Exemplo n.º 1
0
        public override int Update(FormM form, DFDictionary entity, ref string message)
        {
            try
            {
                var dict = new DFDictionary();
                /*基本查询语句*/
                var sql = "select * from WF_M_ROLE where 1=1";

                /*查询条件*/

                using (var db = Pub.DB)
                {
                    var parameters = entity.To <WF_M_ROLE>();
                    var oldEntity  = db.Query <WF_M_ROLE>(sql, parameters).FirstOrDefault();
                    if (oldEntity == null)
                    {
                        message = "记录已经不存在".GetRes();
                        return(DFPub.EXECUTE_ERROR);
                    }
                    var newDict = DFDictionary.Create <WF_M_ROLE>(oldEntity);
                    // 把更新的值更新进去
                    newDict.Merge(entity);
                    // 将 Dictionary 转成 Entity
                    var newEntity = newDict.To <WF_M_ROLE>();
                    db.Update <WF_M_ROLE>(newEntity);
                    return(DFPub.EXECUTE_SUCCESS);
                }
            }
            catch (Exception ex)
            {
                message = ex.Message;
                return(DFPub.EXECUTE_ERROR);
            }
        }
Exemplo n.º 2
0
        public override int Insert(FormM form, DFDictionary entity, ref string message)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(entity["ModuleId"]))
                {
                    throw new Exception("请选择模块".GetRes());
                }
                if (string.IsNullOrWhiteSpace(entity["PMenuId"]))
                {
                    throw new Exception("请选择父菜单".GetRes());
                }

                var parent   = WF_M_MENULoader.Query(entity["PMenuId"]).FirstOrDefault();
                var siblings = WF_M_MENULoader.Query(null, parent.MenuLabel).ToList();

                var newEntity = entity.To <WF_M_MENU>();
                newEntity.MenuId = Guid.NewGuid().ToString();
                var user = Util.GetCurrentUser();
                newEntity.CreateTime     = DateTime.Now;
                newEntity.CreateUser     = user.UserName;
                newEntity.LastModifyTime = DateTime.Now;
                newEntity.LastModifyUser = user.UserName;
                newEntity.MenuLabel      = LabelHelper.GetNextLabelUsingSubLabelList(parent.MenuLabel, siblings.Select(a => a.MenuLabel).ToList());

                WF_M_MENULoader.Insert(newEntity);
                message = "新增成功".GetRes();
                return(DFPub.EXECUTE_SUCCESS);
            }
            catch (Exception ex)
            {
                message = ex.Message;
                return(DFPub.EXECUTE_ERROR);
            }
        }
        public override int Insert(FormM form, DFDictionary entity, ref string message)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(entity["CodeType"]))
                {
                    throw new Exception("代码分类必须输入".GetRes());
                }
                if (string.IsNullOrWhiteSpace(entity["CodeName"]))
                {
                    throw new Exception("代码名称必须输入".GetRes());
                }
                var currentUser = Util.GetCurrentUser();
                var dict        = new DFDictionary();
                /*基本查询语句*/
                var sql = "select * from WF_M_PUBLICCODE where 1=1";

                /*查询条件*/
                sql += " and CodeType=@CodeType and CodeName=@CodeName";

                using (var db = Pub.DB)
                {
                    var parameters = new { CodeName = entity["CodeName"], CodeType = entity["CodeType"] };
                    var oldEntity  = db.Query <WF_M_PUBLICCODE>(sql, parameters).FirstOrDefault();
                    if (oldEntity != null)
                    {
                        message = "代码已经存在".GetRes();
                        return(DFPub.EXECUTE_ERROR);
                    }

                    var newEntity = entity.To <WF_M_PUBLICCODE>();
                    newEntity.CodeId         = Guid.NewGuid().ToString();
                    newEntity.CodeType       = entity["CodeType"];
                    newEntity.CodeName       = entity["CodeName"];
                    newEntity.CodeValue      = entity["CodeValue"];
                    newEntity.CodeLongValue  = entity["CodeLongValue"];
                    newEntity.CodeOrder      = ParseHelper.ParseInt(entity["CodeOrder"]);
                    newEntity.CreateUser     = currentUser.UserName;
                    newEntity.CreateTime     = DateTime.Now;
                    newEntity.LastModifyUser = currentUser.UserName;
                    newEntity.LastModifyTime = DateTime.Now;
                    db.Insert(newEntity);

                    // 默认为 role_user 角色组用户
                    UserRoleLoader.Create(newEntity.CodeId, Constants.ROLE_USER, currentUser.UserName);

                    message = "新增成功".GetRes();
                    return(DFPub.EXECUTE_SUCCESS);
                }
            }
            catch (Exception ex)
            {
                message = ex.Message;
                return(DFPub.EXECUTE_ERROR);
            }
        }
