コード例 #1
0
        async Task ExecuteLoadPeriodCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Periods.Clear();
                var periods = await DataStoreP.GetPeriodsAsync(true);

                foreach (var period in periods)
                {
                    Periods.Add(period);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
コード例 #2
0
        public async void LoadGpnAsync()
        {
            if (string.IsNullOrEmpty(GpnFile))
            {
                return;
            }

            try
            {
                GpnLoadDateTime = null;
                IsBusy          = true;
                Periods.Clear();

                BusyText = "Untis Datei laden...";
                Result   = await UntisExporter.ParseFileAsync(GpnFile);

                foreach (var period in Result.Periods)
                {
                    Periods.Add(period);
                }

                GpnLoadDateTime = DateTime.Now;
            }
            catch (Exception e)
            {
                await dialogCoordinator.ShowMessageAsync(this, "Fehler beim Laden der Untis-Datei", e.Message, MessageDialogStyle.Affirmative);

                Result = null;
            }
            finally
            {
                IsBusy   = false;
                BusyText = "";
            }
        }
コード例 #3
0
        public override IEnumerable <IPeriod> Evaluate(IDateTime referenceDate, DateTime periodStart, DateTime periodEnd, bool includeReferenceDateInResults)
        {
            // Create a recurrence pattern suitable for use during evaluation.
            IRecurrencePattern pattern = ProcessRecurrencePattern(referenceDate);

            // Enforce evaluation restrictions on the pattern.
            EnforceEvaluationRestrictions(pattern);

            var periods = new HashSet <IPeriod>();

            foreach (DateTime dt in GetDates(referenceDate, periodStart, periodEnd, -1, pattern, includeReferenceDateInResults))
            {
                // Create a period from the date/time.
                IPeriod p = CreatePeriod(dt, referenceDate);

                if (!periods.Contains(p))
                {
                    periods.Add(p);
                }
            }


            Periods.Clear();

            foreach (var period in periods)
            {
                if (!Periods.Contains(period))
                {
                    Periods.Add(period);
                }
            }

            return(Periods);
        }
コード例 #4
0
ファイル: Event.cs プロジェクト: MaitreDede/dday-ical
        /// <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.
        /// </note>
        /// </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>                
        internal override List<Period> Evaluate(iCalDateTime FromDate, iCalDateTime ToDate)
        {
            // Add the event itself, before recurrence rules are evaluated
            // NOTE: this fixes a bug where (if evaluated multiple times)
            // a period can be added to the Periods collection multiple times.
            Period period = new Period(DTStart, Duration);
            // Ensure the period does not already exist in our collection
            if (!Periods.Contains(period))
                Periods.Add(period);
            
            // Evaluate recurrences normally
            base.Evaluate(FromDate, ToDate);

            // Ensure each period has a duration
            foreach(Period p in Periods)
            {
                if (p.EndTime == null)
                {
                    p.Duration = Duration;
                    if (p.Duration != null)
                        p.EndTime = p.StartTime + Duration;
                    else p.EndTime = p.StartTime;
                }
                // Ensure the Kind of time is consistent with DTStart
                p.EndTime.IsUniversalTime = DTStart.IsUniversalTime;
            }

            return Periods;
        }
コード例 #5
0
 /// <summary>
 /// Evaulates the RRule component, and adds each specified Period
 /// to the <see cref="Periods"/> collection.
 /// </summary>
 /// <param name="periodStart">The beginning date of the range to evaluate.</param>
 /// <param name="periodEnd">The end date of the range to evaluate.</param>
 virtual protected void EvaluateRRule(IDateTime referenceDate, DateTime periodStart, DateTime periodEnd, bool includeReferenceDateInResults)
 {
     // Handle RRULEs
     if (Recurrable.RecurrenceRules != null &&
         Recurrable.RecurrenceRules.Count > 0)
     {
         foreach (IRecurrencePattern rrule in Recurrable.RecurrenceRules)
         {
             IEvaluator evaluator = rrule.GetService(typeof(IEvaluator)) as IEvaluator;
             if (evaluator != null)
             {
                 IList <IPeriod> periods = evaluator.Evaluate(referenceDate, periodStart, periodEnd, includeReferenceDateInResults);
                 foreach (IPeriod p in periods)
                 {
                     if (!Periods.Contains(p))
                     {
                         Periods.Add(p);
                     }
                 }
             }
         }
     }
     else if (includeReferenceDateInResults)
     {
         // If no RRULEs were found, then we still need to add
         // the initial reference date to the results.
         IPeriod p = new Period(referenceDate.Copy <IDateTime>());
         if (!Periods.Contains(p))
         {
             Periods.Add(p);
         }
     }
 }
コード例 #6
0
        public override IList <IPeriod> Evaluate(IDateTime referenceDate, DateTime periodStart, DateTime periodEnd, bool includeReferenceDateInResults)
        {
            // Create a recurrence pattern suitable for use during evaluation.
            IRecurrencePattern pattern = ProcessRecurrencePattern(referenceDate);

            // Enforce evaluation restrictions on the pattern.
            EnforceEvaluationRestrictions(pattern);

            Periods.Clear();
            foreach (DateTime dt in GetDates(referenceDate, periodStart, periodEnd, -1, pattern, includeReferenceDateInResults))
            {
                // Turn each resulting date/time into an IDateTime and associate it
                // with the reference date.
                IDateTime newDt = new iCalDateTime(dt, referenceDate.TZID);

                // NOTE: fixes bug #2938007 - hasTime missing
                newDt.HasTime = referenceDate.HasTime;

                newDt.AssociateWith(referenceDate);

                // Create a period from the new date/time.
                IPeriod p = new Period(newDt);

                if (!Periods.Contains(p))
                {
                    Periods.Add(p);
                }
            }

            return(Periods);
        }
コード例 #7
0
        /// <summary>
        /// Gets the next report number for this foundry
        /// </summary>
        /// <param name="ctx">Context under which to give the report number</param>
        /// <returns></returns>
        public String getNextReportNumber(RadiographyContext ctx)
        {
            //period logic - first check whether which is the current period or we need to create a new period
            if (NextResetDate < DateTime.Now)
            {
                //end date the current period, and create a new period
                if (CurrentPeriod != null)
                {
                    CurrentPeriod.EndDate = NextResetDate;
                }
                var newPeriod = new Period
                {
                    StartDate = NextResetDate,
                    Foundry   = this,
                    FoundryID = ID,
                };
                Periods.Add(newPeriod);

                //set the next reset date to one year hence
                NextResetDate = NextResetDate.AddYears(1);
                //for ctx to get these changes
                ctx.Foundries.AttachAsModified(this, ctx);
                ctx.Periods.Add(newPeriod);
                ctx.SaveChanges();
            }

            //fetch immediately from the database, otherwise convert.toint32 will fail
            var reports    = ctx.RGReports.Where(p => p.ReportNo.StartsWith(this.ReportNumberPrefix) && p.ReportDate > CurrentPeriod.StartDate).ToList();
            var lastNumber = !reports.Any() ? 0 : reports.Max(p => Convert.ToInt32(p.ReportNo.Replace(ReportNumberPrefix, "")));

            return(String.Concat(ReportNumberPrefix, Convert.ToString(lastNumber + 1)));
        }
コード例 #8
0
ファイル: Event.cs プロジェクト: MaitreDede/dday-ical
        /// <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 List <Period> Evaluate(Date_Time FromDate, Date_Time ToDate)
        {
            // Add the event itself, before recurrence rules are evaluated
            // NOTE: this fixes a bug where (if evaluated multiple times)
            // a period can be added to the Periods collection multiple times.
            Period period = new Period(DTStart, Duration);

            // Ensure the period does not already exist in our collection
            if (!Periods.Contains(period))
            {
                Periods.Add(period);
            }

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

            // Ensure each period has a duration
            foreach (Period p in Periods)
            {
                if (p.EndTime == null)
                {
                    p.Duration = Duration;
                    p.EndTime  = p.StartTime + Duration;
                }
                // Ensure the Kind of time is consistent with DTStart
                else if (p.EndTime.Kind != DTStart.Kind)
                {
                    p.EndTime.Value = DateTime.SpecifyKind(p.EndTime.Value, DTStart.Kind);;
                }
            }

            return(Periods);
        }
コード例 #9
0
        /// <summary>
        /// Evalates the RDate component, and adds each specified DateTime or
        /// Period to the <see cref="Periods"/> 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)
                    {
                        Period p = null;
                        if (obj is Period)
                        {
                            p = (Period)obj;
                        }
                        else if (obj is Date_Time)
                        {
                            p = new Period((Date_Time)obj);
                        }

                        if (p != null && !Periods.Contains(p))
                        {
                            Periods.Add(p);
                        }
                    }
                }
            }
        }
