public ObjectResult ResolveOffnetServices(PartnerServPkg postData)
        {
            return(WebFunction.Execute <PartnerServPkg, PartnerServPkg>(this, postData, (osp) =>
            {
                string error;
                PartnerServPkg pkg;

                try
                {
                    var NewOsp = OffnetBiz.ResolveOffnet(osp.GetPartnerServicePackage(), out error);
                    pkg = new PartnerServPkg(NewOsp);
                }
                catch (Exception e)
                {
                    if (e.Data.Contains("Custom Msg"))
                    {
                        pkg = new PartnerServPkg {
                            ErrorString = e.Data["Custom Msg"].ToString() + e.Message, IsValid = false
                        };
                    }
                    else
                    {
                        pkg = new PartnerServPkg {
                            ErrorString = e.Message, IsValid = false
                        };
                    }
                }
                return new WebResult <PartnerServPkg>(pkg);
            }));
        }
Exemple #2
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 AddRules(PartnerKeyWeb key)
        {
            var rules = OffnetServiceRuleParser.GetRules(OffnetBiz.GetPartnerServiceConfig(key).ServiceRule, Utility.ConvertToMountain(key.EffectiveDate));

            if (rules != null)
            {
                foreach (var r in rules)
                {
                    AddRule(r, key, this);
                }
            }
        }
Exemple #4
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);
            }
        }
        public PartnerServicePackage ApplyRules(PartnerServicePackage package)
        {
            //Validate partner

            var key = package.Partner;

            if (key == null)
            {
                throw new ApplicationException("Missing Partner!");
            }
            if ((key.PartnerOrderId == 0 || String.IsNullOrEmpty(key.PartnerOrderName)) || string.IsNullOrEmpty(OffnetBiz.GetPartnerServiceConfig(key).ServiceRule))
            {
                return(package);                                                                                                                                                     //If there are no rules, there is nothing to do.
            }
            AddRules(key);

            // For all the existing services, move them into the rule set so they can be used by the rules...
            if (package.Services != null)
            {
                foreach (var pair in package.Services)
                {
                    _existingServices.Add(pair.Key, pair.Value);
                }
            }
            //Run through the rules...
            _serviceRules = _serviceRules.ToList();
            foreach (var rule in _serviceRules)
            {
                try
                {
                    rule.Apply(package, this);
                }
                catch (Exception e)
                {
                    throw new Exception(e.Message + ", Partner " + package?.Partner?.PartnerOrderName + ", Rule: " + rule, e);
                }
            }

            //Any left over services need to be removed from package.
            foreach (var pair in _existingServices)
            {
                var sKey = pair.Value;
                package.AddService(pair.Key, sKey);
            }

            return(package);
        }