protected void Page_Init(object sender, EventArgs e) { if (Contact == null) { RedirectToAccessDenied(GetString("general.invalidparameters")); } AuthorizationHelper.AuthorizedReadContact(true); // Initialize process selector ucSelector.UniSelector.SelectionMode = SelectionModeEnum.SingleButton; // Check permissions if (WorkflowStepInfoProvider.CanUserStartAutomationProcess(CurrentUser, CurrentSiteName)) { ucSelector.UniSelector.OnItemsSelected += UniSelector_OnItemsSelected; ucSelector.UniSelector.SetValue("IsLiveSite", false); ucSelector.Enabled = true; } else { ucSelector.Enabled = false; } listElem.ObjectID = Contact.ContactID; listElem.ObjectType = ContactInfo.OBJECT_TYPE; listElem.EditActionUrl = "Process_Detail.aspx?stateid={0}"; }
/// <summary> /// Initializes contact selector. /// </summary> private void InitContactSelector() { // Initialize contact selector ucSelector.UniSelector.SelectionMode = SelectionModeEnum.SingleButton; WorkflowInfo process = WorkflowInfoProvider.GetWorkflowInfo(ProcessID); if (process == null) { RedirectToInformation("editedobject.notexists"); } // Check permissions if (WorkflowStepInfoProvider.CanUserStartAutomationProcess(CurrentUser, SiteInfoProvider.GetSiteName(listContacts.SiteID)) && (listContacts.SiteID != UniSelector.US_GLOBAL_AND_SITE_RECORD) && ((process != null) && process.WorkflowEnabled)) { ucSelector.UniSelector.OnItemsSelected += UniSelector_OnItemsSelected; ucSelector.SiteID = listContacts.SiteID; ucSelector.IsLiveSite = false; ucSelector.IsSiteManager = ContactHelper.IsSiteManager; ucSelector.Enabled = true; ucSelector.UniSelector.DialogButton.ToolTipResourceString = "automenu.startstatedesc"; } else { ucSelector.Enabled = false; ucSelector.UniSelector.DialogButton.ToolTipResourceString = process.WorkflowEnabled ? "general.nopermission" : "autoMenu.DisabledStateDesc"; } }
void UniSelector_OnItemsSelected(object sender, EventArgs e) { try { int contactId = ValidationHelper.GetInteger(ucSelector.Value, 0); AutomationManager manager = AutomationManager.GetInstance(CurrentUser); var infoObj = ContactInfoProvider.GetContactInfo(contactId); if (WorkflowStepInfoProvider.CanUserStartAutomationProcess(CurrentUser, SiteInfoProvider.GetSiteName(infoObj.ContactSiteID))) { using (CMSActionContext context = new CMSActionContext()) { context.AllowAsyncActions = false; manager.StartProcess(infoObj, ProcessID); } } } catch (ProcessRecurrenceException ex) { ShowError(ex.Message); } catch (Exception ex) { LogAndShowError("Automation", "STARTPROCESS", ex); } listContacts.ReloadData(); pnlUpdate.Update(); }
protected void Page_Load(object sender, EventArgs e) { if (!IsAuthorized()) { RedirectToAccessDenied(GetString("general.nopermission")); } // Initialize contact selector ucSelector.UniSelector.SelectionMode = SelectionModeEnum.SingleButton; ucSelector.UniSelector.ButtonImage = GetImageUrl("/Objects/MA_AutomationState/add.png"); // Check permissions if (WorkflowStepInfoProvider.CanUserStartAutomationProcess(CurrentUser, SiteInfoProvider.GetSiteName(Contact.ContactSiteID))) { ucSelector.UniSelector.OnItemsSelected += UniSelector_OnItemsSelected; ucSelector.UniSelector.DialogImage.CssClass = "NewItemImage"; ucSelector.UniSelector.DialogLink.CssClass = "MenuItemEdit"; ucSelector.UniSelector.SetValue("SiteID", SiteID); ucSelector.UniSelector.SetValue("IsLiveSite", false); ucSelector.IsSiteManager = ContactHelper.IsSiteManager; ucSelector.Enabled = true; } else { ucSelector.Enabled = false; ucSelector.UniSelector.DialogImage.CssClass = "NewItemImageDisabled"; ucSelector.UniSelector.DialogLink.CssClass = "MenuItemEditDisabled"; } listElem.ObjectID = Contact.ContactID; listElem.ObjectType = PredefinedObjectType.CONTACT; listElem.EditActionUrl = "Process_Detail.aspx?stateid={0}" + (IsSiteManager ? "&issitemanager=1" : String.Empty); }
private void UniSelector_OnItemsSelected(object sender, EventArgs e) { var contacts = ValidationHelper.GetString(ucSelector.Value, null); if (String.IsNullOrEmpty(contacts) || !WorkflowStepInfoProvider.CanUserStartAutomationProcess(CurrentUser, CurrentSiteName)) { return; } var contactIds = contacts.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries).Select(i => ValidationHelper.GetInteger(i, 0)); var manager = AutomationManager.GetInstance(CurrentUser); var processId = UIContext.ObjectID; var warningBuilder = new StringBuilder(); using (CMSActionContext context = new CMSActionContext { AllowAsyncActions = false }) { try { foreach (var contactId in contactIds) { var contact = ContactInfo.Provider.Get(contactId); try { manager.StartProcess(contact, processId); } catch (ProcessRecurrenceException ex) { warningBuilder.AppendFormat("<div>{0}</div>", ex.Message); } } } catch (Exception ex) { LogAndShowError("Automation", "STARTPROCESS", ex); return; } } var warning = warningBuilder.ToString(); if (!String.IsNullOrEmpty(warning)) { ShowWarning(String.Format(GetString("sf.automation.error"), ""), warning); } else { ShowConfirmation(GetString("ma.process.startedselected")); } // Reload grid listContacts.ReloadData(); pnlUpdate.Update(); // Reset selector ucSelector.Value = null; }
/// <summary> /// Initializes contact selector. /// </summary> private void InitContactSelector() { // Initialize contact selector ucSelector.UniSelector.SelectionMode = SelectionModeEnum.MultipleButton; ucSelector.UniSelector.DialogButton.ResourceString = "om.contact.general.additems"; // Check permissions if (WorkflowStepInfoProvider.CanUserStartAutomationProcess(CurrentUser, CurrentSiteName) && Process.WorkflowEnabled) { ucSelector.UniSelector.OnItemsSelected += UniSelector_OnItemsSelected; ucSelector.Enabled = true; ucSelector.UniSelector.DialogButton.ToolTipResourceString = "ma.automationprocess.addcontacts.tooltip"; ucSelector.UniSelector.DialogInformationMessage = GetString("ma.automationprocess.startprocessinfo"); } else { ucSelector.Enabled = false; ucSelector.UniSelector.DialogButton.ToolTipResourceString = Process.WorkflowEnabled ? "general.nopermission" : "autoMenu.DisabledStateDesc"; } }
/// <summary> /// Initializes contact selector. /// </summary> private void InitContactSelector() { // Initialize contact selector ucSelector.UniSelector.SelectionMode = SelectionModeEnum.SingleButton; ucSelector.UniSelector.ButtonImage = GetImageUrl("/Objects/MA_AutomationState/add.png"); // Check permissions if (WorkflowStepInfoProvider.CanUserStartAutomationProcess(CurrentUser, SiteInfoProvider.GetSiteName(listContacts.SiteID)) && (listContacts.SiteID != UniSelector.US_GLOBAL_OR_SITE_RECORD)) { ucSelector.UniSelector.OnItemsSelected += UniSelector_OnItemsSelected; ucSelector.UniSelector.DialogImage.CssClass = "NewItemImage"; ucSelector.UniSelector.DialogLink.CssClass = "MenuItemEdit"; ucSelector.SiteID = listContacts.SiteID; ucSelector.IsLiveSite = false; ucSelector.IsSiteManager = ContactHelper.IsSiteManager; ucSelector.Enabled = true; } else { ucSelector.Enabled = false; ucSelector.UniSelector.DialogImage.CssClass = "NewItemImageDisabled"; ucSelector.UniSelector.DialogLink.CssClass = "MenuItemEditDisabled"; } }
protected void Page_Load(object sender, EventArgs e) { // Get edited object (contact group) if (CMSContext.EditedObject != null) { currentUser = CMSContext.CurrentUser; cgi = (ContactGroupInfo)CMSContext.EditedObject; siteID = cgi.ContactGroupSiteID; // Check permissions readSiteContacts = ContactHelper.AuthorizedReadContact(CMSContext.CurrentSiteID, false); modifySiteContacts = ContactHelper.AuthorizedModifyContact(CMSContext.CurrentSiteID, false); modifySiteCG = ContactGroupHelper.AuthorizedModifyContactGroup(CMSContext.CurrentSiteID, false); if (siteID <= 0) { readGlobalContacts = ContactHelper.AuthorizedReadContact(UniSelector.US_GLOBAL_RECORD, false); modifyGlobalContacts = ContactHelper.AuthorizedModifyContact(UniSelector.US_GLOBAL_RECORD, false); modifyGlobalCG = ContactGroupHelper.AuthorizedModifyContactGroup(UniSelector.US_GLOBAL_RECORD, false); } // Setup unigrid gridElem.WhereCondition = GetWhereCondition(); gridElem.OnAction += new OnActionEventHandler(gridElem_OnAction); gridElem.ZeroRowsText = GetString("om.contact.nocontacts"); gridElem.OnBeforeDataReload += new OnBeforeDataReload(gridElem_OnBeforeDataReload); gridElem.OnExternalDataBound += new OnExternalDataBoundEventHandler(gridElem_OnExternalDataBound); modifyCombined = // Site contact group -> only site Contacts can be added ((siteID > 0) && (modifySiteContacts || modifySiteCG)) // Global contact group -> both site and global Contacts can be added || ((siteID <= 0) && ( // User can display only global Contacts (readGlobalContacts && !readSiteContacts && (modifyGlobalContacts || modifyGlobalCG)) || // User can display only site Contacts (readSiteContacts && !readGlobalContacts && (modifySiteContacts || modifySiteCG)) || // User can display both site and global Contacts (readSiteContacts && readGlobalContacts && (modifySiteCG || modifySiteContacts) && (modifyGlobalCG || modifyGlobalContacts)) )); if (!string.IsNullOrEmpty(cgi.ContactGroupDynamicCondition)) { // Set specific confirmation to remove grid action CMS.UIControls.UniGridConfig.Action removeAction = (CMS.UIControls.UniGridConfig.Action)gridElem.GridActions.Actions[1]; removeAction.Confirmation = "$om.contactgroupmember.confirmremove$"; } // Initialize dropdown lists if (!RequestHelper.IsPostBack()) { // Display mass actions if (modifyCombined) { drpAction.Items.Add(new ListItem(GetString("general." + Action.SelectAction), Convert.ToInt32(Action.SelectAction).ToString())); drpAction.Items.Add(new ListItem(GetString("general.remove"), Convert.ToInt32(Action.Remove).ToString())); drpWhat.Items.Add(new ListItem(GetString("om.contact." + What.Selected), Convert.ToInt32(What.Selected).ToString())); drpWhat.Items.Add(new ListItem(GetString("om.contact." + What.All), Convert.ToInt32(What.All).ToString())); } } else { if (RequestHelper.CausedPostback(btnOk)) { // Set delayed reload for unigrid if mass action is performed gridElem.DelayedReload = true; } } // Initialize contact selector contactSelector.UniSelector.ButtonImage = GetImageUrl("/Objects/OM_Contact/add.png"); contactSelector.UniSelector.DialogImage.CssClass = "NewItemImage"; contactSelector.UniSelector.DialogLink.CssClass = "MenuItemEdit"; contactSelector.UniSelector.OnItemsSelected += UniSelector_OnItemsSelected; contactSelector.UniSelector.SelectionMode = SelectionModeEnum.MultipleButton; // Initialize contact selector processSelector.UniSelector.SelectionMode = SelectionModeEnum.SingleButton; processSelector.UniSelector.ButtonImage = GetImageUrl("/Objects/MA_AutomationState/add.png"); // Check permissions if (WorkflowStepInfoProvider.CanUserStartAutomationProcess(CurrentUser, SiteInfoProvider.GetSiteName(siteID))) { processSelector.UniSelector.SelectionConfirmation = GetString("ma.process.startgroupconfirmation"); processSelector.UniSelector.OnItemsSelected += Process_OnItemsSelected; processSelector.UniSelector.DialogImage.CssClass = "NewItemImage"; processSelector.UniSelector.DialogLink.CssClass = "MenuItemEdit"; processSelector.UniSelector.SetValue("SiteID", siteID); processSelector.IsSiteManager = ContactHelper.IsSiteManager; processSelector.Enabled = true; } else { processSelector.Enabled = false; processSelector.UniSelector.DialogImage.CssClass = "NewItemImageDisabled"; processSelector.UniSelector.DialogLink.CssClass = "MenuItemEditDisabled"; } // Register JS scripts RegisterScripts(); } else { StopProcessing = true; } }