コード例 #10
0
ファイル: Event.cs プロジェクト: MaitreDede/dday-ical
        /// <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 List <Period> Evaluate(Date_Time FromDate, Date_Time ToDate)
        {
            // Add the event itself, before recurrence rules are evaluated
            // NOTE: this fixes a bug where (if evaluated multiple times)
            // a period can be added to the Periods collection multiple times.
            Period period = new Period(DTStart, Duration);

            if (!Periods.Contains(period))
            {
                Periods.Add(period);
            }

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

            // Ensure each period has a duration
            foreach (Period p in Periods)
            {
                if (p.EndTime == null)
                {
                    p.Duration = Duration;
                    p.EndTime  = p.StartTime + Duration;
                }
            }

            return(Periods);
        }
コード例 #11
0
ファイル: Event.cs プロジェクト: MaitreDede/dday-ical
        /// <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);
        }
コード例 #12
0
        private async Task LoadDate(IOutcomeReportServiceProvider provider)
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            using (var service = provider.GetService())
            {
                var response = await service.GetAllPeriodsAsync(new ApplicationService.GetAllPeriodsRequest());

                if (ReferenceEquals(response.Exception, null))
                {
                    foreach (var vm in response.PeriodViewModels)
                    {
                        Periods.Add(vm);
                    }
                }
                else
                {
                    System.Diagnostics.Debug.WriteLine(response.Exception);
                }
            }

            IsBusy = false;
        }
