This is a migrated thread and some comments may be shown as answers.

slow performans of Radscheduler , please check my code

2 Answers 71 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
shashidhar ch
Top achievements
Rank 1
shashidhar ch asked on 20 Aug 2010, 11:46 AM
Hi,

when i am loading around 1000 to 2000 event , radscheduler geting very slow.
we are written functionality to retrive the recurring event from the data base by reading the rule.
but it is very slow.

check the below code . can you please give me some idea. what's worng with my code.

in future there may around lakhs of appointments. what can we do if we want to improve the performance.

Thanking you
Shashi

   private void BindFamilyCalender()
        {
            string memberIDList = string.Empty;
            for (int counter = 0; counter < dlMyFamily.Items.Count; counter++)
            {
                CheckBox chkMember = (CheckBox)dlMyFamily.Items[counter].FindControl("chkMember");
                HiddenField hdMemberID = (HiddenField)dlMyFamily.Items[counter].FindControl("HidMemberID");
                if ((chkMember != null) && (chkMember.Checked == true))
                {
                    if (memberIDList.Equals(""))
                        memberIDList += hdMemberID.Value;
                    else
                        memberIDList += "," + hdMemberID.Value;
                }
            }
            int FamilyID = Convert.ToInt32(Session["FamilyID"].ToString());
            if (!string.IsNullOrEmpty(memberIDList))
            {
                Members members = qest.BusinessLogic.Member.SelectAllFamilyMembersByFamilyID1(FamilyID, memberIDList);
                RadCalenders radcals = new RadCalenders();
                RadCalenders radcals1 = new RadCalenders();
                RadCalenders radcals2 = new RadCalenders();
                radcals = AddAppointmentByType("2");  

                for (int i = 0; i < members.Count; i++)
                {

                    foreach (MemberCalendar memcal in MemberCalendarBase.GetFamilyMembersAppointmentsByFamilyIDMemberID(FamilyID, Convert.ToInt32(members[i].MemberID)))
                    {
                       
                        if ((members[i].FamilyMember.IsSharedCalenderWithFamily == true && memcal.IsConfidential == false) || Convert.ToInt32(Session["MemberID"].ToString()) == memcal.MemberID || (members[i].FamilyMember.IsSharedCalenderWithFamily == false && memcal.SpecialAppointment != 0))
                        {
                            RadCalender radcal = new RadCalender();
                            radcal.ID = memcal.MemberID;
                            radcal.StartDate = memcal.ApptStartDate.Value;
                            radcal.EndDate = memcal.ApptEndDate.Value;

                            radcal.Content = memcal.ApptContent;
                            radcal.RecurrenceRule = memcal.RecurrenceRule;
                            radcal.RecurrenceParentKey = Convert.ToInt32(memcal.MemberID);
                            radcal.MCID = memcal.MemberCalendarID;
                            if (members[i].FamilyMember.Color.ToString() != "")
                            {
                                radcal.Color = Convert.ToInt32(members[i].FamilyMember.Color);
                            }
                            radcal.IsAdmin = members[i].FamilyMember.IsAdmin.ToString();
                            radcal.Fullname = members[i].FirstName.ToString();                       
                            if (memcal.IsRepeating == true)
                            { radcal.IsRepeating = true; }
                            else
                            { radcal.IsRepeating = false; }

                            radcal.RecurrencePattern = memcal.RecurrencePattern;
                            radcal.RepeatingInterval = memcal.RepeatingInterval;
                            radcal.EventAssociated = memcal.EventAssociated;
                            radcal.Description = memcal.Description;
                            radcal.street = memcal.Street;
                            radcal.city = memcal.City;
                            radcal.state = memcal.State;
                            radcal.zip = memcal.Zip;
                            radcal.IsConfidential = (bool)memcal.IsConfidential; 
                            radcal.Types = 1;
                            radcal.SpecialAppointment = Convert.ToInt32(memcal.SpecialAppointment);

                            if (memcal.RecurrenceRule != "" && memcal.RecurrenceRule != null)
                            {
                                #region Reading recurrence rule for MemberCalener
                                RadCalender radcalRec;
                                Appointment recurringAppointment = new Appointment(radcal.ID, Convert.ToDateTime(memcal.ApptStartDate.Value),
                                Convert.ToDateTime(memcal.ApptEndDate.Value), radcal.Content, radcal.RecurrenceRule);

                                RecurrenceRange range = new RecurrenceRange();
                                range.Start = recurringAppointment.Start;
                                range.EventDuration = recurringAppointment.End - recurringAppointment.Start;

                                if (memcal.maxocc.ToString() != "")
                                {
                                    range.MaxOccurences = Convert.ToInt32(memcal.maxocc);
                                }
                                else
                                {
                                    range.MaxOccurences = 1;
                                }

                                string rruleAsString = "";
                                int DayOfMonth = 0;
                                int pIntervel;

                                if (recurringAppointment.RecurrenceRule.Contains("HOURLY") == true)      
                                {
                                    if (memcal.RepeatingInterval != "")
                                    {
                                        pIntervel = Convert.ToInt32(memcal.RepeatingInterval);

                                    }
                                    else
                                    {
                                        pIntervel = 1;

                                    }
                                    HourlyRecurrenceRule rrule = new HourlyRecurrenceRule(pIntervel, range);
                                    rruleAsString = rrule.ToString();

                                    foreach (DateTime occurrence in rrule.Occurrences)
                                    {
                                        radcalRec = new RadCalender();
                                        string pEndDate = (Convert.ToDateTime(occurrence.ToString()) + range.EventDuration).ToString();
                                        radcalRec.ID = memcal.MemberID;
                                        radcalRec.StartDate = occurrence;
                                        radcalRec.EndDate = Convert.ToDateTime(pEndDate);
                                        radcalRec.Content = memcal.ApptContent;
                                        radcalRec.RecurrenceParentKey = Convert.ToInt32(memcal.MemberID);
                                        radcalRec.MCID = memcal.MemberCalendarID;
                                        radcalRec.Types = 1;

                                        if (members[i].FamilyMember.Color.ToString() != "")
                                        {
                                            radcalRec.Color = Convert.ToInt32(members[i].FamilyMember.Color);
                                        }
                                        radcalRec.IsAdmin = members[i].FamilyMember.IsAdmin.ToString();
                                        radcalRec.Fullname = members[i].FirstName.ToString();

                                        radcalRec.RecurrencePattern = memcal.RecurrencePattern;
                                        radcalRec.RepeatingInterval = memcal.RepeatingInterval;
                                        radcalRec.EventAssociated = memcal.EventAssociated;
                                        radcalRec.Description = memcal.Description;
                                        radcalRec.street = memcal.Street;
                                        radcalRec.city = memcal.City;
                                        radcalRec.state = memcal.State;
                                        radcalRec.zip = memcal.Zip;
                                        radcalRec.IsConfidential = (bool)memcal.IsConfidential;
                                        if (memcal.maxocc.ToString() != "")
                                        {
                                            radcalRec.Maxocc = Convert.ToInt32(memcal.maxocc);
                                        }
                                        else
                                        {
                                            radcalRec.Maxocc = 1;
                                        }

                                        radcals.Add(radcalRec);
                                        radcals2.Add(radcalRec);
                                    }
                                }
                                if (recurringAppointment.RecurrenceRule.Contains("DAILY") == true)          // FOR DAILY APPOINTMENTS
                                {
                                    if (memcal.RepeatingInterval != "")
                                    {
                                        pIntervel = Convert.ToInt32(memcal.RepeatingInterval);
                                    }
                                    else
                                    {
                                        pIntervel = 1;
                                    }

                                    DailyRecurrenceRule rrule = new DailyRecurrenceRule(pIntervel, range);
                                    rruleAsString = rrule.ToString();
                                    hidRRule.Value = rruleAsString;
                                    foreach (DateTime occurrence in rrule.Occurrences)
                                    {
                                        radcalRec = new RadCalender();
                                        string pEndDate = (Convert.ToDateTime(occurrence.ToString()) + range.EventDuration).ToString();
                                        radcalRec.ID = memcal.MemberID;
                                        radcalRec.StartDate = occurrence;
                                        radcalRec.EndDate = Convert.ToDateTime(pEndDate);
                                        radcalRec.Content = memcal.ApptContent;
                                        radcalRec.RecurrenceParentKey = Convert.ToInt32(memcal.MemberID);
                                        radcalRec.MCID = memcal.MemberCalendarID;
                                        radcalRec.Types = 1;
                                        if (members[i].FamilyMember.Color.ToString() != "")
                                        {
                                            radcalRec.Color = Convert.ToInt32(members[i].FamilyMember.Color);
                                        }
                                        radcalRec.IsAdmin = members[i].FamilyMember.IsAdmin.ToString();
                                        radcalRec.Fullname = members[i].FirstName.ToString();
                                        radcalRec.RecurrencePattern = memcal.RecurrencePattern;
                                        radcalRec.RepeatingInterval = memcal.RepeatingInterval;
                                        radcalRec.EventAssociated = memcal.EventAssociated;
                                        radcalRec.Description = memcal.Description;
                                        radcalRec.street = memcal.Street;
                                        radcalRec.city = memcal.City;
                                        radcalRec.state = memcal.State;
                                        radcalRec.zip = memcal.Zip;
                                        radcalRec.IsConfidential = (bool)memcal.IsConfidential; 
                                        if (memcal.maxocc.ToString() != "")
                                        {
                                            radcalRec.Maxocc = Convert.ToInt32(memcal.maxocc);
                                        }
                                        else
                                        {
                                            radcalRec.Maxocc = 1;
                                        }
                                        radcals.Add(radcalRec);
                                        radcals2.Add(radcalRec);
                                    }
                                }
                                if (recurringAppointment.RecurrenceRule.Contains("YEARLY") == true)            
                                {
                                    int MonthOfDay = 0;
                                    if (memcal.monthday.ToString() != "")
                                    {
                                        MonthOfDay = Convert.ToInt32(memcal.monthday);
                                    }
                                    else
                                    {
                                        MonthOfDay = 1;
                                    }
                                    if (memcal.RepeatingInterval.ToString() != "")
                                    {
                                        // 21st May 2010 new code
                                        // new code on 21st May 2010 for early recurrence rule.
                                        string MonthIndex = memcal.RepeatingInterval.ToString();
                                        RecurrenceMonth MonthMask = RecurrenceMonth.None;
                                        switch (MonthIndex)
                                        {
                                            case "1":
                                                MonthMask |= RecurrenceMonth.January;
                                                break;
                                            case "2":
                                                MonthMask |= RecurrenceMonth.February;
                                                break;
                                            case "3":
                                                MonthMask |= RecurrenceMonth.March;
                                                break;
                                            case "4":
                                                MonthMask |= RecurrenceMonth.April;
                                                break;
                                            case "5":
                                                MonthMask |= RecurrenceMonth.May;
                                                break;
                                            case "6":
                                                MonthMask |= RecurrenceMonth.June;
                                                break;
                                            case "7":
                                                MonthMask |= RecurrenceMonth.July;
                                                break;
                                            case "8":
                                                MonthMask |= RecurrenceMonth.August;
                                                break;
                                            case "9":
                                                MonthMask |= RecurrenceMonth.September;
                                                break;
                                            case "10":
                                                MonthMask |= RecurrenceMonth.October;
                                                break;
                                            case "11":
                                                MonthMask |= RecurrenceMonth.November;
                                                break;
                                            case "12":
                                                MonthMask |= RecurrenceMonth.December;
                                                break;
                                            default:
                                                MonthMask |= RecurrenceMonth.January;
                                                break;
                                        }
                                        YearlyRecurrenceRule yrrule = new YearlyRecurrenceRule(MonthMask, MonthOfDay, range);
                                        rruleAsString = yrrule.ToString();
                                        foreach (DateTime occurrence in yrrule.Occurrences)
                                        {
                                            radcalRec = new RadCalender();
                                            string pEndDate = (Convert.ToDateTime(occurrence.ToString()) + range.EventDuration).ToString();
                                            radcalRec.ID = memcal.MemberID;
                                            radcalRec.StartDate = occurrence;
                                            radcalRec.EndDate = Convert.ToDateTime(pEndDate);
                                            radcalRec.Content = memcal.ApptContent;
                                            radcalRec.RecurrenceParentKey = Convert.ToInt32(memcal.MemberID);
                                            radcalRec.MCID = memcal.MemberCalendarID;
                                            radcalRec.Types = 1;
                                            if (memcal.monthday.ToString() != "")
                                            {
                                                radcalRec.Monthday = Convert.ToInt32(memcal.monthday);
                                            }
                                            else
                                            {
                                                radcalRec.Monthday = 1;
                                            }
                                            if (members[i].FamilyMember.Color.ToString() != "")
                                            {
                                                radcalRec.Color = Convert.ToInt32(members[i].FamilyMember.Color);
                                            }

                                            radcalRec.IsAdmin = members[i].FamilyMember.IsAdmin.ToString();
                                            radcalRec.Fullname = members[i].FirstName.ToString();

                                            radcalRec.RecurrencePattern = memcal.RecurrencePattern;
                                            radcalRec.RepeatingInterval = memcal.RepeatingInterval;
                                            radcalRec.EventAssociated = memcal.EventAssociated;
                                            radcalRec.Description = memcal.Description;
                                            radcalRec.street = memcal.Street;
                                            radcalRec.city = memcal.City;
                                            radcalRec.state = memcal.State;
                                            radcalRec.zip = memcal.Zip;
                                            radcalRec.SpecialAppointment = Convert.ToInt32(memcal.SpecialAppointment);
                                            radcalRec.IsConfidential = (bool)memcal.IsConfidential;
                                            if (memcal.maxocc.ToString() != "")
                                            {
                                                radcalRec.Maxocc = Convert.ToInt32(memcal.maxocc);
                                            }
                                            else
                                            {
                                                radcalRec.Maxocc = 1;
                                            }

                                            radcals.Add(radcalRec);
                                            radcals2.Add(radcalRec);

                                        }
                                    }
                                }

                                #endregion
                            }
                            else
                            {
                                radcals.Add(radcal);
                                radcals2.Add(radcal);

                            }

                        }

                    }

                }
                radcals1 = BindHolidayCalender1();
                foreach (qest.WebUI.RadCalender objRadCal in radcals1)
                {
                    radcals2.Add(objRadCal);
                }

                radMyScheduler.DataSource = radcals2;
                radMyScheduler.DataBind();
            }
            else
            {
                return;
            }
          
        }

2 Answers, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 24 Aug 2010, 02:58 PM
Hello shashidhar ch,

I suggest you try the general top performance tips:
http://www.telerik.com/products/aspnet-ajax/resources/top-performance.aspx

You can also consider Web Service binding which provides significant performance improvement for some cases and the Optimized Queries approach.

Greetings,
Peter
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
shashidhar ch
Top achievements
Rank 1
answered on 26 Aug 2010, 02:56 PM
Hi,

i have seen the code  by opening the url.
i am not understood the total functionalities and how it works.
if you have , can you please send me the sample code project  zip file.
then i can directly open the project and check the code.

is the above code is correct ?  am i on right track ?
Greetings,
Shashidhar Ch
Tags
Scheduler
Asked by
shashidhar ch
Top achievements
Rank 1
Answers by
Peter
Telerik team
shashidhar ch
Top achievements
Rank 1
Share this question
or