Example #1
0
        /// <summary>
        ///     Computes all players in the NHL and populates the ranking grid
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void ComputeAll_Click(object sender, EventArgs e)
        {
            _dt.Rows.Clear();

            foreach (var team in SelectionResources.TeamList)
            {
                foreach (var person in team.PersonList)
                {
                    var player = new Player(ApiLoader.LoadPlayer(DateTime.Now.Year, person.Id), person);
                    SeasonCalculator.CalculateExpectedSeason(player);

                    if (player.HasSufficientInfo)
                    {
                        AddPlayerToDt(player);
                    }
                }
            }

            BindGrid();

            //Making the computeAll button invisible
            computeAllButton.Visible = false;

            //Making the export button visible
            exportButton.Visible = true;
        }
        /// <summary>
        /// Function to renew HTTPS certification.
        /// </summary>
        /// <param name="manipulator"><see cref="MySqlDataManipulator"/> used to add the company to the database</param>
        /// <remarks>As this is a command to be used by the developers on the project, error output is minimal</remarks>
        public override void PerformFunction(MySqlDataManipulator manipulator)
        {
            var server = ApiLoader.LoadApiAndListen(16384);

            Console.WriteLine("Attempting to retrieve new certificate");
            CertificateRenewer.GetFirstCert(false);
        }
Example #3
0
        /// <summary>
        ///     Calls the needed methods to calculate and print the player's expected season in the result textbox
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void ComputePlayer(object sender, EventArgs e)
        {
            if (playersSelect.SelectedItem == null)
            {
                return;
            }

            SelectionResources.PlayerIndex = playersSelect.SelectedIndex;
            computeButton.Enabled          = false;
            var person = SelectionResources.PersonList[playersSelect.SelectedIndex];

            //Check if the player hasn't already been loaded (avoiding to call the api again)
            if (!SelectionResources.PlayersMemory.Any(p =>
                                                      p.Id.Equals(SelectionResources.PersonList[playersSelect.SelectedIndex].Id)))
            {
                //Fetching the player through the player loader
                var player = new Player(ApiLoader.LoadPlayer(DateTime.Now.Year, person.Id), person);
                SeasonCalculator.CalculateExpectedSeason(player);

                //Adding player to the already calculated players if he has sufficient info
                if (player.HasSufficientInfo)
                {
                    SelectionResources.PlayersMemory.Add(player);
                }

                //Printing the player's expected season to the result textbox
                result.Text = player.ToString();
            }
            else
            {
                result.Text = SelectionResources.PlayersMemory.First(p => p.Id.Equals(person.Id)).ToString();
            }
        }
Example #4
0
        public MapFactory(IJSRuntime jsRuntime)
        {
            _api = new ApiLoader(jsRuntime);

            _moduleTask = new(() => jsRuntime.InvokeAsync <IJSInProcessObjectReference>(
                                  "import",
                                  "./_content/Proxoft.Maps.OpenStreetMap.Maps/maps_v1.js").AsTask());
        }
Example #5
0
        public MapFactory(GoogleApiConfiguration configuration, IJSRuntime jsRuntime)
        {
            _api           = new ApiLoader(jsRuntime);
            _configuration = configuration;

            _moduleTask = new(() => jsRuntime.InvokeAsync <IJSInProcessObjectReference>(
                                  "import",
                                  "./_content/Proxoft.Maps.Google.Maps/maps.js").AsTask());
        }
 public void TestTeamNumber()
 {
     Assert.AreEqual(ApiLoader.LoadTeams().Count, NB_TEAMS);
 }
 public void TestLoadPlayer()
 {
     Assert.AreEqual(NB_SEASONS, ApiLoader.LoadPlayer(2019, ovechkinId).SeasonList.Count);
 }
Example #8
0
        static void Main(string[] args)
        {
            Console.WriteLine(DateTime.Now.ToLocalTime().ToString());
            DatabaseConfigurationFileContents config;

            try
            {
                config = RetrieveConfiguration();
            } catch (ThreadInterruptedException)
            {
                return;
            }
            if (config == null)
            {
                Console.WriteLine("Failed to retrieve or restore database configuration file. Exiting");
                return;
            }
            bool res = MySqlDataManipulator.GlobalConfiguration.Connect(new MySqlConnectionString(config.Host, config.Database, config.User).ConstructConnectionString(config.Pass.ConvertToString()));

            if (!res && MySqlDataManipulator.GlobalConfiguration.LastException.Number != 1049 && MySqlDataManipulator.GlobalConfiguration.LastException.Number != 0)
            {
                Console.WriteLine("Encountered an error opening the global configuration connection");
                Console.WriteLine(MySqlDataManipulator.GlobalConfiguration.LastException.Message);
                return;
            }
            if (!MySqlDataManipulator.GlobalConfiguration.ValidateDatabaseIntegrity(new MySqlConnectionString(config.Host, null, config.User).ConstructConnectionString(config.Pass.ConvertToString()), config.Database))
            {
                Console.WriteLine("Encountered an error opening the global configuration connection");
                Console.WriteLine(MySqlDataManipulator.GlobalConfiguration.LastException.Message);
                return;
            }
            MySqlDataManipulator.GlobalConfiguration.Close();
            CommandLineArgumentParser parser = new CommandLineArgumentParser(args);

            MySqlDataManipulator.GlobalConfiguration.Connect(new MySqlConnectionString(config.Host, config.Database, config.User).ConstructConnectionString(config.Pass.ConvertToString()));
            config.Pass.Dispose();
            config = null;
            bool exit = DatabaseEntityCreationUtilities.PerformRequestedCreation(MySqlDataManipulator.GlobalConfiguration, parser);

            MySqlDataManipulator.GlobalConfiguration.Close();
            if (exit)
            {
                return;
            }
            if (!GlobalModelHelper.LoadOrTrainGlobalModels(ReflectionHelper.GetAllKeywordPredictors()))
            {
                throw new NullReferenceException("One or more global models failed to load. Server cannot start.");
            }
            else if (AveragedPerceptronTagger.GetTagger() == null)
            {
                throw new NullReferenceException("Failed to load the Averaged Perceptron Tagger");
            }
            Logger.GetLogger(Logger.LoggerDefaultFileLocations.DEFAULT).Log(Logger.LogLevel.INFO, "Server is starting up");
            using (Logger.Disposer)
            {
                Thread t = new Thread(RenewCertificate);
                t.Start();
                Thread train = new Thread(PerformTraining);
                train.Start();
                var server = ApiLoader.LoadApiAndListen(16384);
                while (server.IsAlive)
                {
                    Thread.Sleep(100);
                    if (Console.KeyAvailable)
                    {
                        ConsoleKeyInfo key = Console.ReadKey(true);
                        if (key.Key == ConsoleKey.Enter)
                        {
                            server.Close();
                        }
                    }
                }
                t.Interrupt();
                train.Interrupt();
            }
            //QueryProcessor processor = new QueryProcessor(QueryProcessorSettings.GenerateDefaultSettings());
            //processor.ProcessQuery(new Util.MechanicQuery("autocar", "xpeditor", null, null, "runs rough"));
        }