コード例 #13
0
ファイル: PeriodListVM.cs プロジェクト: mehabadi/HPMS
 public PeriodListVM()
 {
     PeriodMgtAppLocalizedResources = new PeriodMgtAppLocalizedResources();
     init();
     Periods.Add(new PeriodDTOWithAction {
         Id = 4, Name = "Test"
     });
 }
コード例 #14
0
        private void AddPeriodCmd()
        {
            var newPeriod = new Period();

            MainContext.AddEntity(newPeriod);
            Periods.Add(newPeriod);
            SelectedPeriod = newPeriod;
        }
コード例 #15
0
 private void Initialize()
 {
     Periods.Clear();
     foreach (QuotePeriod period in Enum.GetValues(typeof(QuotePeriod)))
     {
         Periods.Add(CalculateChartData(period));
     }
 }
        /// <summary>
        /// Add period to search criteria.
        /// </summary>
        /// <param name="period">The period.</param>
        public void Add(IPeriod period)
        {
            if (Periods.IsNull())
            {
                Periods = new PeriodList();
            }

            Periods.Add(period);
        }
コード例 #17
0
 private void Periods_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
 {
     Periods.Clear();
     foreach (PeriodViewModel period in MainViewModel.Instance.Parameters.Periods)
     {
         Periods.Add(period);
     }
     SelectedPeriod = Periods.FirstOrDefault();
 }
コード例 #18
0
        public override List <Period> Evaluate(Date_Time FromDate, Date_Time ToDate)
        {
            // Add the event itself, before recurrence rules are evaluated
            if (DTStart != null)
            {
                Periods.Add(new Period(DTStart));
            }

            return(base.Evaluate(FromDate, ToDate));
        }
コード例 #19
0
        public MonthlyPeriod GetPeriod(int year, int month)
        {
            var period = Periods.Where(x => x.FirstDayOfMonth == new DateTime(year, month, 1)).SingleOrDefault();

            if (period == null)
            {
                period = new MonthlyPeriod(year, month, this);
                Periods.Add(period);
            }
            return(period);
        }
