Exemplo n.º 1
0
        public DataSet Query(int startRowIndex, int maximumRows, string connection, string tableName, string selectFields, string where, string orderBy, ref int totalCount)
        {
            QueryCondition qc = new QueryCondition(startRowIndex, maximumRows, selectFields, tableName, orderBy, where);

            //OnBuildQueryCondition(qc);

            TSqlCommonAdapter adapter = new TSqlCommonAdapter(connection);

            DataSet result = adapter.SplitPageQuery(qc, totalCount <= 0);

            if (result.Tables.Count > 1)
            {
                totalCount = (int)result.Tables[1].Rows[0][0];
            }

            var contextCacheKey = connection + "." + tableName + ".Query";

            ObjectContextCache.Instance[contextCacheKey] = totalCount;

            //当页码超出索引的,返回最大页
            if (result.Tables[0].Rows.Count == 0 && totalCount > 0)
            {
                int newStartRowIndex = (totalCount - 1) / maximumRows * maximumRows;

                totalCount = -1;

                result = Query(newStartRowIndex, maximumRows, connection, tableName, selectFields, where, orderBy, ref totalCount);
            }

            return(result);
        }
Exemplo n.º 2
0
        private DataView InnerQuery(string entityID, int startRowIndex, int pageSize, string orderBy, ref int totalCount)
        {
            WhereSqlClauseBuilder wsc = new WhereSqlClauseBuilder();

            wsc.AppendItem("status", (int)SchemaObjectStatus.Normal);
            wsc.AppendItem("EntityCode", entityID);

            QueryCondition qc = new QueryCondition(startRowIndex, pageSize, "*", ORMapping.GetMappingInfo <DEEntityInstanceBase>().TableName, orderBy, wsc.ToSqlString(TSqlBuilder.Instance));

            TSqlCommonAdapter adapter = new TSqlCommonAdapter(GetConnectionName());

            DataSet ds = adapter.SplitPageQuery(qc, totalCount <= 0);

            DataView result = ds.Tables[0].DefaultView;

            if (ds.Tables.Count > 1)
            {
                totalCount = (int)ds.Tables[1].Rows[0][0];
            }

            //当页码超出索引的,返回最大页
            if (result.Count == 0 && totalCount > 0)
            {
                int newStartRowIndex = (totalCount - 1) / pageSize * pageSize;

                totalCount = -1;

                result = this.Query(entityID, newStartRowIndex, pageSize, orderBy, ref totalCount);
            }

            return(result);
        }
        private static WfClientUserOperationLogPageQueryResult QueryUserOperationLog(QueryCondition qc, int totalCount)
        {
            TSqlCommonAdapter adapter = new TSqlCommonAdapter(UserOperationLogAdapter.Instance.ConnectionName);

            UserOperationLogCollection serverLogs = adapter.SplitPageQuery <UserOperationLog, UserOperationLogCollection>(qc, ref totalCount);

            WfClientUserOperationLogCollection clientLogs = WfClientUserOperationLogConverter.Instance.ServerToClient(serverLogs);

            WfClientUserOperationLogPageQueryResult result = new WfClientUserOperationLogPageQueryResult();

            result.TotalCount = totalCount;
            result.QueryResult.CopyFrom(clientLogs);

            return(result);
        }
        private static WfClientProcessCurrentInfoPageQueryResult QueryProcessInfo(QueryCondition qc, int totalCount)
        {
            TSqlCommonAdapter adapter = new TSqlCommonAdapter(WfProcessCurrentInfoAdapter.Instance.ConnectionName);

            WfProcessCurrentInfoCollection processInfo = adapter.SplitPageQuery <WfProcessCurrentInfo, WfProcessCurrentInfoCollection>(qc, ref totalCount);

            WfClientProcessCurrentInfoCollection clientInfo = new WfClientProcessCurrentInfoCollection();

            WfClientProcessCurrentInfoConverter.Instance.ServerToClient(processInfo, clientInfo);

            WfClientProcessCurrentInfoPageQueryResult result = new WfClientProcessCurrentInfoPageQueryResult();

            result.TotalCount = totalCount;
            result.QueryResult.CopyFrom(clientInfo);

            return(result);
        }
        public WfClientProcessDescriptorInfoPageQueryResult QueryProcessDescriptorInfo(int startRowIndex, int maximumRows, string where, string orderBy, int totalCount)
        {
            OperationContext.Current.FillContextToOguServiceContext();

            if (orderBy.IsNullOrEmpty())
            {
                orderBy = "MODIFY_TIME DESC";
            }

            string selectFields = "PROCESS_KEY, APPLICATION_NAME, PROGRAM_NAME, PROCESS_NAME, ENABLED, CREATE_TIME, CREATOR_ID, CREATOR_NAME, MODIFY_TIME, MODIFIER_ID, MODIFIER_NAME, IMPORT_TIME, IMPORT_USER_ID, IMPORT_USER_NAME";

            QueryCondition qc = new QueryCondition(
                startRowIndex,
                maximumRows,
                selectFields,
                ORMapping.GetMappingInfo(typeof(WfProcessDescriptorInfo)).TableName,
                orderBy);

            WhereSqlClauseBuilder builder = new WhereSqlClauseBuilder();

            builder.AppendTenantCode();

            if (where.IsNotEmpty())
            {
                where += " AND ";
            }

            where += builder.ToSqlString(TSqlBuilder.Instance);

            qc.WhereClause = where;

            TSqlCommonAdapter adapter = new TSqlCommonAdapter(WfProcessDescriptorInfoAdapter.Instance.ConnectionName);

            WfProcessDescriptorInfoCollection processInfo = adapter.SplitPageQuery <WfProcessDescriptorInfo, WfProcessDescriptorInfoCollection>(qc, ref totalCount);

            WfClientProcessDescriptorInfoCollection clientInfo = new WfClientProcessDescriptorInfoCollection();

            WfClientProcessDescriptorInfoConverter.Instance.ServerToClient(processInfo, clientInfo);

            WfClientProcessDescriptorInfoPageQueryResult result = new WfClientProcessDescriptorInfoPageQueryResult();

            result.TotalCount = totalCount;
            result.QueryResult.CopyFrom(clientInfo);

            return(result);
        }