public ICollection <AttributeInfo> GetAttributes(OffnetServiceKey key, SearchOptions searchOptions)
        {
            //Offnet service attributes Use the rule set to GetAttributes...
            var myRuleSet = new CommonRuleSet();

            foreach (var r in _vvRules)
            {
                myRuleSet.AddRule(null, r);
            }
            foreach (var r in _vfyRules)
            {
                myRuleSet.AddRule(null, r);
            }

            foreach (var pair in key.Values.Where(pair => pair.Value != null))
            {
                myRuleSet.AddRule(pair.Key, new RuleValue(pair.Value));
                var list = new string[1];
                list[0] = pair.Value.Value;
                myRuleSet.AddRule(pair.Key, new ValidValueSet(pair.Key, list));
            }
            myRuleSet.AddAddresses(key);

            var atts = myRuleSet.GetAttributes(searchOptions, null, null);

            return(atts);
        }
Exemple #2
0
        public static OffnetServiceConfiguration GetServiceConfiguration(OffnetServiceKey key)
        {
            OffnetServiceConfiguration sc;

            sc = GetServiceConfiguration(key.Id, key.EffectiveDate);
            return(sc);
        }
        public static ImpactAttributes GetImpactAttributes(OffnetServiceKey key, List <string> changedAttributes)
        {
            var           attributes        = Get(key, false);
            List <string> impacts           = new List <string>();
            var           serviceId         = key.Id;
            var           serviceInstanceId = key.ServiceInstanceId;

            foreach (var attribute in changedAttributes)
            {
                bool isDesignImpact       = attributes.Where(a => a.Name == attribute).Select(a => a.DesignImpact).FirstOrDefault();
                bool isProvisioningImpact = attributes.Where(a => a.Name == attribute).Select(a => a.ProvisioningImpact).FirstOrDefault();

                if (isDesignImpact && isProvisioningImpact)
                {
                    impacts.Add(attribute + " (DESIGN IMPACT, POVISIONING IMPACT)");
                }
                else if (isDesignImpact && !isProvisioningImpact)
                {
                    impacts.Add(attribute + " (DESIGN IMPACT)");
                }
                else if (!isDesignImpact && isProvisioningImpact)
                {
                    impacts.Add(attribute + " (POVISIONING IMPACT)");
                }
            }
            return(new ImpactAttributes(serviceId, serviceInstanceId, impacts));
        }
 public ObjectResult BuildChild(BuildOffnetChildServiceRequestWeb postData)
 {
     return(WebFunction.Execute <BuildOffnetChildServiceRequestWeb, OffnetHierarchyWeb>(this, postData, (req) =>
     {
         var key = new OffnetServiceKey(req.ParentService);
         var child = OffnetServiceHierarchy.BuildChild(key, req.Name);
         return new WebResult <OffnetHierarchyWeb>(child);
     }));
 }
        public ObjectResult Children(OffnetServiceKeyWeb postData)
        {
            return(WebFunction.Execute <OffnetServiceKeyWeb, List <OffnetServiceChildWeb> >(this, postData, (sv) =>
            {
                var key = new OffnetServiceKey(sv);
                var children = OffnetServiceHierarchy.Get(key);

                return new WebResult <List <OffnetServiceChildWeb> >(children.Select(c => c.ToWeb()).ToList());
            }));
        }
 public ObjectResult Attributes(OffnetServiceAttributesKeyWeb postData)
 {
     return(WebFunction.Execute <OffnetServiceAttributesKeyWeb, OffnetAttributeSourcesInfoWeb>(this, postData, (sa) =>
     {
         OffnetAttributeSourcesInfoWeb info;
         var sKey = new OffnetServiceKey(sa);
         info = OffnetServiceAttributes.GetAttributes(sKey, sa.PopulateLists);
         return new WebResult <OffnetAttributeSourcesInfoWeb>(info);
     }));
 }