コード例 #20
0
ファイル: Todo.cs プロジェクト: MaitreDede/dday-ical
        public override List <Period> Evaluate(Date_Time FromDate, Date_Time ToDate)
        {
            // Add the todo itself, before recurrence rules are evaluated
            Period startPeriod = new Period(DTStart);

            if (DTStart != null &&
                !Periods.Contains(startPeriod))
            {
                Periods.Add(startPeriod);
            }

            return(base.Evaluate(FromDate, ToDate));
        }
コード例 #21
0
        public HoldingPeriodReturn(IEnumerable <Tuple <DateTime, DateTime> > periods, IEnumerable <Tuple <decimal, DateTime> > incomes)
        {
            foreach (var period in periods)
            {
                var addedPeriod = ReturnCalculationPeriod.Build(period.Item1, period.Item2, Id);
                Periods.Add(addedPeriod);
            }

            foreach (var income in incomes)
            {
                var addedIncome = ReturnIncome.Build(income.Item1, income.Item2, Id);
                Incomes.Add(addedIncome);
            }
        }
コード例 #22
0
        public async void Get()
        {
            var jData = await DataService.Get("VaccinePeriods");

            if (jData == "ConnectionError")
            {
                StandardMessagesDisplay.NoConnectionToast();
            }
            else if (jData == "null")
            {
                StandardMessagesDisplay.NoDataDisplayMessage();
            }
            else if (jData == "Error")
            {
                StandardMessagesDisplay.Error();
            }
            else if (jData == "ErrorTracked")
            {
                StandardMessagesDisplay.ErrorTracked();
            }
            else
            {
                try
                {
                    var data = JsonConvert.DeserializeObject <Dictionary <string, PeriodModel> >(jData);

                    if (data != null)
                    {
                        foreach (KeyValuePair <string, PeriodModel> item in data)
                        {
                            Periods?.Add(
                                new PeriodModel
                            {
                                FId        = item.Key.ToString(),
                                Id         = item.Value.Id,
                                StartDate  = item.Value.StartDate,
                                EndDate    = item.Value.EndDate,
                                PeriodName = item.Value.PeriodName
                            }
                                );
                        }
                    }
                }
                catch (Exception ex)
                {
                    Crashes.TrackError(ex);
                    StandardMessagesDisplay.InputToast(ex.Message);
                }
            }
        }
コード例 #23
0
        public void StartPeriod()
        {
            string periodName;

            if (!ReadyToCapture)
            {
                return;
            }

            if (currentPeriod != null)
            {
                string msg = Catalog.GetString("Period recording already started");
                App.Current.Dialogs.WarningMessage(msg, this);
                return;
            }
            recbutton.Visible   = false;
            pausebutton.Visible = savebutton.Visible = stopbutton.Visible = true;

            if (PeriodsNames != null && PeriodsNames.Count > Periods.Count)
            {
                periodName = PeriodsNames [Periods.Count];
            }
            else
            {
                periodName = (Periods.Count + 1).ToString();
            }
            currentPeriod = new Period {
                Name = periodName
            };

            currentTimeNode      = currentPeriod.Start(accumTime, periodName);
            currentTimeNode.Stop = currentTimeNode.Start;
            currentPeriodStart   = DateTime.UtcNow;
            timeoutID            = GLib.Timeout.Add(20, UpdateTime);
            if (Capturer != null)
            {
                if (Periods.Count == 0)
                {
                    Capturer.Start();
                }
                else
                {
                    Capturer.TogglePause();
                }
            }
            periodlabel.Markup = currentPeriod.Name;
            Capturing          = true;
            Periods.Add(currentPeriod);
            Log.Debug("Start new period start=", currentTimeNode.Start.ToMSecondsString());
        }
コード例 #24
0
ファイル: Journal.cs プロジェクト: MaitreDede/dday-ical
        public override System.Collections.Generic.List <Period> Evaluate(iCalDateTime FromDate, iCalDateTime ToDate)
        {
            if (Start != null)
            {
                Period p = new Period(Start);
                if (!Periods.Contains(p))
                {
                    Periods.Add(p);
                }

                return(base.Evaluate(FromDate, ToDate));
            }
            return(new System.Collections.Generic.List <Period>());
        }
