public static List <Project> Get() { List <Project> list = UnicornCache.Get <List <Project> >(CacheKey.Project); if (list == null) { list = new List <Project>(); string sql = "select Id,Name,ParentId,Url,TestUrl,SiteFileName,DatabaseName,TestUserName,TestPassword,Remark,IsShow from Projects order by Id desc"; DataTable dt = ProjectDB.GetDt(sql); foreach (DataRow row in dt.Rows) { Project o = new Project(); o.Id = St.ToInt32(row["Id"], 0); o.Name = row["Name"].ToString(); o.Url = row["Url"].ToString(); o.ParentId = St.ToInt32(row["ParentId"], 0); o.TestUrl = row["TestUrl"].ToString(); o.SiteFileName = row["SiteFileName"].ToString(); o.DatabaseName = row["DatabaseName"].ToString(); o.TestUserName = row["TestUserName"].ToString(); o.TestPassword = row["TestPassword"].ToString(); o.Remark = row["Remark"].ToString(); o.IsShow = St.ToInt32(row["IsShow"], 0); list.Add(o); } UnicornCache.Add(CacheKey.Project, list); } return(list); }
public static List <User> Get() { List <User> list = UnicornCache.Get <List <User> >(CacheKey.User); if (list == null) { list = new List <User>(); string sql = "select Id,UserName,Password,RealName,RoleType,Status,LeaveTime,bugzillaid from Users"; DataTable dt = ProjectDB.GetDt(sql); foreach (DataRow row in dt.Rows) { User o = new User(); o.Id = St.ToInt32(row["Id"], 0); o.UserName = row["UserName"].ToString(); o.Password = row["Password"].ToString(); o.RealName = row["RealName"].ToString(); o.RoleType = St.ToInt32(row["RoleType"], 0); o.Status = St.ToInt32(row["Status"], 0); o.LeaveTime = St.ToDateTime(row["LeaveTime"].ToString()); o.BugzillaId = St.ToInt32(row["bugzillaid"], 0); list.Add(o); } UnicornCache.Add(CacheKey.User, list); } return(list); }
public static List <Dic> Get() { List <Dic> list = UnicornCache.Get <List <Dic> >(CacheKey.Dic); if (list == null) { list = new List <Dic>(); string sql = "select Id,Code,Name,Type,Remark,AddTime from Dics"; DataTable dt = ProjectDB.GetDt(sql); foreach (DataRow row in dt.Rows) { Dic o = new Dic(); o.Id = St.ToInt32(row["Id"], 0); o.Code = row["Code"].ToString(); o.Name = row["Name"].ToString(); o.Type = St.ToInt32(row["Type"].ToString(), 0); o.Remark = row["Remark"].ToString(); o.AddTime = St.ToDateTime(row["AddTime"].ToString()); list.Add(o); } UnicornCache.Add(CacheKey.Dic, list); } return(list); }
public static void Delete(int id) { string sql = @"Delete from Projects where Id=@id"; SqlParam p = new SqlParam(); p.AddParam("@id", id, SqlDbType.Int, 0); ProjectDB.SqlExecute(sql, p); UnicornCache.Remove(CacheKey.Project); }
public static void Update(int id) { string sql = @"update Users set [Status]=[Status]%2+1 where Id=@id"; SqlParam p = new SqlParam(); p.AddParam("@id", id, SqlDbType.Int, 0); ProjectDB.SqlExecute(sql, p); UnicornCache.Remove(CacheKey.User); }
public static void Update(int id, string username, string password) { string sql = @"update Users set Password=@Password where Id=@id"; SqlParam p = new SqlParam(); p.AddParam("@id", id, SqlDbType.Int, 0); p.AddParam("@Password", St.GetMd5(username + password), SqlDbType.VarChar, 100); ProjectDB.SqlExecute(sql, p); UnicornCache.Remove(CacheKey.User); }
public static void Add(string code, string name, int type, string remark) { string sql = @"insert into Dics(Code,Name,Type,Remark) values(@Code,@Name,@Type,@Remark)"; SqlParam p = new SqlParam(); p.AddParam("@Code", code, SqlDbType.VarChar, 50); p.AddParam("@Name", name, SqlDbType.VarChar, 50); p.AddParam("@Type", type, SqlDbType.Int, 0); p.AddParam("@Remark", remark, SqlDbType.VarChar, 50); ProjectDB.SqlExecute(sql, p); UnicornCache.Remove(CacheKey.Dic); }
public static void Update(int id, string code, string name, int type, string remark) { string sql = @"update Dics set Code=@Code,Name=@Name,Type=@Type,Remark=@Remark where Id=@id"; SqlParam p = new SqlParam(); p.AddParam("@id", id, SqlDbType.Int, 0); p.AddParam("@Code", code, SqlDbType.VarChar, 50); p.AddParam("@Name", name, SqlDbType.VarChar, 50); p.AddParam("@Type", type, SqlDbType.Int, 0); p.AddParam("@Remark", remark, SqlDbType.VarChar, 50); ProjectDB.SqlExecute(sql, p); UnicornCache.Remove(CacheKey.Dic); }
public static void Add(string username, string realname, int userrole, DateTime leavetime, int bugzillaid) { string sql = @" if exists(select Id from Users where UserName=@UserName) update Users set RealName=@RealName,RoleType=@RoleType,LeaveTime=@LeaveTime,bugzillaid=@bugzillaid where UserName=@UserName else insert into Users(UserName,Password,RealName,RoleType,Status,LeaveTime,bugzillaid) values(@UserName,@Password,@RealName,@RoleType,1,@LeaveTime,@bugzillaid)" ; SqlParam p = new SqlParam(); p.AddParam("@UserName", username, SqlDbType.VarChar, 100); p.AddParam("@RealName", realname, SqlDbType.VarChar, 500); p.AddParam("@RoleType", userrole, SqlDbType.Int, 0); p.AddParam("@Password", St.GetMd5(username + "123456"), SqlDbType.VarChar, 100); p.AddParam("@LeaveTime", leavetime, SqlDbType.DateTime, 0); p.AddParam("@bugzillaid", bugzillaid, SqlDbType.Int, 0); ProjectDB.SqlExecute(sql, p); UnicornCache.Remove(CacheKey.User); }
public static void Add(int id, string name, string url, int parentid, string TestUrl, string SiteFileName, string DatabaseName, string TestUserName, string TestPassword, string Remark, int IsShow) { string sql = @" if exists(select Id from Projects where Id=@Id) update Projects set Name=@Name,ParentId=@ParentId,Url=@Url,TestUrl=@TestUrl,SiteFileName=@SiteFileName,DatabaseName=@DatabaseName,TestUserName=@TestUserName,TestPassword=@TestPassword,Remark=@Remark,IsShow=@IsShow where Id=@Id else insert into Projects(Name,ParentId,Url,TestUrl,SiteFileName,DatabaseName,TestUserName,TestPassword,Remark,IsShow) values(@Name,@ParentId,@Url,@TestUrl,@SiteFileName,@DatabaseName,@TestUserName,@TestPassword,@Remark,@IsShow)" ; SqlParam p = new SqlParam(); p.AddParam("@Id", id, SqlDbType.Int, 0); p.AddParam("@Name", name, SqlDbType.VarChar, 500); p.AddParam("@ParentId", parentid, SqlDbType.Int, 0); p.AddParam("@Url", url, SqlDbType.VarChar, 500); p.AddParam("@TestUrl", TestUrl, SqlDbType.VarChar, 500); p.AddParam("@SiteFileName", SiteFileName, SqlDbType.VarChar, 500); p.AddParam("@DatabaseName", DatabaseName, SqlDbType.VarChar, 500); p.AddParam("@TestUserName", TestUserName, SqlDbType.VarChar, 200); p.AddParam("@TestPassword", TestPassword, SqlDbType.VarChar, 200); p.AddParam("@Remark", Remark, SqlDbType.VarChar, 500); p.AddParam("@IsShow", IsShow, SqlDbType.Int, 0); ProjectDB.SqlExecute(sql, p); UnicornCache.Remove(CacheKey.Project); }
protected string GetBugzillaUserName(int id) { Dictionary <int, string> dic = UnicornCache.Get <Dictionary <int, string> >(CacheKey.BugzillaUsers); if (dic == null) { dic = new Dictionary <int, string>(); var ll = DAL.UserRule.Get(); foreach (var o in ll) { dic.Add(o.BugzillaId, o.RealName); } UnicornCache.Add(CacheKey.BugzillaUsers, dic); } if (dic.ContainsKey(id)) { return(dic[id]); } else { return(""); } }