Пример #1
0
        /// <summary>
        /// 删除
        /// </summary>
        /// <returns>
        /// 0操作失败,请联系管理员
        /// 1操作成功
        /// 11当前对象已不存在
        /// 14当前数据已经使用,不允许删除
        /// </returns>
        public int Delete(int logUserId, string logUserName, int id)
        {
            int rlt = 1;

            using (var ctx = TranContext.BeginTran())
            {
                try
                {
                    var model = dal.GetModel(ctx, t => t.ID == id);
                    if (model == null)
                    {
                        rlt = 11;
                    }
                    if (rlt == 1 &&
                        (this.BLLProvider.RolePurviewBLL.GetCount(t => t.PurviewId == id) > 0 ||
                         this.BLLProvider.UserPurviewBLL.GetCount(t => t.PurviewId == id) > 0))
                    {
                        rlt = 14;
                    }
                    if (rlt == 1)
                    {
                        #region 系统日志
                        SysLog sysLogModel = new SysLog();
                        sysLogModel.TableName      = "PurviewInfo";
                        sysLogModel.BusinessName   = DatabasePDMHelper.GetDataTableName(sysLogModel.TableName);
                        sysLogModel.CreateUserId   = logUserId;
                        sysLogModel.CreateUserName = logUserName;
                        sysLogModel.ObjectId       = id;
                        sysLogModel.OperationType  = EOperationType.除.GetHashCode();

                        var entry = ctx.Entry(model);
                        if (rlt == 1 && !this.BLLProvider.SysLogBLL.Add(ctx, sysLogModel, entry))
                        {
                            rlt = 0;
                        }
                        #endregion

                        if (!dal.Delete(ctx, model))
                        {
                            rlt = 0;
                        }
                    }
                    if (rlt == 1)
                    {
                        TranContext.Commit(ctx);
                    }
                    else
                    {
                        TranContext.Rollback(ctx);
                    }
                }
                catch (Exception ex)
                {
                    rlt = 0;
                    TranContext.Rollback(ctx);
                    this.BLLProvider.SystemExceptionLogBLL.Add(ex.Source, ex.InnerException.Message, ex.Message);
                }
            }
            return(rlt);
        }
Пример #2
0
        /// <summary>
        /// 操作列表
        /// </summary>
        public DataTable GetActionList(int logUserId, string logUserName, int systemId, int moduleId, int functionId, string actionName, string actionCode, int isEnable, int pageIndex, int pageSize, out int count)
        {
            count = 0;
            try
            {
                DataTable  rlt = dal.GetActionList(systemId, moduleId, functionId, actionName, actionCode, isEnable, pageIndex, pageSize, out count);
                DataColumn col = new DataColumn("PurviewTypeName");
                foreach (DataRow item in rlt.Rows)
                {
                    item["PurviewTypeName"] = (EPurviewType)int.Parse(item["PurviewType"].ToString());
                }

                #region 系统日志
                SysLog sysLogModel = new SysLog();
                sysLogModel.TableName      = "PurviewInfo";
                sysLogModel.BusinessName   = DatabasePDMHelper.GetDataTableName(sysLogModel.TableName);
                sysLogModel.CreateUserId   = logUserId;
                sysLogModel.CreateUserName = logUserName;
                sysLogModel.OperationType  = EOperationType.访问.GetHashCode();
                this.BLLProvider.SysLogBLL.Add(null, sysLogModel, null);
                #endregion
            }
            catch (Exception ex)
            {
                this.BLLProvider.SystemExceptionLogBLL.Add(ex.Source, ex.InnerException.Message, ex.Message);
            }
            return(null);
        }
Пример #3
0
 /// <summary>
 /// 列表
 /// </summary>
 /// <param name="searchType">
 /// 1=编号、2=账号、3=姓名
 /// </param>
 /// <returns></returns>
 public DataTable GetList(int logUserId, string logUserName, int searchType, string keyWord, int isEnable, int pageIndex, int pageSize, out int count)
 {
     count = 0;
     try
     {
         #region 系统日志
         SysLog sysLogModel = new SysLog();
         sysLogModel.TableName      = "UserInfo";
         sysLogModel.BusinessName   = DatabasePDMHelper.GetDataTableName(sysLogModel.TableName);
         sysLogModel.CreateUserId   = logUserId;
         sysLogModel.CreateUserName = logUserName;
         sysLogModel.OperationType  = EOperationType.访问.GetHashCode();
         this.BLLProvider.SysLogBLL.Add(null, sysLogModel, null);
         #endregion
         DataTable rltDt = dal.GetList(searchType, keyWord, isEnable, pageIndex, pageSize, out count);
         var       datas = this.BLLProvider.DataDictionaryBLL.AllDictionary;
         rltDt.Columns.Add("DutyName");
         rltDt.Columns.Add("TitleName");
         foreach (DataRow item in rltDt.Rows)
         {
             item["DutyName"]  = datas.Find(t => t.ID == int.Parse(item["DutyId"].ToString())).Name;
             item["TitleName"] = datas.Find(t => t.ID == int.Parse(item["TitleId"].ToString())).Name;
         }
         return(rltDt);
     }
     catch (Exception ex)
     {
         this.BLLProvider.SystemExceptionLogBLL.Add(ex.Source, ex.InnerException.Message, ex.Message);
     }
     return(null);
 }
Пример #4
0
        /// <summary>
        /// 列表
        /// </summary>
        /// <param name="dp"></param>
        /// <returns></returns>
        public DataTable GetList(int logUserId, string logUserName)
        {
            try
            {
                #region 系统日志
                SysLog sysLogModel = new SysLog();
                sysLogModel.TableName      = "IPBlacklist";
                sysLogModel.BusinessName   = DatabasePDMHelper.GetDataTableName(sysLogModel.TableName);
                sysLogModel.CreateUserId   = logUserId;
                sysLogModel.CreateUserName = logUserName;
                sysLogModel.OperationType  = EOperationType.访问.GetHashCode();
                this.BLLProvider.SysLogBLL.Add(null, sysLogModel, null);
                #endregion

                var list = dal.GetList(t => true).Cast <IPBlacklist>().ToList();

                DataTable  rltDt = ConvertHelper.ToDataTable(list);
                DataColumn col   = new DataColumn("CategoryName");
                rltDt.Columns.Add(col);
                foreach (DataRow item in rltDt.Rows)
                {
                    item["CategoryName"] = (EIPBlacklistCategory)int.Parse(item["Category"].ToString());
                }
            }
            catch (Exception ex)
            {
                this.BLLProvider.SystemExceptionLogBLL.Add(ex.Source, ex.InnerException.Message, ex.Message);
            }
            return(null);
        }
