Beispiel #1
0
        public static async Task Main(string[] args)
        {
            if (!Directory.Exists(workdir))
            {
                try
                {
                    Directory.CreateDirectory(workdir);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex + " An error occurred creating the workdir:" + workdir);
                    return;
                }
            }

            if (!File.Exists(myConfig))
            {
                FirstRun.Helper();
            }
            else
            {
                Status.isFirstRun = false;
            }

            var host = CreateHostBuilder(args).Build();

            CreateDbIfNotExists(host);



            await host.RunAsync();
        }
    public SelectImportedGamesPage(FirstRun firstRun)
    {
        InitializeComponent();
        FirstRun = firstRun; // Set

        InitUI();            // Load the UI
    }
Beispiel #3
0
        public void should_log_error_while_fetching_delegate_method_B_by_id_from_registry()
        {
            DelegateRegistry <Func <int, int, double> > .TryGetValue(GuidHashCode(TestClass.GUID));

            if (_isFirstRun)
            {
                LogAssert.Expect(LogType.Error, new Regex("Cannot create delegate .*"));
            }
            FirstRun.Init();
        }
Beispiel #4
0
 public void WriteTo(Properties.Settings settings, ConfigReader reader)
 {
     settings.MessagePanelHeight = MessagePanelHeight;
     settings.FirstRun           = FirstRun.ToString();
     settings.DownloadsFolder    = DownloadsFolder;
     settings.HideToTray         = HideToSystemTray;
     settings.ShowPopups         = ShowPopups;
     settings.AudioAlerts        = AudioAlerts;
     settings.DownloadsFolder    = DownloadsFolder;
     reader.SetSetting(SettingKey.EnableStatusLogging, EnableStatusLogging);
     reader.SetSetting(SettingKey.CheckForUpdates, CheckForUpdates);
 }
Beispiel #5
0
        public void Start()
        {
            if (_started)
            {
                return;
            }
            _msn = new Msn(MsnGetters);

            #region First run
            if (Settings.Get <bool>(_names.FirstRun))
            {
                var firstRunModule = new FirstRun(delegate()
                {
                    var module = new OsuPathResolver();
                    if (AddModule(module))
                    {
                        StartModule(module);
                    }
                });
                AddModule(firstRunModule);
                StartModule(firstRunModule);
                if (!firstRunModule.CompletedSuccesfully)
                {
                    Program.SafeQuit();
                }
            }
            MsnGetters.Clear();
            #endregion

            var mapStringFormatter = new MapStringFormatter(new MainMapDataGetter(_mapDataFinders, _mapDataGetters, _mapDataParsers, _mapDataReplacementSetters, _saver, _logger));
            StartModule(mapStringFormatter);

            _logger.Log("Starting...", LogLevel.Advanced);
            _logger.Log(">Main classes...", LogLevel.Advanced);
            _sqliteControler = new SqliteControler(new SqliteConnector());

            _logger.Log(">Modules...", LogLevel.Advanced);
            StartModules();
            _logger.Log(">loaded {0} modules, where {1} are providing settings", LogLevel.Basic, _modules.Count.ToString(), SettingsList.Count.ToString());

            #region plugins
            //TODO: plugin loading
            #endregion plugins

            Settings.Add(_names.FirstRun.Name, false);
            _started = true;
            _logger.Log("Started!", LogLevel.Basic);
        }