Exemple #7
0
 public AddOffnetServiceRule(long serviceId, DateTime effDate, string tagName, bool allowReplacement, bool requireReplacement)
 {
     _tagName = tagName;
     _key     = new OffnetServiceKey(serviceId)
     {
         EffectiveDate = effDate
     };
     var sc = OffnetBiz.GetServiceConfiguration(serviceId, effDate);
     //_key.AllowSharedStandalone = sc.AllowSharedStandalone;
 }
        public void AddServiceKey(OffnetServiceKey key)
        {
            _key = key;

            if (key.Values != null)
            {
                foreach (var value in key.Values)
                {
                    AddValue(value.Key, new RuleValue(value.Value));
                }
            }
        }
        public override OffnetServiceKey FetchAndRemoveExistingService(string name)
        {
            OffnetServiceKey key = null;

            if (_existingServices.ContainsKey(name))
            {
                _existingServices.TryGetValue(name, out key);
            }
            if (key != null)
            {
                _existingServices.Remove(name);
            }
            return(key);
        }
        public static List <OffnetServiceChild> Get(OffnetServiceKey key, string name = null)
        {
            //List<OffnetServiceHierarchy> children = _Cache.CheckCache(key.Id.ToString());
            List <OffnetServiceHierarchy> children = new List <OffnetServiceHierarchy>();
            var kids = new List <OffnetServiceChild>();

            children = OffnetDataAccess.GetOffnetChildren(key);

            // _Cache.StoreCache(key.Id.ToString(), children);

            if (children != null && children.Count > 0)
            {
                var                searchOptions = SearchOptions.DEFAULTS_ONLY;
                string             error;
                RuleValue          quantity;
                OffnetServiceChild kid;

                var ruleSet = new OffnetServiceRuleSet();
                ruleSet.AddDefaults(key);
                ruleSet.AddServiceKey(key);

                foreach (var child in children)
                {
                    if (name == null || name.Equals(child.Name))
                    {
                        kid = new OffnetServiceChild()
                        {
                            Id   = child.Id,
                            Name = child.Name
                        };

                        if (ValueRuleParser.ParseRule(child.MaxQuantityRule).TryGetValue(ruleSet, searchOptions, out quantity, out error))
                        {
                            kid.MaxQuantity = quantity.ToInteger() ?? 0;
                        }
                        if (ValueRuleParser.ParseRule(child.MinQuantityRule).TryGetValue(ruleSet, searchOptions, out quantity, out error))
                        {
                            kid.MinQuantity = quantity.ToInteger() ?? 0;
                        }
                        if (kid.MaxQuantity > 0 || kid.MaxQuantity == -1)
                        {
                            kids.Add(kid);
                        }
                    }
                }
            }
            return(kids);
        }
Exemple #11
0
        public PartnerServicePackage GetPartnerServicePackage()
        {
            var pkg = new PartnerServicePackage();

            pkg.Partner = Partner;
            if (Services != null)
            {
                foreach (var pair in Services)
                {
                    if (Services != null)
                    {
                        var key = new OffnetServiceKey(pair.Service);
                        pkg.AddService(pair.Name, key);
                    }
                }
            }
            return(pkg);
        }
        //Servicecatalogbl ServiceRuleset
        #region AddDefaults
        public void AddDefaults(OffnetServiceKey key)
        {
            var config = OffnetServiceConfiguration.Get(key.Id, key.EffectiveDate);

            IPriceRule pricingRule;

            foreach (var attribute in config.Attributes)
            {
                if (!string.IsNullOrEmpty(attribute.Value.DefaultValue))
                {
                    pricingRule = ValueRuleParser.ParseRule(attribute.Value.DefaultValue);
                    if (pricingRule == null || pricingRule is RuleValue)
                    {
                        pricingRule = new PriceRuleValue(attribute.Value.DefaultValue, false);
                    }
                    AddDefault(attribute.Key, new DefaultRuleValue(pricingRule));
                }
            }
        }
