Exemplo n.º 1
0
        public void OpenLoginDialog(string login = null, string pwrd = null)
        {
            if (loginDialogIsShown)
            {
                return;
            }
            try
            {
                loginDialogIsShown = true;
                var dlg = new LoginForm(this);
                if (!string.IsNullOrEmpty(login))
                {
                    dlg.Login = login;
                }
                if (!string.IsNullOrEmpty(pwrd))
                {
                    dlg.Password = pwrd;
                }
                var dlgResult = dlg.ShowDialog();
                UserSettings.Instance.HidePasswordChars = dlg.HidePassword;

                if (dlgResult != DialogResult.Yes)
                {
                    return;
                }
                if (!AccountStatus.Instance.isAuthorized)
                {
                    return;
                }
                // показать диалог выбора счета
                var dlgAc = new SelectAccountForm();
                dlgAc.ShowDialog();
                HistoryOrderStorage.Instance.HurryUpUpdate();
            }
            finally
            {
                loginDialogIsShown = false;
            }
        }
Exemplo n.º 2
0
        public BotAccount GetStartUpAccount()
        {
            ISession session = TinyIoC.TinyIoCContainer.Current.Resolve <ISession>();

            if (!session.LogicSettings.AllowMultipleBot)
            {
                runningAccount = Accounts.Last();
            }
            else
            {
                runningAccount = GetMinRuntime(true);
            }

            if (session.LogicSettings.AllowMultipleBot &&
                session.LogicSettings.MultipleBotConfig.SelectAccountOnStartUp)
            {
                SelectAccountForm f = new SelectAccountForm();
                f.ShowDialog();
                runningAccount = f.SelectedAccount;
            }
            runningAccount.LoggedTime = DateTime.Now;
            return(runningAccount);
        }
Exemplo n.º 3
0
        public Account GetStartUpAccount()
        {
            ISession session = TinyIoCContainer.Current.Resolve <ISession>();
            Account  startupAccount;

            if (!AllowMultipleBot())
            {
                startupAccount = _context.Account.Last();
            }
            else
            {
                startupAccount = GetMinRuntime(true);
            }

            if (AllowMultipleBot() &&
                session.LogicSettings.MultipleBotConfig.SelectAccountOnStartUp)
            {
                SelectAccountForm f = new SelectAccountForm();
                f.ShowDialog();
                startupAccount = f.SelectedAccount;
            }
            return(startupAccount);
        }
Exemplo n.º 4
0
        public BotAccount GetStartUpAccount()
        {
            ISession session = TinyIoC.TinyIoCContainer.Current.Resolve <ISession>();

            if (!session.LogicSettings.AllowMultipleBot)
            {
                runningAccount = Accounts.Last();
            }
            else
            {
                runningAccount = GetMinRuntime();
            }

            if (session.LogicSettings.AllowMultipleBot &&
                session.LogicSettings.MultipleBotConfig.SelectAccountOnStartUp)
            {
                SelectAccountForm f = new SelectAccountForm();
                f.ShowDialog();
                runningAccount = f.SelectedAccount;
            }
            runningAccount.LoggedTime = DateTime.Now;
            return(runningAccount);

            //if (session.LogicSettings.AllowMultipleBot
            //   && session.LogicSettings.MultipleBotConfig.SelectAccountOnStartUp)
            //{
            //    byte index = 0;
            //    Console.WriteLine();
            //    Console.WriteLine();
            //    Logic.Logging.Logger.Write("PLEASE SELECT AN ACCOUNT TO START. AUTO START AFTER 30 SEC");
            //    List<Char> availableOption = new List<char>();
            //    foreach (var item in this.Accounts)
            //    {
            //        var ch = (char)(index + 65);
            //        availableOption.Add(ch);
            //        int day = (int)item.RuntimeTotal / 1440;
            //        int hour = (int)(item.RuntimeTotal - (day * 1400)) / 60;
            //        int min = (int)(item.RuntimeTotal - (day * 1400) - hour * 60);

            //        var runtime = $"{day:00}:{hour:00}:{min:00}:00";

            //        Logic.Logging.Logger.Write($"{ch}. {item.GoogleUsername}{item.PtcUsername} \t\t{runtime}");
            //        index++;
            //    }

            //    char select = ' ';
            //    DateTime timeoutvalue = DateTime.Now.AddSeconds(30);

            //    while (DateTime.Now < timeoutvalue && !availableOption.Contains(select))
            //    {
            //        if (Console.KeyAvailable)
            //        {
            //            ConsoleKeyInfo cki = Console.ReadKey();
            //            select = cki.KeyChar;
            //            select = Char.ToUpper(select);
            //            if (!availableOption.Contains(select))
            //            {
            //                Console.Out.WriteLine("Please select an account from list");
            //            }
            //        }
            //        else
            //        {
            //            Thread.Sleep(100);
            //        }
            //    }

            //    if (availableOption.Contains(select))
            //    {
            //        bot = this.Accounts[select - 65];
            //    }
            //    else
            //    {
            //        bot = this.Accounts.OrderBy(p => p.RuntimeTotal).First();
            //    }
            //}
            //if(bot == null)
            //    this.Accounts.OrderBy(p => p.RuntimeTotal).First();

            //return bot;
        }