k3cloud提交流程

/**
                                    //SaleFBillNo
                                    string SaleFBillNo = jo["Result"]["ResponseStatus"]["SuccessEntitys"][0]["Number"].ToString();
                                    
                                    //获取销售订单id
                                    QueryBuilderParemeter queryParameter = new QueryBuilderParemeter();
                                    queryParameter.BusinessInfo = this.GetBusinessInfo("SAL_SaleOrder");
                                    queryParameter.FilterClauseWihtKey = "FBillNo = '" + SaleFBillNo +"'";
                                    DynamicObject[] SalerObjs = BusinessDataServiceHelper.Load(this.Context,
                                         this.GetBusinessInfo("SAL_SaleOrder").GetDynamicObjectType(), queryParameter);
                                    int SaleerFID = Convert.ToInt32(SalerObjs[0]["id"].ToString());
                                    
                                    //设置自动提交
                                    

                                    var Ids = SalerObjs.Select(p => p["Id"]).ToArray();

                                    object[] pkArray = (from p in SalerObjs
                                                        select p[0]).ToArray();
                                    OperateOption submitOption = OperateOption.Create();
                                    submitOption.SetIgnoreWarning(true);
                                    submitOption.SetIgnoreInteractionFlag(true);
                                    //submitOption.AddInteractionFlag(K3.Core.SCM.SCMConst.MinusCheckSensor);// 跳过负库存校验
                                    
                                    BusinessInfo SalerInfo = this.GetBusinessInfo("SAL_SaleOrder");
? ?? ?? ?? ?                        ISubmitService submitService = ServiceHelper.GetService<ISubmitService>();
                                    IOperationResult submitResult = submitService.Submit(this.Context, SalerInfo,
                                        pkArray, "Submit", submitOption);

                                    if (!submitResult.IsSuccess)
                                    {
                                        IOperationResult DelResult = BusinessDataServiceHelper.Delete(
                                        this.Context,
                                        SalerInfo,
                                        new object[] { SaleerFID });
                                        unaduit(client, FBillNoItem);
                                        string msg = GetErrMsgFromOperationResult("", submitResult);
                                        throw new Exception(msg);
                                    }
                                    **/
                                    // 本演示只提交一张单据,批量处理,请自行修改代码实现
                                    //string formIdtest = this.BusinessInfo.GetForm().Id;
                                    string formId = "SAL_SaleOrder";
                                    //string billId = Convert.ToString(e.DataEntitys[0][0]);
                                    string SaleFBillNoItem = jo["Result"]["ResponseStatus"]["SuccessEntitys"][0]["Number"].ToString();
                                    string billId = jo["Result"]["ResponseStatus"]["SuccessEntitys"][0]["Id"].ToString();
                                    BusinessInfo SalerInfo = this.GetBusinessInfo("SAL_SaleOrder");
                                    //获取销售订单id
                                    QueryBuilderParemeter queryParameter = new QueryBuilderParemeter();
                                    queryParameter.BusinessInfo = SalerInfo;
                                    queryParameter.FilterClauseWihtKey = "FID = '" + billId + "'";
                                    DynamicObject[] SalerObjs = BusinessDataServiceHelper.Load(this.Context,
                                         SalerInfo.GetDynamicObjectType(), queryParameter);
                                    int SaleerFID = Convert.ToInt32(SalerObjs[0]["id"].ToString());
                                    //DynamicObject billObject = e.DataEntitys[0];// 获取单据数据包
                                    var submitContext = this.Context.Clone() as Context;
                                    submitContext.UserId = Convert.ToInt64(SalerObjs[0]["CreatorId_Id"]);
                                    submitContext.UserName = Convert.ToString(((DynamicObject)SalerObjs[0]["CreatorId"])["Name"]);

                                    //submitResult = wfService.ListSubmit(submitContext, this.BusinessInfo, 0, new object[] { billId }, findProcResultList, submitOption);
                                    // 首先判断单据是否已经有未完成的工作流
                                    IProcInstService procInstService = Kingdee.BOS.Workflow.Contracts.ServiceFactory.GetProcInstService(submitContext);
                                    bool isExist = procInstService.CheckUnCompletePrcInstExsit(submitContext, formId, billId);
                                    if (isExist == true)
                                    {
                                        throw new KDBusinessException("AutoSubmit-001", "该单据已经启动了流程,不允许重复提交!");
                                    }

                                    // 读取单据的工作流配置模板
                                    IWorkflowTemplateService wfTemplateService = Kingdee.BOS.Workflow.Contracts.ServiceFactory.GetWorkflowTemplateService(submitContext);
                                    List<FindPrcResult> findProcResultList = wfTemplateService.GetPrcListByFormID(
                                                    formId, new string[] { billId }, submitContext);
                                    if (findProcResultList == null || findProcResultList.Count == 0)
                                    {
                                        throw new KDBusinessException("AutoSubmit-002", "查找单据适用的流程模板失败,不允许提交工作流!");
                                    }

                                    // 设置提交参数:忽略操作过程中的警告,避免与用户交互
                                    OperateOption submitOption = OperateOption.Create();
                                    submitOption.SetIgnoreWarning(true);
                                    IOperationResult submitResult = null;

                                    FindPrcResult findProcResult = findProcResultList[0];
                                    if (findProcResult.Result == TemplateResultType.Error)
                                    {
                                        throw new KDBusinessException("AutoSubmit-003", "单据不符合流程启动条件,不允许提交工作流!");
                                    }
                                    else if (findProcResult.Result != TemplateResultType.Normal)
                                    {// 本单无适用的流程图,直接走传统审批
                                        ISubmitService submitService = ServiceHelper.GetService<ISubmitService>();
                                        submitResult = submitService.Submit(submitContext, SalerInfo,
                                            new object[] { billId }, "Submit", submitOption);
                                    }
                                    else
                                    {// 走工作流
                                        IBOSWorkflowService wfService = Kingdee.BOS.Workflow.Contracts.ServiceFactory.GetBOSWorkflowService(submitContext);
                                        submitResult = wfService.ListSubmit(submitContext, SalerInfo,
                                            0, new object[] { billId }, findProcResultList, submitOption);
                                    }

                                    // 判断提交结果
                                    if (submitResult.IsSuccess == true)
                                    {
                                        // 自动提交成功,显示空操作本身的成功提示即可
                                    }
                                    else
                                    {
                                        /*
                                        submitResult.MergeValidateErrors();
                                        if (submitResult.OperateResult == null)
                                        {// 未知原因导致提交失败
                                            throw new KDBusinessException("AutoSubmit-004", "未知原因导致自动提交失败!");
                                        }
                                        else
                                        {
                                            StringBuilder sb = new StringBuilder();
                                            sb.AppendLine("自动提交失败,失败原因:");
                                            foreach (var operateResult in submitResult.OperateResult)
                                            {
                                                sb.AppendLine(operateResult.Message);
                                            }
                                            throw new KDBusinessException("AutoSubmit-005", sb.ToString());
                                        }
                                         */
                                        IOperationResult DelResult = BusinessDataServiceHelper.Delete(
                                        this.Context,
                                        SalerInfo,
                                        new object[] { SaleerFID });
                                        DeleSale(client, SaleFBillNoItem);
                                        unaduit(client, FBillNoItem);
                                        string msg = GetErrMsgFromOperationResult("", submitResult);
                                        throw new Exception(msg);
                                    }
                                }