Exemple #13
0
        public static List <OffnetAttributeSource> GetOffnetAttributeSource(OffnetServiceKey key)
        {
            List <OffnetAttributeSource> sources = new List <OffnetAttributeSource>();

            using (var connection = new OracleConnection(FscApplication.Current.Settings.FscConnectionString))
            {
                connection.Open();

                sources = connection.Query <OffnetAttributeSource>(@"
                    select s.OFFNET_SERVICE_ID OffnetServiceId, s.VERSION Version, s.PARTNER_ORDER_ID PartnerOrderId, s.ATTRIBUTE_NAME AttributeName, s.REQUEST_SOURCE RequestSource, s.ATTRIBUTE_SOURCE AttributeSource, s.SOLUTION_TARGET SolutionTarget
                    from fsc_dba.OFFNET_ATTRIBUTE_SOURCE s
                    inner join fsc_dba.Offnet_Service_Configuration sc on s.OFFNET_SERVICE_ID = sc.Offnet_Service_Id and (sc.from_eff_date <= :effectiveDate and (sc.to_eff_date is null or sc.to_eff_date > :effectiveDate))
                    where s.OFFNET_SERVICE_ID = :id", new
                {
                    id            = key.Id,
                    effectiveDate = key.EffectiveDate
                }).AsList();
            }
            return(sources);
        }
Exemple #14
0
        public static List <OffnetServiceHierarchy> GetOffnetChildren(OffnetServiceKey key, string name = null)
        {
            List <OffnetServiceHierarchy> children = new List <OffnetServiceHierarchy>();

            using (var connection = new OracleConnection(FscApplication.Current.Settings.FscConnectionString))
            {
                connection.Open();

                children = connection.Query <OffnetServiceHierarchy>(@"
                    select Child_Service_Id Id, o.Name, Min_Quantity MinQuantityRule, Max_Quantity MaxQuantityRule
                    from fsc_dba.Offnet_Hierarchy o
                    inner join fsc_dba.Offnet_Service_Configuration sc on o.Child_Service_Id = sc.Offnet_Service_Id and (sc.from_eff_date <= :effectiveDate and (sc.to_eff_date is null or sc.to_eff_date > :effectiveDate))
                    where o.Offnet_Service_Id = :id", new
                {
                    id            = key.Id,
                    effectiveDate = key.EffectiveDate
                }).AsList();
            }
            return(children);
        }
Exemple #15
0
        protected AttributeValue CreateAttribute(OffnetServiceKey sk, string value)
        {
            //Need to determine type to use...
            try
            {
                var sc = OffnetBiz.GetServiceConfiguration(sk.Id, sk.EffectiveDate);
                if (!sc.IsConfigurableAttribute(_sAttName, sk))
                {
                    return(null);
                }
                return(new AttributeValue(value,
                                          value,
                                          AttributeType.SimpleText));
                //Alaw simple text type for partner attributes
            }
            catch (Exception e)
            {
                Debugger.Log(new PcatExceptionInfo(this.ToString(), e));

                throw new ApplicationException("Resolve Services failed.  Unable to get ServiceAttribute type for " + _sAttName + " on Service " + sk?.Id);
            }
        }
