public Form_Main(HDCDbContext _hDCDbContext
                         , Ticker _theTicker
                         , BackendLogic _dayCareBackEndAccess)
        {
            InitializeComponent();
            theArgs                       = new TickerArgs();
            hDCDbContext                  = _hDCDbContext;
            theTicker                     = _theTicker;
            dayCareBackEndAccess          = _dayCareBackEndAccess;
            this.label1.Text              = "";
            this.label2.Text              = "";
            this.SimulationFinishedEvent += button_Show_EndReport_VisibleChanged;

            this.mainReportTypes = $"INFO TYPE\n\n" +
                                   $"Simulation ID:\n\n" +
                                   $"Simulation started at:\n" +
                                   $"Simulation time now:\n" +
                                   $"Tick number now:\n\n" +
                                   $"Number of Hamdters in Cleintele this simulation:\n" +
                                   $"Capacity of daycare:\n" +
                                   $"The Hamster gender distribution is:\n\n" +
                                   $"AVG Wait for first Exersice:\n" +
                                   $"Number of Cages:\n" +
                                   $"Capacity of each Cage:\n\n" +
                                   $"Number of Exersice Areas:\n" +
                                   $"Capacity of each Exersice Area:\n";

            this.MainReport_Test_Types.Text = "Main Report Window";
        }
Exemple #2
0
        /// <summary>
        /// Methode used to resed db in order to reseed it with different DB model
        /// </summary>
        /// <returns></returns>
        private Task ResetDb()
        {
            // Selecting all entities that needs to be removed in order to reed seed db (not logs)
            //var hamsters = hDCDbContext.Hamsters;

            //var cages = hDCDbContext.Cages;

            //var exAreas = hDCDbContext.ExerciseAreas;

            ////Removes selected entities
            //if (hamsters != null)
            //{
            //    hDCDbContext.Hamsters.RemoveRange(hamsters);
            //}
            //if (cages != null)
            //{
            //    hDCDbContext.Cages.RemoveRange(cages);
            //}
            //if (exAreas != null)
            //{
            //    hDCDbContext.ExerciseAreas.RemoveRange(exAreas);
            //}
            hDCDbContext.Database.EnsureDeleted();

            // Saves changes
            hDCDbContext.SaveChanges();

            hDCDbContext = new HDCDbContext();

            hDCDbContext.Database.EnsureCreated();

            return(Task.CompletedTask);
        }
        static void Main()
        {
            Application.SetHighDpiMode(HighDpiMode.SystemAware);
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            // creates a new custom EF dbConteqt
            hDCDbContext = new HDCDbContext();
            // if there are no db in system one will be created in SQLEXPERSS
            hDCDbContext.Database.EnsureCreated();

            // theArgs are the info engine in the backend, it is an info carrier
            // supplies info to various parts ot thr program and is ofthen updated
            theArgs = new TickerArgs();

            // Is the same idea as theArgs but in the UI part of the program
            // carries info to different parts of UI, used to construct info Raports
            ReportArgs = new ReportArgs();

            // is the more literal engine, drives the program ittration and drives the simulation
            theTicker = new Ticker();
            // Ticker has tick event wich starts each iterration of the simulatin
            theTicker.tick += StartSimulation;

            // BackendLogic id the go between UI and backend, here are pretty much
            // all the methodes used to gather data from backend
            dayCareBackEndAccessAccess = new BackendLogic(hDCDbContext, theArgs, ReportArgs);

            // sets theArgs form last saves settings
            SetArgsFromSettingsFile();

            // if Hamsters are empty
            if (hDCDbContext.Hamsters.Count() == 0)
            {
                dayCareBackEndAccessAccess.SeedDB(theArgs);
            }

            // creates Main window form
            Main_Form = new Form_Main(hDCDbContext, theTicker, dayCareBackEndAccessAccess);

            // Creates separate UIthred to handle all of the forms logic
            Thread UIThread = new Thread(StartForm);

            UIThread.Start();

            // creates a loop to keep alive main thread untill simulation strts
            SimulationAwaiter(theTicker);
        }
Exemple #4
0
 public BackendLogic(HDCDbContext _hDCDbContext, TickerArgs _theArgs, ReportArgs _ReportArgs)
 {
     hDCDbContext = _hDCDbContext;
     //theArgs = _theArgs;
     ReportArgs = _ReportArgs;
 }