Esempio n. 1
0
        /// <summary>
        /// Adds publising jobs to the job list control.
        /// </summary>
        private void FillJobList()
        {
            IEnumerable <PublishJobEntry> jobEntries = PublishJobHelper.GetJobs();

            if (((IList)jobEntries).Count == 0)
            {
                AddEmptyItem();
            }
            else
            {
                string selectedItemId = "";
                if (JobList.SelectedItems.Length > 0)
                {
                    selectedItemId = JobList.SelectedItems[0].ID;
                }
                JobList.Controls.Clear();
                foreach (var job in jobEntries)
                {
                    ListviewItem listItem = new ListviewItem();
                    Context.ClientPage.AddControl(JobList, listItem);
                    PopulateListviewItem(listItem, job, selectedItemId);
                }
                SheerResponse.SetInnerHtml("JobPanel", JobList);
            }
        }
        /// <summary>
        /// Fills the list view control with an array of options.
        /// </summary>
        /// <param name="options">The options.</param>
        protected void FillOptionList(PollOptionItem[] options)
        {
            if (options == null)
            {
                return;
            }

            foreach (PollOptionItem option in options)
            {
                // Create and add the new ListviewItem control to the Listview. We have to assign an unique
                // ID to each control on the page
                ListviewItem listItem = new ListviewItem();

                OptionList.Controls.Add(listItem);
                listItem.ID = Control.GetUniqueID("I");

                // Populate the list item with data.
                listItem.Header = option.Name;
                listItem.Icon   = option.InnerItem.Appearance.Icon;
                listItem.ColumnValues["title"] = option.Title;
                listItem.ColumnValues["index"] = option.Index;
                listItem.ColumnValues["id"]    = option.ID;
            }
            SheerResponse.SetOuterHtml("OptionList", OptionList);
        }
Esempio n. 3
0
        /// <summary>
        /// Populates this instance.
        /// </summary>
        protected virtual void Populate()
        {
            this.Controls.Clear();
            this.ColumnNames.Clear();
            this.ColumnNames.Add("Icon", "Icon");

            HashSet <string> columnNames = new HashSet <string>();

            int count = ASR.Current.Context.Settings.PageSize;
            int start = (CurrentPage - 1) * count;

            foreach (var result in Current.Context.Report.GetResultElements(start, count))
            {
                ListviewItem lvi = new ListviewItem();
                lvi.ID    = Control.GetUniqueID("lvi");
                lvi.Icon  = result.Icon;
                lvi.Value = result.Value;
                foreach (var column in result.GetColumnNames())
                {
                    columnNames.Add(column);
                    lvi.ColumnValues.Add(column, result.GetColumnValue(column));
                }
                this.Controls.Add(lvi);
            }
            foreach (var column in columnNames)
            {
                this.ColumnNames.Add(column, column);
            }
        }
Esempio n. 4
0
        private Sitecore.Data.Items.Item retrieveItem(ListviewItem listItem)
        {
            string path = listItem.Header;

            Sitecore.Globalization.Language lang    = Sitecore.Globalization.Language.Current;
            Sitecore.Data.Version           version = Sitecore.Data.Version.Latest;
            Sitecore.Data.Items.Item        item    = null;
            if (listItem.ColumnValues.Contains("lang"))
            {
                Sitecore.Globalization.Language.TryParse(listItem.ColumnValues["lang"].ToString(), out lang);
            }
            if (listItem.ColumnValues.Contains("version"))
            {
                version = new Sitecore.Data.Version(listItem.ColumnValues["version"].ToString());
            }

            item =
                Properties.Db.GetItem(path, lang, version);
            if (item == null)
            {
                if (Properties.Db.HasContentItem)
                {
                    path = "/sitecore/content/" + path;
                    item = Properties.Db.GetItem(path, lang, version);
                    if (item != null)
                    {
                        return(item);
                    }
                }
                throw new Exception("Item does not exist in such language");
            }
            return(item);
        }
Esempio n. 5
0
        public void AddItem()
        {
            var selectedIcon = IconFile.Value;

            Context.ClientPage.ClientResponse.DisableOutput();

            try
            {
                var id = Sitecore.Web.UI.HtmlControls.Control.GetUniqueID("ListItem");

                var listviewItem = new ListviewItem
                {
                    ID     = id,
                    Icon   = selectedIcon,
                    Header = selectedIcon,
                    Value  = selectedIcon
                };

                Context.ClientPage.AddControl(IconList, listviewItem);
            }
            finally
            {
                Context.ClientPage.ClientResponse.EnableOutput();
            }
            Context.ClientPage.ClientResponse.Refresh(IconList);
        }
        /// <summary>
        /// Raises the load event.
        /// </summary>
        /// <param name="e">
        /// The <see cref="System.EventArgs"/> instance containing the event data.
        /// </param>
        /// <remarks>
        /// This method notifies the server control that it should perform actions common to each HTTP
        /// request for the page it is associated with, such as setting up a database query. At this
        /// stage in the page lifecycle, server controls in the hierarchy are created and initialized,
        /// view state is restored, and form controls reflect client-side data. Use the IsPostBack
        /// property to determine whether the page is being loaded in response to a client postback,
        /// or if it is being loaded and accessed for the first time.
        /// </remarks>
        protected override void OnLoad([NotNull] EventArgs e)
        {
            Assert.ArgumentNotNull(e, "e");

            this.CheckSecurity();

            base.OnLoad(e);

            if (Context.ClientPage.IsEvent)
            {
                return;
            }

            var urlHandle = UrlHandle.Get();

            var icon = urlHandle["ic"];

            if (!string.IsNullOrEmpty(icon))
            {
                this.Dialog["Icon"] = icon;
            }

            var header = WebUtil.SafeEncode(urlHandle["he"]);

            if (header.Length > 0)
            {
                this.Dialog["Header"] = header;
            }

            var text = WebUtil.SafeEncode(urlHandle["txt"]);

            if (text.Length > 0)
            {
                this.Dialog["Text"] = text;
            }

            var button = WebUtil.SafeEncode(urlHandle["btn"]);

            if (button.Length > 0)
            {
                this.Dialog["OKButton"] = button;
            }

            var filter    = urlHandle["flt"];
            var blobsList = LogStorageManager.ListBlobs(filter);

            foreach (var blob in blobsList)
            {
                var item = new ListviewItem();
                this.FileLister.Controls.Add(item);
                item.ID     = Control.GetUniqueID("I");
                item.Header = blob.Uri.Segments.Last();
                item.Icon   = "Applications/16x16/document.png";
                item.ServerProperties["Blob"] = blob.Name;
                item.ColumnValues["size"]     = MainUtil.FormatSize(blob.Properties.Length);
                item.ColumnValues["modified"] = blob.Properties.LastModified.HasValue ? blob.Properties.LastModified.Value.LocalDateTime : DateTime.Now;
            }
        }
Esempio n. 7
0
        public override void Refresh()
        {
            Sitecore.Context.ClientPage.ClientResponse.DisableOutput();

            Controls.Clear();
            ColumnNames.Clear();
            ColumnNames.Add("Icon", "Icon");

            if (Data == null)
            {
                return;
            }

            var pageSize    = Data.PageSize;
            var offset      = (CurrentPage - 1) * pageSize;
            var columnNames = new HashSet <string>(StringComparer.OrdinalIgnoreCase);

            foreach (var result in FilteredItems.Skip(offset).Take(pageSize))
            {
                var lvi  = new ListviewItem();
                var keys = result.Display.Keys;
                lvi.ID   = GetUniqueID("lvi");
                lvi.Icon = keys.Contains("__icon")
                    ? result.Display["__Icon"]
                    : keys.Contains("Icon")
                        ? result.Display["Icon"]
                        : (result.Original is Item)
                            ? ((Item)result.Original).Appearance.Icon
                            : "Office/32x32/graph_node.png";
                lvi.Value = result.Id.ToString(CultureInfo.InvariantCulture);
                foreach (var column in result.Display.Keys)
                {
                    columnNames.Add(column);
                    var val = result.Display[column];
                    switch (val)
                    {
                    case ("False"):
                        var uncheckedSource = Sitecore.Resources.Images.GetThemedImageSource("Office/16x16/delete.png");
                        val = $"<div class='unchecked'><img src='{uncheckedSource}'/></div>";
                        break;

                    case ("True"):
                        var checkedSource = Sitecore.Resources.Images.GetThemedImageSource("Office/16x16/check.png");
                        val = $"<div class='checked'><img src='{checkedSource}'/></div>";
                        break;
                    }
                    lvi.ColumnValues.Add(column, val);
                }
                Controls.Add(lvi);
            }
            foreach (var column in columnNames)
            {
                ColumnNames.Add(column, column);
            }

            Sitecore.Context.ClientPage.ClientResponse.EnableOutput();
            Sitecore.Context.ClientPage.ClientResponse.SetOuterHtml(ID, this);
        }
