public string GetHTMLDayInMonthView(string date, Options options, int startHour, int hour)
        {
            if ((HttpContext.Current.Request.UserLanguages != null) &&
                     (!String.IsNullOrEmpty(HttpContext.Current.Request.UserLanguages[0])))
                {
                    Utilities.SetCurrentCulture(HttpContext.Current.Request.UserLanguages[0]);
                }

             var moduleSettings = new ModuleSettings(options.SiteSettingsPath);
             Item site_settings = moduleSettings.GetSettingsItem();

             Item settingsItem = moduleSettings.GetActiveDatabase().GetItem(options.ControlSettingsPath);

             var stringWriter = new StringWriter();
             var writer = new HtmlTextWriter(stringWriter);

             MonthView view;
             if (Utilities.IsTemplateSettingsEqual(settingsItem, site_settings,
                                               ModuleSettings.MonthViewField))
             {
            view = new MonthView(options.CalendarID, settingsItem, options.SiteSettingsPath);
             }
             else
             {
            view = new MonthView(options.CalendarID, moduleSettings.MonthViewSettings,
                                 options.SiteSettingsPath);
            view.SetSettings(settingsItem, options.SiteSettingsPath);
             }

             view.IsReinitNeed = true;
             view.Attributes["startHour"] = startHour.ToString();
             view.Attributes["numHours"] = hour.ToString();
             view.CurrentDate = Utilities.StringToDate(options.Date);

             view.RenderDayCell(writer, Utilities.StringToDate(date));
             return stringWriter.ToString();
        }
        public string GetViewHTML(int num, int startHour, string viewName, string currentView,
                                int hour, Options options)
        {
            if ((HttpContext.Current.Request.UserLanguages != null) &&
                     (!String.IsNullOrEmpty(HttpContext.Current.Request.UserLanguages[0])))
                {
                    Utilities.SetCurrentCulture(HttpContext.Current.Request.UserLanguages[0]);
                }

             var stringWriter = new StringWriter();
             var writer = new HtmlTextWriter(stringWriter);
             if (num > -1)
             {
            writer.Write(string.Format("<calendarNum>{0}</calendarNum>", num));
             }

             var moduleSettings = new ModuleSettings(options.SiteSettingsPath);
             Item site_settings = moduleSettings.GetSettingsItem();
             Item settingsItem = moduleSettings.GetActiveDatabase().GetItem(options.ControlSettingsPath);

             if (viewName == "day")
             {
            if (HttpContext.Current.Session[options.CalendarID] == null)
            {
               HttpContext.Current.Session.Add(options.CalendarID, currentView);
            }

            DayView view;
            if (Utilities.IsTemplateSettingsEqual(settingsItem, site_settings,
                                                  ModuleSettings.DayViewField))
            {
               view = new DayView(options.CalendarID, settingsItem, options.SiteSettingsPath);
            }
            else
            {
               view = new DayView(options.CalendarID, moduleSettings.DayViewSettings,
                                  options.SiteSettingsPath);
               view.SetSettings(settingsItem, options.SiteSettingsPath);
            }
            view.IsReinitNeed = true;

            view.CurrentDate = Utilities.StringToDate(options.Date);
            if (startHour > -1)
            {
               view.NumHoursDisplayed = hour;
               view.StartHour = startHour;
            }
            view.RenderControl(writer);
             }
             else
             {
            if (HttpContext.Current.Session[options.CalendarID] != null)
            {
               HttpContext.Current.Session.Remove(options.CalendarID);
            }

            if (viewName == "week")
            {
               WeekView view;
               if (Utilities.IsTemplateSettingsEqual(settingsItem, site_settings,
                                                     ModuleSettings.WeekViewField))
               {
                  view = new WeekView(options.CalendarID, settingsItem, options.SiteSettingsPath);
               }
               else
               {
                  view = new WeekView(options.CalendarID, moduleSettings.WeekViewSettings,
                                      options.SiteSettingsPath);
                  view.SetSettings(settingsItem, options.SiteSettingsPath);
               }
               view.IsReinitNeed = true;
               view.CurrentDate = Utilities.StringToDate(options.Date);
               if (startHour > -1)
               {
                  view.NumHoursDisplayed = hour;
                  view.StartHour = startHour;
               }
               view.RenderControl(writer);
            }
            else if (viewName == "month")
            {
               MonthView view;
               if (Utilities.IsTemplateSettingsEqual(settingsItem, site_settings,
                                                     ModuleSettings.MonthViewField))
               {
                  view = new MonthView(options.CalendarID, settingsItem, options.SiteSettingsPath);
               }
               else
               {
                  view = new MonthView(options.CalendarID, moduleSettings.MonthViewSettings,
                                       options.SiteSettingsPath);
                  view.SetSettings(settingsItem, options.SiteSettingsPath);
               }
               view.IsReinitNeed = true;
               view.CurrentDate = Utilities.StringToDate(options.Date);
               view.Attributes["startHour"] = startHour.ToString();
               view.Attributes["numHours"] = hour.ToString();
               view.RenderControl(writer);
            }
            else if (viewName == "agenda")
            {
               settingsItem = (viewName == currentView)
                                 ? settingsItem : moduleSettings.AgendaViewSettings;
               var view = new AgendaView(options.CalendarID, settingsItem, options.SiteSettingsPath);
               view.CurrentDate = Utilities.StringToDate(options.Date);
               view.RenderControl(writer);
            }
             }

             return stringWriter.ToString();
        }