コード例 #1
0
        /// <summary>
        /// 删除数据
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="id">主鍵</param>
        /// <returns>数据表</returns>
        public int Delete(UserInfo userInfo, string id)
        {
            int returnValue = 0;

            using (IDbProvider rdiDbProvider = DbFactoryProvider.GetProvider(SystemInfo.RDIFrameworkDbType))
            {
                try
                {
                    rdiDbProvider.Open(RDIFrameworkDbConection);
                    LogManager.Instance.Add(rdiDbProvider, userInfo, this.serviceName, "删除数据", MethodBase.GetCurrentMethod());

                    using (IDbProvider dbProvider = DbFactoryProvider.GetProvider(BusinessDbType))
                    {
                        try
                        {
                            dbProvider.Open(BusinessDbConnection);
                            CustomerClassManager manager = new CustomerClassManager(dbProvider, userInfo);
                            returnValue = manager.Delete(id);
                        }
                        catch (Exception ex)
                        {
                            CiExceptionManager.LogException(rdiDbProvider, userInfo, ex);
                            throw ex;
                        }
                        finally
                        {
                            dbProvider.Close();
                        }
                    }
                }
                catch (Exception ex)
                {
                    CiExceptionManager.LogException(rdiDbProvider, userInfo, ex);
                    throw ex;
                }
                finally
                {
                    rdiDbProvider.Close();
                }
            }
            return(returnValue);
        }
コード例 #2
0
        /// <summary>
        /// 所有人
        /// </summary>
        /// <param name="userId">用户Id</param>
        /// <param name="workFlowId">流程模板Id</param>
        /// <param name="workTaskId">任务模板Id</param>
        /// <param name="workFlowInstanceId">流程实例Id</param>
        /// <param name="workTaskInstanceId">任务实例Id</param>
        /// <param name="operParam"></param>
        /// <returns>是否成功</returns>
        public bool AssignAll(string userId, string workFlowId, string workTaskId, string workFlowInstanceId, string workTaskInstanceId, OperParameter operParam)
        {
            //WriteErrorLog("AssignAll处理者类型:operContent= " + operParam.OperContent, workFlowInstanceId);
            var tmpUser     = "";
            var tmpUserName = "";

            if (string.IsNullOrEmpty(operParam.OperContent))
            {
                return(false);
            }
            switch (operParam.OperRule)
            {
            case "1":
                operParam.OperContent = "ALL";
                AssignUser(userId, workFlowId, workTaskId, workFlowInstanceId, workTaskInstanceId, operParam);
                break;

            case "2":
            {
                string[] names     = { PiUserTable.FieldDeleteMark, PiUserTable.FieldEnabled };
                Object[] values    = { 0, 1 };
                var      dtAllUser = new PiUserManager(DbFactoryProvider.GetProvider(SystemInfo.RDIFrameworkDbType, SystemInfo.RDIFrameworkDbConectionString)).GetDT(names, values, PiUserTable.FieldSortCode);
                if (dtAllUser == null || dtAllUser.Rows.Count <= 0)
                {
                    throw new Exception("引擎没有找到处理者,请检查是否配置处理者。");
                    // WriteErrorLog("所有人" + operParam.OperContenText + "]没有配置处理人!!!", workFlowInstanceId);
                }
                foreach (DataRow dr in dtAllUser.Rows)
                {
                    tmpUser                  = dr[PiUserTable.FieldId].ToString();
                    tmpUserName              = dr[PiUserTable.FieldUserName].ToString();
                    operParam.OperContent    = tmpUser;
                    operParam.OperContenText = tmpUserName;
                    AssignUser(userId, workFlowId, workTaskId, workFlowInstanceId, workTaskInstanceId, operParam);
                }
            }
            break;
            }
            return(true);
        }
コード例 #3
0
        private DataTable ExecSql(string sql)
        {
            DataTable dt = new DataTable();

            using (IDbProvider dbProvider = DbFactoryProvider.GetProvider(BusinessDbType))
            {
                try
                {
                    dbProvider.Open(BusinessDbConnection);
                    dt = dbProvider.Fill(sql);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    dbProvider.Close();
                }
            }
            return(dt);
        }
コード例 #4
0
        /// <summary>
        /// 组织机构处理者
        /// </summary>
        /// <param name="userId">用户Id</param>
        /// <param name="workFlowId">流程模板Id</param>
        /// <param name="workTaskId">任务模板Id</param>
        /// <param name="workFlowInstanceId">流程实例Id</param>
        /// <param name="workTaskInstanceId">任务实例Id</param>
        /// <param name="operParam"></param>
        /// <returns>是否成功</returns>
        public bool AssignArchitecture(string userId, string workFlowId, string workTaskId, string workFlowInstanceId, string workTaskInstanceId, OperParameter operParam)
        {
            var tmpUser     = "";
            var tmpUserName = "";

            if (string.IsNullOrEmpty(operParam.OperContent))
            {
                return(false);
            }

            switch (operParam.OperRule)
            {
            case "1":
                AssignUser(userId, workFlowId, workTaskId, workFlowInstanceId, workTaskInstanceId, operParam);
                break;

            case "2":
            {
                //var archUser = new PiUserManager(DbFactoryProvider.GetProvider(SystemInfo.RDIFrameworkDbType, SystemInfo.RDIFrameworkDbConectionString)).GetChildrenUsers(operParam.OperContent);
                var archUser = new PiUserManager(DbFactoryProvider.GetProvider(SystemInfo.RDIFrameworkDbType, SystemInfo.RDIFrameworkDbConectionString)).GetDTByRole(operParam.OperContent);
                if (archUser == null || archUser.Rows.Count <= 0)
                {
                    throw new Exception("引擎没有找到处理者,请检查是否配置处理者。");
                    //WriteErrorLog("部门或者岗位[" + operParam.OperContenText + "]没有配置处理人!!!", workFlowInstanceId);
                }
                foreach (DataRow dr in archUser.Rows)
                {
                    tmpUser                  = dr[PiUserTable.FieldId].ToString();
                    tmpUserName              = dr[PiUserTable.FieldRealName].ToString();
                    operParam.OperContent    = tmpUser;
                    operParam.OperContenText = tmpUserName;
                    AssignUser(userId, workFlowId, workTaskId, workFlowInstanceId, workTaskInstanceId, operParam);
                }
            }
            break;
            }
            return(true);
        }
コード例 #5
0
        /// <summary>
        /// 取得实体
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="id">主鍵</param>
        /// <returns>实体</returns>
        public LinkManEntity GetEntity(UserInfo userInfo, string id)
        {
            LinkManEntity entity = null;

            using (IDbProvider dbProvider = DbFactoryProvider.GetProvider(BusinessDbType))
            {
                try
                {
                    dbProvider.Open(BusinessDbConnection);
                    LinkManManager manager = new LinkManManager(dbProvider, userInfo);
                    entity = manager.GetEntity(id);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    dbProvider.Close();
                }
            }
            return(entity);
        }
コード例 #6
0
        /// <summary>
        /// 服务器端检查在线状态
        /// </summary>
        /// <returns>离线人数</returns>
        public int ServerCheckOnLine()
        {
            int returnValue = 0;

            using (IDbProvider dbProvider = DbFactoryProvider.GetProvider(SystemInfo.RDIFrameworkDbType))
            {
                try
                {
                    dbProvider.Open(RDIFrameworkDbConection);
                    returnValue = userLogOnManager.CheckOnLine();
                }
                catch (Exception ex)
                {
                    LogHelper.WriteException(ex);
                    throw ex;
                }
                finally
                {
                    dbProvider.Close();
                }
            }
            return(returnValue);
        }
コード例 #7
0
        /// <summary>
        /// 更新实体
        /// </summary>
        /// <param name="userInfo">使用者</param>
        /// <param name="entity">实体</param>
        /// <param name="statusMessage">返回状态信息</param>
        /// <returns>影响行数</returns>
        public int Update(UserInfo userInfo, CiItemDetailsEntity entity, out string statusMessage)
        {
            int returnValue = 0;

            statusMessage = string.Empty;

            using (IDbProvider dbProvider = DbFactoryProvider.GetProvider(SystemInfo.RDIFrameworkDbType))
            {
                try
                {
                    dbProvider.Open(RDIFrameworkDbConection);

                    var manager = new CiItemDetailsManager(dbProvider, userInfo);
                    if (manager.IsExisted(entity))
                    {
                        returnValue   = 0;
                        statusMessage = "已存在相同的明细项!";
                    }
                    else
                    {
                        returnValue   = manager.UpdateEntity(entity);
                        statusMessage = "修改数据成功!";
                    }
                }
                catch (Exception ex)
                {
                    CiExceptionManager.LogException(dbProvider, userInfo, ex);
                    throw ex;
                }
                finally
                {
                    dbProvider.Close();
                }
            }

            return(returnValue);
        }
コード例 #8
0
        private void GetPreviewData()
        {
            Cursor holdCursor = this.Cursor;

            this.Cursor = Cursors.WaitCursor;
            var recordCount = 0;
            QueryEngineDefineEntity queryEngineDefineEntity = RDIFrameworkService.Instance.QueryEngineService.GetQueryEngineDefineEntity(this.UserInfo, this.EntityId);
            CiDbLinkDefineEntity    dblinkEntity            = null;
            IDbProvider             dbProvider = null;

            if (queryEngineDefineEntity != null && !string.IsNullOrEmpty(queryEngineDefineEntity.DataBaseLinkName))
            {
                dblinkEntity = RDIFrameworkService.Instance.DbLinkDefineService.GetEntity(this.UserInfo, queryEngineDefineEntity.DataBaseLinkName);
            }

            if (dblinkEntity != null)
            {
                var DbDefine = RDIFrameworkService.Instance.DbLinkDefineService.GetEntityByLinkName(this.UserInfo, dblinkEntity.LinkName);
                dbProvider = DbDefine != null?DbFactoryProvider.GetProvider((CurrentDbType)Enum.Parse(typeof(CurrentDbType), DbDefine.LinkType, true), SecretHelper.AESDecrypt(DbDefine.LinkData))
                                 : DbFactoryProvider.GetProvider(SystemInfo.BusinessDbType, SystemInfo.BusinessDbConnectionString);

                var dtDynamicJsonDt = dbProvider.GetDTByPage(out recordCount, queryEngineDefineEntity.QueryString, ucPagerEx1.PageIndex, ucPagerEx1.PageSize, string.Empty, queryEngineDefineEntity.OrderByField);
                ucPagerEx1.RecordCount = recordCount;
                ucPagerEx1.InitPageInfo();
                this.dgvListSample.AutoGenerateColumns = true;
                this.dgvListSample.DataSource          = dtDynamicJsonDt.DefaultView;
            }
            else
            {
                ucPagerEx1.RecordCount = 0;
                ucPagerEx1.InitPageInfo();
                this.dgvListSample.AutoGenerateColumns = true;
                this.dgvListSample.DataSource          = null;
            }

            this.Cursor = holdCursor;
        }
