当前位置: 首页>>代码示例>>C#>>正文


C# Connection.RevertUser方法代码示例

本文整理汇总了C#中Connection.RevertUser方法的典型用法代码示例。如果您正苦于以下问题:C# Connection.RevertUser方法的具体用法?C# Connection.RevertUser怎么用?C# Connection.RevertUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Connection的用法示例。


在下文中一共展示了Connection.RevertUser方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ApproveK2Process


//.........这里部分代码省略.........
                {
                    #region 更新Datafield
                    if (dataFields != null && dataFields.Count > 0)
                    {
                        ProcessInstance CurrentProcessInst = workList.ProcessInstance;
                        //更新Datafields
                        foreach (string key in dataFields.Keys)
                        {
                            if (CurrentProcessInst.DataFields[key] != null)
                            {
                                if (CurrentProcessInst.DataFields[key].Value.ToString() != dataFields[key])
                                {
                                    CurrentProcessInst.DataFields[key].Value = dataFields[key];
                                }
                            }
                        }
                    }
                    #endregion

                    #region 审批任务
                    //批量审批没有actionString,默认第一个操作
                    if (string.IsNullOrEmpty(actionString))
                    {
                        if (workList.Actions[0].Name == REJECTACTION)
                        {
                            workList.GotoActivity("流程未通过");
                        }
                        else if (workList.Actions[0].Name == UNDOACTION)
                        {
                            workList.GotoActivity("流程撤销");
                        }
                        else
                        {
                            workList.Actions[0].Execute();
                        }
                    }
                    else
                    {
                        //执行匹配的操作
                        if (actionString == UNDOACTION)
                        {
                            workList.GotoActivity("流程撤销");
                        }
                        else if (actionString == REJECTACTION)
                        {
                            workList.GotoActivity("流程未通过");
                        }
                        else
                        {
                            bool isExcute = false;
                            for (int i = 0; i < workList.Actions.Count; i++)
                            {
                                if (workList.Actions[i].Name == actionString)
                                {
                                    workList.Actions[i].Execute();
                                    isExcute = true;
                                    break;
                                }
                            }
                            if (!isExcute)
                            {
                                jr.Code = ResultCode.Fail;
                                jr.Msg = string.Format("Action:{0}错误", actionString);
                                return jr;
                            }
                        }
                    }
                    #endregion

                    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;
        }
开发者ID:nanin,项目名称:k2-workflowapi,代码行数:101,代码来源:K2ServiceProvider.cs

示例2: ReAssign

        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;
        }
开发者ID:nanin,项目名称:k2-workflowapi,代码行数:49,代码来源:K2ServiceProvider.cs

示例3: StartProcess

        public ResultModel StartProcess(string processName, int loginId, string objectId, string folio, Dictionary<string, string> dataFields,out int procInstId)
        {
            Connection k2Connect = null;
            WorklistItem workList = null;
            ResultModel jr = new ResultModel() { Code = ResultCode.Fail };
            procInstId = 0;
            try
            {
                k2Connect = new Connection();
                k2Connect.Open(ConfigurationManager.AppSettings["K2Server"], ConfigurationManager.AppSettings["K2LoginString"]);
                k2Connect.ImpersonateUser(SecurityLable(loginId.ToString()));
                //创建实例
                ProcessInstance ProcessInst = k2Connect.CreateProcessInstance(processName);
                if (!string.IsNullOrEmpty(folio))
                {
                    ProcessInst.Folio = folio;
                }
                #region //赋值datafields
                foreach (string key in dataFields.Keys)
                {
                    if (ProcessInst.DataFields[key] != null)
                    {
                        ProcessInst.DataFields[key].Value = dataFields[key];
                    }
                }
                #endregion

                k2Connect.StartProcessInstance(ProcessInst);

                procInstId = ProcessInst.ID;
                jr.Code = ResultCode.Sucess;
                jr.Msg = procInstId.ToString();
            }
            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;
            //var result = (new K2Service.K2Service()).StartProcess(processCode, loginId, objectId, folio, jsonData, ConfigurationManager.AppSettings["APIKEY"]);
        }
开发者ID:nanin,项目名称:k2-workflowapi,代码行数:57,代码来源:K2ServiceProvider.cs

示例4: GetWorklistItems

        public DataTable GetWorklistItems(Dictionary<string, object> properties, Dictionary<string, object> parameters)
        {
            bool impersonate = false;
            string impersonateUser = "";
            ConnectionSetup connectSetup = new ConnectionSetup();
            connectSetup.ConnectionString = _connectionString;

            if (properties.ContainsKey("UserName"))
            {
                if (!(string.IsNullOrEmpty(properties["UserName"].ToString())))
                {
                    connectSetup.ConnectionString = _connectionstringImpersonate;
                    impersonateUser = properties["UserName"].ToString();
                    impersonate = true;
                }
                else
                    connectSetup.ConnectionString = _connectionString;
            }

            WorklistCriteria criteria = null;
            if (properties.Count > 0)
                criteria = GetWorklistCriteria(properties);

            Connection cnn = new Connection();
            try
            {
                cnn.Open(connectSetup);
                if (impersonate)
                    cnn.ImpersonateUser(impersonateUser);

                DataTable dt = GetResultTable();

                Worklist worklist;
                if ((criteria != null) && (criteria.Filters.GetLength(0) > 0))
                    worklist = cnn.OpenWorklist(criteria);
                else
                    worklist = cnn.OpenWorklist();
                foreach (WorklistItem item in worklist)
                {
                    DataRow row = dt.NewRow();
                    row["AllocatedUser"] = item.AllocatedUser;
                    row["Data"] = item.Data;
                    row["ID"] = item.ID;
                    row["Link"] = "<hyperlink><link>" + HttpUtility.HtmlEncode(item.Data) + "</link><display>Open</display></hyperlink>";
                    row["SerialNumber"] = item.SerialNumber;
                    row["Status"] = item.Status;
                    row["ActivityID"] = item.ActivityInstanceDestination.ActID;
                    row["ActivityInstanceID"] = item.ActivityInstanceDestination.ActInstID;
                    row["ActivityName"] = item.ActivityInstanceDestination.Name;
                    row["Priority"] = item.ActivityInstanceDestination.Priority;
                    row["StartDate"] = item.EventInstance.StartDate;
                    row["ActivityInstanceDestinationID"] = item.ActivityInstanceDestination.ID;
                    row["ProcessInstanceID"] = item.ProcessInstance.ID;
                    row["ProcessFullName"] = item.ProcessInstance.FullName;
                    row["ProcessName"] = item.ProcessInstance.Name;
                    row["Folio"] = item.ProcessInstance.Folio;
                    row["EventInstanceName"] = item.EventInstance.Name;
                    dt.Rows.Add(row);
                }
                if (impersonate)
                    cnn.RevertUser();
                cnn.Close();
                cnn.Dispose();
                return dt;

            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
开发者ID:hoshyK2,项目名称:K2-Worklist-Service-Broker,代码行数:71,代码来源:BasicWorklistItem.cs


注:本文中的Connection.RevertUser方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。