Beispiel #6
0
        public void SaveConfig(Stream outputStream)
        {
            if (null == outputStream)
            {
                throw new ArgumentNullException(nameof(outputStream));
            }

            XmlWriterSettings settings = new XmlWriterSettings
            {
                Indent = true
            };

            using (XmlWriter writer = XmlWriter.Create(outputStream, settings))
            {
                writer.WriteStartElement("Mzinga.Viewer");

                writer.WriteAttributeString("version", AppVM.FullVersion);
                writer.WriteAttributeString("date", DateTime.UtcNow.ToString());

                writer.WriteElementString("EngineType", EngineType.ToString());
                writer.WriteElementString("EngineCommandLine", EngineCommandLine);
                writer.WriteElementString("HexOrientation", HexOrientation.ToString());
                writer.WriteElementString("NotationType", NotationType.ToString());
                writer.WriteElementString("PieceStyle", PieceStyle.ToString());
                writer.WriteElementString("PieceColors", PieceColors.ToString());
                writer.WriteElementString("DisablePiecesInHandWithNoMoves", DisablePiecesInHandWithNoMoves.ToString());
                writer.WriteElementString("DisablePiecesInPlayWithNoMoves", DisablePiecesInPlayWithNoMoves.ToString());
                writer.WriteElementString("HighlightTargetMove", HighlightTargetMove.ToString());
                writer.WriteElementString("HighlightValidMoves", HighlightValidMoves.ToString());
                writer.WriteElementString("HighlightLastMovePlayed", HighlightLastMovePlayed.ToString());
                writer.WriteElementString("BlockInvalidMoves", BlockInvalidMoves.ToString());
                writer.WriteElementString("RequireMoveConfirmation", RequireMoveConfirmation.ToString());
                writer.WriteElementString("AddPieceNumbers", AddPieceNumbers.ToString());
                writer.WriteElementString("StackPiecesInHand", StackPiecesInHand.ToString());
                writer.WriteElementString("PlaySoundEffects", PlaySoundEffects.ToString());
                writer.WriteElementString("ShowBoardHistory", ShowBoardHistory.ToString());
                writer.WriteElementString("ShowMoveCommentary", ShowMoveCommentary.ToString());
                writer.WriteElementString("FirstRun", FirstRun.ToString());
                writer.WriteElementString("CheckUpdateOnStart", CheckUpdateOnStart.ToString());

                InternalGameEngineConfig?.SaveGameAIConfig(writer, "InternalGameAI", ConfigSaveType.BasicOptions);

                writer.WriteEndElement();
            }
        }
        void ApplicationLaunched(object sender, EventArgs e)
        {
            if (Platform.Preferences.IsFirstRun)
            {
                Log.Info("Awareness launched for the first time.");
                FirstRun.Raise(this);
                Platform.Preferences.IsFirstRun = false;
            }
            else
            {
                Log.Info("Awareness launched.");
            }

            if (Platform.Preferences.PlayBowlOnStart)
            {
                BowlPlayer.Play(1);
            }
            BreakTimer.Start();
        }
