Example #1
0
        public async Task <Status> Get()
        {
            var sites = _settingsHelper.GetSites().ToList();

            Trace.WriteLine("Sites: " + string.Join(", ", sites));
            var siteSet = new HashSet <string>(sites.Concat(sites.Select(s => s + "(staging)")), StringComparer.OrdinalIgnoreCase);

            WebSpacesListResponse spaces;

            try
            {
                var client = _clientHelper.GetWebSiteClient();
                spaces = await client.WebSpaces.ListAsync(CancellationToken.None);
            }
            catch (Exception ex)
            {
                Trace.TraceError(ex.ToString());
                throw;
            }
            try
            {
                var siteLists = await Task.WhenAll(spaces.Select(space => ListWebSites(space.Name, siteSet)));

                Output = DtoCollection.Create(siteLists.SelectMany(l => l).Select(WebSiteDto.FromSdk).OrderBy(dto => dto.Name));
            }
            catch (Exception ex)
            {
                Trace.TraceError(ex.ToString());
                throw;
            }
            return(200);
        }
Example #2
0
        public async Task <Status> Post(WebSiteDto site)
        {
            var client = _clientHelper.GetWebSiteClient();
            await client.WebSites.SyncRepositoryAsync(WebSpace, Name, CancellationToken.None);

            return(200);
        }
Example #3
0
        public async Task <Status> Put(AppSettingsDto dto)
        {
            var client = _clientHelper.GetWebSiteClient();

            try
            {
                var settings = await client.WebSites.GetConfigurationAsync(WebSpace, Name, CancellationToken.None);

                var parameters = new WebSiteUpdateConfigurationParameters
                {
                    AppSettings       = Merge(settings.AppSettings, dto.Settings),
                    ConnectionStrings = null,
                    DefaultDocuments  = null,
                    HandlerMappings   = null,
                    Metadata          = null
                };
                var op =
                    await client.WebSites.UpdateConfigurationAsync(WebSpace, Name, parameters, CancellationToken.None);

                return((int)op.StatusCode);
            }
            catch (Exception ex)
            {
                Trace.TraceError(ex.ToString());
                return(500);
            }
        }
Example #4
0
        public async Task <Status> Get()
        {
            var client = _clientHelper.GetWebSiteClient();
            var status = await client.GetOperationStatusAsync(WebSpace, SiteName, OperationId, CancellationToken.None);

            Output = new OperationStatusDto
            {
                Status = status.Status.ToString()
            };
            return(200);
        }
Example #5
0
        public async Task <Status> Post(WebSiteDto site)
        {
            var client    = _clientHelper.GetWebSiteClient();
            var operation = await client.WebSites.BeginSwapingSlotsAsync(WebSpace, Name, Slot, CancellationToken.None);

            Output = new OperationResultDto
            {
                OperationId = operation.OperationId,
                SiteName    = Name,
                WebSpace    = WebSpace
            };
            return(202);
        }