示例#1
0
        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));
        }
示例#2
0
        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"
            });
        }
示例#3
0
        public List <KeyValuePair <string, Project> > GetProject()
        {
            var projects = RedisBase.HashGetAll <KeyValuePair <string, Project> >(this._key).ForIn(t =>
            {
                if (!string.IsNullOrEmpty(t.Value.StartTime))
                {
                    t.Value.RunTime = (DateTime.Now - Convert.ToDateTime(t.Value.StartTime)).Days;
                }
                t.Value.Progress  = CalcProgress(t.Value.Task);
                t.Value.TotalTime = CalcTotalTime(t.Value.Task);
            });

            if (projects != null)
            {
                return(projects.ToList());
            }
            return(null);
        }
示例#4
0
        public object Login(Account account, string ipAddress)
        {
            var model = RedisBase.HashGetAll <KeyValuePair <string, Account> >(this._key)
                        .Where(t => t.Value.AccountName == account.AccountName);

            //Tuple
            if (!model.Any())
            {
                return(new
                {
                    result = false,
                    message = "用户不存在"
                });
            }
            var item = model.FirstOrDefault();

            if (item.Value.Password != account.Password)
            {
                return(new
                {
                    result = false,
                    message = "密码错误"
                });
            }
            new BllSession().AddSession(new SessionCache()
            {
                IpAddress = ipAddress,
                Token     = item.Value.Id,
                Name      = item.Value.UserName
            });

            Chat.SendClientMessage(new Message()
            {
                Timestamp   = DateTime.UtcNow,
                Body        = "login out",
                MessageType = MessageType.LoginOut
            });

            return(new
            {
                result = item
            });
        }
示例#5
0
 public List <KeyValuePair <string, TaskTarget> > GetWorkTask()
 {
     return(RedisBase.HashGetAll <KeyValuePair <string, TaskTarget> >(TASK_TARGET));
 }
示例#6
0
 public List <KeyValuePair <string, Account> > GetAccountById(string uuid)
 {
     return(RedisBase.HashGetAll <KeyValuePair <string, Account> >(this._key).Where(t => t.Key == uuid).ToList());
 }
示例#7
0
 public List <KeyValuePair <string, Account> > GetAccount()
 {
     return(RedisBase.HashGetAll <KeyValuePair <string, Account> >(this._key));
 }
 public List <KeyValuePair <string, WorkTask> > GetWorkTask()
 {
     return(RedisBase.HashGetAll <KeyValuePair <string, WorkTask> >(this._key));
 }
示例#9
0
 public List <KeyValuePair <string, TaskTarget> > GetTaskTarget()
 {
     return(RedisBase.HashGetAll <KeyValuePair <string, TaskTarget> >(this._key));
 }