Пример #5
0
        /// <summary>
        /// 列表
        /// </summary>
        /// <param name="dp"></param>
        /// <returns></returns>
        public DataTable GetList(int logUserId, string logUserName, int systemId)
        {
            try
            {
                DataTable  rlt = dal.GetList(systemId);
                DataColumn col = new DataColumn("CategoryName");
                foreach (DataRow item in rlt.Rows)
                {
                    item["CategoryName"] = this.BLLProvider.DataDictionaryBLL.AllDictionary.First(t => t.ID == int.Parse(item["Category"].ToString())).Name;
                }

                #region 系统日志
                SysLog sysLogModel = new SysLog();
                sysLogModel.TableName      = "RoleInfo";
                sysLogModel.BusinessName   = DatabasePDMHelper.GetDataTableName(sysLogModel.TableName);
                sysLogModel.CreateUserId   = logUserId;
                sysLogModel.CreateUserName = logUserName;
                sysLogModel.OperationType  = EOperationType.访问.GetHashCode();
                this.BLLProvider.SysLogBLL.Add(null, sysLogModel, null);
                #endregion
            }
            catch (Exception ex)
            {
                this.BLLProvider.SystemExceptionLogBLL.Add(ex.Source, ex.InnerException.Message, ex.Message);
            }
            return(null);
        }
Пример #6
0
        /// <summary>
        /// 列表
        /// </summary>
        /// <param name="dp"></param>
        /// <returns></returns>
        public DataTable GetList(int logUserId, string logUserName, DateTime startDate, DateTime endDate, int pageIndex, int pageSize, out int count)
        {
            count = 0;
            try
            {
                DateTime tmpStartDate = ConvertHelper.ObjectToDateTime(startDate.ToShortDateString() + " 00:00:00");
                DateTime tmpEndDate   = ConvertHelper.ObjectToDateTime(endDate.AddDays(1).ToShortDateString() + " 00:00:00");
                Expression <Func <SystemExceptionLog, bool> > condition = t => t.CreateDate >= tmpStartDate && t.CreateDate <= endDate;
                List <SystemExceptionLog> list = dal.GetList(pageIndex, pageSize, out count, condition, t => t.CreateDate, false).Cast <SystemExceptionLog>().ToList();

                #region 系统日志
                SysLog sysLogModel = new SysLog();
                sysLogModel.TableName      = "SystemExceptionLog";
                sysLogModel.BusinessName   = DatabasePDMHelper.GetDataTableName(sysLogModel.TableName);
                sysLogModel.CreateUserId   = logUserId;
                sysLogModel.CreateUserName = logUserName;
                sysLogModel.OperationType  = EOperationType.访问.GetHashCode();
                this.BLLProvider.SysLogBLL.Add(null, sysLogModel, null);
                #endregion
                return(ConvertHelper.ToDataTable <SystemExceptionLog>(list));
            }
            catch (Exception ex)
            {
                this.BLLProvider.SystemExceptionLogBLL.Add(ex.Source, ex.InnerException.Message, ex.Message);
            }
            return(null);
        }
Пример #7
0
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="model"></param>
        /// <returns>
        /// 0 失败
        /// 1 成功
        /// 12 名称重复
        /// 13 编码重复
        /// </returns>
        public int Add(MenuInfo model)
        {
            int rlt = 1;

            if (IsRepeatName(model.SystemId, model.Name, model.ID))
            {
                rlt = 12;
            }
            if (rlt == 1 && IsRepeatCode(model.SystemId, model.Code, model.ID))
            {
                rlt = 13;
            }
            if (rlt == 1)
            {
                using (var ctx = TranContext.BeginTran())
                {
                    try
                    {
                        model.ID         = this.GetNewID();
                        model.CreateDate = DateTime.Now;
                        #region 系统日志
                        SysLog sysLogModel = new SysLog();
                        sysLogModel.TableName      = "MenuInfo";
                        sysLogModel.BusinessName   = DatabasePDMHelper.GetDataTableName(sysLogModel.TableName);
                        sysLogModel.CreateUserId   = model.ModifyUserId;
                        sysLogModel.CreateUserName = model.ModifyUserName;
                        sysLogModel.ObjectId       = model.ID;
                        sysLogModel.OperationType  = EOperationType.新增.GetHashCode();

                        var entry = ctx.Entry(model);
                        if (rlt == 1 && !this.BLLProvider.SysLogBLL.Add(ctx, sysLogModel, entry))
                        {
                            rlt = 0;
                        }
                        #endregion
                        if (rlt == 1 && !dal.Insert(ctx, model))
                        {
                            rlt = 0;
                        }
                        if (rlt == 1)
                        {
                            TranContext.Commit(ctx);
                        }
                        else
                        {
                            TranContext.Rollback(ctx);
                        }
                    }
                    catch (Exception ex)
                    {
                        rlt = 0;
                        TranContext.Rollback(ctx);
                        this.BLLProvider.SystemExceptionLogBLL.Add(ex.Source, ex.InnerException.Message, ex.Message);
                    }
                }
            }
            return(rlt);
        }
Пример #8
0
        /// <summary>
        /// 设置用户角色
        /// </summary>
        /// <returns>
        /// 0操作失败,请联系管理员
        /// 1操作成功
        /// </returns>
        public int UserRoleSet(int logUserId, string logUserName, int systemId, int userId, List <int> lstRoleId)
        {
            int rlt = 1;

            using (var ctx = TranContext.BeginTran())
            {
                try
                {
                    #region 系统日志
                    SysLog sysLogModel = new SysLog();
                    sysLogModel.TableName      = "DataDictionary";
                    sysLogModel.BusinessName   = DatabasePDMHelper.GetDataTableName(sysLogModel.TableName);
                    sysLogModel.CreateUserId   = logUserId;
                    sysLogModel.CreateUserName = logUserName;
                    sysLogModel.OperationType  = EOperationType.修改.GetHashCode();

                    if (rlt == 1 && !this.BLLProvider.SysLogBLL.Add(ctx, sysLogModel, null))
                    {
                        rlt = 0;
                    }
                    #endregion

                    dal.Delete(ctx, systemId, userId);
                    List <UserRole> modeList = new List <UserRole>();
                    foreach (var item in lstRoleId)
                    {
                        UserRole model = new UserRole();
                        model.ID             = GetNewID();
                        model.CreateDate     = DateTime.Now;
                        model.CreateUserId   = logUserId;
                        model.CreateUserName = logUserName;
                        model.RoleId         = item;
                        model.UserId         = userId;
                        modeList.Add(model);
                    }
                    if (rlt == 1 && !dal.Insert(ctx, modeList))
                    {
                        rlt = 0;
                    }
                    if (rlt == 1)
                    {
                        TranContext.Commit(ctx);
                    }
                    else
                    {
                        TranContext.Rollback(ctx);
                    }
                }
                catch (Exception ex)
                {
                    rlt = 0;
                    TranContext.Rollback(ctx);
                    this.BLLProvider.SystemExceptionLogBLL.Add(ex.Source, ex.InnerException.Message, ex.Message);
                }
            }
            return(rlt);
        }
