CheckForUpdate() static private method

static private CheckForUpdate ( bool updateOverride = false ) : Task
updateOverride bool
return Task
Exemplo n.º 1
0
        private async void MainForm_Load(object sender, EventArgs e)
        {
            Logging.InitFormLogger();

            BotListView.LargeImageList = BotListView.SmallImageList = AvatarImageList;

            await Task.Run(async() => {
                Program.ArchiLogger.LogGenericInfo("ASF V" + SharedInfo.Version);

                if (!Directory.Exists(SharedInfo.ConfigDirectory))
                {
                    Program.ArchiLogger.LogGenericError("Config directory could not be found!");
                    Environment.Exit(1);
                }

                await ASF.CheckForUpdate().ConfigureAwait(false);

                // Before attempting to connect, initialize our list of CMs
                await Bot.InitializeCMs(Program.GlobalDatabase.CellID, Program.GlobalDatabase.ServerListProvider).ConfigureAwait(false);
            });

            foreach (string botName in Directory.EnumerateFiles(SharedInfo.ConfigDirectory, "*.json").Select(Path.GetFileNameWithoutExtension))
            {
                switch (botName)
                {
                case SharedInfo.ASF:
                case "example":
                case "minimal":
                    continue;
                }

                Bot bot = new Bot(botName);

                BotStatusForm botStatusForm = new BotStatusForm(bot);

                BotIndexes[botName] = AvatarImageList.Images.Count;

                AvatarImageList.Images.Add(botName, botStatusForm.AvatarPictureBox.Image);

                botStatusForm.TopLevel = false;
                BotStatusPanel.Controls.Add(botStatusForm);

                ListViewItem botListViewItem = new ListViewItem {
                    ImageIndex = BotIndexes[botName],
                    Text       = botName
                };

                BotListView.Items.Add(botListViewItem);
            }

            if (BotListView.Items.Count > 0)
            {
                BotListView.Items[0].Selected = true;
                BotListView.Select();
            }
        }
Exemplo n.º 2
0
        private static async Task InitASF(string[] args)
        {
            ASF.ArchiLogger.LogGenericInfo("ASF V" + SharedInfo.Version);

            await InitGlobalConfigAndLanguage().ConfigureAwait(false);

            if (!Runtime.IsRuntimeSupported)
            {
                ASF.ArchiLogger.LogGenericError(Strings.WarningRuntimeUnsupported);
                await Task.Delay(60 * 1000).ConfigureAwait(false);
            }

            await InitGlobalDatabaseAndServices().ConfigureAwait(false);

            // If debugging is on, we prepare debug directory prior to running
            if (GlobalConfig.Debug)
            {
                Logging.EnableTraceLogging();

                if (Directory.Exists(SharedInfo.DebugDirectory))
                {
                    try {
                        Directory.Delete(SharedInfo.DebugDirectory, true);
                        await Task.Delay(1000).ConfigureAwait(false);                         // Dirty workaround giving Windows some time to sync
                    } catch (IOException e) {
                        ASF.ArchiLogger.LogGenericException(e);
                    }
                }

                Directory.CreateDirectory(SharedInfo.DebugDirectory);

                DebugLog.AddListener(new Debugging.DebugListener());
                DebugLog.Enabled = true;
            }

            // Parse post-init args
            if (args != null)
            {
                await ParsePostInitArgs(args).ConfigureAwait(false);
            }

            // If we ran ASF as a client, we're done by now
            if (Mode.HasFlag(EMode.Client) && !Mode.HasFlag(EMode.Server))
            {
                await Exit().ConfigureAwait(false);
            }

            await ASF.CheckForUpdate().ConfigureAwait(false);

            await ASF.InitBots().ConfigureAwait(false);

            ASF.InitEvents();
        }
