/// <summary>
        ///     Initials the setup.
        /// </summary>
        private static void InitialSetup()
        {
            Logger.LogMessage("Bot firing up initial setup");
            Logger.LogMessage();
            Logger.LogMessage();

            ////////////////////////////
            DownTimeProvider = new DownTimeProvider(DateTime.Now);

            ////////////////////////////

            CurrentPromo = null;
            State = BotState.FullRun;

            UserSettings = UserSettingsHelper.ReadUserSettings();

            LocalBot = new LocalBot();
            LocalBot.Login();
        }
Пример #2
0
        /// <summary>
        /// Reads the user settings from path.
        /// </summary>
        /// <param name="path">The path.</param>
        /// <returns></returns>
        /// <exception cref="System.ArgumentNullException">path</exception>
        /// <exception cref="System.NullReferenceException">
        /// Username
        /// or
        /// Password
        /// </exception>
        public static UserSettings ReadUserSettingsFromPath(string path)
        {
            if (path.IsNullOrBlank())
            {
                throw new ArgumentNullException("path");
            }

            var settings = new UserSettings();

            var source = new IniConfigSource(path);

            settings.Username = source.Configs["Credentials"].Get("Username");
            settings.Password = source.Configs["Credentials"].Get("Password");

            if (settings.Username.IsNullOrBlank())
            {
                throw new NullReferenceException("Username not specified");
            }

            if (settings.Password.IsNullOrBlank())
            {
                throw new NullReferenceException("Password not specified");
            }

            settings.MinWaitTime = int.Parse(source.Configs["Settings"].Get("MinWaitTime"));
            settings.MaxWaitTime = int.Parse(source.Configs["Settings"].Get("MaxWaitTime"));
            settings.MinBlinkBidIsk = long.Parse(source.Configs["Settings"].Get("MinBlinkBidIsk"));
            settings.MaxBlinkBidIsk = long.Parse(source.Configs["Settings"].Get("MaxBlinkBidIsk"));
            settings.DownTime = int.Parse(source.Configs["Settings"].Get("DownTime"));
            settings.RunTime = int.Parse(source.Configs["Settings"].Get("RunTime"));

            settings.DebugMode = int.Parse(source.Configs["Settings"].Get("DebugMode"));
            settings.proxyIp = source.Configs["Settings"].Get("proxyIp");
            settings.proxyPort = source.Configs["Settings"].Get("proxyPort");
            settings.proxyUser = source.Configs["Settings"].Get("proxyUser");
            settings.proxyPass = source.Configs["Settings"].Get("proxyPass");
            settings.useProxy = bool.Parse(source.Configs["Settings"].Get("useProxy"));
            settings.proxyType = int.Parse(source.Configs["Settings"].Get("proxyType", "0"));

            source.Save(path);

            return settings;
        }