Пример #9
0
        /// <summary>
        /// 角色成员添加
        /// </summary>
        /// <param name="xmlCredentials"></param>
        /// <param name="roleId"></param>
        /// <param name="userIdList"></param>
        /// <returns>
        /// 0 成功
        /// 1 失败
        /// </returns>
        public int Add(int logUserId, string logUserName, int roleId, List <int> userIdList)
        {
            int rlt = 1;

            using (var ctx = TranContext.BeginTran())
            {
                try
                {
                    List <UserRole> list = new List <UserRole>();
                    foreach (var item in userIdList)
                    {
                        UserRole model = new UserRole();
                        model.ID             = dal.GetNewID("UserRole");
                        model.UserId         = item;
                        model.RoleId         = roleId;
                        model.CreateDate     = DateTime.Now;
                        model.CreateUserId   = logUserId;
                        model.CreateUserName = logUserName;
                        list.Add(model);

                        #region 系统日志
                        SysLog sysLogModel = new SysLog();
                        sysLogModel.TableName      = "UserRole";
                        sysLogModel.BusinessName   = DatabasePDMHelper.GetDataTableName(sysLogModel.TableName);
                        sysLogModel.CreateUserId   = logUserId;
                        sysLogModel.CreateUserName = logUserName;
                        sysLogModel.OperationType  = EOperationType.新增.GetHashCode();
                        var entry = ctx.Entry(model);
                        if (rlt == 1 && !this.BLLProvider.SysLogBLL.Add(ctx, sysLogModel, entry))
                        {
                            rlt = 0;
                        }
                        #endregion
                    }

                    if (rlt == 1 && !this.BLLProvider.UserRoleBLL.Insert(ctx, list))
                    {
                        rlt = 0;
                    }
                    if (rlt == 1)
                    {
                        TranContext.Commit(ctx);
                    }
                    else
                    {
                        TranContext.Rollback(ctx);
                    }
                }
                catch (Exception ex)
                {
                    rlt = 0;
                    TranContext.Rollback(ctx);
                    this.BLLProvider.SystemExceptionLogBLL.Add(ex.Source, ex.InnerException.Message, ex.Message);
                }
            }
            return(rlt);
        }
Пример #10
0
        /// <summary>
        /// 角色成员删除
        /// </summary>
        /// <returns>
        /// 0
        /// 1
        /// 15 该成员不能删除,因为该成员只有一个角色
        /// </returns>
        public int Delete(int logUserId, string logUserName, int roleId, int userId)
        {
            int rlt = 1;

            using (var ctx = TranContext.BeginTran())
            {
                try
                {
                    int count = this.BLLProvider.UserRoleBLL.GetCount(t => t.UserId == userId);
                    if (count == 1)
                    {
                        rlt = 15;
                    }
                    var model = this.BLLProvider.UserRoleBLL.GetModel(ctx, t => t.UserId == userId && t.RoleId == roleId);
                    if (rlt == 1 && !this.BLLProvider.UserRoleBLL.Delete(ctx, model))
                    {
                        rlt = 0;
                    }
                    if (rlt == 1 && !this.BLLProvider.UserPurviewBLL.Delete(ctx, t => t.RoleId == roleId && t.UserId == userId))
                    {
                        rlt = 0;
                    }

                    #region 系统日志
                    SysLog sysLogModel = new SysLog();
                    sysLogModel.TableName      = "UserRole";
                    sysLogModel.BusinessName   = DatabasePDMHelper.GetDataTableName(sysLogModel.TableName);
                    sysLogModel.CreateUserId   = logUserId;
                    sysLogModel.CreateUserName = logUserName;
                    sysLogModel.OperationType  = EOperationType.除.GetHashCode();
                    var entry = ctx.Entry(model);
                    if (rlt == 1 && !this.BLLProvider.SysLogBLL.Add(ctx, sysLogModel, entry))
                    {
                        rlt = 0;
                    }
                    #endregion
                    if (rlt == 1)
                    {
                        TranContext.Commit(ctx);
                    }
                    else
                    {
                        TranContext.Rollback(ctx);
                    }
                }
                catch (Exception ex)
                {
                    rlt = 0;
                    TranContext.Rollback(ctx);
                    this.BLLProvider.SystemExceptionLogBLL.Add(ex.Source, ex.InnerException.Message, ex.Message);
                }
            }
            return(rlt);
        }
Пример #11
0
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="ctx"></param>
        /// <param name="model"></param>
        /// <param name="entry"></param>
        /// <returns></returns>
        internal bool Add(BPMSEntities ctx, SysLog model, DbEntityEntry entry)
        {
            /// 资源
            /// http://www.cnblogs.com/oppoic/p/ef_dbpropertyvalues_toobject_clone_setvalues_changetracker_entries.html
            List <SysLogDetails> logDetailList = new List <SysLogDetails>();
            bool rlt = true;

            model.ID = GetNewID();
            var location = IPHelper.GetLocation();

            model.IPAddress      = location.GetIPAddress.ToString();
            model.IPAddressName  = location.ToString();
            model.CreateDate     = DateTime.Now;
            model.CreateUserId   = model.CreateUserId;
            model.CreateUserName = model.CreateUserName;

            if (!Insert(ctx, model))
            {
                rlt = false;
            }
            if (rlt == true && entry != null)
            {
                IEnumerable <string> propertyNames = null;
                if (model.OperationType == EOperationType.新增.GetHashCode() || model.OperationType == EOperationType.除.GetHashCode())
                {
                    propertyNames = entry.CurrentValues.PropertyNames;
                }
                else if (model.OperationType == EOperationType.修改.GetHashCode())
                {
                    propertyNames = entry.CurrentValues.PropertyNames.Where(t => entry.Property(t).IsModified);
                }
                foreach (var propertyName in propertyNames)
                {
                    SysLogDetails logDetail = new SysLogDetails();
                    logDetail.ID        = GetNewID("SysLogDetails");
                    logDetail.SyslogId  = model.ID;
                    logDetail.FieldName = propertyName;
                    logDetail.FieldText = DatabasePDMHelper.GetColumnName(model.TableName, propertyName);
                    logDetail.NewValue  = entry.Property(propertyName).CurrentValue.ToString();
                    logDetail.OldValue  = entry.Property(propertyName).OriginalValue.ToString();
                    logDetailList.Add(logDetail);
                }
                SysLogDetailsDal detailDal = new SysLogDetailsDal();
                if (!detailDal.Insert(ctx, logDetailList))
                {
                    rlt = false;
                }
            }
            return(rlt);
        }
Пример #12
0
        /// <summary>
        /// 重置密码
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public bool PasswordReset(int logUserId, string logUserName, int id)
        {
            int rlt = 1;

            using (var ctx = TranContext.BeginTran())
            {
                try
                {
                    var    model  = dal.GetModel(ctx, t => t.ID == id);
                    string md5Pwd = FormsAuthentication.HashPasswordForStoringInConfigFile(model.Account, "MD5").Substring(0, 20);
                    model.Password = md5Pwd;

                    #region 系统日志
                    SysLog sysLogModel = new SysLog();
                    sysLogModel.TableName      = "UserInfo";
                    sysLogModel.BusinessName   = DatabasePDMHelper.GetDataTableName(sysLogModel.TableName);
                    sysLogModel.CreateUserId   = logUserId;
                    sysLogModel.CreateUserName = logUserName;
                    sysLogModel.ObjectId       = model.ID;
                    sysLogModel.OperationType  = EOperationType.修改.GetHashCode();
                    sysLogModel.Remark         = "重置用户密码";
                    if (rlt == 1 && !this.BLLProvider.SysLogBLL.Add(ctx, sysLogModel, null))
                    {
                        rlt = 0;
                    }
                    #endregion
                    if (rlt == 1 && !dal.Update(ctx, model))
                    {
                        rlt = 0;
                    }
                    if (rlt == 1)
                    {
                        TranContext.Commit(ctx);
                    }
                    else
                    {
                        TranContext.Rollback(ctx);
                    }
                    return(rlt == 1 ? true : false);
                }
                catch (Exception ex)
                {
                    rlt = 0;
                    TranContext.Rollback(ctx);
                    this.BLLProvider.SystemExceptionLogBLL.Add(ex.Source, ex.InnerException.Message, ex.Message);
                }
            }
            return(rlt == 1 ? true : false);
        }
