Example #1
0
 public User(PlatformUser user)
 {
     ID = user.ID;
     Title = user.Title;
     Name = user.Name;
     Surname = user.Surname;
     Patronym = user.Patronym;
     Description = user.Description;
     Login = user.Login;
     RoleMask = user.RoleMask;
 }
Example #2
0
        private static void MakeEmail(PlatformUser us)
        {
            var domain = mailDomains.GetRandomValue();

            // имя вида [email protected]
            if (rand.Next(100) < 30)
            {
                if (rand.Next(100) < 60)
                    us.Email = Transliteration.Front(us.Name) + "." + Transliteration.Front(us.Surname) + domain;
                else // либо [email protected]
                    us.Email = Transliteration.Front(us.Surname) + "." + Transliteration.Front(us.Name) + domain;
                return;
            }

            // имя вида [email protected]
            if (rand.Next(100) < 40)
            {
                us.Email = Transliteration.Front(us.Name[0].ToString()) + Transliteration.Front(us.Surname);
                // или [email protected]
                if (rand.Next(100) < 66)
                    us.Email += (1996 - rand.Next(25));
                else
                    us.Email += (1996 - rand.Next(25)).ToString().Substring(2, 2);
                us.Email += domain;
                return;
            }

            // имя из логина [email protected]
            if (rand.Next(100) < 65)
            {
                us.Email = us.Login + domain;
                return;
            }

            // [email protected] или [email protected]
            us.Email = us.Login;
            if (rand.Next(100) < 66)
                us.Email += (1996 - rand.Next(25));
            else
                us.Email += (1996 - rand.Next(25)).ToString().Substring(2, 2);
            us.Email += domain;
        }
 public List<Transfer> GetAllUserPayments(ProtectedOperationContext ctx, PlatformUser user, out WalletError error)
 {
     error = WalletError.OK;
     if (Channel == null)
         throw new Exception("WalletManagerProxy: связь не установлена");
     try
     {
         return Channel.GetAllUserPayments(ctx, user, out error);
     }
     catch
     {
         RenewFactory();
         try
         {
             return Channel.GetAllUserPayments(ctx, user, out error);
         }
         catch (Exception ex2)
         {
             Logger.Error("GetAllUserPayments() error: ", ex2);
             return null;
         }
     }
 }
        public AuthenticationResponse ModifyUserAndAccount(string oldLogin, string oldPassword, PlatformUser userNew, 
            int? accountId, float accountMaxLeverage, out bool loginIsBusy)
        {
            loginIsBusy = false;

            using (var dbContext = DatabaseContext.Instance.Make())
            {
                try
                {
                    // получить пользователя и проверить логин/пароль
                    var user = dbContext.PLATFORM_USER.FirstOrDefault(u => u.Login == oldLogin);
                    if (user == null) return AuthenticationResponse.InvalidAccount;
                    if (user.Password != oldPassword) return AuthenticationResponse.WrongPassword;

                    if (userNew.Login != user.Login)
                    {// проверить доступность нового login-а
                        if (dbContext.PLATFORM_USER.Any(u => u.Login == userNew.Login))
                        {
                            loginIsBusy = true;
                            return AuthenticationResponse.NotAuthorized;
                        }
                    }

                    // обновить данные пользователя
                    user.Login = userNew.Login;
                    user.Name = userNew.Name;
                    user.Password = userNew.Password;
                    user.Patronym = userNew.Patronym;
                    user.Phone1 = userNew.Phone1;
                    user.Phone2 = userNew.Phone2;
                    user.Title = string.IsNullOrEmpty(userNew.Title) ? user.Title : userNew.Title;
                    user.Description = userNew.Description;

                    // обновить счет (макс плечо)
                    if (accountId.HasValue)
                    {
                        var acc = dbContext.ACCOUNT.FirstOrDefault(a => a.ID == accountId.Value);
                        if (acc != null && ((int)(acc.MaxLeverage * 10) != (int)(accountMaxLeverage * 10)))
                        {
                            acc.MaxLeverage = (decimal) accountMaxLeverage;
                        }
                    }
                    dbContext.SaveChanges();

                    return AuthenticationResponse.OK;
                }
                catch (Exception ex)
                {
                    Logger.ErrorFormat("Ошибка в ModifyUserAndAccount({0}) : {1}", oldLogin, ex);
                    return AuthenticationResponse.ServerError;
                }
            }
        }
