LogGenericError() private static method

private static LogGenericError ( string message, [ previousMethodName = null ) : void
message string
previousMethodName [
return void
Example #1
0
        private static void Init()
        {
            AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionHandler;
            TaskScheduler.UnobservedTaskException      += UnobservedTaskExceptionHandler;

            Directory.SetCurrentDirectory(ExecutableDirectory);

            // 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(ASFDirectory))
                    {
                        Directory.SetCurrentDirectory(ASFDirectory);
                        break;
                    }
                }

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

            if (!Directory.Exists(ConfigDirectory))
            {
                Logging.LogGenericError("Config directory could not be found!");
                Environment.Exit(1);
            }
        }
Example #2
0
        private void MainTab_Selected(object sender, TabControlEventArgs e)
        {
            if ((sender == null) || (e == null))
            {
                return;
            }

            if (e.TabPage == RemoveTab)
            {
                ConfigPage configPage = OldTab as ConfigPage;
                if (configPage == null)
                {
                    MainTab.SelectedIndex = -1;
                    return;
                }

                if (configPage == ASFTab)
                {
                    MainTab.SelectedTab = ASFTab;
                    Logging.LogGenericError("You can't remove global config!");
                    return;
                }

                MainTab.SelectedTab = configPage;

                if (DialogBox.YesNoBox("Removal", "Do you really want to remove this config?") != DialogResult.Yes)
                {
                    return;
                }

                MainTab.SelectedIndex = 0;
                configPage.ASFConfig.Remove();
                MainTab.TabPages.Remove(configPage);
            }
            else if (e.TabPage == RenameTab)
            {
                ConfigPage configPage = OldTab as ConfigPage;
                if (configPage == null)
                {
                    MainTab.SelectedIndex = -1;
                    return;
                }

                if (configPage == ASFTab)
                {
                    MainTab.SelectedTab = ASFTab;
                    Logging.LogGenericError("You can't rename global config!");
                    return;
                }

                MainTab.SelectedTab = configPage;

                string input;
                if (DialogBox.InputBox("Rename", "Your new bot name:", out input) != DialogResult.OK)
                {
                    return;
                }

                if (string.IsNullOrEmpty(input))
                {
                    Logging.LogGenericError("Your bot name is empty!");
                    return;
                }

                // Get rid of any potential whitespaces in bot name
                input = Regex.Replace(input, @"\s+", "");

                configPage.ASFConfig.Rename(input);
                configPage.RefreshText();
            }
            else if (e.TabPage == NewTab)
            {
                ConfigPage configPage = OldTab as ConfigPage;
                if (configPage == null)
                {
                    MainTab.SelectedIndex = -1;
                    return;
                }

                MainTab.SelectedTab = configPage;

                Tutorial.OnAction(Tutorial.EPhase.BotNickname);

                string input;
                if (DialogBox.InputBox("New", "Your new bot name:", out input) != DialogResult.OK)
                {
                    return;
                }

                if (string.IsNullOrEmpty(input))
                {
                    Logging.LogGenericError("Your bot name is empty!");
                    return;
                }

                // Get rid of any potential whitespaces in bot name
                input = Regex.Replace(input, @"\s+", "");

                if (ASFConfig.ASFConfigs.Select(config => Path.GetFileNameWithoutExtension(config.FilePath)).Any(fileNameWithoutExtension => (fileNameWithoutExtension == null) || fileNameWithoutExtension.Equals(input)))
                {
                    Logging.LogGenericError("Bot with such name exists already!");
                    return;
                }

                input = Path.Combine(Program.ConfigDirectory, input + ".json");

                ConfigPage newConfigPage = new ConfigPage(BotConfig.Load(input));
                MainTab.TabPages.Insert(MainTab.TabPages.Count - ReservedTabs, newConfigPage);
                MainTab.SelectedTab = newConfigPage;
                Tutorial.OnAction(Tutorial.EPhase.BotNicknameFinished);
            }
            else if (e.TabPage == ASFTab)
            {
                Tutorial.OnAction(Tutorial.EPhase.GlobalConfigOpened);
            }
        }