Пример #13
0
        /// <summary>
        /// 设置用户权限
        /// </summary>
        /// <returns>
        /// 0 失败
        /// 1 成功
        /// </returns>
        public int UserPurviewSet(int logUserId, string logUserName, List <UserPurview> modelList)
        {
            int rlt = 1;

            using (var ctx = TranContext.BeginTran())
            {
                try
                {
                    #region 系统日志
                    SysLog sysLogModel = new SysLog();
                    sysLogModel.TableName      = "UserPurview";
                    sysLogModel.BusinessName   = DatabasePDMHelper.GetDataTableName(sysLogModel.TableName);
                    sysLogModel.CreateUserId   = logUserId;
                    sysLogModel.CreateUserName = logUserName;
                    sysLogModel.OperationType  = EOperationType.修改.GetHashCode();
                    sysLogModel.Remark         = "分配用户权限";
                    if (rlt == 1 && !this.BLLProvider.SysLogBLL.Add(ctx, sysLogModel, null))
                    {
                        rlt = 0;
                    }
                    #endregion

                    if (rlt == 1 && !dal.Delete(ctx, t => t.UserId == modelList.First().UserId&& t.RoleId == modelList.First().RoleId))
                    {
                        rlt = 0;
                    }
                    if (rlt == 1 && !dal.Insert(ctx, modelList))
                    {
                        rlt = 0;
                    }
                    if (rlt == 1)
                    {
                        TranContext.Commit(ctx);
                    }
                    else
                    {
                        TranContext.Rollback(ctx);
                    }
                }
                catch (Exception ex)
                {
                    rlt = 0;
                    TranContext.Rollback(ctx);
                    this.BLLProvider.SystemExceptionLogBLL.Add(ex.Source, ex.InnerException.Message, ex.Message);
                }
            }
            return(rlt);
        }
Пример #14
0
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="idList"></param>
        /// <returns>
        /// 0操作失败,请联系管理员
        /// 1操作成功
        /// </returns>
        public int Delete(int logUserId, string logUserName, int systemId, int roleId, int userId)
        {
            int rlt = 1;

            using (var ctx = TranContext.BeginTran())
            {
                try
                {
                    if (rlt == 1)
                    {
                        #region 系统日志
                        SysLog sysLogModel = new SysLog();
                        sysLogModel.TableName      = "UserPurview";
                        sysLogModel.BusinessName   = DatabasePDMHelper.GetDataTableName(sysLogModel.TableName);
                        sysLogModel.CreateUserId   = logUserId;
                        sysLogModel.CreateUserName = logUserName;
                        sysLogModel.OperationType  = EOperationType.除.GetHashCode();
                        sysLogModel.Remark         = "重置用户权限";
                        if (rlt == 1 && !this.BLLProvider.SysLogBLL.Add(ctx, sysLogModel, null))
                        {
                            rlt = 0;
                        }
                        #endregion

                        dal.Delete(ctx, systemId, roleId, userId);
                    }
                    if (rlt == 1)
                    {
                        TranContext.Commit(ctx);
                    }
                    else
                    {
                        TranContext.Rollback(ctx);
                    }
                }
                catch (Exception ex)
                {
                    rlt = 0;
                    TranContext.Rollback(ctx);
                    this.BLLProvider.SystemExceptionLogBLL.Add(ex.Source, ex.InnerException.Message, ex.Message);
                }
            }
            return(rlt);
        }
Пример #15
0
 /// <summary>
 /// 用户权限列表
 /// </summary>
 /// <returns></returns>
 public DataTable GetList(int logUserId, string logUserName, int systemId, int roleId, int userId)
 {
     try
     {
         #region 系统日志
         SysLog sysLogModel = new SysLog();
         sysLogModel.TableName      = "UserPurview";
         sysLogModel.BusinessName   = DatabasePDMHelper.GetDataTableName(sysLogModel.TableName);
         sysLogModel.CreateUserId   = logUserId;
         sysLogModel.CreateUserName = logUserName;
         sysLogModel.OperationType  = EOperationType.访问.GetHashCode();
         this.BLLProvider.SysLogBLL.Add(null, sysLogModel, null);
         #endregion
         return(GetUserPurview(systemId, roleId, userId));
     }
     catch (Exception ex)
     {
         this.BLLProvider.SystemExceptionLogBLL.Add(ex.Source, ex.InnerException.Message, ex.Message);
     }
     return(null);
 }
Пример #16
0
        /// <summary>
        /// 删除 将在此时间之前的日志删除
        /// </summary>
        /// <param name="endDate">截止日期</param>
        /// <returns></returns>
        public int Delete(int logUserId, string logUserName, int systemId, DateTime endDate)
        {
            int rlt = 1;

            using (var ctx = TranContext.BeginTran())
            {
                try
                {
                    #region 系统日志
                    SysLog sysLogModel = new SysLog();
                    sysLogModel.TableName      = "SysLoginLog";
                    sysLogModel.BusinessName   = DatabasePDMHelper.GetDataTableName(sysLogModel.TableName);
                    sysLogModel.CreateUserId   = logUserId;
                    sysLogModel.CreateUserName = logUserName;
                    sysLogModel.OperationType  = EOperationType.除.GetHashCode();
                    this.BLLProvider.SysLogBLL.Add(ctx, sysLogModel, null);
                    #endregion
                    if (!dal.Delete(ctx, t => t.SystemId == systemId && t.CreateDate <= endDate))
                    {
                        rlt = 0;
                    }
                    if (rlt == 1)
                    {
                        TranContext.Commit(ctx);
                    }
                    else
                    {
                        TranContext.Rollback(ctx);
                    }
                }
                catch (Exception ex)
                {
                    rlt = 0;
                    TranContext.Rollback(ctx);
                    this.BLLProvider.SystemExceptionLogBLL.Add(ex.Source, ex.InnerException.Message, ex.Message);
                }
            }
            return(rlt);
        }