Exemplo n.º 3
0
        private static async Task InitASF(string[] args)
        {
            ASF.ArchiLogger.LogGenericInfo("ASF V" + SharedInfo.Version + " (" + SharedInfo.ModuleVersion + ")");

            await InitGlobalConfigAndLanguage().ConfigureAwait(false);
            await InitGlobalDatabaseAndServices().ConfigureAwait(false);

            // If debugging is on, we prepare debug directory prior to running
            if (GlobalConfig.Debug)
            {
                Logging.EnableTraceLogging();

                if (Directory.Exists(SharedInfo.DebugDirectory))
                {
                    try {
                        Directory.Delete(SharedInfo.DebugDirectory, true);
                        await Task.Delay(1000).ConfigureAwait(false);                         // Dirty workaround giving Windows some time to sync
                    } catch (IOException e) {
                        ASF.ArchiLogger.LogGenericException(e);
                    }
                }

                Directory.CreateDirectory(SharedInfo.DebugDirectory);

                DebugLog.AddListener(new Debugging.DebugListener());
                DebugLog.Enabled = true;
            }

            // Parse post-init args
            if (args != null)
            {
                ParsePostInitArgs(args);
            }

            await ASF.CheckForUpdate().ConfigureAwait(false);

            await ASF.InitBots().ConfigureAwait(false);

            ASF.InitEvents();
        }
Exemplo n.º 4
0
        internal static string GetUserInput(ASF.EUserInputType userInputType, string botName = SharedInfo.ASF, string extraInformation = null) => null;         // TODO

        internal static async Task InitASF()
        {
            ASF.ArchiLogger.LogGenericInfo("ASF V" + SharedInfo.Version);

            await InitGlobalConfigAndLanguage().ConfigureAwait(false);

            if (!Runtime.IsRuntimeSupported)
            {
                ASF.ArchiLogger.LogGenericError(Strings.WarningRuntimeUnsupported);
                await Task.Delay(60 * 1000).ConfigureAwait(false);
            }

            await InitGlobalDatabaseAndServices().ConfigureAwait(false);

            // If debugging is on, we prepare debug directory prior to running
            if (GlobalConfig.Debug)
            {
                if (Directory.Exists(SharedInfo.DebugDirectory))
                {
                    try {
                        Directory.Delete(SharedInfo.DebugDirectory, true);
                        await Task.Delay(1000).ConfigureAwait(false);                         // Dirty workaround giving Windows some time to sync
                    } catch (IOException e) {
                        ASF.ArchiLogger.LogGenericException(e);
                    }
                }

                Directory.CreateDirectory(SharedInfo.DebugDirectory);

                DebugLog.AddListener(new Debugging.DebugListener());
                DebugLog.Enabled = true;
            }

            await ASF.CheckForUpdate().ConfigureAwait(false);

            await ASF.InitBots().ConfigureAwait(false);

            ASF.InitEvents();
        }
Exemplo n.º 5
0
        private static void Init(string[] args)
        {
            AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionHandler;
            TaskScheduler.UnobservedTaskException      += UnobservedTaskExceptionHandler;

            string homeDirectory = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);

            if (!string.IsNullOrEmpty(homeDirectory))
            {
                Directory.SetCurrentDirectory(homeDirectory);

                // Allow loading configs from source tree if it's a debug build
                if (Debugging.IsDebugBuild)
                {
                    // Common structure is bin/(x64/)Debug/ArchiSteamFarm.exe, so we allow up to 4 directories up
                    for (byte i = 0; i < 4; i++)
                    {
                        Directory.SetCurrentDirectory("..");
                        if (Directory.Exists(SharedInfo.ConfigDirectory))
                        {
                            break;
                        }
                    }

                    // If config directory doesn't exist after our adjustment, abort all of that
                    if (!Directory.Exists(SharedInfo.ConfigDirectory))
                    {
                        Directory.SetCurrentDirectory(homeDirectory);
                    }
                }
            }

            // Parse pre-init args
            if (args != null)
            {
                ParsePreInitArgs(args);
            }

            Logging.InitLoggers();
            ASF.ArchiLogger.LogGenericInfo("ASF V" + SharedInfo.Version);

            if (!Runtime.IsRuntimeSupported)
            {
                ASF.ArchiLogger.LogGenericError("ASF detected unsupported runtime version, program might NOT run correctly in current environment. You're running it at your own risk!");
                Thread.Sleep(10000);
            }

            InitServices();

            // If debugging is on, we prepare debug directory prior to running
            if (GlobalConfig.Debug)
            {
                if (Directory.Exists(SharedInfo.DebugDirectory))
                {
                    Directory.Delete(SharedInfo.DebugDirectory, true);
                    Thread.Sleep(1000);                     // Dirty workaround giving Windows some time to sync
                }

                Directory.CreateDirectory(SharedInfo.DebugDirectory);

                SteamKit2.DebugLog.AddListener(new Debugging.DebugListener());
                SteamKit2.DebugLog.Enabled = true;
            }

            // Parse post-init args
            if (args != null)
            {
                ParsePostInitArgs(args);
            }

            // If we ran ASF as a client, we're done by now
            if (Mode == EMode.Client)
            {
                Exit();
            }

            // From now on it's server mode
            if (!Directory.Exists(SharedInfo.ConfigDirectory))
            {
                ASF.ArchiLogger.LogGenericError("Config directory doesn't exist!");
                Thread.Sleep(5000);
                Exit(1);
            }

            ASF.CheckForUpdate().Wait();

            // Before attempting to connect, initialize our list of CMs
            Bot.InitializeCMs(GlobalDatabase.CellID, GlobalDatabase.ServerListProvider);

            foreach (string botName in Directory.EnumerateFiles(SharedInfo.ConfigDirectory, "*.json").Select(Path.GetFileNameWithoutExtension))
            {
                switch (botName)
                {
                case SharedInfo.ASF:
                case "example":
                case "minimal":
                    continue;
                }

                new Bot(botName).Forget();
            }

            if (Bot.Bots.Count == 0)
            {
                ASF.ArchiLogger.LogGenericWarning("No bots are defined, did you forget to configure your ASF?");
            }

            ASF.InitFileWatcher();
        }