Beispiel #8
0
        private void DisplayFirstRunIfApplicable()
        {
            CreateAppFolders();
            AppConfig.Initialise();

            if (AppConfig.Instance.IsFirstRun)
            {
                App.AppLogger.Logger.Log(devoctomy.DFramework.Logging.Interfaces.LoggerMessageType.Information,
                                         "Starting first run wizard.");

                AndroidSetSoftInputMode(true);
                FirstRun firstRun = new FirstRun();
                firstRun.Finish += FirstRun_Finish;
                MainPage         = firstRun;
            }
            else
            {
                App.AppLogger.Logger.Log(devoctomy.DFramework.Logging.Interfaces.LoggerMessageType.Information,
                                         "Initialising clipboard obfuscator (it isn't started at this point).");

                _appController = new AppController <BurgerMenuHostPage>(this,
                                                                        SetupMainPage);
                try
                {
                    App.AppLogger.Logger.Log(devoctomy.DFramework.Logging.Interfaces.LoggerMessageType.Information, "cachy App:PerformStartup");

                    CloudStorageSyncManager.Initialise(
                        App.AppLogger.Logger,
                        GetProviderValue,
                        GetCredential);
                    Start();

                    _performedStartup = true;
                }
                catch (UnauthorizedAccessException) //uaex)
                {
                    //we don't have storage permission
                    throw;
                }
            }
        }
        private void LoadSettings()
        {
            if (Settings.Default.FirstRun == true)
            {
                FirstRun frun = new FirstRun();
                frun.Show();
            }

            if (File.Exists(Settings.Default.PlaylistLocation))
                CurrentPlaylistLocation = Settings.Default.PlaylistLocation;
            else
                CurrentPlaylistLocation = settings.appdata_folder + "\\Tejash-Player-Playlist.tpp";

            if (Settings.Default.RememberVolume == true)
            {
                PlayerEngine.volume = Settings.Default.Volume;
                volSlider.Value = (int)PlayerEngine.volume;
                checkBox3.CheckState = CheckState.Checked;
            }
            else
                checkBox3.CheckState = CheckState.Unchecked;

            if (Settings.Default.LPFM == true)
            {
                checkBox4.Checked = true;
                use_lastfm = true;
            }
            else
            {
                checkBox4.Checked = false;
                use_lastfm = false;
            }

            if (Settings.Default.sounds == true)
            {
                notify_sounds = true;
                checkBox5.Checked = true;
            }
            else
            {
                notify_sounds = false;
                checkBox5.Checked = false;
            }
        }
 public SearchRAWGPage(FirstRun firstRun)
 {
     InitializeComponent();
     FirstRun = firstRun;         // Define
 }
        public void Start()
        {
            if (_started)
            {
                return;
            }
            _msn = new Msn(MsnGetters);

            #region First run

            bool shouldForceFirstRun = false;
            var  lastVersionStr      = Settings.Get <string>(_names.LastRunVersion);
            if (lastVersionStr == _names.LastRunVersion.Default <string>())
            {
                shouldForceFirstRun = true;
            }
            else
            {
                try
                {
                    var lastVersion      = Helpers.Helpers.GetDateFromVersionString(lastVersionStr);
                    var versionToResetOn = Helpers.Helpers.GetDateFromVersionString("v161030.20");
                    shouldForceFirstRun = lastVersion < versionToResetOn;
                }
                catch (Exception e)
                {
                    if (e is FormatException || e is ArgumentNullException)
                    {
                        shouldForceFirstRun = true;
                    }
                    else
                    {
                        throw;
                    }
                }
            }

            if (Settings.Get <bool>(_names.FirstRun) || shouldForceFirstRun)
            {
                var firstRunModule = new FirstRun(delegate()
                {
                    var module = new OsuPathResolver();
                    if (AddModule(module))
                    {
                        StartModule(module);
                    }
                });
                AddModule(firstRunModule);
                StartModule(firstRunModule);
                if (!firstRunModule.CompletedSuccesfully)
                {
                    Program.SafeQuit();
                }
            }
            MsnGetters.Clear();
            #endregion

            var mapStringFormatter = new MapStringFormatter(new MainMapDataGetter(_mapDataFinders, _mapDataGetters, _mapDataParsers, _mapDataReplacementSetters, _saver, _logger, Settings));
            AddModule(mapStringFormatter);

            _logger.Log("Starting...", LogLevel.Advanced);
            _logger.Log(">Main classes...", LogLevel.Advanced);
            _sqliteControler = new SqliteControler(new SqliteConnector());

            _logger.Log(">Modules...", LogLevel.Advanced);
            StartModules();
            _logger.Log(">loaded {0} modules, where {1} are providing settings", LogLevel.Basic, _modules.Count.ToString(), SettingsList.Count.ToString());

            #region plugins
            //TODO: plugin loading
            #endregion plugins

            Settings.Add(_names.FirstRun.Name, false);
            Settings.Add(_names.LastRunVersion.Name, Program.ScVersion);
            _started = true;
            _logger.Log("Started!", LogLevel.Basic);
        }
        private void OnFirstRun(FirstRun @event)
        {
            var toast = Toasts.FirstRun();

            toastNotifier.Show(toast);
        }
 public AddGamesPage(FirstRun firstRun)
 {
     InitializeComponent();
     FirstRun = firstRun;         // Define
 }
