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); } }
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); }
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); } }
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); }