Exemple #1
0
        /// <summary>
        /// Sleep worklist item by Serial Number
        /// </summary>
        /// <param name="serialNumber">The Serial Number of worklist item</param>
        /// <param name="hours">The durations in Hours</param>
        public void SleepWorklistItem(string serialNumber, int hours, string sharedUser, string managedUser)
        {
            try {
                using (Connection workflowClient = this.GetWorkflowClient()) {
                    K2.WorklistItem worklistItem = workflowClient.OpenWorklistItem(serialNumber, "ASP", false, false, managedUser, sharedUser);

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

                    var duration = GetCalulateSeconds(hours);

                    if (duration <= 0)
                    {
                        worklistItem.Sleep(false);
                    }
                    else
                    {
                        worklistItem.Sleep(true, duration);
                    }
                }
            } catch (SmartException ex) {
                throw ex;
            }
        }
Exemple #2
0
        public static void Sleep(string sn, int second)
        {
            SourceCode.Workflow.Client.Connection con = new Connection();
            try
            {
                ConnectionSetup conSetup = GetConnectionSetup();
                con.Open(conSetup);
                con.ImpersonateUser(_CurrentUser);

                SourceCode.Workflow.Client.WorklistItem listItem = con.OpenWorklistItem(sn);
                listItem.Sleep(true, second);
            }
            catch (Exception ex)
            {
                // TODO: throw?
                throw ex;
            }
            finally
            {
                try
                {
                    con.RevertUser();
                }
                catch
                {
                    throw;
                }

                if (con != null)
                {
                    con.Close();
                }
            }
        }
Exemple #3
0
        /// <summary>
        /// 挂起
        /// </summary>
        /// <param name="sn"></param>
        /// <param name="sourceUser"></param>
        /// <param name="second"></param>
        public static void SleepWorkListItem(string sn, string sourceUser, int second)
        {
            using (Connection conn = new Connection())
            {
                try
                {
                    ConnectionSetup conSetup = GetConnectionSetup();
                    conn.Open(conSetup);
                    conn.ImpersonateUser(sourceUser);

                    SourceCode.Workflow.Client.WorklistItem listItem = conn.OpenWorklistItem(sn);
                    listItem.Sleep(true, second);
                }
                catch
                {
                    // TODO: throw?
                    throw;
                }
                finally
                {
                    try
                    {
                        conn.RevertUser();
                    }
                    catch
                    {
                        throw;
                    }

                    if (conn != null)
                    {
                        conn.Close();
                    }
                }
            }
        }