/// <summary> /// Returns object query of automation states for my pending contacts which can be used as datasource for unigrid. /// </summary> /// <param name="user">User for whom pending contacts are shown</param> /// <param name="contactsWhereCondition">Where condition for filtering contacts</param> private ObjectQuery <AutomationStateInfo> GetPendingContacts(UserInfo user, string contactsWhereCondition) { // Get complete where condition for pending steps var condition = WorkflowStepInfoProvider.GetAutomationPendingStepsWhereCondition(user, SiteContext.CurrentSiteID); // Get automation steps specified by condition with permission control var automationWorkflowSteps = WorkflowStepInfoProvider.GetWorkflowSteps() .Where(condition) .Column("StepID") .WhereEquals("StepWorkflowType", (int)WorkflowTypeEnum.Automation); // Get all pending contacts from automation state where status is Pending and current user is the owner var allPendingContacts = AutomationStateInfoProvider.GetAutomationStates() .WhereIn("StateStepID", automationWorkflowSteps) .WhereEquals("StateStatus", (int)ProcessStatusEnum.Pending) .WhereEquals("StateObjectType", ContactInfo.OBJECT_TYPE); var contactIDs = ContactInfoProvider.GetContacts() .Column("ContactID") .Where(contactsWhereCondition); if (ShowOnlyMyPendingContacts) { contactIDs.WhereEquals("ContactOwnerUserID", user.UserID); } return(allPendingContacts.WhereIn("StateObjectID", contactIDs.AsMaterializedList("ContactID"))); }
private void gridState_OnAction(string actionName, object actionArgument) { switch (actionName.ToLowerCSafe()) { case "delete": int stateId = ValidationHelper.GetInteger(actionArgument, 0); AutomationManager manager = AutomationManager.GetInstance(CurrentUser); var obj = CMSObjectHelper.GetObjectById(ObjectType, ObjectID); var state = AutomationStateInfoProvider.GetAutomationStateInfo(stateId); manager.RemoveProcess(obj, state); break; } }
protected void listElem_OnAction(string actionName, object actionArgument) { switch (actionName) { case "delete": var stateID = ValidationHelper.GetInteger(actionArgument, 0); if (stateID > 0) { if (mCanRemoveAutomationProcesses) { var stateInfo = AutomationStateInfoProvider.GetAutomationStateInfo(stateID); AutomationStateInfoProvider.DeleteAutomationStateInfo(stateInfo); } } break; } }
protected void listElem_OnAction(string actionName, object actionArgument) { switch (actionName) { case "delete": var stateID = ValidationHelper.GetInteger(actionArgument, 0); if (stateID > 0) { var stateInfo = AutomationStateInfoProvider.GetAutomationStateInfo(stateID); if ((stateInfo != null) && WorkflowStepInfoProvider.CanUserRemoveAutomationProcess(CurrentUser, SiteInfoProvider.GetSiteName(stateInfo.StateSiteID))) { AutomationStateInfoProvider.DeleteAutomationStateInfo(stateInfo); } } break; } }
/// <summary> /// Remove contact from process. Called when the "Remove contact from process" button is pressed. /// Expects the CreateAutomationState method to be run first. /// </summary> private bool RemoveContactFromProcess() { // Get dataset of contacts string where = "ContactLastName LIKE N'My New Contact%'"; int topN = 1; var contacts = ContactInfoProvider.GetContacts().Where(where).TopN(topN); // Get the process WorkflowInfo process = WorkflowInfoProvider.GetWorkflowInfo("MyNewProcess", WorkflowTypeEnum.Automation); if (DataHelper.DataSourceIsEmpty(contacts) || (process == null)) { return(false); } // Get the contact from dataset ContactInfo contact = contacts.First <ContactInfo>(); // Get the instance of automation manager AutomationManager manager = AutomationManager.GetInstance(CurrentUser); // Get the states var states = AutomationStateInfoProvider.GetAutomationStates() .WhereEquals("StateWorkflowID", process.WorkflowID) .WhereEquals("StateObjectID", contact.ContactID) .WhereEquals("StateObjectType", PredefinedObjectType.CONTACT); if (states.Any()) { // Loop through the individual items foreach (AutomationStateInfo state in states) { // Remove contact from process manager.RemoveProcess(contact, state); } return(true); } return(false); }
private void gridState_OnAction(string actionName, object actionArgument) { switch (actionName.ToLowerCSafe()) { case "delete": int stateId = ValidationHelper.GetInteger(actionArgument, 0); var obj = BaseAbstractInfoProvider.GetInfoById(ObjectType, ObjectID); var state = AutomationStateInfoProvider.GetAutomationStateInfo(stateId); if (!CurrentUser.IsAuthorizedPerResource(ModuleName.ONLINEMARKETING, "RemoveProcess", SiteInfoProvider.GetSiteName(state.StateSiteID))) { RedirectToAccessDenied(ModuleName.ONLINEMARKETING, "RemoveProcess"); } AutomationManager manager = AutomationManager.GetInstance(CurrentUser); manager.RemoveProcess(obj, state); break; } }
/// <summary> /// Remove contact from process. Called when the "Remove contact from process" button is pressed. /// Expects the CreateAutomationState method to be run first. /// </summary> private bool RemoveContactFromProcess() { // Get dataset of contacts string where = "ContactLastName LIKE N'My New Contact%'"; int topN = 1; InfoDataSet <ContactInfo> contacts = ContactInfoProvider.GetContacts(where, null, topN, null); // Get the process WorkflowInfo process = WorkflowInfoProvider.GetWorkflowInfo("MyNewProcess", WorkflowTypeEnum.Automation); if (!DataHelper.DataSourceIsEmpty(contacts) && (process != null)) { // Get the contact from dataset ContactInfo contact = contacts.First <ContactInfo>(); // Get the instance of automation manager AutomationManager manager = AutomationManager.GetInstance(CurrentUser); // Prepare the parameters where = "StateWorkflowID = " + process.WorkflowID + " AND StateObjectID = " + contact.ContactID + " AND StateObjectType = '" + PredefinedObjectType.CONTACT + "'"; // Get the states InfoDataSet <AutomationStateInfo> states = AutomationStateInfoProvider.GetStates(where, null); if (!DataHelper.DataSourceIsEmpty(states)) { // Loop through the individual items foreach (AutomationStateInfo state in states) { // Remove contact from process manager.RemoveProcess(contact, state); } return(true); } } return(false); }