Example #5
0
 public AuthenticationResponse ModifyUserAndAccount(string oldLogin, string oldPassword, 
     PlatformUser user, int? accountId, float accountMaxLeverage, out bool loginIsBusy)
 {
     loginIsBusy = false;
     return AuthenticationResponse.ServerError;
 }
Example #6
0
 public AuthenticationResponse GetUserDetail(string login, string password, out PlatformUser user)
 {
     user = null;
     return AuthenticationResponse.ServerError;
 }
 public AuthenticationResponse ModifyUserAndAccount(string oldLogin, string oldPassword, PlatformUser user, int? accountId,
                                                    float accountMaxLeverage, out bool loginIsBusy)
 {
     throw new NotImplementedException();
 }
 public AuthenticationResponse GetUserDetail(string login, string password, out PlatformUser user)
 {
     throw new NotImplementedException();
 }
Example #9
0
        public List<Transfer> GetAllUserPayments(ProtectedOperationContext secCtx, PlatformUser user, out WalletError error)
        {
            if (!UserSessionStorage.Instance.PermitUserOperation(secCtx, false, false))
            {
                error = WalletError.InsufficientRights;
                return null;
            }

            error = WalletError.ServerError;
            var transfers = new List<Transfer>();

            try
            {
                using (var ctx = DatabaseContext.Instance.Make())
                {
                    var queryTrans = (from trans in ctx.TRANSFER where trans.User == user.ID select trans).ToList().Select(
                        LinqToEntity.DecorateTransfer).ToList();
                }

                return transfers;
            }
            catch (Exception ex)
            {
                Logger.Error("GetAllUserPayments() error", ex);
                error = WalletError.ServerError;
                return null;
            }
        }
Example #10
0
 public AccountRegistrationStatus RegisterAccount(PlatformUser user, string accountCurrency, int startBalance,
                                                  decimal maxLeverage, string completedPassword, bool autoSignIn)
 {
     throw new NotImplementedException();
 }
Example #11
0
 public static PLATFORM_USER UndecoratePlatformUser(PlatformUser user)
 {
     var us = new PLATFORM_USER
     {
         ID = user.ID,
         Title = user.Title,
         Login = user.Login,
         Name = user.Name,
         Password = user.Password,
         Patronym = user.Patronym,
         Phone1 = user.Phone1,
         Phone2 = user.Phone2,
         RoleMask = (int)user.RoleMask,
         Surname = user.Surname,
         Description = user.Description,
         Email = user.Email,
         RegistrationDate = user.RegistrationDate
     };
     return us;
 }
Example #12
0
        private static bool SendEmailOnNewAccount(PlatformUser user, bool isDemo)
        {
            var sb = new StringBuilder();
            sb.AppendLine(string.Format("Уважаемый {0},", user.MakeFullName()));
            sb.AppendLine();
            sb.AppendLine(string.Format("в платформе {0} открыт {1} для пользователя {2}.",
                PlatformConstants.PlatformLongName, isDemo ? "демо-счет" : "счет", user.Login));
            sb.AppendLine(string.Format("Пароль для доступа к счету: {0}.", user.Password));
            sb.AppendLine();
            sb.AppendLine("Спасибо, что выбрали нас!");

            return HttpMailServerProxy.SendEmails(new[] { user.Email },
                                           "Регистрация счета в " + PlatformConstants.PlatformShortName,
                                           sb.ToString(), new string[0]);
        }