Exemple #16
0
 public void AddService(string name, OffnetServiceKey key)
 {
     if (Services == null)
     {
         Services = new Dictionary <string, OffnetServiceKey>();
     }
     if (name == null)
     {
         return;
     }
     if (key == null && Services.ContainsKey(name))
     {
         Services.Remove(name);
     }
     if (Services.ContainsKey(name))
     {
         throw new ApplicationException(name + " already exists.  Service names need to be unique in the PSP.");
     }
     if (key != null)
     {
         Services.Add(name, key);
     }
 }
        public static OffnetHierarchyWeb BuildChild(OffnetServiceKey parent, string childName)
        {
            var children = Get(parent, childName);
            OffnetServiceKey childService = null;

            OffnetServiceKey[] childServices;
            OffnetHierarchyWeb offnetHierarchy = null;

            if (children.Count == 0)
            {
                throw new ApplicationException($"{childName} is not a child of service {parent.Id}");
            }
            int i;

            foreach (var child in children)
            {
                childServices = new OffnetServiceKey[child.MaxQuantity];
                if (child.MinQuantity > 1 && child.MaxQuantity > 1)
                {
                    long tempInstance = 1;

                    if (((parent.Children == null || !parent.Children.ContainsKey(childName)) && child.MaxQuantity > 0) ||
                        (parent.Children != null && parent.Children.ContainsKey(childName) && child.MaxQuantity > parent.Children[childName].Count)
                        )
                    {
                        for (i = 0; i <= child.MaxQuantity - 1; i++)
                        {
                            childService = new OffnetServiceKey(child.Id)
                            {
                                EffectiveDate    = parent.EffectiveDate,
                                ParentServiceKey = parent,
                            };
                            childService.AddMissingAttributes();
                            childService.SetAttributeValue(childService, tempInstance);
                            tempInstance++;
                            childServices[i] = childService;
                        }
                        offnetHierarchy = new OffnetHierarchyWeb(childServices);
                        break;
                    }
                }
                else
                {
                    if ((child.MaxQuantity == -1 || (parent.Children == null || !parent.Children.ContainsKey(childName)) && child.MaxQuantity > 0) ||
                        (parent.Children != null && parent.Children.ContainsKey(childName) && child.MaxQuantity > parent.Children[childName].Count))
                    {
                        childService = new OffnetServiceKey(child.Id)
                        {
                            EffectiveDate    = parent.EffectiveDate,
                            ParentServiceKey = parent,
                        };
                        childService.AddMissingAttributes();
                        childServices[0] = childService;
                    }
                    offnetHierarchy = new OffnetHierarchyWeb(childServices);
                    break;
                }
            }
            if (childService == null)
            {
                throw new ApplicationException($"{childName} can't be created on service {parent.Id}");
            }
            return(offnetHierarchy);
        }
        public static OffnetAttributeSourcesInfoWeb GetAttributes(OffnetServiceKey key, bool populateLists)
        {
            AttributeInfoWeb list;

            OffnetAttributeInfoWeb[]  info;
            OffnetAttributeSourceInfo source;

            OffnetAttributeSourceInfo[]   sources;
            OffnetAttributeSourcesInfoWeb infoWeb;

            if (key == null)
            {
                infoWeb = new OffnetAttributeSourcesInfoWeb {
                    ErrorString = "Key cannot be null"
                };
                return(infoWeb);
            }
            try
            {
                var    atts           = Get(key, populateLists);
                var    srcs           = OffnetDataAccess.GetOffnetAttributeSource(key);
                string name           = null;
                string value          = null;
                string partnerOrderId = null;
                info = new OffnetAttributeInfoWeb[atts.Count];
                var i = 0;
                foreach (var att in atts)
                {
                    name      = att.Name;
                    value     = att.GetValue();
                    list      = new AttributeInfoWeb(att);
                    info[i++] = new OffnetAttributeInfoWeb(name, value, list);
                    if (name == "PartnerOrderId")
                    {
                        partnerOrderId = value;
                    }
                }

                //var attributes= srcs.Where(x => x.PartnerOrderId.ToString() == partnerOrderId && x.OffnetServiceId == key.Id).Select(x => x.AttributeName).ToList();
                List <string> filteredSrcs = new List <string>();
                filteredSrcs = srcs.Where(x => x.PartnerOrderId.ToString() == partnerOrderId && x.OffnetServiceId == key.Id).Select(x => x.AttributeSource).Distinct().ToList();
                sources      = new OffnetAttributeSourceInfo[filteredSrcs.Count];
                var j = 0;

                foreach (var s in filteredSrcs)
                {
                    var attributes = new List <string>(srcs.Where(x => x.PartnerOrderId.ToString() == partnerOrderId && x.OffnetServiceId == key.Id && x.AttributeSource == s)
                                                       .Select(x => x.AttributeName).ToList());
                    Dictionary <string, string> keyValuePairs = new Dictionary <string, string>();
                    foreach (var a in attributes)
                    {
                        var attrList = info.ToList();
                        var v        = attrList.Where(x => x.AttributeProperties.Name.Equals(a)).Select(x => x.AttributeProperties.Value).FirstOrDefault();
                        keyValuePairs.Add(a, v);
                    }
                    source = new OffnetAttributeSourceInfo
                    {
                        Source          = s,
                        OffnetServiceId = key.Id,
                        PartnerOrderId  = partnerOrderId,
                        Attributes      = keyValuePairs
                    };
                    sources[j++] = source;
                }
                infoWeb = new OffnetAttributeSourcesInfoWeb(sources, info);
            }
            catch (Exception e)
            {
                infoWeb = new OffnetAttributeSourcesInfoWeb {
                    ErrorString = e.Message
                };
            }

            return(infoWeb);
        }
        public static ICollection <AttributeInfo> Get(OffnetServiceKey key, bool populateLists)
        {
            var config = OffnetServiceConfiguration.Get(key.Id, key.EffectiveDate);

            var list = ValidValueRuleParser.GetRules(config.ValidValueRule);

            var set = new ValidValueRuleSet();

            set.AddRules(list);

            var attributeSet = set.GetAttributes(key, SearchOptions.ALL_FALSE);
            //If we have an attribute with  no valid options, clear the value and try again...
            var emptyAttributes = (from a in attributeSet where a.Values == null || a.Values.Count == 0 select a.Name).ToList();

            if (emptyAttributes.Count > 0)
            {
                foreach (var a in emptyAttributes)
                {
                    key.RemoveAttribute(a);
                }
                attributeSet = set.GetAttributes(key, SearchOptions.ALL_FALSE);
            }

            IDictionary <string, AttributeInfo> tempList = new Dictionary <string, AttributeInfo>();

            foreach (var a in attributeSet)
            {
                tempList[a.Name] = a;
            }

            key.AddMissingAttributes();
            //Next we need to look if there are non-list items that need to be collected.
            foreach (var pair in config.Attributes)
            {
                AttributeInfo a = null;
                if (tempList.ContainsKey(pair.Key))
                {
                    tempList.TryGetValue(pair.Key, out a);
                }

                tempList[pair.Key] = AttributeFactory.CreateAttribute(pair.Value, pair.Key, a, key);
                if ((pair.Value.Type == AttributeType.Parent || pair.Value.Type == AttributeType.Related) &&
                    key.HasAttribute(pair.Key))
                {
                    tempList[pair.Key].SetValue(key.GetAttributeValue(pair.Key, SearchOptions.ALL_TRUE));
                }
            }


            var ruleSet = new OffnetServiceRuleSet();

            ruleSet.AddDefaults(key);  // add defaults so rules such as IsApplicable can use them

            //key doesn't have all the data we have generated so to use the latest we will build a ValueHolder that has what we need...
            string aValue;

            foreach (var a in tempList.Values)
            {
                aValue = a.GetValue();
                if (!string.IsNullOrEmpty(aValue)) // don't add empty values
                {
                    ruleSet.AddValue(a.Name, new RuleValue(aValue));
                }
            }
            //Determine which attributes we don't need
            var finalList = tempList.Values.Where(a => config.IsConfigurableAttribute(a.Name, ruleSet)).ToDictionary(a => a.Name);


            //Last we need to try and add a description to attributes that haven't had them added yet...
            //and flag them as optional or not.  We will also set the default value if there is one.
            foreach (var a in finalList.Values)
            {
                a.Optional = config.IsOptional(a.Name, ruleSet).ToString();

                a.Label = config.GetLabel(a.Name);
                if (config.HasDefault(a.Name))
                {
                    try
                    {
                        a.DefaultValue = config.GetDefaultValue(a.Name, key);
                    }
                    catch (Exception) { }
                }
                a.Hidden              = config.IsHidden(a.Name, key);
                a.MaxRepeats          = config.GetMaxRepeats(a.Name);
                a.RequiresRefresh     = config.GetRequiresRefresh(a.Name);
                a.ReadOnly            = config.IsReadOnly(a.Name, key);
                a.ApplicableForChange = config.GetApplicableForChange(a.Name);
                a.AffectsChildren     = config.AffectsChildren(a.Name);
                a.DesignImpact        = config.IsDesignImpact(a.Name, key);
                a.ProvisioningImpact  = config.IsProvisioningImpact(a.Name, key);

                var attribute = a as ListAttribute;
                if (attribute != null)
                {
                    var la = attribute;
                    if (populateLists && la.GetValue() != null && !la.ReadOnly && !la.Hidden)
                    {
                        //Since the value has been set, the list of options is empty.  If it is asked for, we will determine
                        //the list of options if this was not set.
                        var myKey = key.Clone(false);

                        myKey.AddValue(la.Name, null);
                        var myAtts = set.GetAttributes(myKey, SearchOptions.ALL_FALSE);

                        foreach (var av in
                                 from myAtt in myAtts
                                 where myAtt.Name.Equals(la.Name)
                                 from av in ((ListAttribute)myAtt).GetList()
                                 select av)
                        {
                            la.AddValue(av);
                        }
                    }
                }
            }

            return(config.SortList(finalList.Values));
        }