コード例 #9
0
        /// <summary>
        /// 计算总记录数
        /// </summary>
        /// <returns>记录总数</returns>
        private int Calc()
        {
            int    RecordCount  = 0;
            string sqlStatement = string.Empty;

            if (string.IsNullOrEmpty(SqlWhereStatement.Trim()))
            {
                sqlStatement = "select count(*) as rowsCount from " + TableName;
            }
            else
            {
                sqlStatement = "select count(*) as rowsCount from " + TableName + " where " + SqlWhereStatement;
            }

            IDataReader dr = DbFactoryProvider.GetProvider(this.pageDbType, this.pageConnstring).ExecuteReader(sqlStatement);;

            if (dr.Read())
            {
                RecordCount = Int32.Parse(dr["rowsCount"].ToString());
            }
            dr.Close();
            dr.Dispose();
            return(RecordCount);
        }
コード例 #10
0
        /// <summary>
        /// 根据主键数组获取数据
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="ids">主鍵</param>
        /// <returns>数据表</returns>
        public DataTable GetDataTableByIds(UserInfo userInfo, string[] ids)
        {
            DataTable dataTable = new DataTable(CustomerClassTable.TableName);

            using (IDbProvider dbProvider = DbFactoryProvider.GetProvider(BusinessDbType))
            {
                try
                {
                    dbProvider.Open(BusinessDbConnection);
                    CustomerClassManager manager = new CustomerClassManager(dbProvider, userInfo);
                    dataTable           = manager.GetDT(CustomerClassTable.FieldId, ids, CustomerClassTable.FieldSortCode);
                    dataTable.TableName = CustomerClassTable.TableName;
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    dbProvider.Close();
                }
            }
            return(dataTable);
        }
コード例 #11
0
        private DataTable TDataBind()
        {
            //读取页码值保存到currentPage变量中进行按钮失效运算
            currentPage = pageIndex;
            //读取总页参数进行按钮失效运算
            pages = pageCounts;
            //判断四个按钮(首页、上一页、下一页、尾页)状态
            if (currentPage + 1 > 1)
            {
                btnFirstPage.Enabled = true;
                btnPrevPage.Enabled  = true;
            }
            else
            {
                btnFirstPage.Enabled = false;
                btnPrevPage.Enabled  = false;
            }
            if (currentPage == pages)
            {
                btnNextPage.Enabled = false;
                btnLastPage.Enabled = false;
            }
            else
            {
                btnNextPage.Enabled = true;
                btnLastPage.Enabled = true;
            }
            //核心SQL语句,进行查询运算(决定了分页的效率:))
            StringBuilder sbSqlStatement = new StringBuilder();

            switch (this.pageDbType)
            {
            case CurrentDbType.SqlServer:
            case CurrentDbType.DB2:
                if (string.IsNullOrEmpty(SqlWhereStatement.Trim()))
                {
                    sbSqlStatement.Append("SELECT TOP " + PageSize + "  " + QueryFieldList + " FROM " + TableName + " WHERE " + PrimaryKey + " NOT IN(SELECT TOP ");
                    sbSqlStatement.Append(PageSize * currentPage + "  " + PrimaryKey + " FROM " + TableName);
                    sbSqlStatement.Append(" ORDER BY " + OrderField + " DESC) ORDER BY " + OrderField + " DESC");
                }
                else
                {
                    sbSqlStatement.Append("SELECT TOP " + PageSize + "  " + QueryFieldList + " FROM " + TableName + " WHERE " + SqlWhereStatement + " AND " + PrimaryKey + " NOT IN(SELECT TOP ");
                    sbSqlStatement.Append(PageSize * currentPage + "  " + PrimaryKey + "  FROM " + TableName + " WHERE " + SqlWhereStatement + "  ORDER BY " + OrderField + " DESC) ORDER BY " + OrderField + " DESC");
                }
                break;

            case CurrentDbType.Oracle:
                string sqlCount = (this.PageIndex * this.PageSize).ToString();
                string sqlStart = ((this.PageIndex - 1) * this.PageSize).ToString();
                if (!string.IsNullOrEmpty(SqlWhereStatement))
                {
                    SqlWhereStatement = "WHERE " + SqlWhereStatement;
                }

                sbSqlStatement.Append(string.Format("SELECT * FROM (SELECT T.*, ROWNUM RN FROM (SELECT * FROM {0} {1} ORDER BY {2}) T WHERE ROWNUM <= {3}) WHERE RN > {4}"
                                                    , TableName, SqlWhereStatement, OrderField, sqlCount, sqlStart));
                break;

            case CurrentDbType.Access:
                sqlStart = ((this.PageIndex - 1) * this.PageSize).ToString();
                sbSqlStatement.Append(string.Format("SELECT * FROM (SELECT TOP {0} * FROM (SELECT TOP {1} * FROM {2} T ORDER BY {3} ) T1 ORDER BY {4} DESC ) T2 ORDER BY {5} "
                                                    , PageSize, sqlStart, TableName, OrderField, OrderField, OrderField));
                break;
            }
            _pageTable = DbFactoryProvider.GetProvider(this.pageDbType, this.pageConnstring).Fill(sbSqlStatement.ToString());
            //显示Label控件LcurrentPaget和文本框控件gotoPage状态
            lblCurrentPage.Text = (currentPage + 1).ToString();
            txtGoToPage.Text    = (currentPage + 1).ToString();
            return(_pageTable);
        }
