Esempio n. 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);
        }
Esempio n. 2
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);
        }
 public AuthSchedulerStepDef(Settings settings, DataCollector dataCollector)
 {
     _settings         = settings;
     _dataCollector    = dataCollector;
     _tranContext      = _dataCollector.GetLocationInstance().GetTranContext(_settings.Util.TranViewDataServiceUrl["ConnectionStrings:TranFacilityCodeBCOR"]);
     _accretiveContext = _dataCollector.GetLocationInstance().GetAccretiveContext();
     _minDaysOut       = int.Parse(_settings.Util.GetTestData("MinDaysOut"));
     _maxDaysOut       = int.Parse(_settings.Util.GetTestData("MaxDaysOut"));
 }
Esempio n. 4
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);
        }
Esempio n. 5
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);
        }
Esempio n. 6
0
        /// <summary>
        /// Method to check elgible account ia available in AuthRequestLog
        /// </summary>
        /// <param name="tranContext"></param>
        /// <param name="actualResistrationIDs"></param>
        /// <returns></returns>

        public List <EligibleAccounts> GetEligibleAuthRequestLog(TranContext tranContext, List <int> actualResistrationIDs)
        {
            var authSchedulerLogResult = (from authScheduler in tranContext.AuthRequestLog
                                          where authScheduler.DateSent > DateTime.Now && actualResistrationIDs.Contains(authScheduler.RegistrationID)
                                          select new EligibleAccounts
            {
                RegistrationID = authScheduler.RegistrationID
            }).Distinct().ToList();

            return(authSchedulerLogResult);
        }
Esempio n. 7
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);
        }
Esempio n. 8
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);
        }
Esempio n. 9
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);
        }
Esempio n. 10
0
        /// <summary>
        /// 系统退出
        /// </summary>
        /// <param name="account"></param>
        /// <returns>
        /// 0操作失败,请联系管理员
        /// 1操作成功
        /// 2账号不存在
        /// </returns>
        public int LogOut(int systemId, int userId)
        {
            int rlt = 1;

            using (var ctx = TranContext.BeginTran())
            {
                UserInfo userInfo = dal.GetModel(ctx, t => t.ID == userId);
                if (userInfo == null)
                {
                    rlt = 2;
                }
                if (rlt == 1 && !this.BLLProvider.SysLoginLogBLL.Add(ctx, systemId, userInfo.Account, ELoginStatus.成功退出, ""))
                {
                    rlt = 0;
                }
            }
            return(rlt);
        }
Esempio n. 11
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);
        }
Esempio n. 12
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);
        }
Esempio n. 13
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);
        }