Example #13
0
        public AccountRegistrationStatus RegisterAccount(PlatformUser user,
            string accountCurrency, int startBalance, decimal maxLeverage, string completedPassword, bool autoSignIn)
        {
            // проверить заполнение логина-почты-баланса-плеча
            if (user.Login.Length < PlatformUser.LoginLenMin ||
                user.Login.Length > PlatformUser.LoginLenMax) return AccountRegistrationStatus.IncorrectLogin;
            if (user.Email.Length < PlatformUser.EmailLenMin ||
                user.Email.Length > PlatformUser.EmailLenMax) return AccountRegistrationStatus.IncorrectEmail;
            if (!PlatformUser.CheckLoginSpelling(user.Login)) return AccountRegistrationStatus.IncorrectLogin;
            if (startBalance < Account.MinimumStartDepo || startBalance > Account.MaximumStartDepo)
                return AccountRegistrationStatus.IncorrectBalance;
            if (maxLeverage < 0) maxLeverage = 0;
            else if (maxLeverage > Account.MaximumDepoLeverage) maxLeverage = Account.MaximumDepoLeverage;
            long hash;
            if (!TradingContractDictionary.Instance.GetTickers(out hash).Any(c => c.ActiveBase == accountCurrency ||
                c.ActiveCounter == accountCurrency)) return AccountRegistrationStatus.WrongCurrency;

            // сгенерировать пароль
            if (string.IsNullOrEmpty(completedPassword))
            {
                string pwrd;
                while (true)
                {
                    pwrd = RandomWordGenerator.Password(new Random().Next(2) + 2);
                    if (pwrd.Length < PlatformUser.PasswordLenMin || pwrd.Length > PlatformUser.PasswordLenMax)
                        continue;
                    break;
                }
                user.Password = pwrd;
            }
            else
                user.Password = completedPassword;
            user.RegistrationDate = DateTime.Now;
            Logger.InfoFormat("RegisterAccount (email={0}, login={1}, pwrd={2}{3})",
                user.Email, user.Login, user.Password, string.IsNullOrEmpty(completedPassword) ? " (auto)" : "");
            if (string.IsNullOrEmpty(user.Title))
                user.Title = string.IsNullOrEmpty(user.Name) ? user.Login : user.Name;
            user.RoleMask = UserRole.Trader;

            // попытка создать пользователя и открыть счет
            using (var ctx = DatabaseContext.Instance.Make())
            {
                try
                {
                    // проверка дублирования
                    var existUser = ctx.PLATFORM_USER.FirstOrDefault(u => u.Email.Equals(user.Email, StringComparison.OrdinalIgnoreCase));
                    Logger.InfoFormat("Регистрация пользователя: email {0} занят", user.Email);
                    if (existUser != null) return AccountRegistrationStatus.DuplicateEmail;
                    existUser = ctx.PLATFORM_USER.FirstOrDefault(u => u.Login == user.Login);
                    if (existUser != null) return AccountRegistrationStatus.DuplicateLogin;
                }
                catch (Exception ex)
                {
                    Logger.Error("Ошибка в RegisterAccount(checks)", ex);
                    return AccountRegistrationStatus.ServerError;
                }

                // в рамках одной транзакции создать логин и счет
                //using (var transaction = ctx.Connection.BeginTransaction())
                {
                    DbTransaction transaction;
                    try
                    {
                        if (((IObjectContextAdapter)ctx).ObjectContext.Connection.State != ConnectionState.Open)
                            ((IObjectContextAdapter)ctx).ObjectContext.Connection.Open();
                        Logger.Info("Connection's opened");
                        transaction = ((IObjectContextAdapter)ctx).ObjectContext.Connection.BeginTransaction();
                    }
                    catch (Exception ex)
                    {
                        Logger.Error("RegisterAccount - ошибка в ctx.Connection.BeginTransaction", ex);
                        return AccountRegistrationStatus.ServerError;
                    }

                    try
                    {
                        // добавить пользователя
                        var userBase = LinqToEntity.UndecoratePlatformUser(user);
                        ctx.PLATFORM_USER.Add(userBase);

                        // добавить счет
                        var account = new ACCOUNT
                        {
                            AccountGroup = defaultDemoAccountGroupCode,
                            MaxLeverage = maxLeverage,
                            Balance = startBalance,
                            UsedMargin = 0,
                            Currency = accountCurrency,
                            Description = string.Format("demo account for {0}", user.Login),
                            Status = (int)Account.AccountStatus.Created,
                            TimeCreated = DateTime.Now,
                        };
                        try
                        {
                            ctx.ACCOUNT.Add(account);
                            // сохранить изменения (добавление пользователя и счета, нужны ID)
                            ctx.SaveChanges();
                        }
                        catch (Exception ex)
                        {
                            Logger.Error("RegisterAccount - ACCOUNT adding error", ex);
                            return AccountRegistrationStatus.ServerError;
                        }

                        // добавить кошелек
                        try
                        {
                            var wallet = new WALLET
                            {
                                Balance = 0,
                                Currency = accountCurrency,
                                Password = user.Password,
                                User = userBase.ID
                            };
                            ctx.WALLET.Add(wallet);
                        }
                        catch (Exception ex)
                        {
                            Logger.Error("RegisterAccount - WALLET adding error", ex);
                            return AccountRegistrationStatus.ServerError;
                        }

                        // пользователь-счет
                        var userAccount = new PLATFORM_USER_ACCOUNT
                        {
                            PlatformUser = userBase.ID,
                            Account = account.ID,
                            RightsMask = (int)AccountRights.Управление
                        };
                        ctx.PLATFORM_USER_ACCOUNT.Add(userAccount);

                        // перевод на счет
                        var trans = new BALANCE_CHANGE
                        {
                            ValueDate = DateTime.Now,
                            AccountID = account.ID,
                            Amount = startBalance,
                            ChangeType = (int)BalanceChangeType.Deposit,
                            Description = "initial deposit"
                        };
                        ctx.BALANCE_CHANGE.Add(trans);

                        // сделать сигнальщиком
                        if (makeNewlyAddedUsersSignallers)
                            MakeNewlyRegisteredAccountSignaller(ctx, userBase, account);

                        // сохранить все изменения
                        ctx.SaveChanges();
                        if (string.IsNullOrEmpty(completedPassword))
                            if (!SendEmailOnNewAccount(user, true))
                            {
                                transaction.Rollback();
                                return AccountRegistrationStatus.EmailDeliveryError;
                            }

                        transaction.Commit();
                        ((IObjectContextAdapter)ctx).ObjectContext.Connection.Close();
                    }
                    catch (Exception ex)
                    {
                        Logger.ErrorFormat("Ошибка в RegisterAccount (login={0}, email={1}) : {2}",
                                           user.Login, user.Email, ex);
                        transaction.Rollback();
                        ((IObjectContextAdapter)ctx).ObjectContext.Connection.Close();
                        return AccountRegistrationStatus.ServerError;
                    }
                } // using (transaction ...
            }
            return AccountRegistrationStatus.OK;
        }
 public PaidService GetPaidServiceDetail(int serviceId, out PlatformUser serviceOwner)
 {
     serviceOwner = null;
     if (Channel == null)
         throw new Exception("WalletManagerProxy: связь не установлена");
     try
     {
         return Channel.GetPaidServiceDetail(serviceId, out serviceOwner);
     }
     catch
     {
         RenewFactory();
         try
         {
             return Channel.GetPaidServiceDetail(serviceId, out serviceOwner);
         }
         catch (Exception ex2)
         {
             Logger.Error("GetPaidServiceDetail() error: ", ex2);
             return null;
         }
     }
 }
