Beispiel #1
0
        /// <summary>
        /// 发布流程模板
        /// </summary>
        public JsonResult PublishWorkflow(WorkflowTemplateViewModel model)
        {
            return(ExecuteFunctionRun(() =>
            {
                DraftWorkflowTemplate DraftWorkflowTemplate = ReadRequestWorkflowTemplate(model);
                if (DraftWorkflowTemplate == null)
                {
                    return Json(new { Result = false, Errors = new List <string>()
                                      {
                                          "Designer.WorkflowHandler_Msg1"
                                      } });
                }

                string WorkflowCode = DraftWorkflowTemplate.WorkflowCode;
                WorkflowClause Clause = this.Engine.WorkflowManager.GetClause(WorkflowCode);
                if (Clause == null)
                {
                    return Json(new { Result = false, Errors = new List <string>()
                                      {
                                          "Designer.WorkflowHandler_Msg2"
                                      } });
                }
                DraftWorkflowTemplate.BizObjectSchemaCode = Clause.BizSchemaCode;

                // 先保存流程模板
                if (!this.Engine.WorkflowManager.SaveDraftTemplate(this.UserValidator.UserID, DraftWorkflowTemplate))
                {
                    return Json(new { Result = false, Errors = new List <string>()
                                      {
                                          "Designer.WorkflowHandler_Msg3"
                                      } });
                }

                OThinker.H3.DataModel.BizObjectSchema schema = this.Engine.BizObjectManager.GetPublishedSchema(Clause.BizSchemaCode);
                OThinker.H3.ValidationResult ValidationResult = DraftWorkflowTemplate.Validate(schema);

                if (!ValidationResult.Valid)
                {
                    return Json(ValidationResult);
                }

                PublishResult PublishResult = this.Engine.WorkflowManager.RegisterWorkflow(this.UserValidator.UserID, DraftWorkflowTemplate.WorkflowCode, true);

                if (PublishResult.Result == (long)OThinker.H3.ErrorCode.SUCCESS)
                {
                    return Json(new { Result = true, Message = new List <string>()
                                      {
                                          "流程发布成功:当前版本号: " + PublishResult.RegisteredVersion.ToString()
                                      } });
                }
                else
                {
                    return Json(new { Result = false, Errors = PublishResult.Errors });
                }
            }));
        }
Beispiel #2
0
        /// <summary>
        /// 验证流程模板是否合法
        /// </summary>
        /// <param name="DraftWorkflowTemplate"></param>
        /// <returns></returns>
        public JsonResult ValidateWorkflow(WorkflowTemplateViewModel model)
        {
            return(ExecuteFunctionRun(() =>
            {
                DraftWorkflowTemplate DraftWorkflowTemplate = ReadRequestWorkflowTemplate(model);
                if (DraftWorkflowTemplate != null)
                {
                    OThinker.H3.DataModel.BizObjectSchema schema = this.Engine.BizObjectManager.GetPublishedSchema(DraftWorkflowTemplate.BizObjectSchemaCode);
                    OThinker.H3.ValidationResult ValidationResult = DraftWorkflowTemplate.Validate(schema);

                    return Json(new { Result = ValidationResult.Valid, Errors = ValidationResult.Errors, Warnings = ValidationResult.Warnings });
                }
                else
                {
                    var result = new { Result = false, Errors = new List <string>()
                                       {
                                           "Designer.WorkflowHandler_Msg0"
                                       } };
                    return Json(result);
                }
            }));
        }
Beispiel #3
0
        /// <summary>
        /// 删除服务方法
        /// </summary>
        /// <param name="serviceCode"></param>
        /// <param name="methodNames"></param>
        /// <returns></returns>
        public JsonResult DeleteData(string serviceCode, string methodNames)
        {
            return(ExecuteFunctionRun(() =>
            {
                ActionResult result = new ActionResult(true, "");
                string[] methods = methodNames.Split(';');
                OThinker.H3.BizBus.BizService.BizService Service = GetService(serviceCode);
                foreach (string methodName in methods)
                {
                    BizServiceMethod BizServiceMethod = Service.GetMethod(methodName);
                    if (BizServiceMethod != null && BizServiceMethod.UsedCount > 0)
                    {
                        result.Success = false;
                        result.Message = "BizServiceMethod.Mss1";

                        return Json(result);
                    }
                    if (!string.IsNullOrWhiteSpace(methodName))
                    {
                        Service.RemoveMethod(methodName);
                    }
                }

                OThinker.H3.ValidationResult result2 = Engine.BizBus.UpdateBizService(Service, true);
                if (result2.Valid)
                {
                    // 删除成功
                    result.Message = "msgGlobalString.DeleteSucced";
                }
                else
                {
                    // 删除失败
                    result.Message = "msgGlobalString.DeleteFailed";
                    result.Extend = result2.ToString();//记录具体错误信息
                    result.Success = false;
                }
                return Json(result);
            }));
        }