Exemplo n.º 6
0
        private static async Task InitCore(string[] args)
        {
            AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionHandler;
            TaskScheduler.UnobservedTaskException      += UnobservedTaskExceptionHandler;

            string homeDirectory = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);

            if (!string.IsNullOrEmpty(homeDirectory))
            {
                Directory.SetCurrentDirectory(homeDirectory);

                // Allow loading configs from source tree if it's a debug build
                if (Debugging.IsDebugBuild)
                {
                    // Common structure is bin/(x64/)Debug/ArchiSteamFarm.exe, so we allow up to 4 directories up
                    for (byte i = 0; i < 4; i++)
                    {
                        Directory.SetCurrentDirectory("..");
                        if (Directory.Exists(SharedInfo.ConfigDirectory))
                        {
                            break;
                        }
                    }

                    // If config directory doesn't exist after our adjustment, abort all of that
                    if (!Directory.Exists(SharedInfo.ConfigDirectory))
                    {
                        Directory.SetCurrentDirectory(homeDirectory);
                    }
                }
            }

            // Parse pre-init args
            if (args != null)
            {
                ParsePreInitArgs(args);
            }

            Logging.InitLoggers();
            ASF.ArchiLogger.LogGenericInfo("ASF V" + SharedInfo.Version);

            await InitServices().ConfigureAwait(false);

            if (!Runtime.IsRuntimeSupported)
            {
                ASF.ArchiLogger.LogGenericError(Strings.WarningRuntimeUnsupported);
                await Task.Delay(10 * 1000).ConfigureAwait(false);
            }

            // If debugging is on, we prepare debug directory prior to running
            if (GlobalConfig.Debug)
            {
                if (Directory.Exists(SharedInfo.DebugDirectory))
                {
                    try {
                        Directory.Delete(SharedInfo.DebugDirectory, true);
                        await Task.Delay(1000).ConfigureAwait(false);                         // Dirty workaround giving Windows some time to sync
                    } catch (IOException e) {
                        ASF.ArchiLogger.LogGenericException(e);
                    }
                }

                Directory.CreateDirectory(SharedInfo.DebugDirectory);

                DebugLog.AddListener(new Debugging.DebugListener());
                DebugLog.Enabled = true;
            }

            // Parse post-init args
            if (args != null)
            {
                await ParsePostInitArgs(args).ConfigureAwait(false);
            }

            // If we ran ASF as a client, we're done by now
            if (Mode.HasFlag(EMode.Client) && !Mode.HasFlag(EMode.Server))
            {
                Exit();
            }

            await ASF.CheckForUpdate().ConfigureAwait(false);

            await ASF.InitBots().ConfigureAwait(false);

            ASF.InitFileWatcher();
        }