private void SetStatus() { try { var inMaintenance = CommonIISHelper.GetArrRuleEnabled("IsInMaintenance"); if (inMaintenance == null || !inMaintenance.HasValue) { throw new Exception("Error retrieving 'IsInMaintenance' ArrRule."); } else if (inMaintenance.Value) { // this instance is in maintenance mode this.Status = AzurePluginStatus.Warning; this.StatusMessage = "Maintenance"; } else { this.Status = AzurePluginStatus.Healthy; this.StatusMessage = "Running"; } } catch (Exception ex) { this.Status = AzurePluginStatus.Error; this.StatusMessage = ex.Message; } }
/// <summary> /// Handles changes made to the additional configuration /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void AdditionalConfiguration_Changed(object sender, ConfigurationItemChangedEventArgs e) { Trace.TraceInformation(TRACESOURCE + ":AdditionalConfiguration: " + e.Name + " (" + e.ChangeType.ToString() + ")" + " New = " + e.NewValue ?? "NULL" + " | " + "Old = " + e.OldValue ?? "NULL"); if (e.Name == "IsInMaintenance") { // this instance is told to change it's maintenance mode var stringValue = (e.ChangeType == ChangeType.Added | e.ChangeType == ChangeType.Modified) ? e.NewValue : e.OldValue; bool newValue; if (bool.TryParse(stringValue, out newValue)) { // enable or disable the Routing rule to the maintenance page CommonIISHelper.ChangeArrRuleEnabled("IsInMaintenance", newValue); } } SetStatus(); }