示例#1
0
        public async Task <Status> Get()
        {
            var user       = (IgorUser)CurrentUser;
            var extensions = _clientHelper.GetWebSiteExtensionsClient(HostName, user.Name, user.Password);

            try
            {
                var deployments = await extensions.Deployments.ListAsync(null, CancellationToken.None);

                var current = deployments.Deployments.FirstOrDefault(d => d.Active);
                if (current != null)
                {
                    Output = new DeploymentDto
                    {
                        Message = current.Message,
                        Time    = current.ReceivedTime
                    };
                    return(200);
                }
                return(404);
            }
            catch
            {
                return(404);
            }
        }
示例#2
0
        public async Task <Status> Post(WebSiteDto site)
        {
            var user        = (IgorUser)CurrentUser;
            var extensions  = _clientHelper.GetWebSiteExtensionsClient(Name, user.Name, user.Password);
            var jobs        = (await extensions.WebJobs.ListContinuousAsync(null, CancellationToken.None)).ToList();
            var runningJobs = jobs.Where(job => job.Status.Equals("Stopped", StringComparison.OrdinalIgnoreCase));
            var tasks       = runningJobs.Select(job => extensions.WebJobs.StartContinuousAsync(job.Name, CancellationToken.None));
            await Task.WhenAll(tasks);

            return(200);
        }
示例#3
0
        public IUser GetLoggedInUser(IContext context)
        {
            string[] header;
            if (!context.Request.Headers.TryGetValue("Authorization", out header))
            {
                return(null);
            }
            if (header == null || header.Length != 1)
            {
                return(null);
            }
            var user = HttpRuntime.Cache.Get(header[0]) as IgorUser;

            if (user != null)
            {
                return(user);
            }
            var dict = ConnectionStringParser.ParseConnectionString(header[0]);

            if (!(dict.ContainsKey("User") && dict.ContainsKey("Password")))
            {
                return(null);
            }
            user = new IgorUser(dict["User"], Uri.UnescapeDataString(dict["Password"]));
            var site   = _settingsHelper.GetSites().First();
            var client = _clientHelper.GetWebSiteExtensionsClient(site, user.Name, user.Password);

            try
            {
                var task = client.Settings.ListAsync(CancellationToken.None);
                task.Wait();
                if (task.IsFaulted || task.IsCanceled)
                {
                    return(null);
                }
                HttpRuntime.Cache[header[0]] = user;
                return(user);
            }
            catch (Exception)
            {
                return(null);
            }
        }
示例#4
0
        public async Task <Status> Get()
        {
            var user       = (IgorUser)CurrentUser;
            var extensions = _clientHelper.GetWebSiteExtensionsClient(Name, user.Name, user.Password);
            var jobs       = (await extensions.WebJobs.ListContinuousAsync(null, CancellationToken.None)).ToList();

            try
            {
                Output = new WebJobStatusDto
                {
                    TotalCount   = jobs.Count,
                    RunningCount = jobs.Count(job => job.Status.Equals("Running", StringComparison.OrdinalIgnoreCase))
                };
            }
            catch (Exception ex)
            {
                Trace.TraceError(ex.ToString());
                return(404);
            }
            return(200);
        }