Exemplo n.º 1
0
 public DataResult EditProcessInfo(ProcessInfoEdit Model)
 {
     //BForm bWorkOrder = new BForm();
     ///操作员信息获取、测试阶段改信息来自常量的引用中。
     ///当后台能获取操作员信息后,需取消using OTG.OA.Framework.Const的引用。
     UserInfo mUser = BusinessConst.GetDefault();
     Model.GroupID = mUser.GroupID;
     Model.OperatorID = mUser.ID;
     Model.OperatorName = mUser.Name;
     Model.OperateTime = DateTime.Now;
     int iBack = processService.EditProcessInfo(Model);
     if (iBack == 1)
     {
         dataResult.Code = ResponseStatusCode.Success;
         dataResult.Msg = "操作成功!";
     }
     else
     {
         dataResult.Code = ResponseStatusCode.Error;
         dataResult.Msg = "操作失败!";
     }
     return dataResult;
 }
Exemplo n.º 2
0
        /// <summary>
        /// 添加/编辑自定义流程
        /// </summary>
        /// <param name="Model"></param>
        /// <returns></returns>
        public int EditProcessInfo(ProcessInfoEdit Model) {
            MySqlConnection conn = DbMySqlConnectionWrite();
            int iBack = 0;
            try
            {
                using (conn)
                {
                    if (string.IsNullOrEmpty(Model.ID))
                    {
                        //添加流程
                        string strProcessID = Guid.NewGuid().ToString();
                        iBack = conn.Insert("process")
                        .Field("PK_Process", DbType.AnsiString, strProcessID)
                        .Field("PK_Group", DbType.AnsiString, Model.GroupID)
                        .Field("Name", DbType.AnsiString, Model.Name)
                        .Field("Type", DbType.Int32, Model.Type)
                        .Field("T_Deleted", DbType.Int32, 0)
                        .Field("T_Creater", DbType.AnsiString, Model.OperatorID)
                        .Field("T_CreaterName", DbType.AnsiString, Model.OperatorName)
                        .Field("T_CreateTime", DbType.DateTime, Model.OperateTime)
                        .Field("T_Updater", DbType.AnsiString, Model.OperatorID)
                        .Field("T_UpdaterName", DbType.AnsiString, Model.OperatorName)
                        .Field("T_UpdateTime", DbType.DateTime, Model.OperateTime)
                        .Execute();
                        Model.ID = strProcessID;
                    }
                    else
                    {
                        //修改流程
                        iBack = conn.Update("process")
                            .Set("Name", DbType.AnsiString, Model.Name)
                            .Set("Type", DbType.Int32, Model.Type)
                            .Set("T_Deleted", DbType.Int32, 0)
                            .Set("T_Updater", DbType.AnsiString, Model.OperatorID)
                            .Set("T_UpdaterName", DbType.AnsiString, Model.OperatorName)
                            .Set("T_UpdateTime", DbType.DateTime, Model.OperateTime)
                            .Where(WhereMySQL.Equal("PK_Process", DbType.AnsiString, Model.ID))
                            .Execute();
                        //清空该流程中节点信息
                        iBack = conn.Delete("processinfo")
                            .Where(WhereMySQL.Equal("PK_Process", DbType.AnsiString, Model.ID))
                            .Execute();
                        ////清理未使用的表单副本
                        //string pullOrgDeptSql = "select PK_FormBU from processinfobackups where PK_FormBU in( select PK_FormBU from processinfo where PK_Process = @ProcessID )";
                        //List<MySqlParameter> lstSqlParameters = new List<MySqlParameter>();
                        //lstSqlParameters.Add(new MySqlParameter("@ProcessID", Model.ID));
                        //var t3 = conn.ExecuteReader(pullOrgDeptSql, lstSqlParameters.ToArray());
                        //List<string> lstFormBUID = new List<string>();

                        //while(t3.Read())
                        //{
                        //    lstFormBUID.Add(t3.TryGetValue<string>("PK_FormBU"));
                        //}
                        //iBack = conn.Delete("forminfobackups")
                        //    .Where(WhereMySQL.In("PK_FormBU", DbType.AnsiString, lstFormBUID.ToArray()))
                        //    .Execute();
                    }
                    //生成控件副本信息
                    List<string> lstFormID = Model.Detail.Select(o => o.FormID).ToList();
                    Dictionary<string, string> dFormIDKeyValiue = new Dictionary<string, string>();

                    var f7 = conn.MultiQuery<List<FormInfoDetailView>>("forminfo")
                        .PrimaryKey("PK_Form")
                        .Fields("PK_Form AS ID,Name,ControlSort,ControlJson,Remark,T_Deleted AS Del,T_Creater AS CreaterID,T_CreaterName AS CreaterName,T_CreateTime AS CreateTime,T_Updater AS UpdaterID,T_UpdaterName AS UpdaterName,T_UpdateTime AS UpdateTime")
                        .OrderBy("T_CreateTime", false)
                        .Where(WhereMySQL.In("PK_Form", DbType.AnsiString, lstFormID.ToArray()));
                    List<FormInfoDetailView> lstFormInfo = f7.Execute();

                    foreach (FormInfoDetailView temp in lstFormInfo) {
                        if (!dFormIDKeyValiue.ContainsKey(temp.ID))
                        {
                            dFormIDKeyValiue.Add(temp.ID, Guid.NewGuid().ToString());
                        }
                        iBack = conn.Insert("forminfobackups")
                        .Field("PK_FormBU", DbType.AnsiString, dFormIDKeyValiue[temp.ID])
                        .Field("Name", DbType.AnsiString, temp.Name)
                        .Field("ControlSort", DbType.Int32, temp.ControlSort)
                        .Field("ControlJson", DbType.Int32, temp.ControlJson)
                        .Field("Remark", DbType.Int32, temp.Remark)
                        .Field("T_Creater", DbType.AnsiString, temp.CreaterID)
                        .Field("T_CreaterName", DbType.AnsiString, temp.CreaterName)
                        .Field("T_CreateTime", DbType.DateTime, temp.CreateTime)
                        .Field("T_Updater", DbType.AnsiString, temp.UpdaterID)
                        .Field("T_UpdaterName", DbType.AnsiString, temp.UpdaterName)
                        .Field("T_UpdateTime", DbType.DateTime, temp.UpdateTime)
                        .Execute();                        
                    }
                    ///创建流程节点
                    Dictionary<string, string> dIDKeyValiue = new Dictionary<string, string>();
                    foreach (var item in Model.Detail)
                    {
                        if (!dIDKeyValiue.ContainsKey(item.ID)) {
                            dIDKeyValiue.Add(item.ID, Guid.NewGuid().ToString());
                        }
                        if (!string.IsNullOrEmpty(item.PreviousID)&&!dIDKeyValiue.ContainsKey(item.PreviousID))
                        {
                            dIDKeyValiue.Add(item.PreviousID, Guid.NewGuid().ToString());
                        }
                        if (!string.IsNullOrEmpty(item.NextID) && !dIDKeyValiue.ContainsKey(item.NextID))
                        {
                            dIDKeyValiue.Add(item.NextID, Guid.NewGuid().ToString());
                        }

                        iBack = conn.Insert("processinfo")
                        .Field("PK_ProcessInfo", DbType.AnsiString, dIDKeyValiue[item.ID])
                        .Field("PK_Process", DbType.AnsiString, Model.ID)
                        .Field("PreviousID", DbType.AnsiString, dIDKeyValiue[item.PreviousID])
                        .Field("NextID", DbType.AnsiString, dIDKeyValiue[item.NextID])
                        .Field("PK_FormBU", DbType.AnsiString, dFormIDKeyValiue[item.FormID])
                        .Field("JudgementJson", DbType.AnsiString, item.JudgementJson)
                        .Field("Type", DbType.DateTime, item.Type)
                        .Field("IsAllComplete", DbType.AnsiString, item.IsAllComplete)
                        .Execute();
                    }

                }
                return iBack;
            }
            catch
            {
                return 0;
            }
        }