Ejemplo n.º 1
0
        public static PartnerServPkg FromString(string prodServPkgString)
        {
            PartnerServPkg partServPkg = null;
            int            index, index2;

            if (prodServPkgString.IndexOf("ParentProduct = [") > 0)
            {
                return(FromStringNew(prodServPkgString));
            }

            if (prodServPkgString.StartsWith("PartnerServPkg:"))
            {
                partServPkg         = new PartnerServPkg();
                index               = prodServPkgString.IndexOf("PartnerServPkg:");
                partServPkg.Partner = PartnerKeyWeb.FromString(prodServPkgString.Substring(29, index - 29));

                prodServPkgString = prodServPkgString.Substring(index + 18);
                // todo: write code for Services here

                index  = prodServPkgString.IndexOf(",IsValid =");
                index2 = prodServPkgString.IndexOf(",ErrorString =");
                partServPkg.IsValid     = bool.Parse(prodServPkgString.Substring(index + 11, index2 - index - 11));
                partServPkg.ErrorString = prodServPkgString.Substring(index2 + 15);
            }

            return(partServPkg);
        }
Ejemplo n.º 2
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);
        }