I want to iterate over all the published nodes (if it's fast enough (sub 20-30 seconds) then unpublished too) when my application starts and put them in a Dictionary<int, Object>.
I tried a few ways to do this, such as:
1) UmbracoContext.Current.HttpContext: it requires HttpRequest as far as I understand and therefore can't use it on application startup
2) UmbracoApplicationBase -> ContentService: it's too slow (takes at least 2 minutes to iterate)
3) uQuery: even slower than ContentService
4) DynamicNode: it's really fast but gets only the published content (I can live with that..)
Therefore I'm leaning towards using DynamicNode but I've been reading over the internet it's not recommended.
Does anyone have any recommendations how to do such iteration efficientaly?
P.S: I know there are many problems with me putting the nodes inside a dictionary like that (for example after publishing I have to update the dictionary etc.), but let's assume there are no problems for now :)
I have considered Examine but haven't test it just yet.
I tried avoiding parsing the XML file myself since it might get complicated with time when we add new document types, and as far as I understand DynamicNode actually uses the umbraco.config so it's basically doing the exact job I would've done when parsing.
Examine is the best thing for performance, it's 100%. XML parsing it's hard and usefull, try to use Examine or clear Lucene queries to your own index set.
Eventually I reverted to using UmbracoHelper which operates relateively fast (not as fast as I would have wanted though) since it uses umbraco.config.
I am facing another problem now though:
Using 7.1.1.
Via a standalone application, I use ContentService to add nodes to umbraco (I parse a file and add its contents to the system). I perform Save and then Publish and the nodes appear as published in the front-end umbraco and I can see them in the database under cmsContent.
All is good and nice except that ContentService is not updating the xml (cache) umbraco.config and therefore they won't show up neither in the UmbracoHelper nor in cmsContentXml table.
I have read many posts regarding the issue, but none have helped. Some suggested I use UpdateDocumentCache, but it's deprecated and it doesn't solve the problem anyway.
Republishing the entire site doesn't update, neither manually nor via the link dialogs/republish.aspx?xml=true since the data is not in the cache in the first place!
Also, performing library.RefreshContent throws a null exception.
To sum up, I'm confused about two things:
1) Which umbraco.config should be updated? The one in the standalone application's bin/AppData folder or the one in the web project's AppData folder?
2) How do i enforce updating the web project's umbraco.config file.
Thank you in advance
P.S: Let me know if i should open a new post for this..
P.P.S: I'm leaving Examine as a last resort since it's a tad more complicated.
1) In Web.config "umbracoContentXMLUseLocalTemp" was set to True, changing it to False helped in the next step.
2) I started working in a different manner for inserting data:
The standalone application saves the nodes but does not publish them.
As has been said in this post, a standalone application cannot publish content since it's not in webcontext. Therefore I used a solution similar to the one suggested in the second page of this link where I send a HTTP request to my server to publish the nodes by itself.
Iteration over all nodes on application startup
Hi,
I want to iterate over all the published nodes (if it's fast enough (sub 20-30 seconds) then unpublished too) when my application starts and put them in a Dictionary<int, Object>.
I tried a few ways to do this, such as:
1) UmbracoContext.Current.HttpContext: it requires HttpRequest as far as I understand and therefore can't use it on application startup
2) UmbracoApplicationBase -> ContentService: it's too slow (takes at least 2 minutes to iterate)
3) uQuery: even slower than ContentService
4) DynamicNode: it's really fast but gets only the published content (I can live with that..)
Therefore I'm leaning towards using DynamicNode but I've been reading over the internet it's not recommended.
Does anyone have any recommendations how to do such iteration efficientaly?
P.S: I know there are many problems with me putting the nodes inside a dictionary like that (for example after publishing I have to update the dictionary etc.), but let's assume there are no problems for now :)
Thank you in advance,
Giorgio
Left field option 5... Just go direct to the app_data\umbraco.config XML file parse that avoiding any umbraco overheads?
Still only published content though.
Another thought interrogate an examine index?
Thank you for your response.
I have considered Examine but haven't test it just yet.
I tried avoiding parsing the XML file myself since it might get complicated with time when we add new document types, and as far as I understand DynamicNode actually uses the umbraco.config so it's basically doing the exact job I would've done when parsing.
Hi Giorgio,
Examine is the best thing for performance, it's 100%. XML parsing it's hard and usefull, try to use Examine or clear Lucene queries to your own index set.
Examine is created for speed.
http://umbraco.com/follow-us/blog-archive/2011/9/16/examining-examine
https://our.umbraco.org/documentation/Reference/Searching/Examine/
Thanks
Hello,
DynamicNode is the old legacy api. If you want to get published nodes try IPublishedContent.
Jeroen
Thank you for the replies.
Eventually I reverted to using UmbracoHelper which operates relateively fast (not as fast as I would have wanted though) since it uses umbraco.config.
I am facing another problem now though:
Using 7.1.1.
Via a standalone application, I use ContentService to add nodes to umbraco (I parse a file and add its contents to the system). I perform Save and then Publish and the nodes appear as published in the front-end umbraco and I can see them in the database under cmsContent.
All is good and nice except that ContentService is not updating the xml (cache) umbraco.config and therefore they won't show up neither in the UmbracoHelper nor in cmsContentXml table.
I have read many posts regarding the issue, but none have helped. Some suggested I use UpdateDocumentCache, but it's deprecated and it doesn't solve the problem anyway.
Republishing the entire site doesn't update, neither manually nor via the link dialogs/republish.aspx?xml=true since the data is not in the cache in the first place!
Also, performing library.RefreshContent throws a null exception.
To sum up, I'm confused about two things:
1) Which umbraco.config should be updated? The one in the standalone application's bin/AppData folder or the one in the web project's AppData folder?
2) How do i enforce updating the web project's umbraco.config file.
Thank you in advance
P.S: Let me know if i should open a new post for this..
P.P.S: I'm leaving Examine as a last resort since it's a tad more complicated.
Giorgio,
Did you try ApplicationContext.Services.ContentService.SaveAndPublishWithStatus(playerFromUmbraco, 0, false); method?
We are using it for such situations.
Umbraco.config is placed in project AppData folder, not bin.
Thanks
Ok eventually everything worked out:
I'm doing the iteration through UmbracoHelper.
Regarding not updating umbraco.config:
1) In Web.config "umbracoContentXMLUseLocalTemp" was set to True, changing it to False helped in the next step.
2) I started working in a different manner for inserting data:
The standalone application saves the nodes but does not publish them.
As has been said in this post, a standalone application cannot publish content since it's not in webcontext. Therefore I used a solution similar to the one suggested in the second page of this link where I send a HTTP request to my server to publish the nodes by itself.
Thank you everyone for trying to help.
(Is there a way to mark this topic as solved?)
is working on a reply...