Example #1
0
    /// <summary>
    /// 加签
    /// </summary>
    /// <param name="sn"></param>
    /// <param name="Account"></param>
    /// <param name="nextUser"></param>
    public static void ForwardToNextApprover(string sn, string Account, string nextUser)
    {
        using (Connection conn = new Connection())
        {
            try
            {
                conn.Open(K2ServerName, GetConnString());
                conn.RevertUser();
                conn.ImpersonateUser(Account);

                WorklistItem wli = conn.OpenWorklistItem(sn);

                string addApproversBy = wli.ActivityInstanceDestination.DataFields["AddApproversBy"].Value.ToString();

                addApproversBy += Account + ";";

                wli.ActivityInstanceDestination.DataFields["AddApproversBy"].Value = addApproversBy;
                wli.Actions["更新"].Execute();
                wli.Redirect(nextUser);
            }
            catch
            {
                throw;
            }
            finally
            {
                conn.Close();
            }
        }
    }
Example #2
0
    /// <summary>
    /// 加签返回
    /// </summary>
    /// <param name="sn"></param>
    /// <param name="Account"></param>
    public static bool BackToPreApprover(string sn, string Account)
    {
        using (Connection conn = new Connection())
        {
            try
            {
                conn.Open(K2ServerName, GetConnString());
                conn.RevertUser();
                conn.ImpersonateUser(Account);

                WorklistItem wli = conn.OpenWorklistItem(sn);

                string addApproversBy = wli.ActivityInstanceDestination.DataFields["AddApproversBy"].Value.ToString();

                string[] arrPreApprovers = addApproversBy.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);

                string lastPreApprover = arrPreApprovers[arrPreApprovers.Length - 1];

                addApproversBy = addApproversBy.Substring(0, addApproversBy.Length - lastPreApprover.Length - 1);

                wli.ActivityInstanceDestination.DataFields["AddApproversBy"].Value = addApproversBy;
                wli.Actions["更新"].Execute();
                wli.Redirect(lastPreApprover);
                return(true);
            }
            catch
            {
                return(false);
            }
            finally
            {
                conn.Close();
            }
        }
    }
        /// <summary>
        /// Redirect Task Function.
        /// </summary>
        /// <param name="serialNumber">THe identity workflow.</param>
        /// <param name="destinationTask">The Redirect to User.</param>
        /// <returns></returns>
        public string RedirectTask(string serialNumber, string destinationTask)
        {
            string result = string.Empty;

            WorklistItem worklistItem = _connection.OpenWorklistItem(serialNumber, "ASP", true);

            worklistItem.Redirect(destinationTask);

            return(result);
        }
Example #4
0
        public ResultModel ReAssign(string sn, int assignFrom, int assignTo, out string activityName, out string processCode, out int procInstID)
        {
            Connection   k2Connect = null;
            WorklistItem workList  = null;
            ResultModel  jr        = new ResultModel()
            {
                Code = ResultCode.Fail
            };

            activityName = string.Empty;
            processCode  = string.Empty;
            procInstID   = 0;
            try
            {
                k2Connect = new Connection();
                k2Connect.Open(ConfigurationManager.AppSettings["K2Server"], ConfigurationManager.AppSettings["K2LoginString"]);
                k2Connect.ImpersonateUser(SecurityLable(assignFrom.ToString()));
                workList = k2Connect.OpenWorklistItem(sn);
                if (workList != null)
                {
                    workList.Redirect(SecurityLable(assignTo.ToString()));
                    jr.Code      = ResultCode.Sucess;
                    jr.Msg       = "";
                    activityName = workList.ActivityInstanceDestination.Name;
                    processCode  = workList.ProcessInstance.DataFields["ProcessCode"].Value.ToString();
                    procInstID   = workList.ProcessInstance.ID;
                }
            }
            catch (Exception ex)
            {
                jr.Msg = ex.Message;
            }
            finally
            {
                if (workList != null)
                {
                    if (workList.Status == WorklistStatus.Open)
                    {
                        try
                        {
                            k2Connect.RevertUser();
                            workList.Release();
                        }
                        catch { }
                    }
                }
                if (k2Connect != null)
                {
                    k2Connect.Close();
                }
            }
            return(jr);
        }
        private void RedirectWorklistItem()
        {
            string sn  = base.GetStringProperty(Constants.SOProperties.ClientWorklist.SerialNumber, true);
            string fqn = base.GetStringProperty(Constants.SOProperties.ClientWorklist.FQN, true);

            using (Connection k2Con = this.ServiceBroker.K2Connection.GetWorkflowClientConnection())
            {
                WorklistItem wli = k2Con.OpenWorklistItem(sn);
                wli.Redirect(fqn);

                k2Con.Close();
            }
        }
Example #6
0
        private void RedirectWorklistItem()
        {
            string sn  = base.GetStringProperty(Constants.SOProperties.ClientWorklist.SerialNumber, true);
            string fqn = base.GetStringProperty(Constants.SOProperties.ClientWorklist.FQN, true);

            using (Connection k2Con = new Connection())
            {
                k2Con.Open(base.K2ClientConnectionSetup);

                WorklistItem wli = k2Con.OpenWorklistItem(sn);
                wli.Redirect(fqn);

                k2Con.Close();
            }
        }
        internal void RedirectManagedUserWorklistItem(string managedUser, string serialNumber, string userName)
        {
            try
            {
                OpenConnection();
                WorklistItem item = _cnn.OpenManagedWorklistItem(managedUser, serialNumber, "ASP", false);

                item.Redirect(userName);
                CloseConnection();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                _cnn.Dispose();
            }
        }
Example #8
0
    /// <summary>
    /// 转签
    /// </summary>
    /// <param name="sn"></param>
    /// <param name="Account"></param>
    /// <param name="nextUser"></param>
    public static void ForwardToNextApprover_Change(string sn, string Account, string nextUser)
    {
        using (Connection conn = new Connection())
        {
            try
            {
                conn.Open(K2ServerName, GetConnString());
                conn.RevertUser();
                conn.ImpersonateUser(Account);

                WorklistItem wli = conn.OpenWorklistItem(sn);
                wli.Actions["更新"].Execute();
                wli.Redirect(nextUser);
            }
            catch
            {
                throw;
            }
            finally
            {
                conn.Close();
            }
        }
    }