Ejemplo n.º 1
0
        public void StoreLocations()
        {
            SelectedLocation.Clear();
            var lstLocations = new ArrayList();

            if (Settings.Enablelocations == EventModuleSettings.DisplayLocations.SingleSelect)
            {
                lstLocations.Add(ddlLocations.SelectedValue);
            }
            else
            {
                if (ddlLocations.CheckedItems.Count > 0 && ddlLocations.CheckedItems.Count != ddlLocations.Items.Count)
                {
                    foreach (var item in ddlLocations.CheckedItems)
                    {
                        lstLocations.Add(item.Value);
                    }
                }
                else
                {
                    lstLocations.Add("-1");
                }
            }
            SelectedLocation = lstLocations;
        }
Ejemplo n.º 2
0
        private void Page_Load(object sender, EventArgs e)
        {
            try
            {
                // Add the external Validation.js to the Page
                const string csname = "ExtValidationScriptFile";
                var          cstype = MethodBase.GetCurrentMethod().GetType();
                var          cstext = "<script src=\"" + ResolveUrl("~/DesktopModules/Events/Scripts/Validation.js") +
                                      "\" type=\"text/javascript\"></script>";
                if (!Page.ClientScript.IsClientScriptBlockRegistered(csname))
                {
                    Page.ClientScript.RegisterClientScriptBlock(cstype, csname, cstext, false);
                }

                ddlLocations.EmptyMessage = Localization.GetString("NoLocations", LocalResourceFile);
                ddlLocations.Localization.AllItemsCheckedString =
                    Localization.GetString("AllLocations", LocalResourceFile);
                ddlLocations.Localization.CheckAllString =
                    Localization.GetString("SelectAllLocations", LocalResourceFile);
                if (Settings.Enablelocations == EventModuleSettings.DisplayLocations.SingleSelect)
                {
                    ddlLocations.CheckBoxes = false;
                }

                if (!Page.IsPostBack)
                {
                    //Bind DDL
                    var ctrlEventLocations = new EventLocationController();
                    var lstLocations       = ctrlEventLocations.EventsLocationList(PortalId);

                    var arrLocations = new ArrayList();
                    if (Settings.Restrictlocations)
                    {
                        foreach (EventLocationInfo dbLocation in lstLocations)
                        {
                            foreach (int location in Settings.ModuleLocationIDs)
                            {
                                if (dbLocation.Location == location)
                                {
                                    arrLocations.Add(dbLocation);
                                }
                            }
                        }
                    }
                    else
                    {
                        arrLocations.AddRange(lstLocations);
                    }

                    if (lstLocations.Count == 0)
                    {
                        Visible = false;
                        SelectedLocation.Clear();
                        return;
                    }

                    //Restrict locations by events in time frame.
                    if (Settings.RestrictLocationsToTimeFrame)
                    {
                        //Only for list view.
                        var whichView = string.Empty;
                        if (!(Request.QueryString["mctl"] == null) && ModuleId ==
                            Convert.ToInt32(Request.QueryString["ModuleID"]))
                        {
                            if (Request["mctl"].EndsWith(".ascx"))
                            {
                                whichView = Request["mctl"];
                            }
                            else
                            {
                                whichView = Request["mctl"] + ".ascx";
                            }
                        }
                        if (whichView.Length == 0)
                        {
                            if (!ReferenceEquals(
                                    Request.Cookies.Get("DNNEvents" + Convert.ToString(ModuleId)), null))
                            {
                                whichView = Request.Cookies.Get("DNNEvents" + Convert.ToString(ModuleId)).Value;
                            }
                            else
                            {
                                whichView = Settings.DefaultView;
                            }
                        }

                        if (whichView == "EventList.ascx" || whichView == "EventRpt.ascx")
                        {
                            var objEventInfoHelper =
                                new EventInfoHelper(ModuleId, TabId, PortalId, Settings);
                            var lstEvents = default(ArrayList);

                            var getSubEvents = Settings.MasterEvent;
                            var numDays      = Settings.EventsListEventDays;
                            var displayDate  = default(DateTime);
                            var startDate    = default(DateTime);
                            var endDate      = default(DateTime);
                            if (Settings.ListViewUseTime)
                            {
                                displayDate = DisplayNow();
                            }
                            else
                            {
                                displayDate = DisplayNow().Date;
                            }
                            if (Settings.EventsListSelectType == "DAYS")
                            {
                                startDate = displayDate.AddDays(Settings.EventsListBeforeDays * -1);
                                endDate   = displayDate.AddDays(Settings.EventsListAfterDays * 1);
                            }
                            else
                            {
                                startDate = displayDate;
                                endDate   = displayDate.AddDays(numDays);
                            }

                            lstEvents = objEventInfoHelper.GetEvents(startDate, endDate, getSubEvents,
                                                                     new ArrayList(Convert.ToInt32(new[] { "-1" })),
                                                                     new ArrayList(Convert.ToInt32(new[] { "-1" })), -1,
                                                                     -1);

                            var eventLocationIds = new ArrayList();
                            foreach (EventInfo lstEvent in lstEvents)
                            {
                                eventLocationIds.Add(lstEvent.Location);
                            }
                            foreach (EventLocationInfo lstLocation in lstLocations)
                            {
                                if (!eventLocationIds.Contains(lstLocation.Location))
                                {
                                    arrLocations.Remove(lstLocation);
                                }
                            }
                        }
                    }

                    //Bind locations.
                    ddlLocations.DataSource = arrLocations;
                    ddlLocations.DataBind();

                    if (Settings.Enablelocations == EventModuleSettings.DisplayLocations.SingleSelect)
                    {
                        ddlLocations.Items.Insert(
                            0,
                            new RadComboBoxItem(Localization.GetString("AllLocations", LocalResourceFile),
                                                "-1"));
                        ddlLocations.SelectedIndex = 0;
                    }
                    ddlLocations.OnClientDropDownClosed =
                        "function() { btnUpdateClick('" + btnUpdate.UniqueID + "','" + ddlLocations.ClientID +
                        "');}";
                    ddlLocations.OnClientLoad = "function() { storeText('" + ddlLocations.ClientID + "');}";
                    if (Settings.Enablelocations == EventModuleSettings.DisplayLocations.SingleSelect)
                    {
                        foreach (int location in SelectedLocation)
                        {
                            ddlLocations.SelectedIndex =
                                ddlLocations.FindItemByValue(location.ToString()).Index;
                            break;
                        }
                    }
                    else
                    {
                        foreach (int location in SelectedLocation)
                        {
                            foreach (RadComboBoxItem item in ddlLocations.Items)
                            {
                                if (item.Value == location.ToString())
                                {
                                    item.Checked = true;
                                }
                            }
                        }

                        if (Convert.ToInt32(SelectedLocation[0]) == -1)
                        {
                            foreach (RadComboBoxItem item in ddlLocations.Items)
                            {
                                item.Checked = true;
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
                //ProcessModuleLoadException(Me, exc)
            }
        }