コード例 #12
0
        /// <summary>
        /// 创建所有符合条件的任务实例
        /// </summary>
        /// <param name="userId">处理人Id</param>
        /// <param name="workFlowId">工作流模板id</param>
        /// <param name="workTaskId">当前任务Id</param>
        /// <param name="workFlowInstanceId">工作流实例Id</param>
        /// <param name="workTaskInstanceId">原任务实例Id</param>
        /// <param name="operatorInstanceId">处理者实例Id</param>
        /// <param name="commandName">命令</param>
        /// <returns>
        /// 000002:没有配置后续任务
        /// 000000:操作成功
        /// </returns>
        public string CreateNextTaskInstance(string userId, string workFlowId, string workTaskId, string workFlowInstanceId, string workTaskInstanceId, string operatorInstanceId, string commandName)
        {
            var userName = new PiUserManager(DbFactoryProvider.GetProvider(SystemInfo.RDIFrameworkDbType, SystemInfo.RDIFrameworkDbConectionString), this.UserInfo).GetEntity(userId).UserName;

            var dt = GetLineEndTasks(workFlowId, workTaskId, commandName);

            if (dt != null && dt.Rows.Count > 0)
            {
                var condition        = "";                  //条件
                var priority         = "";                  //优先级,只执行优先级最高的分支,如果优先级相同 那么同时执行。
                var endTaskId        = "";                  //后续任务节点Id
                var endoperRule      = "";                  //新任务处理者策略
                var startoperRule    = "";                  //当前任务处理者策略
                var taskType         = "";                  //节点类型
                var endTaskTypeAndOr = "";                  //控制节点专用,表示and/or
                var operParam        = new OperParameter(); //创建处理者参数

                #region 配置了后续节点
                var l = dt.Rows.Count;
                var branchPriority = dt.Rows[0]["PRIORITY"].ToString();//优先级
                //遍历满足条件的所有任务节点
                for (var i = 0; i < l; i++)
                {
                    var dr = dt.Rows[i];
                    condition            = dr["CONDITION"].ToString();
                    priority             = dr["PRIORITY"].ToString();
                    endTaskId            = dr["ENDTASKID"].ToString();
                    endoperRule          = dr["ENDOPERRULE"].ToString();
                    startoperRule        = dr["STARTOPERRULE"].ToString();
                    taskType             = dr["ENDTASKTYPEID"].ToString();
                    endTaskTypeAndOr     = dr["ENDTASKTYPEANDOR"].ToString();
                    operParam.OperRule   = endoperRule;
                    operParam.IsJumpSelf = Convert.ToBoolean(dr["ISJUMPSELF"]);
                    if (priority != branchPriority)
                    {
                        break;                                                                                          //只执行优先级最高的分支
                    }
                    if (ExpressPass(userId, workFlowId, workTaskId, workFlowInstanceId, workTaskInstanceId, condition)) //满足条件的任务节点
                    {
                        switch (taskType)
                        {
                        case "2":    //结束节点
                        {
                            #region 结束节点
                            //产生一个结束节点的实例
                            var newEndTaskId   = BusinessLogic.NewGuid();      //新任务处理者实例Id
                            var endWorktaskIns = new WorkTaskInstanceEntity
                            {
                                WorkFlowId     = workFlowId,
                                WorkTaskId     = endTaskId,
                                WorkFlowInsId  = workFlowInstanceId,
                                WorkTaskInsId  = newEndTaskId,
                                PreviousTaskId = workTaskInstanceId,
                                TaskInsCaption = new WorkTaskManager(this.DBProvider, this.UserInfo).GetTaskCaption(endTaskId),
                                Status         = "2"//结束节点不需要再处理,但此处不能为3,设置结束实例会修改该值=3
                            };
                            new WorkTaskInstanceManager(this.DBProvider, this.UserInfo).Create(endWorktaskIns);

                            //设置处理者实例正常结束
                            new OperatorInstanceManager(this.DBProvider, this.UserInfo).SetOperatorInstanceOver(userId, operatorInstanceId);
                            //设置任务实例正常结束
                            new WorkTaskInstanceManager(this.DBProvider, this.UserInfo).SetWorkTaskInstanceOver(userName, workTaskInstanceId);
                            new WorkTaskInstanceManager(this.DBProvider, this.UserInfo).SetWorkTaskInstanceOver(userName, newEndTaskId);        //结束节点实例 结束
                            //设置流程实例正常结束
                            new WorkFlowInstanceManager(this.DBProvider, this.UserInfo).SetWorkflowInstanceOver(workFlowInstanceId);
                            //设定流程实例的当前位置
                            new WorkFlowInstanceManager(this.DBProvider, this.UserInfo).SetCurrTaskId(workFlowInstanceId, endTaskId);
                            new WorkTaskInstanceManager(this.DBProvider, this.UserInfo).SetSuccessMsg(WorkFlowConst.WorkflowOverMsg, workTaskInstanceId);        //结束节点单独处理,任务提交给谁了
                            //检查是否子流程调用
                            DataTable operInfo = new WorkFlowInstanceManager(this.DBProvider, this.UserInfo).GetWorkflowInstance(workFlowInstanceId);
                            if (operInfo != null && operInfo.Rows.Count > 0)
                            {
                                var isSubWorkflow     = false;    //是否是子流程调用
                                var mainWorkflowInsId = "";
                                var mainWorktaskId    = "";
                                var mainWorkflowId    = "";
                                var mainWorktaskInsId = "";
                                isSubWorkflow     = BusinessLogic.ConvertIntToBoolean(operInfo.Rows[0][WorkFlowInstanceTable.FieldIsSubWorkflow]);
                                mainWorkflowInsId = operInfo.Rows[0][WorkFlowInstanceTable.FieldMainWorkflowInsId].ToString();  //主流程实例Id
                                mainWorktaskId    = operInfo.Rows[0][WorkFlowInstanceTable.FieldMainWorktaskId].ToString();     //子流程节点模板Id
                                mainWorkflowId    = operInfo.Rows[0][WorkFlowInstanceTable.FieldMainWorkflowId].ToString();     //主流程模板Id
                                mainWorktaskInsId = operInfo.Rows[0][WorkFlowInstanceTable.FieldMainWorktaskInsId].ToString();  //主任务实例Id,进入子节点前的任务节点实例
                                if (isSubWorkflow)
                                {
                                    //创建一个子流程节点实例痕迹,表示子流程节点处理完成
                                    var newTaskId        = BusinessLogic.NewGuid(); //新任务处理者实例Id
                                    var workTaskInstance = new WorkTaskInstanceEntity {
                                        WorkFlowId     = mainWorkflowId,
                                        WorkTaskId     = mainWorktaskId,
                                        WorkFlowInsId  = mainWorkflowInsId,
                                        WorkTaskInsId  = newTaskId,
                                        PreviousTaskId = mainWorktaskInsId,
                                        TaskInsCaption = "子流程",
                                        Status         = "3"
                                    };
                                    new WorkTaskInstanceManager(this.DBProvider, this.UserInfo).Create(workTaskInstance);
                                    var result = CreateNextTaskInstance(userId, mainWorkflowId, mainWorktaskId, mainWorkflowInsId, newTaskId, operatorInstanceId, "提交");
                                    if (result != WorkFlowConst.SuccessCode)
                                    {
                                        return(result);
                                    }
                                }
                            }
                            #endregion
                            break;
                        }

                        case "3":
                        {
                            #region 交互节点
                            switch (endoperRule)
                            {
                            case "1":
                            {
                                //创建一个任务实例
                                var newTaskId        = BusinessLogic.NewGuid();     //新任务处理者实例Id
                                var workTaskInstance = new WorkTaskInstanceEntity
                                {
                                    WorkFlowId     = workFlowId,
                                    WorkTaskId     = endTaskId,
                                    WorkFlowInsId  = workFlowInstanceId,
                                    WorkTaskInsId  = newTaskId,
                                    PreviousTaskId = workTaskInstanceId,
                                    TaskInsCaption = new WorkTaskManager(this.DBProvider, this.UserInfo).GetTaskCaption(endTaskId),
                                    Status         = "1"
                                };
                                new WorkTaskInstanceManager(this.DBProvider, this.UserInfo).Create(workTaskInstance);
                                //创建多个处理人
                                var result = CreateOperInstance(userId, workTaskInstanceId, workTaskId, workFlowId, endTaskId, workFlowInstanceId, newTaskId, operParam);            //创建处理者实例
                                if (result != WorkFlowConst.SuccessCode)
                                {
                                    return(result);
                                }
                            }
                            break;

                            case "2":
                            {
                                //创建任务实例和处理人
                                var result = CreateOperInstance(userId, workTaskInstanceId, workTaskId, workFlowId, endTaskId, workFlowInstanceId, workTaskInstanceId, operParam);
                                if (result != WorkFlowConst.SuccessCode)
                                {
                                    return(result);
                                }
                            }
                            break;
                            }

                            //设置处理者实例正常结束
                            new OperatorInstanceManager(this.DBProvider, this.UserInfo).SetOperatorInstanceOver(userId, operatorInstanceId);
                            //设置任务实例正常结束
                            new WorkTaskInstanceManager(this.DBProvider, this.UserInfo).SetWorkTaskInstanceOver(userName, workTaskInstanceId);
                            //设定流程实例的当前位置
                            new WorkFlowInstanceManager(this.DBProvider, this.UserInfo).SetCurrTaskId(workFlowInstanceId, endTaskId);
                            //设定任务实例成功提交信息
                            new WorkTaskInstanceManager(this.DBProvider, this.UserInfo).SetSuccessMsg(WorkFlowConst.SuccessMsg, workTaskInstanceId);
                            #endregion
                            break;
                        }

                        case "4":    //控制节点
                        {
                            #region 控制节点
                            //设置处理者实例正常结束
                            new OperatorInstanceManager(this.DBProvider, this.UserInfo).SetOperatorInstanceOver(userId, operatorInstanceId);
                            //设置任务实例正常结束
                            new WorkTaskInstanceManager(this.DBProvider, this.UserInfo).SetWorkTaskInstanceOver(userName, workTaskInstanceId);
                            //设定流程实例的当前位置
                            new WorkFlowInstanceManager(this.DBProvider, this.UserInfo).SetCurrTaskId(workFlowInstanceId, endTaskId);
                            //设定任务实例成功提交信息
                            new WorkTaskInstanceManager(this.DBProvider, this.UserInfo).SetSuccessMsg(WorkFlowConst.SuccessMsg, workTaskInstanceId);
                            //******start检查判断节点前面的所以节点的任务实例是否都完成


                            //取控制节点前端所以节点,进行逐个判断
                            var dtstart = GetLineStartTasks(workFlowId, endTaskId);
                            var allPass = true;        //全部通过
                            foreach (DataRow dr1 in dtstart.Rows)
                            {
                                var taskId = dr1["STARTTASKID"].ToString();
                                if (endTaskTypeAndOr == WorkConst.Command_Or)                                  //or分支
                                {
                                    if (IsPassJudge(workFlowId, workFlowInstanceId, taskId, endTaskTypeAndOr)) //判断每个节点实例是否完成
                                    {
                                        allPass = true;
                                        break;        //如果有一个通过即可。
                                    }
                                    allPass = false;
                                }
                                else                                                                            //and分支
                                {
                                    if (!IsPassJudge(workFlowId, workFlowInstanceId, taskId, endTaskTypeAndOr)) //判断每个节点实例是否完成
                                    {
                                        allPass = false;
                                        break;        //如果有一个未完成的,不产生新的实例,流程等待。
                                    }
                                }
                            }

                            //********end检查判断节点前面的所以节点的任务实例结束

                            //如果判断节点前面的流程实例全部完成,自动进行递归,创建下一任务实例。
                            if (allPass)
                            {
                                //创建一个判断节点实例
                                var newTaskId        = BusinessLogic.NewGuid(); //新任务处理者实例Id
                                var workTaskInstance = new WorkTaskInstanceEntity
                                {
                                    WorkFlowId     = workFlowId,
                                    WorkTaskId     = endTaskId,
                                    WorkFlowInsId  = workFlowInstanceId,
                                    WorkTaskInsId  = newTaskId,
                                    PreviousTaskId = workTaskInstanceId,
                                    TaskInsCaption = endTaskTypeAndOr,
                                    Status         = "3"
                                };
                                new WorkTaskInstanceManager(this.DBProvider, this.UserInfo).Create(workTaskInstance);
                                var result = CreateNextTaskInstance(userId, workFlowId, endTaskId, workFlowInstanceId, newTaskId, operatorInstanceId, "提交");
                                if (result != WorkFlowConst.SuccessCode)
                                {
                                    return(result);
                                }
                            }
                            #endregion
                            break;
                        }

                        case "5":    //查看节点
                        {
                            #region 查看节点
                            switch (endoperRule)
                            {
                            case "1":
                            {
                                //创建一个任务实例
                                var newTaskId        = BusinessLogic.NewGuid();     //新任务处理者实例Id
                                var workTaskInstance = new WorkTaskInstanceEntity
                                {
                                    WorkFlowId     = workFlowId,
                                    WorkTaskId     = endTaskId,
                                    WorkFlowInsId  = workFlowInstanceId,
                                    WorkTaskInsId  = newTaskId,
                                    PreviousTaskId = workTaskInstanceId,
                                    TaskInsCaption = new WorkTaskManager(this.DBProvider, this.UserInfo).GetTaskCaption(endTaskId),
                                    Status         = "1"
                                };
                                new WorkTaskInstanceManager(this.DBProvider, this.UserInfo).Create(workTaskInstance);

                                //创建多个处理人
                                var result = CreateOperInstance(userId, workTaskInstanceId, workTaskId, workFlowId, endTaskId, workFlowInstanceId, newTaskId, operParam);            //创建任务实例
                                if (result != WorkFlowConst.SuccessCode)
                                {
                                    return(result);
                                }
                            }
                            break;

                            case "2":
                            {
                                //创建任务实例和处理人

                                var result = CreateOperInstance(userId, workTaskInstanceId, workTaskId, workFlowId, endTaskId, workFlowInstanceId, workTaskInstanceId, operParam);
                                if (result != WorkFlowConst.SuccessCode)
                                {
                                    return(result);
                                }
                            }
                            break;
                            }
                            //设置处理者实例正常结束
                            new OperatorInstanceManager(this.DBProvider, this.UserInfo).SetOperatorInstanceOver(userId, operatorInstanceId);
                            //设置任务实例正常结束
                            new WorkTaskInstanceManager(this.DBProvider, this.UserInfo).SetWorkTaskInstanceOver(userName, workTaskInstanceId);
                            //设定流程实例的当前位置
                            new WorkFlowInstanceManager(this.DBProvider, this.UserInfo).SetCurrTaskId(workFlowInstanceId, endTaskId);
                            //设定任务实例成功提交信息
                            new WorkTaskInstanceManager(this.DBProvider, this.UserInfo).SetSuccessMsg(WorkFlowConst.SuccessMsg, workTaskInstanceId);
                            #endregion
                            break;
                        }

                        case "6":    //子流程节点
                        {
                            #region 子流程节点
                            var subWf = new SubWorkFlowManager(this.DBProvider, this.UserInfo).GetSubWorkflowTable(workFlowId, endTaskId);
                            if (subWf != null && subWf.Rows.Count > 0)
                            {
                                var subWorkflowId      = subWf.Rows[0][SubWorkFlowTable.FieldSubWorkFlowId].ToString();
                                var subStartTaskId     = subWf.Rows[0][SubWorkFlowTable.FieldSubStartTaskId].ToString();
                                var subWorkflowCaption = subWf.Rows[0][SubWorkFlowTable.FieldSubWorkFlowCaption].ToString();
                                //*******进入子流程
                                var wfruntime = new WorkFlowRuntime
                                {
                                    UserId             = userId,
                                    WorkFlowId         = subWorkflowId,
                                    WorkTaskId         = subStartTaskId,
                                    WorkFlowInstanceId = BusinessLogic.NewGuid(),
                                    WorkTaskInstanceId = BusinessLogic.NewGuid(),
                                    IsSubWorkflow      = true,
                                    MainWorkflowId     = workFlowId,
                                    MainWorkflowInsId  = workFlowInstanceId,
                                    MainWorktaskId     = endTaskId,
                                    MainWorktaskInsId  = workTaskInstanceId,       //记录进入子流程之前的任务实例
                                    WorkFlowNo         = "subWorkflow",
                                    CommandName        = "提交",
                                    WorkflowInsCaption = subWorkflowCaption,
                                    IsDraft            = true//开始节点需要交互,草稿状态,暂不提交
                                };
                                wfruntime.Start();
                                //设置处理者实例正常结束
                                new OperatorInstanceManager(this.DBProvider, this.UserInfo).SetOperatorInstanceOver(userId, operatorInstanceId);
                                //设置任务实例正常结束
                                new WorkTaskInstanceManager(this.DBProvider, this.UserInfo).SetWorkTaskInstanceOver(userName, workTaskInstanceId);
                                //设定流程实例的当前位置
                                new WorkFlowInstanceManager(this.DBProvider, this.UserInfo).SetCurrTaskId(workFlowInstanceId, endTaskId);
                                //设定任务实例成功提交信息
                                new WorkTaskInstanceManager(this.DBProvider, this.UserInfo).SetSuccessMsg(WorkFlowConst.SuccessMsg, workTaskInstanceId);
                            }
                            #endregion
                            break;
                        }
                        }
                    }
                }
                #endregion
            }
            else
            {   //未配置后续节点
                return(WorkFlowConst.NoFoundTaskCode);
            }
            return(WorkFlowConst.SuccessCode);
        }
コード例 #13
0
        /// <summary>
        /// 创建处理者实例
        /// </summary>
        /// <param name="userId">用户Id</param>
        /// <param name="oldWorktaskInsId"></param>
        /// <param name="oldworktaskId"></param>
        /// <param name="workFlowId"></param>
        /// <param name="workTaskId"></param>
        /// <param name="workFlowInstanceId"></param>
        /// <param name="WorkTaskInstanceId"></param>
        /// <param name="operParam"></param>
        /// <returns></returns>
        private string CreateOperInstance(string userId, string oldWorktaskInsId, string oldworktaskId, string workFlowId, string workTaskId, string workFlowInstanceId, string WorkTaskInstanceId, OperParameter operParam)
        {
            int    operType;             //处理类型
            string operContent;          //处理者id
            int    OperRelation;         //处理者关系
            var    OperContentText = ""; //处理者的名称

            //动态指定下一任务处理人
            DataTable tmpDyDt = new WorkTaskInstanceManager(this.DBProvider, this.UserInfo).GetTaskInsNextOperTable(workFlowId, oldworktaskId, workFlowInstanceId, oldWorktaskInsId);

            foreach (DataRow dr in tmpDyDt.Rows)
            {
                operContent = dr[WorkTaskInsNextOperTable.FieldUserId].ToString();
                if (string.IsNullOrEmpty(operContent))
                {
                    continue;
                }
                var userName = new PiUserManager(DbFactoryProvider.GetProvider(SystemInfo.RDIFrameworkDbType, SystemInfo.RDIFrameworkDbConectionString), this.UserInfo).GetEntity(operContent).RealName;
                operParam.OperContent    = operContent;
                operParam.OperContenText = userName;
                operParam.OperRelation   = 0;
                operParam.OperType       = 3;
                new InstanceTypeManager(this.DBProvider, this.UserInfo).AssignUser(userId, workFlowId, workTaskId, workFlowInstanceId, WorkTaskInstanceId, operParam);
            }

            DataTable tmpTeDt = new WorkTaskManager(this.DBProvider, this.UserInfo).GetTaskOperator(workFlowId, workTaskId);

            //如果没有处理者
            if ((tmpTeDt == null || tmpTeDt.Rows.Count <= 0) && (tmpDyDt.Rows.Count <= 0))
            {
                return(WorkFlowConst.NoFoundOperatorCode);
            }

            foreach (DataRow dr in tmpTeDt.Rows)
            {
                operType                 = System.Convert.ToInt16(dr[OperatorTable.FieldOperType].ToString());
                operContent              = dr[OperatorTable.FieldOperContent].ToString();
                OperRelation             = Convert.ToInt16(dr[OperatorTable.FieldRelation]);
                OperContentText          = dr[OperatorTable.FieldOperDisplay].ToString();
                operParam.OperType       = operType;
                operParam.OperContent    = operContent;
                operParam.OperRelation   = OperRelation;
                operParam.OperContenText = OperContentText;
                switch (operType)
                {       //在此函数中加入处理者策略
                case 1: //流程启动者
                    var startflowUser     = new InstanceTypeManager(this.DBProvider, this.UserInfo).GetStartWorkflowUser(workFlowInstanceId);
                    var startflowUserName = new PiUserManager(DbFactoryProvider.GetProvider(SystemInfo.RDIFrameworkDbType, SystemInfo.RDIFrameworkDbConectionString), this.UserInfo).GetEntity(startflowUser).UserName;
                    operParam.OperContent    = startflowUser;
                    operParam.OperContenText = startflowUserName;
                    if (OperRelation == 0)    //无处理这关系
                    {
                        new InstanceTypeManager(this.DBProvider, this.UserInfo).AssignUser(userId, workFlowId, workTaskId, workFlowInstanceId, WorkTaskInstanceId, operParam);
                    }
                    else
                    {
                        new InstanceTypeManager(this.DBProvider, this.UserInfo).UserRelation(userId, workFlowId, workTaskId, workFlowInstanceId, WorkTaskInstanceId, operParam);
                    }
                    break;

                case 2:    //某一任务实际处理者
                    var dtTaskUser = new InstanceTypeManager(this.DBProvider, this.UserInfo).GetTaskInstanceUser(workFlowInstanceId, operContent);
                    foreach (DataRow drUser in dtTaskUser.Rows)
                    {
                        var rlUserId   = drUser["USERID"].ToString();
                        var rlUserName = new PiUserManager(DbFactoryProvider.GetProvider(SystemInfo.RDIFrameworkDbType, SystemInfo.RDIFrameworkDbConectionString), this.UserInfo).GetEntity(rlUserId).RealName;
                        operParam.OperContent    = rlUserId;
                        operParam.OperContenText = rlUserName;
                        if (OperRelation == 0)    //无处理这关系
                        {
                            new InstanceTypeManager(this.DBProvider, this.UserInfo).AssignUser(userId, workFlowId, workTaskId, workFlowInstanceId, WorkTaskInstanceId, operParam);
                        }
                        else
                        {
                            new InstanceTypeManager(this.DBProvider, this.UserInfo).UserRelation(userId, workFlowId, workTaskId, workFlowInstanceId, WorkTaskInstanceId, operParam);
                        }
                    }
                    break;

                case 3:    //指定人员
                    if (OperRelation == 0)
                    {
                        new InstanceTypeManager(this.DBProvider, this.UserInfo).AssignUser(userId, workFlowId, workTaskId, workFlowInstanceId, WorkTaskInstanceId, operParam);
                    }
                    else
                    {
                        new InstanceTypeManager(this.DBProvider, this.UserInfo).UserRelation(userId, workFlowId, workTaskId, workFlowInstanceId, WorkTaskInstanceId, operParam);
                    }
                    break;

                case 4:    //部门
                    if (OperRelation == 0)
                    {
                        new InstanceTypeManager(this.DBProvider, this.UserInfo).AssignArchitecture(userId, workFlowId, workTaskId, workFlowInstanceId, WorkTaskInstanceId, operParam);
                    }
                    else
                    {
                        new InstanceTypeManager(this.DBProvider, this.UserInfo).ArchRelation(userId, workFlowId, workTaskId, workFlowInstanceId, WorkTaskInstanceId, operParam);
                    }
                    break;

                case 5:    //角色
                    new InstanceTypeManager(this.DBProvider, this.UserInfo).AssignGroup(userId, workFlowId, workTaskId, workFlowInstanceId, WorkTaskInstanceId, operParam);
                    break;

                case 6:    //岗位
                    new InstanceTypeManager(this.DBProvider, this.UserInfo).AssignArchitecture(userId, workFlowId, workTaskId, workFlowInstanceId, WorkTaskInstanceId, operParam);
                    break;

                case 7:    //从变量中获取
                    var varUser = GetWorkTaskVarValue(userId, workFlowId, workTaskId, workFlowInstanceId, WorkTaskInstanceId, OperContentText);
                    if (varUser.Length > 2)
                    {
                        varUser = varUser.Substring(1, varUser.Length - 2);

                        var varUserName = new PiUserManager(DbFactoryProvider.GetProvider(SystemInfo.RDIFrameworkDbType, SystemInfo.RDIFrameworkDbConectionString), this.UserInfo).GetEntity(varUser).UserName;
                        if (string.IsNullOrEmpty(varUserName) || varUserName == "'")
                        {
                            return(WorkFlowConst.IsNullUserIdCode);   //如果用户取不到就报错
                        }
                        operParam.OperContent    = varUser;
                        operParam.OperContenText = varUserName;
                    }
                    else
                    {
                        return(WorkFlowConst.IsNullUserIdCode); //如果用户取不到就报错
                    }
                    if (OperRelation == 0)                      //无处理者关系
                    {
                        new InstanceTypeManager(this.DBProvider, this.UserInfo).AssignUser(userId, workFlowId, workTaskId, workFlowInstanceId, WorkTaskInstanceId, operParam);
                    }
                    else
                    {
                        new InstanceTypeManager(this.DBProvider, this.UserInfo).UserRelation(userId, workFlowId, workTaskId, workFlowInstanceId, WorkTaskInstanceId, operParam);
                    }

                    break;

                case 8:    //某一任务选择的处理者
                    throw new Exception("无此类型");
                    break;

                case 9:    //所有人
                    new InstanceTypeManager(this.DBProvider, this.UserInfo).AssignAll(userId, workFlowId, workTaskId, workFlowInstanceId, WorkTaskInstanceId, operParam);
                    break;

                case 10:    //指派
                    throw new Exception("无此类型");
                    break;

                case 11:    //授权
                    throw new Exception("无此类型");
                    break;

                default:
                    Console.WriteLine("Default case");
                    break;
                }
            }
            return(WorkFlowConst.SuccessCode);
        }
