Esempio n. 1
0
        public static void AddMissingParentAttributes(OffnetServiceKey key)
        {
            if (key.ParentServiceKey != null)
            {
                key.ParentServiceKey.AddMissingAttributes();

                var    childConfig  = OffnetServiceConfiguration.Get(key.Id, key.EffectiveDate);
                var    parentConfig = OffnetServiceConfiguration.Get(key.ParentServiceKey.Id, key.ParentServiceKey.EffectiveDate);
                string value;
                foreach (var attribute in childConfig.Attributes)
                {
                    if (attribute.Value.Type == AttributeType.Parent)
                    {
                        value = key.ParentServiceKey.GetAttributeValue(attribute.Value.Name, SearchOptions.ALL_TRUE);
                        if (value == null)
                        {
                            value = parentConfig.GetDefaultValue(attribute.Value.Name, key.ParentServiceKey);
                        }
                        if (value != null)
                        {
                            key.AddAttribute(attribute.Value.Name, value);
                        }
                    }
                }
            }
        }
Esempio n. 2
0
        public void SetAttributeValue(OffnetServiceKey key, long id)
        {
            var    childConfig = OffnetServiceConfiguration.Get(key.Id, key.EffectiveDate);
            string value;

            foreach (var attribute in childConfig.Attributes)
            {
                if (attribute.Value.Name.Equals("UNI Reference ID"))
                {
                    value = id.ToString();
                    key.AddAttribute(attribute.Value.Name, value);
                }
            }
        }
        public static OffnetServiceConfiguration Get(long id, DateTime effectiveDate)
        {
            var sKey    = id.ToString();
            var configs = _Cache.CheckCache(sKey);
            OffnetServiceConfiguration sc;

            if (configs == null)
            {
                try
                {
                    sc = OffnetDataAccess.GetServiceConfig(id, effectiveDate);
                    _Cache.StoreCache(id.ToString(), new List <OffnetServiceConfiguration>()
                    {
                        sc
                    });
                }
                catch (Exception e)
                {
                    sc = new OffnetServiceConfiguration();
                    throw new ApplicationException("Error fetching service configuration :" + e.Message);
                }
            }
            else
            {
                sc = configs.FirstOrDefault(c => c.IsEffective(effectiveDate));
                if (sc == null)
                {
                    try
                    {
                        sc = OffnetDataAccess.GetServiceConfig(id, effectiveDate);
                        configs.Add(sc);
                    }
                    catch (Exception e)
                    {
                        sc = new OffnetServiceConfiguration();
                        throw new ApplicationException("Error fetching service configuration :" + e.Message);
                    }
                }
                _Cache.StoreCache(id.ToString(), new List <OffnetServiceConfiguration>()
                {
                    sc
                });
            }
            return(sc);
        }
Esempio n. 4
0
        public static void AddMissingDefaultAttributes(OffnetServiceKey key)
        {
            var    childConfig = OffnetServiceConfiguration.Get(key.Id, key.EffectiveDate);
            string value;

            foreach (var attribute in childConfig.Attributes)
            {
                //if (attribute.Value.Type != AttributeType.List
                //    && key.GetAttributeValue(attribute.Value.Name, SearchOptions.ALL_FALSE) == null
                //    && !childConfig.IsOptional(attribute.Value.Name, key))
                //{
                value = childConfig.GetDefaultValue(attribute.Value.Name, key);
                if (value != null)
                {
                    key.AddAttribute(attribute.Value.Name, value);
                }
                //}
            }
        }