Beispiel #1
0
        public PatientGenerator()
        {
            _hospitals   = MedWatchDAL.FindHospitals().ToList();
            _diseases    = MedWatchDAL.FindDiseases().ToList();
            _freeDoctors = new Dictionary <int, IList <int> >();
            _busyDoctors = new Dictionary <int, IList <int> >();
            _patientsTakenInChargeByDoctor = new List <IPatientTakenInChargeByDoctor>();
            _patientIds = new List <int>();
            _stopWatch  = new Stopwatch();

            // Assign doctors to each hospital
            foreach (var hospital in _hospitals)
            {
                var numberOfDoctors = hospital.AssignedDoctors;
                var doctorsList     = new List <int>(numberOfDoctors);
                for (var i = 0; i < numberOfDoctors; ++i)
                {
                    doctorsList.Add(GeneratorHelper.RandomNumericalValue(int.MaxValue));
                }
                _freeDoctors.Add(hospital.Id, doctorsList);
                _busyDoctors.Add(hospital.Id, new List <int>());
            }

            // Creates the patient arrival sorted dictionary
            _patientsArrival = new SortedDictionary <DiseasePriority, IList <IPatientArrival> >();
            for (var diseasePriority = DiseasePriority.VeryHigh; diseasePriority < DiseasePriority.Invalid; ++diseasePriority)
            {
                _patientsArrival.Add(diseasePriority, new List <IPatientArrival>());
            }
        }
Beispiel #2
0
        private void Dashboard_Load(object sender, EventArgs e)
        {
            try
            {
                btnPauseResume.Enabled = false;
                this.Text = AppName;

                var hospitals = MedWatchDAL.FindHospitals();

                var hospitalStatsDataTable = CreateDataTableForHospitalStats(hospitals);
                dataGridView.DataSource = hospitalStatsDataTable;

                InitPerformanceCounters(hospitals);

                // initialization de l'acteur pour le tableau de bord
                _dashboardActor = Program.MediWatchActors.ActorOf(Props.Create(() => new DashboardActor(hospitalStatsDataTable, btnPauseResume)), ActorPaths.DashboardActorName);

                // initialization du commander
                _commanderActor = Program.MediWatchActors.ActorOf(Props.Create(() => new MediWatchCommanderActor(hospitals, _dashboardActor)), ActorPaths.MediWatchCommanderActorName);

                btnPauseResume.Enabled = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show($"While loading up dashboard: {ex.ToString()}", AppName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #3
0
        private static void InsertEventsInDataBaseHandle()
        {
            var stopWatch = new Stopwatch();

            while (_insertEvent.WaitOne())
            {
                // Stored the new events in the database
                var hospitalEventList = _hospitalEventDictionary[_listToInsertInDataBase];
                stopWatch.Restart();
                MedWatchDAL.InsertBulkHospitalEvents(hospitalEventList);
                s_logger.Trace(
                    "Generated and stored {0} events in the database, elapsed time = {1} ms (Concurrent DB Access = {2} ms)",
                    hospitalEventList.Count, _elapsedTimeDictionary[_listToInsertInDataBase],
                    stopWatch.ElapsedMilliseconds);
                hospitalEventList.Clear();
                _syncEvent.Set();
                stopWatch.Stop();
            }
        }
Beispiel #4
0
        private void Fetching()
        {
            Receive <SubscribeEventFetcher>(sc =>
            {
                _subscriptions.Add(sc.Subscriber);
            });

            Receive <UnsubscribeEventFetcher>(uc =>
            {
                _subscriptions.Remove(uc.Subscriber);
            });

            Receive <FetchHostpitalEvents>(fetch =>
            {
                _log.Debug($"(H{_hospital.Id}) Fetching hospital events after event id {_lastEventId}");

                var sw = Stopwatch.StartNew();

                var dbEvents = MedWatchDAL.FindHospitalEventsAfter(_hospital.Id, _lastEventId, MaxCountPerFetch);

                foreach (var dbe in dbEvents)
                {
                    var actorEvent = ConvertToActorEvent(dbe);
                    Publish(actorEvent);

                    _lastEventId = dbe.EventId;
                }

                //var beforeLog = sw.Elapsed;
                _log.Info($"(H{_hospital.Id}) Fetching and publishing {dbEvents.Count()} events took {sw.ElapsedMilliseconds} ms");
                //var afterLog = sw.Elapsed;

                //_log.Info( $"(H{_hospital.Id}) Logging took {(afterLog - beforeLog).TotalMilliseconds} ms" );
            });

            Receive <TogglePauseFetchingHospitalEvents>(togglePauseFetching =>
            {
                _cancelFetching.Cancel(false);
                UnbecomeStacked();
            });
        }
Beispiel #5
0
        private static Dictionary <DiseaseType, Disease> InitDiseases()
        {
            var diseases = MedWatchDAL.FindDiseases();

            return(diseases.ToDictionary(d => d.Id));
        }