コード例 #1
0
 public ItemWorkflowModel(Item i)
 {
     if (i != null)
     {
         _contextItem = i;
         _database = i.Database;
         if (_database != null)
         {
             _workflowProvider = _database.WorkflowProvider;
             if (_workflowProvider != null)
             {
                 _workflow = _workflowProvider.GetWorkflow(ContextItem);
                 if (_workflow != null)
                 {
                     _workflowState = _workflow.GetState(ContextItem);
                 }
             }
         }
     }
 }
コード例 #2
0
        /// <summary>
        ///     Retrieves the latest history entry and determines if its latest modify date is within the date range
        /// </summary>
        /// <param name="workflowProvider"></param>
        /// <param name="item"></param>
        /// <param name="begin"></param>
        /// <param name="end"></param>
        /// <param name="lastHistoryItem"></param>
        /// <returns></returns>
        private static bool GetLatestWorkflowHistoryEntry(IWorkflowProvider workflowProvider, Item item, DateTime begin,
            DateTime end, out WorkflowEvent lastHistoryItem)
        {
            lastHistoryItem = null;

            //Get the workflow for the current item
            var itemWorkflow = workflowProvider.GetWorkflow(item);

            //If the workflow for the item is null then move to the next item
            if (itemWorkflow == null) return true;
            //Grab the history of the items workflow
            var itemHistory = itemWorkflow.GetHistory(item);

            //If the history of the item is null or has no entries then move to the next item
            if (itemHistory == null || itemHistory.Length <= 0) return true;

            //Grab the latest history update to an item
            lastHistoryItem = itemHistory[itemHistory.Length -1];

            //Ensure that the latest history update exist in the specified date range
            return lastHistoryItem.Date <= begin || lastHistoryItem.Date >= end;
        }