Пример #1
0
        protected static Queries.QueryMetadata Query(string serverId)
        {
            Queries.QueryMetadata           query      = new Queries.QueryMetadata();
            Queries.QueryDataSourceMetadata datasource = new Queries.QueryDataSourceMetadata();
            datasource.Table            = "BatchServerConfig";
            datasource.DynamicFieldList = true;
            datasource.Name             = "BatchServerConfig";
            datasource.Enabled          = true;
            datasource.OrderMode        = Queries.OrderMode.OrderBy;

            datasource.Ranges = new List <Queries.QueryRangeMetadata>();
            datasource.Ranges.Add(new Queries.QueryDataRangeMetadata()
            {
                Enabled = true, FieldName = "ServerId", Value = serverId
            });

            query.DataSources = new List <Queries.QueryDataSourceMetadata>();
            query.DataSources.Add(datasource);
            query.OrderByFields = new List <Queries.QueryOrderByMetadata>();
            query.OrderByFields.Add(new Queries.QueryDataOrderByMetadata()
            {
                DataSource = datasource.Name, SortOrder = Queries.SortOrder.Ascending, FieldName = "RecId"
            });

            return(query);
        }
Пример #2
0
        public static List <BatchConfiguration> Get(string serverId, string serverName, int wsdlPort)
        {
            Queries.QueryServiceClient queryClient = EndPoint.GetQueryClient(serverName, wsdlPort);

            Queries.QueryMetadata query = BatchConfiguration.Query(serverId);

            Queries.Paging paging = new Queries.PositionBasedPaging();
            (paging as Queries.PositionBasedPaging).StartingPosition       = 1;
            (paging as Queries.PositionBasedPaging).NumberOfRecordsToFetch = 100;

            Queries.ExecuteQueryRequest request = new Queries.ExecuteQueryRequest(query, paging);
            DataSet data = queryClient.ExecuteQuery(query, ref paging);

            List <BatchConfiguration> configs = null;

            configs = BatchConfiguration.RowsToConfigs(data);

            return(configs);
        }
Пример #3
0
        public static async Task <List <ServerConfiguration> > GetAsync(string serverName, int wsdlPort)
        {
            Queries.QueryServiceClient queryClient = EndPoint.GetQueryClient(serverName, wsdlPort);

            Queries.QueryMetadata query = ServerConfiguration.Query();

            Queries.PositionBasedPaging paging = new Queries.PositionBasedPaging();
            paging.StartingPosition       = 1;
            paging.NumberOfRecordsToFetch = 100;

            Queries.ExecuteQueryRequest         request   = new Queries.ExecuteQueryRequest(query, paging);
            Task <Queries.ExecuteQueryResponse> queryTask = queryClient.ExecuteQueryAsync(request);

            await queryTask;

            List <ServerConfiguration> configs = null;

            if (queryTask.Result != null)
            {
                configs = ServerConfiguration.RowsToConfigs(queryTask.Result.ExecuteQueryResult);

                // Get tasks for fetching batch configuration for each server
                var tasks = from server in configs select BatchConfiguration.GetAsync(server.ServerId, serverName, wsdlPort);

                // Await all batch configuration calls to return
                List <BatchConfiguration>[] batches = await Task.WhenAll(tasks);

                // Assign each batch configuration to its respective server
                foreach (var server in configs)
                {
                    var batchConfig = from b in batches where b[0].ServerId == server.ServerId select b;

                    if (batchConfig != null && batchConfig.Count() > 0)
                    {
                        server.BatchConfigurations = batchConfig.First().ToList();
                    }
                }
            }

            return(configs);
        }
Пример #4
0
        public static async Task <List <BatchConfiguration> > GetAsync(string serverId, string serverName, int wsdlPort)
        {
            Queries.QueryServiceClient queryClient = EndPoint.GetQueryClient(serverName, wsdlPort);

            Queries.QueryMetadata query = BatchConfiguration.Query(serverId);

            Queries.Paging paging = new Queries.PositionBasedPaging();
            (paging as Queries.PositionBasedPaging).StartingPosition       = 1;
            (paging as Queries.PositionBasedPaging).NumberOfRecordsToFetch = 100;

            Queries.ExecuteQueryRequest         request   = new Queries.ExecuteQueryRequest(query, paging);
            Task <Queries.ExecuteQueryResponse> queryTask = queryClient.ExecuteQueryAsync(request);

            await queryTask;

            List <BatchConfiguration> configs = null;

            if (queryTask.Result != null)
            {
                configs = BatchConfiguration.RowsToConfigs(queryTask.Result.ExecuteQueryResult);
            }

            return(configs);
        }