Esempio n. 8
0
        public void RenderItem(Func <ListviewWidget, HelperResult> content = null, Boolean divider = false)
        {
            var item = new ListviewItem {
                Result  = content(this),
                Divider = divider
            };

            RenderItem(item);
        }
Esempio n. 9
0
        /// <summary>
        /// Adds a dummy message to the job list control if there are no publishing jobs to show.
        /// </summary>
        private void AddEmptyItem()
        {
            JobList.Controls.Clear();
            ListviewItem emptyItem = new ListviewItem();

            emptyItem.Header   = Sitecore.Globalization.Translate.Text("There are no publishing jobs to display.");
            emptyItem.Disabled = true;
            Context.ClientPage.AddControl(JobList, emptyItem);
            SheerResponse.SetInnerHtml("JobPanel", JobList);
        }
Esempio n. 10
0
        public ListviewItem AddItem(string header)
        {
            var control = new ListviewItem {
                ID = Sitecore.Web.UI.HtmlControls.Control.GetUniqueID("I")
            };

            _view.Controls.Add(control);
            control.Header = header;
            return(control);
        }
Esempio n. 11
0
        public ListviewWidget AddItem(Func <ListviewWidget, HelperResult> content = null, Boolean divider = false)
        {
            var item = new ListviewItem {
                Result  = content(this),
                Divider = divider
            };

            _items.Add(item);

            return(this);
        }
Esempio n. 12
0
        protected void AddItem(Sitecore.Data.Items.Item item)
        {
            Control parent = ItemList;

            ListviewItem listItem = new ListviewItem();

            listItem.ID = Control.GetUniqueID("I");
            parent.Controls.Add(listItem);

            listItem.Icon   = item.Appearance.Icon;
            listItem.Header = item.Paths.ContentPath;

            if (Properties.ReportItem.Version)
            {
                listItem.ColumnValues.Add("version", item.Version.ToString());
            }
            if (Properties.ReportItem.Language)
            {
                listItem.ColumnValues.Add("lang", item.Language.Name);
            }

            foreach (FieldItem field in Properties.ReportItem.StFields)
            {
                Field  f = item.Fields[field.FieldID];
                object o = f;
                if (field.Props != null)
                {
                    if (!string.IsNullOrEmpty(field.Fieldtype))
                    {
                        //o = Sitecore.Reflection.ReflectionUtil.CreateObject("Sitecore.kernel", field.Fieldtype, new object[]{f});
                        o = Sitecore.Reflection.ReflectionUtil.CreateObject(field.Fieldtype, new object[] { f });
                    }

                    StringBuilder sb = new StringBuilder();
                    foreach (string st in field.Props)
                    {
                        PropertyInfo pi = o.GetType().GetProperty(st);
                        if (pi != null)
                        {
                            sb.Append(pi.GetValue(o, null) + " ");
                        }
                    }
                    listItem.ColumnValues.Add(field.Name, sb.ToString());
                }
                else
                {
                    listItem.ColumnValues.Add(field.Name, f.Value);
                }
            }
            foreach (string st in Properties.ReportItem.CustomFields)
            {
                listItem.ColumnValues.Add(st, item[st]);
            }
        }
Esempio n. 13
0
        public void RenderItem(ListviewItem item)
        {
            _writer.WriteBeginTag("li");
            if (item.Divider == true)
            {
                _writer.WriteAttribute("data-role", "list-divider");
            }
            _writer.Write(System.Web.UI.HtmlTextWriter.TagRightChar);

            _writer.Write(item.Result.ToHtmlString());

            _writer.WriteEndTag("li");
        }
        protected void FillTaskList()
        {
            XmlNodeList configNodes = Factory.GetConfigNodes("scheduling/agent");

            if (configNodes != null)
            {
                int count = configNodes.Count;
                for (int i = 0; i <= (count - 1); i++)
                {
                    XmlNode node = configNodes.Item(i);
                    if (ShowNode(node))
                    {
                        var item = new ListviewItem();
                        Context.ClientPage.AddControl(AgentTaskList, item);
                        item.ID   = Control.GetUniqueID("I");
                        item.Icon = "";
                        item.ColumnValues["Name"] = item.Header = item.Value = node.Attributes["type"] == null?Translate.Text("No type is defined") : node.Attributes["type"].Value;

                        item.ColumnValues["MethodName"] = node.Attributes["method"] == null?Translate.Text("No method name is defined") : node.Attributes["method"].Value;

                        item.ColumnValues["Interval"] = node.Attributes["interval"] == null?Translate.Text("No interval is defined") : node.Attributes["interval"].Value;
                    }
                }
            }
            string query = string.Format("/sitecore/*[@@id='{0}']//*[@@templateid='{1}']", ItemIDs.SystemRoot,
                                         TemplateIDs.Schedule);

            Item[] items = Context.ContentDatabase.SelectItems(query);
            if ((items != null) && items.Any())
            {
                foreach (Item item2 in items)
                {
                    var item3 = new ScheduleItem(item2);
                    if (item3 != null)
                    {
                        var item = new ListviewItem();
                        Context.ClientPage.AddControl(ScheduledTaskList, item);
                        item.ID   = Control.GetUniqueID("I");
                        item.Icon = item3.Icon;
                        item.ColumnValues["Name"]        = item.Header = item3.DisplayName;
                        item.ColumnValues["CommandName"] = (item3.CommandItem != null)
                            ? item3.CommandItem.DisplayName
                            : "No Command Item Defined";
                        item.ColumnValues["LastRun"] = item3.LastRun.ToString("MM/dd/yyyy HH:mm:ss");
                        item.Value = item3.ID.ToString();
                    }
                }
            }
        }
 protected virtual void  CreateControl(Item item, string fields, string color = "Black", string version = "-", string language = "-" )
 {
     var lbi = new ListviewItem
                       {
                           Header =  item.Paths.FullPath,
                           Icon = item.Appearance.Icon,                                  
                           Foreground  = color,
                           ID = Control.GetUniqueID("lvi")
                       };
         lbi.ColumnValues.Add("Path",item.Paths.FullPath);
         lbi.ColumnValues.Add("Url", LinkManager.GetItemUrl(item,UrlOptions));
         lbi.ColumnValues.Add("Fields",fields);
         lbi.ColumnValues.Add("Version", version);
         lbi.ColumnValues.Add("Language", language);
     Listview.Controls.Add(lbi);
 }
Esempio n. 16
0
 public override void Put(PackageEntry entry)
 {
     if (entry.Key.IndexOf(_filter, StringComparison.InvariantCultureIgnoreCase) >= 0)
     {
         string       str;
         ListviewItem item = AddItem(entry.Key);
         item.ColumnValues["key"]     = entry.Key;
         item.ColumnValues["source"]  = PackageUtils.TryGetValue(entry.Properties, "source");
         item.ColumnValues["options"] = FormatInstallOptions(new BehaviourOptions(entry.Properties, Sitecore.Install.Constants.IDCollisionPrefix));
         if (entry.Attributes.TryGetValue("icon", out str))
         {
             item.Icon = str;
         }
         Count++;
     }
 }