Пример #17
0
 /// <summary>
 /// 列表
 /// </summary>
 /// <param name="dp"></param>
 /// <returns></returns>
 public DataTable GetList(int logUserId, string logUserName, DateTime startDate, DateTime endDate, int systemId, string account, int pageIndex, int pageSize, out int count)
 {
     count = 0;
     try
     {
         #region 系统日志
         SysLog sysLogModel = new SysLog();
         sysLogModel.TableName      = "SysLoginLog";
         sysLogModel.BusinessName   = DatabasePDMHelper.GetDataTableName(sysLogModel.TableName);
         sysLogModel.CreateUserId   = logUserId;
         sysLogModel.CreateUserName = logUserName;
         sysLogModel.OperationType  = EOperationType.访问.GetHashCode();
         this.BLLProvider.SysLogBLL.Add(null, sysLogModel, null);
         #endregion
         return(dal.GetList(startDate, endDate, systemId, account, pageIndex, pageSize, out count));
     }
     catch (Exception ex)
     {
         this.BLLProvider.SystemExceptionLogBLL.Add(ex.Source, ex.InnerException.Message, ex.Message);
     }
     return(null);
 }
Пример #18
0
        /// <summary>
        /// 列表
        /// </summary>
        /// <returns></returns>
        public DataTable GetList(int logUserId, string logUserName, int systemId, int dictType)
        {
            try
            {
                var list = dal.GetList(t => t.SystemId == systemId && t.DictType == dictType).Cast <DataDictionary>()
                           .Select(t => new
                {
                    t.ID,
                    t.DictType,
                    t.Name,
                    t.Code,
                    t.ParentId,
                    t.IsEnable,
                    t.Remark,
                    t.SortIndex,
                    t.AllowDelete,
                    t.AllowEdit
                });

                #region 系统日志
                SysLog sysLogModel = new SysLog();
                sysLogModel.TableName      = "DataDictionary";
                sysLogModel.BusinessName   = DatabasePDMHelper.GetDataTableName(sysLogModel.TableName);
                sysLogModel.CreateUserId   = logUserId;
                sysLogModel.CreateUserName = logUserName;
                sysLogModel.OperationType  = EOperationType.访问.GetHashCode();
                this.BLLProvider.SysLogBLL.Add(null, sysLogModel, null);
                #endregion

                return(ConvertHelper.ToDataTable(list.Cast <object>().ToArray()));
            }
            catch (Exception ex)
            {
                this.BLLProvider.SystemExceptionLogBLL.Add(ex.Source, ex.InnerException.Message, ex.Message);
            }
            return(null);
        }
Пример #19
0
        /// <summary>
        /// 列表
        /// </summary>
        /// <param name="dp"></param>
        /// <returns></returns>
        public DataTable GetList(int logUserId, string logUserName)
        {
            try
            {
                var list = dal.GetList(t => true).Cast <DataDictionary>().ToList();

                #region 系统日志
                SysLog sysLogModel = new SysLog();
                sysLogModel.TableName      = "SystemInfo";
                sysLogModel.BusinessName   = DatabasePDMHelper.GetDataTableName(sysLogModel.TableName);
                sysLogModel.CreateUserId   = logUserId;
                sysLogModel.CreateUserName = logUserName;
                sysLogModel.OperationType  = EOperationType.访问.GetHashCode();
                this.BLLProvider.SysLogBLL.Add(null, sysLogModel, null);
                #endregion

                return(ConvertHelper.ToDataTable(list));
            }
            catch (Exception ex)
            {
                this.BLLProvider.SystemExceptionLogBLL.Add(ex.Source, ex.InnerException.Message, ex.Message);
            }
            return(null);
        }
Пример #20
0
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="model"></param>
        /// <returns>
        /// 0操作失败,请联系管理员
        /// 1操作成功
        /// 11当前对象已不存在
        /// 17账号重复
        /// 13编码重复
        /// </returns>
        public int Edit(UserInfo model)
        {
            int rlt = 1;

            using (var ctx = TranContext.BeginTran())
            {
                try
                {
                    var oldModel = dal.GetModel(ctx, t => t.ID == model.ID);
                    if (oldModel == null)
                    {
                        rlt = 11;
                    }
                    if (rlt == 1 && IsRepeatAccount(model.Account, model.ID))
                    {
                        rlt = 17;
                    }
                    if (rlt == 1 && IsRepeatCode(model.Code, model.ID))
                    {
                        rlt = 13;
                    }
                    if (rlt == 1)
                    {
                        #region Model
                        oldModel.Name           = model.Name;
                        oldModel.Spell          = model.Spell;
                        oldModel.Alias          = model.Alias;
                        oldModel.RoleId         = model.RoleId;
                        oldModel.Gender         = model.Gender;
                        oldModel.Mobile         = model.Mobile;
                        oldModel.Telephone      = model.Telephone;
                        oldModel.Birthday       = model.Birthday;
                        oldModel.Email          = model.Email;
                        oldModel.OICQ           = model.OICQ;
                        oldModel.DutyId         = model.DutyId;
                        oldModel.TitleId        = model.TitleId;
                        oldModel.CompanyId      = model.CompanyId;
                        oldModel.DepartmentId   = model.DepartmentId;
                        oldModel.WorkgroupId    = model.WorkgroupId;
                        oldModel.Remark         = model.Remark;
                        oldModel.IsEnable       = model.IsEnable;
                        oldModel.SortIndex      = model.SortIndex;
                        oldModel.ModifyDate     = DateTime.Now;
                        oldModel.ModifyUserId   = model.ModifyUserId;
                        oldModel.ModifyUserName = model.ModifyUserName;
                        #endregion

                        #region 系统日志
                        SysLog sysLogModel = new SysLog();
                        sysLogModel.TableName      = "UserInfo";
                        sysLogModel.BusinessName   = DatabasePDMHelper.GetDataTableName(sysLogModel.TableName);
                        sysLogModel.CreateUserId   = model.ModifyUserId;
                        sysLogModel.CreateUserName = model.ModifyUserName;
                        sysLogModel.ObjectId       = model.ID;
                        sysLogModel.OperationType  = EOperationType.修改.GetHashCode();

                        var entry = ctx.Entry(oldModel);
                        if (rlt == 1 && !this.BLLProvider.SysLogBLL.Add(ctx, sysLogModel, entry))
                        {
                            rlt = 0;
                        }
                        #endregion

                        if (rlt == 1 && !dal.Insert(ctx, oldModel))
                        {
                            rlt = 0;
                        }
                    }
                    if (rlt == 1)
                    {
                        TranContext.Commit(ctx);
                    }
                    else
                    {
                        TranContext.Rollback(ctx);
                    }
                }
                catch (Exception ex)
                {
                    rlt = 0;
                    TranContext.Rollback(ctx);
                    this.BLLProvider.SystemExceptionLogBLL.Add(ex.Source, ex.InnerException.Message, ex.Message);
                }
            }
            return(rlt);
        }
