Exemplo n.º 1
0
        /// <summary>
        /// Adds the checkboxes.
        /// </summary>
        /// <param name="checklists">The checklists.</param>
        /// <param name="condition">The condition.</param>
        public virtual void AddCheckboxes(NameValueCollection checklists, QueryCondition condition)
        {
            for (var cl = 0; cl < checklists.Count; cl++)
            {
                var fieldName        = checklists.Keys[cl];
                var checkBoxesValues = new ListString(checklists[cl]);
                var subquery         = new Query();
                for (var cb = 0; cb < checkBoxesValues.Count; cb++)
                {
                    subquery.Add(new FieldQuery(fieldName, checkBoxesValues[cb], MatchVariant.Exactly));
                    if (cb < checkBoxesValues.Count - 1)
                    {
                        subquery.AppendCondition(QueryCondition.Or);
                    }
                }

                this.CheckListsSubQuery.AppendSubquery(subquery);
                if (cl < checklists.Count - 1)
                {
                    this.CheckListsSubQuery.AppendCondition(QueryCondition.And);
                }
            }

            this.AddSubquery(this.CheckListsSubQuery, condition);
        }
        /// <summary>
        /// Add to shopping cart event.
        /// </summary>
        /// <param name="productCode">The product code.</param>
        /// <param name="productName">Name of the product.</param>
        /// <param name="quantity">The quantity.</param>
        /// <param name="price">The price.</param>
        public virtual void AddToShoppingCart(string productCode, string productName, uint quantity, decimal price)
        {
            Assert.ArgumentNotNull(productName, "productName");
            Assert.ArgumentNotNull(productCode, "productCode");

            if (!Tracker.IsActive)
            {
                return;
            }

            AnalyticsHelper analyticsHelper = Context.Entity.Resolve<AnalyticsHelper>();
            Assert.IsNotNull(analyticsHelper, "analyticsHelper");

            string description = analyticsHelper.GetPageEventDescription(EventConstants.EventAddToShoppingCart);
            if (string.IsNullOrEmpty(description))
            {
                description = EventConstants.EventAddToShoppingCart;
            }

            string text = description.FormatWith(new { Quantity = quantity, ProductName = productName, Price = price });
            ListString data = new ListString { productName, quantity.ToString(CultureInfo.InvariantCulture), price.ToString(CultureInfo.InvariantCulture), productCode.ToString(CultureInfo.InvariantCulture) };

            var currentPage = Tracker.Current.CurrentPage;
            if (currentPage == null)
            {
                return;
            }

            var pageEventData = new PageEventData(EventConstants.EventAddToShoppingCart) { Text = text, Data = data.ToString() };
            currentPage.Register(pageEventData);
        }
Exemplo n.º 3
0
 public AliasInfo(string value)
 {
     Assert.ArgumentNotNullOrEmpty(value, nameof(value));
     value     = StringUtil.RemovePrefix(MultiSiteAliases.Constants.ForwardSlash, value);
     value     = StringUtil.RemovePostfix(MultiSiteAliases.Constants.ForwardSlash, value);
     this.path = new ListString(value, MultiSiteAliases.Constants.ForwardSlashChar);
 }
    /// <summary>
    /// Runs this post step
    /// </summary>
    /// <param name="output">
    /// The output.
    /// </param>
    /// <param name="metaData">
    /// The meta data.
    /// </param>
    public void Run([NotNull] ITaskOutput output, [NotNull] NameValueCollection metaData)
    {
      Assert.ArgumentNotNull(output, "output");
      Assert.ArgumentNotNull(metaData, "metaData");

      string attributes = metaData["Attributes"];
      if (string.IsNullOrEmpty(attributes))
      {
        return;
      }

      string packages = new ListString(attributes).Where(a => a.StartsWith("innerpackages=")).Select(s => s.Substring("innerpackages=".Length)).FirstOrDefault();
      if (string.IsNullOrEmpty(packages))
      {
        return;
      }

      using (new SecurityDisabler())
      {
        using (new ProxyDisabler())
        {
          using (new SyncOperationContext())
          {
            Callback cb = () =>
            {
              this.PackageInstaller.InstallPackages(packages);
              return true;
            };

            output.Execute(cb);
          }
        }
      }
    }
