/// <summary> /// Click event. /// </summary> /// <param name="sender">The Sender.</param> /// <param name="e">The EventArgs.</param> protected void ButtonRemoveService_Click(object sender, EventArgs e) { using (SPLongOperation operation = new SPLongOperation(this)) { operation.LeadingHTML = HttpContext.GetGlobalResourceObject("ClubCloud.Service.ServiceAdminResources", "ManageServiceRemoveOperationLeadingHtml", CultureInfo.CurrentCulture).ToString(); operation.TrailingHTML = HttpContext.GetGlobalResourceObject("ClubCloud.Service.ServiceAdminResources", "ManageServiceRemoveOperationTrailingHtml", CultureInfo.CurrentCulture).ToString(); operation.Begin(); ClubCloudService.RemoveService(); operation.End("/_admin/ClubCloud.Service/ManageService.aspx"); } }
/// <summary> /// This method gets invoked when the command is called /// </summary> protected override void InternalProcessRecord() { // Validate a farm exists SPFarm farm = SPFarm.Local; if (farm == null) { this.ThrowTerminatingError(new InvalidOperationException("SharePoint server farm not found."), ErrorCategory.ResourceUnavailable, this); } SPServer server = SPServer.Local; if (server == null) { this.ThrowTerminatingError(new InvalidOperationException("SharePoint local server not found."), ErrorCategory.ResourceUnavailable, this); } if (this.ShouldProcess(SPFarm.Local.Name)) { // Remove the service ClubCloudService.RemoveService(); } }