/// <summary>
        /// Gets the item field template.
        /// </summary>
        /// <param name="viewField">The view field.</param>
        /// <returns></returns>
        protected virtual ITemplate GetItemFieldTemplate(Field viewField)
        {
            switch (viewField.Type)
            {
            case "Boolean":
            case "AllDayEvent":
                return(new BooleanFieldValueTemplate(viewField));

            case "Number":
                return(new NumberFieldValueTemplate(viewField));

            case "URL":
                return(new LinkFieldValueTemplate(viewField));

            case "Currency":
                return(new FieldValueTemplate(viewField, this.folderPath.ClientID, MainUtil.GetInt(viewField["LCID"], 1033), "{0:C}"));
            }

            switch (viewField.Name)
            {
            case "FileSizeDisplay":
                return(new FileSizeFieldValueTemplate(viewField, this.folderPath.ClientID));
            }

            return(new FieldValueTemplate(viewField, this.folderPath.ClientID));
        }
    private bool IsValid(string currentItemTemplateId)
    {
        var validatorParameters = Parameters;

        // parsing all validators,they are splited by & char
        foreach (var currentParam in validatorParameters)
        {
            //checking if current item template id is in parameters value
            if (currentParam.Value.Contains(currentItemTemplateId))
            {
                if (currentParam.Value.Contains(TemplateLengthSeparator))
                {
                    var maxLenghKeyValuePair = currentParam.Value.Split(TemplateLengthSeparator)[1];
                    if (maxLenghKeyValuePair.Contains(FieldLengthSeparator))
                    {
                        var    maxLengthValue         = maxLenghKeyValuePair.Split(FieldLengthSeparator)[1];
                        int    intMaxLengthValue      = MainUtil.GetInt(maxLengthValue, 0);
                        string controlValidationValue = this.ControlValidationValue;
                        if (string.IsNullOrEmpty(controlValidationValue) ||
                            controlValidationValue.Length <= intMaxLengthValue)
                        {
                            return(true);
                        }
                        else
                        {
                            Text = GetText("The maximum length of the field \"{0}\" is {1} characters.", this.GetFieldDisplayName(), maxLengthValue);
                            return(false);
                        }
                    }
                }
            }
        }
        return(true);
    }
Exemple #3
0
        protected virtual void ParseNode(SafeDictionary <string> attributes)
        {
            Assert.ArgumentNotNull(attributes, "attributes");
            var str = Extract(attributes, "outputMethod");

            xhtml     = str == "xhtml" || Settings.Rendering.ImagesAsXhtml && str != "html";
            source    = Extract(attributes, "src");
            alt       = Extract(attributes, "alt");
            border    = Extract(attributes, "border");
            hspace    = Extract(attributes, "hspace");
            vspace    = Extract(attributes, "vspace");
            className = Extract(attributes, "class");
            if (string.IsNullOrEmpty(border) && !xhtml)
            {
                border = "0";
            }
            allowStretch      = MainUtil.GetBool(Extract(attributes, ref asSet, "allowStretch", "as"), false);
            ignoreAspectRatio = MainUtil.GetBool(Extract(attributes, "ignoreAspectRatio", "iar"), false);
            width             = MainUtil.GetInt(Extract(attributes, ref widthSet, "width", "w"), 0);
            height            = MainUtil.GetInt(Extract(attributes, ref heightSet, "height", "h"), 0);
            scale             = MainUtil.GetFloat(Extract(attributes, ref scaleSet, "scale", "sc"), 0.0f);
            maxWidth          = MainUtil.GetInt(Extract(attributes, ref maxWidthSet, "maxWidth", "mw"), 0);
            maxHeight         = MainUtil.GetInt(Extract(attributes, ref maxHeightSet, "maxHeight", "mh"), 0);
            thumbnail         = MainUtil.GetBool(Extract(attributes, ref thumbnailSet, "thumbnail", "thn"), false);
            backgroundColor   = Extract(attributes, "backgroundColor", "bc") ?? string.Empty;
            database          = Extract(attributes, "database", "db");
            language          = Extract(attributes, "language", "la");
            version           = Extract(attributes, "version", "vs");
            disableMediaCache = MainUtil.GetBool(Extract(attributes, ref disableMediaCacheSet, "disableMediaCache"), false);
        }
