Example #1
0
        /// <summary>
        /// Get collection data for a specified ResourceType
        /// </summary>
        /// <param name="item">PublishingCollectionItem object</param>
        /// <param name="specificDirectory">Directory of Pivot collections</param>
        /// <param name="request">HttpRequest object</param>
        private static void CreateCollectionData(PublishingCollectionItem item, DirectoryInfo specificDirectory, HttpRequest request)
        {
            List <CollectionData> collectionData = new List <CollectionData>();

            if (specificDirectory != null)
            {
                IDictionary <string, int> itemsCount = GetItemCount(specificDirectory);
                int count = 0;
                itemsCount.TryGetValue("TotalItemsCount", out count);
                item.TotalNoOfElements = count;
                itemsCount.Remove("TotalItemsCount");
                if (itemsCount != null && itemsCount.Count > 0)
                {
                    foreach (KeyValuePair <string, int> data in itemsCount)
                    {
                        string path = string.Format(
                            "{0}://{1}/VisualExplorer/{2}/{3}/{4}",
                            request.Url.Scheme,
                            request.Url.Authority,
                            pathPrefix,
                            specificDirectory.Name,
                            data.Key);
                        path = request.RequestContext.HttpContext.Server.UrlEncode(path);
                        path = string.Format("Viewer.aspx?Uri={0}", path);
                        collectionData.Add(new CollectionData {
                            Name = data.Key, NumberOfElements = data.Value, Path = path
                        });
                    }

                    item.Collection = collectionData;
                }
                else
                {
                    collectionData.Add(new CollectionData {
                        NumberOfElements = 0
                    });
                    item.Collection = collectionData;
                }
            }
            else
            {
                collectionData.Add(new CollectionData {
                    NumberOfElements = 0
                });
                item.Collection = collectionData;
            }
        }
Example #2
0
 /// <summary>
 /// RowDataBound event handler
 /// </summary>
 /// <param name="sender">Sender object</param>
 /// <param name="e">Event data for RowDataBound event</param>
 private void CollectionsGrid_RowDataBound(object sender, GridViewRowEventArgs e)
 {
     if (e.Row.RowType == System.Web.UI.WebControls.DataControlRowType.Footer)
     {
         var itemCollection = collectionsGrid.DataSource as IEnumerable <PublishingCollectionItem>;
         if (itemCollection != null)
         {
             PublishingCollectionItem pubItem = itemCollection.FirstOrDefault();
             if (pubItem != default(PublishingCollectionItem))
             {
                 e.Row.Cells[2].Text = pubItem.TotalNoOfResources.ToString();
                 int noOfElementsCount = 0;
                 itemCollection.ToList().ForEach(p => noOfElementsCount = noOfElementsCount + p.TotalNoOfElements);
                 e.Row.Cells[4].Text = noOfElementsCount.ToString();
             }
         }
     }
 }
