public object AddAccount(Account account) { var item = RedisBase.HashGetAll <KeyValuePair <string, Account> >(this._key); if (item != null) { bool isExist = item.Any(t => t.Value.AccountName == account.AccountName); if (isExist) { return(new { result = false, message = "昵称已经被占用" }); } } account.Id = Guid.NewGuid().ToString(); KeyValuePair <string, Account> model = new KeyValuePair <string, Account>(account.Id, account); RedisBase.HashSet <KeyValuePair <string, Account> >(this._key, model.Key, model); return(new { result = true, message = "success" }); }
public object AddTaskTarget([FromBody] TaskTarget tageTarget) { return(base.OperationToResult(() => { return RedisBase.HashSet <TaskTarget>(TASK_TARGET, tageTarget.Guid, tageTarget); })); }
public string AddSession(SessionCache sessionCache) { //SessionCache sCache = // RedisBase.Hash_Get<SessionCache>(sessionCache.Token, sessionCache.Token); dynamic result = this.IsExisted(sessionCache.Token); if (result.isExisted) { RedisBase.HashSet <SessionCache>(sessionCache.Token, sessionCache.Token, sessionCache); RedisBase.HashSetExpire(sessionCache.Token, DateTime.Now.AddMinutes(TIMER)); return(null); } else { var sCache = result.cache; if (sCache.IpAddress == sessionCache.IpAddress) { RedisBase.HashSetExpire(sessionCache.Token, DateTime.Now.AddMinutes(TIMER)); return(null); } RedisBase.HashRemove(sCache.Token, sCache.Token); RedisBase.HashSet <SessionCache>(sessionCache.Token, sessionCache.Token, sessionCache); RedisBase.HashSetExpire(sessionCache.Token, DateTime.Now.AddMinutes(TIMER)); return(sCache.Token); } }
public bool AddAccountForAdminPage(Account account) { var item = RedisBase.HashGetAll <KeyValuePair <string, Account> >(this._key); if (item != null) { var accounts = item.Where(t => t.Value.AccountName == account.AccountName); if (accounts.Any()) { var count = item.Where(t => t.Value.AccountName.Contains(account.AccountName)).Count(); account.AccountName = account.AccountName + "(" + count + ")"; } } account.Id = Guid.NewGuid().ToString(); if (account.Password == "-1") { account.Password = account.ConfirmPassword = "******"; } KeyValuePair <string, Account> model = new KeyValuePair <string, Account>(account.Id, account); return(RedisBase.HashSet <KeyValuePair <string, Account> >(this._key, model.Key, model)); }
/// <summary> /// 敏感词 /// </summary> public static List <string> GetDirtyWord() { try { List <string> list = redis.HashGetAllValues <string>("DirtyWord"); if (list.Count == 0) { string str = string.Empty; string filePath = System.Web.HttpContext.Current.Server.MapPath("~/Config/dirtyword.config"); if (System.IO.File.Exists(filePath)) { StreamReader sr = new StreamReader(filePath, Encoding.Default); str = sr.ReadToEnd(); sr.Close(); } list = Newtonsoft.Json.JsonConvert.DeserializeObject <List <string> >(str); var index = 0; list.ForEach(x => { redis.HashSet <string>("DirtyWord", index++.ToString(), x); }); } return(list); } catch (Exception ex) { return(new List <string>()); } }
public bool AddProject(Project project) { project.SetGuid(); KeyValuePair <string, Project> model = new KeyValuePair <string, Project>(project.Guid, project); if (model.Value.Task != null) { BllWorkTask bllWorkTask = new BllWorkTask(); model.Value.Task.ForEach(t => { t.SetGuid(); t.PojectId = project.Guid; bllWorkTask.AddWorkTask(t); //if (t.TaskInfo != null) //{ // t.TaskInfo.ForEach(l => // { // l.SetGuid(); // l.WorkTaskId = t.Guid; // }); //} }); model.Value.Task = null; } return(RedisBase.HashSet <KeyValuePair <string, Project> >(this._key, model.Key, model)); }
public bool AddWorkTask(WorkTask workTask) { if (string.IsNullOrEmpty(workTask.Guid)) { workTask.SetGuid(); } KeyValuePair <string, WorkTask> work = new KeyValuePair <string, WorkTask>(workTask.Guid, workTask); return(RedisBase.HashSet(this._key, work.Key, work)); }
public bool AddTaskTarget(TaskTarget taskTarget) { if (string.IsNullOrEmpty(taskTarget.Guid)) { taskTarget.SetGuid(); } taskTarget.CreateTime = DateTime.UtcNow.ToString(); KeyValuePair <string, TaskTarget> model = new KeyValuePair <string, TaskTarget>(taskTarget.Guid, taskTarget); return(RedisBase.HashSet <KeyValuePair <string, TaskTarget> >(this._key, taskTarget.Guid, model)); }
private object AddAttachment(string fileName) { return(base.OperationToResult(() => { Attachment attach = new Attachment(); attach.DateTime = DateTime.UtcNow.ToString(); attach.FileName = fileName; attach.SetGuid(); KeyValuePair <string, Attachment> model = new KeyValuePair <string, Attachment>(attach.Guid, attach); return RedisBase.HashSet <KeyValuePair <string, Attachment> >(ATTACH, model.Key, model); })); }