Beispiel #14
0
    public void ApplyLocalization(int language)
    {
        if (SceneManager.GetActiveScene().name == "Start")
        {
            OptionLoc(language);
            FirstRun firstRun = changeScene.startManager;

            if (language == 0)
            {
                if (PlayerPrefs.GetInt("startgame") == 0)
                {
                    firstRun.start.GetComponentInChildren <Text>().text = "New Game";
                }
                else
                {
                    firstRun.start.GetComponentInChildren <Text>().text = "Continue";
                }


                firstRun.options.GetComponentInChildren <Text>().text = "Options";
                firstRun.random.GetComponentInChildren <Text>().text  = "Random";
            }
            else if (language == 1)
            {
                if (PlayerPrefs.GetInt("startgame") == 0)
                {
                    firstRun.start.GetComponentInChildren <Text>().text = "Новая Игра";
                }
                else
                {
                    firstRun.start.GetComponentInChildren <Text>().text = "Продолжить";
                }

                firstRun.options.GetComponentInChildren <Text>().text = "Настройки";
                firstRun.random.GetComponentInChildren <Text>().text  = "Случайная Игра";
            }
            else if (language == 2)
            {
                if (PlayerPrefs.GetInt("startgame") == 0)
                {
                    firstRun.start.GetComponentInChildren <Text>().text = "Нова Гра";
                }
                else
                {
                    firstRun.start.GetComponentInChildren <Text>().text = "Продовжити";
                }

                firstRun.options.GetComponentInChildren <Text>().text = "Налаштування";
                firstRun.random.GetComponentInChildren <Text>().text  = "Випадкова Гра";
            }
        }
        else
        if (SceneManager.GetActiveScene().name == "Field")
        {
            OptionLoc(language);
            FieldSceneManager fieldManager = changeScene.fieldSceneManager;

            if (language == 0)
            {
            }
            else if (language == 1)
            {
            }
            else if (language == 2)
            {
            }
        }
        else
        if (SceneManager.GetActiveScene().name == "ProgressMap")
        {
            OptionLoc(language);
            ProgressMapManager progressMap = changeScene.mapManager;

            if (language == 0)
            {
            }
            else if (language == 1)
            {
            }
            else if (language == 2)
            {
            }
        }
    }
Beispiel #15
0
        public static void Save()
        {
            XmlWriterSettings settings = new XmlWriterSettings();

            settings.Indent              = true;
            settings.NewLineChars        = Environment.NewLine;
            settings.NewLineOnAttributes = true;
            using (XmlWriter writer = XmlWriter.Create("Data.dat", settings))
            {
                writer.WriteStartDocument();
                writer.WriteStartElement("Data");

                writer.WriteAttributeString("FirstRun", FirstRun.ToString());
                writer.WriteAttributeString("MacAddress", GetMacAddress());
                writer.WriteAttributeString("CommitteeName", CommitteeName);
                writer.WriteAttributeString("GSLAgenda", GSLAgenda);
                writer.WriteAttributeString("SSLAgenda", SSLAgenda);
                writer.WriteAttributeString("RollCallDone", RollCallDone.ToString());
                writer.WriteAttributeString("ExtraData", ExtraData);

                foreach (Country country in Countries)
                {
                    writer.WriteStartElement("Country");

                    writer.WriteAttributeString("Name", country.Name);
                    writer.WriteAttributeString("Flag", country.Flag);
                    writer.WriteAttributeString("Attendance", country.Attendance.ToString());
                    writer.WriteAttributeString("GSL", country.GSL.ToString());
                    writer.WriteAttributeString("SSL", country.SSL.ToString());

                    writer.WriteEndElement();
                }

                writer.WriteStartElement("Topics");

                foreach (Country country in Countries)
                {
                    foreach (Topic topic in country.MC)
                    {
                        writer.WriteStartElement("Topic");

                        writer.WriteAttributeString("Heading", topic.Heading);
                        writer.WriteAttributeString("Passed", topic.Passed.ToString());
                        //TODO report / log this incident
                        if (topic.ProposedBy != country)
                        {
                            throw new InvalidDataException("The proposed country is not the same as the parent country. This incident must be reported.");
                        }
                        writer.WriteAttributeString("ProposedBy", topic.ProposedBy.Name);

                        writer.WriteStartElement("SpeakingCountries");

                        foreach (Country speaker in topic.SpeakingCountries)
                        {
                            writer.WriteElementString("Country", speaker.Name);
                        }

                        writer.WriteEndElement();

                        writer.WriteEndElement();
                    }
                }

                writer.WriteEndElement();

                writer.WriteEndElement();
                writer.WriteEndDocument();
                writer.Close();
            }
        }
