/// <summary> /// Invokes the specified sender. /// </summary> /// <param name="sender">The sender.</param> /// <param name="element">The element.</param> public void Invoke(object sender, object element) { if (element is CommandParameters) { CommandParameters cp = (CommandParameters)element; WorkflowDefinition work = null; int error = 0; string errorMessage = String.Empty; try { work = WorkflowConfiguration.Instance.GetWorkflow(cp.CommandName); Guid customerGuid = ManagementHelper.GetGuidFromQueryString("customerid"); int orderid = ManagementHelper.GetIntFromQueryString("id"); ProcessWorkflowCommand(cp.CommandName, orderid, customerGuid, ManagementHelper.GetValueFromQueryString("class", "")); } catch (Exception ex) { error++; errorMessage = ex.Message; } if (error > 0) { errorMessage = errorMessage.Replace("'", "\\'").Replace(Environment.NewLine, "\\n"); ClientScript.RegisterStartupScript(((Control)sender).Page, ((Control)sender).Page.GetType(), Guid.NewGuid().ToString("N"), String.Format("CSManagementClient.SetSaveStatus('Failed to process workflow command \"{0}\". Error: {1}');", work.DisplayName, errorMessage), true); } else { ClientScript.RegisterStartupScript(((Control)sender).Page, ((Control)sender).Page.GetType(), Guid.NewGuid().ToString("N"), String.Format("CSManagementClient.SetSaveStatus('Successfully completed \"{0}\". Make sure to save the order before proceeding.');", work.DisplayName), true); } } }
/// <summary> /// Invokes the specified sender. /// </summary> /// <param name="sender">The sender.</param> /// <param name="element">The element.</param> public void Invoke(object sender, object element) { if (element is CommandParameters) { CommandParameters cp = (CommandParameters)element; int error = 0; string errorMessage = String.Empty; try { Guid customerGuid = ManagementHelper.GetGuidFromQueryString("customerid"); int orderid = ManagementHelper.GetIntFromQueryString("id"); ProcessCreateCommand(orderid, customerGuid); } catch (Exception ex) { error++; errorMessage = ex.Message; } if (error > 0) { errorMessage = errorMessage.Replace("'", "\\'").Replace(Environment.NewLine, "\\n"); ClientScript.RegisterStartupScript(((Control)sender).Page, ((Control)sender).Page.GetType(), Guid.NewGuid().ToString("N"), String.Format("CSManagementClient.SetSaveStatus('{0}{1}');", "Failed to create Purchase Order. Error: ", errorMessage), true); } else { ClientScript.RegisterStartupScript(((Control)sender).Page, ((Control)sender).Page.GetType(), Guid.NewGuid().ToString("N"), String.Format("CSManagementClient.SetSaveStatus('Successfully created purchase order');"), true); } } }
/// <summary> /// Invokes the specified sender. /// </summary> /// <param name="sender">The sender.</param> /// <param name="element">The element.</param> public void Invoke(object sender, object element) { if (element is CommandParameters) { CommandParameters cp = (CommandParameters)element; int error = 0; int numEmails = 0; string errorMessage = String.Empty; try { Guid customerGuid = ManagementHelper.GetGuidFromQueryString("customerid"); int orderid = ManagementHelper.GetIntFromQueryString("id"); numEmails = ProcessNotificationCommand(orderid, customerGuid, ManagementHelper.GetValueFromQueryString("class", "")); } catch (Exception ex) { LogManager.GetLogger(GetType()).Error("Order Notification Error.", ex); error++; errorMessage = ex.Message; } if (error > 0) { errorMessage = errorMessage.Replace("'", "\\'").Replace(Environment.NewLine, "\\n"); ClientScript.RegisterStartupScript(((Control)sender).Page, ((Control)sender).Page.GetType(), Guid.NewGuid().ToString("N"), String.Format("CSManagementClient.SetSaveStatus('{0}{1} Check log for more details.');", "Failed to send notification. Error: ", errorMessage), true); } else { ClientScript.RegisterStartupScript(((Control)sender).Page, ((Control)sender).Page.GetType(), Guid.NewGuid().ToString("N"), String.Format("CSManagementClient.SetSaveStatus('Successfully sent {0} notifications');", numEmails.ToString()), true); } } }