Whats the problem?

Mar 12, 2014 at 7:02 PM
Hi! Anyone know why the data (users, newsletters) are stored in the xlm file and not on the bd of sqlserver . In the web.config file I have the configuration:

" <BlogEngine>
<blogProvider defaultProvider="DbBlogProvider" fileStoreProvider="XmlBlogProvider">
  <providers>
    <add description="Xml Blog Provider" name="XmlBlogProvider" type="BlogEngine.Core.Providers.XmlBlogProvider, BlogEngine.Core" />
    <add connectionStringName="BlogEngine" description="Sql Database Provider" name="DbBlogProvider" type="BlogEngine.Core.Providers.DbBlogProvider, BlogEngine.Core" />
  < / providers>
</ blogProvider >
<blogFileSystemProvider defaultProvider="XmlBlogProvider">
  <providers>
    <add description="Xml Blog Provider" name="XmlBlogProvider" type="BlogEngine.Core.Providers.XmlFileSystemProvider, BlogEngine.Core" />
    <add storageVariable="BlogEngine" description="Sql Database Provider" name="DbBlogProvider" type="BlogEngine.Core.Providers.DbFileSystemProvider, BlogEngine.Core" />
    < - <add storageVariable="\\UNCPath\BlogFiles" description="UNC Path Provider" name="UNCBlogProvider" type="BlogEngine.Core.Providers.UNCFileSystemProvider, BlogEngine.Core" /> ->
  < / providers>
</ blogFileSystemProvider >
< / BlogEngine >
<connectionStrings>
<clear />
<add name="BlogEngine" connectionString="Server=.\SQLEXPRESS;Database=be2014;Trusted_Connection=True;" providerName="System.Data.SqlClient" />
! <- <add name = " BlogEngine " connectionString = "Data Source = localhost; User ID = usernmae ; Password = password; persist security info = False ; initial catalog = BlogEngineFileStore ; " providerName = " System.Data.SqlClient " / > ->
< / connectionStrings >
"
I await your response <BlogEngine>
<blogProvider defaultProvider="DbBlogProvider" fileStoreProvider="XmlBlogProvider">
  <providers>
    <add description="Xml Blog Provider" name="XmlBlogProvider" type="BlogEngine.Core.Providers.XmlBlogProvider, BlogEngine.Core" />
    <add connectionStringName="BlogEngine" description="Sql Database Provider" name="DbBlogProvider" type="BlogEngine.Core.Providers.DbBlogProvider, BlogEngine.Core" />
  < / providers>
</ blogProvider >
<blogFileSystemProvider defaultProvider="XmlBlogProvider">
  <providers>
    <add description="Xml Blog Provider" name="XmlBlogProvider" type="BlogEngine.Core.Providers.XmlFileSystemProvider, BlogEngine.Core" />
    <add storageVariable="BlogEngine" description="Sql Database Provider" name="DbBlogProvider" type="BlogEngine.Core.Providers.DbFileSystemProvider, BlogEngine.Core" />
    < - <add storageVariable="\\UNCPath\BlogFiles" description="UNC Path Provider" name="UNCBlogProvider" type="BlogEngine.Core.Providers.UNCFileSystemProvider, BlogEngine.Core" /> ->
  < / providers>
</ blogFileSystemProvider >
< / BlogEngine >
<connectionStrings>
<clear />
<add name="BlogEngine" connectionString="Server=.\SQLEXPRESS;Database=be2014;Trusted_Connection=True;" providerName="System.Data.SqlClient" />
! <- <add name = " BlogEngine " connectionString = "Data Source = localhost; User ID = usernmae ; Password = password; persist security info = False ; initial catalog = BlogEngineFileStore ; " providerName = " System.Data.SqlClient " / > ->
< / connectionStrings >

Thanks

Carles
Mar 13, 2014 at 5:09 PM
Edited Mar 13, 2014 at 5:25 PM
Hi Carles,

To have everything in the database you need to do a search and replace the following:

XmlBlogProvider with --> DbBlogProvider


These two elements I think is what needs to be changed:


