예제 #1
0
        public async Task <ActionResult> Save(long id, string name, string processContent, TableSource tableSource, string remark)
        {
            var result = new JsonModel();

            try
            {
                var flow = await WfProcessRepository.GetByIdAsync(id) ?? new WfProcess();

                flow.Name           = name;
                flow.ProcessContent = processContent;
                flow.TableSource    = tableSource;
                flow.Remark         = remark;
                flow.CommonStatus   = CommonStatus.Disabled;

                await WfProcessRepository.SaveAsync(flow);

                result.Data    = flow.Id;
                result.message = "保存成功。请发布流程,否则无法显示~";
            }
            catch (Exception ex)
            {
                result.message = "保存出错";
            }

            return(Json(result));
        }
예제 #2
0
        public async Task <ActionResult> Publish(long id, string name)
        {
            var result = new JsonModel {
                statusCode = 300, message = "发布失败,流程不存在!", closeCurrent = false
            };

            if (id <= 0)
            {
                return(Json(result));
            }
            var flow = await WfProcessRepository.GetByIdAsync(id);

            if (flow == null)
            {
                return(Json(result));
            }

            // 每个数据源有且只有一个发布的流程图
            var hasPublished = await WfProcessRepository.HasPublishedProcess(flow.TableSource);

            if (hasPublished)
            {
                result.message = $"发布失败,数据源【{flow.TableSource.GetDescriotion()}】已经有一个已发布的流程~";
                return(Json(result));
            }

            // 不允许同名
            var existedName = await WfProcessRepository.IsExsitName(name);

            if (existedName)
            {
                result.message = $"发布失败,流程名称已存在,请更改名称~";
                return(Json(result));
            }

            flow.CommonStatus = CommonStatus.Enabled;
            await WfProcessRepository.SaveAsync(flow);

            result.statusCode = 200;
            result.message    = "发布成功!";
            return(Json(result));
        }
예제 #3
0
        public async Task <ActionResult> GetFlowData(long id)
        {
            var flow = await WfProcessRepository.GetByIdAsync(id);

            return(Json(flow, JsonRequestBehavior.AllowGet));
        }