Exemple #1
0
        /// <summary>
        /// 获取预发起FormMode
        /// </summary>
        /// <param name="formInput"></param>
        /// <param name="k2Id"></param>
        /// <param name="userName"></param>
        /// <returns></returns>
        private KStarFormModel GetPreStartupData(KStarFormInput formInput, string k2Id, string userName)
        {
            var proStartLogInfo = _bpmInterfaceLogService.GetProStartInterfaceLog(k2Id);//根据K2ID获取流程发起日志信息

            #region 权限检查 K2ID是否已经提交
            if (proStartLogInfo == null)
            {
                //您没有权限打开此表单
                throw new KStarCustomException(KStarForm_Prompt.NoOpenFormAuthority);
            }

            var formInstance = _kStarFormStorageService.GetPrcServer_FormInstanceByFolio(k2Id);
            if (formInstance != null)
            {
                //如果已经存在表单,返回查看页面数据
                formInput.FormId = formInstance.Id;
                return(_kStarWorkFlowService.GetKStarFormByView(formInput));
                ////表单状态为已提交,请勿重复提交!
                //throw new KStarCustomException(KStarForm_Prompt.FormIDRepeatSubmit);
            }
            #endregion

            var requestMessage = proStartLogInfo.RequestMessage;
            var proStartData   = JsonConvert.DeserializeObject <RequstModel <ProcessStartArgs> >(requestMessage);
            var proStartInfo   = proStartData.requestInfo;

            var model = _kStarWorkFlowService.GetApiSubmitModel(userName, proStartInfo.applyUserCode, proStartLogInfo.SplitProcessCode, "BPMService", Guid.Empty);
            model.FormInstance.Folio       = k2Id;                                                              //更新流程编码
            model.FormInstance.BizId       = proStartLogInfo.BizID;                                             //更新BizId
            model.FormInstance.FormSubject = proStartInfo.folio;                                                //流程标题
            model.KStarFormButtons         = model.KStarFormButtons.Where(t => t.Code != "SaveDraft").ToList(); // 过虑保存草稿按钮

            model.FormContent.FormDataToJson = proStartInfo.bizData;                                            //流程表单数据
            return(model);
        }
Exemple #2
0
        /// <summary>
        /// 发起接口 一步法 直接发起流程处理
        /// </summary>
        /// <returns></returns>
        public long NewTaskStart(ProcessStartInfo ProcessStartInfo)
        {
            //初始化kStarFormModel
            var formModel = _KStarWorkFlowService.GetApiSubmitModel(ProcessStartInfo.StartUserCode, ProcessStartInfo.ApplyUserCode, ProcessStartInfo.SplitProcessCode, "BPMService", Guid.Empty);

            if (formModel != null)
            {
                formModel.FormInstance.Folio       = ProcessStartInfo.K2ID;      //K2ID
                formModel.FormInstance.BizId       = ProcessStartInfo.BizId;     //BizID
                formModel.FormInstance.FormSubject = ProcessStartInfo.Folio;     //流程标题

                formModel.FormContent.FormDataToJson = ProcessStartInfo.BizData; //流程表单数据
            }

            var    processStartuptUrl = _processBusService.GetProcessStartuptUrl(ProcessStartInfo.SplitProcessCode); //获取流程发起地址
            string apiSubmitUrl       = string.Format("{0}/ApiSubmit", processStartuptUrl);                          //获取表单ApiSubmit请求地址

            apiSubmitUrl = _processBusService.UrlAddK2ID(apiSubmitUrl, ProcessStartInfo.K2ID);                       //添加K2ID参数

            stopwatch.Stop();
            timespan = stopwatch.Elapsed;
            _logger.Debug("StartProcess", $"url: {apiSubmitUrl} GetProcessStartuptUrl 执行时间:{ timespan.TotalMilliseconds} ms");//方法计时记录日志系统

            //获取参数Json
            string param = Newtonsoft.Json.JsonConvert.SerializeObject(formModel);

            param = Newtonsoft.Json.JsonConvert.SerializeObject(new { jsonData = param });
            string responseString = string.Empty;

            try
            {
                stopwatch.Reset();
                stopwatch.Start();

                //请求模拟提交地址
                responseString = HttpHelper.HttpPostRequest(apiSubmitUrl, param, 60);
                if (string.IsNullOrWhiteSpace(responseString))
                {
                    return(0);
                }

                stopwatch.Stop();
                timespan = stopwatch.Elapsed;
                _logger.Debug("StartProcess", $"ApiSubmit 执行时间:{ timespan.TotalMilliseconds} ms");//方法计时记录日志系统

                //处理返回信息
                var submitResInfo = JsonConvert.DeserializeObject <SubmitResponseModel>(responseString);
                if (submitResInfo == null || (submitResInfo != null && submitResInfo.Code != 200))
                {
                    throw new Exception(submitResInfo.Message);
                }

                return(submitResInfo.Data.Item2);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }