예제 #1
0
        public static Queries.QueryServiceClient GetQueryClient(string serverName, int wsdlPort)
        {
            Queries.QueryServiceClient queryClient = new Queries.QueryServiceClient(
                new System.ServiceModel.NetTcpBinding()
            {
                TransferMode = System.ServiceModel.TransferMode.Streamed
            },
                new System.ServiceModel.EndpointAddress(String.Format("net.tcp://{0}:{1}/DynamicsAx/Services/QueryService", serverName, wsdlPort)));

            queryClient.Endpoint.Contract = System.ServiceModel.Description.ContractDescription.GetContract(typeof(Queries.IQueryService));

            return(queryClient);
        }
예제 #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);
        }