Example #15
0
        public AccountRegistrationResponse RegisterAccount(
            string login,
            string password,
            string email,
            string firstName,
            string lastName,
            string patronym,
            string phone,
            string currency, int startBalance)
        {
            var usr = new PlatformUser
            {
                Login = login,
                Password = password,
                Email = email,
                Name = firstName,
                Surname = lastName,
                Patronym = patronym,
                Phone1 = phone,
                RegistrationDate = DateTime.Now
            };

            var resp = new AccountRegistrationResponse();
            if (currency != "USD")
                resp.errors.Add("Поддерживаемые валюты: " + "USD");
            //if (!PlatformUser.CheckLoginSpelling(usr.Login))
            //    resp.errors.Add("Логин задан некорректно");
            if (resp.errors.Count > 0)
                return resp;

            var status = ManagerAccount.Instance.RegisterAccount(usr,
                currency, startBalance < 1000 ? 1000 : startBalance, 0, usr.Password, false);
            resp.status = status;
            resp.statusName = EnumFriendlyName<AccountRegistrationStatus>.GetString(status);

            return resp;
        }
 public AccountRegistrationStatus RegisterAccount(PlatformUser user, string accountCurrency,
     int startBalance, decimal maxLeverage, string completedPassword, bool autoSignIn)
 {
     return AccountRegistrationStatus.ServerError;
 }
