private void setPredictionEventData()

        {
            DateTime today           = DateTime.Now;
            string   currentDateTime = today.ToString("yyyy-MM-dd HH:mm");



            PredictionModelManager predictionModelManager = new PredictionModelManager();

            List <EventModel> eventModelList = new List <EventModel>();

            eventModelList = predictionModelManager.getAllPastEvents(loggedInUser);

            if (eventModelList.Count != 0)
            {
                SE_allEventCount = eventModelList.Count();
                foreach (EventModel eventModel in eventModelList)
                {
                    DateTime start = eventModel.Event_begin_time;
                    DateTime end   = eventModel.Event_end_time;

                    double minutesgap = end.Subtract(start).TotalMinutes;
                    Console.WriteLine(minutesgap);
                    ST_eventHours += minutesgap;
                }

                MT_avgTimeperEvent = ST_eventHours / SE_allEventCount;

                EventModel firstEvent = eventModelList.First();

                //get Weeks
                DateTime firstDate = firstEvent.Event_begin_time;
                DateTime lastDate  = DateTime.Now;
                NW_numberofWeeks = (lastDate - firstDate).TotalDays / 7;


                EW_eventsPerWeeek            = SE_allEventCount / NW_numberofWeeks;
                MTPW_meanTimeUsagePerWeek    = MT_avgTimeperEvent * EW_eventsPerWeeek;
                prediction_followingFourWeek = MTPW_meanTimeUsagePerWeek * 4;



                this.lblNoOfPastEvent.Text = Convert.ToString(SE_allEventCount);


                this.lblAvgHoursPerEvent.Text = Convert.ToString(Convert.ToInt32(MT_avgTimeperEvent) / 60) + ":" + Convert.ToString(Convert.ToInt32(MT_avgTimeperEvent) % 60);

                this.lblAvgEventsPerWeek.Text = Convert.ToString(EW_eventsPerWeeek);
                this.lblMeanTimeperWeek.Text  = Convert.ToString(Convert.ToInt32(MTPW_meanTimeUsagePerWeek) / 60) + ":" + Convert.ToString(Convert.ToInt32(MTPW_meanTimeUsagePerWeek) % 60);
                this.lblAvgTimePerMonth.Text  = Convert.ToString(Convert.ToInt32(prediction_followingFourWeek) / 60) + ":" + Convert.ToString(Convert.ToInt32(prediction_followingFourWeek) % 60);


                //Console.WriteLine(ST_eventHours+ SE_allEventCount+" "+ MT_avgTimeperEvent+" "+totalWeeks);
            }
            else
            {
                MessageBox.Show("There are no past Events");
            }
        }
Exemplo n.º 2
0
        private void btnPrediction_Click(object sender, EventArgs e)
        {
            PredictionModelManager predictionModelManager = new PredictionModelManager();

            List <EventModel> eventModelList = new List <EventModel>();

            eventModelList = predictionModelManager.getAllPastEvents(loggedInUser);

            if (eventModelList.Count != 0)
            {
                PredictionTimeView predictionTimeView = new PredictionTimeView(loggedInUser);
                this.Hide();
                predictionTimeView.ShowDialog();
                this.Close();
            }
            else
            {
                MessageBox.Show("There are no past Events");
            }
        }