예제 #1
0
    void Process_OnItemsSelected(object sender, EventArgs e)
    {
        try
        {
            int processId             = ValidationHelper.GetInteger(processSelector.Value, 0);
            AutomationManager manager = AutomationManager.GetInstance(CurrentUser);

            ContactGroupContactListInfo listInfo = new ContactGroupContactListInfo();
            var contacts = listInfo.Generalized.GetData(null, GetWhereCondition(), null, 0, "ContactID", false);
            if (!DataHelper.DataSourceIsEmpty(contacts))
            {
                string error = null;
                using (CMSActionContext context = new CMSActionContext())
                {
                    context.AllowAsyncActions = false;
                    foreach (DataRow row in contacts.Tables[0].Rows)
                    {
                        // Get contact
                        int contactId = ValidationHelper.GetInteger(row[0], 0);
                        var contact   = ContactInfoProvider.GetContactInfo(contactId);

                        try
                        {
                            // Start process
                            manager.StartProcess(contact, processId);
                        }
                        catch (ProcessRecurrenceException ex)
                        {
                            error += ex.Message + "<br />";
                        }
                    }
                }

                if (string.IsNullOrEmpty(error))
                {
                    ShowConfirmation(GetString("ma.process.started"));
                }
                else
                {
                    ShowError(GetString("ma.process.error"), error, null);
                }
            }
        }
        catch (Exception ex)
        {
            LogAndShowError("Automation", "STARTPROCESS", ex);
        }

        gridElem.ReloadData();
        pnlUpdate.Update();
    }
    void Process_OnItemsSelected(object sender, EventArgs e)
    {
        try
        {
            int processId = ValidationHelper.GetInteger(processSelector.Value, 0);
            AutomationManager manager = AutomationManager.GetInstance(CurrentUser);

            ContactGroupContactListInfo listInfo = new ContactGroupContactListInfo();
            var contacts = listInfo.Generalized.GetData(null, GetWhereCondition(), null, 0, "ContactID", false);
            if (!DataHelper.DataSourceIsEmpty(contacts))
            {
                string error = null;
                using (CMSActionContext context = new CMSActionContext())
                {
                    context.AllowAsyncActions = false;
                    foreach (DataRow row in contacts.Tables[0].Rows)
                    {
                        // Get contact
                        int contactId = ValidationHelper.GetInteger(row[0], 0);
                        var contact = ContactInfoProvider.GetContactInfo(contactId);

                        try
                        {
                            // Start process
                            manager.StartProcess(contact, processId);
                        }
                        catch (ProcessRecurrenceException ex)
                        {
                            error += ex.Message + "<br />";
                        }
                    }
                }

                if (string.IsNullOrEmpty(error))
                {
                    ShowConfirmation(GetString("ma.process.started"));
                }
                else
                {
                    ShowError(GetString("ma.process.error"), error, null);
                }
            }
        }
        catch (Exception ex)
        {
            LogAndShowError("Automation", "STARTPROCESS", ex);
        }

        gridElem.ReloadData();
        pnlUpdate.Update();
    }