Example #17
0
 public PaidService GetPaidServiceDetail(int serviceId, out PlatformUser serviceOwner)
 {
     // вернуть сервис и прогрессивную шкалу расценок
     var list = GetServicesByUserOrId(serviceId, false, out serviceOwner);
     return list.Count == 0 ? null : list[0];
 }
 public CreateReadonlyUserRequestStatus MakeOrDeleteReadonlyUser(ProtectedOperationContext secCtx, int accountId, bool makeNew,
                                                                 string pwrd, out PlatformUser user)
 {
     throw new NotImplementedException();
 }
Example #19
0
        public WalletError GetTransferExtendedInfo(ProtectedOperationContext secCtx,
                                                   int transferId, out BalanceChange balanceChange, out PlatformUser user)
        {
            balanceChange = null;
            user = null;

            if (!UserSessionStorage.Instance.PermitUserOperation(secCtx, false, false))
                return WalletError.InsufficientRights;

            var error = WalletError.ServerError;
            try
            {
                using (var ctx = DatabaseContext.Instance.Make())
                {
                    var trans = ctx.TRANSFER.FirstOrDefault(t => t.ID == transferId);
                    if (trans == null) return WalletError.InvalidData;
                    if (trans.BalanceChange.HasValue)
                    {
                        balanceChange = LinqToEntity.DecorateBalanceChange(trans.BALANCE_CHANGE);
                        return WalletError.OK;
                    }
                    if (trans.RefWallet.HasValue)
                    {
                        var us = ctx.PLATFORM_USER.FirstOrDefault(u => u.ID == trans.RefWallet.Value);
                        if (us != null)
                        {
                            user = LinqToEntity.DecoratePlatformUser(us);
                            user.Password = string.Empty;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.ErrorFormat("GetTransferExtendedInfo({0}) error: {1}", transferId, ex);
                error = WalletError.ServerError;
            }
            return error;
        }
 public RequestStatus QueryReadonlyUserForAccount(ProtectedOperationContext secCtx, int accountId, out PlatformUser user)
 {
     throw new NotImplementedException();
 }
Example #21
0
        private List<PaidService> GetServicesByUserOrId(int id, bool byUser, out PlatformUser serviceOwner)
        {
            serviceOwner = null;
            var srvList = new List<PaidService>();
            try
            {
                using (var ctx = DatabaseContext.Instance.Make())
                {
                    var query = byUser
                                    ? ctx.SERVICE.Where(s => s.User == id)
                                    : ctx.SERVICE.Where(s => s.ID == id);
                    foreach (var srv in query)
                    {
                        var paidServ = LinqToEntity.DecoratePaidService(srv);
                        var srvId = srv.ID;
                        // добавить рейты
                        foreach (var rate in ctx.SERVICE_RATE.Where(r => r.Service == srvId))
                            paidServ.serviceRates.Add(new PaidServiceRate
                            {
                                Amount = rate.Amount,
                                RateType = (PaidServiceRate.ServiceRateType)rate.RateType,
                                UserBalance = rate.UserBalance
                            });
                        srvList.Add(paidServ);
                    }

                    if (byUser)
                        serviceOwner = LinqToEntity.DecoratePlatformUser(ctx.PLATFORM_USER.First(u => u.ID == id));
                    else
                    {
                        var srv = srvList.FirstOrDefault();
                        if (srv != null)
                            serviceOwner = LinqToEntity.DecoratePlatformUser(ctx.PLATFORM_USER.First(u => u.ID == srv.User));
                    }
                }
                return srvList;
            }
            catch (Exception ex)
            {
                Logger.ErrorFormat("GetServicesByUserOrId({0}, {1}) error: {2}", id, byUser, ex);
                return srvList;
            }
        }
Example #22
0
 public CreateReadonlyUserRequestStatus MakeOrDeleteReadonlyUser(ProtectedOperationContext secCtx,
                                                                int accountId, bool makeNew, string pwrd,
                                                                out PlatformUser user)
 {
     user = null;
     return CreateReadonlyUserRequestStatus.CommonError;
 }
Example #23
0
        private void EditExisting()
        {
            var login = AccountStatus.Instance.Login;
            if (string.IsNullOrEmpty(login)) return;
            if (string.IsNullOrEmpty(oldPassword)) return;
            if (editedUser == null) return;
            if (editedAccount == null) return;

            // собрать данные
            var user = new PlatformUser
            {
                Email = tbEmail.Text,
                Login = tbLogin.Text,
                Name = tbName.Text,
                Surname = tbSurname.Text,
                Patronym = tbPatronym.Text,
                Phone1 = tbPhone1.Text,
                Phone2 = tbPhone2.Text,
                Description = tbDescription.Text,
                Password = tbPassword.Text
            };
            var maxLeverage = tbMaxLeverage.Text.ToFloatUniform();

            bool loginIsBusy;
            var resp = MainForm.serverProxyTrade.proxy.ModifyUserAndAccount(login, oldPassword,
                                                                              user, editedAccount.ID, maxLeverage, out loginIsBusy);
            if (loginIsBusy)
            {
                MessageBox.Show(string.Format(Localizer.GetString("MessageLoginInUse"), user.Login));
                return;
            }

            if (resp == AuthenticationResponse.AccountInactive ||
                resp == AuthenticationResponse.InvalidAccount ||
                resp == AuthenticationResponse.WrongPassword ||
                resp == AuthenticationResponse.ServerError)
            {
                var msg = Localizer.GetString("MessageUnableToUpdate") + " - " +
                    EnumFriendlyName<AuthenticationResponse>.GetString(resp);
                MessageBox.Show(msg, Localizer.GetString("TitleError"));
            }

            // обновить дополнительные данные о пользователе
            try
            {
                var userInfoExSource =
                    new UserInfoExCache(TradeSharpAccountStatistics.Instance.proxy, TerminalEnvironment.FileCacheFolder);
                var info = new UserInfoEx
                    {
                        Id = editedUser.ID,
                        AvatarBig = bigAvatarPanel.BackgroundImage as Bitmap,
                        AvatarSmall = smallAvatarPanel.BackgroundImage as Bitmap,
                        About = aboutRichTextBox.Text,
                        Contacts = ContactListUtils.PackContacts(contactsListView)
                    };
                userInfoExSource.SetUserInfo(info);
            }
            catch (Exception ex)
            {
                MessageBox.Show(Localizer.GetString("TitleServerError"),
                    Localizer.GetString("TitleError"));
                Logger.Info("Ошбика при записи дополнительной информации о пользователе", ex);
                return;
            }
            MessageBox.Show(Localizer.GetString("MessageDataSuccessfulyUpdated"),
                Localizer.GetString("TitleConfirmation"),
                MessageBoxButtons.OK,
                MessageBoxIcon.Asterisk);
        }
Example #24
0
 public RequestStatus QueryReadonlyUserForAccount(ProtectedOperationContext secCtx, int accountId,
                                                  out PlatformUser user)
 {
     user = null;
     return RequestStatus.CommonError;
 }
Example #25
0
        private void RegisterNewAccount()
        {
            var user = new PlatformUser
            {
                Email = tbEmail.Text,
                Login = tbLogin.Text,
                Name = tbName.Text,
                Surname = tbSurname.Text,
                Patronym = tbPatronym.Text,
                Phone1 = tbPhone1.Text,
                Phone2 = tbPhone2.Text,
                Description = tbDescription.Text
            };

            // передать запрос на регистрацию на сервер
            var depoSz = cbDepoSize.Text.Replace(" ", "").ToInt();
            var requestError = string.Empty;
            try
            {
                var status = TradeSharpAccount.Instance.proxy.RegisterAccount(user, cbCurrency.Text, depoSz,
                    tbMaxLeverage.Text.ToDecimalUniformSafe() ?? 0,
                    EnablePasswordOnRegistration ? tbPassword.Text : string.Empty, AppConfig.GetBooleanParam("AutoSignIn", false));
                if (status != AccountRegistrationStatus.OK)
                    requestError = EnumFriendlyName<AccountRegistrationStatus>.GetString(status);
            }
            catch (Exception ex)
            {
                requestError = Localizer.GetString("TitleServerError");
                Logger.Error("Ошибка в RegisterAccount", ex);
            }

            if (!string.IsNullOrEmpty(requestError))
            {
                MessageBox.Show(requestError,
                    Localizer.GetString("TitleError"),
                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                if (onRegistred != null) onRegistred(false);
                return;
            }

            MainForm.Instance.AddMessageToStatusPanelSafe(DateTime.Now,
                string.Format(
                    Localizer.GetString("MessageUserRegisteredFmt"),
                    tbLogin.Text,
                    EnablePasswordOnRegistration ? ", " + Localizer.GetString("MessageUserRegisteredPasswordPart") + " " + tbPassword.Text : ""));

            var msg = EnablePasswordOnRegistration
                ? Localizer.GetString("MessageRegistrationCompleted")
                : string.Format(Localizer.GetString("MessageRegistrationCompletedEmailFmt"),
                    Environment.NewLine, tbEmail.Text);
            MessageBox.Show(msg,
                Localizer.GetString("TitleConfirmation"),
                MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            Registred = true;
            if (onRegistred != null) onRegistred(true);
        }
Example #26
0
        private List<PlatformUser> MakeUsersWithNames()
        {
            var users = new List<PlatformUser>();
            var pwrd = tbPassword.Text;

            foreach (var line in tbUserNames.Lines)
            {
                if (string.IsNullOrEmpty(line) || line.Length < 10) continue;
                var parts = line.Split(
                    new[] {' ', (char) Keys.Tab, ';', ','}, StringSplitOptions.RemoveEmptyEntries);
                if (parts.Length != 3) continue;

                var login = parts.FirstOrDefault(p => (p[0] >= 'a' && p[0] <= 'z') || (p[0] >= 'A' && p[0] <= 'Z'));
                if (string.IsNullOrEmpty(login)) continue;

                parts = parts.Except(new[] {login}).ToArray();
                var user = new PlatformUser
                    {
                        Login = login,
                        Name = parts[0],
                        Surname = parts[1],
                        Password = pwrd,
                        Title = "Trader",
                        RightsMask = UserAccountRights.Trade,
                        RegistrationDate = DateTime.Now
                    };
                MakeEmail(user);
                users.Add(user);
            }

            return users;
        }
Example #27
0
 private void ShowSignallerOptions(PlatformUser user)
 {
     workerLoadManagerServices.RunWorkerAsync(user);
     SwitchLoadingUserInfoProgressBar(true);
 }
 public AuthenticationResponse GetUserDetail(string login, string password, out PlatformUser userDecorated)
 {
     userDecorated = null;
     using (var dbContext = DatabaseContext.Instance.Make())
     {
         try
         {
             var user = dbContext.PLATFORM_USER.FirstOrDefault(u => u.Login == login);
             if (user == null) return AuthenticationResponse.InvalidAccount;
             if (user.Password != password) return AuthenticationResponse.WrongPassword;
             userDecorated = LinqToEntity.DecoratePlatformUser(user);
             return AuthenticationResponse.OK;
         }
         catch (Exception ex)
         {
             Logger.ErrorFormat("Ошибка в GetUserDetail({0}) : {1}", login, ex);
             return AuthenticationResponse.ServerError;
         }
     }
 }
 public AccountRegistrationStatus RegisterAccount(PlatformUser user, string accountCurrency, int startBalance, decimal maxLeverage, string completedPassword, bool autoSignIn)
 {
     return Channel.RegisterAccount(user, accountCurrency, startBalance, maxLeverage, completedPassword,
                                         autoSignIn);
 }