コード例 #25
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="periods"></param>
        /// <param name="incomes"></param>
        public HoldingPeriodReturn(IEnumerable <Tuple <DateTime, DateTime> > periods, IEnumerable <Tuple <decimal, DateTime> > incomes)
        {
            foreach (var period in periods)
            {
                Periods.Add(new ReturnCalculationPeriod {
                    DateFrom = period.Item1, DateTo = period.Item2, ReturnId = this.Id
                });
            }

            foreach (var income in incomes)
            {
                Incomes.Add(new ReturnIncome {
                    Amount = income.Item1, Timestamp = income.Item2, ReturnId = this.Id
                });
            }
        }
コード例 #26
0
        virtual public IPeriod GetNext(IDateTime referenceDate)
        {
            DateTime?dt = GetNextDate(referenceDate, referenceDate.Value, Pattern);

            if (dt != null)
            {
                // Create a period from the date/time.
                IPeriod p = CreatePeriod(dt.Value, referenceDate);

                if (!Periods.Contains(p))
                {
                    Periods.Add(p);
                }
            }
            return(null);
        }
コード例 #27
0
        public ValidityPeriod GetOrAddPeriod(int sequence)
        {
            var period = Periods.FirstOrDefault(p => p.Sequence == sequence);

            if (period == null)
            {
                period = new ValidityPeriod
                {
                    Sequence = sequence
                };

                Periods.Add(period);
            }

            return(period);
        }
コード例 #28
0
ファイル: Todo.cs プロジェクト: MaitreDede/dday-ical
        public override List <Period> Evaluate(Date_Time FromDate, Date_Time ToDate)
        {
            // TODO items can only recur if a start date is specified
            if (DTStart != null)
            {
                // Add the todo itself, before recurrence rules are evaluated
                Period startPeriod = new Period(DTStart);
                if (DTStart != null &&
                    !Periods.Contains(startPeriod))
                {
                    Periods.Add(startPeriod);
                }

                return(base.Evaluate(FromDate, ToDate));
            }
            return(new List <Period>());
        }
コード例 #29
0
        public Period PostPeriod(Period period)
        {
            period.AccountId = Session.DefaultAccount.AccountId;
            var item = Periods.FirstOrDefault(c => c.PeriodId == period.PeriodId);

            if (item != null)
            {
                item = period;
                return(item);
            }
            else
            {
                period.PeriodId = GeneratePeriodId();
                Periods.Add(period);
                return(period);
            }
        }
コード例 #30
0
        public Game(GameListItem item)
        {
            Id         = item.Id;
            DateStart  = item.Date;
            DateUpdate = item.UpdD;
            Country    = new Country {
                Id = item.CntI, Title = item.CntN
            };
            League = new League {
                Id = item.LeaI, Title = item.LeaN
            };
            Season = new Season {
                Id = item.SeaI, Title = item.SeaN
            };
            Stage = new Stage {
                Id = item.StgI, Title = item.StgN
            };
            Status   = item.Stat;
            TeamHome = new Team {
                Id = item.THId, Title = item.THNm
            };
            TeamAway = new Team {
                Id = item.TAId, Title = item.TANm
            };
            Periods.Add(new Score {
                Away = item.Sc1A, Home = item.Sc1H, Id = 1, Name = "P1"
            });
            Periods.Add(new Score {
                Away = item.Sc2A, Home = item.Sc2H, Id = 2, Name = "P2"
            });
            Periods.Add(new Score {
                Away = item.Sc3A, Home = item.Sc3H, Id = 3, Name = "P3"
            });
            Periods.Add(new Score {
                Away = item.Sc4A, Home = item.Sc4H, Id = 4, Name = "P4"
            });
            Periods.Add(new Score {
                Away = item.ScOA, Home = item.ScOH, Id = 5, Name = "OT"
            });
            var total = new Score {
                Away = item.ScTA, Home = item.ScTH, Id = 6, Name = "TT"
            };

            Periods.Add(total);
            Total = total;
        }