Exemple #4
0
 /// <summary>
 /// Translates to shipping option.
 /// </summary>
 /// <param name="shippingOptionItem">The shipping option item.</param>
 /// <param name="shippingOption">The shipping option.</param>
 protected virtual void TranslateToShippingOption(Item shippingOptionItem, ShippingOption shippingOption)
 {
     shippingOption.ExternalId         = shippingOptionItem.ID.Guid.ToString();
     shippingOption.Name               = shippingOptionItem[CommerceServerStorefrontConstants.KnownFieldNames.Value];
     shippingOption.ShopName           = this.GetShopName();
     shippingOption.ShippingOptionType = MainUtil.GetInt(shippingOptionItem[CommerceServerStorefrontConstants.KnownFieldNames.ShippingOptionValue], 0);
 }
        public DataSetItemModel GetDataSetItemModel(string id)
        {
            var item  = _database.GetItem(id);
            var model = new DataSetItemModel();

            if (item != null)
            {
                model.MaxKeysPerSegment = MainUtil.GetInt(item["Max Keys Per Segment"], DefaultMaxKeysPerSegment);
                model.TimeResolution    = ReadTimeResolution(StringUtil.GetString(item["Time Resolution"], WeeklyTimeResolution));

                var segmentsField = (MultilistField)item.Fields["Segments"];

                if (segmentsField != null)
                {
                    model.Segments.AddRange(segmentsField.TargetIDs);
                }
                else
                {
                    Log.Warn($"[DataStudio] Could not load segments field from item '{item.Paths.Path}'", this);
                }
            }
            else
            {
                Log.Warn($"[DataStudio] Could not load data set item '{id}'", this);
            }

            return(model);
        }
        /// <summary>
        /// Arranges the system sites.
        /// </summary>
        public static void ArrangeSitesContext()
        {
            // Change items index
            if (SystemSiteDefinitions != null)
            {
                using (new EventDisabler())
                {
                    Items.MoveLast(SystemSiteDefinitions);
                }
            }

            SitesOrders.Clear();

            // Store indexes for using by comparer
            foreach (var site in SiteDefinitions)
            {
                SitesOrders[site.Name] = MainUtil.GetInt(site["__Sortorder"], 0);
            }

            // Sort sites context
            lock (SiteContextFactory.Sites)
            {
                SiteContextFactory.Sites.Sort(new SiteComparer());
            }
        }
        private void ParseParameters(string source)
        {
            var parameters = new UrlString(source);

            if (!string.IsNullOrEmpty(parameters.Parameters[FROM_FIELD_NAME]))
            {
                From = MainUtil.GetInt(parameters.Parameters[FROM_FIELD_NAME], 0);
            }
            else
            {
                From = 1;
            }

            if (!string.IsNullOrEmpty(parameters.Parameters[TO_FIELD_NAME]))
            {
                To = MainUtil.GetInt(parameters.Parameters[TO_FIELD_NAME], 100);
            }
            else
            {
                To = 100;
            }
            // TO SHOW RAW VALUES
            if (!string.IsNullOrEmpty(parameters.Parameters[IS_DEBUG_FIELD_NAME]))
            {
                IsDebug = MainUtil.GetBool(parameters.Parameters[IS_DEBUG_FIELD_NAME], false);
            }
        }
        /// <summary>
        /// Executes the specified rule context.
        /// </summary>
        /// <param name="ruleContext">The rule context.</param>
        /// <returns>Returns value indicating whether Device Screen Height matches Value or not</returns>
        protected override bool Execute(T ruleContext)
        {
            Assert.ArgumentNotNull(ruleContext, "ruleContext");
            int height = HttpContext.Current.Request.Browser.ScreenPixelsHeight;

            return(Compare(MainUtil.GetInt(height, 1024)));
        }
        /// <summary>
        /// Executes the specified rule context.
        /// </summary>
        /// <param name="ruleContext">The rule context.</param>
        /// <returns>Returns value indicating whether Device Screen Height matches Value or not</returns>
        protected override bool Execute(T ruleContext)
        {
            Assert.ArgumentNotNull(ruleContext, "ruleContext");
            int width = HttpContext.Current.Request.Browser.ScreenPixelsWidth;

            return(Compare(MainUtil.GetInt(width, 768)));
        }
        protected void PageSize_Change()
        {
            string str  = Context.ClientPage.ClientRequest.Form["PageSize"];
            int    @int = MainUtil.GetInt(str, 10);

            this.PageSize = @int;
            this.Refresh();
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="CurrencyInformationModel"/> class.
 /// </summary>
 /// <param name="item">The item.</param>
 public CurrencyInformationModel(Item item)
 {
     this.Name           = item.Name;
     this.Description    = item[StorefrontConstants.KnownFieldNames.CurrencyDescription];
     this.Symbol         = item[StorefrontConstants.KnownFieldNames.CurrencySymbol];
     this.SymbolPosition = MainUtil.GetInt(item[StorefrontConstants.KnownFieldNames.CurrencySymbolPosition], 3);
     this.CurrencyNumberFormatCulture = item[StorefrontConstants.KnownFieldNames.CurrencyNumberFormatCulture];
 }
Exemple #12
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DatabaseHealthCheck"/> class.
        /// </summary>
        /// <param name="item">The item.</param>
        public QueueCheck(Item item) : base(item)
        {
            this.Database = item["Database"];
            this.Table    = item["Table"];

            this.WarnCount  = MainUtil.GetInt(item["Warn Count"], 100);
            this.ErrorCount = MainUtil.GetInt(item["Error Count"], 100);
        }
        /// <summary>
        /// When overridden in a derived class, this method contains the code to determine whether the value in the input control is valid.
        /// </summary>
        /// <returns>The result of the evaluation.</returns>
        protected override ValidatorResult Evaluate()
        {
            int   minWidth    = MainUtil.GetInt(Parameters["MinWidth"], 0);
            int   minHeight   = MainUtil.GetInt(Parameters["MinHeight"], 0);
            int   maxWidth    = MainUtil.GetInt(Parameters["MaxWidth"], int.MaxValue);
            int   maxHeight   = MainUtil.GetInt(Parameters["MaxHeight"], int.MaxValue);
            float aspectRatio = MainUtil.GetFloat(Parameters["AspectRatio"], 0.00f);

            if (ItemUri != null)
            {
                if (MediaItem == null)
                {
                    return(ValidatorResult.Valid);
                }

                int width  = MainUtil.GetInt(MediaItem.InnerItem["Width"], 0);
                int height = MainUtil.GetInt(MediaItem.InnerItem["Height"], 0);

                if (minWidth == maxWidth && minHeight == maxHeight && (width != minWidth || height != minHeight))
                {
                    return(GetResult("The image referenced in the Image field \"{0}\" does not match the size requirements. Image needs to be exactly {1}x{2} but is {3}x{4}",
                                     GetField().DisplayName, minWidth.ToString(), minHeight.ToString(), width.ToString(),
                                     height.ToString()));
                }

                if (aspectRatio != 0.00f && height != 0 && (Math.Round((double)width / height, 2) != Math.Round(aspectRatio, 2)))
                {
                    return(GetResult("The image referenced in the Image field \"{0}\" has an invalid aspect ratio. The aspect ratio needs to be {1} but is {2}.",
                                     GetField().DisplayName, Math.Round(aspectRatio, 2).ToString(),
                                     (Math.Round((double)width / height, 2).ToString())));
                }

                if (width < minWidth)
                {
                    return(GetResult("The image referenced in the Image field \"{0}\" is too small. The width needs to be at least {1} pixels but is {2}.",
                                     GetField().DisplayName, minWidth.ToString(), width.ToString()));
                }

                if (height < minHeight)
                {
                    return(GetResult("The image referenced in the Image field \"{0}\" is too small. The height needs to be at least {1} pixels but is {2}.",
                                     GetField().DisplayName, minHeight.ToString(), height.ToString()));
                }

                if (width > maxWidth)
                {
                    return(GetResult("The image referenced in the Image field \"{0}\" is too big. The width needs to at most {1} pixels but is {2}.",
                                     GetField().DisplayName, maxWidth.ToString(), width.ToString()));
                }

                if (height > maxHeight)
                {
                    return(GetResult("The image referenced in the Image field \"{0}\" is too big. The height needs to be at most {1} pixels but is {2}.",
                                     GetField().DisplayName, maxHeight.ToString(), height.ToString()));
                }
            }
            return(ValidatorResult.Valid);
        }
        // Enable/Disable button... This is as close as I could get without copy and pasting all the private methods... this does not get called on refresh and does not check all the conditions... but good enough I think
        protected new void OnRenderingClick(string index)
        {
            Assert.ArgumentNotNull(index, "index");

            var i = MainUtil.GetInt(index, -1);

            this.btnPrefab.Disabled = i < 0;

            base.OnRenderingClick(index);
        }
        /// <summary>
        /// Gets the cache settings.
        /// </summary>
        /// <param name="pollVotesCacheSettingID">The poll votes cache setting ID.</param>
        /// <returns></returns>
        public int GetCacheSettings(ID pollVotesCacheSettingID)
        {
            var settingsItem = PollConstants.DatabaseContext.GetItem(PollConstants.PollVotesCacheSettings);

            if (settingsItem != null)
            {
                return(MainUtil.GetInt(settingsItem[pollVotesCacheSettingID], 0));
            }
            return(0);
        }
Exemple #16
0
        /// <summary>
        /// Translates to payment option.
        /// </summary>
        /// <param name="paymentOptionItem">The payment option item.</param>
        /// <param name="paymentOption">The payment option.</param>
        /// <param name="result">The result.</param>
        protected virtual void TranslateToPaymentOption(Item paymentOptionItem, PaymentOption paymentOption, GetPaymentOptionsResult result)
        {
            paymentOption.ExternalId = paymentOptionItem.ID.Guid.ToString();
            paymentOption.Name       = paymentOptionItem.DisplayName;
            paymentOption.ShopName   = this.GetShopName();

            int enumValue = MainUtil.GetInt(paymentOptionItem[CommerceServerStorefrontConstants.KnownFieldNames.PaymentOptionValue], 0);

            paymentOption.PaymentOptionType = this.TranslatePaymentOptionType(enumValue, result);
        }
        /// <summary>
        /// Gets the rendering definition.
        /// </summary>
        /// <returns>
        /// The rendering definition.
        /// </returns>
        private RenderingDefinition GetRenderingDefinition()
        {
            ArrayList renderings = GetLayoutDefinition().GetDevice(DeviceId).Renderings;

            if (renderings == null)
            {
                return(null);
            }
            return(renderings[MainUtil.GetInt(SelectedIndex, 0)] as RenderingDefinition);
        }
        /// <summary>
        /// Translates to shipping option.
        /// </summary>
        /// <param name="shippingOptionItem">The shipping option item.</param>
        /// <param name="shippingOptionType">Type of the shipping option.</param>
        /// <param name="shippingOption">The shipping option.</param>
        protected virtual void TranslateToShippingOption(Item shippingOptionItem, Item shippingOptionType, ShippingOption shippingOption)
        {
            var fulfillmentOptionTypeString = shippingOptionType[Sitecore.Commerce.Constants.Templates.FulfillmentOptionType.Fields.TypeID];

            Assert.IsNotNullOrEmpty(fulfillmentOptionTypeString, string.Format(CultureInfo.InvariantCulture, "The Fulfillment Option Type item is not defined. ID: {0}", fulfillmentOptionTypeString));

            shippingOption.ExternalId         = shippingOptionItem.ID.Guid.ToString();
            shippingOption.Name               = shippingOptionItem[CommerceServerStorefrontConstants.KnownFieldNames.Title];
            shippingOption.ShopName           = this.GetShopName();
            shippingOption.ShippingOptionType = MainUtil.GetInt(shippingOptionType[Sitecore.Commerce.Constants.Templates.FulfillmentOptionType.Fields.TypeID], 0);
        }
        protected virtual CustomGetRecommendedProductsArgs GetRecommendedProductsPipelineArgs(
            CustomGetRecommendedProductsArgs args = null)
        {
            CustomGetRecommendedProductsArgs recommendedProductsArgs = args ?? new CustomGetRecommendedProductsArgs();
            Rendering rendering = RenderingContext.CurrentOrNull.ValueOrDefault(context => context.Rendering);

            recommendedProductsArgs.ProductsQuery = rendering?.Item.Fields["Products query"]?.Value;
            recommendedProductsArgs.MaxNumberOfRecommendedProducts = MainUtil.GetInt(rendering?.Item.Fields["Max number of recommended products"]?.Value, 4);
            recommendedProductsArgs.RelationshipFieldName          = rendering?.Item.Fields["Related products fields name"]?.Value;
            recommendedProductsArgs.Tag = rendering.Parameters["Tag"];
            return(recommendedProductsArgs);
        }
Exemple #20
0
        public void ItemIndexerByFieldId_AfterIntAdd_ReturnsAddedValue(string fieldName, int addedFieldValue, ID fieldId)
        {
            // Arrange
            var fakeItem = new FakeItem();

            fakeItem.Add(fieldId, fieldName, addedFieldValue);
            Item item = fakeItem;

            // Act
            var actualFieldValue = MainUtil.GetInt(item[fieldId], 0);

            // Assert
            actualFieldValue.Should().Be(addedFieldValue);
        }
        /// <summary>
        /// Add shipping optin by configuration setting
        /// </summary>
        /// <param name="configNode">The configuration node.</param>
        public virtual void AddPaymentOption(XmlNode configNode)
        {
            Assert.ArgumentNotNull(configNode, "configNode");

            string value = XmlUtil.GetAttribute("value", configNode);

            Assert.IsNotNullOrEmpty(value, "value");

            int key = MainUtil.GetInt(value, 0);

            if (!this.PaymentOptionList.ContainsKey(key))
            {
                var paymentOption = new PaymentOption();

                switch (key)
                {
                case 1:
                    paymentOption.PaymentOptionType = PaymentOptionType.PayCard;
                    paymentOption.Name        = Globalization.Translate.Text(Texts.PayCard);
                    paymentOption.Description = Globalization.Translate.Text(Texts.PayCard);
                    break;

                case 2:
                    paymentOption.PaymentOptionType = PaymentOptionType.PayLoyaltyCard;
                    paymentOption.Name        = Globalization.Translate.Text(Texts.PayLoyaltyCard);
                    paymentOption.Description = Globalization.Translate.Text(Texts.PayLoyaltyCard);
                    break;

                case 3:
                    paymentOption.PaymentOptionType = PaymentOptionType.PayGiftCard;
                    paymentOption.Name        = Globalization.Translate.Text(Texts.PayGiftCard);
                    paymentOption.Description = Globalization.Translate.Text(Texts.PayGiftCard);
                    break;

                case 4:
                    paymentOption.PaymentOptionType = NopPaymentOptionType.OnlinePayment;
                    paymentOption.Name        = Globalization.Translate.Text(Texts.OnlinePayment);
                    paymentOption.Description = Globalization.Translate.Text(Texts.OnlinePayment);
                    break;

                case 0:
                    paymentOption.PaymentOptionType = PaymentOptionType.None;
                    paymentOption.Name        = Globalization.Translate.Text(Texts.NoPaymentPreference);
                    paymentOption.Description = Globalization.Translate.Text(Texts.NoPaymentPreference);
                    break;
                }

                this.PaymentOptionList[key] = paymentOption;
            }
        }
Exemple #22
0
 protected void OnRenderingClick(string index)
 {
     Assert.ArgumentNotNull(index, "index");
     if (this.SelectedIndex >= 0)
     {
         SheerResponse.SetStyle(StringUtil.GetString(this.Controls[this.SelectedIndex]), "background", string.Empty);
     }
     this.SelectedIndex = MainUtil.GetInt(index, -1);
     if (this.SelectedIndex >= 0)
     {
         SheerResponse.SetStyle(StringUtil.GetString(this.Controls[this.SelectedIndex]), "background", "#D0EBF6");
     }
     this.UpdateRenderingsCommandsState();
 }
Exemple #23
0
 protected void OnColumnClick(string index)
 {
     Assert.ArgumentNotNull(index, "index");
     //deselect current
     if (SelectedIndex >= 0)
     {
         SheerResponse.SetStyle(StringUtil.GetString(Controls[SelectedIndex]), "background", string.Empty);
     }
     //select current
     SelectedIndex = MainUtil.GetInt(index, -1);
     if (SelectedIndex >= 0)
     {
         SheerResponse.SetStyle(StringUtil.GetString(Controls[SelectedIndex]), "background", "#EDB078");
     }
 }
        protected virtual PlayerProperties GetPlayerProperties()
        {
            //TODO:var item = this.GetItem();
            //IPlayerMarkupGenerator generator = MediaFrameworkContext.GetPlayerMarkupGenerator(item);

            return(new PlayerProperties
            {
                ItemId = this.SourceItemID,
                //TODO:Template = item.TemplateID,
                //MediaId = generator.GetMediaId(item),
                PlayerId = new ID(this.PlayersList.Value),
                Width = MainUtil.GetInt(this.WidthInput.Value, MediaFrameworkContext.DefaultPlayerSize.Width),
                Height = MainUtil.GetInt(this.HeightInput.Value, MediaFrameworkContext.DefaultPlayerSize.Height)
            });
        }
Exemple #25
0
        private GetLogItem ReadItem([NotNull] StreamReader reader, [NotNull] FileInfo file, DateTime date)
        {
            Debug.ArgumentNotNull(reader, nameof(reader));
            Debug.ArgumentNotNull(file, nameof(file));

            if (Eof(reader))
            {
                return(null);
            }

            var line = ReadLine(reader);

            if (line == null)
            {
                return(null);
            }

            if (line.StartsWith("ManagedPoolThread"))
            {
                return(ReadManagedPoolThread(reader, file, date, line));
            }

            if (line.EndsWith("INFO  **************************************************"))
            {
                return(ReadSitecoreShutDown(reader, file, date));
            }

            if (line.IndexOf("**********************************************************************", StringComparison.Ordinal) >= 0)
            {
                return(ReadSitecoreStarted(reader, file, date, line));
            }

            var n = line.IndexOf(' ');

            if (n > 0)
            {
                var threadString = line.Left(n);

                if (MainUtil.GetInt(threadString, -1) >= 0)
                {
                    return(ReadThreadItem(reader, file, date, line));
                }
            }

            return(null);
        }
        private static HtmlTag ApplyDynamicPlaceholderSyntax(SitecoreHelper helper, HtmlTag tag)
        {
            var match = DynamicPlaceholderRegex.Match(tag.Text);

            if (match.Success)
            {
                var placeholderKey = match.Groups["placeholderKey"].Value;
                var parameters     = ParseParameters(match.Groups["parameters"].Value);
                var count          = MainUtil.GetInt(parameters["count"], 1);
                var maxCount       = MainUtil.GetInt(parameters["maxCount"], 0);
                var seed           = MainUtil.GetInt(parameters["seed"], 0);
                var placeholder    = helper.DynamicPlaceholder(placeholderKey, count, maxCount, seed).ToString();
                tag.Text = DynamicPlaceholderRegex.Replace(tag.Text, placeholder);
            }

            return(tag);
        }
        /// <summary>
        /// Translates to payment option.
        /// </summary>
        /// <param name="paymentOptionItem">The payment option item.</param>
        /// <param name="paymentOption">The payment option.</param>
        /// <param name="result">The result.</param>
        protected virtual void TranslateToPaymentOption(Item paymentOptionItem, PaymentOption paymentOption, GetPaymentOptionsResult result)
        {
            paymentOption.ExternalId  = paymentOptionItem.ID.Guid.ToString();
            paymentOption.Name        = paymentOptionItem.DisplayName;
            paymentOption.Description = paymentOptionItem.DisplayName;
            paymentOption.ShopName    = this.GetShopName();

            var paymentOptionTypeId = paymentOptionItem[Sitecore.Commerce.Constants.Templates.PaymentOption.Fields.PaymentOptionType];

            var paymentOptionTypeItem = Sitecore.Context.Database.GetItem(paymentOptionTypeId);

            Assert.IsNotNull(paymentOptionTypeItem, string.Format(CultureInfo.InvariantCulture, "The Payment Option Type is undefined in Sitecore.  ID: {0}", paymentOptionTypeId));

            int enumValue = MainUtil.GetInt(paymentOptionTypeItem[CommerceServerStorefrontConstants.KnownFieldNames.TypeId], 0);

            paymentOption.PaymentOptionType = this.TranslatePaymentOptionType(enumValue, result);
        }
Exemple #28
0
        /// <summary>
        /// Add shipping optin by configuration setting
        /// </summary>
        /// <param name="configNode">The configuration node.</param>
        public virtual void AddShippingOption(XmlNode configNode)
        {
            Assert.ArgumentNotNull(configNode, "configNode");

            string value = XmlUtil.GetAttribute("value", configNode);

            Assert.IsNotNullOrEmpty(value, "value");

            int key = MainUtil.GetInt(value, 0);

            if (!this.ShippingOptionList.ContainsKey(key))
            {
                var shippingOption = new ShippingOption();

                switch (key)
                {
                case 1:
                    shippingOption.ShippingOptionType = ShippingOptionType.ShipToAddress;
                    shippingOption.Name        = Globalization.Translate.Text(Texts.ShipToNewAddress);
                    shippingOption.Description = Globalization.Translate.Text(Texts.ShipToNewAddress);
                    break;

                case 2:
                    shippingOption.ShippingOptionType = ShippingOptionType.PickupFromStore;
                    shippingOption.Name        = Globalization.Translate.Text(Texts.PickupFromStore);
                    shippingOption.Description = Globalization.Translate.Text(Texts.PickupFromStore);
                    break;

                case 3:
                    shippingOption.ShippingOptionType = ShippingOptionType.ElectronicDelivery;
                    shippingOption.Name        = Globalization.Translate.Text(Texts.EmailDelivery);
                    shippingOption.Description = Globalization.Translate.Text(Texts.EmailDelivery);
                    break;

                default:
                    shippingOption.ShippingOptionType = ShippingOptionType.None;
                    shippingOption.Name        = Globalization.Translate.Text(Texts.NoDeliveryPreference);
                    shippingOption.Description = Globalization.Translate.Text(Texts.NoDeliveryPreference);
                    break;
                }

                this.ShippingOptionList[key] = shippingOption;
            }
        }
Exemple #29
0
        /// <summary>
        /// Changes the width.
        /// </summary>
        protected void ChangeWidth()
        {
            if (this.ImageWidth == 0)
            {
                return;
            }
            var num = MainUtil.GetInt(this.WidthEdit.Text, 0);

            if (num > 0)
            {
                if (!string.IsNullOrWhiteSpace(Ratio.Value))
                {
                    return;
                }
                if (num > 8192)
                {
                    num = 8192;
                    this.WidthEdit.Text = "8192";
                    SheerResponse.SetAttribute(this.WidthEdit.ClientID, "value", this.WidthEdit.Text);
                }
                if (this.Aspect.Checked)
                {
                    if (!string.IsNullOrEmpty(this.X2.Text) && !string.IsNullOrEmpty(this.X1.Text) && !string.IsNullOrEmpty(this.Y2.Text) && !string.IsNullOrEmpty(this.Y2.Text))
                    {
                        var croppedWidth  = Math.Round((decimal)(int.Parse(this.X2.Text) - int.Parse(this.X1.Text)));
                        var croppedHeight = Math.Round((decimal)(int.Parse(this.Y2.Text) - int.Parse(this.Y1.Text)));
                        if (croppedHeight > 0 && croppedWidth > 0)
                        {
                            this.HeightEdit.Text = ((int)(croppedHeight * num / croppedWidth)).ToString();
                        }
                        else
                        {
                            this.HeightEdit.Text = string.Empty;
                        }
                    }
                    else
                    {
                        this.HeightEdit.Text = ((int)((double)num / (double)this.ImageWidth * (double)this.ImageHeight)).ToString();
                    }
                    SheerResponse.SetAttribute(this.HeightEdit.ClientID, "value", this.HeightEdit.Text);
                }
            }
            SheerResponse.SetReturnValue(true);
        }
        private static int[] ReadSize(string value, int[] defaultValue)
        {
            if (defaultValue == null || defaultValue.Length != 2)
            {
                defaultValue = new[] { 400, 300 };
            }

            if (!string.IsNullOrEmpty(value))
            {
                string[] sizeArray = value.Split(new[] { ',', '|' }, StringSplitOptions.RemoveEmptyEntries);

                if (sizeArray.Length == 2)
                {
                    return(new[] { MainUtil.GetInt(sizeArray[0], defaultValue[0]), MainUtil.GetInt(sizeArray[1], defaultValue[1]) });
                }
            }

            return(defaultValue);
        }