Exemplo n.º 1
0
        public OffnetServiceKey(OffnetServiceKeyWeb web)
            : this(web.ServiceID)
        {
            if (web.Attributes != null)
            {
                foreach (var ai in web.Attributes)
                {
                    if (ai.Value != null)
                    {
                        var a = new AttributeValue(ai.Value.Value, ai.Value.DisplayValue, new AttributeType(ai.Type));
                        AddValue(ai.Name, a);
                    }
                }
            }

            if (web.Date != null)
            {
                EffectiveDate = (DateTime)web.Date;
            }
            if (web.ParentServiceKey != null)
            {
                ParentServiceKey = new OffnetServiceKey(web.ParentServiceKey);
            }

            if (web.ChildServices != null || web.ChildServices.Count() > 0)
            {
                foreach (var child in web.ChildServices)
                {
                    Children.Add(child.Name, child.Services.Select(s => new OffnetServiceKey(s)).ToList());
                }
            }
        }
Exemplo n.º 2
0
        public OffnetServiceKeyWeb ToWeb()
        {
            var web = new OffnetServiceKeyWeb();
            int i;

            web.IsValid   = true;
            web.ServiceID = Id;
            web.Date      = EffectiveDate;

            if (ParentServiceKey != null)
            {
                web.ParentServiceKey = ParentServiceKey.ToWeb();
            }
            if (Values != null)
            {
                web.AttributesList = new Dictionary <string, string>();
                web.Attributes     = new OffnetAttrInstanceWeb[Values.Count];
                i = 0;
                foreach (var pair in Values)
                {
                    var a = pair.Value;
                    web.AttributesList.Add(pair.Key, a.Value);
                    web.Attributes[i++] = new OffnetAttrInstanceWeb(pair.Key, a.Value, a.DisplayValue, a.Type);
                }
            }
            web.ChildServices = new OffnetServiceCollectionWeb[Children.Count];
            i = 0;
            foreach (var child in Children)
            {
                web.ChildServices[i++] = new OffnetServiceCollectionWeb(child.Key, child.Value.Select(c => c.ToWeb()).ToArray());
            }
            i = 0;
            return(web);
        }
        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());
            }));
        }
Exemplo n.º 4
0
        public static OffnetServKeyPair FromString(string text)
        {
            int index = text.IndexOf('=');
            var sk    = new OffnetServKeyPair()
            {
                Name    = text.Substring(0, index - 1),
                Service = OffnetServiceKeyWeb.FromString(text.Substring(index + 1))
            };

            return(sk);
        }
        public void PomChildren()
        {
            Startup.LoadSettings();
            var key = new OffnetServiceKeyWeb();

            key.ServiceID     = 3;
            key.Date          = DateTime.Now;
            key.Attributes    = new OffnetAttrInstanceWeb[0];
            key.ChildServices = new OffnetServiceCollectionWeb[0];
            key.IsValid       = true;
            var url      = FscApplication.Current.Settings.FscUrls.FSCMediation + MediationEndPoints.pomChildren;
            var children = ApiClient.Post <List <OffnetServiceChildWeb>, OffnetServiceKeyWeb>
                               (HttpTargetType.FSCMediation, "FSC Mediation Pom Serv Children", url, key, ApiClient.ContentType.Json, ApiClient.HeaderType.FSCMediation);

            Assert.IsNotNull(children);
            Assert.IsTrue(children.Count > 0);
        }
        public void PomBuildChild()
        {
            //Assumes that service Id 3 has children
            Startup.LoadSettings();
            var key    = new BuildOffnetChildServiceRequestWeb();
            var parent = new OffnetServiceKeyWeb();

            parent.ServiceID     = 3;
            parent.Date          = DateTime.Now;
            parent.Attributes    = new OffnetAttrInstanceWeb[0];
            parent.ChildServices = new OffnetServiceCollectionWeb[0];
            parent.IsValid       = true;
            key.ParentService    = parent;
            key.Name             = "ASOG_UNI";
            var url       = FscApplication.Current.Settings.FscUrls.FSCMediation + MediationEndPoints.pomBuildChild;
            var hierarchy = ApiClient.Post <OffnetHierarchyWeb, BuildOffnetChildServiceRequestWeb>
                                (HttpTargetType.FSCMediation, "FSC Mediation Pom Serv BuildChild", url, key, ApiClient.ContentType.Json, ApiClient.HeaderType.FSCMediation);

            Assert.IsNotNull(hierarchy);
            Assert.IsTrue(hierarchy.Services.Length > 0);
        }