コード例 #14
0
        /// <summary>
        /// 指定处理人
        /// </summary>
        /// <param name="userId">用户Id</param>
        /// <param name="workFlowId">流程模板Id</param>
        /// <param name="workTaskId">任务模板Id</param>
        /// <param name="workFlowInstanceId">流程实例Id</param>
        /// <param name="workTaskInstanceId">任务实例Id</param>
        /// <param name="operParam">处理者参数</param>
        /// <returns>是否成功</returns>
        public bool AssignUser(string userId, string workFlowId, string workTaskId, string workFlowInstanceId, string workTaskInstanceId, OperParameter operParam)
        {
            if (string.IsNullOrEmpty(operParam.OperContent))
            {
                return(false);
            }

            switch (operParam.OperRule)
            {
            case "1":
            {
                //创建处理人实例
                var operInsEntity = new OperatorInstanceEntity()
                {
                    OperatorInsId   = BusinessLogic.NewGuid(),
                    WorkFlowId      = workFlowId,
                    WorkTaskId      = workTaskId,
                    WorkFlowInsId   = workFlowInstanceId,
                    WorkTaskInsId   = workTaskInstanceId,  //此时是新任务Id
                    UserId          = "",
                    OperRealtion    = operParam.OperRelation,
                    OperContent     = operParam.OperContent,
                    OperContentText = operParam.OperContenText,
                    OperType        = operParam.OperType//此处保留原来的处理类型
                };
                string successCode = new OperatorInstanceManager(this.DBProvider).Create(operInsEntity);

                //给处理者发送信息
                if (!string.IsNullOrEmpty(successCode) && successCode.Length > 0)
                {
                    var messageEntity = new CiMessageEntity
                    {
                        Id           = BusinessLogic.NewGuid(),
                        FunctionCode = MessageFunction.Remind.ToString(),
                        ReceiverId   = DefaultRole.Administrator.ToString(),
                        Title        = "业务流程消息",
                        MSGContent   = "你有一待办任务,请到未认领任务界面认领。",
                        IsNew        = 1,
                        ReadCount    = 0,
                        Enabled      = 1,
                        DeleteMark   = 0
                    };

                    var messageManager = new CiMessageManager(DbFactoryProvider.GetProvider(SystemInfo.RDIFrameworkDbType, SystemInfo.RDIFrameworkDbConectionString), this.UserInfo);
                    messageManager.BatchSend(operInsEntity.OperContent, null, null, messageEntity, false);
                }

                if ((userId == operParam.OperContent) && (operParam.IsJumpSelf))    //处理者是提交人,自动处理
                {
                    var wfrun = new WorkFlowRuntime();
                    wfrun.Run(userId, operInsEntity.OperatorInsId, "提交");
                }
            }
            break;

            case "2":
            {
                //创建任务实例
                var newTaskId         = BusinessLogic.NewGuid();//新任务实例Id
                var workTaskInsEntity = new WorkTaskInstanceEntity()
                {
                    WorkFlowId     = workFlowId,
                    WorkTaskId     = workTaskId,
                    WorkFlowInsId  = workFlowInstanceId,
                    WorkTaskInsId  = newTaskId,
                    PreviousTaskId = workTaskInstanceId,    //此时是当前任务Id
                    TaskInsCaption = new WorkTaskManager(this.DBProvider).GetTaskCaption(workTaskId),
                    Status         = "1",
                };
                new WorkTaskInstanceManager(this.DBProvider).Create(workTaskInsEntity);

                //创建处理人实例
                var operInsEntity = new OperatorInstanceEntity()
                {
                    OperatorInsId   = BusinessLogic.NewGuid(),
                    WorkFlowId      = workFlowId,
                    WorkTaskId      = workTaskId,
                    WorkFlowInsId   = workFlowInstanceId,
                    WorkTaskInsId   = newTaskId,
                    UserId          = "",
                    OperRealtion    = operParam.OperRelation,
                    OperContent     = operParam.OperContent,
                    OperContentText = operParam.OperContenText,
                    OperType        = 3,//此处修改为指定处理人
                };
                string successCode = new OperatorInstanceManager(this.DBProvider).Create(operInsEntity);

                //给处理者发送信息
                if (!string.IsNullOrEmpty(successCode) && successCode.Length > 0)
                {
                    var messageEntity = new CiMessageEntity
                    {
                        Id           = BusinessLogic.NewGuid(),
                        FunctionCode = MessageFunction.Remind.ToString(),
                        ReceiverId   = DefaultRole.Administrator.ToString(),
                        Title        = "业务流程消息",
                        MSGContent   = "你有一待办任务,请到未认领任务界面认领。",
                        IsNew        = 1,
                        ReadCount    = 0,
                        Enabled      = 1,
                        DeleteMark   = 0
                    };

                    var messageManager = new CiMessageManager(DbFactoryProvider.GetProvider(SystemInfo.RDIFrameworkDbType, SystemInfo.RDIFrameworkDbConectionString), this.UserInfo);
                    messageManager.BatchSend(operInsEntity.OperContent, null, null, messageEntity, false);
                }
                if ((userId == operParam.OperContent) && (operParam.IsJumpSelf))    //处理者是提交人,自动处理
                {
                    var wfrun = new WorkFlowRuntime();
                    wfrun.Run(userId, operInsEntity.OperatorInsId, "提交");
                }
            }
            break;
            }
            return(true);
        }
