Esempio n. 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        siteSelector.DropDownSingleSelect.AutoPostBack = true;
        siteSelector.UniSelector.OnSelectionChanged   += new EventHandler(DropDownSingleSelect_OnSelectionChanged);
        siteSelector.AllowGlobal           = true;
        siteSelector.AllowAll              = false;
        siteSelector.AllowSetSpecialFields = true;

        // Check site manager or cms desk
        if (SiteID != 0)
        {
            pnlSite.Visible       = false;
            listElem.SiteID       = SiteID;
            listElem.SiteQueryUrl = "&SiteID=" + SiteID;
        }
        else
        {
            if (!RequestHelper.IsPostBack())
            {
                siteSelector.Value = (SelectedSiteID != 0) ? SelectedSiteID.ToString() : siteSelector.GlobalRecordValue;
            }

            if (ValidationHelper.GetString(siteSelector.Value, String.Empty) != siteSelector.GlobalRecordValue)
            {
                listElem.SiteID       = siteSelector.SiteID;
                SelectedSiteID        = siteSelector.SiteID;
                listElem.SiteQueryUrl = "&SelectedSiteID=" + SelectedSiteID;
            }
            else
            {
                // (global) picked - set selectedID as 0 (used in new link generation)
                SelectedSiteID = 0;
            }
        }

        // New membership initialization
        HeaderActions.AddAction(new HeaderAction()
        {
            Text          = GetString("membership.membership.new"),
            ImageUrl      = GetImageUrl("Objects/CMS_Membership/add.png"),
            OnClientClick = "AddNewItem();"
        });

        // Set the actions
        ICMSMasterPage master = CurrentMaster;

        // Set the title
        PageTitle title = master.Title;

        title.TitleText     = GetString("membership.membership.list");
        title.TitleImage    = GetImageUrl("Objects/CMS_Membership/object.png");
        title.HelpTopicName = "membership_list";
        title.HelpName      = "helpTopic";

        listElem.OnCheckPermissions += new CMSAdminControl.CheckPermissionsEventHandler(membershipListElem_OnCheckPermissions);
    }
Esempio n. 2
0
    /// <summary>
    /// Handles the UniGrid's OnAction event.
    /// </summary>
    /// <param name="actionName">Name of item (button) that threw event</param>
    /// <param name="actionArgument">ID (value of Primary key) of corresponding data row</param>
    protected void UniGridTasks_OnAction(string actionName, object actionArgument)
    {
        switch (actionName.ToLower())
        {
        case "edit":

            URLHelper.Redirect("Task_Edit.aspx?taskname=" + actionArgument.ToString() + "&" + GetSiteOrSelectedSite());

            break;

        case "delete":
        {
            // Check "modify" permission
            if (!CMSContext.CurrentUser.IsAuthorizedPerResource("CMS.ScheduledTasks", "Modify"))
            {
                RedirectToAccessDenied("CMS.ScheduledTasks", "Modify");
            }

            // Delete the task
            try
            {
                int taskId = Convert.ToInt32(actionArgument);

                TaskInfo ti = TaskInfoProvider.GetTaskInfo(taskId);
                if (ti != null)
                {
                    ti.Generalized.LogSynchronization = SynchronizationTypeEnum.LogSynchronization;
                    ti.Generalized.LogIntegration     = true;
                    ti.Generalized.LogEvents          = true;
                    TaskInfoProvider.DeleteTaskInfo(ti);
                }
            }
            catch (Exception ex)
            {
                lblError.Visible = true;
                lblError.Text    = GetString("Task_List.DeleteError") + " Original exception: " + ex.Message;
            }
        }
        break;

        case "execute":
        {
            // Check "modify" permission
            if (!CMSContext.CurrentUser.IsAuthorizedPerResource("CMS.ScheduledTasks", "Modify"))
            {
                RedirectToAccessDenied("CMS.ScheduledTasks", "Modify");
            }

            TaskInfo ti = TaskInfoProvider.GetTaskInfo(Convert.ToInt32(actionArgument));
            if (ti != null)
            {
                if (ti.TaskEnabled)
                {
                    TaskInterval interval = new TaskInterval();
                    interval = SchedulingHelper.DecodeInterval(ti.TaskInterval);

                    if ((ti.TaskNextRunTime != DateTimeHelper.ZERO_TIME) || (interval.Period == SchedulingHelper.PERIOD_ONCE))
                    {
                        ti.TaskNextRunTime = DateTime.Now;

                        // Update the task
                        TaskInfoProvider.SetTaskInfo(ti);

                        // Run the task
                        SchedulingTimer.RunSchedulerImmediately = true;
                        if (si != null)
                        {
                            SchedulingTimer.SchedulerRunImmediatelySiteName = si.SiteName;
                        }

                        string url = URLHelper.Url.AbsoluteUri;
                        url = URLHelper.AddParameterToUrl(url, "selectedsiteid", SelectedSiteID.ToString());

                        lblInfo.Text    = GetString("ScheduledTask.WasExecuted");
                        lblInfo.Visible = true;

                        //ScriptHelper.RegisterStartupScript(this, typeof(string), "InformExecuted",
                        //        "alert('" + GetString("ScheduledTask.WasExecuted") + "'); \n" +
                        //        "document.location = '" + url + "'; \n", true);
                    }
                    else
                    {
                        lblInfo.Text    = GetString("ScheduledTask.TaskAlreadyrunning");
                        lblInfo.Visible = true;
                    }
                }
                else
                {
                    lblError.Text    = GetString("ScheduledTask.TaskNotEnabled");
                    lblError.Visible = true;
                }
            }
        }
        break;
        }
    }