Esempio n. 17
0
        private void LoadProducts()
        {
            string ProductsPath = "/sitecore/content/Home/Products/Phones";
            Item   products     = Factory.GetDatabase("master").GetItem(ProductsPath);

            foreach (Item product in products.Children)
            {
                ListviewItem productItem = new ListviewItem();
                Context.ClientPage.AddControl(ProductList, productItem);
                productItem.ID                    = Control.GetUniqueID("I");
                productItem.Header                = product["Title"];
                productItem.ColumnValues["Id"]    = product.ID.ToString();
                productItem.ColumnValues["Title"] = product["Title"];
                productItem.ColumnValues["Price"] = product["Price"];
            }
        }
 protected void FillTaskList()
 {
     XmlNodeList configNodes = Factory.GetConfigNodes("scheduling/agent");
     if (configNodes != null)
     {
         int count = configNodes.Count;
         for (int i = 0; i <= (count - 1); i++)
         {
             XmlNode node = configNodes.Item(i);
             if (ShowNode(node))
             {
                 var item = new ListviewItem();
                 Context.ClientPage.AddControl(AgentTaskList, item);
                 item.ID = Control.GetUniqueID("I");
                 item.Icon = "";
                 item.ColumnValues["Name"] = item.Header = item.Value = node.Attributes["type"] == null ? Translate.Text("No type is defined") : node.Attributes["type"].Value;
                 item.ColumnValues["MethodName"] = node.Attributes["method"] == null ? Translate.Text("No method name is defined") : node.Attributes["method"].Value;
                 item.ColumnValues["Interval"] = node.Attributes["interval"] == null ? Translate.Text("No interval is defined") : node.Attributes["interval"].Value;
             }
         }
     }
     string query = string.Format("/sitecore/*[@@id='{0}']//*[@@templateid='{1}']", ItemIDs.SystemRoot,
         TemplateIDs.Schedule);
     Item[] items = Context.ContentDatabase.SelectItems(query);
     if ((items != null) && items.Any())
     {
         foreach (Item item2 in items)
         {
             var item3 = new ScheduleItem(item2);
             if (item3 != null)
             {
                 var item = new ListviewItem();
                 Context.ClientPage.AddControl(ScheduledTaskList, item);
                 item.ID = Control.GetUniqueID("I");
                 item.Icon = item3.Icon;
                 item.ColumnValues["Name"] = item.Header = item3.DisplayName;
                 item.ColumnValues["CommandName"] = (item3.CommandItem != null)
                     ? item3.CommandItem.DisplayName
                     : "No Command Item Defined";
                 item.ColumnValues["LastRun"] = item3.LastRun.ToString("MM/dd/yyyy HH:mm:ss");
                 item.Value = item3.ID.ToString();
             }
         }
     }
 }
Esempio n. 19
0
 /// <summary>
 /// Fills out required fields for a ListviewItem control.
 /// </summary>
 /// <param name="listItem">ListviewItem instance.</param>
 /// <param name="job">A publishing job to be assosiated with.</param>
 /// <param name="selectedItemId">Selected item ID.</param>
 protected void PopulateListviewItem(ListviewItem listItem, PublishJobEntry job, string selectedItemId)
 {
     listItem.ID = job.JobHandle;
     if (job.JobHandle.Equals(selectedItemId))
     {
         listItem.Selected = true;
     }
     listItem.Header = job.Name;
     listItem.ColumnValues["jobName"]      = job.Name;
     listItem.ColumnValues["jobCategory"]  = job.Category;
     listItem.ColumnValues["jobState"]     = job.State;
     listItem.ColumnValues["jobOwner"]     = job.OwnerName;
     listItem.ColumnValues["jobProcessed"] = job.Status.Total > 0
                                             ? job.Status.Processed + "/" + job.Status.Total
                                             : job.Status.Processed.ToString();
     // QueueTime get setup whenever the job gets created.
     listItem.ColumnValues["jobStarted"] = job.Status.Job.QueueTime.ToLocalTime().ToLongTimeString();
 }
 /// <summary>
 /// Fills out required fields for a ListviewItem control.
 /// </summary>
 /// <param name="listItem">ListviewItem instance.</param>
 /// <param name="job">A publishing job to be assosiated with.</param>
 /// <param name="selectedItemId">Selected item ID.</param>
 protected void PopulateListviewItem(ListviewItem listItem, PublishJobEntry job, string selectedItemId)
 {
     listItem.ID = job.JobHandle;
      if (job.JobHandle.Equals(selectedItemId))
      {
     listItem.Selected = true;
      }
      listItem.Header = job.Name;
      listItem.ColumnValues["jobName"] = job.Name;
      listItem.ColumnValues["jobCategory"] = job.Category;
      listItem.ColumnValues["jobState"] = job.State;
      listItem.ColumnValues["jobOwner"] = job.OwnerName;
      listItem.ColumnValues["jobProcessed"] = job.Status.Total > 0
                                             ? job.Status.Processed + "/" + job.Status.Total
                                             : job.Status.Processed.ToString();
      // QueueTime get setup whenever the job gets created.
      listItem.ColumnValues["jobStarted"] = job.Status.Job.QueueTime.ToLocalTime().ToLongTimeString();
 }
Esempio n. 21
0
        public static Listview SetPublishingIListview(Listview publishListview, List <PublishedItemEntity> publishedItemsInfo)
        {
            if (publishedItemsInfo != null)
            {
                foreach (var publishedItem in publishedItemsInfo)
                {
                    var listSubItem = new ListviewItem();

                    publishListview.Controls.Add(listSubItem);

                    listSubItem.ID = Control.GetUniqueID("I");

                    listSubItem.ColumnValues["itemName"] = publishedItem.ItemName;
                    listSubItem.ColumnValues["itemPath"] = publishedItem.ItemPath;
                }
            }

            return(publishListview);
        }
Esempio n. 22
0
        private void AddEntry(Item item, string type, string icon)
        {
            Context.ClientPage.ClientResponse.DisableOutput();
            ListviewItem control;

            try
            {
                control    = new ListviewItem();
                control.ID = Control.GetUniqueID("ListItem");
                Context.ClientPage.AddControl(this.ItemList, control);
                string text = item.Uri.ToString();
                control.Icon   = icon;
                control.Header = $"{type}, {item.Database.Name}:{item.Paths.Path}";
                control.Value  = $"{type}:{text}";
            }
            finally
            {
                Context.ClientPage.ClientResponse.EnableOutput();
            }
            Context.ClientPage.ClientResponse.Refresh(this.ItemList);
        }