Пример #21
0
        /// <summary>
        /// 设置权限
        /// </summary>
        /// <param name="roleId"></param>
        /// <param name="purviewIdList"></param>
        /// <returns>
        /// 0 失败
        /// 1 成功
        /// </returns>
        public int PurviewSet(int logUserId, string logUserName, int roleId, List <int> purviewIdList)
        {
            int rlt = 1;

            using (var ctx = TranContext.BeginTran())
            {
                try
                {
                    if (!dal.Delete(ctx, t => t.RoleId == roleId))
                    {
                        rlt = 0;
                    }
                    if (rlt == 1)
                    {
                        List <RolePurview> list = new List <RolePurview>();
                        foreach (var item in purviewIdList)
                        {
                            RolePurview model = new RolePurview();
                            model.ID        = GetNewID();
                            model.RoleId    = roleId;
                            model.PurviewId = item;
                            list.Add(model);
                        }
                        if (!dal.Insert(ctx, list))
                        {
                            rlt = 0;
                        }
                    }
                    if (rlt == 1)
                    {
                        #region 系统日志
                        SysLog sysLogModel = new SysLog();
                        sysLogModel.TableName      = "RolePurview";
                        sysLogModel.BusinessName   = DatabasePDMHelper.GetDataTableName(sysLogModel.TableName);
                        sysLogModel.CreateUserId   = logUserId;
                        sysLogModel.CreateUserName = logUserName;
                        sysLogModel.OperationType  = EOperationType.修改.GetHashCode();
                        if (rlt == 1 && !this.BLLProvider.SysLogBLL.Add(ctx, sysLogModel, null))
                        {
                            rlt = 0;
                        }
                        #endregion
                    }
                    if (rlt == 1)
                    {
                        TranContext.Commit(ctx);
                    }
                    else
                    {
                        TranContext.Rollback(ctx);
                    }
                }
                catch (Exception ex)
                {
                    rlt = 0;
                    TranContext.Rollback(ctx);
                    this.BLLProvider.SystemExceptionLogBLL.Add(ex.Source, ex.InnerException.Message, ex.Message);
                }
            }
            return(rlt);
        }
Пример #22
0
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="model"></param>
        /// <returns>
        /// 0操作失败,请联系管理员
        /// 1操作成功
        /// 11当前对象已不存在
        /// </returns>
        public int Edit(IPBlacklist model)
        {
            int rlt = 1;

            using (var ctx = TranContext.BeginTran())
            {
                try
                {
                    var oldModel = dal.GetModel(ctx, t => t.ID == model.ID);
                    if (oldModel == null)
                    {
                        rlt = 11;
                    }
                    if (rlt == 1)
                    {
                        oldModel.StartIp        = model.StartIp;
                        oldModel.EndIp          = model.EndIp;
                        oldModel.Failuretime    = model.Failuretime;
                        oldModel.Remark         = model.Remark;
                        oldModel.IsEnable       = model.IsEnable;
                        oldModel.SortIndex      = model.SortIndex;
                        oldModel.ModifyDate     = DateTime.Now;
                        oldModel.ModifyUserId   = model.ModifyUserId;
                        oldModel.ModifyUserName = model.ModifyUserName;

                        #region 系统日志
                        SysLog sysLogModel = new SysLog();
                        sysLogModel.TableName      = "IPBlacklist";
                        sysLogModel.BusinessName   = DatabasePDMHelper.GetDataTableName(sysLogModel.TableName);
                        sysLogModel.CreateUserId   = model.ModifyUserId;
                        sysLogModel.CreateUserName = model.ModifyUserName;
                        sysLogModel.ObjectId       = model.ID;
                        sysLogModel.OperationType  = EOperationType.修改.GetHashCode();

                        var entry = ctx.Entry(oldModel);
                        if (rlt == 1 && !this.BLLProvider.SysLogBLL.Add(ctx, sysLogModel, entry))
                        {
                            rlt = 0;
                        }
                        #endregion

                        if (rlt == 1 && !dal.Insert(ctx, oldModel))
                        {
                            rlt = 0;
                        }
                    }
                    if (rlt == 1)
                    {
                        TranContext.Commit(ctx);
                    }
                    else
                    {
                        TranContext.Rollback(ctx);
                    }
                }
                catch (Exception ex)
                {
                    rlt = 0;
                    TranContext.Rollback(ctx);
                    this.BLLProvider.SystemExceptionLogBLL.Add(ex.Source, ex.InnerException.Message, ex.Message);
                }
            }
            return(rlt);
        }
Пример #23
0
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="idList"></param>
        /// <returns>
        /// 0操作失败,请联系管理员
        /// 1操作成功
        /// 11当前对象已不存在
        /// 14当前数据已经使用,不允许删除
        /// </returns>
        public int Delete(int logUserId, string logUserName, int id)
        {
            int rlt = 1;

            using (var ctx = TranContext.BeginTran())
            {
                try
                {
                    var model = dal.GetModel(ctx, t => t.ID == id);
                    if (model == null)
                    {
                        rlt = 11;
                    }
                    if (rlt == 1)
                    {
                        #region 判断当前数据是否使用
                        int count = 0;
                        switch ((EDictType)model.DictType)
                        {
                        case EDictType.国籍:
                            count = this.BLLProvider.EmployeeBLL.GetCount(t => t.NationId == id);
                            break;

                        case EDictType.角色分类:
                            count = this.BLLProvider.RoleInfoBLL.GetCount(t => t.Category == id);
                            break;

                        case EDictType.民族:
                            count = this.BLLProvider.EmployeeBLL.GetCount(t => t.NationalityId == id);
                            break;

                        case EDictType.学历:
                            count = this.BLLProvider.EmployeeBLL.GetCount(t => t.EducationId == id);
                            break;

                        case EDictType.学位:
                            count = this.BLLProvider.EmployeeBLL.GetCount(t => t.DegreeId == id);
                            break;

                        case EDictType.用工性质:
                            count = this.BLLProvider.EmployeeBLL.GetCount(t => t.WorkingPropertyId == id);
                            break;

                        case EDictType.政治面貌:
                            count = this.BLLProvider.EmployeeBLL.GetCount(t => t.PartyId == id);
                            break;

                        case EDictType.职称:
                            count = this.BLLProvider.EmployeeBLL.GetCount(t => t.TitleId == id);
                            break;

                        case EDictType.职称等级:
                            count = this.BLLProvider.EmployeeBLL.GetCount(t => t.TitleLevelId == id);
                            break;

                        case EDictType.职位:
                            count = this.BLLProvider.EmployeeBLL.GetCount(t => t.DutyId == id);
                            break;
                        }
                        if (count > 0)
                        {
                            rlt = 14;
                        }
                        #endregion
                    }
                    if (rlt == 1)
                    {
                        #region 系统日志
                        SysLog sysLogModel = new SysLog();
                        sysLogModel.TableName      = "DataDictionary";
                        sysLogModel.BusinessName   = DatabasePDMHelper.GetDataTableName(sysLogModel.TableName);
                        sysLogModel.CreateUserId   = logUserId;
                        sysLogModel.CreateUserName = logUserName;
                        sysLogModel.ObjectId       = id;
                        sysLogModel.OperationType  = EOperationType.除.GetHashCode();

                        var entry = ctx.Entry(model);
                        if (rlt == 1 && !this.BLLProvider.SysLogBLL.Add(ctx, sysLogModel, entry))
                        {
                            rlt = 0;
                        }
                        #endregion

                        if (!dal.Delete(ctx, model))
                        {
                            rlt = 0;
                        }
                    }
                    if (rlt == 1)
                    {
                        TranContext.Commit(ctx);
                    }
                    else
                    {
                        TranContext.Rollback(ctx);
                    }
                }
                catch (Exception ex)
                {
                    rlt = 0;
                    TranContext.Rollback(ctx);
                    this.BLLProvider.SystemExceptionLogBLL.Add(ex.Source, ex.InnerException.Message, ex.Message);
                }
            }
            return(rlt);
        }
