示例#1
0
        public virtual ActionResult Update(WFModel entity)
        {
            entity.LastUpdatedTime = DateTime.Now;
            OperationResult or = WFModelService.Update(entity);

            return(this.JsonFormat(or));
        }
示例#2
0
        public async Task <ActionResult> FieldList(string module, string table)
        {
            WFModel model    = new WFModel();
            var     postTask = await client.GetAsync("/api/Workflow/FieldList/?module=" + module + "&table=" + table);

            return(Json(await postTask.Content.ReadAsAsync <List <ModuleTableSetupViewModel> >(), JsonRequestBehavior.AllowGet));
        }
示例#3
0
        public async Task <WFModel> AddWorkFlow(WFModel wFModel)
        {
            var wFentity = _mapper.Map <WF>(wFModel);
            var number   = 1;

            foreach (var wFStep in wFentity.WFSteps)
            {
                wFStep.Number = number;
                number++;
            }
            return(_mapper.Map <WFModel>(await _IWFRepo.Add(wFentity)));
        }
        public async Task <IActionResult> AddWorkFlow([FromBody] WFModel workFlow)
        {
            try
            {
                b
                var result = await _ISupervisor.AddWorkFlow(workFlow);

                return(Ok(result));
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
示例#5
0
        //获得数据库数据
        void GetTemplateData()
        {
            models.Clear();
            MySQLConnection DBConn = null;

            DBConn = new MySQLConnection(new MySQLConnectionString(Configuration.getDBIp(), "workflow", Configuration.getDBUsername(), Configuration.getDBPassword()).AsString);
            try
            {
                DBConn.Open();
                MySQLCommand setformat = new MySQLCommand("set names gb2312", DBConn);
                setformat.ExecuteNonQuery();
                setformat.Dispose();


                string           sql = "select model_name,owner,model_content,lastedit_time,model_disc,create_time from wf_model";
                MySQLDataAdapter mda = new MySQLDataAdapter(sql, DBConn);

                DataTable ds = new DataTable();
                mda.Fill(ds);

                DBConn.Close();
                foreach (DataRow dr in ds.Rows)
                {
                    WFModel wfm = new WFModel();
                    wfm.WFModel_CreateTime   = dr["create_time"].ToString();
                    wfm.WFModel_LasteditTime = dr["lastedit_time"].ToString();
                    wfm.WFModel_Name         = dr["model_name"].ToString();
                    wfm.WFModel_Owner        = dr["owner"].ToString();
                    string test = dr["model_content"].ToString();
                    if (dr["model_content"] == null || dr["model_content"].ToString().Length <= 0)
                    {
                        wfm.WFModel_Content = "";
                    }
                    else
                    {
                        wfm.WFModel_Content = Encoding.Default.GetString((Byte[])dr["model_content"]);
                    }

                    models.Add(wfm);
                }
                view.Source = models;
                this.listView1.DataContext = view;
            }
            catch (Exception e)
            {
                MessageBox.Show("数据库连接失败,请检查网络连接或者数据库配置");
                return;
            }
        }
示例#6
0
        public ActionResult Add(WFModel wFModel)
        {
            string result = "no";

            if (wFModel != null && !string.IsNullOrWhiteSpace(wFModel.ModelTitle) && !string.IsNullOrWhiteSpace(wFModel.ControllerName) && !string.IsNullOrWhiteSpace(wFModel.ActionName))
            {
                wFModel.AddTime   = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                wFModel.IsDeleted = 0;
                wFModel.SubBy     = UserLogin.UserId;
                if (WFModelBll.Add(wFModel))
                {
                    result = "ok";
                }
            }

            return(Content(result));
        }
示例#7
0
        public ActionResult Edit(WFModel wFModel)
        {
            string  result = "no";
            WFModel model  = WFModelBll.GetById(wFModel.ModelId);

            model.ModifiedTime   = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            model.ModelTitle     = wFModel.ModelTitle;
            model.ControllerName = wFModel.ControllerName;
            model.ActionName     = wFModel.ActionName;
            model.Remark         = wFModel.Remark;
            model.SubBy          = UserLogin.UserId;
            if (model.ModelTitle != string.Empty && WFModelBll.Edit(model))
            {
                result = "ok";
            }
            return(Content(result));
        }
        /// <summary>
        /// 保存流程
        /// </summary>
        /// <returns></returns>
        public ActionResult SaveFlow()
        {
            String  json = QuestRequest.Get("wfjson");
            WFModel info = JsonHelper.DecodeObject <WFModel>(json);

            info.DesignJSON = json;
            if (info.Id.IsNullOrEmpty())
            {
                info.Id = Guid.NewGuid();
            }

            List <WFModel> items = new List <WFModel> {
                info
            };
            OperationResult or = WFModelService.AddOrUpdate(c => new { c.Id }, items);

            return(this.JsonFormat(or));
        }
示例#9
0
        //打开操作
        private void Confirm_Click(object sender, RoutedEventArgs e)
        {
            //得到新的添加项
            WFModel selected = listView1.SelectedItem as WFModel;

            selectedModel = selected;

            if (selected == null)
            {
                return;
            }
            selectName    = selected.WFModel_Name;
            selectContent = selected.WFModel_Content;


            if (selectContent.Length > 0)
            {
                // StreamWriter sw = new StreamWriter("template\\temp.xaml", false, Encoding.UTF8);
                // sw.WriteLine(content);
                //  sw.Close();
                //写文件:
                StreamWriter sw = new StreamWriter("template\\temp.xaml", false, Encoding.UTF8);//

                sw.Write(selectContent);
                //   FileStream fs = new FileStream("template\\temp.xaml", FileMode.Create);
                //    String str = new String(selectContent,Encoding.ASCII);
                //   Byte[] decoded = str.getBytes("UTF-8");
                //开始写入
                //    fs.Write(selectContent, 0, selectContent.Length);
                //清空缓冲区、关闭流
                sw.Flush();
                sw.Close();
                selectPath = "template\\temp.xaml";
            }
            else
            {
                selectPath = null;
            }


            this.Visibility = System.Windows.Visibility.Hidden;
        }
        /// <summary>
        /// 获取指定流程Id的首步骤的表单信息
        /// </summary>
        /// <returns>返回操作结果</returns>
        public OperationResult ProcessFirstStep(Guid wfId)
        {
            OperationResult or = new OperationResult(OperationResultType.Error);

            or = WFModelService.GetByKey(wfId);
            if (or.ResultType == OperationResultType.Success)
            {
                try
                {
                    WFModel flow   = or.AppendData as WFModel;
                    WFInfo  wfInfo = this.GetWFInstall(flow.DesignJSON);
                    Step    step   = wfInfo.Steps.Where(c => c.Id == wfInfo.FirstStepID).FirstOrDefault();
                    or = new OperationResult(OperationResultType.Success, "加载成功", step);
                }
                catch (Exception e)
                {
                    or = new OperationResult(OperationResultType.Error, e.Message);
                }
            }
            return(or);
        }
示例#11
0
        /// <summary>
        /// 根据指定参数启动流程
        /// </summary>
        /// <param name="mainId">实体唯一标识Id</param>
        /// <param name="projectId">项目Id</param>
        /// <param name="cName">控制器名称</param>
        /// <param name="user">当前用户</param>
        /// <returns></returns>
        public OperationResult Execute(String mainId, Guid wfModeId, User user)
        {
            String          msg    = String.Empty;
            OperationResult or     = new OperationResult(OperationResultType.Error);
            WFModel         design = WFModelService.Entities.Where(c => c.Id == wfModeId).FirstOrDefault();

            if (design.IsNullOrEmpty())
            {
                msg = "流程设计不存在或已过期.";
                return(new OperationResult(OperationResultType.QueryNull, msg));
            }

            // 根据指定参数启动流程
            WorkflowApplication instance = new WorkflowApplication(mainId, design.Id, user);

            // 任务准备方法
            instance.CreateStep = CreateTask;
            instance.WFComplete = Complete;
            tasks = new List <WFTask>();
            or    = instance.Execute();
            return(or);
        }
示例#12
0
        public async Task <ActionResult> Edit(string comp_id, string wflw_id)
        {
            if (comp_id != null && wflw_id != null)
            {
                WFModel model    = new WFModel();
                var     postTask = await client.GetAsync("/api/Workflow/View/?comp_id=" + comp_id + "&wflw_id=" + wflw_id);

                model = await postTask.Content.ReadAsAsync <WFModel>();

                if (model != null)
                {
                    return(View("Edit", model));
                }
                else
                {
                    RoleIndexViewModel data = new RoleIndexViewModel();
                    ViewBag.Error = "No Workflow Found !";
                    return(View("Index", data));
                }
            }
            return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
        }
        /// <summary>
        /// 根据指定参数启动流程
        /// 根据指定步骤Id查询数据为空,则创建一个新流程
        /// </summary>
        /// <returns>返回操作结果</returns>
        public OperationResult Execute()
        {
            OperationResult or  = new OperationResult(OperationResultType.Error);
            String          msg = String.Empty;

            if (this.DesignId.IsNullOrEmpty())
            {
                msg = "流程设计Id为空.";
                return(new OperationResult(OperationResultType.QueryNull, msg));
            }
            if (this.MainId.IsNullOrEmpty())
            {
                msg = "流程无主题依赖.";
                return(new OperationResult(OperationResultType.QueryNull, msg));
            }
            if (this.NowUser.IsNullOrEmpty())
            {
                msg = "流程启动者不能为空.";
                return(new OperationResult(OperationResultType.QueryNull, msg));
            }
            // 声明流程实例
            WFInfo wfInfo = new WFInfo();
            // 获取当前流程运行实例
            List <WFRunInstance> instances   = WFRunInstanceService.Entities.Where(c => c.MainId == this.MainId).ToList();
            WFRunInstance        runInstance = instances.FirstOrDefault();

            // 如果流程实例不存在,这创建流程实例
            if (runInstance.IsNullOrEmpty())
            {
                or = WFModelService.GetByKey(this.DesignId);
                WFModel design = or.AppendData as WFModel;
                if (!or.IsNullOrEmpty())
                {
                    // 实例当前流程设计
                    wfInfo      = this.GetWFInstall(design.DesignJSON);
                    runInstance = this.CreateInstance(design.DesignJSON, this.MainId, this.NowUser.Id);
                }
                else
                {
                    msg = "流程模型未找到!";
                    return(new OperationResult(OperationResultType.QueryNull, msg));
                }
            }
            else
            {
                // 实例当前流程设计
                wfInfo = this.GetWFInstall(runInstance.DesignJSON);
            }

            // 获取指定实体对应运行步骤信息
            List <WFRunStep> rSteps = WFRunStepService.Entities.Where(c => c.InstanceId == runInstance.Id).OrderByDescending(c => c.Sort).ToList();
            // 获得当前运行步骤
            WFRunStep rStep   = rSteps.FirstOrDefault();
            Boolean   isFirst = false;

            // 判断步骤是否为空,如果为空则为第一次启动流程,并创建一个新步骤信息
            if (rStep.IsNullOrEmpty())
            {
                // 流程当前步骤
                Step step = wfInfo.Steps.Where(c => c.Id == wfInfo.FirstStepID).FirstOrDefault();
                rStep = new WFRunStep
                {
                    ParentId   = Guid.Empty,
                    SId        = step.Id,
                    FormId     = step.FormId.GetGuid(),
                    Name       = step.Name,
                    FormUrl    = step.FormUrl,
                    InstanceId = runInstance.Id,
                    SenderId   = this.NowUser.Id,
                    SenderTime = DateTime.Now,
                    Status     = 2,
                    Sort       = 1
                };
                isFirst = true;
            }

            // 获取当前步骤下一步路线
            List <Line> lines = wfInfo.Lines.Where(c => c.FromID == rStep.SId).ToList();

            // 判断当前步骤是否为空
            if (lines.IsNullOrEmpty() || lines.Count == 0)
            {
                msg = "流程设计中连线存在问题.";
                return(new OperationResult(OperationResultType.QueryNull, msg));
            }

            // 声明下一步骤默认处理者Id和名称
            String rId = String.Empty;

            foreach (Line line in lines)
            {
                Boolean isTrue = false;
                // 判断连线是否满足规则
                if (!line.Expression.IsNullOrEmpty())
                {
                    isTrue = LineWhere(line.Expression, wfInfo.DBTableName);
                }

                if (!line.TSql.IsNullOrEmpty())
                {
                    //or = WFModelService.Context.
                    SqlParameter s = new SqlParameter("@mainId", SqlDbType.UniqueIdentifier)
                    {
                        Value = "00000000-0000-0000-0000-000000000001".GetGuid()
                    };
                    Int32 result = WFModelService.DB.SqlQuery <Int32>(line.TSql, s).FirstOrDefault();
                    isTrue = result > 0 ? true : false;

                    //if (or.ResultType == OperationResultType.Success)
                    //{
                    //    or.AppendData
                    //    isTrue = true;
                    //}
                }
                //Boolean isTrue = true;
                if (isTrue)
                {
                    // 连线下一步骤
                    Step toStep = wfInfo.Steps.Where(c => c.Id == line.ToID).FirstOrDefault();

                    String id = toStep.DefaultUser;
                    rId = rId.IsNullOrEmpty() ? id : rId + ";" + id;

                    WFRunStep item = new WFRunStep
                    {
                        Id         = Guid.NewGuid(),
                        ParentId   = rStep.SId,
                        SId        = toStep.Id,
                        Name       = toStep.Name,
                        FormUrl    = toStep.FormUrl,
                        InstanceId = runInstance.Id,
                        FormId     = toStep.FormId.GetGuid(),
                        SenderId   = NowUser.Id,
                        SenderTime = DateTime.Now,
                        ReceiveId  = id,
                        Status     = 0,
                        Sort       = (rSteps.Count == 0 ? 1 : rSteps.Count) + 1
                    };
                    rSteps.Add(item);
                    //or = this.Insert(item);

                    if (!CreateStep.IsNullOrEmpty())
                    {
                        WFTaskArgs args = new WFTaskArgs(item, wfInfo, runInstance, NowUser);
                        CreateStep(args);
                    }
                }
            }

            // 第一次创建流程
            if (isFirst)
            {
                rStep.ReceiveId = rId;
                rSteps.Add(rStep);

                if (!CreateStep.IsNullOrEmpty())
                {
                    WFTaskArgs args = new WFTaskArgs(rStep, wfInfo, runInstance, NowUser);
                    CreateStep(args);
                }
            }
            or = WFRunStepService.AddOrUpdate(c => new { c.Id }, rSteps);
            if (or.ResultType == OperationResultType.Success)
            {
                or = new OperationResult(OperationResultType.Success, "流程启动成功", true);
                if (!WFComplete.IsNullOrEmpty())
                {
                    WFTaskArgs args = new WFTaskArgs(rStep, wfInfo, runInstance, NowUser);
                    WFComplete(args);
                }
            }
            else
            {
                or = new OperationResult(OperationResultType.QueryNull, "流程启动失败", false);
            }

            return(or);
        }
示例#14
0
        public ActionResult Edit(int mId)
        {
            WFModel wFModel = WFModelBll.GetById(mId);

            return(View(wFModel));
        }
示例#15
0
        public virtual ActionResult Add(WFModel entity)
        {
            OperationResult or = WFModelService.Insert(entity);

            return(this.JsonFormat(or));
        }