Пример #1
0
 /// <summary>
 /// Get the worklist status of current user by serial number
 /// </summary>
 /// <param name="serial">The process serial number</param>
 /// <returns>The worklist item's status</returns>
 public K2.WorklistStatus GetWorklistStatus(string serial)
 {
     K2.WorklistStatus result = K2.WorklistStatus.Available;
     if (serial != null)
     {
         try {
             WorklistItemCollection source       = OpenWorklist();
             Cores.WorklistItem     worklistItem = (
                 from item in source
                 where item.SerialNumber == serial
                 select item).FirstOrDefault <Cores.WorklistItem>();
             result = worklistItem.Status;
         } catch (UnauthorizedAccessException) {
             throw;
         } catch (SmartException ex) {
             throw ex;
         }
     }
     return(result);
 }
Пример #2
0
        /// <summary>
        /// Call and execute worklist item's action
        /// </summary>
        /// <param name="serialNumber">The worklist item's serial number</param>
        /// <param name="action">The worklist item's action name</param>
        /// <param name="synchronous">The execution by synchronus or asynchronous</param>
        /// <param name="allowNonBatch">The allow non batch</param>
        /// <param name="item">The worklist item</param>
        /// <param name="sharedUser">The shared users</param>
        /// <param name="managedUser">The manager user</param>
        private void ExecuteAction(string serialNumber, string action, bool synchronous, bool allowNonBatch, Cores.WorklistItem item, string sharedUser, string managedUser)
        {
            string text = action.ToUpperInvariant();

            if (text.StartsWith("A:") || text.StartsWith("ACTION:"))
            {
                action = RemovePrefix(action);
            }
            else
            {
                if (text.StartsWith("R:") || text.StartsWith("REDIRECT:"))
                {
                    this.Redirect(serialNumber, RemovePrefix(action));
                    return;
                }
                if (text.StartsWith("D:") || text.StartsWith("DELEGATE:"))
                {
                    this.DelegateWorklistItem(serialNumber, RemovePrefix(action));
                    return;
                }
            }
            using (Connection workflowClient = this.GetWorkflowClient()) {
                K2.WorklistItem worklistItem = this.OpenWorklistItem(workflowClient, serialNumber, sharedUser, managedUser);

                K2.Action newAction = worklistItem.Actions[action];

                if (newAction == null)
                {
                    throw new InvalidOperationException(string.Format("Not Found", action));
                }

                if (!newAction.Batchable && !allowNonBatch)
                {
                    throw new InvalidOperationException(string.Format("Not Batchable", action));
                }

                if (item != null)
                {
                    item.ToApi(worklistItem);
                }

                newAction.Execute(synchronous);
            }
        }
Пример #3
0
 /// <summary>
 /// Call and execute worklist item's action
 /// </summary>
 /// <param name="serialNumber">The worklist item's serial number</param>
 /// <param name="action">The worklist item's action name</param>
 /// <param name="synchronous">The execution by synchronus or asynchronous</param>
 /// <param name="allowNonBatch">The allow non batch</param>
 /// <param name="item">The worklist item</param>
 private void ExecuteAction(string serialNumber, string action, bool synchronous, bool allowNonBatch, Cores.WorklistItem item)
 {
     this.ExecuteAction(serialNumber, action, synchronous, allowNonBatch, item, string.Empty, string.Empty);
 }