Esempio n. 23
0
        protected void OnCommandAllClick() // needs work
        {
            Assert.IsNotNull(Properties, "properties is null");
            Assert.IsNotNull(Properties.Command, "command is null");



            int index  = 0;
            int length = ItemList.Items.Length;

            for (int i = 0; i < length; i++)
            {
                ListviewItem lvi = ItemList.Items.GetValue(index) as ListviewItem;
                if (lvi != null)
                {
                    Sitecore.Data.Items.Item item = retrieveItem(lvi);

                    if (item != null)
                    {
                        if (Properties.Command.ExecCommand(item))
                        {
                            ItemList.Controls.RemoveAt(index);
                        }
                        else
                        {
                            index++;
                        }
                    }
                }
            }
            Sitecore.Context.ClientPage.ClientResponse.Refresh(ItemList);
            if (index > 0)
            {
                Sitecore.Context.ClientPage.ClientResponse.Alert("You don't have permission to execute the command on some of the items");
            }
        }
		// Method that creates and fills a new Listview control with data from our query
		protected void FillItemList()
		{
			//Query to show job in order.
			var datasource = from JobEntity job in lstJobDetails
											 orderby job.QueueTime, job.JobName, job.JobCategory, job.JobStatus
											 select job;


			if (datasource == null)
			{
				ItemList.Controls.Clear();
				Context.ClientPage.ClientResponse.SetOuterHtml("ItemList", ItemList);
				return;
			}

			foreach (JobEntity jd in datasource)
			{

				ListviewItem listItem = new ListviewItem();
				Context.ClientPage.AddControl(ItemList, listItem);

				//Check if full site then show in red color(Alerting)
				if (jd.JobName.ToLower().Equals("publish") && !jd.Mode.ToLower().Equals(SingleItem))
					listItem.Style.Add("background-color", "#FFA07A");

				//As publishing jobs are heavy jobs and if child count is more then 1000 then it requires attention,
				//1000 can be changed as per environment requirement.
				if (jd.JobName.ToLower().Equals("publish") && jd.Mode.ToLower().Equals(SingleItem))
				{
					if (int.Parse(jd.ChildCount) > 1000)
						listItem.Style.Add("background-color", "#68BCFF");
				}

				listItem.ID = Control.GetUniqueID("I");
				// Populate the list item with data.
				listItem.ColumnValues["JobName"] = jd.JobName;
				listItem.ColumnValues["QueueTime"] = String.Format("{0:T}", jd.QueueTime.ToLocalTime());
				listItem.ColumnValues["Handle"] = jd.Handle;
				listItem.ColumnValues["JobStatus"] = jd.JobStatus;
				listItem.ColumnValues["JobCategory"] = jd.JobCategory;
				listItem.ColumnValues["Mode"] = jd.Mode;
				listItem.ColumnValues["Owner"] = jd.Owner;
				listItem.ColumnValues["ItemName"] = jd.ItemName;
				listItem.ColumnValues["SourceDatabase"] = jd.SourceDatabase;
				listItem.ColumnValues["TargetDatabase"] = jd.TargetDatabase;
				listItem.ColumnValues["CurrentTargetDatabase"] = jd.CurrentTargetDatabase;
				listItem.ColumnValues["Processed"] = jd.Processed;
				listItem.ColumnValues["ChildCount"] = jd.ChildCount;
				listItem.ColumnValues["Percentage"] = jd.Percentage;
				listItem.ColumnValues["Languages"] = jd.Languages;
				listItem.ColumnValues["CurrentLanguage"] = jd.CurrentLanguage;
				listItem.ColumnValues["Message"] = jd.Message;
			}

			Context.ClientPage.ClientResponse.SetOuterHtml("ItemList", ItemList);
		}
 /// <summary>
 /// Adds a dummy message to the job list control if there are no publishing jobs to show.
 /// </summary>
 private void AddEmptyItem()
 {
     JobList.Controls.Clear();
      ListviewItem emptyItem = new ListviewItem();
      emptyItem.Header = Sitecore.Globalization.Translate.Text("There are no publishing jobs to display.");
      emptyItem.Disabled = true;
      Context.ClientPage.AddControl(JobList, emptyItem);
      SheerResponse.SetInnerHtml("JobPanel", JobList);
 }
 /// <summary>
 /// Adds publising jobs to the job list control.
 /// </summary>
 private void FillJobList()
 {
     IEnumerable<PublishJobEntry> jobEntries = PublishJobHelper.GetJobs();
      if (((IList) jobEntries).Count == 0)
      {
     AddEmptyItem();
      }
      else
      {
     string selectedItemId = "";
     if (JobList.SelectedItems.Length > 0)
     {
        selectedItemId = JobList.SelectedItems[0].ID;
     }
     JobList.Controls.Clear();
     foreach (var job in jobEntries)
     {
        ListviewItem listItem = new ListviewItem();
        Context.ClientPage.AddControl(JobList, listItem);
        PopulateListviewItem(listItem, job, selectedItemId);
     }
     SheerResponse.SetInnerHtml("JobPanel", JobList);
      }
 }
 private void AddEntry(Item item, string type, string icon)
 {
     Context.ClientPage.ClientResponse.DisableOutput();
     ListviewItem control;
     try
     {
         control = new ListviewItem();
         control.ID = Control.GetUniqueID("ListItem");
         Context.ClientPage.AddControl(this.ItemList, control);
         string text = item.Uri.ToString();
         control.Icon = icon;
         control.Header = $"{type}, {item.Database.Name}:{item.Paths.Path}";
         control.Value = $"{type}:{text}";
     }
     finally
     {
         Context.ClientPage.ClientResponse.EnableOutput();
     }
     Context.ClientPage.ClientResponse.Refresh(this.ItemList);
 }