Esempio n. 14
0
        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="account"></param>
        /// <param name="pwd"></param>
        /// <param name="userId"></param>
        /// <returns>
        /// 0登录失败
        /// 1登录成功
        /// 2账号不存在
        /// 3用户已禁用
        /// 4密码不正确
        /// 5当前IP不许登录
        /// 6当前用户没有任何权限
        /// </returns>
        public int Login(string systemCode, string account, string pwd, out int systemId, out int userId, out string userName, out List <RoleInfo> roleList)
        {
            int rlt = 1;

            systemId = 0;
            userId   = 0;
            userName = string.Empty;
            roleList = new List <RoleInfo>();
            using (var ctx = TranContext.BeginTran())
            {
                try
                {
                    UserInfo userInfo = this.BLLProvider.UserInfoBLL.GetModel(ctx, t => t.Account == account);
                    int      sysId    = this.BLLProvider.SystemInfoBLL.GetModel(t => t.Code == systemCode).ID;
                    string   md5Pwd   = FormsAuthentication.HashPasswordForStoringInConfigFile(pwd, "MD5").Substring(0, 20);
                    if (userInfo == null)
                    {
                        this.BLLProvider.SysLoginLogBLL.Add(ctx, sysId, account, ELoginStatus.登录失败, "账号不存在!");
                        rlt = 2;
                    }
                    if (rlt == 1 && !userInfo.IsEnable)
                    {
                        this.BLLProvider.SysLoginLogBLL.Add(ctx, sysId, account, ELoginStatus.登录失败, "账号已禁用!");
                        rlt = 3;
                    }
                    if (rlt == 1 && md5Pwd != userInfo.Password)
                    {
                        this.BLLProvider.SysLoginLogBLL.Add(ctx, sysId, account, ELoginStatus.登录失败, "密码错误!");
                        rlt = 4;
                    }
                    #region IP黑名单比对
                    ///IP黑名单比对
                    string             ip         = IPHelper.GetClientIP();
                    List <IPBlacklist> ipList     = this.BLLProvider.IPBlacklistBLL.GetList(t => t.IsEnable && t.Failuretime > DateTime.Now).Cast <IPBlacklist>().ToList();
                    List <string>      ipRangList = new List <string>();
                    foreach (var item in ipList)
                    {
                        ipRangList.Add(item.StartIp + "-" + item.EndIp);
                    }
                    if (rlt == 1 && ipRangList.Count() > 0 && !IPHelper.TheIpIsRange(ip, ipRangList.ToArray()))
                    {
                        this.BLLProvider.SysLoginLogBLL.Add(ctx, sysId, account, ELoginStatus.登录失败, "IP不允许访问!");
                        rlt = 5;
                    }
                    #endregion

                    #region 获取设置 权限缓存
                    //没有任何权限
                    if (rlt == 1 && userInfo.Account != Consts.ConstValue.SuperAdminAccount && GetUserPurview(sysId, 0, userInfo.ID).Rows.Count <= 0)
                    {
                        this.BLLProvider.SysLoginLogBLL.Add(ctx, sysId, account, ELoginStatus.登录失败, "当前用户没有任何权限!");
                        rlt = 6;
                    }
                    #endregion
                    if (rlt == 1)
                    {
                        systemId = sysId;
                        userId   = userInfo.ID;
                        userName = userInfo.Name;
                        int[] userRoleIDList = this.BLLProvider.UserRoleBLL.GetList(t => t.RoleId, t => t.UserId == userInfo.ID).Cast <int>().ToArray();
                        roleList = this.BLLProvider.RoleInfoBLL.GetList(t => t.SystemId == sysId && t.IsEnable && userRoleIDList.Contains(t.ID)).Cast <RoleInfo>().ToList();

                        if (userInfo.FirstVisit == null)
                        {
                            userInfo.FirstVisit    = DateTime.Now;
                            userInfo.PreviousVisit = DateTime.Now;
                            userInfo.LastVisit     = DateTime.Now;
                            userInfo.IPAddress     = ip;
                            userInfo.MACAddress    = IPHelper.GetMacBySendARP(ip);
                            userInfo.LogOnCount    = 1;
                        }
                        else
                        {
                            userInfo.PreviousVisit = userInfo.LastVisit;
                            userInfo.LastVisit     = DateTime.Now;
                            userInfo.LogOnCount   += 1;
                        }
                    }

                    ///读取缓存信息权限&菜单 根据系统ID&用户Account组成KEY
                    ///过滤当前角色所用的信息
                    ///更新用户表登录相关信息
                    ///

                    if (rlt == 1 && !this.BLLProvider.UserInfoBLL.Update(ctx, userInfo))
                    {
                        rlt = 0;
                    }
                    if (rlt == 1 && !this.BLLProvider.SysLoginLogBLL.Add(ctx, sysId, account, ELoginStatus.登录成功, ""))
                    {
                        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);
        }
Esempio n. 15
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);
        }
