protected void Page_Load(object sender, EventArgs e) { int userResetID; bool isDJ; proxy = new WebsiteClient(); if (Session["userResetID"] != null && Session["isDJ"] != null) { return; } string key = Request.QueryString["key"]; if(key == null || !bool.TryParse(Request.QueryString["DJ"], out isDJ)) { Response.Redirect("~/Error.aspx/?error=Invalid parameters."); return; } Response r; r = proxy.UsePasswordResetKey(key, isDJ, out userResetID); if (userResetID == -1) { Response.Redirect("~/Error.aspx/?error=Invalid key."); return; } Session["userResetID"] = userResetID; Session["isDJ"] = isDJ; }
public void Execute() { var site = new Website() { ComputeMode = ComputeMode.Dedicated, Name = "fluentwebtest38", WebsiteParameters = new WebsiteParameters() { CurrentNumberOfWorkers = 1 } }; site.Config.AppSettings.Add("test1", "test2"); site.Config.HttpLoggingEnabled = true; site.Config.RequestTracingEnabled = true; site.Config.DetailedErrorLoggingEnabled = true; site.Config.ConnectionStrings.Add(new ConnStringInfo() { Name = "test", ConnectionString = "test", Type = "SQLAzure" }); System.Console.WriteLine("Creating website"); System.Console.WriteLine("================"); var client = new WebsiteClient(_subscriptionId, _certificate); client.CreateFromGithub(site, new GitDetails() { Username = "******", Password = "******", RepositoryName = "test-sample-for-azure-deployments" }); }
protected void Page_Load(object sender, EventArgs e) { proxy = new WebsiteClient(); try { upTimeLabel.Text = "Uptime at least: " + TimeSpan.FromMilliseconds(Environment.TickCount).ToString(); } catch (Exception) { upTimeLabel.Text = "Uptime unknown"; } }
public void Execute() { //System.Console.WriteLine("reading website"); //System.Console.WriteLine("================"); //var client = new WebsiteClient(_subscriptionId, _certificate); //var list = client.List(); //list.ForEach(a => System.Console.WriteLine("Website hosts: " + String.Join(", ", a.Hostname.ToArray()))); //var client3 = new WebsiteClient(_subscriptionId, _certificate, "ukwaug"); //System.Console.WriteLine(client3.WebsiteProperties.Config.DetailedErrorLoggingEnabled); //var metrics = client3.GetWebsiteMetricsPerInterval(TimeSpan.FromMinutes(600)); //metrics.ForEach(a => System.Console.WriteLine("Name: {0}, Value: {1} {2}", a.Name, a.Total, a.Units)); //var engine = new WasabiWebRulesEngine("ukwaug", 5); //engine.AddRule(new WasabiWebRule(MetricsConstants.BytesReceived, 10000000, 10000000)); //engine.AddRule(new WasabiWebRule(MetricsConstants.CpuTime, 560000, 5600000)); //var connector = new WebsiteManagementConnector(engine, _subscriptionId, WasabiWebLogicalOperation.Or) // { // ManagementCertificate = _certificate // }; //connector.ScaleUpdate += (state, count) => System.Console.WriteLine("State: {0}, Scale: {1}", state, count); //connector.MonitorAndScale(); var client3 = new WebsiteClient(_subscriptionId, _certificate, "fluentwebtest38"); client3.Stop(); client3.Restart(); var engineAlert = new WasabiWebRulesEngine("fluentwebtest38", 200); engineAlert.AddRule(new WasabiWebRule(MetricsConstants.Http2xx, 3)); var connector2 = new WebsiteManagementConnector(engineAlert, _subscriptionId, WasabiWebLogicalOperation.Or) { ManagementCertificate = _certificate }; //connector2.SubscribeAlerts += // (metric, rule) => // System.Console.WriteLine("Name: {0}, value: {1} {2}", metric.Name, metric.Total, metric.Units); //connector2.MonitorAndAlert(); //connector2.SubscribeAlerts += // (metric, rule) => // System.Console.WriteLine("Name: {0}, value: {1} {2}", metric.Name, metric.Total, metric.Units); //connector2.MonitorAndAlert(); connector2.ScaleUpdate += (state, count) => System.Console.WriteLine("State: {0}, Scale: {1}", state, count); connector2.MonitorAndScale(); }
protected void Page_Load(object sender, EventArgs e) { if (Session["ID"] == null) { Response.Redirect("~/Account/Login2.aspx"); return; } proxy = new WebsiteClient(); AccountNameType.Text = " for " + Session["Username"]; if (((string)Session["Role"]) == "DJ") AccountNameType.Text += " (DJ)"; else AccountNameType.Text += " (singer)"; }
protected virtual void Dispose(bool disposing) { if (_isDisposed) { return; } if (disposing) { WebsiteClient?.Dispose(); EmployerIncentivesApi?.Dispose(); } _isDisposed = true; }
protected void Page_Load(object sender, EventArgs e) { proxy = new WebsiteClient(); bool registrationAllowed; Response r = proxy.IsRegistrationAllowed(out registrationAllowed); if (r.error) { RegistrationLockedMessage.Text = "Registration is currently locked, please try back later."; RegisterSubmit.Enabled = false; return; } if (!registrationAllowed) { RegistrationLockedMessage.Text = "Registration is currently locked, please try back later."; RegisterSubmit.Enabled = false; return; } RegisterSubmit.Enabled = true; }
/// <summary> /// Updates the website based on the scale option /// </summary> public WasabiWebState MonitorAndScale() { _timer.Elapsed += (sender, args) => _stateHistory.Add(DateTime.Now, MonitorAndScale()); EnsureManagementCertificate(); // use the certificate to run the client and command var client = new WebsiteClient(SubscriptionId, ManagementCertificate, _engine.WebsiteName); // get the metrics for the timer time period var metrics = client.GetWebsiteMetricsPerInterval(TimeSpan.FromMinutes(_engine.SamplesPeriodInMins)); if (metrics.Count == 0) { return(WasabiWebState.LeaveUnchanged); } var scalePotential = _engine.Scale(Operation, metrics); // with the scale potential we'll need to increase or decrease the instance count if (scalePotential == WasabiWebState.ScaleDown && client.InstanceCount > 1) { client.InstanceCount -= 1; } if (scalePotential == WasabiWebState.ScaleUp && client.InstanceCount < 10) { client.InstanceCount += 1; } client.Update(); // raise the event now if (ScaleUpdate != null) { ScaleUpdate(scalePotential, client.InstanceCount); } return(scalePotential); }
/// <summary> /// Raises the alert event if any of the metrics have been breached in the time period /// </summary> public void MonitorAndAlert() { EnsureManagementCertificate(); // use the certificate to run the client and command var client = new WebsiteClient(SubscriptionId, ManagementCertificate, _engine.WebsiteName); // get the metrics for the timer time period var metrics = client.GetWebsiteMetricsPerInterval(TimeSpan.FromMinutes(_engine.SamplesPeriodInMins)); // enumerate the metrics piece by piece foreach (var metric in metrics) { // check for the metric to ensure it's in the collection otherwise discard it if (_engine[metric.Name] == null) { continue; } var rule = _engine[metric.Name]; if ((metric.Total > rule.IsGreaterThan || metric.Total < rule.IsLessThan) && SubscribeAlerts != null) { SubscribeAlerts(metric, rule); } } }
protected void Page_Load(object sender, EventArgs e) { proxy = new WebsiteClient(); }