Пример #1
0
        protected override void DoCommand(IOrderGroup order, CommandParameters cp)
        {
            Mediachase.Ibn.Web.UI.CHelper.RequireDataBind();
            var purchaseOrder   = order as PurchaseOrder;
            var workflowResults = OrderGroupWorkflowManager.RunWorkflow(purchaseOrder, "SaveChangesWorkflow",
                                                                        false,
                                                                        //false,
                                                                        new Dictionary <string, object>
            {
                {
                    "PreventProcessPayment",
                    !string.IsNullOrEmpty(order.Properties["QuoteStatus"] as string) &&
                    (order.Properties["QuoteStatus"].ToString() == Constant.Quote.RequestQuotation ||
                     order.Properties["QuoteStatus"].ToString() == Constant.Quote.RequestQuotationFinished)
                }
            });

            if (workflowResults.Status != WorkflowStatus.Completed)
            {
                var msg = "Unknow error";
                if (workflowResults.Exception != null)
                {
                    msg = workflowResults.Exception.Message;
                }

                ErrorManager.GenerateError(msg);
            }
            else
            {
                WriteOrderChangeNotes(purchaseOrder);
                SavePurchaseOrderChanges(purchaseOrder);
                OrderHelper.ExitPurchaseOrderFromEditMode(purchaseOrder.OrderGroupId);
            }

            var warnings = OrderGroupWorkflowManager.GetWarningsFromWorkflowResult(workflowResults);

            if (warnings.Any())
            {
                CommandHandlerHelper.ShowStatusMessage(string.Join(", ", warnings), CommandManager);
            }
        }