Esempio n. 16
0
        /// <summary>
        /// Methode to get elogible account from database
        /// </summary>
        /// <param name="tranContext"></param>
        /// <param name="accretiveContext"></param>
        /// <param name="minDaysOut"></param>
        /// <param name="maxDaysOut"></param>
        /// <returns></returns>
        public List <EligibleAccounts> GetAuthEligibleAccounts(TranContext tranContext, AccretiveContext accretiveContext, int?minDaysOut, int?maxDaysOut)
        {
            var payorplans = tranContext.PayorPlans.ToList();


            var PayorPlanID = (from hipaaConnector in accretiveContext.HIPAAConnectors
                               join hipaaPayorConnector in accretiveContext.HIPAAPayorConnectors on hipaaConnector.ID equals hipaaPayorConnector.ConnectorID
                               join accPayers in accretiveContext.Payors on hipaaPayorConnector.PayorCode.Trim() equals accPayers.PayorCode.Trim()
                               where hipaaPayorConnector.Status == true && hipaaConnector.Description.Contains("AH Spider") && hipaaConnector.Enabled == true
                               select new
            {
                PayorCode = hipaaPayorConnector.PayorCode
            }).Distinct().ToList();


            var PayorPlanIDs = (from qc1 in payorplans
                                join qc2 in PayorPlanID on qc1.PayorCode == null ? null : qc1.PayorCode.Trim() equals qc2.PayorCode == null ? null : qc2.PayorCode.Trim()
                                select new
            {
                Id = qc1.ID
            }).ToList().Select(x => x.Id).ToList();

            var registrations = (from reg in tranContext.Registrations
                                 where reg.IsDischarged == false && (reg.AdmitDate >= DateTime.Now.Date.AddDays(minDaysOut.Value) && reg.AdmitDate <= DateTime.Now.Date.AddDays(maxDaysOut.Value)) &&
                                 AccountProperty.PatientTypes.Contains(reg.PatientType)
                                 select new
            {
                RegistrationID = reg.ID,
                EncounterID = reg.EncounterID,
                PatientType = reg.PatientType,
                AdmitDate = reg.AdmitDate,
                FacilityCode = reg.FacilityCode
            }).Distinct();

            var AuthCompltedAccount = (from reg in registrations
                                       join regAuth in tranContext.RegistrationAuthorizations on reg.RegistrationID equals regAuth.RegistrationID
                                       join auth in tranContext.Authorizations on regAuth.AuthorizationID equals auth.ID
                                       join recordStatus in tranContext.RecordTaskStatus.Where(rec => rec.TaskID == 32) on reg.RegistrationID equals recordStatus.RecordKey
                                       where (recordStatus.Status == 1 || recordStatus.Status == 4) &&
                                       auth.AuthorizationValidationStatusID == 1
                                       select new
            {
                RegistrationID = reg.RegistrationID,
                EncounterID = reg.EncounterID,
                PatientType = reg.PatientType,
                AdmitDate = reg.AdmitDate,
                FacilityCode = reg.FacilityCode
            }).ToList().Distinct();

            var authRecords = (from reg in registrations
                               join cov in tranContext.Coverages on reg.RegistrationID equals cov.RegistrationID
                               where reg.AdmitDate != null && reg.AdmitDate >= DateTime.Now.Date.AddDays(minDaysOut.Value) && reg.AdmitDate <= DateTime.Now.Date.AddDays(maxDaysOut.Value) && reg.PatientType != "E" && PayorPlanIDs.Contains(cov.PayorPlanID.Value) && cov.CoverageStatus == "A" && cov.VerificationStatus == 1 // && service.IsFinal == true && authNeed.NeedAuth == true
                               select new
            {
                RegistrationID = reg.RegistrationID,
                EncounterID = reg.EncounterID,
                PatientType = reg.PatientType,
                AdmitDate = reg.AdmitDate,
                FacilityCode = reg.FacilityCode
            }).ToList().Except(AuthCompltedAccount);



            var EligibleAuthRec = (from em in authRecords
                                   select new EligibleAccounts
            {
                RegistrationID = em.RegistrationID,
                EncounterID = em.EncounterID,
                PatientType = em.PatientType,
                AdmitDate = em.AdmitDate,
                FacilityCode = em.FacilityCode
            }).ToList();

            return(EligibleAuthRec);
        }
Esempio n. 17
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);
        }
