Esempio n. 1
0
        /// <summary>
        /// Update cached period information.
        /// </summary>
        /// <param name="periods">Updated periods.</param>
        private static void LoadPeriods(PeriodList periods)
        {
            Period     currentPublicPeriod;
            PeriodList publicPeriods;

            if (periods.IsNotEmpty())
            {
                currentPublicPeriod = null;
                publicPeriods       = new PeriodList();
                foreach (Period period in periods)
                {
                    if (period.StopUpdate < DateTime.Today)
                    {
                        if (period.PeriodType.Id == (Int32)DEFAULT_PERIOD_TYPE)
                        {
                            currentPublicPeriod = period;
                        }
                        publicPeriods.Add(period);
                    }
                }

                CurrentPublicPeriod = currentPublicPeriod;
                Periods             = periods;
                PublicPeriods       = publicPeriods;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Get all period objects of a sertain period type.
        /// </summary>
        /// <param name="periodTypeId">Id enum of the period type.</param>
        /// <returns>All periods of the requested type.</returns>
        public static PeriodList GetPeriods(PeriodTypeId periodTypeId)
        {
            PeriodList periods = new PeriodList();

            for (Int32 getAttempts = 0; (periods.IsNull()) && (getAttempts < 3); getAttempts++)
            {
                LoadPeriods();
            }

            foreach (Period period in Periods)
            {
                if (period.PeriodType.Id == (Int32)periodTypeId)
                {
                    periods.Add(period);
                }
            }
            return(periods);
        }
Esempio n. 3
0
        /// <summary>
        /// Get periods from web service.
        /// </summary>
        private static void LoadPeriods()
        {
            PeriodList periods;

            if (Periods.IsNull())
            {
                // Get data from web service.
                periods = new PeriodList();
                foreach (WebPeriod webPeriod in WebServiceClient.GetPeriods())
                {
                    periods.Add(new Period(webPeriod.Id,
                                           webPeriod.Year,
                                           webPeriod.Name,
                                           webPeriod.Information,
                                           webPeriod.StopUpdate,
                                           webPeriod.PeriodTypeId));
                }
                LoadPeriods(periods);
            }
        }