Пример #24
0
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="model"></param>
        /// <returns>
        /// 0 失败
        /// 1 成功
        /// 17 账号重复
        /// 13 编码重复
        /// </returns>
        public int Add(UserInfo model)
        {
            int rlt = 1;

            if (IsRepeatAccount(model.Account, model.ID))
            {
                rlt = 17;
            }
            if (rlt == 1 && IsRepeatCode(model.Code, model.ID))
            {
                rlt = 13;
            }
            if (rlt == 1)
            {
                using (var ctx = TranContext.BeginTran())
                {
                    try
                    {
                        model.ID = this.GetNewID();

                        string md5Pwd = FormsAuthentication.HashPasswordForStoringInConfigFile(model.Account, "MD5").Substring(0, 20);
                        model.Password = md5Pwd;

                        #region 系统日志
                        SysLog sysLogModel = new SysLog();
                        sysLogModel.TableName      = "UserInfo";
                        sysLogModel.BusinessName   = DatabasePDMHelper.GetDataTableName(sysLogModel.TableName);
                        sysLogModel.CreateUserId   = model.ModifyUserId;
                        sysLogModel.CreateUserName = model.ModifyUserName;
                        sysLogModel.ObjectId       = model.ID;
                        sysLogModel.OperationType  = EOperationType.新增.GetHashCode();

                        var entry = ctx.Entry(model);
                        if (rlt == 1 && !this.BLLProvider.SysLogBLL.Add(ctx, sysLogModel, entry))
                        {
                            rlt = 0;
                        }
                        #endregion
                        if (rlt == 1 && !dal.Insert(ctx, model))
                        {
                            rlt = 0;
                        }
                        if (rlt == 1)
                        {
                            TranContext.Commit(ctx);
                        }
                        else
                        {
                            TranContext.Rollback(ctx);
                        }
                    }
                    catch (Exception ex)
                    {
                        rlt = 0;
                        TranContext.Rollback(ctx);
                        this.BLLProvider.SystemExceptionLogBLL.Add(ex.Source, ex.InnerException.Message, ex.Message);
                    }
                }
            }
            return(rlt);
        }
Пример #25
0
        /// <summary>
        /// 列表
        /// </summary>
        /// <param name="category"></param>
        /// <param name="searchType">1=工号、2=姓名</param>
        /// <param name="keyWord"></param>
        /// <returns></returns>
        public DataTable GetList(int logUserId, string logUserName, EOrgaCategory category, int orgaId, int searchType, string keyWord, int pageIndex, int pageSize, out int count)
        {
            count = 0;
            try
            {
                #region 系统日志
                SysLog sysLogModel = new SysLog();
                sysLogModel.TableName      = "Employee";
                sysLogModel.BusinessName   = DatabasePDMHelper.GetDataTableName(sysLogModel.TableName);
                sysLogModel.CreateUserId   = logUserId;
                sysLogModel.CreateUserName = logUserName;
                sysLogModel.OperationType  = EOperationType.访问.GetHashCode();
                this.BLLProvider.SysLogBLL.Add(null, sysLogModel, null);
                #endregion

                Expression <Func <Employee, bool> > condition = t => true;
                if (category == EOrgaCategory.集团)
                {
                    condition.And(t => t.SubCompanyId == orgaId);
                }
                else if (category == EOrgaCategory.公司)
                {
                    condition.And(t => t.CompanyId == orgaId);
                }
                else if (category == EOrgaCategory.部门)
                {
                    condition.And(t => t.DepartmentId == orgaId);
                }
                else if (category == EOrgaCategory.工作组)
                {
                    condition.And(t => t.WorkgroupId == orgaId);
                }

                if (searchType == 1)
                {
                    condition.And(t => t.Code == keyWord);
                }
                if (searchType == 2)
                {
                    condition.And(t => t.Name == keyWord);
                }


                List <Employee> list  = dal.GetList(pageIndex, pageSize, out count, condition, t => t.Code, true).Cast <Employee>().ToList();
                DataTable       rltDt = ConvertHelper.ToDataTable(list);
                rltDt.Columns.AddRange(new DataColumn[]
                {
                    new DataColumn("DutyName"),
                    new DataColumn("EducationName"),
                    new DataColumn("DegreeName"),
                    new DataColumn("TitleName"),
                    new DataColumn("TitleLevelName"),
                    new DataColumn("PartyName"),
                    new DataColumn("NationName"),
                    new DataColumn("NationalityName"),
                    new DataColumn("WorkingPropertyName"),
                    new DataColumn("CompetencyName"),
                });

                var dict = this.BLLProvider.DataDictionaryBLL.AllDictionary;
                foreach (DataRow item in rltDt.Rows)
                {
                    item["DutyName"]            = dict.Find(t => t.ID == int.Parse(item["DutyId"].ToString())).Name;
                    item["EducationName"]       = dict.Find(t => t.ID == int.Parse(item["Education"].ToString())).Name;
                    item["DegreeName"]          = dict.Find(t => t.ID == int.Parse(item["Degree"].ToString())).Name;
                    item["TitleName"]           = dict.Find(t => t.ID == int.Parse(item["TitleId"].ToString())).Name;
                    item["TitleLevelName"]      = dict.Find(t => t.ID == int.Parse(item["DutyId"].ToString())).Name;
                    item["PartyName"]           = dict.Find(t => t.ID == int.Parse(item["DutyId"].ToString())).Name;
                    item["NationName"]          = dict.Find(t => t.ID == int.Parse(item["DutyId"].ToString())).Name;
                    item["NationalityName"]     = dict.Find(t => t.ID == int.Parse(item["DutyId"].ToString())).Name;
                    item["WorkingPropertyName"] = dict.Find(t => t.ID == int.Parse(item["DutyId"].ToString())).Name;
                    item["CompetencyName"]      = dict.Find(t => t.ID == int.Parse(item["DutyId"].ToString())).Name;
                }



                return(rltDt);
            }
            catch (Exception ex)
            {
                this.BLLProvider.SystemExceptionLogBLL.Add(ex.Source, ex.InnerException.Message, ex.Message);
            }
            return(null);
        }