Esempio n. 18
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);
        }
        /// <summary>
        /// load state from file.
        /// </summary>
        /// <param name="asset">
        /// the state machine file.
        /// </param>
        /// <returns></returns>
        private bool LoadFromFile(TextAsset asset)
        {
            SMContext context = JsonConvert.DeserializeObject <SMContext>(asset.text);

            //!解析状态值
            for (int i = 0; i < context.states.Count; i++)
            {
                try
                {
                    SMState state = Activator.CreateInstance(Type.GetType(context.states[i]),
                                                             new object[] { context.states[i], gameObject }) as SMState;
                    _statesByName.Add(context.states[i], state);
                    _statesByHash.Add(state.HashCode, state);
                }
                catch
                {
                    Debug.Log("can't create state named " + context.states[i]);
                    continue;
                }
            }

            Default      = GetState(context.default_state);
            _activeState = Default;

            //!解析默认参数值
            foreach (string param in context.default_params)
            {
                ParseParamData(param);
            }

            //!解析transtitions
            for (int i = 0; i < context.transitions.Count; i++)
            {
                TranContext tranContext = context.transitions[i];
                SMState     origin      = GetState(tranContext.origin);

                if (origin == null)
                {
                    Debug.Log(string.Format("can't make transition from {0} to {1}",
                                            tranContext.origin, tranContext.dest));
                    continue;
                }

                SMTransition transition = origin.MakeTransition(tranContext.dest, tranContext.duration);

                if (transition == null)
                {
                    Debug.Log(string.Format("can't make transition from {0} to {1}",
                                            tranContext.origin, tranContext.dest));
                    continue;
                }

                for (int j = 0; j < context.transitions[i].conditions.Count; j++)
                {
                    string        fileName = tranContext.conditions[j].fileName;
                    List <string> args     = tranContext.conditions[j].paramDatas;

                    try
                    {
                        SMCondition condition = Activator.CreateInstance(Type.GetType(fileName), new object[] { args, gameObject }) as SMCondition;
                        transition.AddCondition(condition);
                    }
                    catch
                    {
                        Debug.Log(string.Format("can't make transition from {0} to {1}, condition {2} not found!",
                                                tranContext.origin, tranContext.dest, tranContext.conditions[j]));
                        origin.RemoveTransition(transition);
                    }
                }
            }

            return(true);
        }
Esempio n. 20
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);
        }
Esempio n. 21
0
        /// <summary>
        /// 修改密码
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="oldPwd"></param>
        /// <param name="newPwd"></param>
        /// <returns>
        /// 0 操作失败,请联系管理员
        /// 1 操作成功
        /// 2 账号不存在
        /// 4 密码错误!
        /// </returns>
        public int ChangePassword(int userId, string oldPwd, string newPwd)
        {
            int rlt = 1;

            using (var ctx = TranContext.BeginTran())
            {
                try
                {
                    UserInfo userInfo = dal.GetModel(ctx, t => t.ID == userId);
                    if (userInfo == null)
                    {
                        rlt = 2;
                    }
                    if (rlt == 1)
                    {
                        string oldmd5Pwd = FormsAuthentication.HashPasswordForStoringInConfigFile(oldPwd, "MD5").Substring(0, 20);
                        if (oldmd5Pwd != userInfo.Password)
                        {
                            rlt = 4;
                        }
                    }
                    if (rlt == 1)
                    {
                        string newmd5Pwd = FormsAuthentication.HashPasswordForStoringInConfigFile(newPwd, "MD5").Substring(0, 20);
                        userInfo.Password           = newmd5Pwd;
                        userInfo.ChangePasswordDate = DateTime.Now;

                        #region 系统日志
                        SysLog sysLogModel = new SysLog();
                        sysLogModel.BusinessName   = "修改密码";
                        sysLogModel.CreateUserId   = userId;
                        sysLogModel.CreateUserName = userInfo.Name;
                        sysLogModel.ObjectId       = userId;
                        sysLogModel.OperationType  = EOperationType.修改.GetHashCode();
                        sysLogModel.TableName      = "UserInfo";
                        var entry = ctx.Entry(userInfo);
                        if (rlt == 1 && !this.BLLProvider.SysLogBLL.Add(ctx, sysLogModel, entry))
                        {
                            rlt = 0;
                        }
                        #endregion
                        if (rlt == 1 && !dal.Update(ctx, userInfo))
                        {
                            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);
        }
Esempio n. 22
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);
        }
Esempio n. 23
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);
        }