public void AppendLoginHistory(JObject request) { var lanIP = RequestHelper.ClientIP; var hostName = RequestHelper.IsLanIP(lanIP) ? RequestHelper.ClientHostName : string.Empty; //如果是内网就获取,否则出错获取不到,且影响效率 var UserCode = request.Value <string>("usercode"); var UserName = FormsAuth.GetLoginer().UserName; var IP = request.Value <string>("ip"); var City = request.Value <string>("city"); if (IP != lanIP) { IP = string.Format("{0}/{1}", IP, lanIP).Trim('/').Replace("::1", "localhost"); } var item = new sys_loginHistory(); item.UserCode = UserCode; item.UserName = UserName; item.HostName = hostName; item.HostIP = IP; item.LoginCity = City; item.LoginDate = DateTime.Now; db.Insert <sys_loginHistory>("sys_loginHistory", item).AutoMap(x => x.ID).Execute(); }
public void Logger(string position, string target, string type, object message) { ILog Log = LogManager.GetLogger("Operation"); var user = FormsAuth.GetLoginer().UserName; Log.InfoFormat("{0}在位置{1}对{2}做了{3},数据为{4}", user, position, target, type, JsonConvert.SerializeObject(message)); }
public bool AuthorizeUserMenu(List <string> urls) { var UserCode = FormsAuth.GetLoginer().UserCode; var result = db.Sql(string.Format(@" select 1 from sys_roleMenuMap A left join sys_userRoleMap B on B.RoleCode = A.RoleCode left join sys_menu C on C.MenuCode = A.MenuCode where B.UserCode = '{1}' and C.URL in ('{0}')", string.Join("','", urls), UserCode)).QueryMany <int>(); return(result.Count > 0); }
public void Audit(string id, JObject data) { var pUpdate = ParamUpdate.Instance() .Update("mms_deal") .Column("ApproveState", data["status"]) .Column("ApproveRemark", data["comment"]) .Column("ApprovePerson", FormsAuth.GetLoginer().UserName) .Column("ApproveDate", DateTime.Now) .Where("BillNo", id); var service = new mms_dealService(); var rowsAffected = service.Update(pUpdate); MvcHelper.ThrowHttpExceptionWhen(rowsAffected < 0, "单据审核失败[BillNo={0}],请重试或联系管理员!", id); }
public void LoggerOperation(string position, string target, string type, object message) { var user = FormsAuth.GetLoginer(); db.UseSharedConnection(true); db.Insert("sys_log") .Column("UserCode", user.UserCode) .Column("UserName", user.UserName) .Column("Position", position) .Column("Target", target) .Column("Type", type) .Column("Message", JsonConvert.SerializeObject(message)) .Column("Date", DateTime.Now) .Execute(); }
public string ChangePassword(string PasswordOld, string PasswordNew) { var UserCode = FormsAuth.GetLoginer().UserCode; var pQuery = ParamQuery.Instance() .Where("UserCode", UserCode) .Where("Password", EncryptHelper.MD5(PasswordOld)); var list = GetModelList(pQuery); if (list.Count == 0) { return("原密码不正确!"); } db.Update("sys_user") .Column("Password", EncryptHelper.MD5(PasswordNew)) .Where("UserCode", UserCode) .Execute(); return(string.Empty); }
public Dictionary <string, string> GetCurrentUserSettings() { var result = new Dictionary <string, string>(); var UserCode = FormsAuth.GetLoginer <LoginerBase>().UserCode; var settings = db.Sql("select * from sys_userSetting where UserCode=@0", UserCode).QueryMany <sys_userSetting>(); foreach (var item in settings) { result.Add(item.SettingCode, item.SettingValue); } foreach (var item in AppSettings.DefaultUserSettings) { if (!result.ContainsKey(item.Key)) { result.Add(item.Key, item.Value); } } return(result); }
public void SaveCurrentUserSettings(JObject settings) { var UserCode = FormsAuth.GetLoginer <LoginerBase>().UserCode; foreach (JProperty item in settings.Children()) { var result = db.Update("sys_userSetting") .Column("SettingValue", item.Value.ToString()) .Where("UserCode", UserCode) .Where("SettingCode", item.Name) .Execute(); if (result <= 0) { var model = new sys_userSetting(); model.UserCode = UserCode; model.SettingCode = item.Name; model.SettingValue = item.Value.ToString(); db.Insert <sys_userSetting>("sys_userSetting", model).AutoMap(x => x.ID).Execute(); } } }
public List <sys_roleMenuColumnMap> GetCurrentUserMenuColumns() { var MenuCode = new sys_menuService().GetCurrentMenuCode(); var UserCode = FormsAuth.GetLoginer().UserCode; var sql = @" select * from sys_roleMenuColumnMap where MenuCode = @0 and RoleCode in ( select RoleCode from sys_userRoleMap where userCode = @1 union select A.RoleCode from sys_organizeRoleMap A inner join sys_userOrganizeMap B on B.OrganizeCode = A.OrganizeCode where B.UserCode = @1 )"; var result = db.Sql(sql, MenuCode, UserCode).QueryMany <sys_roleMenuColumnMap>(); return(result); }
public List <sys_button> GetCurrentUserMenuButtons() { var MenuCode = GetCurrentMenuCode(); var UserCode = FormsAuth.GetLoginer().UserCode; var sql = @" select A.* from sys_button A inner join sys_roleMenuButtonMap B on B.MenuCode = @0 and B.ButtonCode = A.ButtonCode where RoleCode in ( select RoleCode from sys_userRoleMap where userCode = @1 union select A.RoleCode from sys_organizeRoleMap A inner join sys_userOrganizeMap B on B.OrganizeCode = A.OrganizeCode where B.UserCode = @1 ) order by ButtonSeq"; var result = db.Sql(sql, MenuCode, UserCode).QueryMany <sys_button>(); return(result); }
public static LoginerBase GetLoginer() { return(FormsAuth.GetLoginer()); }
public virtual List <dynamic> GetUserMenus() { return(new sys_menuService().GetUserMenu(FormsAuth.GetLoginer().UserCode)); }
public static string GetUserName() { return(FormsAuth.GetLoginer().UserName); }