Exemplo n.º 4
0
        public override int Insert(FormM form, DFDictionary entity, ref string message)
        {
            if (string.IsNullOrWhiteSpace(entity["UserName"]))
            {
                throw new WFException("用户名必须输入".GetRes());
            }
            var currentUser = Util.GetCurrentUser();
            var dict        = new DFDictionary();
            /*基本查询语句*/
            var sql = "select * from WF_M_USER where 1=1";

            /*查询条件*/
            sql += " and UserName=@UserName";

            using (var db = Pub.DB)
            {
                var parameters = new { UserName = entity["UserName"] };
                var oldEntity  = db.Query <WF_M_USER>(sql, parameters).FirstOrDefault();
                if (oldEntity != null)
                {
                    throw new WFException("用户名已经存在".GetRes());
                }


                if (entity["Category"] == "SENDER")
                {
                    if (string.IsNullOrWhiteSpace(entity["CompanyName"]))
                    {
                        throw new WFException("请输入托运单位");
                    }
                }

                var newEntity = entity.To <WF_M_USER>();
                newEntity.UserId         = Guid.NewGuid().ToString();
                newEntity.Password       = HashHelper.GenerateUserHash(newEntity.UserName, "123456");
                newEntity.Status         = ParseHelper.ParseInt(entity["Status"]);
                newEntity.CreateUser     = currentUser.UserName;
                newEntity.CreateTime     = DateTime.Now;
                newEntity.LastModifyUser = currentUser.UserName;
                newEntity.LastModifyTime = DateTime.Now;
                //var company = WF_M_COMPANYLoader.Get(newEntity.CompanyCode);
                //newEntity.CompanyName = company.CompanyName;
                db.Insert(newEntity);

                // 默认为 role_user 角色组用户
                UserRoleLoader.Create(newEntity.UserId, Constants.ROLE_USER, currentUser.UserName);

                message = "新增成功".GetRes();
                return(DFPub.EXECUTE_SUCCESS);
            }
        }
 public override int Insert(FormM form, DFDictionary entity, ref string message)
 {
     using (var db = Pub.DB)
     {
         if (string.IsNullOrWhiteSpace(entity["ExecutorValue"]))
         {
             throw new WFException("请选择用户".GetRes());
         }
         var newEntity = entity.To <WF_M_STEPEXECUTOR>();
         newEntity.ExecutorId       = Guid.NewGuid().ToString();
         newEntity.ExecutorPriority = ParseHelper.ParseInt(entity["ExecutorPriority"]);
         db.Insert <WF_M_STEPEXECUTOR>(newEntity);
         message = "新增成功".GetRes();
         return(DFPub.EXECUTE_SUCCESS);
     }
 }
Exemplo n.º 6
0
        public override int Insert(FormM form, DFDictionary entity, ref string message)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(entity["ResId"]))
                {
                    throw new Exception("资源编号".GetRes());
                }
                var currentUser = Util.GetCurrentUser();
                var dict        = new DFDictionary();
                /*基本查询语句*/
                var sql = "select * from WF_M_RES where 1=1";

                /*查询条件*/
                sql += " and ResId=@ResId";

                using (var db = Pub.DB)
                {
                    var parameters = new { ResId = entity["ResId"] };
                    var oldEntity  = db.Query <WF_M_RES>(sql, parameters).FirstOrDefault();
                    if (oldEntity != null)
                    {
                        message = "记录已经存在".GetRes();
                        return(DFPub.EXECUTE_ERROR);
                    }

                    var newEntity = entity.To <WF_M_RES>();
                    newEntity.ResId              = entity["ResId"];
                    newEntity.English            = entity["English"];
                    newEntity.ChineseSimplified  = entity["ChineseSimplified"];
                    newEntity.ChineseTraditional = entity["ChineseTraditional"];
                    newEntity.CreateUser         = currentUser.UserName;
                    newEntity.CreateTime         = DateTime.Now;
                    newEntity.LastModifyUser     = currentUser.UserName;
                    newEntity.LastModifyTime     = DateTime.Now;
                    db.Insert(newEntity);

                    message = "新增成功".GetRes();
                    return(DFPub.EXECUTE_SUCCESS);
                }
            }
            catch (Exception ex)
            {
                message = ex.Message;
                return(DFPub.EXECUTE_ERROR);
            }
        }
Exemplo n.º 7
0
        public override int Insert(FormM form, DFDictionary entity, ref string message)
        {
            try
            {
                var currentUser = Util.GetCurrentUser();
                var dict        = new DFDictionary();
                /*基本查询语句*/
                var sql = "select * from WF_M_ROLE where 1=1";

                /*查询条件*/
                sql += " and RoleId=@RoleId";

                using (var db = Pub.DB)
                {
                    var parameters = new { RoleId = entity["RoleId"] };
                    var oldEntity  = db.Query <WF_M_ROLE>(sql, parameters).FirstOrDefault();
                    if (oldEntity != null)
                    {
                        message = "该角色编号已经存在".GetRes();
                        return(DFPub.EXECUTE_ERROR);
                    }

                    var newEntity = entity.To <WF_M_ROLE>();
                    newEntity.RoleId   = entity["RoleId"];
                    newEntity.RoleName = entity["RoleName"];
                    newEntity.Remark   = entity["Remark"];

                    newEntity.CreateUser     = currentUser.UserName;
                    newEntity.CreateTime     = DateTime.Now;
                    newEntity.LastModifyUser = currentUser.UserName;
                    newEntity.LastModifyTime = DateTime.Now;
                    db.Insert(newEntity);
                    message = "新增成功".GetRes();
                    return(DFPub.EXECUTE_SUCCESS);
                }
            }
            catch (Exception ex)
            {
                message = ex.Message;
                return(DFPub.EXECUTE_ERROR);
            }
        }
        public override int Insert(FormM form, DFDictionary entity, ref string message)
        {
            var item = WF_M_ROLE_MODELLoader.Get(entity["ModelId"], entity["RoleId"]);

            if (item != null)
            {
                throw new WFException("记录已经存在");
            }
            var newEntity = entity.To <WF_M_ROLE_MODEL>();

            var user = string.Empty;

            user = Util.GetCurrentUser().UserName;
            newEntity.CreateTime     = DateTime.Now;
            newEntity.CreateUser     = user;
            newEntity.LastModifyTime = DateTime.Now;
            newEntity.LastModifyUser = user;
            WF_M_ROLE_MODELLoader.Insert(newEntity);
            message = "新增成功".GetRes();
            return(DFPub.EXECUTE_SUCCESS);
        }