Ejemplo n.º 1
0
        /// <summary>
        /// Evalates the RDate component, and adds each specified DateTime or
        /// Period to the <see cref="DateTimes"/> collection.
        /// </summary>
        /// <param name="FromDate">The beginning date of the range to evaluate.</param>
        /// <param name="ToDate">The end date of the range to evaluate.</param>
        virtual protected void EvaluateRDate(Date_Time FromDate, Date_Time ToDate)
        {
            // Handle RDATEs
            if (RDate != null)
            {
                foreach (RDate rdate in RDate)
                {
                    ArrayList Items = rdate.Evaluate(DTStart, FromDate, ToDate);
                    foreach (object obj in Items)
                    {
                        Date_Time dt = null;
                        if (obj is Period)
                        {
                            dt = ((Period)obj).StartTime;
                        }
                        else if (obj is Date_Time)
                        {
                            dt = (Date_Time)obj;
                        }

                        if (dt != null && !DateTimes.Contains(dt))
                        {
                            DateTimes.Add(dt);
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        protected override void EvaluateRDate(Date_Time FromDate, Date_Time ToDate)
        {
            // Handle RDATEs
            if (RDate != null)
            {
                foreach (RDate rdate in RDate)
                {
                    ArrayList Items = rdate.Evaluate(DTStart, FromDate, ToDate);
                    foreach (object obj in Items)
                    {
                        Period p = null;
                        if (obj is Period)
                        {
                            p = (Period)obj;
                        }
                        else if (obj is Date_Time)
                        {
                            p = new Period((Date_Time)obj, (TimeSpan)Duration);
                        }

                        if (p != null && !Periods.Contains(p))
                        {
                            Periods.Add(p);
                            DateTimes.Add(p.StartTime);
                        }
                    }
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Evaluates this event to determine the dates and times for which the event occurs.
        /// This method only evaluates events which occur between <paramref name="FromDate"/>
        /// and <paramref name="ToDate"/>; therefore, if you require a list of events which
        /// occur outside of this range, you must specify a <paramref name="FromDate"/> and
        /// <paramref name="ToDate"/> which encapsulate the date(s) of interest.
        /// <note type="caution">
        ///     For events with very complex recurrence rules, this method may be a bottleneck
        ///     during processing time, especially when this method in called for a large number
        ///     of events, in sequence, or for a very large time span.
        /// </summary>
        /// <param name="FromDate">The beginning date of the range to evaluate.</param>
        /// <param name="ToDate">The end date of the range to evaluate.</param>
        /// <returns></returns>
        public override ArrayList Evaluate(Date_Time FromDate, Date_Time ToDate)
        {
            // Add the event itself, before recurrence rules are evaluated
            DateTimes.Add(DTStart.Copy());
            Periods.Add(new Period(DTStart, Duration));

            // Evaluate recurrences normally
            base.Evaluate(FromDate, ToDate);

            // Remove DateTimes that already have a Period
            for (int i = DateTimes.Count - 1; i >= 0; i--)
            {
                foreach (Period p in Periods)
                {
                    if (p.StartTime == DateTimes[i])
                    {
                        DateTimes.RemoveAt(i);
                    }
                }
            }

            // Convert each calculated Date_Time into a Period.
            foreach (Date_Time dt in DateTimes)
            {
                Period p = new Period(dt, Duration);
                if (!Periods.Contains(p))
                {
                    Periods.Add(p);
                }
            }

            Periods.Sort();
            return(Periods);
        }
Ejemplo n.º 4
0
        public override ArrayList Evaluate(Date_Time FromDate, Date_Time ToDate)
        {
            // Add the event itself, before recurrence rules are evaluated
            if (DTStart != null)
            {
                DateTimes.Add(DTStart);
            }

            return(base.Evaluate(FromDate, ToDate));
        }
Ejemplo n.º 5
0
        private void SetGraph()
        {
            ReadTestData();
            ReadGradingSystemData();
            SeriesCollection.Clear();

            LineSeriesCollection.Clear();
            DateTimes.Clear();

            if (SelectedSubject == null)
            {
                return;
            }
            if (SelectedTestType == null)
            {
                return;
            }
            if (SelectedGradingPeriod == null)
            {
                return;
            }


            //var selectedSubject = AssociatedPerson.Subjects.Where(x => x.Name == SelectedSubject.Name);
            LineSeries           dummyLineSeries = new LineSeries();
            ChartValues <double> chartValues     = new ChartValues <double>();

            foreach (var test in SelectedSubject.Tests.Where(x => x.TestType.Name == SelectedTestType.Name && x.GradingPeriod.Name == SelectedGradingPeriod.Name))
            {
                chartValues.Add(test.Percentage);
                DateTimes.Add(test.TestDate.ToString(CultureInfo.InvariantCulture));
                if (chartValues.Count() > 4)
                {
                    GraphWidth = chartValues.Count() * 150;
                }
            }

            dummyLineSeries.Values = chartValues;
            //dummyLineSeries.LineSmoothness = 0;

            LineSeriesCollection.Add(dummyLineSeries);

            foreach (var s in LineSeriesCollection)
            {
                SeriesCollection.Add(s);
            }
        }
 public ArbitraryCountdown AddDate(DateTime dateTime)
 {
     DateTimes.Add(dateTime);
     SortDates();
     return(this);
 }
        private void LoadDashboardTimespan()
        {
            try
            {
                // Load Current Day Start and Day End
                var d        = DateTime.Now;
                var dayStart = new DateTime(d.Year, d.Month, d.Day, 0, 0, 0, DateTimeKind.Local);
                var dayEnd   = dayStart.AddDays(1);

                DateTimes.Clear();
                for (var x = 0; x <= 24; x++)
                {
                    DateTimes.Add(dayStart.AddHours(x));
                }

                // Load From Setting
                string   fromSetting = Properties.Settings.Default.SavedStatusFromTime;
                DateTime savedFrom   = DateTime.MinValue;
                DateTime.TryParse(fromSetting, out savedFrom);

                // Load To Setting
                string   toSetting = Properties.Settings.Default.SavedStatusToTime;
                DateTime savedTo   = DateTime.MinValue;
                DateTime.TryParse(toSetting, out savedTo);

                // Set From
                if (savedFrom > dayStart)
                {
                    From = savedFrom;
                }
                else if (savedFrom > DateTime.MinValue)
                {
                    From = new DateTime(dayStart.Year, dayStart.Month, dayStart.Day, savedFrom.Hour, 0, 0);
                }
                else
                {
                    From = dayStart;
                }

                // Set To
                if (savedTo > dayStart && savedTo < dayEnd && savedTo > From)
                {
                    To = savedTo;
                }
                else if (savedTo > DateTime.MinValue && savedTo.Hour > 0)
                {
                    To = new DateTime(dayStart.Year, dayStart.Month, dayStart.Day, savedTo.Hour, 0, 0);
                }
                else
                {
                    To = dayEnd;
                }

                SaveDashboardTimespan();
                SendDashboardTimespan();
            }
            catch (Exception ex)
            {
                Logger.Log("LoadDashboardTimespan :: Exception :: " + ex.Message);
            }
        }
        private void UpdateDashboardTimespan()
        {
            try
            {
                // Load Current Day Start and Day End
                var d        = DateTime.Now;
                var dayStart = new DateTime(d.Year, d.Month, d.Day, 0, 0, 0, DateTimeKind.Local);
                var dayEnd   = dayStart.AddDays(1);

                DateTime from = DateTime.MinValue;
                DateTime to   = DateTime.MinValue;

                // Set From
                if (From > dayStart)
                {
                    from = From;
                }
                else if (From > DateTime.MinValue)
                {
                    from = new DateTime(dayStart.Year, dayStart.Month, dayStart.Day, From.Hour, 0, 0);
                }
                else
                {
                    from = dayStart;
                }

                // Set To
                if (To > dayStart && To <= dayEnd)
                {
                    to = To;
                }
                else if (To > DateTime.MinValue && To.Hour > 0)
                {
                    to = new DateTime(dayStart.Year, dayStart.Month, dayStart.Day, To.Hour, 0, 0);
                }
                else
                {
                    to = dayEnd;
                }

                // Update Timespan
                if (From != from || To != to)
                {
                    DateTimes.Clear();
                    for (var x = 0; x <= 24; x++)
                    {
                        DateTimes.Add(dayStart.AddHours(x));
                    }

                    From = from;
                    To   = to;

                    SaveDashboardTimespan();
                    SendDashboardTimespan();
                }
            }
            catch (Exception ex)
            {
                Logger.Log("UpdateDashboardTimespan :: Exception :: " + ex.Message);
            }
        }
Ejemplo n.º 9
0
 public void Add(DateTime dateTime, IWeatherData weatherData)
 {
     DateTimes.Add(dateTime);
     WeatherDatas.Add(weatherData);
 }