public override void Invoke(AWSCredentials creds, RegionEndpoint region, int maxItems)
        {
            AmazonServerMigrationServiceConfig config = new AmazonServerMigrationServiceConfig();

            config.RegionEndpoint = region;
            ConfigureClient(config);
            AmazonServerMigrationServiceClient client = new AmazonServerMigrationServiceClient(creds, config);

            GetServersResponse resp = new GetServersResponse();

            do
            {
                GetServersRequest req = new GetServersRequest
                {
                    NextToken = resp.NextToken
                    ,
                    MaxResults = maxItems
                };

                resp = client.GetServers(req);
                CheckError(resp.HttpStatusCode, "200");

                foreach (var obj in resp.ServerList)
                {
                    AddObject(obj);
                }
            }while (!string.IsNullOrEmpty(resp.NextToken));
        }
        /// <summary>
        /// 获取下载任务的服务器列表
        /// </summary>
        /// <param name="gid"></param>
        /// <returns></returns>
        public async Task <List <ServerModel> > GetServers(string gid)
        {
            var res = new GetServersResponse(await _client.SendRequestAsync(new GetServersRequest
            {
                GID = gid
            }));

            return(res?.Info);
        }
示例#3
0
        private GetServersResponse GetLocalServers()
        {
            _logger.Info("Reading local servers list.");
            var servers     = _database.QueryAsync <Server>("select * from Servers");
            var localResult = new GetServersResponse();

            localResult.AddRange(servers.Result);
            return(localResult);
        }
示例#4
0
        public GetServersResponse GetServers(GetServersRequest request)
        {
            var response = new GetServersResponse();

            response.ServerInfoList = new List <ServerInfo>();

            //var list = _hbArchiveItems.Where(w => w.ApplicationName == request.ServiceName || request.AllServers).GroupBy(x => x.ClientMachine).Select(group => new { ServerName = group.Key, Items = group.ToList() }).ToList();

            var deneme =
                _allInfo.Where(w => w.ApplicationName == request.ServiceName || request.AllServers)
                .GroupBy(g => g.ServerName)
                .Select(group => new { ServerName = group.Key, Items = group.ToList() })
                .ToList();

            foreach (var item in deneme)
            {
                var serviceInfo = item.Items.OrderByDescending(x => x.LastHeartBeatDate).FirstOrDefault();
                if (serviceInfo != null)
                {
                    response.ServerInfoList.Add(new ServerInfo()
                    {
                        ServerName = item.ServerName,
                        LastHb     = serviceInfo.LastHeartBeatDate
                    });
                }
            }

            //var deneme = list.Join(_allInfo, hbArchiveItem => hbArchiveItem.ServerName,
            //    allService => allService.ServerName,
            //    (hbArchiveItem, allService) => new { HbArchiveItem = hbArchiveItem, ServiceInfo = allService });

            //foreach (var hbArchiveItem in list)
            //{
            //    response.ServerInfoList.Add(new ServerInfo()
            //    {
            //        ServerName = hbArchiveItem.ClientMachine,
            //        LastHb =
            //    });
            //}
            return(response);
        }
示例#5
0
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            GetServersResponse response = new GetServersResponse();

            context.Read();
            int targetDepth = context.CurrentDepth;

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("lastModifiedOn", targetDepth))
                {
                    var unmarshaller = DateTimeUnmarshaller.Instance;
                    response.LastModifiedOn = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("nextToken", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.NextToken = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("serverCatalogStatus", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.ServerCatalogStatus = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("serverList", targetDepth))
                {
                    var unmarshaller = new ListUnmarshaller <Server, ServerUnmarshaller>(ServerUnmarshaller.Instance);
                    response.ServerList = unmarshaller.Unmarshall(context);
                    continue;
                }
            }

            return(response);
        }