Exemplo n.º 1
0
 public WebPeriodType GetPeriodType(Boolean refresh)
 {
     if (_periodType.IsNull() || refresh)
     {
         _periodType = PeriodManagerTest.GetOnePeriodType(GetContext());
     }
     return(_periodType);
 }
        /// <summary>
        /// Convert a WebPeriodType instance into
        /// an IPeriodType instance.
        /// </summary>
        /// <param name="userContext">
        /// Information about the user that makes this method call.
        /// </param>
        /// <param name="webPeriodType">A WebPeriodType instance.</param>
        /// <returns>An IPeriodType instance.</returns>
        private IPeriodType GetPeriodType(IUserContext userContext, WebPeriodType webPeriodType)
        {
            IPeriodType periodType;

            periodType             = new PeriodType();
            periodType.DataContext = GetDataContext(userContext);
            periodType.Description = webPeriodType.Description;
            periodType.Id          = webPeriodType.Id;
            periodType.Name        = webPeriodType.Name;
            return(periodType);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Get all period types.
        /// </summary>
        /// <param name="context">Web service request context.</param>
        /// <returns>Period types.</returns>
        public static List <WebPeriodType> GetPeriodTypes(WebServiceContext context)
        {
            List <WebPeriodType> periodTypes;
            String        cacheKey;
            WebPeriodType periodType;

            // Get cached information.
            periodTypes = null;
            cacheKey    = Settings.Default.PeriodTypeCacheKey;
            if (!context.IsInTransaction())
            {
                periodTypes = (List <WebPeriodType>)context.GetCachedObject(cacheKey);
            }

            if (periodTypes.IsNull())
            {
                // Get information from database.
                periodTypes = new List <WebPeriodType>();
                using (DataReader dataReader = context.GetTaxonAttributeDatabase().GetPeriodTypes())
                {
                    while (dataReader.Read())
                    {
                        periodType = new WebPeriodType();
                        periodType.LoadData(dataReader);
                        periodTypes.Add(periodType);
                    }

                    if (!context.IsInTransaction())
                    {
                        // Add information to cache.
                        context.AddCachedObject(cacheKey,
                                                periodTypes,
                                                DateTime.Now + new TimeSpan(12, 0, 0),
                                                CacheItemPriority.AboveNormal);
                    }
                }
            }

            return(periodTypes);
        }
Exemplo n.º 4
0
 public WebPeriodTypeTest()
 {
     _periodType = null;
 }
Exemplo n.º 5
0
 /// <summary>
 /// Load data into the WebPeriodType instance.
 /// </summary>
 /// <param name="periodType">The period type instance.</param>
 /// <param name='dataReader'>An open data reader.</param>
 public static void LoadData(this WebPeriodType periodType, DataReader dataReader)
 {
     periodType.Description = dataReader.GetString(PeriodTypeData.DESCRIPTION);
     periodType.Id          = dataReader.GetInt32(PeriodTypeData.ID);
     periodType.Name        = dataReader.GetString(PeriodTypeData.NAME);
 }