Ejemplo n.º 1
0
 public UserIdModel(UserIdList userId)
     : base(userId)
 {
     if (userId != null)
     {
         User_Id = userId.User_Id;
         Application_Id = userId.Application_Id;
         Owner_Id = userId.Owner_Id;
         Role_Id = userId.Role_Id;
         IsUsed = userId.IsUsed?1:0;
     }
 }
Ejemplo n.º 2
0
 public void UpdateUserInfo(int appid, int userId, string token, UserApplicationInfo info)
 {
     try
     {
         CheckToken(appid, userId, token);
         if (userId != info.User_Id)
         {
             CheckCommand(appid, info.Application_Id, userId, BuiltIns.DefineUserCommand.Id, BuiltIns.AllRole.Id);
         }
         using (TransactionScope scope = new TransactionScope())
         {
             UserApplicationInfo oldInfo = new UserApplicationInfo { Application_Id = info.Application_Id, User_Id = info.User_Id };
             modelAccesser.Get<UserApplicationInfo>(oldInfo);
             if (oldInfo.Loaded)
             {
                 if (oldInfo.Role_Id != info.Role_Id)
                 {
                     CheckCommand(appid, info.Application_Id, userId, BuiltIns.UserRoleUpDownCommand.Id, BuiltIns.AllRole.Id);
                     UserIdList idList = new UserIdList { User_Id = info.User_Id, Application_Id = info.Application_Id };
                     modelAccesser.Get<UserIdList>(idList);
                     if (idList.Loaded)
                     {
                         idList.Role_Id = info.Role_Id;
                         idList.IsUsed = true;
                         modelAccesser.Update<UserIdList>(idList);
                     }
                     else
                     {
                         idList.IsUsed = true;
                         idList.Owner_Id = -1;
                         idList.Role_Id = info.Role_Id;
                         modelAccesser.Add<UserIdList>(idList);
                     }
                 }
                 modelAccesser.Update<UserApplicationInfo>(info);
                 scope.Complete();
             }
         }
     }
     catch (Exception)
     {
         throw new DatabaseException();
     }
 }
Ejemplo n.º 3
0
 public UserIdList AddUserIdList(int appid, int userId, string token, UserIdList idlist)
 {
     try
     {
         CheckToken(appid, userId, token);
         CheckCommand(appid, idlist.Application_Id, userId, BuiltIns.DefineUserIdCommand.Id, BuiltIns.AllRole.Id);
         modelAccesser.Add(idlist);
         return idlist;
     }
     catch (Exception)
     {
         throw new DatabaseException();
     }
 }
Ejemplo n.º 4
0
 public void UpdateUserIdList(int appid, int userId, string token, UserIdList idlist)
 {
     try
     {
         CheckToken(appid, userId, token);
         modelAccesser.Update<UserIdList>(idlist);
     }
     catch (Exception)
     {
         throw new DatabaseException();
     }
 }
Ejemplo n.º 5
0
 public string AgentLogin(int appid, int userId, int agent, string password, string agentPassword = "")
 {
     try
     {
         string token = Login(appid, userId, password);
         if (!string.IsNullOrEmpty(token))
         {
             UserIdList userIdList = new UserIdList { Application_Id = appid, User_Id = userId, Owner_Id = agent };
             modelAccesser.Get<UserIdList>(userIdList);
             if (userIdList.Loaded)
             {
                 logger.Debug("Login OK : AppId - " + appid + " , UserId - " + userId + "Agent - " + agent + " , Token = " + token);
             }
             logger.Debug("Exit Login : AppId - " + appid + " , UserId - " + userId + "Agent - " + agent);
         }
         return token;
     }
     catch (Exception ex)
     {
         logger.Error("Agent login Error: AppId - " + appid + " , UserId - " + userId, ex);
         throw new DatabaseException();
     }
 }
Ejemplo n.º 6
0
        public User Register(int appid, int userId, string account, string pwd, int sex)
        {
            try
            {
                User newUser = null;
                using (TransactionScope scope = new TransactionScope())
                {
                    var userIdList = new UserIdList { Application_Id = appid, User_Id = userId };
                    modelAccesser.Get(userIdList);
                    if (!userIdList.Loaded)
                    {
                        userIdList.Application_Id = BuiltIns.AllApplication.Id;
                        userIdList.User_Id = userId;
                        modelAccesser.Get(userIdList);
                    }
                    if (userIdList.Loaded)
                    {
                        userIdList.IsUsed = true;
                        modelAccesser.Update<UserIdList>(userIdList);

                        newUser = new User { Id = userId, ApplicationCreated_Id = appid, Name = account, NickName = account, Password = pwd, Gender = sex == 0 };
                        modelAccesser.Add<User>(newUser);
                        UserApplicationInfo userInfo = new UserApplicationInfo { Application_Id = appid, Role_Id = BuiltIns.RegisterUserRole.Id, User_Id = userId, Money = 0, AgentMoney = 0, Score = 0 };
                        modelAccesser.Add<UserApplicationInfo>(userInfo);
                    }
                    scope.Complete();
                }

                return newUser;
            }
            catch (Exception)
            {
                throw new DatabaseException();
            }
        }
Ejemplo n.º 7
0
 public YoYoStudio.Model.Core.UserIdList AddUserIdList(int userId, string token, YoYoStudio.Model.Core.UserIdList idlist)
 {
     return(client.AddUserIdList(application_Id, userId, token, idlist));
 }
Ejemplo n.º 8
0
 public void UpdateUserIdList(int userId, string token, YoYoStudio.Model.Core.UserIdList idlist)
 {
     client.UpdateUserIdList(application_Id, userId, token, idlist);
 }