Example #3
0
        /// <summary>
        /// Get status for Pivot collection items
        /// </summary>
        /// <param name="request">HttpRequest object</param>
        /// <returns>List of PublishingCollectionItem objects for all resource types</returns>
        internal static PublishingCollectionItems GetAllPivotCollectionItemsForPivot(HttpRequest request)
        {
            IEnumerable <DirectoryInfo> directories = EnumeratePublishingFolder();

            PublishingServiceReference.PublishingServiceClient client = new PublishingServiceReference.PublishingServiceClient();
            PublishingCollectionItems result    = new PublishingCollectionItems();
            IDictionary <string, int> resources = GetResourceCount();
            int totalResourceCount = 0;

            resources.TryGetValue("Zentity.Core.Resource", out totalResourceCount);

            foreach (KeyValuePair <string, int> resource in resources)
            {
                if (resource.Key.Equals("Zentity.Core.Resource"))
                {
                    continue;
                }

                DirectoryInfo specificDirectory = directories.Where(d => d.Name.Equals(resource.Key)).FirstOrDefault();
                string        dataModelName = string.Empty, resourceTypeName = string.Empty;
                if (resource.Key.Contains("."))
                {
                    dataModelName    = resource.Key.Remove(resource.Key.LastIndexOf('.'));
                    resourceTypeName = resource.Key.Replace(dataModelName + ".", string.Empty);
                }

                PublishingCollectionItem item          = new PublishingCollectionItem();
                PublishStatus            publishStatus = client.GetPublishingStatusByResourceType(dataModelName, resourceTypeName);
                item.DataModel          = dataModelName;
                item.ResourceType       = resourceTypeName;
                item.NumberOfResources  = resource.Value;
                item.TotalNoOfResources = totalResourceCount;

                if (publishStatus == null)
                {
                    List <PublishStatus> publishStatusFromQueue = client.GetQueuedRequestsByResourceType(dataModelName, resourceTypeName);
                    if (publishStatusFromQueue != null && publishStatusFromQueue.Count > 0)
                    {
                        item.Status = PublishingStatus.Queued;
                    }
                    else
                    {
                        item.Status = PublishingStatus.NotStarted;
                    }
                }
                else
                {
                    if (publishStatus.CurrentStage == PublishStage.Completed || publishStatus.CurrentStage == PublishStage.AbortedOnDemand || publishStatus.CurrentStage == PublishStage.AbortedOnError)
                    {
                        List <PublishStatus> publishStatusFromQueue = client.GetQueuedRequestsByResourceType(dataModelName, resourceTypeName);
                        if (publishStatusFromQueue != null && publishStatusFromQueue.Count > 0)
                        {
                            item.Status = PublishingStatus.Queued;
                        }
                        else
                        {
                            item.LastUpdated = publishStatus.EndTime.Equals(DateTime.MinValue) ? string.Empty : publishStatus.EndTime.ToString();
                            SetItemStatus(item, publishStatus);
                        }
                    }
                    else
                    {
                        item.LastUpdated = publishStatus.EndTime.Equals(DateTime.MinValue) ? string.Empty : publishStatus.EndTime.ToString();
                        SetItemStatus(item, publishStatus);
                    }
                }

                CreateCollectionData(item, specificDirectory, request);
                result.Add(item);
            }

            return(result);
        }
Example #4
0
        /// <summary>
        /// Set status of a Pivot collection
        /// </summary>
        /// <param name="item">PublishingCollectionItem object</param>
        /// <param name="status">status to be set</param>
        private static void SetItemStatus(PublishingCollectionItem item, PublishStatus status)
        {
            #region Set CurrentStage and populate collection data based on the stage
            switch (status.CurrentStage)
            {
            case PublishStage.NotStarted:
                item.Status = string.Format("{0}", PublishingStatus.NotStarted);
                break;

            case PublishStage.Initiating:
                item.Status = string.Format("{0}", PublishingStatus.Initiating);
                break;

            case PublishStage.FetchingResourceItems:
                item.Status = string.Format("{0}", PublishingStatus.FetchingResourceItems);
                break;

            case PublishStage.ProcessingResourceItems:
                item.Status = string.Format("{0} ({1} of {2})", PublishingStatus.ProcessingResourceItems, status.ResourceItems.Completed, status.ResourceItems.Total);
                break;

            case PublishStage.PublishIntermediateCollection:
                item.Status = string.Format("{0}", PublishingStatus.PublishingIntermediateCollection);
                break;

            case PublishStage.CreatingImages:
                item.Status = string.Format("{0} ({1} of {2})", PublishingStatus.CreatingImages, status.Images.Completed, status.Images.Total);
                break;

            case PublishStage.CreatingDeepZoomImages:
                item.Status = string.Format("{0} ({1} of {2})", PublishingStatus.CreatingDeepZoomImages, status.DeepZoomImages.Completed, status.DeepZoomImages.Total);
                break;

            case PublishStage.CreatingDeepZoomCollection:
                item.Status = string.Format("{0}", PublishingStatus.CreatingDeepZoomCollection);
                break;

            case PublishStage.DeletingExistingCollection:
                item.Status = string.Format("{0}", PublishingStatus.DeletingExistingCollection);
                break;

            case PublishStage.CopyingNewCollection:
                item.Status = string.Format("{0}", PublishingStatus.CopyingNewCollection);
                break;

            case PublishStage.CopyingExistingCollection:
                item.Status = string.Format("{0}", PublishingStatus.CopyingExistingCollection);
                break;

            case PublishStage.PerformingCleanup:
                item.Status = string.Format("{0}", PublishingStatus.PerformingCleanup);
                break;

            case PublishStage.Completed:
                item.Status = string.Format("{0}", PublishingStatus.Completed);
                break;

            case PublishStage.AbortedOnError:
                item.Status = string.Format("{0}", PublishingStatus.AbortedOnError);
                break;

            case PublishStage.AbortedOnDemand:
                item.Status = string.Format("{0}", PublishingStatus.AbortedByUser);
                break;
            }
            #endregion
        }