示例#1
0
    /// <summary>
    /// Saves users data
    /// </summary>
    private void SaveUsersData()
    {
        // Remove old items
        string newValues = ValidationHelper.GetString(usUsers.Value, null);
        string items     = DataHelper.GetNewItemsInList(newValues, currentUsers);

        if (!String.IsNullOrEmpty(items))
        {
            string[] newItems = items.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            if (newItems != null)
            {
                // Add all new items to site
                foreach (string item in newItems)
                {
                    int userId = ValidationHelper.GetInteger(item, 0);
                    // If user is authorized, remove it
                    WorkflowUserInfo wsu = WorkflowUserInfoProvider.GetWorkflowUserInfo(WorkflowID, userId);
                    if (wsu != null)
                    {
                        WorkflowUserInfoProvider.DeleteWorkflowUserInfo(wsu);
                    }
                }
            }
        }

        // Add new items
        items = DataHelper.GetNewItemsInList(currentUsers, newValues);
        if (!String.IsNullOrEmpty(items))
        {
            string[] newItems = items.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            if (newItems != null)
            {
                // Add all new items to site
                foreach (string item in newItems)
                {
                    int userId = ValidationHelper.GetInteger(item, 0);

                    // If user is not authorized, authorize it
                    if (WorkflowUserInfoProvider.GetWorkflowUserInfo(WorkflowID, userId) == null)
                    {
                        WorkflowUserInfoProvider.AddUserToWorkflow(WorkflowID, userId);
                    }
                }
            }
        }
    }
示例#2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (WorkflowID <= 0)
        {
            StopProcessing = true;
            return;
        }

        usUsers.ObjectType     = UserInfo.OBJECT_TYPE;
        usUsers.WhereCondition = "(UserIsHidden = 0 OR UserIsHidden IS NULL)";

        ucApprove.TemplateType       = WorkflowModule.WORKFLOW_EMAIL_TEMPLATE_TYPE_NAME;
        ucReadyApproval.TemplateType = WorkflowModule.WORKFLOW_EMAIL_TEMPLATE_TYPE_NAME;
        ucReject.TemplateType        = WorkflowModule.WORKFLOW_EMAIL_TEMPLATE_TYPE_NAME;
        ucPublish.TemplateType       = WorkflowModule.WORKFLOW_EMAIL_TEMPLATE_TYPE_NAME;
        ucArchive.TemplateType       = WorkflowModule.WORKFLOW_EMAIL_TEMPLATE_TYPE_NAME;
        ucNotif.TemplateType         = WorkflowModule.WORKFLOW_EMAIL_TEMPLATE_TYPE_NAME;

        // Get the active users for this site
        var users = WorkflowUserInfoProvider.GetWorkflowUsers("WorkflowID = " + WorkflowID, null, 0, "UserID").Select <WorkflowUserInfo, string>(u => u.UserID.ToString());

        currentUsers = string.Join(";", users.ToArray());

        chkEmails.NotSetChoice.Text = GetString("general.usesitesettings") + " (##DEFAULT##)";
        chkEmails.SetDefaultValue(WorkflowHelper.SendWorkflowEmails(SiteContext.CurrentSiteName));
        chkEmails.AutoPostBack    = true;
        chkEmails.CheckedChanged += SendNotification_Changed;

        ucApprove.CurrentSelector.TextBoxSelect.WatermarkText       = WorkflowHelper.GetDefaultEmailTemplateName(WorkflowEmailTypeEnum.Approved);
        ucReadyApproval.CurrentSelector.TextBoxSelect.WatermarkText = WorkflowHelper.GetDefaultEmailTemplateName(WorkflowEmailTypeEnum.ReadyForApproval);
        ucReject.CurrentSelector.TextBoxSelect.WatermarkText        = WorkflowHelper.GetDefaultEmailTemplateName(WorkflowEmailTypeEnum.Rejected);
        ucArchive.CurrentSelector.TextBoxSelect.WatermarkText       = WorkflowHelper.GetDefaultEmailTemplateName(WorkflowEmailTypeEnum.Archived);
        ucPublish.CurrentSelector.TextBoxSelect.WatermarkText       = WorkflowHelper.GetDefaultEmailTemplateName(WorkflowEmailTypeEnum.Published);
        ucNotif.CurrentSelector.TextBoxSelect.WatermarkText         = WorkflowHelper.GetDefaultEmailTemplateName(WorkflowEmailTypeEnum.Notification);

        chkApprove.CheckedChanged       += chkApprove_CheckedChanged;
        chkReadyApproval.CheckedChanged += chkReadyApproval_CheckedChanged;
        chkReject.CheckedChanged        += chkReject_CheckedChanged;
        chkArchive.CheckedChanged       += chkArchive_CheckedChanged;
        chkPublish.CheckedChanged       += chkPublish_CheckedChanged;

        if (!RequestHelper.IsPostBack())
        {
            chkEmails.InitFromThreeStateValue(Workflow, "WorkflowSendEmails");
            usUsers.Value         = currentUsers;
            ucApprove.Value       = Workflow.WorkflowApprovedTemplateName;
            ucReadyApproval.Value = Workflow.WorkflowReadyForApprovalTemplateName;
            ucReject.Value        = Workflow.WorkflowRejectedTemplateName;
            ucArchive.Value       = Workflow.WorkflowArchivedTemplateName;
            ucPublish.Value       = Workflow.WorkflowPublishedTemplateName;
            ucNotif.Value         = Workflow.WorkflowNotificationTemplateName;

            ucApprove.Enabled       = chkApprove.Checked = Workflow.WorkflowSendApproveEmails;
            ucReadyApproval.Enabled = chkReadyApproval.Checked = Workflow.WorkflowSendReadyForApprovalEmails;
            ucReject.Enabled        = chkReject.Checked = Workflow.WorkflowSendRejectEmails;
            ucArchive.Enabled       = chkArchive.Checked = Workflow.WorkflowSendArchiveEmails;
            ucPublish.Enabled       = chkPublish.Checked = Workflow.WorkflowSendPublishEmails;

            pnlTemplates.Enabled = pnlUsers.Enabled = usUsers.Enabled = ValidationHelper.GetBoolean(chkEmails.GetActualValue(), true);
        }

        bool documents = Workflow.IsDocumentWorkflow;

        plcApprove.Visible = documents;
        plcRest.Visible    = documents;
    }