i am getting all registered members through ApplicationContext.Current.Services.MemberService.GetAll(0, int.MaxValue, out totalRecords);
and filter records as weekly registered, monthly registered and yearly registered then save them at the backend of Umbraco. But this is slowing down my website.
Is it better to save that at backend when admin clicks the node from backend. Is there any event for node click. I need a solution urgently. As my website going slowly day by day.
Any other solution will be appreciated. Any help !.
Here is the code for saving at the backend:
var members = ApplicationContext.Current.Services.MemberService.GetAll(0, int.MaxValue, out totalRecords);
foreach (var mem in members)
{
var _memberCreateDate = mem.CreateDate;
if (mem.CreateDate >= DateTime.Now.AddDays(-7))
{
_lastWeekRegisters = _lastWeekRegisters + 1;
}
if (mem.CreateDate >= DateTime.Now.AddMonths(-1))
{
_lastMonthRegisters = _lastMonthRegisters + 1;
}
if (mem.CreateDate >= DateTime.Now.AddYears(-1))
{
_lastYearRegisters = _lastYearRegisters + 1;
}
}
var _reportingContainer = ApplicationContext.Current.Services.ContentService;
var newReporting = _reportingContainer.GetById(Convert.ToInt32(1111));
newReporting.SetValue("accountCreatedLastWeek", _lastWeekRegisters);
newReporting.SetValue("accountCreatedMonth", _lastMonthRegisters);
newReporting.SetValue("accountCreatedYear", _lastYearRegisters);
ApplicationContext.Current.Services.ContentService.SaveAndPublishWithStatus(newReporting);
I'm not entirely sure of all the details of your situation, but let me make a few educated guesses.
It seems like you have a specific content node, with ID 1111. You are using that content node as a way of reporting some account creation statistics to somebody that views that content node. You do this by setting a few fields ("accountCreatedLastWeek", "accountCreatedMonth", "accountCreatedYear"). With lots of members now in your site, this calculation is getting slower and slower. My guess is you are performing this calculation in some inappropriate place, such as on each page load.
Your thought is that you can spend less time performing this calculation by only performing it when node 1111 is clicked in the back office. I have an alternative to that solution.
Why not create a property editor that has a button that says "Recalculate Statistics", and that button would change the value of the 3 fields? Alternatively, you can create a dashboard and don't store the information in a content node at all. Or you can still store the information in a content node, but still display the information in the dashboard.
Alternatively, you could create a property editor that doesn't have anything to display. It would simply call an API immediately and update the statistics fields. You'd also have to figure out a way to reload the page after the calculation is done (without running into a situation where you repeatedly reload the page without end).
and for info on AngularJS, there are several good tutorials on YouTube.
Note that there are implications for your xml cache if you change the setting on ContinouslyUpdateXmlDiskCache but I had to because of the size of my site.
Click Event on Content Node click
I need to save a value when admin click the node from backend. Can you tell what event handler will works.
i am getting all registered members through ApplicationContext.Current.Services.MemberService.GetAll(0, int.MaxValue, out totalRecords);
and filter records as weekly registered, monthly registered and yearly registered then save them at the backend of Umbraco. But this is slowing down my website.
Is it better to save that at backend when admin clicks the node from backend. Is there any event for node click. I need a solution urgently. As my website going slowly day by day.
Any other solution will be appreciated. Any help !.
Here is the code for saving at the backend:
var members = ApplicationContext.Current.Services.MemberService.GetAll(0, int.MaxValue, out totalRecords); foreach (var mem in members) { var _memberCreateDate = mem.CreateDate; if (mem.CreateDate >= DateTime.Now.AddDays(-7)) { _lastWeekRegisters = _lastWeekRegisters + 1; } if (mem.CreateDate >= DateTime.Now.AddMonths(-1)) { _lastMonthRegisters = _lastMonthRegisters + 1; } if (mem.CreateDate >= DateTime.Now.AddYears(-1)) { _lastYearRegisters = _lastYearRegisters + 1; } }
any suggestions !!!
Not sure I can help, Alysa, because I have just created my first backoffice plugin, and it hasn't been an easy learning curve.
From what you are describing, it seems like this is a backoffice plugin that you have developed.
Am I correct?
i am just saving the New Registered users at the backend of the Umbraco. and its slow down my website.
How many members are there? How big is your site.
I can't see anything that looks obviously incorrect in the code you posted.
SaveAndPublishWithStatus may be causing the performance issue... try just Save and see if that speeds things up.
Oh, and I had to set
ContinouslyUpdateXmlDiskCache
toFalse
because it was slowing my site.i have till date 600 users and it will increase by the time. I will try to only use " save" method and set ContinouslyUpdateXmlDiskCache to the false.
I'm not entirely sure of all the details of your situation, but let me make a few educated guesses.
It seems like you have a specific content node, with ID 1111. You are using that content node as a way of reporting some account creation statistics to somebody that views that content node. You do this by setting a few fields ("accountCreatedLastWeek", "accountCreatedMonth", "accountCreatedYear"). With lots of members now in your site, this calculation is getting slower and slower. My guess is you are performing this calculation in some inappropriate place, such as on each page load.
Your thought is that you can spend less time performing this calculation by only performing it when node 1111 is clicked in the back office. I have an alternative to that solution.
Why not create a property editor that has a button that says "Recalculate Statistics", and that button would change the value of the 3 fields? Alternatively, you can create a dashboard and don't store the information in a content node at all. Or you can still store the information in a content node, but still display the information in the dashboard.
Alternatively, you could create a property editor that doesn't have anything to display. It would simply call an API immediately and update the statistics fields. You'd also have to figure out a way to reload the page after the calculation is done (without running into a situation where you repeatedly reload the page without end).
Excellent response, Nicholas, and these links helped me build my first backoffice app.
https://github.com/perploug/UkFest-AngularJS-Demo
https://github.com/ViGiLnT/ApproveIt
https://umbraco.github.io/Belle/#/tutorials
and for info on AngularJS, there are several good tutorials on YouTube.
Note that there are implications for your xml cache if you change the setting on
ContinouslyUpdateXmlDiskCache
but I had to because of the size of my site.is working on a reply...