Exemplo n.º 5
0
        protected new string RenderRecentIcons()
        {
            int            num            = 0;
            ListString     recentIcons    = RecentIcons;
            HtmlTextWriter htmlTextWriter = new HtmlTextWriter(new StringWriter());
            ImageBuilder   imageBuilder   = new ImageBuilder()
            {
                Width  = 32,
                Height = 32
            };

            foreach (string str in recentIcons)
            {
                var source = Images.GetThemedImageSource(str, ImageDimension.id32x32);

                var isExists = File.Exists(FileUtil.MapPath(source));

                if (isExists)
                {
                    imageBuilder.Src = source;
                    imageBuilder.Alt = StringUtil.Capitalize(FileUtil.GetFileNameWithoutExtension(str).Replace("_", " "));
                    imageBuilder.Attributes.Set("sc_path", str);
                    imageBuilder.Class = "scRecentIcon";
                    htmlTextWriter.Write(imageBuilder.ToString());
                    ++num;
                }
            }
            if (num == 0)
            {
                htmlTextWriter.Write("<div align=\"center\" style=\"padding:32px 0px 0px 0px\"><i>");
                htmlTextWriter.Write(Translate.Text("There are no icons to display."));
                htmlTextWriter.Write("</i></div>");
            }
            return(htmlTextWriter.InnerWriter.ToString());
        }
 public ListString(ListString other) : this(facerecognitionPINVOKE.new_ListString__SWIG_1(ListString.getCPtr(other)), true)
 {
     if (facerecognitionPINVOKE.SWIGPendingException.Pending)
     {
         throw facerecognitionPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Exemplo n.º 7
0
        /// <summary>Closes this dialog.</summary>
        /// <param name="uploadedItemsRaw">The uploaded items raw.</param>
        public void Close(string uploadedItemsRaw)
        {
            Assert.ArgumentNotNull((object)uploadedItemsRaw, "uploadedItemsRaw");
            ListString listString = new ListString(uploadedItemsRaw);

            if (uploadedItemsRaw == "undefined" || listString.Count == 0)
            {
                base.OK_Click();
            }
            else
            {
                ItemUri itemUri = ItemUri.Parse(listString[0]);
                Assert.IsNotNull((object)itemUri, "uri");
                if (WebUtil.GetQueryString("edit") == "1")
                {
                    UrlString urlString = new UrlString("/sitecore/shell/Applications/Content Manager/default.aspx");
                    urlString["fo"]    = itemUri.ItemID.ToString();
                    urlString["mo"]    = "popup";
                    urlString["wb"]    = "0";
                    urlString["pager"] = "0";
                    urlString[Sitecore.Configuration.State.Client.UsesBrowserWindowsQueryParameterName] = WebUtil.GetQueryString(Sitecore.Configuration.State.Client.UsesBrowserWindowsQueryParameterName, "0");
                    urlString.Add("sc_content", WebUtil.GetQueryString("sc_content"));
                    SheerResponse.ShowModalDialog(urlString.ToString(), string.Equals(Sitecore.Context.Language.Name, "ja-jp", StringComparison.InvariantCultureIgnoreCase) ? "1115" : "955", "560");
                }
                SheerResponse.SetDialogValue(itemUri.ItemID.ToString());
                base.OK_Click();
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// Checkouts the delivery next.
        /// </summary>
        /// <param name="deliveryAlternativeOption">The delivery alternative option.</param>
        /// <param name="notificationOption">The notification option.</param>
        /// <param name="notificationText">The notification text.</param>
        public virtual void DeliveryNext(string deliveryAlternativeOption, string notificationOption, string notificationText)
        {
            Assert.ArgumentNotNull(deliveryAlternativeOption, "deliveryAlternativeOption");
            Assert.ArgumentNotNull(notificationOption, "notificationOption");
            Assert.ArgumentNotNull(notificationText, "notificationText");

            if (!Tracker.IsActive)
            {
                return;
            }

            AnalyticsHelper analyticsHelper = Context.Entity.Resolve<AnalyticsHelper>();
            Assert.IsNotNull(analyticsHelper, "analyticsHelper");

            string description = analyticsHelper.GetPageEventDescription(EventConstants.EventCheckoutDeliveryNext);
            if (string.IsNullOrEmpty(description))
            {
                description = EventConstants.EventCheckoutDeliveryNext;
            }

            string text = description.FormatWith(new { DeliveryAlternativeOption = deliveryAlternativeOption, NotificationOption = notificationOption, NotificationText = notificationText });
            ListString data = new ListString { deliveryAlternativeOption, notificationOption, notificationText };

            var currentPage = Tracker.Current.CurrentPage;
            if (currentPage == null)
            {
                return;
            }

            var pageEventData = new PageEventData(EventConstants.EventCheckoutDeliveryNext) { Text = text, Data = data.ToString() };
            currentPage.Register(pageEventData);
        }
 public ListStringEnumerator(ListString collection)
 {
     collectionRef = collection;
     currentIndex  = -1;
     currentObject = null;
     currentSize   = collectionRef.Count;
 }
        IList <Item> GetItems()
        {
            var result = new List <Item>();
            var values = new ListString(GetItem()[FieldID]);

            foreach (var id in values)
            {
                var item = Client.ContentDatabase.GetItem(id);
                if (item != null)
                {
                    result.Add(item);
                }
                else
                {
                    // If this field used to be an Image field then the value was stored
                    // as an XmlValue instead of just an ItemID
                    // So, we'll try to parse it out.
                    Sitecore.Shell.Applications.ContentEditor.XmlValue xmlVal = new Sitecore.Shell.Applications.ContentEditor.XmlValue(id, "image");
                    string mediaID = xmlVal.GetAttribute("mediaid");
                    if (!String.IsNullOrEmpty(mediaID))
                    {
                        item = Client.ContentDatabase.GetItem(mediaID);
                        if (item != null)
                        {
                            result.Add(item);
                        }
                    }
                }
            }

            return(result);
        }
Exemplo n.º 11
0
        private IEnumerable <FieldDescriptor> CreateFieldDescriptors(string fields, string datasourceString)
        {
            Item item = null;
            var  db   = Factory.GetDatabase(RequestContext.Database);

            if (ID.IsID(datasourceString))
            {
                var itemId = ID.Parse(datasourceString);
                if (!ID.IsNullOrEmpty(itemId))
                {
                    item = db.GetItem(itemId);
                }
            }
            else if (!string.IsNullOrWhiteSpace(datasourceString) && datasourceString.StartsWith("query:"))
            {
                item = RequestContext.Item.Axes.SelectSingleItem(datasourceString.Substring("query:".Length));
            }
            if (item == null)
            {
                item = RequestContext.Item;
            }

            var fieldString = new ListString(fields);

            return(new ListString(fieldString)
                   .Where(x => item.Fields[x] != null)
                   .Select(field => new FieldDescriptor(item, field))
                   .ToList());
        }
Exemplo n.º 12
0
        IList <Item> GetItems()
        {
            var result = new List <Item>();
            var values = new ListString(GetItem()[FieldID]);

            foreach (var id in values)
            {
                var item = Client.ContentDatabase.GetItem(id);
                if (item != null)
                {
                    result.Add(item);
                }
                //if id is not a valid Sitecore id and has at least one closing angle bracket
                else if (!Sitecore.Data.ID.IsID(id) && id.IndexOf(">", System.StringComparison.Ordinal) > -1)
                {
                    // If this field used to be an Image field then the value was stored
                    // as an XmlValue instead of just an ItemID
                    // So, we'll try to parse it out.
                    Sitecore.Shell.Applications.ContentEditor.XmlValue xmlVal = new Sitecore.Shell.Applications.ContentEditor.XmlValue(id, "image");
                    string mediaID = xmlVal.GetAttribute("mediaid");
                    if (!String.IsNullOrEmpty(mediaID))
                    {
                        item = Client.ContentDatabase.GetItem(mediaID);
                        if (item != null)
                        {
                            result.Add(item);
                        }
                    }
                }
            }

            return(result);
        }
Exemplo n.º 13
0
        protected void Run(ClientPipelineArgs args)
        {
            Assert.ArgumentNotNull(args, "args");
            if (args.IsPostBack)
            {
                if (args.Result == "yes")
                {
                    var str = new ListString(args.Parameters["item"]);
                    foreach (string str2 in str)
                    {
                        Manager.LoadItem(str2, new LoadOptions {
                            Database = Context.ContentDatabase, ForceUpdate = true
                        });
                    }

                    SheerResponse.SetLocation(string.Empty);
                }
            }
            else
            {
                var str3 = new ListString(args.Parameters["item"]);
                SheerResponse.Confirm(str3.Count == 1 ? Translate.Text("Do you want to restore \"{0}\"?", new object[] { str3 }) : Translate.Text("Do you want to restore these {0} items?", new object[] { str3.Count }));
                args.WaitForPostBack();
            }
        }
Exemplo n.º 14
0
        /// <summary>
        /// Gets the selected items.
        /// </summary>
        /// <param name="sources">The sources.</param><param name="selected">The selected.</param><param name="unselected">The unselected.</param><contract><requires name="sources" condition="not null"/></contract>
        private void GetSelectedItems(IEnumerable <Item> sources, out ArrayList selected, out IDictionary unselected)
        {
            Assert.ArgumentNotNull(sources, "sources");
            var listString = new ListString(this.Value);

            unselected = new SortedList(StringComparer.Ordinal);
            selected   = new ArrayList(listString.Count);
            foreach (string t in listString)
            {
                selected.Add(t);
            }

            foreach (Item obj in sources)
            {
                string str   = obj.ID.ToString();
                int    index = listString.IndexOf(str);
                if (index >= 0)
                {
                    selected[index] = obj;
                }
                else
                {
                    unselected.Add(MainUtil.GetSortKey(obj.Name), obj);
                }
            }
        }
Exemplo n.º 15
0
        // on ok
        protected override void OnOK(object sender, EventArgs args)
        {
            Assert.ArgumentNotNull(sender, "sender");
            Assert.ArgumentNotNull((object)args, "args");
            ListString listString = new ListString(WebUtil.GetFormValue("sortorder"));

            if (listString.Count == 0) // no changes made
            {
                base.OnOK(sender, args);
            }
            else
            {
                if (IsDBsort(listString.ToString()))
                {
                    SortContentOptions sortContentOptions = SortContentOptions.Parse();
                    ProcessDbOrder(sortContentOptions.Item.Children[0], listString); // save sort order of db view data
                }
                else // sort input view items
                {
                    ListString source = listString;
                    this.Sort(source.Select <string, ID>(x => ShortID.DecodeID(x)));
                    SheerResponse.SetDialogValue("1");
                }
                base.OnOK(sender, args);
            }
        }
        /// <summary>
        /// Adds the renderings.
        /// </summary>
        /// <returns>List of renderings, with personalization processed</returns>
        private static IEnumerable<RenderingReference> AddRenderings()
        {
            Item item = Context.Item;
            if (item == null)
            {
                return new RenderingReference[0];
            }

            DeviceItem device = Context.Device;
            if (device == null)
            {
                return new RenderingReference[0];
            }

            RuleList<ConditionalRenderingsRuleContext> globalRules = GetGlobalRules(item);
            List<RenderingReference> collection = new List<RenderingReference>(item.Visualization.GetRenderings(device, true));
            List<RenderingReference> list3 = new List<RenderingReference>(collection);
            foreach (RenderingReference reference in list3)
            {
                string conditions = reference.Settings.Conditions;
                if (!string.IsNullOrEmpty(conditions))
                {
                    List<Item> conditionItems = new ListString(conditions).Select(item.Database.GetItem).Where(x => x != null).ToList();
                    if (conditionItems.Count > 0)
                    {
                        var rules = RuleFactory.GetRules<ConditionalRenderingsRuleContext>(conditionItems, "Rule");
                        var ruleContext = new ConditionalRenderingsRuleContext(collection, reference) { Item = item };

                        if (!PersonaHelper.DisableOtherRules)
                        {
                            rules.Run(ruleContext);
                        }

                        foreach (var conditionItem in conditionItems)
                        {
                            if (!PersonaHelper.RuleIsActive(conditionItem))
                            {
                                continue;
                            }

                            var conditionRules = RuleFactory.GetRules<ConditionalRenderingsRuleContext>(new[] {conditionItem}, "Rule");
                            foreach (var action in conditionRules.Rules.SelectMany(rule => rule.Actions))
                            {
                                action.Apply(ruleContext);
                            }
                        }
                    }
                }

                if (globalRules != null)
                {
                    ConditionalRenderingsRuleContext context4 = new ConditionalRenderingsRuleContext(collection, reference);
                    context4.Item = item;
                    ConditionalRenderingsRuleContext context3 = context4;
                    globalRules.Run(context3);
                }
            }

            return collection.ToArray();
        }
        protected override void OnOK(object sender, EventArgs args)
        {
            Assert.ArgumentNotNull(sender, "sender");
            Assert.ArgumentNotNull(args, "args");
            ListString str         = new ListString(WebUtil.GetFormValue("sortorder"));
            ListString strToDelete = new ListString(WebUtil.GetFormValue("deleteItem"));

            if (str.Count == 0 && strToDelete.Count == 0)
            {
                base.OnOK(sender, args);
            }
            else
            {
                if (strToDelete.Count > 0)
                {
                    this.Delete(from i in strToDelete select ShortID.DecodeID(i));
                }
                if (str.Count > 0)
                {
                    this.Sort(from i in str select ShortID.DecodeID(i));
                }

                SheerResponse.SetDialogValue("1");
                base.OnOK(sender, args);
            }
        }
Exemplo n.º 18
0
        // saves order of db view data
        private void ProcessDbOrder(Item dbViewItem, ListString list)
        {
            string newOrder = string.Empty;

            string[] facList = dbViewItem.Fields["Faculty List"].Value.Split('&');
            Dictionary <string, string> originalOrder = facList.ToDictionary(item => item.Split('=')[0], item => item.Split('=')[1]);
            string lastSequence = list.ToString().Split(',').Last();

            string[] personIDs = lastSequence.Split('|');
            foreach (string p in personIDs)
            {
                string myJobTitle = originalOrder[p];
                if (String.IsNullOrEmpty(newOrder))
                {
                    newOrder += p + "=" + myJobTitle;
                }
                else
                {
                    newOrder += "&" + p + "=" + myJobTitle;
                }
            }
            dbViewItem.Editing.BeginEdit();
            try
            {
                dbViewItem.Fields["Faculty List"].Value = newOrder;
                dbViewItem.Editing.EndEdit();
            }
            catch (Exception) { dbViewItem.Editing.CancelEdit(); }
            SheerResponse.Eval("window.top.location.reload();");
        }
    public string Execute(string itemLocators)
    {        
        Assert.ArgumentNotNullOrEmpty(itemLocators, "items");

        var masterVariablesReplacer = Configuration.Factory.GetMasterVariablesReplacer();

        var result = new ListString('|');

        foreach (var itemlocator in itemLocators.Split('|'))
        {
            var separator = itemlocator.IndexOf(':');
            var databaseName = itemlocator.Substring(0, separator);

            var database = Configuration.Factory.GetDatabase(databaseName);
            if (database == null) continue;            

            var item = database.GetItem(itemlocator.Substring(separator+1));
            if (item != null)
            {
                item.Fields.ReadAll();
                var revision = item[FieldIDs.Revision];
                using (new EditContext(item))
                {
                    masterVariablesReplacer.ReplaceItem(item);
                }
                if(item[FieldIDs.Revision] != revision)
                {
                    result.Add(string.Format("{0}:{1}",databaseName,item.ID));
                }
            }
        }
        return result.ToString();
    }
Exemplo n.º 20
0
        /// <summary>
        /// Starts the rebuilding.
        /// </summary>
        protected virtual void StartRebuilding()
        {
            ListString databases = new ListString();
            ListString indexMap  = new ListString(this.IndexMap);

            foreach (string formKey in Sitecore.Context.ClientPage.ClientRequest.Form.Keys)
            {
                if (!string.IsNullOrEmpty(formKey) && formKey.StartsWith("dk_"))
                {
                    int index = indexMap.IndexOf(formKey);
                    if (index >= 0)
                    {
                        databases.Add(indexMap[index + 1]);
                    }
                }
            }

            Registry.SetString("/Current_User/Rebuild Search Index/Selected", databases.ToString());
            JobOptions options = new JobOptions("RebuildSearchIndex", "index", Client.Site.Name, new Builder(databases.ToString()), "Build")
            {
                AfterLife   = TimeSpan.FromMinutes(1.0),
                ContextUser = Sitecore.Context.User
            };
            Job job = JobManager.Start(options);

            Sitecore.Context.ClientPage.ServerProperties["handle"] = job.Handle.ToString();
            Sitecore.Context.ClientPage.ClientResponse.Timer("CheckStatus", 500);
        }
Exemplo n.º 21
0
        /// <summary>
        /// Runs this post step
        /// </summary>
        /// <param name="output">The output.</param>
        /// <param name="metaData">The meta data.</param>
        public void Run([NotNull] ITaskOutput output, [NotNull] NameValueCollection metaData)
        {
            Assert.ArgumentNotNull(output, "output");
            Assert.ArgumentNotNull(metaData, "metaData");

            if (string.IsNullOrEmpty(this.PriceCulture))
            {
                this.Write("Numbers converting: The current price culture is not set. There is nothing to convert.", Level.INFO);
                return;
            }

            CultureInfo currentCulture = System.Threading.Thread.CurrentThread.CurrentCulture;

            try
            {
                System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo(this.PriceCulture);

                ListString lineFields = new ListString("Vat|TotalPriceExVat|TotalPriceIncVat|DiscountExVat|DiscountIncVat|PriceExVat|PriceIncVat|TotalVat|PossibleDiscountExVat|PossibleDiscountIncVat");
                this.FormatPrices(Settings.GetSetting("Ecommerce.Order.OrderLineItemTempalteId"), lineFields);

                ListString orderFields = new ListString("Vat|DiscountExVat|DiscountIncVat|PriceExVat|PriceIncVat|TotalVat|PossibleDiscountExVat|PossibleDiscountIncVat|Shipping Price");
                this.FormatPrices(Settings.GetSetting("Ecommerce.Order.OrderItemTempalteId"), orderFields);

                this.FormatProductPrices(new ListString("{A457165A-E6C0-45AD-91BF-2C7407CB86E5}"));
                this.Write("Conversion was finished.", null, Level.INFO);
            }
            catch (Exception ex)
            {
                this.Write("Numbers converting: convertion failed", ex, Level.ERROR);
            }
            finally
            {
                System.Threading.Thread.CurrentThread.CurrentCulture = currentCulture;
            }
        }
Exemplo n.º 22
0
        /// <summary>
        /// This is the process that Runs the Index Rebuild
        /// </summary>
        private void BuildIndexes()
        {
            var selected = new ListString(Registry.GetString("/Current_User/Rebuild Search Index/Selected"));
            var indexMap = new ListString();

            foreach (Index str3 in SearchManager.Indexes)
            {
                this.BuildIndexCheckbox(str3.Name, str3.Name, selected, indexMap);
            }

            if (Config.Scaling.Enabled)
            {
                RemoteSearchManager.Initialize();
                foreach (RemoteIndex str3 in RemoteSearchManager.Indexes)
                {
                    this.BuildIndexCheckbox(str3.Name, str3.Name, selected, indexMap);
                }

                InMemorySearchManager.Initialize();
                foreach (InMemoryIndex str3 in InMemorySearchManager.Indexes)
                {
                    this.BuildIndexCheckbox(str3.Name, str3.Name, selected, indexMap);
                }
            }

            this.BuildIndexCheckbox("$system", "Quick search index", selected, indexMap);
            this.IndexMap = indexMap.ToString();
        }
Exemplo n.º 23
0
        public void PrepareToDelete(ClientPipelineArgs args)
        {
            Assert.ArgumentNotNull(args, "args");

            var itemIDs  = new ListString(args.Parameters["items"]);
            var database = this.factory.GetDatabase(args.Parameters["database"]);

            foreach (var itemID in itemIDs)
            {
                var item = database.GetItem(itemID);
                if (SharepointProvider.IsActiveIntegrationConfigItem(item))
                {
                    args.Parameters[CancelationKey] = CancelationValue;
                    return;
                }

                if (SharepointProvider.IsActiveIntegrationDataItem(item))
                {
                    var integrationItem = new IntegrationItem(item);
                    if (!integrationItem.IsNew)
                    {
                        args.CustomData.Add(itemID, integrationItem.GUID);
                        args.CustomData.Add(itemID + "parentID", item.ParentID);
                    }
                }
            }
        }
        private static bool TryGetListIds(Contact contact, out ListString lists)
        {
            var value = contact.Tags.Find(UserGroupTagKey)?.Values.FirstOrDefault()?.Value ?? string.Empty;

            lists = new ListString(value);
            return(lists.Count > 0);
        }
Exemplo n.º 25
0
        /// <summary>
        /// Handles the grid row double click event.
        /// </summary>
        /// <param name="args">The arguments.</param>
        public virtual void AddButtonClick(GridCommandEventArgs args)
        {
            Assert.ArgumentNotNull(args, "args");

            if (args.RowsID == null)
            {
                return;
            }

            var rowIDs = new ListString();
            var showProductGridItemDublicatedAlert = false;

            foreach (var id in args.RowsID.Cast <string>().Where(ID.IsID))
            {
                if (this.View.SelectedProducts.Contains(id))
                {
                    showProductGridItemDublicatedAlert = true;
                }
                else
                {
                    rowIDs.Add(id);
                }
            }

            if (rowIDs.Count > 0)
            {
                this.View.AddRowToSelectedProductsGrid(rowIDs.ToString());
            }

            if (showProductGridItemDublicatedAlert)
            {
                this.View.ShowProductGridItemDublicatedAlert();
            }
        }
        private void BuildCheckList()
        {
            this.FlushTargets.Controls.Clear();
            string     str2 = Settings.DefaultPublishingTargets.ToLowerInvariant();
            ListString str  = new ListString(Registry.GetString("/Current_User/Publish/Targets"));

            // add master database

            Sitecore.Publishing.PublishManager.GetPublishingTargets(Context.ContentDatabase).ForEach(target =>
            {
                string str3 = "pb_" + ShortID.Encode(target.ID);
                HtmlGenericControl child = new HtmlGenericControl("input");
                this.FlushTargets.Controls.Add(child);
                child.Attributes["type"] = "checkbox";
                child.ID  = str3;
                bool flag = str2.IndexOf('|' + target.Key + '|', StringComparison.InvariantCulture) >= 0;
                if (str.Contains(target.ID.ToString()))
                {
                    flag = true;
                }
                if (flag)
                {
                    child.Attributes["checked"] = "checked";
                }
                child.Disabled = !target.Access.CanWrite();
                HtmlGenericControl control2 = new HtmlGenericControl("label");
                this.FlushTargets.Controls.Add(control2);
                control2.Attributes["for"] = str3;
                control2.InnerText         = target.DisplayName;
                this.FlushTargets.Controls.Add(new LiteralControl("<br>"));
            });
        }
Exemplo n.º 27
0
        /// <summary>
        /// Builds the jquery-tokeninput control.
        /// </summary>
        /// <param name="output">The HtmlTextWriter control used to output the control.</param>
        protected override void DoRender(HtmlTextWriter output)
        {
            var fieldValue = string.Empty;

            if (!string.IsNullOrEmpty(this.Value))
            {
                var list = new ListString(this.Value);
                fieldValue = string.Join("|", list.Items);
            }

            var controlId = "{0}_Value".FormatWith(ID);

            output.RenderSelfClosingTag(
                HtmlTextWriterTag.Input,
                new HtmlAttribute("id", controlId),
                new HtmlAttribute("style", "width:100%"),
                new HtmlAttribute("value", fieldValue));

            if (this.Source.StartsWith("lucene:", StringComparison.InvariantCultureIgnoreCase))
            {
                this.RenderServiceOptions(output, this.Source, controlId);
            }
            else
            {
                this.RenderManualOptions(output, this.Source, controlId);
            }
        }
Exemplo n.º 28
0
        public void GetDestination(ClientPipelineArgs args)
        {
            Assert.ArgumentNotNull(args, "args");
            Database database = GetDatabase(args);

            if (args.Result == "undefined")
            {
                args.AbortPipeline();
            }
            else if ((args.Result != null) && (args.Result.Length > 0))
            {
                args.Parameters["target"] = args.Result;
                Item item = database.GetItem(args.Result);
                Assert.IsNotNull(item, typeof(Item), "ID: {0}", new object[] { args.Result });
                if (!item.Access.CanCreate())
                {
                    Context.ClientPage.ClientResponse.Alert("You do not have permission to create items here.");
                    args.AbortPipeline();
                }
                args.IsPostBack = false;
            }
            else
            {
                ListString str   = new ListString(args.Parameters["items"], '|');
                Item       item2 = database.Items[str[0]];
                Assert.IsNotNull(item2, typeof(Item), "ID: {0}", new object[] { str[0] });
                UrlString str2 = new UrlString("/sitecore/shell/Applications/Dialogs/SmartMoveToSubItems.aspx");
                str2.Append("fo", item2.ID.ToString());
                str2.Append("sc_content", item2.Database.Name);
                Context.ClientPage.ClientResponse.ShowModalDialog(str2.ToString(), true);
                args.WaitForPostBack();
            }
        }
Exemplo n.º 29
0
        private IEnumerable <FieldDescriptor> BuildListWithFieldsToShow(string fieldString)
        {
            var fieldList  = new List <FieldDescriptor>();
            var fieldNames = new ListString(fieldString).ToArray();

            if (fieldNames.Any())
            {
                IncludePatterns =
                    fieldNames
                    .Where(name => !name.StartsWith("-"))
                    .Select(
                        name =>
                        new WildcardPattern(name, WildcardOptions.IgnoreCase | WildcardOptions.CultureInvariant))
                    .ToList();
                ExcludePatterns =
                    fieldNames
                    .Where(name => name.StartsWith("-"))
                    .Select(
                        name =>
                        new WildcardPattern(name.Substring(1),
                                            WildcardOptions.IgnoreCase | WildcardOptions.CultureInvariant))
                    .ToList();
            }
            var currentItem = CurrentItem;

            currentItem.Fields.ReadAll();
            var template =
                TemplateManager.GetTemplate(Settings.DefaultBaseTemplate,
                                            currentItem.Database);

            FieldCollection fields = new FieldCollection(CurrentItem);

            fields.ReadAll();
            fields.Sort();

            foreach (Field field in fields)
            {
                //if not including standard field and it's standard, skip it.
                if (!IncludeStandardFields && template.ContainsField(field.ID))
                {
                    continue;
                }

                var name          = field.Name;
                var wildcardMatch = IncludePatterns.Any(pattern => pattern.IsMatch(name));
                if (!wildcardMatch)
                {
                    continue;
                }
                if (ExcludePatterns.Any(pattern => pattern.IsMatch(name)))
                {
                    wildcardMatch = false;
                }
                if (wildcardMatch)
                {
                    fieldList.Add(new FieldDescriptor(currentItem, field.Name));
                }
            }
            return(fieldList);
        }
        new protected virtual void GetSelectedItems(Item[] sources, out ArrayList selected,
                                                    out OrderedDictionary unselected)
        {
            Assert.ArgumentNotNull(sources, "sources");
            var listString = new ListString(Value);

            unselected = new OrderedDictionary();
            selected   = new ArrayList(listString.Count);
            for (int index = 0; index < listString.Count; ++index)
            {
                selected.Add(listString[index]);
            }
            foreach (Item obj in sources)
            {
                string str   = obj.ID.ToString();
                int    index = listString.IndexOf(str);
                if (index >= 0)
                {
                    selected[index] = obj;
                }
                else
                {
                    unselected.Add(MainUtil.GetSortKey(obj.Name), obj);
                }
            }
        }
        public void Prepare(ClientPipelineArgs args)
        {
            Assert.ArgumentNotNull(args, "args");
            Assert.ArgumentNotNull(args, "args");
            Database   database = GetDatabase(args);
            ListString list     = new ListString(args.Parameters["items"], '|');

            foreach (string id in list)
            {
                Item item = database.GetItem(id);
                if (SharepointProvider.IsActiveIntegrationConfigItem(item))
                {
                    args.Parameters[CancelationKey] = "1";
                }

                if (SharepointProvider.IsActiveIntegrationDataItem(item))
                {
                    if (item != null)
                    {
                        CacheableIntegrationItemInfo cacheableIntegrationItemInfo = IntegrationCache.GetIntegrationItemInfo(item.ID);
                        if (cacheableIntegrationItemInfo != null)
                        {
                            args.Parameters[id] = cacheableIntegrationItemInfo.ParentItemId.ToString();
                            args.Parameters[id + "uniqueId"] = cacheableIntegrationItemInfo.SharepointItemId;
                        }
                    }
                }
            }
        }
Exemplo n.º 32
0
        /// <summary>
        /// Handles the ItemCommand event of the UcProductsListView control.
        /// </summary>
        /// <param name="source">The source of the event.</param>
        /// <param name="e">The <see cref="System.Web.UI.WebControls.RepeaterCommandEventArgs"/> instance containing the event data.</param>
        protected void UcProductsListView_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            if (e.CommandName != "Delete" || string.IsNullOrEmpty((string)e.CommandArgument))
            {
                return;
            }

            ListString listString  = new ListString((string)e.CommandArgument);
            string     productCode = listString[0];

            ProductLine existingProductLine = this.Cart.ShoppingCartLines.FirstOrDefault(p => p.Product.Code.Equals(productCode));

            if (existingProductLine != null)
            {
                AnalyticsUtil.ShoppingCartItemRemoved(productCode, existingProductLine.Product.Title, existingProductLine.Quantity);
            }

            IShoppingCartManager shoppingCartManager = Sitecore.Ecommerce.Context.Entity.Resolve <IShoppingCartManager>();

            shoppingCartManager.RemoveProductLine(productCode);

            if (this.Cart.ShoppingCartLines.Count == 0)
            {
                this.Response.Redirect(LinkManager.GetItemUrl(Sitecore.Context.Item));
            }

            Sitecore.Ecommerce.Context.Entity.SetInstance(this.Cart);

            this.UpdateTotals(this.Cart);
            this.UpdateProductLines(this.Cart);
        }
        /// <summary>
        /// Starts Building Indexes
        /// </summary>
        protected void StartRebuilding()
        {
            var str  = new ListString();
            var str2 = new ListString(this.IndexMap);

            foreach (string str3 in Context.ClientPage.ClientRequest.Form.Keys)
            {
                if (!string.IsNullOrEmpty(str3) && str3.StartsWith("dk_"))
                {
                    int index = str2.IndexOf(str3);
                    if (index >= 0)
                    {
                        str.Add(str2[index + 1]);
                    }
                }
            }

            Registry.SetString("/Current_User/Rebuild Search Index/Selected", str.ToString());


            var options2 = new JobOptions("RebuildSearchIndex", "index", Client.Site.Name,
                                          new Builder(str.ToString()), "Build")
            {
                AfterLife   = TimeSpan.FromMinutes(1.0),
                ContextUser = Context.User
            };
            var options = options2;
            var job     = JobManager.Start(options);

            Context.ClientPage.ServerProperties["handle"] = job.Handle.ToString();
            Context.ClientPage.ClientResponse.Timer("CheckStatus", 500);
        }
Exemplo n.º 34
0
        /// <summary>
        /// The actual deletion process.
        /// </summary>
        /// <param name="args">Pipeline args</param>
        protected void Run(ClientPipelineArgs args)
        {
            Assert.ArgumentNotNull(args, "args");
            ListString str = new ListString(args.Parameters["ID"]);

            if (args.IsPostBack)
            {
                if (args.Result == "yes")
                {
                    List <string> list = new List <string>();

                    foreach (string str2 in str)
                    {
                        Repository.Delete(str2);
                    }

                    Thread.Sleep(250);                     // Doing this gives Javascript time to refresh the page.
                    AjaxScriptManager.Current.Dispatch("redirectmanager:redirectdeleted");
                }
            }
            else
            {
                if (str.Count == 1)
                {
                    string str5 = str[0];

                    SheerResponse.Confirm("Are you sure you want to delete this redirect?");
                }
                else
                {
                    SheerResponse.Confirm(Translate.Text("Are you sure you want to delete these {0} redirects?", new object[] { str.Count }));
                }
                args.WaitForPostBack();
            }
        }
        /// <summary>
        /// Gets the list of renderings defined as 'Allowed Controls" for the specified
        /// placeholder settings item.
        /// </summary>
        /// <param name="placeholderItem">The placeholder settings item.</param>
        /// <returns>The list of allowed renderings.</returns>
        public static IEnumerable <Item> GetAllowedRenderingsByPlaceholder(Item placeholderItem)
        {
            Assert.ArgumentNotNull(placeholderItem, nameof(placeholderItem));

            // Reads the 'Allowed Controls' field
            ListString listString = new ListString(placeholderItem["Allowed Controls"]);

            if (listString.Count <= 0)
            {
                return(null);
            }

            // Converts the raw value from the 'Allowed Controls' field to a list of actual Items
            // by calling to the database
            List <Item> renderings = new List <Item>();

            foreach (string path in listString)
            {
                Item obj = placeholderItem.Database.GetItem(path);
                if (obj != null)
                {
                    renderings.Add(obj);
                }
            }

            return(renderings);
        }
Exemplo n.º 36
0
        protected void Run(ClientPipelineArgs args)
        {
            Assert.ArgumentNotNull(args, "args");
            if (args.IsPostBack)
            {
                if (args.Result == "yes")
                {
                    var str = new ListString(args.Parameters["item"]);
                    foreach (string str2 in str)
                    {
                        Directory.Delete(str2, true);
                    }

                    SheerResponse.SetLocation(string.Empty);
                }
            }
            else
            {
                var str3 = new ListString(args.Parameters["item"]);
                if (str3.Count == 1)
                {
                    SheerResponse.Confirm(Translate.Text("Are you sure you want to permanently delete \"{0}\"?", new object[] { str3 }));
                }
                else
                {
                    SheerResponse.Confirm(Translate.Text("Are you sure you want to permanently delete these {0} items?", new object[] { str3.Count }));
                }

                args.WaitForPostBack();
            }
        }
Exemplo n.º 37
0
        protected void Run(ClientPipelineArgs args)
        {
            Assert.ArgumentNotNull(args, "args");
            if (args.IsPostBack)
            {
                if (args.Result == "yes")
                {
                    var str = new ListString(args.Parameters["item"]);
                    foreach (string str2 in str)
                    {
                        Directory.Delete(str2, true);
                    }

                    SheerResponse.SetLocation(string.Empty);
                }
            }
            else
            {
                var str3 = new ListString(args.Parameters["item"]);
                if (str3.Count == 1)
                {
                    SheerResponse.Confirm(Translate.Text("Are you sure you want to permanently delete \"{0}\"?", new object[] { str3 }));
                }
                else
                {
                    SheerResponse.Confirm(Translate.Text("Are you sure you want to permanently delete these {0} items?", new object[] { str3.Count }));
                }

                args.WaitForPostBack();
            }
        }
        protected void Run(ClientPipelineArgs args)
        {
            string var = args.Parameters["rid"];
            Util.AssertNotNull(var);
            if (!args.IsPostBack)
            {
                using (new SecurityDisabler())
                {
                    UrlString urlString = new UrlString("/sitecore/shell/~/xaml/RecipientListManagement.RecipientsLists.Lists.Creation.AddSitecoreRoles.SelectRoles.aspx");
                    new UrlHandle().Add(urlString);
                    foreach (string str in args.Parameters.AllKeys)
                    {
                        urlString.Add(str, args.Parameters[str]);
                    }
                    SheerResponse.ShowModalDialog(urlString.ToString(), "600", "650", string.Empty, true);
                    args.WaitForPostBack();
                    return;
                }
            }
            if (args.HasResult)
            {
                ListString roles = new ListString((args.Result == "-") ? string.Empty : args.Result);

                TargetAudience recipientList = Factory.GetTargetAudience(var);
                if ((recipientList != null) && (recipientList.InnerItem != null))
                {
                    IEnumerable<string> enumerable = null;
                    if (recipientList.ExtraOptInList != null)
                    {
                        enumerable = (recipientList.OptInList == null) ? roles : (from role in roles
                                                                                                      where recipientList.OptInList.Roles.All<Role>(x => x.Name != role) && recipientList.ExtraOptInList.Roles.All<Role>(x => x.Name != role)
                                                                                                      select role).ToList<string>() as IEnumerable<string>;
                    }
                    else
                    {
                        enumerable = (recipientList.OptInList == null) ? roles : (from role in roles
                                                                                                      where recipientList.OptInList.Roles.All<Role>(x => x.Name != role)
                                                                                                      select role).ToList<string>() as IEnumerable<string>;
                    }
                    foreach (string str in enumerable)
                    {
                        recipientList.Source.AddRoleToExtraOptIn(str);
                    }
                    NotificationManager.Instance.Notify("MessageFromCommand", new MessageEventArgs("Recipients were imported to the selected list."));
                    NotificationManager.Instance.Notify("RecipientsChanged");
                    NotificationManager.Instance.Notify("RefreshRecipientLists");
                }
            }
        }
 private void AutoMap()
 {
     var assembliesToRegister = new ListString(Settings.GetSetting("SimpleInjectorAssembliesToRegister", "TomGrable.Website.Core"));
     var assemblies = AppDomain.CurrentDomain.GetAssemblies().Where(a => assembliesToRegister.Any(assembly => a.FullName.StartsWith(assembly)));
     var registrations =
         assemblies.SelectMany(assembly => assembly.GetExportedTypes().Where(type => type.GetInterfaces().Any())).Select(type => new
         {
             Service = type.GetInterfaces().Single(),
             Implementation = type
         });
     foreach (var reg in registrations)
     {
         Container.Current.Register(reg.Service, reg.Implementation, Lifestyle.Transient);
     }
 }
Exemplo n.º 40
0
 /// <summary>
 /// Copied Sitecore.Shell.Framework.Pipelines.CopyItems
 /// is listed as private in Sitecore
 /// </summary>
 /// <param name = "args"></param>
 /// <returns>List of Items</returns>
 private static List<Item> GetItems(ClientPipelineArgs args)
 {
     Assert.ArgumentNotNull(args, "args");
     List<Item> list = new List<Item>();
     Database database = GetDatabase(args);
     ListString str = new ListString(args.Parameters["items"], '|');
     foreach (string str2 in str)
     {
         Item item = database.Items[str2];
         if (item != null)
         {
             list.Add(item);
         }
     }
     return list;
 }
Exemplo n.º 41
0
        protected void Run(ClientPipelineArgs args)
        {
            Assert.ArgumentNotNull(args, "args");

            ListString list = new ListString(args.Parameters["entryids"]);

            if (args.IsPostBack)
            {
                if (args.HasResult && args.Result == "yes")
                {
                    if (list.Items.Any())
                    {
                        foreach (string id in list.Items)
                        {
                            Guid entryId = MainUtil.GetGuid(id, Guid.Empty);

                            if (entryId != Guid.Empty)
                            {
                                RedirectManager.DeleteRedirect(entryId);
                            }
                        }

                        Client.AjaxScriptManager.Dispatch("redirects:refresh");
                    }
                }
            }
            else
            {
                if (list.Any())
                {
                    if (list.Count == 1)
                    {
                        SheerResponse.Confirm(Translate.Text("Are you sure you want to delete this redirect?"));
                    }
                    else
                    {
                        SheerResponse.Confirm(Translate.Text("Are you sure you want to delete these {0} redirects?", new object[] { list.Count }));
                    }
                    args.WaitForPostBack();

                }
            }
        }
        protected void Run(ClientPipelineArgs args)
        {
            Assert.ArgumentNotNull(args, "args");
            if (args.IsPostBack)
            {
                if (args.Result == "yes")
                {
                    var str = new ListString(args.Parameters["item"]);
                    foreach (string str2 in str)
                    {
                        Manager.LoadItem(str2, new LoadOptions { Database = Context.ContentDatabase, ForceUpdate = true });
                    }

                    SheerResponse.SetLocation(string.Empty);
                }
            }
            else
            {
                var str3 = new ListString(args.Parameters["item"]);
                SheerResponse.Confirm(str3.Count == 1 ? Translate.Text("Do you want to restore \"{0}\"?", new object[] { str3 }) : Translate.Text("Do you want to restore these {0} items?", new object[] { str3.Count }));
                args.WaitForPostBack();
            }
        }
Exemplo n.º 43
0
        public override void Execute(CommandContext context)
        {
            Assert.ArgumentNotNull(context, "context");

            ClientPipelineArgs args = new ClientPipelineArgs();

            ListString list = new ListString(context.Parameters["entryids"]);

            bool isNew = context.Parameters["new"] == "1";

            if (list.Items.Any() && !isNew)
            {
                Guid entryId = MainUtil.GetGuid(list.Items.FirstOrDefault(), Guid.Empty);
                if (entryId != Guid.Empty)
                {
                    RedirectEntry entry = RedirectManager.GetRedirect(entryId);
                    if (entry != null)
                    {
                        args.Parameters["entryid"] = entryId.ToString();
                        args.Parameters["oldpath"] = entry.OldPath;
                        args.Parameters["itemid"] = entry.ItemID.ToString();
                        args.Parameters["querystring"] = entry.QueryString;
                        args.Parameters["site"] = entry.Site;
                    }
                }
            }

            ContinuationManager current = ContinuationManager.Current;
            if (current != null)
            {
                current.Start(this, "Run", args);
            }
            else
            {
                Context.ClientPage.Start(this, "Run", args);
            }
        }
Exemplo n.º 44
0
 /// <summary>
 /// Adds string value to the pipe-separated value field.
 /// By default NameValueCollection uses comma.
 /// </summary>
 /// <param name="list">The list.</param>
 /// <param name="key">The key.</param>
 /// <param name="value">The value.</param>
 private static void AddListStringValue(NameValueCollection list, string key, string value)
 {
     if (string.IsNullOrEmpty(list[key]))
       {
     list.Add(key, value);
       }
       else
       {
     var values = new ListString(list[key]) { value };
     list[key] = values.ToString();
       }
 }
 protected void Validator_SuppressValidator(string markerId)
 {
     Assert.ArgumentNotNull(markerId, "markerId");
     Assert.IsTrue(UserOptions.ContentEditor.ShowValidatorBar, "Validator bar is switched off in Content Editor.");
     ValidatorCollection validators = ValidatorManager.GetValidators(ValidatorsMode.ValidatorBar, this.ValidatorsKey);
     var byMarkerID = validators.GetByMarkerID(markerId);
     if (byMarkerID != null)
     {
         Assert.IsNotNull(byMarkerID.ItemUri, "Item URI is null.");
         Item item = Database.GetItem(byMarkerID.ItemUri);
         if (item != null)
         {
             ListString str = new ListString(item["__Suppressed Validation Rules"]);
             Assert.IsNotNull(byMarkerID.ValidatorID, "Validator ID is null.");
             if (!str.Contains(byMarkerID.ValidatorID.ToString()))
             {
                 str.Add(byMarkerID.ValidatorID.ToString());
                 using (new SecurityDisabler())
                 {
                     item.Editing.BeginEdit();
                     item["__Suppressed Validation Rules"] = str.ToString();
                     item.Editing.EndEdit();
                 }
                 validators.Remove(byMarkerID);
                 WebUtil.SetSessionValue(this.ValidatorsKey + ValidatorsMode.ValidatorBar, validators);
                 SheerResponse.Eval("scContent.validate()");
             }
         }
     }
 }
 public string GetValue()
 {
     ListString list = new ListString();
      string id = GetViewStateString("ID");
      Sitecore.Web.UI.HtmlControls.Listbox listbox = FindControl(id + "_selected") as Sitecore.Web.UI.HtmlControls.Listbox;
      Sitecore.Web.UI.HtmlControls.ListItem[] itemArray = listbox.Items;
      for (int i = 0; i < itemArray.Length; i++)
      {
     Sitecore.Web.UI.HtmlControls.ListItem item = itemArray[i];
     string[]pair  = item.Value.Split(new char[]{'|'});
     if(pair.Length <= 1)
     {
        continue;
     }
     list.Add(pair[1]);
      }
      return list.ToString();
 }
    /// <summary>
    /// If the field has value, renders selected items
    /// </summary>
    /// <param name="output">The writer.</param>
    void RenderValue(HtmlTextWriter output) {
      if (string.IsNullOrEmpty(Value)) {
        return;
      }

      var list = new ListString(Value);
      foreach(string id in list) {
        Item item = Sitecore.Context.ContentDatabase.GetItem(id);
        string text = item != null ? item.DisplayName : id;

        output.Write("<div class='textlist-item' sc_value='{0}'>".FormatWith(id));
        output.Write(text);
        output.Write("<a href='#' class='textlist-closebutton'></a>");
        output.Write("</div>");
      }
    }
        /// <summary>
        /// User login succeded.
        /// </summary>
        /// <param name="userName">Name of the user.</param>
        public virtual void UserLoginSucceded(string userName)
        {
            Assert.ArgumentNotNull(userName, "userName");

            if (!Tracker.IsActive)
            {
                return;
            }

            AnalyticsHelper analyticsHelper = Context.Entity.Resolve<AnalyticsHelper>();
            Assert.IsNotNull(analyticsHelper, "analyticsHelper");

            string description = analyticsHelper.GetPageEventDescription(EventConstants.EventUserLoginSucceded);
            if (string.IsNullOrEmpty(description))
            {
                description = EventConstants.EventUserLoginSucceded;
            }

            string text = description.FormatWith(new
            {
                Username = userName,
            });
            ListString data = new ListString { userName };

            var currentPage = Tracker.Current.CurrentPage;
            if (currentPage == null)
            {
                return;
            }

            var pageEventData = new PageEventData(EventConstants.EventUserLoginSucceded) { Text = text, Data = data.ToString() };
            currentPage.Register(pageEventData);
        }
 protected override void GetSelectedItems(Item[] sources, out ArrayList selected, out IDictionary unselected)
 {
     Assert.ArgumentNotNull(sources, "sources");
     ListString listString = new ListString(this.Value);
     unselected = new SortedList(System.StringComparer.Ordinal);
     selected = new System.Collections.ArrayList(listString.Count);
     for (int i = 0; i < listString.Count; i++)
     {
         selected.Add(listString[i]);
     }
     for (int j = 0; j < sources.Length; j++)
     {
         Item item = sources[j];
         string item2 = item.ID.ToString();
         int num = listString.IndexOf(item2);
         if (num >= 0)
         {
             selected[num] = item;
         }
         else
         {
             unselected.Add(MainUtil.GetSortKey(item.Name), item);
         }
     }
 }
 /// <summary>
 /// Builds the Checkboxes to select indexes
 /// </summary>
 /// <param name="name">
 /// The name.
 /// </param>
 /// <param name="header">
 /// The header.
 /// </param>
 /// <param name="selected">
 /// The selected.
 /// </param>
 /// <param name="indexMap">
 /// The index map.
 /// </param>
 private void BuildIndexCheckbox(string name, string header, ListString selected, ListString indexMap)
 {
     Assert.ArgumentNotNull(name, "name");
     Assert.ArgumentNotNull(header, "header");
     Assert.ArgumentNotNull(selected, "selected");
     Assert.ArgumentNotNull(indexMap, "indexMap");
     var child = new Checkbox();
     this.Indexes.Controls.Add(child);
     child.ID = Control.GetUniqueID("dk_");
     child.Header = header;
     child.Value = name;
     child.Checked = true;//selected.Contains(name);
     indexMap.Add(child.ID);
     indexMap.Add(name);
     this.Indexes.Controls.Add(new LiteralControl("<br />"));
 }
		public string GetValue()
		{
			ListString str = new ListString();
			string viewStateString = base.GetViewStateString("ID");
			Listbox listbox = this.FindControl(viewStateString + "_selected") as Listbox;
			Assert.IsNotNull(listbox, typeof(Listbox));
			foreach (ListItem item in listbox.Items)
			{
				string[] strArray = item.Value.Split(new char[] { '|' });
				if (strArray.Length > 1)
				{
					str.Add(strArray[1]);
				}
			}
			return str.ToString();
		}
        /// <summary>
        /// This is the process that Runs the Index Rebuild
        /// </summary>
        private void BuildIndexes()
        {
            var selected = new ListString(Registry.GetString("/Current_User/Rebuild Search Index/Selected"));
            var indexMap = new ListString();
            foreach (var str3 in SearchHelper.GetIndexes())
            {
                this.BuildIndexCheckbox(str3.Name, str3.Name, selected, indexMap);
            }

            //this.BuildIndexCheckbox("Select All", "Select All", selected, indexMap);
            //this.BuildIndexCheckbox("Deselect All", "Deselect All", selected, indexMap);
            this.BuildIndexCheckbox("$system", "Quick search index", selected, indexMap);
            this.IndexMap = indexMap.ToString();
        }
        IList<Item> GetItems()
        {
            var result = new List<Item>();
            var values = new ListString(GetItem()[FieldID]);

            foreach (var id in values)
            {
                var item = Client.ContentDatabase.GetItem(id);
                if (item != null)
                {
                    result.Add(item);
                }
                else
                {
                    // If this field used to be an Image field then the value was stored 
                    // as an XmlValue instead of just an ItemID
                    // So, we'll try to parse it out.
                    Sitecore.Shell.Applications.ContentEditor.XmlValue xmlVal = new Sitecore.Shell.Applications.ContentEditor.XmlValue(id, "image");
                    string mediaID = xmlVal.GetAttribute("mediaid");
                    if (!String.IsNullOrEmpty(mediaID))
                    {
                        item = Client.ContentDatabase.GetItem(mediaID);
                        if (item != null) result.Add(item);
                    }
                }
            }

            return result;
        }
Exemplo n.º 54
0
        /// <summary>
        /// Shoppings the cart item updated.
        /// </summary>
        /// <param name="productCode">The product code.</param>
        /// <param name="productName">Name of the product.</param>
        /// <param name="amount">The products amount.</param>
        public virtual void ShoppingCartItemUpdated(string productCode, string productName, uint amount)
        {
            Assert.ArgumentNotNull(productCode, "shoppingCartContent");
            Assert.ArgumentNotNull(productName, "itemsInShoppingCart");

            if (!Tracker.IsActive)
            {
                return;
            }

            AnalyticsHelper analyticsHelper = Context.Entity.Resolve<AnalyticsHelper>();
            Assert.IsNotNull(analyticsHelper, "analyticsHelper");

            string description = analyticsHelper.GetPageEventDescription(EventConstants.EventShoppingCartItemUpdated);
            if (string.IsNullOrEmpty(description))
            {
                description = EventConstants.EventShoppingCartItemUpdated;
            }

            string text = description.FormatWith(new { ProductName = productName, Amount = amount });
            ListString data = new ListString { productCode, productName, amount.ToString(CultureInfo.InvariantCulture) };

            var currentPage = Tracker.Current.CurrentPage;
            if (currentPage == null)
            {
                return;
            }

            var pageEventData = new PageEventData(EventConstants.EventShoppingCartItemUpdated) { Text = text, Data = data.ToString() };
            currentPage.Register(pageEventData);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="Sitecore.ItemBucket.Kernel.Commands.RebuildBucketIndex.Builder"/> class.
 /// </summary>
 /// <param name="indexname">
 /// The indexname.
 /// </param>
 public Builder(string indexname)
 {
     Assert.ArgumentNotNull(indexname, "indexname");
     this.indexNames = new ListString(indexname);
 }
Exemplo n.º 56
0
        private IEnumerable<FieldDescriptor> BuildListWithFieldsToShow(string fieldString)
        {
            var fieldList = new List<FieldDescriptor>();
            var fieldNames = new ListString(fieldString).ToArray();

            if (fieldNames.Any())
            {
                IncludePatterns =
                    fieldNames
                        .Where(name => !name.StartsWith("-"))
                        .Select(
                            name =>
                                new WildcardPattern(name, WildcardOptions.IgnoreCase | WildcardOptions.CultureInvariant))
                        .ToList();
                ExcludePatterns =
                    fieldNames
                        .Where(name => name.StartsWith("-"))
                        .Select(
                            name =>
                                new WildcardPattern(name.Substring(1),
                                    WildcardOptions.IgnoreCase | WildcardOptions.CultureInvariant))
                        .ToList();
            }
            var currentItem = CurrentItem;
            currentItem.Fields.ReadAll();
            var template =
                TemplateManager.GetTemplate(Settings.DefaultBaseTemplate,
                    currentItem.Database);

            foreach (Field field in currentItem.Fields)
            {
                //if not including standard field and it's standard, skip it.
                if (!IncludeStandardFields && template.ContainsField(field.ID))
                {
                    continue;
                }

                var name = field.Name;
                var wildcardMatch = IncludePatterns.Any(pattern => pattern.IsMatch(name));
                if (!wildcardMatch)
                {
                    continue;
                }
                if (ExcludePatterns.Any(pattern => pattern.IsMatch(name)))
                {
                    wildcardMatch = false;
                }
                if (wildcardMatch)
                {
                    fieldList.Add(new FieldDescriptor(currentItem, field.Name));
                }
            }
            return fieldList;
        }
        /// <summary>
        /// Handles the ItemCommand event of the UcProductsListView control.
        /// </summary>
        /// <param name="source">The source of the event.</param>
        /// <param name="e">The <see cref="System.Web.UI.WebControls.RepeaterCommandEventArgs"/> instance containing the event data.</param>
        protected void UcProductsListView_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            if (e.CommandName != "Delete" || string.IsNullOrEmpty((string)e.CommandArgument))
              {
            return;
              }

              ListString listString = new ListString((string)e.CommandArgument);
              string productCode = listString[0];

              ProductLine existingProductLine = this.Cart.ShoppingCartLines.FirstOrDefault(p => p.Product.Code.Equals(productCode));

              if (existingProductLine != null)
              {
            AnalyticsUtil.ShoppingCartItemRemoved(productCode, existingProductLine.Product.Title, existingProductLine.Quantity);
              }

              IShoppingCartManager shoppingCartManager = Sitecore.Ecommerce.Context.Entity.Resolve<IShoppingCartManager>();
              shoppingCartManager.RemoveProductLine(productCode);

              if (this.Cart.ShoppingCartLines.Count == 0)
              {
            this.Response.Redirect(LinkManager.GetItemUrl(Sitecore.Context.Item));
              }

              Sitecore.Ecommerce.Context.Entity.SetInstance(this.Cart);

              this.UpdateTotals(this.Cart);
              this.UpdateProductLines(this.Cart);
        }
        /// <summary>
        /// Starts Building Indexes
        /// </summary>
        protected void StartRebuilding()
        {
            var str = new ListString();
            var str2 = new ListString(this.IndexMap);
            foreach (string str3 in Context.ClientPage.ClientRequest.Form.Keys)
            {
                if (!string.IsNullOrEmpty(str3) && str3.StartsWith("dk_"))
                {
                    int index = str2.IndexOf(str3);
                    if (index >= 0)
                    {
                        str.Add(str2[index + 1]);
                    }
                }
            }

            Registry.SetString("/Current_User/Rebuild Search Index/Selected", str.ToString());

                var options2 = new JobOptions("RebuildSearchIndex", "index", Client.Site.Name,
                                              new Builder(str.ToString()), "Build")
                {
                    AfterLife = TimeSpan.FromMinutes(1.0),
                    ContextUser = Context.User
                };
                var options = options2;
                var job = JobManager.Start(options);
                Context.ClientPage.ServerProperties["handle"] = job.Handle.ToString();
                Context.ClientPage.ClientResponse.Timer("CheckStatus", 500);
        }
        /// <summary>
        /// Handles the Click event of the btnEmptyShoppingCart control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void btnEmptyShoppingCart_Click(object sender, EventArgs e)
        {
            uint numberOfProducts = 0;
              ListString shoppingCartContent = new ListString();
              foreach (ShoppingCartLine line in this.Cart.ShoppingCartLines)
              {
            shoppingCartContent.Add(line.Product.Code);
            numberOfProducts += line.Quantity;
              }

              AnalyticsUtil.ShoppingCartEmptied(shoppingCartContent.ToString(), numberOfProducts);

              this.Cart.ShoppingCartLines.Clear();

              ICheckOut checkOut = Sitecore.Ecommerce.Context.Entity.Resolve<ICheckOut>();
              if (checkOut is CheckOut)
              {
            ((CheckOut)checkOut).ResetCheckOut();
              }

              ItemUtil.RedirectToNavigationLink(ContinueShopping, false);
        }
        IList<Item> GetItems()
        {
            var result = new List<Item>();
            var values = new ListString(GetItem()[FieldID]);

            foreach (var id in values)
            {
                var item = Client.ContentDatabase.GetItem(id);
                if (item != null)
                {
                    result.Add(item);
                }
                //if id is not a valid Sitecore id and has at least one closing angle bracket
		else if(!Sitecore.Data.ID.IsID(id) && id.IndexOf(">", System.StringComparison.Ordinal) > -1 )
                {
                    // If this field used to be an Image field then the value was stored 
                    // as an XmlValue instead of just an ItemID
                    // So, we'll try to parse it out.
                    Sitecore.Shell.Applications.ContentEditor.XmlValue xmlVal = new Sitecore.Shell.Applications.ContentEditor.XmlValue(id, "image");
                    string mediaID = xmlVal.GetAttribute("mediaid");
                    if (!String.IsNullOrEmpty(mediaID))
                    {
                        item = Client.ContentDatabase.GetItem(mediaID);
                        if (item != null) result.Add(item);
                    }
                }
            }

            return result;
        }