Beispiel #16
0
        // LINQPad script entry point
        // when deployed as an Azure Function this method is not used
        public static async Task <int> MainAsync(object userQuery, string[] args)
        {
            var hasConsoleInput = false;

            if ("LPRun.exe".Equals(Process.GetCurrentProcess().MainModule.ModuleName, StringComparison.OrdinalIgnoreCase))
            {
                hasConsoleInput = Environment.UserInteractive;

                // pipe trace to console
                Trace.Listeners.Add(new ConsoleTraceListener());
            }

            if (userQuery == null)
            {
                throw new ArgumentNullException("User query cannot be null. You should pass 'this' here.", nameof(userQuery));
            }
            var userQueryTypeInfo = new UserQueryTypeInfo(userQuery);

            var currentQuery = Util.CurrentQuery;

            if (currentQuery == null)
            {
                throw new InvalidOperationException("This script must be run from wthin a LINQPad context (either via LINQPad or LPRun).");
            }
            var currentQueryInfo = new QueryInfo(currentQuery);

            var currentQueryPath = Util.CurrentQueryPath;

            if (currentQueryPath == null)
            {
                throw new InvalidOperationException("A file name is required (save your LINQPad query to disk). Without it, we cannot establish a context for your functions.");
            }
            var currentQueryPathInfo = new QueryPathInfo(currentQueryPath);

            // ========

            args = args ?? new string[0]; // note: `args` can be null
            if (args.Length == 0)
            {
                if (FirstRun.ShouldPrompt())
                {
                    FirstRun.Prompt();
                }

                // ================================

                var workingDirectory = Path.Combine(Env.GetLocalAppDataDirectory(), currentQueryPathInfo.InstanceId);
                Debug.WriteLine($"workingDirectory: {workingDirectory}");
                FunctionApp.Deploy(workingDirectory);

                // ================================

                Compiler.Compile(new UserQueryTypeInfo(userQuery), currentQueryInfo, new CompilationOptions(currentQueryPath)
                {
                    OutDir = workingDirectory,
                }, currentQueryInfo);

                // ================================

                StorageEmulator.StartOrInstall();

                // todo: if AzureWebJobsStorage or AzureWebJobsDashboard is set elsewhere, like app.config we shouldn't override them like this

                if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("AzureWebJobsStorage")))
                {
                    Environment.SetEnvironmentVariable("AzureWebJobsStorage", "UseDevelopmentStorage=true");
                }

                if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("AzureWebJobsDashboard")))
                {
                    Environment.SetEnvironmentVariable("AzureWebJobsDashboard", "UseDevelopmentStorage=true");
                }

                // ================================

                var lastWriteTime = File.GetLastWriteTimeUtc(currentQueryPathInfo.QueryPath);

                using (var fs = new FileSystemWatcher(currentQueryPathInfo.QueryDirectoryName, currentQueryPathInfo.QueryFileName))
                {
                    var stream = new BlockingCollection <int>();

                    ThreadPool.QueueUserWorkItem(_ =>
                    {
                        foreach (var x in stream.GetConsumingEnumerable())
                        {
                            Thread.Sleep(250); // hold, for just a moment...

                            var lastWriteTime2 = File.GetLastWriteTimeUtc(currentQueryPathInfo.QueryPath);
                            if (lastWriteTime < lastWriteTime2)
                            {
                                Debug.WriteLine("Recompiling...");

                                Util.RunAndWait(currentQueryPathInfo.QueryPath, new[] { "-compile", "-out-dir", workingDirectory });

                                Debug.WriteLine("Recompiled!");

                                lastWriteTime = lastWriteTime2;
                            }
                        }
                    });

                    fs.Changed += (sender, e) => stream.Add(0);

                    fs.EnableRaisingEvents = true;

                    await JobHost.LaunchAsync(workingDirectory);

                    stream.CompleteAdding();
                }

                // ================================

                return(0);
            }
            else
            {
                try
                {
                    var options = CommandLine.Parse(args, new Options {
                    });
                    if (options.compile)
                    {
                        var compilationOptions = new CompilationOptions(currentQueryPath);
                        compilationOptions.OutDir = options.out_dir == null?Path.Combine(compilationOptions.QueryDirectoryName, compilationOptions.QueryName + "_" + userQueryTypeInfo.Id) : Path.GetFullPath(options.out_dir);

                        Compiler.Compile(userQueryTypeInfo, currentQueryInfo, compilationOptions, currentQueryInfo);
                        Trace.WriteLine($"Done. Output written to '{compilationOptions.OutDir}'");
                        return(0);
                    }
                    else if (options.publish)
                    {
                        var compilationOptions = new CompilationOptions(currentQueryPath);
                        compilationOptions.OutDir = Path.Combine(compilationOptions.QueryDirectoryName, compilationOptions.QueryName + "_" + userQueryTypeInfo.Id + "_" + Environment.TickCount);
                        try
                        {
                            Compiler.Compile(userQueryTypeInfo, currentQueryInfo, compilationOptions, currentQueryInfo);

                            var publishSettingsFileNames = FileUtil.ResolveSearchPatternUpDirectoryTree(compilationOptions.QueryDirectoryName, "*.PublishSettings").ToList();
                            if (1 != publishSettingsFileNames.Count)
                            {
                                if (1 < publishSettingsFileNames.Count)
                                {
                                    throw new InvalidOperationException($"Aborted. Found two or more '*.PublishSettings' files. " + string.Join(", ", publishSettingsFileNames));
                                }
                                else
                                {
                                    throw new InvalidOperationException($"Aborted. Cannot find a '*.PublishSettings' file in '{compilationOptions.QueryDirectoryName}' or any of it's parents");
                                }
                            }

                            var kudu = KuduClient.FromPublishProfile(publishSettingsFileNames[0]);

                            var appSettings = kudu.GetSettings();
                            if (appSettings.TryGetValue("WEBSITE_SITE_NAME", out var siteName) && appSettings.TryGetValue("WEBSITE_SLOT_NAME", out var slotName))
                            {
                                Trace.WriteLine($"Publishing to '{siteName}' ({slotName})...");
                            }
                            else
                            {
                                Trace.WriteLine($"Site '{kudu.Host}' metadata is missing");
                            }

                            // this setting needs to be changed using the az command line
                            // https://docs.microsoft.com/en-us/azure/azure-functions/set-runtime-version#view-and-update-the-runtime-version-using-azure-cli
                            // using the Kudu settings API doesn't update the application app settings

                            if (appSettings.TryGetValue("FUNCTIONS_EXTENSION_VERSION", out var functionsExtensionVersion))
                            {
                                if (functionsExtensionVersion != "~1")
                                {
                                    var text    = "The Azure Functions runtime version 1.x is required. Would you like to change the FUNCTIONS_EXTENSION_VERSION setting to ~1?";
                                    var caption = "Azure Functions Runtime";

                                    if (MessageBox.ShowYesNoQuestion(text, caption))
                                    {
                                        var result = await Az.RunAsunc("functionapp", "list", "--query", $"[?name=='{siteName}']");

                                        if (result.Output.Count() != 1)
                                        {
                                            throw new InvalidOperationException($"Aborted. Cannot find Azure Function App '{siteName}'");
                                        }

                                        var functionApp = result.Output[0];

                                        var g = (string)functionApp["resourceGroup"];

                                        var result2 = await Az.RunAsunc("functionapp", "config", "appsettings", "set", "-g", g, "-n", siteName, "--settings", "FUNCTIONS_EXTENSION_VERSION=~1");

                                        if (result2.ExitCode != 0)
                                        {
                                            throw new InvalidOperationException($"Aborted. Cannot configure Azure Function App '{siteName}'");
                                        }
                                    }
                                    else
                                    {
                                        throw new InvalidOperationException("Aborted. Azure Functions runtime version 1.x is required");
                                    }
                                }
                            }

                            // need to check for cloud pad function app runtime
                            // if not found, offer to deploy it

                            if (!kudu.VfsExists("site/wwwroot/bin/CloudPad.FunctionApp.dll"))
                            {
                                if (hasConsoleInput)
                                {
                                    var text    = "It looks like the CloudPad.FunctionApp (runtime) has not been deployed yet. Would you like to deploy this now (you only do this once per Azure Function App)?";
                                    var caption = "Deployment";

                                    if (MessageBox.ShowYesNoQuestion(text, caption))
                                    {
                                        Trace.WriteLine($"Deploying runtime... (this will just take a minute)");
                                        kudu.ZipDeployPackage(FunctionApp.PackageUri);
                                    }
                                }
                                else
                                {
                                    Trace.WriteLine($"Oh no. You have to deploy the CloudPad.FunctionApp runtime first");
                                    return(1);
                                }
                            }

                            Trace.WriteLine($"Deploying script '{currentQueryPathInfo.QueryFileNameWithoutExtension}' ({userQueryTypeInfo.AssemblyName})...");

                            kudu.ZipUpload(compilationOptions.OutDir);
                        }
                        finally
                        {
                            if (Directory.Exists(compilationOptions.OutDir))
                            {
                                Directory.Delete(compilationOptions.OutDir, true);
                            }
                        }
                        Trace.WriteLine("Done.");
                        if (options.interactive)
                        {
                            if (hasConsoleInput)
                            {
                                Console.WriteLine("Press any key to continue...");
                                Console.ReadKey();
                            }
                        }
                        return(0);
                    }
                    else if (options.pack)
                    {
                        var compilationOptions = new CompilationOptions(currentQueryPath);
                        compilationOptions.OutDir = options.out_dir == null?Path.Combine(compilationOptions.QueryDirectoryName, compilationOptions.QueryName + "_publish") : Path.GetFullPath(options.out_dir);

                        FunctionApp.Deploy(compilationOptions.OutDir);
                        Compiler.Compile(userQueryTypeInfo, currentQueryInfo, compilationOptions, currentQueryInfo);
                        Trace.WriteLine($"Done. Output written to '{compilationOptions.OutDir}'");
                        return(0);
                    }
                    else if (options.install)
                    {
                        FirstRun.Install();
                        return(0);
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    Console.WriteLine(ex.StackTrace);

                    if (hasConsoleInput)
                    {
                        Console.WriteLine("Press any key to continue...");
                        Console.ReadKey();
                    }

                    throw;
                }
                return(1);
            }
        }
        public void Start()
        {
            if (_started)
            {
                return;
            }

            #region First run

            bool shouldForceFirstRun = false;
            var  lastVersionStr      = Settings.Get <string>(_names.LastRunVersion);
            if (lastVersionStr == _names.LastRunVersion.Default <string>())
            {
                shouldForceFirstRun = true;
            }
            else
            {
                try
                {
                    var lastVersion      = Helpers.Helpers.GetDateFromVersionString(lastVersionStr);
                    var versionToResetOn = Helpers.Helpers.GetDateFromVersionString("v180209.13");
                    shouldForceFirstRun = lastVersion < versionToResetOn;
                }
                catch (Exception e)
                {
                    if (e is FormatException || e is ArgumentNullException)
                    {
                        shouldForceFirstRun = true;
                    }
                    else
                    {
                        throw;
                    }
                }
            }

            _logger.Log("Preloading plugins", LogLevel.Advanced);

            var plugins = GetPlugins();


            if (Settings.Get <bool>(_names.FirstRun) || shouldForceFirstRun)
            {
                var firstRunControls = new List <FirstRunUserControl>();

                var firstRunControlProviders =
                    plugins.Where(p => p.GetType().GetInterfaces().Contains(typeof(IFirstRunControlProvider))).ToList();


                foreach (var plugin in firstRunControlProviders)
                {
                    LoadPlugin(plugin);
                    firstRunControls.AddRange(((IFirstRunControlProvider)plugin).GetFirstRunUserControls());
                }
                _logger.Log(">Early loaded {0} plugins for firstRun setup", LogLevel.Advanced, firstRunControlProviders.Count.ToString());

                var firstRunModule = new FirstRun(firstRunControls);

                AddModule(firstRunModule);
                StartModule(firstRunModule);
                if (!firstRunModule.CompletedSuccesfully)
                {
                    Program.SafeQuit();
                }
            }
            MsnGetters.Clear();
            #endregion



            _logger.Log("Starting...", LogLevel.Advanced);
            _logger.Log(">Main classes...", LogLevel.Advanced);
            _sqliteControler = new SqliteControler(new SqliteConnector(_logger));

            _logger.Log(">Modules...", LogLevel.Advanced);
            StartModules();
            _logger.Log(">loaded {0} modules, where {1} are providing settings", LogLevel.Basic, _modules.Count.ToString(), SettingsList.Count.ToString());

            #region plugins
            _logger.Log("Initalizing {0} plugins", LogLevel.Advanced, plugins.Count.ToString());

            _logger.Log("==========", LogLevel.Advanced);

            foreach (var plugin in plugins)
            {
                LoadPlugin(plugin);
            }
            _logger.Log("==========", LogLevel.Advanced);

            ProritizePluginsUsage();
            #endregion plugins

            Settings.Add(_names.FirstRun.Name, false);
            Settings.Add(_names.LastRunVersion.Name, Program.ScVersion);

            var mapStringFormatter = new MapStringFormatter(
                new MainMapDataGetter(_mapDataFinders, _mapDataGetters, _mapDataParsers, _mapDataReplacementSetters, _saver, _logger, Settings),
                _osuEventSources);

            AddModule(mapStringFormatter);
            StartModule(mapStringFormatter);

            _started = true;
            _logger.Log("Started!", LogLevel.Basic);
        }
 public FinishPage(FirstRun firstRun)
 {
     InitializeComponent();
     FirstRun = firstRun;         // Define
 }