<blogFileSystemProvider defaultProvider="DbBlogProvider"> <--- Data files like newsletter will be stored in database
<membership defaultProvider="DbBlogProvider"> <--- Users will be stored in database
Mar 14, 2014 at 3:02 AM
According to the 2.9 upgrade instuctions you need to add a third to the list kbdavis gave you.
roleManager defaultProvider="XmlRoleProvider" -> roleManager defaultProvider="DbRoleProvider"
Mar 14, 2014 at 4:00 PM
Thanks, works everything but the newletter, not stored in the db.
I have noticed that when you click on the button "Notify me" do not save the email
in the xml file or in the database making the changes you propose, even sample notice Thanks.

Carles
Mar 14, 2014 at 7:00 PM
Hi CarlesAntoli,

The changes to the web.config should not effect the newsletter since it is hardcoded to save to the newsletter.xml file.

Why it stopped working when switching to database provider is a mystery.

I am working on the Newsletter widget for another issue:

Discussion:
https://blogengine.codeplex.com/discussions/535636


Will add changing everything to database as a test too.

In the widget.ascx.cs file has the following:

fileName = Path.Combine(Blog.CurrentInstance.StorageLocation, "newsletter.xml");

Maybe changing

fileStoreProvider="XmlBlogProvider">

to

DbBlogProvider


Is the issue?
Mar 14, 2014 at 7:19 PM
Hi kbDavis and leemicw

I also assumed that was the problem, why the bd doubt there is a table "be_PostNotify" prepared to keep records newsletter. Not a major problema

in my case but it is a hassle when managing emails. I am very happy with the performance of BlogEngine, have you done a very good job of programming

and design, front and good weekend.

Carles
Mar 21, 2014 at 3:43 PM
Was this fixed? Saving to the newsletter.xml file is not an option for me at we have our blog on two servers and depending on what server the visitor is on, the xml files would be out of sync. That is why we went to a database with the blog. Is there new version of the newsletter widget that I can upload or complete instructions on updating the current widget to write and read from a DB?

thanks in advance,

Ron
Mar 21, 2014 at 6:06 PM
Hi Ron,

As far as I know the Newsletter widget "as-is" can only save the email addresses to the newsletter.xml file.

If you are in a hurry to get it to save to your database then you would have to modify the Newsletter widget to save to database instead of xml file.


Here is a starting point:

https://blogengine.codeplex.com/SourceControl/latest#BlogEngine/BlogEngine.NET/widgets/Newsletter/widget.ascx.cs


File: /widgets/Newsletter/widget.ascx.cs
private void AddEmail(string email)
        {
            try
            {
                lock (syncRoot)
                {
                    if (!Utils.IsEmailValid(email)) { return; }
                    email = email.Trim();

                    LoadEmails();

                    if (!DoesEmailExist(email))
                    {

                       /////////////// Repace XML code below with database code///////////////////
                        XmlNode node = docs[Blog.CurrentInstance.Id].CreateElement("email");                  
                        node.InnerText = email;
                        docs[Blog.CurrentInstance.Id].FirstChild.AppendChild(node);
                       /////////////////////////////////////////////////////////////////////////////////////////

                        callback = "true";
                        SaveEmails();
                    }
                    else
                    {

                        /////////////// Repace XML code below with database code///////////////////
                        var emailNode = docs[Blog.CurrentInstance.Id].SelectSingleNode(string.Format("emails/email[text()='{0}']", email));
                        if (emailNode != null)
                        {
                            docs[Blog.CurrentInstance.Id].FirstChild.RemoveChild(emailNode);
                        }
                       //////////////////////////////////////////////////////////////////////////////////////////

                        callback = "false";
                        SaveEmails();
                    }
                }
            }
            catch
            {
                callback = "false";
            }
        }

        #endregion
Then you do the same through out the widget code.


Or if you can wait I am in the works of creating a mailing list manager for BlogEngine.Net and it will save all emails and others things
to a database instead of xml.

It is going to be a month or so till that is in a workable condition.


If you can't wait and don't won't to edit the widget yourself then you can contact me directly at:




Kbdavis07@yahoo.com We can work something out if needed.




Have a great day!



Brian Davis

http://www.BloggersOnline.com
Mar 21, 2014 at 6:43 PM
Brian,
Thank you, I will wait for your update, please keep me informed.

thanks again,

Ron