Пример #1
0
 public ReleaseCheckoutProfile(ReleaseCheckoutProfile other)
 {
     CheckoutProfile   = other.CheckoutProfile;
     TasksCount        = other.TasksCount;
     NotificationEmail = other.NotificationEmail;
     ClothesSizeSystem = other.ClothesSizeSystem;
     Size      = other.Size;
     VariantId = other.VariantId;
 }
Пример #2
0
 public CheckoutTaskCcProfile(ReleaseCheckoutProfile releaseCheckoutProfile, int maxCheckoutsCount)
 {
     m_releaseCheckoutProfile = releaseCheckoutProfile;
     m_maxCheckoutsCount      = maxCheckoutsCount;
     m_semaphore = new SemaphoreSlim(maxCheckoutsCount, maxCheckoutsCount);
 }
Пример #3
0
        public static Project LoadFromFile(string fileName)
        {
            Project project     = new Project();
            string  projectJson = File.ReadAllText(fileName);

            JObject projecJObject = JObject.Parse(projectJson);

            project.Name     = (string)projecJObject[PropertyHelper.GetPropertyName(() => project.Name)];
            project.FileName = fileName;

            foreach (JToken token in projecJObject[PropertyHelper.GetPropertyName(() => project.CheckoutProfiles)])
            {
                CheckoutProfile profile = new CheckoutProfile();

                profile.Name     = (string)token[PropertyHelper.GetPropertyName(() => profile.Name)];
                profile.Email    = (string)token[PropertyHelper.GetPropertyName(() => profile.Email)];
                profile.BuyLimit = (int)token[PropertyHelper.GetPropertyName(() => profile.BuyLimit)];

                JToken billingAddressToken = token[PropertyHelper.GetPropertyName(() => profile.BillingAddress)];

                Address billingAddress = new Address();
                billingAddress.FirstName          = (string)billingAddressToken[PropertyHelper.GetPropertyName(() => billingAddress.FirstName)];
                billingAddress.SecondName         = (string)billingAddressToken[PropertyHelper.GetPropertyName(() => billingAddress.SecondName)];
                billingAddress.StreetAddress1     = (string)billingAddressToken[PropertyHelper.GetPropertyName(() => billingAddress.StreetAddress1)];
                billingAddress.StreetAddressLine2 = (string)billingAddressToken[PropertyHelper.GetPropertyName(() => billingAddress.StreetAddressLine2)];
                billingAddress.PostalCode         = (string)billingAddressToken[PropertyHelper.GetPropertyName(() => billingAddress.PostalCode)];
                billingAddress.City        = (string)billingAddressToken[PropertyHelper.GetPropertyName(() => billingAddress.City)];
                billingAddress.Country     = CountriesCollection.Countries[(CountryCode)billingAddressToken[PropertyHelper.GetPropertyName(() => billingAddress.Country)].Value <int>()];
                billingAddress.State       = billingAddress.Country.States.ElementAtOrDefault((int)billingAddressToken[PropertyHelper.GetPropertyName(() => billingAddress.State)]);
                billingAddress.PhoneNumber = (string)billingAddressToken[PropertyHelper.GetPropertyName(() => billingAddress.PhoneNumber)];

                profile.BillingAddress = billingAddress;

                JToken shippingAddressToken = token[PropertyHelper.GetPropertyName(() => profile.ShippingAddress)];

                Address shippingAddress = new Address();
                shippingAddress.FirstName          = (string)shippingAddressToken[PropertyHelper.GetPropertyName(() => shippingAddress.FirstName)];
                shippingAddress.SecondName         = (string)shippingAddressToken[PropertyHelper.GetPropertyName(() => shippingAddress.SecondName)];
                shippingAddress.StreetAddress1     = (string)shippingAddressToken[PropertyHelper.GetPropertyName(() => shippingAddress.StreetAddress1)];
                shippingAddress.StreetAddressLine2 = (string)shippingAddressToken[PropertyHelper.GetPropertyName(() => shippingAddress.StreetAddressLine2)];
                shippingAddress.PostalCode         = (string)shippingAddressToken[PropertyHelper.GetPropertyName(() => shippingAddress.PostalCode)];
                shippingAddress.City        = (string)shippingAddressToken[PropertyHelper.GetPropertyName(() => shippingAddress.City)];
                shippingAddress.Country     = CountriesCollection.Countries[(CountryCode)shippingAddressToken[PropertyHelper.GetPropertyName(() => shippingAddress.Country)].Value <int>()];
                shippingAddress.State       = shippingAddress.Country.States.ElementAtOrDefault((int)shippingAddressToken[PropertyHelper.GetPropertyName(() => shippingAddress.State)]);
                shippingAddress.PhoneNumber = (string)shippingAddressToken[PropertyHelper.GetPropertyName(() => shippingAddress.PhoneNumber)];

                profile.ShippingAddress     = shippingAddress;
                profile.IsShippingAsBilling = (bool)token[PropertyHelper.GetPropertyName(() => profile.IsShippingAsBilling)];

                JToken payCardToken = token[PropertyHelper.GetPropertyName(() => profile.PayCard)];

                PayCard payCard = new PayCard();
                payCard.Number         = (string)payCardToken[PropertyHelper.GetPropertyName(() => payCard.Number)];
                payCard.Holder         = (string)payCardToken[PropertyHelper.GetPropertyName(() => payCard.Holder)];
                payCard.ExpirationDate = payCardToken[PropertyHelper.GetPropertyName(() => payCard.ExpirationDate)].ToObject <DateTime>();
                payCard.CVS            = (string)payCardToken[PropertyHelper.GetPropertyName(() => payCard.CVS)];
                payCard.Type           = PayCardTypeCollection.TypesDictionary[(PayCardTypeCode)payCardToken[PropertyHelper.GetPropertyName(() => payCard.Type)].ToObject <int>()];

                profile.PayCard = payCard;

                project.CheckoutProfiles.Add(profile);
            }

            foreach (JToken token in projecJObject[PropertyHelper.GetPropertyName(() => project.Releases)])
            {
                Release release = new Release();

                release.Name        = (string)token[PropertyHelper.GetPropertyName(() => release.Name)];
                release.Footsite    = FootsiteCollection.SitesDictionary[(FootsiteType)token[PropertyHelper.GetPropertyName(() => release.Footsite)].ToObject <int>()];
                release.ProductLink = (string)token[PropertyHelper.GetPropertyName(() => release.ProductLink)];
                release.Category    = (string)token[PropertyHelper.GetPropertyName(() => release.Category)];

                foreach (string keyword in JsonConvert.DeserializeObject <List <string> >(token[PropertyHelper.GetPropertyName(() => release.KeyWords)].ToString()))
                {
                    release.KeyWords.Add(keyword);
                }

                release.Style = (string)token[PropertyHelper.GetPropertyName(() => release.Style)];
                string globalProxyStr = (string)token[PropertyHelper.GetPropertyName(() => release.GlobalProxy)];
                release.GlobalProxy = globalProxyStr != null ? new Proxy(globalProxyStr) : null;

                //try
                //{
                //    if (release.CaptchaHarvester != null)
                //    {
                //        release.CaptchaHarvester.TwoCaptchaApiKey =
                //            token[PropertyHelper.GetPropertyName(() => release.CaptchaHarvester)][
                //                    PropertyHelper.GetPropertyName(() => release.CaptchaHarvester.TwoCaptchaApiKey)]
                //                .Value<string>();
                //    }
                //}
                //catch (Exception e)
                //{

                //}

                foreach (JToken profileJToken in token[PropertyHelper.GetPropertyName(() => release.Profiles)])
                {
                    ReleaseCheckoutProfile profile = new ReleaseCheckoutProfile();

                    profile.CheckoutProfile   = project.CheckoutProfiles[(int)profileJToken[PropertyHelper.GetPropertyName(() => profile.CheckoutProfile)]];
                    profile.TasksCount        = (int)profileJToken[PropertyHelper.GetPropertyName(() => profile.TasksCount)];;
                    profile.NotificationEmail = (string)profileJToken[PropertyHelper.GetPropertyName(() => profile.NotificationEmail)];
                    profile.ClothesSizeSystem = ClothesSizeSystemCollection.SystemsDictionary[(ClothesSizeSystemCode)profileJToken[PropertyHelper.GetPropertyName(() => profile.ClothesSizeSystem)].ToObject <int>()];
                    profile.Size      = (string)profileJToken[PropertyHelper.GetPropertyName(() => profile.Size)];
                    profile.VariantId = (string)profileJToken[PropertyHelper.GetPropertyName(() => profile.VariantId)];

                    release.Profiles.Add(profile);
                }

                foreach (JToken proxyJToken in token[PropertyHelper.GetPropertyName(() => release.Proxies)])
                {
                    Proxy proxy = new Proxy(proxyJToken.Value <string>());

                    release.Proxies.Add(proxy);
                }

                project.Releases.Add(release);
            }

            return(project);
        }