コード例 #15
0
        /// <summary>
        /// 按查询引擎主键列表得到对应的查询引擎定义列表
        /// </summary>
        private void GetDynamicJsonByQueryEngineDefineId(HttpContext context)
        {
            try
            {
                var queryEngineDefineId = PublicMethod.GetString(WebCommon.StringHelper.GetRequestObject("queryEngineDefineId"));
                int pageSize            = Convert.ToInt32(WebCommon.StringHelper.GetRequestObject("pageSize"));
                int pageIndex           = Convert.ToInt32(WebCommon.StringHelper.GetRequestObject("pageNumber"));
                //排序字段
                string sortName = RDIFramework.Utilities.BusinessLogic.ConvertToString(WebCommon.StringHelper.GetRequestObject("sort"));
                //排序方式
                string sortType = RDIFramework.Utilities.BusinessLogic.ConvertToString(WebCommon.StringHelper.GetRequestObject("order"));

                var where = "";
                var filters = RDIFramework.Utilities.BusinessLogic.ConvertToString(WebCommon.StringHelper.GetRequestObject("filter"));
                if (!string.IsNullOrEmpty(filters))
                {
                    string grouptype;
                    var    list = SearchFilter.GetSearchList(filters, out grouptype);
                    where = SearchFilter.ToSql(list, grouptype);
                }

                var      _pageindex  = pageIndex > 0 ? pageIndex : 1;
                var      _pagesize   = pageSize > 0 ? pageSize : 10;
                var      recordCount = 0;
                UserInfo vUser       = Utils.UserInfo;
                QueryEngineDefineEntity queryEngineDefineEntity = RDIFrameworkService.Instance.QueryEngineService.GetQueryEngineDefineEntity(vUser, queryEngineDefineId);
                CiDbLinkDefineEntity    dblinkEntity            = null;
                IDbProvider             dbProvider = null;
                if (queryEngineDefineEntity != null && !string.IsNullOrEmpty(queryEngineDefineEntity.DataBaseLinkName))
                {
                    dblinkEntity = RDIFrameworkService.Instance.DbLinkDefineService.GetEntity(vUser, queryEngineDefineEntity.DataBaseLinkName);
                }

                if (dblinkEntity != null)
                {
                    var DbDefine = RDIFrameworkService.Instance.DbLinkDefineService.GetEntityByLinkName(vUser, dblinkEntity.LinkName);
                    dbProvider = DbDefine != null?DbFactoryProvider.GetProvider((CurrentDbType)Enum.Parse(typeof(CurrentDbType), DbDefine.LinkType, true), SecretHelper.AESDecrypt(DbDefine.LinkData))
                                     : DbFactoryProvider.GetProvider(SystemInfo.BusinessDbType, SystemInfo.BusinessDbConnectionString);
                }

                var dtDynamicJsonDt = dbProvider.GetDTByPage(out recordCount, queryEngineDefineEntity.QueryString, _pageindex, _pagesize, string.Empty, queryEngineDefineEntity.OrderByField);


                var JsonData = new
                {
                    page  = _pageindex,
                    total = recordCount,
                    rows  = dtDynamicJsonDt
                };
                string returnJson = Newtonsoft.Json.JsonConvert.SerializeObject(JsonData);
                //{ "columns":"[[ {"field":"field1","title":"title1"},{...} ]]",data:[{page:"pageIndex",total:"totalNum",rows:[{name1:value,name2:value},{...}]}]}
                returnJson = "{\"columns\":" + CreateDataGridColumnModel(dtDynamicJsonDt) + ",\"data\":[" + returnJson + "]}";

                //TODO:待处理,处理异常情况(如:数据库连接失败等),前端应该提示
                context.Response.Write(returnJson);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #16
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            SystemInfo.EnableRecordLog = true;
            SystemInfo.StartupPath     = Application.StartupPath;
            UserConfigHelper.GetConfig();
            System.Console.ForegroundColor = ConsoleColor.Red;
            System.Console.WriteLine(@"服务器端正在启动...");
            System.Console.ForegroundColor = ConsoleColor.White;
            // 读取配置文件
            var configuration            = ConfigurationManager.OpenExeConfiguration(Assembly.GetEntryAssembly().Location);
            var serviceModelSectionGroup = (ServiceModelSectionGroup)configuration.GetSectionGroup("system.serviceModel");
            // 开启每个服务
            var idxService = 1;

            if (serviceModelSectionGroup != null)
            {
                foreach (var serviceHost in from ServiceElement serviceElement in serviceModelSectionGroup.Services.Services
                         let assemblyString = serviceElement.Name.Substring(0, serviceElement.Name.LastIndexOf('.'))
                                              select new System.ServiceModel.ServiceHost(Assembly.Load(assemblyString).GetType(serviceElement.Name), serviceElement.Endpoints[0].Address))
                {
                    serviceHost.Opened += delegate
                    {
                        Console.WriteLine(@"第{0:00}个服务:{1}", idxService, serviceHost.BaseAddresses[0]);
                    };
                    serviceHost.Open();
                    idxService++;
                }


                /* V2.7版本时的方法
                 * foreach (ServiceElement serviceElement in serviceModelSectionGroup.Services.Services)
                 * {
                 *  var assemblyString = serviceElement.Name.Substring(0, serviceElement.Name.LastIndexOf('.'));
                 *  var serviceHost =
                 *      new System.ServiceModel.ServiceHost(Assembly.Load(assemblyString).GetType(serviceElement.Name),
                 *          serviceElement.Endpoints[0].Address);
                 *
                 *  serviceHost.Opened += delegate
                 *  {
                 *      Console.WriteLine(@"第{0:00}个服务:{1}", idxService, serviceHost.BaseAddresses[0]);
                 *  };
                 *  serviceHost.Open();
                 *  idxService++;
                 * }*/
            }
            System.Console.ForegroundColor = ConsoleColor.Green;
            System.Console.WriteLine(@"服务器端已正常启动...");
            System.Console.ForegroundColor = ConsoleColor.White;

            System.Console.WriteLine();
            System.Console.WriteLine();


            System.Console.WriteLine(@"服务器 当前时间:" + DateTime.Now.ToString(SystemInfo.DateTimeFormat));
            var dbProvider = DbFactoryProvider.GetProvider(SystemInfo.RDIFrameworkDbType, SystemInfo.RDIFrameworkDbConection);

            System.Console.WriteLine(@"数据库服务器 当前时间:" + dbProvider.GetDBDateTime());
            System.Console.WriteLine();

            // 写入调试信息
            #if (DEBUG)
            var rdiDBProviderService = new RDIFrameworkDBProviderService();
            System.Console.WriteLine(@"RDIFramework.NET ━ .NET快速信息化系统开发框架 数据库服务器数据库连接:");
            System.Console.WriteLine(rdiDBProviderService.ServiceDbConnection);
            System.Console.WriteLine(rdiDBProviderService.ExecuteScalar(SystemInfo.UserInfo, "SELECT GETDATE()").ToString());
            System.Console.WriteLine();

            var bizDBProviderService = new BusinessDBProviderService();
            System.Console.WriteLine(@"业务数据库服务器 数据库连接:");
            System.Console.WriteLine(bizDBProviderService.ServiceDbConnection);
            System.Console.WriteLine(bizDBProviderService.ExecuteScalar(SystemInfo.UserInfo, "SELECT GETDATE()").ToString());
            System.Console.ReadLine();
            #endif
            Application.Run(new FrmServiceHost());
        }
コード例 #17
0
        private void InputPage(DataSet ifromDs, DataSet itoDs)
        {
            DataTable fromTable  = ifromDs.Tables["MainUserControl"];
            DataTable toTable    = null;
            var       dbProvider = DbFactoryProvider.GetProvider(SystemInfo.WorkFlowDbType, SystemInfo.WorkFlowDbConnectionString);
            string    tmpguid    = "";

            //1、导入pagobj
            ProgressShow("MainUserControl");
            if (fromTable != null && fromTable.Rows.Count > 0)
            {
                toTable = dbProvider.Fill("select * from mainusercontrol where 1<> 1");
                foreach (DataRow dr in fromTable.Rows)
                {
                    tmpguid = dr["MainUserCtrlId"].ToString();
                    if (tmpguid == null || tmpguid.Trim().Length == 0)
                    {
                        continue;
                    }
                    if (ExistMainUserControl(tmpguid))
                    {
                        continue;
                    }

                    DataRow tmpdr = toTable.NewRow();
                    for (int i = 0; i < fromTable.Columns.Count; i++)
                    {
                        if (toTable.Columns.Contains(fromTable.Columns[i].Caption))
                        {
                            tmpdr[fromTable.Columns[i].Caption] = dr[fromTable.Columns[i].Caption];
                        }
                    }
                    toTable.Rows.Add(tmpdr);
                }
                itoDs.Tables.Add(toTable.Copy());
            }

            //2、导入Control
            ProgressShow("usercontrols");
            fromTable = ifromDs.Tables["usercontrols"];
            if (fromTable != null && fromTable.Rows.Count > 0)
            {
                toTable = dbProvider.Fill("select * from usercontrols where 1<> 1");
                foreach (DataRow dr in fromTable.Rows)
                {
                    tmpguid = dr["UserControlId"].ToString();
                    if (tmpguid == null || tmpguid.Trim().Length == 0)
                    {
                        continue;
                    }
                    if (ExistUserControl(tmpguid))
                    {
                        continue;
                    }

                    DataRow tmpdr = toTable.NewRow();
                    for (int i = 0; i < fromTable.Columns.Count; i++)
                    {
                        if (toTable.Columns.Contains(fromTable.Columns[i].Caption))
                        {
                            tmpdr[fromTable.Columns[i].Caption] = dr[fromTable.Columns[i].Caption];
                        }
                    }
                    toTable.Rows.Add(tmpdr);
                }
                itoDs.Tables.Add(toTable.Copy());
            }
            //3、导入UserControlsLink
            ProgressShow("UserControlsLink");
            fromTable = ifromDs.Tables["UserControlsLink"];
            if (fromTable != null && fromTable.Rows.Count > 0)
            {
                toTable = dbProvider.Fill("select * from usercontrolslink where 1<> 1");
                foreach (DataRow dr in fromTable.Rows)
                {
                    tmpguid = dr["mucLinkId"].ToString();
                    if (tmpguid == null || tmpguid.Trim().Length == 0)
                    {
                        continue;
                    }
                    if (ExistControlLink(tmpguid))
                    {
                        continue;
                    }

                    DataRow tmpdr = toTable.NewRow();
                    for (int i = 0; i < fromTable.Columns.Count; i++)
                    {
                        if (toTable.Columns.Contains(fromTable.Columns[i].Caption))
                        {
                            tmpdr[fromTable.Columns[i].Caption] = dr[fromTable.Columns[i].Caption];
                        }
                    }
                    toTable.Rows.Add(tmpdr);
                }
                itoDs.Tables.Add(toTable.Copy());
            }

            dbProvider.Close();
            dbProvider.Dispose();
        }
コード例 #18
0
        private bool InputWorkflow(DataSet ifromDs, DataSet itoDs)
        {
            DataTable fromTable    = ifromDs.Tables["WorkFlow"];
            var       dbProvider   = DbFactoryProvider.GetProvider(SystemInfo.WorkFlowDbType, SystemInfo.WorkFlowDbConnectionString);
            DataTable toTable      = null;
            string    workFlowguid = ""; //流程guid
            string    workFlowname = ""; //流程名

            if (fromTable != null && fromTable.Rows.Count > 0)
            {
                workFlowguid = fromTable.Rows[0]["workflowId"].ToString();
                workFlowname = fromTable.Rows[0]["flowCaption"].ToString();
                if (existWorkflow(workFlowguid))
                {
                    MessageBox.Show("流程[" + workFlowname + "]已经存在不能导入!", "系统提示");
                    return(false);
                }
                InputFlowId = workFlowguid;//一定要放在开始导入后,导入失败后该值为空

                //1、导入workflow
                ProgressShow("WorkFlow");
                toTable = dbProvider.Fill("SELECT * FROM WorkFlow WHERE 1<>1");
                foreach (DataRow dr in fromTable.Rows)
                {
                    dr["wfclassid"] = WfClassId;
                    DataRow tmpdr = toTable.NewRow();
                    for (int i = 0; i < fromTable.Columns.Count; i++)
                    {
                        if (toTable.Columns.Contains(fromTable.Columns[i].Caption))
                        {
                            tmpdr[fromTable.Columns[i].Caption] = dr[fromTable.Columns[i].Caption];
                        }
                    }
                    toTable.Rows.Add(tmpdr);
                }
                itoDs.Tables.Add(toTable.Copy());
                //2、导入worktask
                ProgressShow("WorkTask");
                fromTable = ifromDs.Tables["WorkTask"];
                if (fromTable != null && fromTable.Rows.Count > 0)
                {
                    toTable = dbProvider.Fill("select * from worktask where 1<> 1");
                    foreach (DataRow dr in fromTable.Rows)
                    {
                        DataRow tmpdr = toTable.NewRow();
                        for (int i = 0; i < fromTable.Columns.Count; i++)
                        {
                            if (toTable.Columns.Contains(fromTable.Columns[i].Caption))
                            {
                                tmpdr[fromTable.Columns[i].Caption] = dr[fromTable.Columns[i].Caption];
                            }
                        }
                        toTable.Rows.Add(tmpdr);
                    }
                    itoDs.Tables.Add(toTable.Copy());
                }
                //3、导入worklink
                ProgressShow("worklink");
                fromTable = ifromDs.Tables["worklink"];
                if (fromTable != null && fromTable.Rows.Count > 0)
                {
                    toTable = dbProvider.Fill("select * from worklink where 1<> 1");
                    foreach (DataRow dr in fromTable.Rows)
                    {
                        DataRow tmpdr = toTable.NewRow();
                        for (int i = 0; i < fromTable.Columns.Count; i++)
                        {
                            if (toTable.Columns.Contains(fromTable.Columns[i].Caption))
                            {
                                tmpdr[fromTable.Columns[i].Caption] = dr[fromTable.Columns[i].Caption];
                            }
                        }
                        toTable.Rows.Add(tmpdr);
                    }
                    itoDs.Tables.Add(toTable.Copy());
                }

                //4、导入var
                ProgressShow("taskvar");
                fromTable = ifromDs.Tables["taskvar"];
                if (fromTable != null && fromTable.Rows.Count > 0)
                {
                    toTable = dbProvider.Fill("select * from taskvar where 1<> 1");
                    foreach (DataRow dr in fromTable.Rows)
                    {
                        DataRow tmpdr = toTable.NewRow();
                        for (int i = 0; i < fromTable.Columns.Count; i++)
                        {
                            if (toTable.Columns.Contains(fromTable.Columns[i].Caption))
                            {
                                tmpdr[fromTable.Columns[i].Caption] = dr[fromTable.Columns[i].Caption];
                            }
                        }
                        toTable.Rows.Add(tmpdr);
                    }
                    itoDs.Tables.Add(toTable.Copy());
                }
                //5、导入operator
                ProgressShow("operator");
                fromTable = ifromDs.Tables["operator"];
                if (fromTable != null && fromTable.Rows.Count > 0)
                {
                    toTable = dbProvider.Fill("select * from operator where 1<>1");
                    foreach (DataRow dr in fromTable.Rows)
                    {
                        DataRow tmpdr = toTable.NewRow();
                        for (int i = 0; i < fromTable.Columns.Count; i++)
                        {
                            if (toTable.Columns.Contains(fromTable.Columns[i].Caption))
                            {
                                tmpdr[fromTable.Columns[i].Caption] = dr[fromTable.Columns[i].Caption];
                            }
                        }
                        toTable.Rows.Add(tmpdr);
                    }
                    itoDs.Tables.Add(toTable.Copy());
                }
                //6、导入subWorkFlow
                ProgressShow("subWorkFlow");
                fromTable = ifromDs.Tables["subWorkFlow"];
                if (fromTable != null && fromTable.Rows.Count > 0)
                {
                    toTable = dbProvider.Fill("select * from subworkflow where 1<>1");
                    foreach (DataRow dr in fromTable.Rows)
                    {
                        DataRow tmpdr = toTable.NewRow();
                        for (int i = 0; i < fromTable.Columns.Count; i++)
                        {
                            if (toTable.Columns.Contains(fromTable.Columns[i].Caption))
                            {
                                tmpdr[fromTable.Columns[i].Caption] = dr[fromTable.Columns[i].Caption];
                            }
                        }
                        toTable.Rows.Add(tmpdr);
                    }
                    itoDs.Tables.Add(toTable.Copy());
                }
                //7、导入WorkTaskCommands
                ProgressShow("WorkTaskCommands");
                fromTable = ifromDs.Tables["WorkTaskCommands"];
                if (fromTable != null && fromTable.Rows.Count > 0)
                {
                    toTable = dbProvider.Fill("select * from worktaskcommands where 1<>1");
                    foreach (DataRow dr in fromTable.Rows)
                    {
                        DataRow tmpdr = toTable.NewRow();
                        for (int i = 0; i < fromTable.Columns.Count; i++)
                        {
                            if (toTable.Columns.Contains(fromTable.Columns[i].Caption))
                            {
                                tmpdr[fromTable.Columns[i].Caption] = dr[fromTable.Columns[i].Caption];
                            }
                        }
                        toTable.Rows.Add(tmpdr);
                    }
                    itoDs.Tables.Add(toTable.Copy());
                }
                //8、导入worktaskControls
                ProgressShow("worktaskControls");
                fromTable = ifromDs.Tables["worktaskControls"];
                if (fromTable != null && fromTable.Rows.Count > 0)
                {
                    toTable = dbProvider.Fill("select * from worktaskcontrols where 1<>1");
                    foreach (DataRow dr in fromTable.Rows)
                    {
                        DataRow tmpdr = toTable.NewRow();
                        for (int i = 0; i < fromTable.Columns.Count; i++)
                        {
                            if (toTable.Columns.Contains(fromTable.Columns[i].Caption))
                            {
                                tmpdr[fromTable.Columns[i].Caption] = dr[fromTable.Columns[i].Caption];
                            }
                        }
                        toTable.Rows.Add(tmpdr);
                    }
                    itoDs.Tables.Add(toTable.Copy());
                }
                //9、导入 WorkFlowEvent
                ProgressShow("WorkFlowEvent");
                fromTable = ifromDs.Tables["WorkFlowEvent"];
                if (fromTable != null && fromTable.Rows.Count > 0)
                {
                    toTable = dbProvider.Fill("select * from workflowevent where 1<> 1");
                    foreach (DataRow dr in fromTable.Rows)
                    {
                        DataRow tmpdr    = toTable.NewRow();
                        string  Evntguid = System.Guid.NewGuid().ToString();
                        for (int i = 0; i < fromTable.Columns.Count; i++)
                        {
                            if (toTable.Columns.Contains(fromTable.Columns[i].Caption))
                            {
                                tmpdr[fromTable.Columns[i].Caption] = dr[fromTable.Columns[i].Caption];
                            }
                        }

                        toTable.Rows.Add(tmpdr);
                    }

                    itoDs.Tables.Add(toTable.Copy());
                }
                //10、导入 WorkOutTime
                ProgressShow("WorkOutTime");
                fromTable = ifromDs.Tables["WorkOutTime"];
                if (fromTable != null && fromTable.Rows.Count > 0)
                {
                    toTable = dbProvider.Fill("select * from workouttime where 1<>1");
                    foreach (DataRow dr in fromTable.Rows)
                    {
                        DataRow tmpdr  = toTable.NewRow();
                        string  otguid = System.Guid.NewGuid().ToString();
                        for (int i = 0; i < fromTable.Columns.Count; i++)
                        {
                            if (toTable.Columns.Contains(fromTable.Columns[i].Caption))
                            {
                                tmpdr[fromTable.Columns[i].Caption] = dr[fromTable.Columns[i].Caption];
                            }
                        }
                        toTable.Rows.Add(tmpdr);
                    }
                    itoDs.Tables.Add(toTable.Copy());
                }
                dbProvider.Close();
                dbProvider.Dispose();

                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #19
0
        /// <summary>
        /// 得到Oracle分页数据
        /// </summary>
        /// <param name="connectionstring">连接字符串</param>
        /// <returns></returns>
        private DataTable GetOraclePageDate(string connectionstring)
        {
            var orcParameters = new OracleParameter[9];

            orcParameters[0] = new OracleParameter("p_tablename", OracleType.VarChar, 50)
            {
                Value = _TableName
            };
            orcParameters[1] = new OracleParameter("p_tablecolumn", OracleType.VarChar, 1000)
            {
                Value = _QueryFieldName
            };
            orcParameters[2] = new OracleParameter("p_order", OracleType.VarChar, 100)
            {
                Value = _OrderStr
            };
            orcParameters[3] = new OracleParameter("p_pagesize", OracleType.Int32)
            {
                Value = PageSize
            };
            orcParameters[4] = new OracleParameter("p_curpage", OracleType.Int32)
            {
                Value = PageIndex
            };
            orcParameters[5] = new OracleParameter("p_where", OracleType.VarChar, 1000)
            {
                Value = _QueryCondition
            };
            orcParameters[6] = new OracleParameter("p_rowcount", OracleType.Int32)
            {
                Value = 0, Direction = ParameterDirection.Output
            };                                                                                                                           //返回的总记录数
            orcParameters[7] = new OracleParameter("p_pagecount", OracleType.Int32)
            {
                Value = 0, Direction = ParameterDirection.Output
            };                                                                                                                            //总页数
            orcParameters[8] = new OracleParameter("p_cursor", OracleType.Cursor)
            {
                Direction = ParameterDirection.Output
            };
            dtPageData = DbFactoryProvider.GetProvider(PageDbType, connectionstring).ExecuteProcedureForDataTable("package_page.proc_page", _TableName, orcParameters);

            if (_isQueryTotalCounts)
            {
                Int32.TryParse(orcParameters[6].Value.ToString(), out _TotalCount);
            }

            if (_TotalCount == 0)
            {
                _PageIndex = 0;
                _PageCount = 0;
            }
            else
            {
                _PageCount = _TotalCount % _PageSize == 0 ? _TotalCount / _PageSize : _TotalCount / _PageSize + 1;

                if (_PageIndex > _PageCount)
                {
                    _PageIndex             = _PageCount;
                    orcParameters[3].Value = _PageSize;
                    dtPageData             = QueryDataTable(connectionstring);
                }
            }

            return(dtPageData);
        }
コード例 #20
0
        private void InputNewWorkflow(DataSet ifromDs)
        {
            DataTable fromTable    = ifromDs.Tables["WorkFlow"];
            DataTable toTable      = null;
            string    workFlowguid = ""; //流程guid
            string    workFlowname = ""; //流程名
            var       dbProvider   = DbFactoryProvider.GetProvider(SystemInfo.WorkFlowDbType, SystemInfo.WorkFlowDbConnectionString);

            if (fromTable != null && fromTable.Rows.Count > 0)
            {
                workFlowguid = System.Guid.NewGuid().ToString();
                workFlowname = fromTable.Rows[0]["flowCaption"].ToString();
                InputFlowId  = workFlowguid;//一定要放在开始导入后,导入失败后该值为空
                //1、导入workflow
                ProgressShow("WorkFlow");
                toTable = dbProvider.Fill("select * from workflow where 1<> 1");
                foreach (DataRow dr in fromTable.Rows)
                {
                    dr["WfClassId"] = WfClassId;
                    DataRow tmpdr = toTable.NewRow();
                    for (int i = 0; i < fromTable.Columns.Count; i++)
                    {
                        if (toTable.Columns.Contains(fromTable.Columns[i].Caption))
                        {
                            tmpdr[fromTable.Columns[i].Caption] = dr[fromTable.Columns[i].Caption];
                        }
                    }
                    tmpdr["workflowId"] = workFlowguid;
                    toTable.Rows.Add(tmpdr);
                }

                //dbProvider.UpdateDTWithTranse(toTable);

                //2、导入WorkLink
                ProgressShow("worklink");
                fromTable = ifromDs.Tables["worklink"];
                if (fromTable != null && fromTable.Rows.Count > 0)
                {
                    toTable = dbProvider.Fill("select * from worklink  where 1<> 1");

                    foreach (DataRow dr in fromTable.Rows)
                    {
                        DataRow tmpdr        = toTable.NewRow();
                        string  worklinkguid = System.Guid.NewGuid().ToString();
                        for (int i = 0; i < fromTable.Columns.Count; i++)
                        {
                            if (toTable.Columns.Contains(fromTable.Columns[i].Caption))
                            {
                                tmpdr[fromTable.Columns[i].Caption] = dr[fromTable.Columns[i].Caption];
                            }
                        }
                        tmpdr["WorklinkId"] = worklinkguid;
                        tmpdr["workflowId"] = workFlowguid;
                        toTable.Rows.Add(tmpdr);
                    }

                    //dbProvider.UpdateDTWithTranse(toTable);
                }
                //3、导入 taskvar
                ProgressShow("taskvar");
                fromTable = ifromDs.Tables["taskvar"];
                if (fromTable != null && fromTable.Rows.Count > 0)
                {
                    toTable = dbProvider.Fill("select * from taskvar  where 1<> 1");
                    foreach (DataRow dr in fromTable.Rows)
                    {
                        DataRow tmpdr   = toTable.NewRow();
                        string  varguid = System.Guid.NewGuid().ToString();
                        for (int i = 0; i < fromTable.Columns.Count; i++)
                        {
                            if (toTable.Columns.Contains(fromTable.Columns[i].Caption))
                            {
                                tmpdr[fromTable.Columns[i].Caption] = dr[fromTable.Columns[i].Caption];
                            }
                        }
                        tmpdr["taskvarId"]  = varguid;
                        tmpdr["workflowId"] = workFlowguid;
                        toTable.Rows.Add(tmpdr);
                    }

                    //dbProvider.UpdateDTWithTranse(toTable);
                }

                //4、导入 worktaskcontrols
                ProgressShow("worktaskcontrols");
                fromTable = ifromDs.Tables["worktaskcontrols"];
                if (fromTable != null && fromTable.Rows.Count > 0)
                {
                    toTable = dbProvider.Fill("select * from worktaskcontrols  where 1<> 1");
                    foreach (DataRow dr in fromTable.Rows)
                    {
                        DataRow tmpdr        = toTable.NewRow();
                        string  taskctrlguid = System.Guid.NewGuid().ToString();
                        for (int i = 0; i < fromTable.Columns.Count; i++)
                        {
                            if (toTable.Columns.Contains(fromTable.Columns[i].Caption))
                            {
                                tmpdr[fromTable.Columns[i].Caption] = dr[fromTable.Columns[i].Caption];
                            }
                        }
                        tmpdr["taskcontrolId"] = taskctrlguid;
                        tmpdr["workflowId"]    = workFlowguid;
                        toTable.Rows.Add(tmpdr);
                    }

                    //dbProvider.UpdateDTWithTranse(toTable);
                }

                //5、导入 operator
                ProgressShow("operator");
                fromTable = ifromDs.Tables["operator"];
                if (fromTable != null && fromTable.Rows.Count > 0)
                {
                    toTable = dbProvider.Fill("select * from operator  where 1<> 1");
                    foreach (DataRow dr in fromTable.Rows)
                    {
                        DataRow tmpdr        = toTable.NewRow();
                        string  operatorguid = System.Guid.NewGuid().ToString();
                        for (int i = 0; i < fromTable.Columns.Count; i++)
                        {
                            if (toTable.Columns.Contains(fromTable.Columns[i].Caption))
                            {
                                tmpdr[fromTable.Columns[i].Caption] = dr[fromTable.Columns[i].Caption];
                            }
                        }
                        tmpdr["operatorId"] = operatorguid;
                        tmpdr["workflowId"] = workFlowguid;
                        toTable.Rows.Add(tmpdr);
                    }
                    //dbProvider.UpdateDTWithTranse(toTable);
                }

                //6、导入 WorkTaskCommands
                ProgressShow("WorkTaskCommands");
                fromTable = ifromDs.Tables["WorkTaskCommands"];
                if (fromTable != null && fromTable.Rows.Count > 0)
                {
                    toTable = dbProvider.Fill("select * from WorkTaskCommands  where 1<> 1");
                    foreach (DataRow dr in fromTable.Rows)
                    {
                        DataRow tmpdr   = toTable.NewRow();
                        string  cmdguid = System.Guid.NewGuid().ToString();
                        for (int i = 0; i < fromTable.Columns.Count; i++)
                        {
                            if (toTable.Columns.Contains(fromTable.Columns[i].Caption))
                            {
                                tmpdr[fromTable.Columns[i].Caption] = dr[fromTable.Columns[i].Caption];
                            }
                        }
                        tmpdr["CommandId"]  = cmdguid;
                        tmpdr["workflowId"] = workFlowguid;
                        toTable.Rows.Add(tmpdr);
                    }

                    //dbProvider.UpdateDTWithTranse(toTable);
                }
                //7、导入 subworkflow
                ProgressShow("subworkflow");
                fromTable = ifromDs.Tables["subworkflow"];
                if (fromTable != null && fromTable.Rows.Count > 0)
                {
                    toTable = dbProvider.Fill("select * from subworkflow  where 1<> 1");
                    foreach (DataRow dr in fromTable.Rows)
                    {
                        DataRow tmpdr   = toTable.NewRow();
                        string  subguid = System.Guid.NewGuid().ToString();
                        for (int i = 0; i < fromTable.Columns.Count; i++)
                        {
                            if (toTable.Columns.Contains(fromTable.Columns[i].Caption))
                            {
                                tmpdr[fromTable.Columns[i].Caption] = dr[fromTable.Columns[i].Caption];
                            }
                        }
                        tmpdr["subId"]      = subguid;
                        tmpdr["workflowId"] = workFlowguid;
                        toTable.Rows.Add(tmpdr);
                    }
                    //dbProvider.UpdateDTWithTranse(toTable);
                }

                //8、导入 WorkFlowEvent
                ProgressShow("WorkFlowEvent");
                fromTable = ifromDs.Tables["WorkFlowEvent"];
                if (fromTable != null && fromTable.Rows.Count > 0)
                {
                    toTable = dbProvider.Fill("select * from WorkFlowEvent  where 1<> 1");
                    foreach (DataRow dr in fromTable.Rows)
                    {
                        DataRow tmpdr    = toTable.NewRow();
                        string  Evntguid = System.Guid.NewGuid().ToString();
                        for (int i = 0; i < fromTable.Columns.Count; i++)
                        {
                            if (toTable.Columns.Contains(fromTable.Columns[i].Caption))
                            {
                                tmpdr[fromTable.Columns[i].Caption] = dr[fromTable.Columns[i].Caption];
                            }
                        }
                        tmpdr["Guid"]       = Evntguid;
                        tmpdr["workflowId"] = workFlowguid;
                        toTable.Rows.Add(tmpdr);
                    }
                    //dbProvider.UpdateDTWithTranse(toTable);
                }

                //9、导入 WorkOutTime
                ProgressShow("WorkOutTime");
                fromTable = ifromDs.Tables["WorkOutTime"];
                if (fromTable != null && fromTable.Rows.Count > 0)
                {
                    toTable = dbProvider.Fill("select * from WorkOutTime  where 1<> 1");
                    foreach (DataRow dr in fromTable.Rows)
                    {
                        DataRow tmpdr  = toTable.NewRow();
                        string  otguid = System.Guid.NewGuid().ToString();
                        for (int i = 0; i < fromTable.Columns.Count; i++)
                        {
                            if (toTable.Columns.Contains(fromTable.Columns[i].Caption))
                            {
                                tmpdr[fromTable.Columns[i].Caption] = dr[fromTable.Columns[i].Caption];
                            }
                        }
                        tmpdr["Guid"]       = otguid;
                        tmpdr["workflowId"] = workFlowguid;
                        toTable.Rows.Add(tmpdr);
                    }
                    //dbProvider.UpdateDTWithTranse(toTable);
                }

                //10、导入WorkTask
                ProgressShow("WorkTask");
                fromTable = ifromDs.Tables["WorkTask"];
                if (fromTable != null && fromTable.Rows.Count > 0)
                {
                    toTable = dbProvider.Fill("select * from WorkTask  where 1<> 1");
                    foreach (DataRow dr in fromTable.Rows)
                    {
                        DataRow tmpdr        = toTable.NewRow();
                        string  taskguid     = System.Guid.NewGuid().ToString();
                        string  oldtaskguide = dr["worktaskId"].ToString();
                        for (int i = 0; i < fromTable.Columns.Count; i++)
                        {
                            if (toTable.Columns.Contains(fromTable.Columns[i].Caption))
                            {
                                tmpdr[fromTable.Columns[i].Caption] = dr[fromTable.Columns[i].Caption];
                            }
                        }
                        tmpdr["worktaskId"] = taskguid;
                        tmpdr["workflowid"] = workFlowguid;
                        toTable.Rows.Add(tmpdr);
                        string tmpUpdate = "update worklink set starttaskid='" + taskguid + "' where workflowId='" + workFlowguid + "' and starttaskid='" + oldtaskguide + "'";
                        dbProvider.ExecuteNonQuery(tmpUpdate);
                        tmpUpdate = "update worklink set endtaskid='" + taskguid + "' where workflowId='" + workFlowguid + "' and endtaskId='" + oldtaskguide + "'";
                        dbProvider.ExecuteNonQuery(tmpUpdate);
                        tmpUpdate = "update taskvar set worktaskid='" + taskguid + "' where workflowId='" + workFlowguid + "' and worktaskid='" + oldtaskguide + "'";
                        dbProvider.ExecuteNonQuery(tmpUpdate);
                        tmpUpdate = "update worktaskcontrols set worktaskid='" + taskguid + "' where workflowId='" + workFlowguid + "' and worktaskid='" + oldtaskguide + "'";
                        dbProvider.ExecuteNonQuery(tmpUpdate);
                        tmpUpdate = "update operator set worktaskid='" + taskguid + "' where workflowId='" + workFlowguid + "' and worktaskid='" + oldtaskguide + "'";
                        dbProvider.ExecuteNonQuery(tmpUpdate);
                        tmpUpdate = "update WorkTaskCommands set worktaskid='" + taskguid + "' where workflowId='" + workFlowguid + "' and worktaskid='" + oldtaskguide + "'";
                        dbProvider.ExecuteNonQuery(tmpUpdate);
                        tmpUpdate = "update subworkflow set worktaskid='" + taskguid + "' where workflowId='" + workFlowguid + "' and worktaskid='" + oldtaskguide + "'";
                        dbProvider.ExecuteNonQuery(tmpUpdate);
                        tmpUpdate = "update WorkFlowEvent set worktaskid='" + taskguid + "' where workflowId='" + workFlowguid + "' and worktaskid='" + oldtaskguide + "'";
                        dbProvider.ExecuteNonQuery(tmpUpdate);
                        tmpUpdate = "update WorkOutTime set worktaskid='" + taskguid + "' where workflowId='" + workFlowguid + "' and worktaskid='" + oldtaskguide + "'";
                        dbProvider.ExecuteNonQuery(tmpUpdate);
                    }

                    //dbProvider.UpdateDTWithTranse(toTable);
                }

                dbProvider.Close();
                dbProvider.Dispose();
            }
        }
コード例 #21
0
 private void FrmTestDgvSummary_Load(object sender, EventArgs e)
 {
     dbProvider = DbFactoryProvider.GetProvider(DbLinks["ProductDBLink"].DbType, SecretHelper.AESDecrypt(DbLinks["ProductDBLink"].DbLink));
     BindData();
 }