private static string GetWorklistOwnerName(WorklistSummary worklist)
 {
     if (worklist.IsStaffOwned)
     {
         return(Formatting.StaffNameAndRoleFormat.Format(worklist.OwnerStaff));
     }
     if (worklist.IsGroupOwned)
     {
         return(worklist.OwnerGroup.Name);
     }
     return(null);
 }
        /// <summary>
        /// Updates the specified worklist folder to reflect the specified worklist.
        /// </summary>
        /// <param name="folder"></param>
        /// <param name="worklist"></param>
        public void UpdateWorklistFolder(IWorklistFolder folder, WorklistSummary worklist)
        {
            if (!this.Folders.Contains(folder))
            {
                return;
            }

            InitializeFolderProperties(folder, worklist);

            // notify that the folder properties have changed
            NotifyFolderPropertiesChanged(folder);
        }
        /// <summary>
        /// Creates and adds a worklist folder for the specified worklist.
        /// </summary>
        /// <param name="worklist"></param>
        /// <returns></returns>
        private IWorklistFolder AddWorklistFolderHelper(WorklistSummary worklist)
        {
            // create an instance of the folder corresponding to the specified worklist class
            var folder = (IWorklistFolder) new TFolderExtensionPoint()
                         .CreateExtension(info => worklist.ClassName == GetWorklistClassForFolderClass(info.ExtensionClass.Resolve()));

            if (folder == null || !(folder is IInitializeWorklistFolder))
            {
                return(null);
            }

            InitializeFolderProperties(folder, worklist);

            // add to folders list
            this.Folders.Add(folder);

            return(folder);
        }
        /// <summary>
        /// Initializes the specified folder's properties from the specified worklist.
        /// </summary>
        /// <param name="worklist"></param>
        /// <param name="folder"></param>
        private static void InitializeFolderProperties(IWorklistFolder folder, WorklistSummary worklist)
        {
            var initFolder = (IInitializeWorklistFolder)folder;

            // augment default base path with worklist name
            var path = folder.FolderPath;

            if (!string.IsNullOrEmpty(worklist.DisplayName))
            {
                path = path.Append(new PathSegment(worklist.DisplayName, folder.ResourceResolver));
            }

            // init folder
            initFolder.Initialize(
                path,
                worklist.WorklistRef,
                worklist.Description,
                GetWorklistOwnership(worklist),
                GetWorklistOwnerName(worklist)
                );
        }
 private static WorklistOwnership GetWorklistOwnership(WorklistSummary worklist)
 {
     return(worklist.IsUserWorklist ?
            (worklist.IsStaffOwned ? WorklistOwnership.Staff : WorklistOwnership.Group)
         : WorklistOwnership.Admin);
 }
 /// <summary>
 /// Attempts to add the specified worklist to this folder system.
 /// </summary>
 /// <remarks>
 /// Returns the new folder if successful, or null if this folder system does not support the
 /// specified worklist class.
 /// </remarks>
 public IWorklistFolder AddWorklistFolder(WorklistSummary worklist)
 {
     return(AddWorklistFolderHelper(worklist));
 }