Пример #1
0
 public static User GetUser(string login)
 {
     LoadConfig();
     User res = null;
     if (Users.ContainsKey(login))
         res= Users[login];
     if (res==null)
     {
         res = new User() { Email = login };
         Users.Add(res.Email, res);
     }
     return res;
 }
Пример #2
0
 internal void SaveUserInfo()
 {
     Worker.EnqueueTask(new WorkerTask(args =>
         {
             try
             {
                 using (var proxy = new WorkChannel())
                 {
                     var data = new UserDTO
                     {
                         UserID = User.UserID,
                         Address = User.Address,
                         Email = User.Email,
                         Name = User.Name,
                         Password = null,
                         Phone = User.Phone,
                         Rights = User.Rights
                     };
                     return proxy.UpdateUser(new UpdateRequest<UserDTO>()
                     {
                         Login = User.Email,
                         Password = User.Password,
                         Data = data
                     });
                 }
             }
             catch (Exception exc)
             {
                 return exc;
             }
         }, (s, e) =>
         {
             if (e.Result is Exception)
             {
                 Utils.HandleException(e.Result as Exception);
                 return;
             }
             var userRes = e.Result as SingleItemResponse<UserDTO>;
             if (userRes == null)
             {
                 Utils.showError(Utils.Messages.UNKNOWN_ERROR_FORMAT);
                 return;
             }
             ClientConfig.CurrentUser.UpdateWithUserDTO(userRes.Data);
             ClientConfig.CurrentUser.RefreshRate = this.User.RefreshRate;
             this.User = ClientConfig.CurrentUser;
             ModifiedUserData = false;
             Utils.showInformation(Utils.Messages.SAVED_SUCCESSFULLY);
         }, null));
 }
Пример #3
0
 public void Load()
 {
     ModifiedPasssword = ModifiedUserData = false;
     Worker.EnqueueTask(new WorkerTask((args) =>
     {
         var user = args[0] as User;
         try
         {
             if (user == null)
                 throw new PizzaNetException(Utils.Messages.NO_USER_LOGGED_IN);
             using (var proxy = new WorkChannel())
             {
                 return proxy.GetUser(new EmptyRequest { Login = user.Email, Password = user.Password });
             }
         }
         catch (Exception e)
         {
             return e;
         }
     }, (s, args) =>
     {
         if (args.Result is Exception)
         {
             Utils.HandleException(args.Result as Exception);
             return;
         }
         var u = args.Result as SingleItemResponse<UserDTO>;
         if (u == null)
         {
             Utils.showError(String.Format(Utils.Messages.NO_USER_FOUND_FORMAT, ClientConfig.CurrentUser.Email));
             return;
         }
         ClientConfig.CurrentUser.UpdateWithUserDTO(u.Data);
         this.User = ClientConfig.CurrentUser;
         CurrentPassword = PasswordRepeated = NewPassword = "";
         Password = ClientConfig.CurrentUser.Password;
     }, ClientConfig.CurrentUser));
 }