Exemplo n.º 7
0
 public OffnetServKeyPair(string name, OffnetServiceKeyWeb key)
 {
     Name    = name;
     Service = key;
 }
Exemplo n.º 8
0
        public static PartnerServPkg FromStringNew(string prodServPkgString)
        {
            PartnerServPkg partServPkg = null;
            int            index1, index2;

            if (prodServPkgString.StartsWith("PartnerServPkg:"))
            {
                partServPkg = new PartnerServPkg();

                PartnerKeyWeb key = null;
                index1       = prodServPkgString.IndexOf("VendorId");
                key.VendorId = Convert.ToInt32(prodServPkgString.Substring(index1 + 13, index1 - 13));

                index2         = prodServPkgString.IndexOf("VendorName =", index1);
                index1         = prodServPkgString.IndexOf(",", index2 + 2);
                key.VendorName = prodServPkgString.Substring(index2 + 8, index1 - index2 - 8);

                index2         = prodServPkgString.IndexOf("RequestType =", index1);
                index1         = prodServPkgString.IndexOf(",", index2 + 2);
                key.VendorName = prodServPkgString.Substring(index2 + 8, index1 - index2 - 8);

                index2         = prodServPkgString.IndexOf("PartnerOrderFormat =", index1);
                index1         = prodServPkgString.IndexOf(",", index2 + 2);
                key.VendorName = prodServPkgString.Substring(index2 + 8, index1 - index2 - 8);

                index2         = prodServPkgString.IndexOf("OrderAction =", index1);
                index1         = prodServPkgString.IndexOf(",", index2 + 2);
                key.VendorName = prodServPkgString.Substring(index2 + 8, index1 - index2 - 8);

                index2         = prodServPkgString.IndexOf("ProductFamily =", index1);
                index1         = prodServPkgString.IndexOf(",", index2 + 2);
                key.VendorName = prodServPkgString.Substring(index2 + 8, index1 - index2 - 8);

                index2         = prodServPkgString.IndexOf("PartnerOrderId =", index1);
                index1         = prodServPkgString.IndexOf(",", index2 + 2);
                key.VendorName = prodServPkgString.Substring(index2 + 8, index1 - index2 - 8);

                index2         = prodServPkgString.IndexOf("PartnerOrderName =", index1);
                index1         = prodServPkgString.IndexOf(",", index2 + 2);
                key.VendorName = prodServPkgString.Substring(index2 + 8, index1 - index2 - 8);

                partServPkg.Partner = key;
                //Need to add the logic for extracting services from string
                OffnetServKeyPair[] ServkeyPair = null;
                OffnetServiceKeyWeb ServKey     = null;
                int servIndex;
                servIndex = prodServPkgString.IndexOf("ServKey:");
                string servKeyString = prodServPkgString.Substring(servIndex, servIndex + prodServPkgString.IndexOf("]"));

                index1            = prodServPkgString.IndexOf("Service ID =");
                ServKey.ServiceID = long.Parse(prodServPkgString.Substring(index1 + 13, index1 - 13));

                index2       = prodServPkgString.IndexOf(",Date =", index1);
                index1       = prodServPkgString.IndexOf(',', index2 + 2);
                ServKey.Date = DateTime.Parse(prodServPkgString.Substring(index2 + 8, index1 - index2 - 8));

                index1 = prodServPkgString.IndexOf(",Attributes = [", index1);
                if (index1 > 0)
                {
                    index2 = prodServPkgString.IndexOf(']', index1);
                    string[] instances = prodServPkgString.Substring(index1 + 15, index2 - index1 - 16).Split(',');
                    List <OffnetAttrInstanceWeb> instanceList = new List <OffnetAttrInstanceWeb>();
                    foreach (string instance in instances)
                    {
                        instanceList.Add(OffnetAttrInstanceWeb.FromString(instance));
                    }
                    ServKey.Attributes = instanceList.ToArray();
                }

                index1          = prodServPkgString.IndexOf(",ErrorString = ", index2);
                ServKey.IsValid = bool.Parse(prodServPkgString.Substring(index2 + 11, index1 - index2 - 11));

                ServKey.ErrorString = prodServPkgString.Substring(index1 + 15);

                partServPkg.Services = ServkeyPair;
            }

            return(partServPkg);
        }