Пример #26
0
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="model"></param>
        /// <returns>
        /// 0操作失败,请联系管理员
        /// 1操作成功
        /// 11当前对象已不存在
        /// 12名称重复
        /// 13编码重复
        /// </returns>
        public int Edit(MenuInfo model)
        {
            int rlt = 1;

            using (var ctx = TranContext.BeginTran())
            {
                try
                {
                    var oldModel = dal.GetModel(ctx, t => t.ID == model.ID);
                    if (oldModel == null)
                    {
                        rlt = 11;
                    }
                    if (rlt == 1 && IsRepeatName(model.SystemId, model.Name, model.ID))
                    {
                        rlt = 12;
                    }
                    if (rlt == 1 && IsRepeatCode(model.SystemId, model.Code, model.ID))
                    {
                        rlt = 13;
                    }
                    if (rlt == 1)
                    {
                        oldModel.Name           = model.Name;
                        oldModel.Code           = model.Code;
                        oldModel.ParentId       = model.ParentId;
                        oldModel.Category       = model.Category;
                        oldModel.PurviewId      = model.PurviewId;
                        oldModel.Icon           = model.Icon;
                        oldModel.IconUrl        = model.IconUrl;
                        oldModel.NavigateUrl    = model.NavigateUrl;
                        oldModel.FormName       = model.FormName;
                        oldModel.IsSplit        = model.IsSplit;
                        oldModel.Remark         = model.Remark;
                        oldModel.IsEnable       = model.IsEnable;
                        oldModel.SortIndex      = model.SortIndex;
                        oldModel.ModifyDate     = DateTime.Now;
                        oldModel.ModifyUserId   = model.ModifyUserId;
                        oldModel.ModifyUserName = model.ModifyUserName;

                        #region 系统日志
                        SysLog sysLogModel = new SysLog();
                        sysLogModel.TableName      = "MenuInfo";
                        sysLogModel.BusinessName   = DatabasePDMHelper.GetDataTableName(sysLogModel.TableName);
                        sysLogModel.CreateUserId   = model.ModifyUserId;
                        sysLogModel.CreateUserName = model.ModifyUserName;
                        sysLogModel.ObjectId       = model.ID;
                        sysLogModel.OperationType  = EOperationType.修改.GetHashCode();

                        var entry = ctx.Entry(oldModel);
                        if (rlt == 1 && !this.BLLProvider.SysLogBLL.Add(ctx, sysLogModel, entry))
                        {
                            rlt = 0;
                        }
                        #endregion

                        if (rlt == 1 && !dal.Insert(ctx, oldModel))
                        {
                            rlt = 0;
                        }
                    }
                    if (rlt == 1)
                    {
                        TranContext.Commit(ctx);
                    }
                    else
                    {
                        TranContext.Rollback(ctx);
                    }
                }
                catch (Exception ex)
                {
                    rlt = 0;
                    TranContext.Rollback(ctx);
                    this.BLLProvider.SystemExceptionLogBLL.Add(ex.Source, ex.InnerException.Message, ex.Message);
                }
            }
            return(rlt);
        }
Пример #27
0
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="model"></param>
        /// <returns>
        /// 0操作失败,请联系管理员
        /// 1操作成功
        /// 13编码重复</returns>
        public int Edit(Employee model)
        {
            int rlt = 1;

            using (var ctx = TranContext.BeginTran())
            {
                try
                {
                    var oldModel = dal.GetModel(ctx, t => t.ID == model.ID);
                    if (rlt == 1 && IsRepeatCode(model.Code, model.ID))
                    {
                        rlt = 13;
                    }
                    if (rlt == 1)
                    {
                        #region RegionName
                        oldModel.Name              = model.Name;
                        oldModel.Code              = model.Code;
                        oldModel.Spell             = model.Spell;
                        oldModel.Alias             = model.Alias;
                        oldModel.Age               = model.Age;
                        oldModel.Birthday          = model.Birthday;
                        oldModel.Gender            = model.Gender;
                        oldModel.SubCompanyId      = model.SubCompanyId;
                        oldModel.CompanyId         = model.CompanyId;
                        oldModel.DepartmentId      = model.DepartmentId;
                        oldModel.WorkgroupId       = model.WorkgroupId;
                        oldModel.DutyId            = model.DutyId;
                        oldModel.IDCard            = model.IDCard;
                        oldModel.BankCode          = model.BankCode;
                        oldModel.Email             = model.Email;
                        oldModel.Mobile            = model.Mobile;
                        oldModel.ShortNumber       = model.ShortNumber;
                        oldModel.Telephone         = model.Telephone;
                        oldModel.OICQ              = model.OICQ;
                        oldModel.OfficePhone       = model.OfficePhone;
                        oldModel.OfficeZipCode     = model.OfficeZipCode;
                        oldModel.OfficeAddress     = model.OfficeAddress;
                        oldModel.OfficeFax         = model.OfficeFax;
                        oldModel.EducationId       = model.EducationId;
                        oldModel.School            = model.School;
                        oldModel.GraduationDate    = model.GraduationDate;
                        oldModel.Major             = model.Major;
                        oldModel.DegreeId          = model.DegreeId;
                        oldModel.TitleId           = model.TitleId;
                        oldModel.TitleDate         = model.TitleDate;
                        oldModel.TitleLevelId      = model.TitleLevelId;
                        oldModel.WorkingDate       = model.WorkingDate;
                        oldModel.JoinInDate        = model.JoinInDate;
                        oldModel.HomeZipCode       = model.HomeZipCode;
                        oldModel.HomeAddress       = model.HomeAddress;
                        oldModel.HomePhone         = model.HomePhone;
                        oldModel.HomeFax           = model.HomeFax;
                        oldModel.Province          = model.Province;
                        oldModel.City              = model.City;
                        oldModel.Area              = model.Area;
                        oldModel.NativePlace       = model.NativePlace;
                        oldModel.PartyId           = model.PartyId;
                        oldModel.NationId          = model.NationId;
                        oldModel.NationalityId     = model.NationalityId;
                        oldModel.WorkingPropertyId = model.WorkingPropertyId;
                        oldModel.Competency        = model.Competency;
                        oldModel.EmergencyContact  = model.EmergencyContact;
                        oldModel.IsDimission       = model.IsDimission;
                        oldModel.DimissionDate     = model.DimissionDate;
                        oldModel.DimissionCause    = model.DimissionCause;
                        oldModel.DimissionWhither  = model.DimissionWhither;

                        oldModel.Remark         = model.Remark;
                        oldModel.SortIndex      = model.SortIndex;
                        oldModel.ModifyDate     = DateTime.Now;
                        oldModel.ModifyUserId   = model.ModifyUserId;
                        oldModel.ModifyUserName = model.ModifyUserName;
                        #endregion

                        #region 系统日志
                        SysLog sysLogModel = new SysLog();
                        sysLogModel.TableName      = "DataDictionary";
                        sysLogModel.BusinessName   = DatabasePDMHelper.GetDataTableName(sysLogModel.TableName);
                        sysLogModel.CreateUserId   = model.ModifyUserId;
                        sysLogModel.CreateUserName = model.ModifyUserName;
                        sysLogModel.ObjectId       = model.ID;
                        sysLogModel.OperationType  = EOperationType.修改.GetHashCode();

                        var entry = ctx.Entry(oldModel);
                        if (rlt == 1 && !this.BLLProvider.SysLogBLL.Add(ctx, sysLogModel, entry))
                        {
                            rlt = 0;
                        }
                        #endregion

                        if (rlt == 1 && !dal.Insert(ctx, oldModel))
                        {
                            rlt = 0;
                        }
                    }
                    if (rlt == 1)
                    {
                        TranContext.Commit(ctx);
                    }
                    else
                    {
                        TranContext.Rollback(ctx);
                    }
                }
                catch (Exception ex)
                {
                    rlt = 0;
                    TranContext.Rollback(ctx);
                    this.BLLProvider.SystemExceptionLogBLL.Add(ex.Source, ex.InnerException.Message, ex.Message);
                }
            }
            return(rlt);
        }