Beispiel #1
0
 public string SendAccountPackage(Account oldAccount, Account newAccount, string keyword)
 {
     if (clientModel.HasFunction(FunctionType.UserSystem))
     {
         while (sending)
         {
             Thread.Sleep(100);
         }
         sending   = true;
         isReceive = false;
         AccountList sendList = new AccountList();
         sendList.AddOldAndNewAccount(oldAccount, newAccount);
         AccountPackage sendPackage = new AccountPackage(sendList, keyword);
         string         send        = JsonSerializer.Serialize(sendPackage);
         Send(send);
         while (!isReceive)
         {
             Thread.Sleep(100);
         }
         sending = false;
         return(receiveMessage);
     }
     else
     {
         return("User System offline, please logoff.");
     }
 }
Beispiel #2
0
        public string SendLoginOrRegisterPackage(string keyword, string idOrName, string password)
        {
            if (clientModel.HasFunction(FunctionType.UserSystem))
            {
                login = false;
                LoginOrRegisterPackage sendPackage = new LoginOrRegisterPackage(keyword, idOrName, password);
                string send = JsonSerializer.Serialize(sendPackage);
                Send(send);
                string             receive            = GetReceive();
                InformationPackage informationPackage = JsonSerializer.Deserialize <InformationPackage>(receive);
                switch (informationPackage.GetInformationType())
                {
                case InformationType.ERROR:
                    ErrorPackage errorPackage = JsonSerializer.Deserialize <ErrorPackage>(receive);
                    //clientModel.SystemOffLine(FunctionType.UserSystem);
                    return(errorPackage.GetKeyword());

                case InformationType.ACCOUNT:
                    AccountPackage accountPackage = JsonSerializer.Deserialize <AccountPackage>(receive);
                    clientModel.UpdateAccount(accountPackage.SendList.GetAccountByIndex(0));
                    receive = GetReceive();
                    FriendPackage friendPackage = JsonSerializer.Deserialize <FriendPackage>(receive);
                    clientModel.UpdateFriendList(friendPackage.SendList);
                    login = true;
                    new Thread(Start).Start();
                    return(null);
                }
                return("Get wrong package.");
            }
            else
            {
                return("User System offline, please logoff.");
            }
        }
Beispiel #3
0
 public OrganizationPackageEditModel CreateModel(Package package, AccountPackage accountPackage)
 {
     return(new OrganizationPackageEditModel
     {
         PackageId = package.Id,
         PackageName = package.Name,
         Gender = (Gender)package.Gender,
         IsRecommended = accountPackage.IsRecommended
     });
 }
        public void Save(AccountPackage domainObject)
        {
            var entity = Mapper.Map <AccountPackage, AccountPackageEntity>(domainObject);

            if (domainObject == null)
            {
                return;
            }
            using (var adapter = PersistenceLayer.GetDataAccessAdapter())
            {
                if (!adapter.SaveEntity(entity))
                {
                    throw new PersistenceFailureException();
                }
            }
        }