Esempio n. 28
0
        private Sitecore.Data.Items.Item retrieveItem(ListviewItem listItem)
        {
            string path = listItem.Header;
            Sitecore.Globalization.Language lang = Sitecore.Globalization.Language.Current;
            Sitecore.Data.Version version = Sitecore.Data.Version.Latest;
            Sitecore.Data.Items.Item item = null;
            if (listItem.ColumnValues.Contains("lang"))
            {
                Sitecore.Globalization.Language.TryParse(listItem.ColumnValues["lang"].ToString(), out lang);
            }
            if (listItem.ColumnValues.Contains("version"))
            {
                version = new Sitecore.Data.Version(listItem.ColumnValues["version"].ToString());
            }

            item =
                Properties.Db.GetItem(path, lang, version);
            if (item == null)
            {
                if (Properties.Db.HasContentItem)
                {
                    path = "/sitecore/content/" + path;
                    item = Properties.Db.GetItem(path, lang, version);
                    if (item  != null)
                    {
                        return item;
                    }
                }
                    throw new Exception("Item does not exist in such language");
            }
            return item;
        }
        protected void BringResults(Message message)
        {
            var rootItem = RootItemDataContext.GetFolder();

            // Activate buttons
            btnExecuteAll.Disabled =
                btnExecuteSelected.Disabled = btnSelectAll.Disabled = false;

            // Switch Context DB for the query
            var currentDb = Context.Database;
            Context.Database = rootItem.Database;

            // Execute query
            var query = rootItem.GetItemXPath() + "//*";
            var scQuery = new Query(query) { Max = 100000 };
            var queryResult = scQuery.Execute();

            // Get Items from Query
            var allItems = new List<Item>();
            if (queryResult.GetType() == typeof(QueryContext))
                allItems.Add(((QueryContext)queryResult).GetQueryContextItem());
            else
                allItems = ((QueryContext[])queryResult).Select(p => p.GetQueryContextItem()).ToList();
            allItems.Insert(0, rootItem);

            // Switch Context DB back
            Context.Database = currentDb;

            // Render results
            ResultItems.Controls.Clear();
            var processor = new Rules.RuleProcessor(Rules, RuleItem);
            foreach (var item in allItems)
            {
                if (!processor.ValidateRule(item))
                    continue;

                // Create and add the new ListviewItem control to the Listview.
                // We have to assign an unique ID to each control on the page.
                var listItem = new ListviewItem();
                Context.ClientPage.AddControl(ResultItems, listItem);
                listItem.ID = Control.GetUniqueID("I");

                // Populate the list item with data.
                listItem.Header = item.Name;
                listItem.Icon = item.Appearance.Icon;
                listItem.Value = item.ID.ToString();
                listItem.ColumnValues["path"] = item.Paths.Path;
                listItem.ColumnValues["language"] = item.Language.Name;
                listItem.ColumnValues["version"] = item.Version.ToString();
            }

            // We need to replace the html in order to avoid duplicate ID's
            Context.ClientPage.ClientResponse.SetOuterHtml("ItemList", ResultItems);
            ResultItems.Refresh();
        }
        private void FillJobList()
        {
            try
            {
                bool queuedFlag = false;
                IEnumerable<PublishJobEntry> jobEntries = PublishJobHelper.GetJobs();
                if (((IList)jobEntries).Count == 0)
                {
                    AddEmptyItem();
                }
                else
                {
                    string selectedItemId = "";

                    if (JobList.SelectedItems.Length > 0)
                    {
                        selectedItemId = JobList.SelectedItems[0].ID;
                    }
                    JobList.Controls.Clear();

                    foreach (var job in jobEntries)
                    {
                        if (job.State.Contains("Queued"))
                        {
                            queuedFlag = true;
                            SheerResponse.SetInnerHtml("lblPublishing", "Queued...");

                            break;
                        }
                        else
                        {
                            queuedFlag = false;
                        }
                    }

                    if (queuedFlag)
                    {
                        SheerResponse.SetAttribute("PublishStatusManagerLink", "style", "display:block;");
                        SheerResponse.SetAttribute("PublishingTarget", "style", "display:none;");
                        SheerResponse.SetAttribute("imgSpinner", "style", "margin-top:20px !important;");
                        SheerResponse.SetInnerHtml("lblPublishing", "Queued...");

                        jobEntries = jobEntries.OrderBy(j => j.Status.Job.QueueTime.ToLocalTime());

                        foreach (var job in jobEntries)
                        {
                            if (job.State != "Finished")
                            {
                                ListviewItem listItem = new ListviewItem();
                                listItem.Disabled = true;

                                if (job.State.Contains("Queued") && job.OwnerName.Contains(Membership.GetUser().UserName))
                                {
                                    listItem.Selected = true;
                                }
                                if(job.State.Contains("Running") && job.OwnerName.Contains(Membership.GetUser().UserName))
                                {
                                    SheerResponse.SetInnerHtml("lblPublishing", "Publishing...");
                                }

                                Context.ClientPage.AddControl(JobList, listItem);

                                PopulateListviewItem(listItem, job, selectedItemId);
                            }
                        }
                        SheerResponse.SetInnerHtml("JobPanel", JobList);
                        SheerResponse.SetAttribute("JobPanel", "Disabled", "true");
                    }
                    else
                    {
                        SheerResponse.SetAttribute("PublishStatusManagerLink", "style", "display:none;");
                        SheerResponse.SetAttribute("PublishingTarget", "style", "display:block;");
                        SheerResponse.SetAttribute("imgSpinner", "style", " ");
                        SheerResponse.SetInnerHtml("lblPublishing", "Publishing...");

                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error("Publish History : Sitecore Ribbon Error : " + ex.Message, Context.Item);
                Log.Error("Publish History : Sitecore Ribbon Error : " + ex.StackTrace, Context.Item);
            }
        }
Esempio n. 31
0
        private void populateItemList(int start, int count)
        {
            ItemList.Controls.Clear();
            ItemList.ColumnNames.Clear();
            ItemList.ColumnNames.Add("Icon", "Icon");

            HashSet<string> columnNames = new HashSet<string>();

            foreach (var result in Current.Context.Report.GetResultElements(start - 1, count))
            {
                ListviewItem lvi = new ListviewItem();
                lvi.ID = Control.GetUniqueID("lvi");
                lvi.Icon = result.Icon;
                lvi.Value = result.Value;
                foreach (var column in result.GetColumnNames())
                {
                    columnNames.Add(column);
                    lvi.ColumnValues.Add(column, result.GetColumnValue(column));
                }
                ItemList.Controls.Add(lvi);
            }
            foreach (var column in columnNames)
            {
                ItemList.ColumnNames.Add(column, column);
            }

            Status.Text = string.Format("{0} results found.", Current.Context.Report.ResultsCount());

            int noPages = (int)Math.Ceiling((decimal)Current.Context.Report.ResultsCount() / Current.Context.Settings.PageSize);
            ItemList.CurrentPage = (int)Math.Ceiling((decimal)start / Current.Context.Settings.PageSize);

            int startpage = noPages > Current.Context.Settings.MaxNumberPages
                && ItemList.CurrentPage > Current.Context.Settings.MaxNumberPages / 2 ? ItemList.CurrentPage - Current.Context.Settings.MaxNumberPages / 2 : 1;
            int endpage = Math.Min(startpage + Current.Context.Settings.MaxNumberPages, noPages);
            if (noPages > 0)
            {
                System.Text.StringBuilder sb = new System.Text.StringBuilder("&nbsp;&nbsp; Page ");
                if (startpage > 1)
                {
                    int newpage = Math.Max(1, startpage - Current.Context.Settings.MaxNumberPages);
                    if (newpage > 1)
                    {
                        ASR.Controls.LinkButton b = new ASR.Controls.LinkButton();
                        b.Header = "first";
                        b.Click = "changepage:" + 1;
                        sb.Append(b.RenderAsText());
                    }
                    ASR.Controls.LinkButton lb = new ASR.Controls.LinkButton();
                    lb.Header = "...";
                    lb.Click = "changepage:" + newpage;
                    sb.Append(lb.RenderAsText());
                }
                for (int i = startpage; i <= endpage; i++)
                {
                    ASR.Controls.LinkButton b = new ASR.Controls.LinkButton();
                    b.Header = i.ToString();
                    b.Selected = i == ItemList.CurrentPage;
                    b.Click = "changepage:" + i;
                    sb.Append(b.RenderAsText());
                }
                if (endpage < noPages)
                {
                    int newpage = Math.Min(noPages, endpage + Current.Context.Settings.MaxNumberPages / 2);
                    ASR.Controls.LinkButton b = new ASR.Controls.LinkButton();
                    b.Header = "...";
                    b.Click = "changepage:" + newpage;
                    sb.Append(b.RenderAsText());
                    if (newpage < noPages)
                    {
                        b = new ASR.Controls.LinkButton();
                        b.Header = "last";
                        b.Click = "changepage:" + noPages;
                        sb.Append(b.RenderAsText());
                    }
                }
                Status.Text += sb.ToString();
            }

            Sitecore.Context.ClientPage.ClientResponse.Refresh(ItemList);

            Sitecore.Context.ClientPage.ClientResponse.Refresh(Status);
        }
 protected void Launch(ListviewItem listviewItem)
 {
     base.Launch(listviewItem);
     CheckforPublish();
 }
 /// <summary>
 /// Removes the control that has specified id.
 /// 
 /// </summary>
 /// <param name="id">The id.</param>
 public void Remove(string id)
 {
     ListviewItem[] listviewItemArray;
     if (id.Length == 0)
         listviewItemArray = this.ItemList.SelectedItems;
     else
         listviewItemArray = new ListviewItem[1]
 {
   Context.ClientPage.FindControl(id) as ListviewItem
 };
     foreach (ListviewItem listviewItem in listviewItemArray)
     {
         if (listviewItem != null)
         {
             listviewItem.Parent.Controls.Remove((System.Web.UI.Control)listviewItem);
             Context.ClientPage.ClientResponse.Remove(listviewItem.ID, true);
         }
     }
 }
Esempio n. 34
0
        //private void openReport(NameValueCollection nvc)
        //{
        //  var id = nvc["id"];
        //  if (string.IsNullOrEmpty(id))
        //  {
        //    return;
        //  }

        //  var director = new SCDirector("master", "en");
        //  if (!director.ObjectExists(id)) return;
        //  var rItem = director.GetObjectByIdentifier<ReportItem>(id);
        //  foreach (string key in nvc.Keys)
        //  {
        //    if (key.Contains("^"))
        //    {
        //      var item_parameter = key.Split('^');
        //      var g = new Guid(item_parameter[0]);

        //      var ri = rItem.FindItem(g);
        //      if (ri != null)
        //      {
        //        ri.SetAttributeValue(item_parameter[1], nvc[key]);
        //      }
        //    }
        //  }
        //  Current.Context.ReportItem = rItem;
        //  Current.Context.Report = null;
        //  this.updateInterface(null);
        //}

        private void populateItemList(int start, int count)
        {
            this.ItemList.Controls.Clear();
            this.ItemList.ColumnNames.Clear();
            this.ItemList.ColumnNames.Add("Icon", "Icon");

            var columnNames = new HashSet <string>();

            foreach (DisplayElement result in Current.Context.Report.GetResultElements(start - 1, count))
            {
                var lvi = new ListviewItem {
                    ID = Control.GetUniqueID("lvi"), Icon = result.Icon, Value = result.Value
                };
                foreach (var column in result.GetColumnNames())
                {
                    columnNames.Add(column);
                    lvi.ColumnValues.Add(column, result.GetColumnValue(column));
                }
                this.ItemList.Controls.Add(lvi);
            }
            foreach (var column in columnNames)
            {
                this.ItemList.ColumnNames.Add(column, column);
            }

            this.Status.Text = string.Format("{0} results found.", Current.Context.Report.ResultsCount());

            var noPages =
                (int)Math.Ceiling((decimal)Current.Context.Report.ResultsCount() / Current.Context.Settings.PageSize);

            this.ItemList.CurrentPage = (int)Math.Ceiling((decimal)start / Current.Context.Settings.PageSize);

            var startpage = noPages > Current.Context.Settings.MaxNumberPages &&
                            this.ItemList.CurrentPage > Current.Context.Settings.MaxNumberPages / 2
                        ? this.ItemList.CurrentPage - Current.Context.Settings.MaxNumberPages / 2
                        : 1;
            var endpage = Math.Min(startpage + Current.Context.Settings.MaxNumberPages, noPages);

            if (noPages > 0)
            {
                var sb = new StringBuilder("&nbsp;&nbsp; Page ");
                if (startpage > 1)
                {
                    var newpage = Math.Max(1, startpage - Current.Context.Settings.MaxNumberPages);
                    if (newpage > 1)
                    {
                        var b = new LinkButton {
                            Header = "first", Click = "changepage:" + 1
                        };
                        sb.Append(b.RenderAsText());
                    }
                    var lb = new LinkButton {
                        Header = "...", Click = "changepage:" + newpage
                    };
                    sb.Append(lb.RenderAsText());
                }
                for (var i = startpage; i <= endpage; i++)
                {
                    var b = new LinkButton
                    {
                        Header = i.ToString(), Selected = i == this.ItemList.CurrentPage, Click = "changepage:" + i
                    };
                    sb.Append(b.RenderAsText());
                }
                if (endpage < noPages)
                {
                    var newpage = Math.Min(noPages, endpage + Current.Context.Settings.MaxNumberPages / 2);
                    var b       = new LinkButton {
                        Header = "...", Click = "changepage:" + newpage
                    };
                    sb.Append(b.RenderAsText());
                    if (newpage < noPages)
                    {
                        b = new LinkButton {
                            Header = "last", Click = "changepage:" + noPages
                        };
                        sb.Append(b.RenderAsText());
                    }
                }
                this.Status.Text += sb.ToString();
            }

            Context.ClientPage.ClientResponse.Refresh(this.ItemList);

            Context.ClientPage.ClientResponse.Refresh(this.Status);
        }
Esempio n. 35
0
        private void PopulateItemList(int start, int count)
        {
            ItemList.Controls.Clear();
            ItemList.ColumnNames.Clear();
            ItemList.ColumnNames.Add("Icon", "Icon");

            var columnNames = new HashSet<string>();

            foreach (DisplayElement result in Current.Context.Report.GetResultElements(start - 1, count))
            {
                var lvi = new ListviewItem
                    {
                        ID = Control.GetUniqueID("lvi"),
                        Icon = result.Icon,
                        Value = result.Value
                    };
                foreach (string column in result.GetColumnNames())
                {
                    columnNames.Add(column);
                    lvi.ColumnValues.Add(column, result.GetColumnValue(column));
                }
                ItemList.Controls.Add(lvi);
            }
            foreach (string column in columnNames)
            {
                ItemList.ColumnNames.Add(column, column);
            }

            Status.Text = string.Format("{0} results found.", Current.Context.Report.ResultsCount());

            var noPages =
                (int) Math.Ceiling((decimal) Current.Context.Report.ResultsCount()/Current.Context.Settings.PageSize);
            ItemList.CurrentPage = (int) Math.Ceiling((decimal) start/Current.Context.Settings.PageSize);

            int startpage = noPages > Current.Context.Settings.MaxNumberPages &&
                            ItemList.CurrentPage > Current.Context.Settings.MaxNumberPages/2
                                ? ItemList.CurrentPage - Current.Context.Settings.MaxNumberPages/2
                                : 1;
            int endpage = Math.Min(startpage + Current.Context.Settings.MaxNumberPages, noPages);
            const string separator = "&nbsp;&nbsp;";
            if (noPages > 0)
            {
                var sb = new StringBuilder("&nbsp;&nbsp; Page ");
                if (startpage > 1)
                {
                    int newpage = Math.Max(1, startpage - Current.Context.Settings.MaxNumberPages);
                    if (newpage > 1)
                    {
                        var b = new LinkButton {Header = "first", Click = "changepage:" + 1};
                        sb.Append(b.RenderAsText());
                    }
                    var lb = new LinkButton {Header = "...", Click = "changepage:" + newpage};
                    sb.Append(lb.RenderAsText());
                }
                for (int i = startpage; i <= endpage; i++)
                {
                    var b = new LinkButton
                        {Header = i.ToString(CultureInfo.InvariantCulture), Selected = i == ItemList.CurrentPage, Click = "changepage:" + i};
                    b.Style.Add(HtmlTextWriterStyle.Cursor, "pointer");
                    sb.Append(b.RenderAsText());
                    sb.Append(separator);
                }
                if (endpage < noPages)
                {
                    int newpage = Math.Min(noPages, endpage + Current.Context.Settings.MaxNumberPages/2);
                    var b = new LinkButton {Header = "...", Click = "changepage:" + newpage};
                    sb.Append(b.RenderAsText());
                    if (newpage < noPages)
                    {
                        b = new LinkButton {Header = "last", Click = "changepage:" + noPages};
                        sb.Append(b.RenderAsText());
                    }
                }
                Status.Text += sb.ToString();
                Status.Style.Add(HtmlTextWriterStyle.Cursor, "default");
            }

            Sitecore.Context.ClientPage.ClientResponse.Refresh(ItemList);

            Sitecore.Context.ClientPage.ClientResponse.Refresh(Status);
        }
Esempio n. 36
0
        protected void AddItem(Sitecore.Data.Items.Item item)
        {
            Control parent = ItemList;

            ListviewItem listItem = new ListviewItem();
            listItem.ID = Control.GetUniqueID("I");
            parent.Controls.Add(listItem);

            listItem.Icon = item.Appearance.Icon;
            listItem.Header = item.Paths.ContentPath;

            if (Properties.ReportItem.Version)
            {
                listItem.ColumnValues.Add("version", item.Version.ToString());
            }
            if (Properties.ReportItem.Language)
            {
                listItem.ColumnValues.Add("lang", item.Language.Name);
            }

            foreach (FieldItem field in Properties.ReportItem.StFields)
            {
                Field f = item.Fields[field.FieldID];
                object o = f;
                if (field.Props!=null)
                {
                    if (!string.IsNullOrEmpty(field.Fieldtype))
                    {
                         //o = Sitecore.Reflection.ReflectionUtil.CreateObject("Sitecore.kernel", field.Fieldtype, new object[]{f});
                         o = Sitecore.Reflection.ReflectionUtil.CreateObject(field.Fieldtype, new object[] { f });
                    }

                    StringBuilder sb = new StringBuilder();
                    foreach (string st in field.Props)
                    {
                        PropertyInfo pi = o.GetType().GetProperty(st);
                        if (pi != null)
                        {
                            sb.Append(pi.GetValue(o, null) + " ");
                        }

                    }
                    listItem.ColumnValues.Add(field.Name, sb.ToString());

                }
                else
                    listItem.ColumnValues.Add(field.Name, f.Value);
            }
            foreach (string st in Properties.ReportItem.CustomFields)
            {
                listItem.ColumnValues.Add(st, item[st]);
            }
        }
Esempio n. 37
0
        private void populateItemList(int start, int count)
        {
            ItemList.Controls.Clear();
            ItemList.ColumnNames.Clear();
            ItemList.ColumnNames.Add("Icon", "Icon");

            HashSet <string> columnNames = new HashSet <string>();

            foreach (var result in Current.Context.Report.GetResultElements(start - 1, count))
            {
                ListviewItem lvi = new ListviewItem();
                lvi.ID    = Control.GetUniqueID("lvi");
                lvi.Icon  = result.Icon;
                lvi.Value = result.Value;
                foreach (var column in result.GetColumnNames())
                {
                    columnNames.Add(column);
                    lvi.ColumnValues.Add(column, result.GetColumnValue(column));
                }
                ItemList.Controls.Add(lvi);
            }
            foreach (var column in columnNames)
            {
                ItemList.ColumnNames.Add(column, column);
            }

            Status.Text = string.Format("{0} results found.", Current.Context.Report.ResultsCount());

            int noPages = (int)Math.Ceiling((decimal)Current.Context.Report.ResultsCount() / Current.Context.Settings.PageSize);

            ItemList.CurrentPage = (int)Math.Ceiling((decimal)start / Current.Context.Settings.PageSize);

            int startpage = noPages > Current.Context.Settings.MaxNumberPages &&
                            ItemList.CurrentPage > Current.Context.Settings.MaxNumberPages / 2 ? ItemList.CurrentPage - Current.Context.Settings.MaxNumberPages / 2 : 1;
            int endpage = Math.Min(startpage + Current.Context.Settings.MaxNumberPages, noPages);

            if (noPages > 0)
            {
                System.Text.StringBuilder sb = new System.Text.StringBuilder("&nbsp;&nbsp; Page ");
                if (startpage > 1)
                {
                    int newpage = Math.Max(1, startpage - Current.Context.Settings.MaxNumberPages);
                    if (newpage > 1)
                    {
                        ASR.Controls.LinkButton b = new ASR.Controls.LinkButton();
                        b.Header = "first";
                        b.Click  = "changepage:" + 1;
                        sb.Append(b.RenderAsText());
                    }
                    ASR.Controls.LinkButton lb = new ASR.Controls.LinkButton();
                    lb.Header = "...";
                    lb.Click  = "changepage:" + newpage;
                    sb.Append(lb.RenderAsText());
                }
                for (int i = startpage; i <= endpage; i++)
                {
                    ASR.Controls.LinkButton b = new ASR.Controls.LinkButton();
                    b.Header   = i.ToString();
                    b.Selected = i == ItemList.CurrentPage;
                    b.Click    = "changepage:" + i;
                    sb.Append(b.RenderAsText());
                }
                if (endpage < noPages)
                {
                    int newpage = Math.Min(noPages, endpage + Current.Context.Settings.MaxNumberPages / 2);
                    ASR.Controls.LinkButton b = new ASR.Controls.LinkButton();
                    b.Header = "...";
                    b.Click  = "changepage:" + newpage;
                    sb.Append(b.RenderAsText());
                    if (newpage < noPages)
                    {
                        b        = new ASR.Controls.LinkButton();
                        b.Header = "last";
                        b.Click  = "changepage:" + noPages;
                        sb.Append(b.RenderAsText());
                    }
                }
                Status.Text += sb.ToString();
            }

            Sitecore.Context.ClientPage.ClientResponse.Refresh(ItemList);

            Sitecore.Context.ClientPage.ClientResponse.Refresh(Status);
        }
        /// <summary>
        /// Populates the listview with the available templates
        /// </summary>
        protected virtual void BindListview()
        {
            List<string> templateIDs = new List<string>();
            if (Parent.Template.StandardValues != null && Parent.Template.StandardValues.Fields[Sitecore.FieldIDs.Branches] != null)
            {
                string insertOptions = Parent.Template.StandardValues.Fields[Sitecore.FieldIDs.Branches].Value;
                templateIDs.AddRange(insertOptions.Split('|'));
            }

            foreach (string templateIDString in templateIDs)
            {
                if(!ID.IsID(templateIDString))
                {
                    continue;
                }

                ID templateID;
                if (ID.TryParse(templateIDString, out templateID))
                {
                    TemplateItem template = Database.GetTemplate(templateID);
                    if (template != null)
                    {
                        ListviewItem listItem = new ListviewItem();
                        Sitecore.Context.ClientPage.AddControl(this.TemplateList, listItem);
                        listItem.ID = Control.GetUniqueID("I");

                        listItem.Header = template.Name;
                        listItem.Icon = template.Icon;
                        listItem.ColumnValues["description"] = template.InnerItem.Help.ToolTip;
                        listItem.Value = template.ID.ToString();
                    }
                }
            }
        }
 /// <summary>
 /// Adds the entry.
 /// </summary>
 /// <param name="Item">The item.</param>
 /// <param name="type">The type.</param>
 /// <param name="icon">The icon.</param>
 private void AddEntry(Item Item, string icon)
 {
     Context.ClientPage.ClientResponse.DisableOutput();
     try
     {
         ListviewItem listviewItem = new ListviewItem();
         listviewItem.ID = Sitecore.Web.UI.HtmlControls.Control.GetUniqueID("ListItem");
         Context.ClientPage.AddControl((System.Web.UI.Control)this.ItemList, (System.Web.UI.Control)listviewItem);
         string str = ((object)Item.Uri).ToString();
         listviewItem.Icon = icon;
         listviewItem.Header = string.Format("{0}", (object)Item.Paths.Path);
         listviewItem.Value = string.Format("{0}", (object)str);
     }
     finally
     {
         Context.ClientPage.ClientResponse.EnableOutput();
     }
     Context.ClientPage.ClientResponse.Refresh((System.Web.UI.Control)this.ItemList);
 }
Esempio n. 40
0
        private void PopulateItemList(int start, int count)
        {
            ItemList.Controls.Clear();
            ItemList.ColumnNames.Clear();
            ItemList.ColumnNames.Add("Icon", "Icon");

            var columnNames = new HashSet <string>();

            foreach (DisplayElement result in Current.Context.Report.GetResultElements(start - 1, count))
            {
                var lvi = new ListviewItem
                {
                    ID    = Control.GetUniqueID("lvi"),
                    Icon  = result.Icon,
                    Value = result.Value
                };
                foreach (string column in result.GetColumnNames())
                {
                    columnNames.Add(column);
                    lvi.ColumnValues.Add(column, result.GetColumnValue(column));
                }
                ItemList.Controls.Add(lvi);
            }
            foreach (string column in columnNames)
            {
                ItemList.ColumnNames.Add(column, column);
            }

            Status.Text = string.Format("{0} results found.", Current.Context.Report.ResultsCount());

            var noPages =
                (int)Math.Ceiling((decimal)Current.Context.Report.ResultsCount() / Current.Context.Settings.PageSize);

            ItemList.CurrentPage = (int)Math.Ceiling((decimal)start / Current.Context.Settings.PageSize);

            int startpage = noPages > Current.Context.Settings.MaxNumberPages &&
                            ItemList.CurrentPage > Current.Context.Settings.MaxNumberPages / 2
                                ? ItemList.CurrentPage - Current.Context.Settings.MaxNumberPages / 2
                                : 1;
            int          endpage   = Math.Min(startpage + Current.Context.Settings.MaxNumberPages, noPages);
            const string separator = "&nbsp;&nbsp;";

            if (noPages > 0)
            {
                var sb = new StringBuilder("&nbsp;&nbsp; Page ");
                if (startpage > 1)
                {
                    int newpage = Math.Max(1, startpage - Current.Context.Settings.MaxNumberPages);
                    if (newpage > 1)
                    {
                        var b = new LinkButton {
                            Header = "first", Click = "changepage:" + 1
                        };
                        sb.Append(b.RenderAsText());
                    }
                    var lb = new LinkButton {
                        Header = "...", Click = "changepage:" + newpage
                    };
                    sb.Append(lb.RenderAsText());
                }
                for (int i = startpage; i <= endpage; i++)
                {
                    var b = new LinkButton
                    {
                        Header = i.ToString(CultureInfo.InvariantCulture), Selected = i == ItemList.CurrentPage, Click = "changepage:" + i
                    };
                    b.Style.Add(HtmlTextWriterStyle.Cursor, "pointer");
                    sb.Append(b.RenderAsText());
                    sb.Append(separator);
                }
                if (endpage < noPages)
                {
                    int newpage = Math.Min(noPages, endpage + Current.Context.Settings.MaxNumberPages / 2);
                    var b       = new LinkButton {
                        Header = "...", Click = "changepage:" + newpage
                    };
                    sb.Append(b.RenderAsText());
                    if (newpage < noPages)
                    {
                        b = new LinkButton {
                            Header = "last", Click = "changepage:" + noPages
                        };
                        sb.Append(b.RenderAsText());
                    }
                }
                Status.Text += sb.ToString();
                Status.Style.Add(HtmlTextWriterStyle.Cursor, "default");
            }

            Sitecore.Context.ClientPage.ClientResponse.Refresh(ItemList);

            Sitecore.Context.ClientPage.ClientResponse.Refresh(Status);
        }
 private static Listview RefreshLinks(System.Web.UI.Control parent)
 {
     Assert.ArgumentNotNull(parent, "parent");
     DesktopLinkCollection desktopLinkCollection = new DesktopLinkCollection(Registry.GetString("/Current_User/Desktop/Links"));
     Listview listview = new Listview();
     Context.ClientPage.AddControl(parent, listview);
     listview.ID = "DesktopLinks";
     listview.Height = new System.Web.UI.WebControls.Unit(100.0, System.Web.UI.WebControls.UnitType.Percentage);
     int num = 0;
     string name = Client.ContentDatabase.Name;
     string name2 = Client.CoreDatabase.Name;
     foreach (DesktopLink current in desktopLinkCollection)
     {
         num++;
         string databaseName = current.DatabaseName;
         bool flag = true;
         string header = Shell.GetLinkHeader(current, out flag);
         bool flag2 = UIUtil.IsControlUri(current.Path);
         if (!(databaseName != name) || !(databaseName != "-") || !(databaseName != name2) || flag2)
         {
             if (!flag2 && databaseName != "-")
             {
                 Database database = Factory.GetDatabase(databaseName);
                 Item item = database.Items[current.Path];
                 if (item == null)
                 {
                     continue;
                 }
                 if (string.Compare(item.TemplateName, "Application Shortcut", System.StringComparison.InvariantCultureIgnoreCase) == 0)
                 {
                     Item applicationFromShortcut = UIUtil.GetApplicationFromShortcut(item);
                     if (applicationFromShortcut == null)
                     {
                         continue;
                     }
                 }
                 if (!flag)
                 {
                     header = item.DisplayName;
                 }
             }
             ListviewItem listviewItem = new ListviewItem();
             Context.ClientPage.AddControl(listview, listviewItem);
             listviewItem.ID = Sitecore.Web.UI.HtmlControls.Control.GetUniqueID("L");
             listviewItem.Header = header;
             listviewItem.Icon = current.Icon;
             listviewItem.ServerProperties["Link"] = current.ToString();
             listviewItem.ServerProperties["Index"] = num - 1;
             listviewItem.ClassPrefix = "scDesktop";
         }
     }
     return listview;
 }
        /// <summary>
        /// Raises the load event.
        /// </summary>
        /// <param name="e">
        /// The <see cref="System.EventArgs"/> instance containing the event data.
        /// </param>
        /// <remarks>
        /// This method notifies the server control that it should perform actions common to each HTTP
        /// request for the page it is associated with, such as setting up a database query. At this
        /// stage in the page lifecycle, server controls in the hierarchy are created and initialized,
        /// view state is restored, and form controls reflect client-side data. Use the IsPostBack
        /// property to determine whether the page is being loaded in response to a client postback,
        /// or if it is being loaded and accessed for the first time.
        /// </remarks>
        protected override void OnLoad([NotNull] EventArgs e)
        {
            Assert.ArgumentNotNull(e, "e");

              this.CheckSecurity();

              base.OnLoad(e);

              if (Context.ClientPage.IsEvent)
              {
            return;
              }

              var urlHandle = UrlHandle.Get();

              var icon = urlHandle["ic"];
              if (!string.IsNullOrEmpty(icon))
              {
            this.Dialog["Icon"] = icon;
              }

              var header = WebUtil.SafeEncode(urlHandle["he"]);
              if (header.Length > 0)
              {
            this.Dialog["Header"] = header;
              }

              var text = WebUtil.SafeEncode(urlHandle["txt"]);
              if (text.Length > 0)
              {
            this.Dialog["Text"] = text;
              }

              var button = WebUtil.SafeEncode(urlHandle["btn"]);
              if (button.Length > 0)
              {
            this.Dialog["OKButton"] = button;
              }

              var filter = urlHandle["flt"];
              var blobsList = LogStorageManager.ListBlobs(filter);

              foreach (var blob in blobsList)
              {
            var item = new ListviewItem();
            this.FileLister.Controls.Add(item);

            item.ID = Control.GetUniqueID("I");
            item.Header = blob.Uri.Segments.Last();
            item.Icon = "Applications/16x16/document.png";
            item.ServerProperties["Blob"] = blob.Name;
            item.ColumnValues["size"] = MainUtil.FormatSize(blob.Properties.Length);
            item.ColumnValues["modified"] = blob.Properties.LastModified.HasValue ? blob.Properties.LastModified.Value.LocalDateTime : DateTime.Now;
              }
        }
Esempio n. 43
0
        public override void Refresh()
        {
            Sitecore.Context.ClientPage.ClientResponse.DisableOutput();

            Controls.Clear();
            ColumnNames.Clear();
            ColumnNames.Add("Icon", "Icon");

            if (Data == null)
            {
                return;
            }

            var pageSize = Data.PageSize;
            var offset = (CurrentPage - 1)*pageSize;
            var columnNames = new HashSet<string>(StringComparer.OrdinalIgnoreCase);

            foreach (var result in FilteredItems.Skip(offset).Take(pageSize))
            {
                var lvi = new ListviewItem();
                var keys = result.Display.Keys;
                lvi.ID = GetUniqueID("lvi");
                lvi.Icon = keys.Contains("__icon")
                    ? result.Display["__Icon"]
                    : keys.Contains("Icon")
                        ? result.Display["Icon"]
                        : (result.Original is Item)
                            ? ((Item) result.Original).Appearance.Icon
                            : "Software/32x32/graph_node.png";
                lvi.Value = result.Id.ToString(CultureInfo.InvariantCulture);
                foreach (var column in result.Display.Keys)
                {
                    columnNames.Add(column);
                    var val = result.Display[column];
                    switch (val)
                    {
                        case ("False"):
                            val = "<div class='unchecked'></div>";
                            break;
                        case ("True"):
                            val = "<div class='checked'></div>";
                            break;
                    }
                    lvi.ColumnValues.Add(column, val);
                }
                Controls.Add(lvi);
            }
            foreach (var column in columnNames)
            {
                ColumnNames.Add(column, column);
            }

            Sitecore.Context.ClientPage.ClientResponse.EnableOutput();
            Sitecore.Context.ClientPage.ClientResponse.SetOuterHtml(ID, this);
        }
Esempio n. 44
0
        //private void openReport(NameValueCollection nvc)
        //{
        //  var id = nvc["id"];
        //  if (string.IsNullOrEmpty(id))
        //  {
        //    return;
        //  }
        //  var director = new SCDirector("master", "en");
        //  if (!director.ObjectExists(id)) return;
        //  var rItem = director.GetObjectByIdentifier<ReportItem>(id);
        //  foreach (string key in nvc.Keys)
        //  {
        //    if (key.Contains("^"))
        //    {
        //      var item_parameter = key.Split('^');
        //      var g = new Guid(item_parameter[0]);
        //      var ri = rItem.FindItem(g);
        //      if (ri != null)
        //      {
        //        ri.SetAttributeValue(item_parameter[1], nvc[key]);
        //      }
        //    }
        //  }
        //  Current.Context.ReportItem = rItem;
        //  Current.Context.Report = null;
        //  this.updateInterface(null);
        //}
        private void populateItemList(int start, int count)
        {
            this.ItemList.Controls.Clear();
              this.ItemList.ColumnNames.Clear();
              this.ItemList.ColumnNames.Add("Icon", "Icon");

              var columnNames = new HashSet<string>();

              foreach (DisplayElement result in Current.Context.Report.GetResultElements(start - 1, count))
              {
            var lvi = new ListviewItem { ID = Control.GetUniqueID("lvi"), Icon = result.Icon, Value = result.Value };
            foreach (var column in result.GetColumnNames())
            {
              columnNames.Add(column);
              lvi.ColumnValues.Add(column, result.GetColumnValue(column));
            }
            this.ItemList.Controls.Add(lvi);
              }
              foreach (var column in columnNames)
              {
            this.ItemList.ColumnNames.Add(column, column);
              }

              this.Status.Text = string.Format("{0} results found.", Current.Context.Report.ResultsCount());

              var noPages =
            (int)Math.Ceiling((decimal)Current.Context.Report.ResultsCount() / Current.Context.Settings.PageSize);
              this.ItemList.CurrentPage = (int)Math.Ceiling((decimal)start / Current.Context.Settings.PageSize);

              var startpage = noPages > Current.Context.Settings.MaxNumberPages &&
                      this.ItemList.CurrentPage > Current.Context.Settings.MaxNumberPages / 2
                        ? this.ItemList.CurrentPage - Current.Context.Settings.MaxNumberPages / 2
                        : 1;
              var endpage = Math.Min(startpage + Current.Context.Settings.MaxNumberPages, noPages);
              if (noPages > 0)
              {
            var sb = new StringBuilder("&nbsp;&nbsp; Page ");
            if (startpage > 1)
            {
              var newpage = Math.Max(1, startpage - Current.Context.Settings.MaxNumberPages);
              if (newpage > 1)
              {
            var b = new LinkButton { Header = "first", Click = "changepage:" + 1 };
            sb.Append(b.RenderAsText());
              }
              var lb = new LinkButton { Header = "...", Click = "changepage:" + newpage };
              sb.Append(lb.RenderAsText());
            }
            for (var i = startpage; i <= endpage; i++)
            {
              var b = new LinkButton
            { Header = i.ToString(), Selected = i == this.ItemList.CurrentPage, Click = "changepage:" + i };
              sb.Append(b.RenderAsText());
            }
            if (endpage < noPages)
            {
              var newpage = Math.Min(noPages, endpage + Current.Context.Settings.MaxNumberPages / 2);
              var b = new LinkButton { Header = "...", Click = "changepage:" + newpage };
              sb.Append(b.RenderAsText());
              if (newpage < noPages)
              {
            b = new LinkButton { Header = "last", Click = "changepage:" + noPages };
            sb.Append(b.RenderAsText());
              }
            }
            this.Status.Text += sb.ToString();
              }

              Context.ClientPage.ClientResponse.Refresh(this.ItemList);

              Context.ClientPage.ClientResponse.Refresh(this.Status);
        }