Beispiel #19
0
        public void UpdateNextRun()
        {
            var now = DateTime.UtcNow;

            // If required first run is in the future, do nothing
            if (FirstRun > now)
            {
                return;
            }

            Array.Sort(Values);

            switch (Periodicity)
            {
            case Periodicity.Yearly:
            {
                int yearToRun = LastRun.Year < now.Year ? now.Year : now.Year + 1;
                int yearToAdd = yearToRun - FirstRun.Year;
                NextRun = FirstRun.AddYears(yearToAdd);
            }
            break;

            case Periodicity.Monthly:
            {
                int monthToRun = -1;
                int monthToAdd = -1;

                try
                {
                    monthToRun = Values.First(month => month > now.Month);
                    monthToAdd = monthToRun - now.Month;
                }
                catch
                {
                    try
                    {
                        monthToRun = Values.Reverse().First(month => month < now.Month);
                        monthToAdd = monthToRun + 12 - now.Month;
                    }
                    catch { }
                }

                if (monthToRun > 0)
                {
                    NextRun = (new DateTime(now.Year, now.Month, 1)).AddMonths(monthToAdd);
                    NextRun = new DateTime(NextRun.Year, NextRun.Month, Math.Min(FirstRun.Day, DateTime.DaysInMonth(NextRun.Year, NextRun.Month)), FirstRun.Hour, FirstRun.Minute, FirstRun.Second, FirstRun.Millisecond);
                }
            }
            break;

            case Periodicity.Weekly:
            {
                var start = new DateTime(now.Year, now.Month, 1, FirstRun.Hour, FirstRun.Minute, FirstRun.Second, FirstRun.Millisecond);

                var      dayOfWeek = FirstRun.DayOfWeek;
                DateTime found     = FirstDateFromDayOfWeek(dayOfWeek, start);

                foreach (int week in Values)
                {
                    var maybe = found.AddDays((week - 1) * 7);
                    if (maybe > now)
                    {
                        if (maybe.Month > now.Month)
                        {
                            NextRun = FirstDateFromDayOfWeek(dayOfWeek, start.AddMonths(1)).AddDays((Values[0] - 1) * 7);
                        }
                        else
                        {
                            NextRun = maybe;
                        }
                        break;
                    }
                }
            }
            break;

            case Periodicity.Daily:
            {
                NextRun = new DateTime(
                    Math.Max(now.Year, FirstRun.Year),
                    Math.Max(now.Month, FirstRun.Month),
                    Math.Max(now.Day, FirstRun.Day),
                    FirstRun.Hour,
                    FirstRun.Minute,
                    FirstRun.Second,
                    FirstRun.Millisecond);

                if (NextRun < now)
                {
                    NextRun = NextRun.AddDays(1);
                }
            }
            break;

            case Periodicity.Hourly:
            {
                NextRun = new DateTime(
                    Math.Max(now.Year, FirstRun.Year),
                    Math.Max(now.Month, FirstRun.Month),
                    Math.Max(now.Day, FirstRun.Day),
                    Math.Max(now.Hour, FirstRun.Hour),
                    FirstRun.Minute,
                    FirstRun.Second,
                    FirstRun.Millisecond);

                if (NextRun < now)
                {
                    NextRun = NextRun.AddHours(1);
                }
            }
            break;

            default:     // if no periodicity
            {
                NextRun = DateTime.MaxValue;
                Enabled = false;
            }
            break;
            }
        }
Beispiel #20
0
 public Welcome(FirstRun firstRun)
 {
     InitializeComponent();
     FirstRun = firstRun;         // Define
 }