/// <summary> /// Click event. /// </summary> /// <param name="sender">The Sender.</param> /// <param name="e">The EventArgs.</param> protected void ButtonTrigger_Click(object sender, EventArgs e) { // Validate this.Validate(); if (!this.IsValid) { return; } // We are valid // Register the database using (SPLongOperation operation = new SPLongOperation(this)) { operation.LeadingHTML = HttpContext.GetGlobalResourceObject("ClubCloud.Service.ServiceAdminResources", "UsersSettingsCreateOperationLeadingHtml", CultureInfo.CurrentCulture).ToString(); operation.TrailingHTML = HttpContext.GetGlobalResourceObject("ClubCloud.Service.ServiceAdminResources", "UsersSettingsCreateOperationTrailingHtml", CultureInfo.CurrentCulture).ToString(); operation.Begin(); try { ServiceClient.TriggerMetaData("12073385", true); } catch { }; operation.End(string.Format(CultureInfo.InvariantCulture, "/_admin/ClubCloud.Service/ManageMetaData.aspx?id={0}", SPHttpUtility.UrlKeyValueEncode(this.ServiceApplication.Id))); } }
void BtnGetMailClick(object sender, EventArgs e) { using (var longOperation = new SPLongOperation(Page)) { longOperation.LeadingHTML = SPSResources.GetResourceString("SPS_FetchMail_Message"); longOperation.TrailingHTML = SPSResources.GetResourceString("SPS_FetchMail_Message2"); longOperation.Begin(); int port; Int32.TryParse(_mailPort, out port); var fetchMail = new FetchMail(_login, _password, _mailServer, port, _ssl, _listGuid); fetchMail.GetMessages(); _error = fetchMail.GetErrorMessage(); if (!string.IsNullOrEmpty(_error)) { SPUtility.TransferToErrorPage(_error); } else { longOperation.End(Page.Request.Url.ToString()); } } }
/// <summary> /// Click event. /// </summary> /// <param name="sender">The Sender.</param> /// <param name="e">The EventArgs.</param> protected void ButtonOk_Click(object sender, EventArgs e) { // Validate this.Validate(); if (!this.IsValid) { return; } // We are valid // Register the database using (SPLongOperation operation = new SPLongOperation(this)) { operation.LeadingHTML = HttpContext.GetGlobalResourceObject("ClubCloud.Service.ServiceAdminResources", "UsersSettingsCreateOperationLeadingHtml", CultureInfo.CurrentCulture).ToString(); operation.TrailingHTML = HttpContext.GetGlobalResourceObject("ClubCloud.Service.ServiceAdminResources", "UsersSettingsCreateOperationTrailingHtml", CultureInfo.CurrentCulture).ToString(); operation.Begin(); //TODO Save string nummer = tbx_bondsnummer.Text.Trim(); string voornaam = tbx_voornaam.Text.Trim(); string achternaam = tbx_achternaam.Text.Trim(); string email = tbx_email.Text.Trim(); string vereniging = ddl_vereniging.SelectedItem.Value; ClubCloud.Model.ClubCloud_Gebruiker gebruiker = new Model.ClubCloud_Gebruiker { Bondsnummer = nummer, Volledigenaam = voornaam + achternaam, Voornaam = voornaam, Achternaam = achternaam, EmailKNLTB = email, VerenigingId = Guid.Parse(vereniging) }; ServiceClient.CreateGebruiker(gebruiker); operation.End(string.Format(CultureInfo.InvariantCulture, "/_admin/ClubCloud.Service/ManageUsers.aspx?id={0}", SPHttpUtility.UrlKeyValueEncode(this.ServiceApplication.Id))); } }
/// <summary> /// TODO: Add comment /// </summary> /// <param name="sender">Sender of the event</param> /// <param name="e">Arguments of the event</param> private void BtnOk_Click(object sender, EventArgs e) { string strPackageFileName = Path.GetFileName(fup_wsp.PostedFile.FileName); string strPackageServerFileName = strTempPath + strPackageFileName; //lblErrorMessage.ForeColor = Color.Red; try { //Checking if the file selected... if (fup_wsp.FileName == "") { //lblErrorMessage.Text = "Please select the solution file"; return; } //Checking if the package already existed in the Farm Solutions. if (SPFarm.Local.Solutions[strPackageFileName] != null) { //lblErrorMessage.Text = "Please retract and remove the solution before uploading it"; return; } using (SPLongOperation operation = new SPLongOperation(this.Page)) { operation.LeadingHTML = "Uploading the solution package"; operation.TrailingHTML = "Adding " + strPackageFileName + " to the solution store.."; operation.Begin(); //Deleting the file if its already existed. if (File.Exists(strPackageServerFileName)) { File.Delete(strPackageServerFileName); } //Saving a copy of the Package. fup_wsp.PostedFile.SaveAs(strPackageServerFileName); //Adding the Package to the Store. SPFarm.Local.Solutions.Add(strPackageServerFileName); //Thread.Sleep(0x1770); operation.End(SPContext.Current.Site.Url + "/_admin/operations.aspx"); } } catch (Exception ex) { throw new SPException(ex.Message); } }
/// <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"); } }
protected void ButtonSave_Click(object sender, EventArgs e) { using (SPLongOperation longOperation = new SPLongOperation(this.Page)) { longOperation.LeadingHTML = "请稍等,这不会花费很长的时间..."; longOperation.TrailingHTML = "请稍等,这不会花费很长的时间..."; longOperation.Begin(); var issue = GetIssue(); issue["是否追责"] = true; issue.Update(); var blaming = CreateBlaming(); var redirectURL = string.Format("{0}listform.aspx?ListId={1}&PageType=4&ID={2}", SPUtility.GetWebLayoutsFolder(blaming.ParentList.ParentWeb), blaming.ParentList.ID, blaming.ID); longOperation.End(redirectURL); } }
protected void EndOperation(SPLongOperation operation, string result) { HttpContext context = HttpContext.Current; if (context.Request.QueryString["IsDlg"] != null) { context.Response.Write("<script type='text/javascript'>alert('" + result + "'); window.frameElement.commitPopup();</script>"); context.Response.Flush(); context.Response.End(); } else { string url = SPContext.Current.Web.Url; operation.End(url, SPRedirectFlags.CheckUrl, context, string.Empty); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { using (SPLongOperation longOperation = new SPLongOperation(this.Page)) { longOperation.LeadingHTML = "Pasting items from your work box clipboard"; longOperation.TrailingHTML = "If you are pasting a lot of items this might take some time."; longOperation.Begin(); String folderPath = Request.QueryString["RootFolder"]; if (String.IsNullOrEmpty(folderPath)) { folderPath = ""; } String docLibraryFolderPath = WorkBox.Web.ServerRelativeUrl + "/" + WorkBox.DocumentLibrary.RootFolder.Url; WBLogging.Generic.Unexpected("Root folder was: " + folderPath + " in : " + WorkBox.DocumentLibrary.RootFolder.Url); WBLogging.Generic.Unexpected("docLibraryFolderPath = " + docLibraryFolderPath); folderPath = folderPath.Replace(docLibraryFolderPath, ""); WBLogging.Generic.Unexpected("Now using folder path: " + folderPath); WBUser user = new WBUser(WorkBox); String clipboardAction = user.PasteClipboard(WorkBox, folderPath); /* * String justReturnOK = "Pasted items are still on clipboard to be copied again."; * if (clipboardAction == WBUser.CLIPBOARD_ACTION__CUT) * { * justReturnOK = "Pasted items removed from original location and clipboard."; * } */ string okPageUrl = "WorkBoxFramework/GenericOKPage.aspx"; string queryString = "justRefreshOK=True"; longOperation.End(okPageUrl, SPRedirectFlags.RelativeToLayoutsPage, Context, queryString); } } }
protected void ButtonGebruikers_Click(object sender, EventArgs e) { // Validate this.Validate(); if (!this.IsValid) { return; } // We are valid // Register the database using (SPLongOperation operation = new SPLongOperation(this)) { operation.LeadingHTML = HttpContext.GetGlobalResourceObject("ClubCloud.Service.ServiceAdminResources", "UsersSettingsCreateOperationLeadingHtml", CultureInfo.CurrentCulture).ToString(); operation.TrailingHTML = HttpContext.GetGlobalResourceObject("ClubCloud.Service.ServiceAdminResources", "UsersSettingsCreateOperationTrailingHtml", CultureInfo.CurrentCulture).ToString(); operation.Begin(); string nummer = tbx_verenigingsnummer.Text; if (!string.IsNullOrWhiteSpace(nummer)) { int pageNum = 1; bool moreRecords = true; while (moreRecords) { try { moreRecords = ServiceClient.GebruikersUpdate("12073385", nummer, pageNum, true); pageNum++; } catch (Exception) { moreRecords = true; } } try { ClubCloud_Vereniging vereniging = ServiceClient.GetVerenigingByNummer("12073385", nummer, true); ServiceClient.LidmaatschappenUpdate("12073385", vereniging.Id, true); } catch { } } operation.End(string.Format(CultureInfo.InvariantCulture, "/_admin/ClubCloud.Service/ManageMetaData.aspx?id={0}", SPHttpUtility.UrlKeyValueEncode(this.ServiceApplication.Id))); } }
/// <summary> /// Click event. /// </summary> /// <param name="sender">The Sender.</param> /// <param name="e">The EventArgs.</param> protected void ButtonInstallServiceInstances_Click(object sender, EventArgs e) { using (SPLongOperation operation = new SPLongOperation(this)) { operation.LeadingHTML = HttpContext.GetGlobalResourceObject("ClubCloud.Service.ServiceAdminResources", "ManageServiceInstallServiceInstancesOperationLeadingHtml", CultureInfo.CurrentCulture).ToString(); operation.TrailingHTML = HttpContext.GetGlobalResourceObject("ClubCloud.Service.ServiceAdminResources", "ManageServiceInstallServiceInstancesOperationTrailingHtml", CultureInfo.CurrentCulture).ToString(); operation.Begin(); // Get the service ClubCloudService service = ClubCloudService.GetOrCreateService(); // Create the service instances ClubCloudServiceInstance.CreateServiceInstances(service); operation.End("/_admin/ClubCloud.Service/ManageService.aspx"); } }
/// <summary> /// Click event. /// </summary> /// <param name="sender">The Sender.</param> /// <param name="e">The EventArgs.</param> protected void ButtonInstallServiceInstances_Click(object sender, EventArgs e) { using (SPLongOperation operation = new SPLongOperation(this)) { operation.LeadingHTML = HttpContext.GetGlobalResourceObject("NVRConfigService.ServiceAdminResources", "ManageServiceInstallServiceInstancesOperationLeadingHtml", CultureInfo.CurrentCulture).ToString(); operation.TrailingHTML = HttpContext.GetGlobalResourceObject("NVRConfigService.ServiceAdminResources", "ManageServiceInstallServiceInstancesOperationTrailingHtml", CultureInfo.CurrentCulture).ToString(); operation.Begin(); // Get the service NVRConfigService service = NVRConfigService.GetOrCreateService(); // Create the service instances ConfigServiceInstance.CreateServiceInstances(service); operation.End("/_admin/NVRConfigService/ManageService.aspx"); } }
/// <summary> /// Click event. /// </summary> /// <param name="sender">The Sender.</param> /// <param name="e">The EventArgs.</param> protected void ButtonInstallService_Click(object sender, EventArgs e) { using (SPLongOperation operation = new SPLongOperation(this)) { operation.LeadingHTML = HttpContext.GetGlobalResourceObject("NVRConfigService.ServiceAdminResources", "ManageServiceInstallOperationLeadingHtml", CultureInfo.CurrentCulture).ToString(); operation.TrailingHTML = HttpContext.GetGlobalResourceObject("NVRConfigService.ServiceAdminResources", "ManageServiceInstallOperationTrailingHtml", CultureInfo.CurrentCulture).ToString(); operation.Begin(); // Install the service NVRConfigService service = NVRConfigService.GetOrCreateService(); // Install the service instances but do not start (provision) them (let the admin do this on the services on server screen). ConfigServiceInstance.CreateServiceInstances(service); // Install the service proxy ConfigServiceProxy.GetOrCreateServiceProxy(); operation.End("/_admin/NVRConfigService/ManageService.aspx"); } }
/// <summary> /// Click event. /// </summary> /// <param name="sender">The Sender.</param> /// <param name="e">The EventArgs.</param> protected void ButtonInstallService_Click(object sender, EventArgs e) { using (SPLongOperation operation = new SPLongOperation(this)) { operation.LeadingHTML = HttpContext.GetGlobalResourceObject("ClubCloud.Service.ServiceAdminResources", "ManageServiceInstallOperationLeadingHtml", CultureInfo.CurrentCulture).ToString(); operation.TrailingHTML = HttpContext.GetGlobalResourceObject("ClubCloud.Service.ServiceAdminResources", "ManageServiceInstallOperationTrailingHtml", CultureInfo.CurrentCulture).ToString(); operation.Begin(); // Install the service ClubCloudService service = ClubCloudService.GetOrCreateService(); // Install the service instances but do not start (provision) them (let the admin do this on the services on server screen). ClubCloudServiceInstance.CreateServiceInstances(service); // Install the service proxy ClubCloudServiceProxy.GetOrCreateServiceProxy(); operation.End("/_admin/ClubCloud.Service/ManageService.aspx"); } }
protected void EndOperation(SPLongOperation operation) { try { HttpContext context = HttpContext.Current; if (context.Request.QueryString["IsDlg"] != null) { context.Response.Write("<script type='text/javascript'>window.frameElement.commitPopup();</script>"); context.Response.Flush(); context.Response.End(); } else { string url = SPContext.Current.Web.Url; operation.End(url, SPRedirectFlags.CheckUrl, context, string.Empty); } } catch (ThreadAbortException) { /* Thrown when redirected */ } catch (Exception ex) { SPUtility.TransferToErrorPage(ex.ToString()); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Request.QueryString["selectedItemsIDsString"] != null && Request.QueryString["selectedListGUID"] != null) { String clipboardAction = Request.QueryString["clipboardAction"]; if (String.IsNullOrEmpty(clipboardAction)) { clipboardAction = WBUser.CLIPBOARD_ACTION__COPY; } using (SPLongOperation longOperation = new SPLongOperation(this.Page)) { string justReturnOK = "Copied to clipboard"; longOperation.LeadingHTML = "Copying details to the clipboard"; if (clipboardAction == WBUser.CLIPBOARD_ACTION__CUT) { justReturnOK = "Cut to clipboard"; longOperation.LeadingHTML = "Cutting details to the clipboard"; } longOperation.TrailingHTML = ""; longOperation.Begin(); string selectedListGUID = Request.QueryString["selectedListGUID"]; string[] selectedItemsIDs = Request.QueryString["selectedItemsIDsString"].ToString().Split('|'); WBUtils.logMessage("The list GUID was: " + selectedListGUID); selectedListGUID = selectedListGUID.Substring(1, selectedListGUID.Length - 2).ToLower(); // Guid sourceListGuid = new Guid(selectedListGUID); //ListGUID.Value = sourceListGuid.ToString(); //ItemID.Value = selectedItemsIDs[1].ToString(); //WBUtils.logMessage("The ListGUID was: " + ListGUID.Value); //WBUtils.logMessage("The ItemID was: " + ItemID.Value); // SPDocumentLibrary sourceDocLib = (SPDocumentLibrary)WorkBox.Web.Lists[sourceListGuid]; WBUser user = new WBUser(WorkBox); WorkBox.Web.AllowUnsafeUpdates = true; String error = user.AddToClipboard(clipboardAction, WorkBox, selectedItemsIDs, false); WorkBox.Web.AllowUnsafeUpdates = false; string okPageUrl = "WorkBoxFramework/GenericOKPage.aspx"; string queryString = "justReturnOK=" + justReturnOK; if (!String.IsNullOrEmpty(error)) { queryString = "justReturnError=" + error; } longOperation.End(okPageUrl, SPRedirectFlags.RelativeToLayoutsPage, Context, queryString); } RenderClipboard(); } else { ItemsOnClipboard.Text = "There was an error with the passed through values"; } closeButton.Focus(); } }
private void PostFile() { bool thumbUploaded = false, posterUploaded = false; string destFolder = mediaConfig.TempLocationFolder; var originFileInfo = new FileInfo(FileToUpload.PostedFile.FileName); try { using (SPLongOperation longOperation = new SPLongOperation(this.Page)) { SPWeb web = SPContext.Current.Web; MediaAsset asset = MediaAsset.FromFile(originFileInfo, SPContext.Current.Web.Url, mediaConfig); longOperation.Begin(); asset.FileSize = FileToUpload.PostedFile.ContentLength; var validator = ValidatorFactory.GetValidator(asset.MediaType, mediaConfig); validator.ValidateFileSize(asset.FileSize); IAssetStorageManager storage = AssetStorageFactory.GetStorageManager("Media", web.Url); string newFileUniqueNameWithoutExtension = Guid.NewGuid().ToString(); string newFileUniqueName = String.Concat(newFileUniqueNameWithoutExtension, originFileInfo.Extension); //upload optional images if (ThumbnailInput.PostedFile != null && !String.IsNullOrEmpty(ThumbnailInput.PostedFile.FileName)) { string thumbFileName = MediaConfig.GetThumbnailFileName(newFileUniqueNameWithoutExtension, ThumbnailInput.PostedFile.FileName); asset.Thumbnail = storage.Save(thumbFileName, ThumbnailInput.PostedFile.InputStream); thumbUploaded = true; } if (PosterInput.PostedFile != null && !String.IsNullOrEmpty(PosterInput.PostedFile.FileName)) { string posterFileName = MediaConfig.GetPosterFileName(newFileUniqueNameWithoutExtension, PosterInput.PostedFile.FileName); asset.Poster = storage.Save(posterFileName, PosterInput.PostedFile.InputStream); posterUploaded = true; } //upload principal file if (asset.MediaType == MediaType.Image) { if (!thumbUploaded)//no thumb image was uploaded { //generate thumb & save ImageProcessor imgProc = new ImageProcessor(); using (MemoryStream thumbStream = new MemoryStream()) { string thumbFileName = MediaConfig.GetThumbnailFileName(newFileUniqueNameWithoutExtension); imgProc.GenerateThumbnail(FileToUpload.PostedFile.InputStream, thumbStream); thumbStream.Position = 0; asset.Thumbnail = storage.Save(thumbFileName, thumbStream); } FileToUpload.PostedFile.InputStream.Position = 0; } //save to final location asset.Location = storage.Save(newFileUniqueName, FileToUpload.PostedFile.InputStream); asset.Status = ProcessingStatus.Success; } else { var tempFileInfo = new FileInfo(Path.Combine(destFolder, newFileUniqueName)); SPSecurity.RunWithElevatedPrivileges(delegate() { //save to file system FileToUpload.PostedFile.SaveAs(tempFileInfo.FullName); asset.TempLocation = tempFileInfo.FullName; asset.Duration = MediaLengthCalculator.GetMediaLength(tempFileInfo); }); try { validator.ValidateLength(asset.Duration); } catch (MediaTooLargeException) { FileUtils.Delete(tempFileInfo); throw; } if (asset.MediaType == MediaType.Audio) { asset.Location = storage.Save(newFileUniqueName, FileToUpload.PostedFile.InputStream); FileUtils.Delete(tempFileInfo); asset.TempLocation = String.Empty; if (!thumbUploaded)//no thumb image was uploaded, upload default { string thumbnailFileName = MediaConfig.GetThumbnailFileName(newFileUniqueNameWithoutExtension, mediaConfig.DefaultAudioThumbnail); SPFile thumbImg = web.GetFile(mediaConfig.DefaultAudioThumbnail); asset.Thumbnail = storage.Save(thumbnailFileName, thumbImg.OpenBinaryStream()); } if (!posterUploaded)//no poster image was uploaded, upload default { string posterFileName = MediaConfig.GetPosterFileName(newFileUniqueNameWithoutExtension, mediaConfig.DefaultAudioPoster); SPFile thumbImg = web.GetFile(web.Url + mediaConfig.DefaultAudioPoster); asset.Poster = storage.Save(posterFileName, thumbImg.OpenBinaryStream()); } asset.Status = ProcessingStatus.Success; } else if (asset.MediaType == MediaType.Video && !mediaConfig.EncodeVideoFlag && thumbUploaded && posterUploaded) { //video doesn't need encoding, nor generation of thumb and poster images => upload file and set status as processed. asset.Location = storage.Save(newFileUniqueName, FileToUpload.PostedFile.InputStream); FileUtils.Delete(tempFileInfo); asset.TempLocation = String.Empty; asset.Status = ProcessingStatus.Success; } } var list = web.Lists[mediaConfig.MediaAssetsListName]; int id; string contentTypeId; mediaRepository.Insert(list, asset, out id, out contentTypeId); string url = String.Format("{0}?ID={1}&ContentTypeId={2}", list.DefaultEditFormUrl, id, contentTypeId); longOperation.End(url); } } catch (ThreadAbortException) { /* Thrown when redirected */} catch (Exception ex) { logger.LogToOperations(ex, LogCategories.Media, EventSeverity.Error, "Error uploading media '{0}'", FileToUpload.PostedFile.FileName); SPUtility.TransferToErrorPage(ex.ToString()); } }
/// <summary> /// Click event. /// </summary> /// <param name="sender">The Sender.</param> /// <param name="e">The EventArgs.</param> protected void ButtonOk_Click(object sender, EventArgs e) { // Validate this.Validate(); if (!this.IsValid) { return; } // We are valid // Register the database using (SPLongOperation operation = new SPLongOperation(this)) { operation.LeadingHTML = HttpContext.GetGlobalResourceObject("ClubCloud.Service.ServiceAdminResources", "UsersSettingsCreateOperationLeadingHtml", CultureInfo.CurrentCulture).ToString(); operation.TrailingHTML = HttpContext.GetGlobalResourceObject("ClubCloud.Service.ServiceAdminResources", "UsersSettingsCreateOperationTrailingHtml", CultureInfo.CurrentCulture).ToString(); operation.Begin(); var name = fup_package.PostedFile.FileName.Split('\\').Last(); string[] parts = name.Split('_'); string applicationName = parts[0]; string verion = parts[1]; string cpu = parts[2]; ClubCloud.Model.ApplicationInfo applicationInfo = ServiceClient.GetApplicationInfoByName(applicationName); if (applicationInfo == null) { applicationInfo = new Model.ApplicationInfo { ApplicationName = applicationName, MajorVersion = verion, CreationDate = DateTime.Now, OperationDate = DateTime.Now, Status = ApplicationStatus.Published }; } else { applicationInfo.MajorVersion = verion; applicationInfo.OperationDate = DateTime.Now; } Stream uploadstream = fup_package.PostedFile.InputStream; fup_package.PostedFile.InputStream.Seek(0, SeekOrigin.Begin); byte[] fileData = new byte[fup_package.PostedFile.ContentLength]; uploadstream.Read(fileData, 0, fup_package.PostedFile.ContentLength); byte[] package = null; byte[] certificate = null; byte[] symbols = null; ApplicationVersion applicationVersion = new ApplicationVersion(); ApplicationProcessorArchitecture applicationProcessorArchitecture = new ApplicationProcessorArchitecture(); using (ZipArchive archive = new ZipArchive(uploadstream, ZipArchiveMode.Read)) { foreach (ZipArchiveEntry entry in archive.Entries) { byte[] buffer = null; using (BinaryReader reader = new BinaryReader(entry.Open())) { buffer = reader.ReadBytes((int)entry.Length); } if (entry.FullName.EndsWith("appx")) { package = buffer; PackageAnalyzeResult result = PackageAnalyzer.GetPackageInfo(entry.Open()); applicationVersion = result.ApplicationVersion; applicationProcessorArchitecture = result.ApplicationProcessorArchitecture; } if (entry.FullName.EndsWith("cer")) { certificate = buffer; } if (entry.FullName.EndsWith("appxsym")) { symbols = buffer; } } } applicationProcessorArchitecture.Certificate = certificate; applicationProcessorArchitecture.Package = package; applicationProcessorArchitecture.Symbols = symbols; //applicationVersion.ApplicationProcessorArchitectures.Add(applicationProcessorArchitecture); //applicationInfo.ApplicationVersions.Add(applicationVersion); applicationInfo = ServiceClient.SetApplicationInfo(applicationInfo); applicationVersion.ApplicationInfoId = applicationInfo.Id; applicationVersion = ServiceClient.SetApplicationVersion(applicationInfo.Id, applicationVersion); applicationProcessorArchitecture.ApplicationVersionId = applicationVersion.Id; applicationProcessorArchitecture = ServiceClient.SetApplicationProcessorArchitecture(applicationVersion.Id, applicationProcessorArchitecture); operation.End("/_admin/ClubCloud.Service/ManagePackage.aspx");//string.Format(CultureInfo.InvariantCulture, "/_admin/ClubCloud.Service/ManageApplication.aspx?id={0}", SPHttpUtility.UrlKeyValueEncode(this.ServiceApplication.Id))); } }
protected void BtnSave_Click(object sender, EventArgs e) { using (SPLongOperation longOperation = new SPLongOperation(this.Page)) { longOperation.LeadingHTML = "Working on it..."; longOperation.TrailingHTML = "Working on it..."; longOperation.Begin(); if (!string.IsNullOrEmpty(JsonString.Value)) { var pageLayouts = JsonHelper.JsonDeserialize<IEnumerable<FabricPageLayout>>(JsonString.Value); Set(SPControlMode.New, pageLayouts.FirstOrDefault()); //Set(SPControlMode.Edit, pageLayouts.FirstOrDefault()); //Set(SPControlMode.Display, pageLayouts.FirstOrDefault()); } var redirectURL = HttpContext.Current.Request.Url.AbsoluteUri; longOperation.End(redirectURL); } }
protected void Page_Load(object sender, EventArgs e) { string localID = Request.QueryString["LocalID"]; if (localID == null || localID == "") { localID = Request.QueryString["IASClientID"]; } if (localID == null || localID == "") { ErrorMessage.Text = "Could not find the LocalID on the request parameters."; return; } bool justFind = false; string justFindString = Request.QueryString["JustFind"]; if (justFindString != null && justFindString != "") { WBUtils.logMessage("Testing JustFind = " + justFindString); justFind = true.ToString().ToLower().Equals(justFindString.ToLower()); WBUtils.logMessage("Testing justFind = " + justFind); WBUtils.logMessage("true.ToString() = " + true.ToString()); } else { WBUtils.logMessage("No JustFind query parameter"); } using (WBCollection collection = new WBCollection(SPContext.Current)) { WorkBox workBox = collection.FindByLocalID(localID); if (workBox == null) { WBUtils.logMessage(" workBox was NULL"); } if (workBox == null && justFind) { string html = "<h3>There is no work box with ID: " + localID + "</h3>\n"; html += "<a href=\"routing.aspx?LocalID=" + localID + "&justFind=false\">Click here to create a new work box with this ID</a>\n"; DoesNotExistYet.Text = html; } else { using (SPLongOperation longOperation = new SPLongOperation(this.Page)) { if (workBox == null) { longOperation.LeadingHTML = "No documents found: creating new work box."; longOperation.TrailingHTML = "This service user doesn't yet have a work box so it is being created."; } else { longOperation.LeadingHTML = "Found service user's work box."; longOperation.TrailingHTML = "Please wait while the work box is opened."; } longOperation.Begin(); collection.Site.AllowUnsafeUpdates = true; collection.Web.AllowUnsafeUpdates = true; if (workBox == null) { workBox = collection.RequestNewWorkBox("", localID); } if (workBox.HasBeenCreated) { workBox.Web.AllowUnsafeUpdates = true; } if (!workBox.HasBeenOpened) { workBox.Open(); } string workBoxUrl = workBox.Url; workBox.Web.AllowUnsafeUpdates = false; collection.Web.AllowUnsafeUpdates = false; collection.Site.AllowUnsafeUpdates = false; workBox.Dispose(); longOperation.End(workBoxUrl, SPRedirectFlags.Static, Context, ""); } } } }
private void onSave(object sender, EventArgs e) { Page.Validate(); if (Page.IsValid) { try { SaveButton btnSave = sender as SaveButton; StringBuilder sbErrors = new StringBuilder(); SPLongOperation longOp = new SPLongOperation(this.Page); longOp.LeadingHTML = "Please wait while the new case data is saved."; longOp.Begin(); try { //SaveButton.SaveItem(btnSave.ItemContext, false, ""); bool isSaveSuccessful = false; isSaveSuccessful = SaveButton.SaveItem(btnSave.ItemContext, false, ""); if (isSaveSuccessful == false) { sbErrors.Append("An error occurred."); } } catch (SPException spex) { sbErrors.Append("An error occurred: " + spex.Message); } catch (Exception ex) { sbErrors.Append("An error occurred: " + ex.Message); } if (SPContext.Current.IsPopUI) { if (sbErrors.Length > 0) { sbErrors.Append("<br/><br/>Please <a href='#' onclick='history.go(-1);return false;'>go back</a> and try again."); longOp.EndScript("document.getElementById('s4-simple-card-content').innerHTML = \"<br/>Errors have occurred during the submission. Details: <br/>" + sbErrors.ToString() + " \";"); } else { longOp.EndScript("try { window.frameElement.commitPopup(); } catch (e) {}"); } } else { if (sbErrors.Length > 0) { SPUtility.TransferToErrorPage(sbErrors.ToString()); } else { longOp.End(SPContext.Current.Web.Url, SPRedirectFlags.DoNotEndResponse | SPRedirectFlags.Trusted, HttpContext.Current, ""); } } } catch (ThreadAbortException) { /* Thrown when redirected */ } catch (Exception ex) { SPUtility.TransferToErrorPage(ex.ToString()); } } }
/// <summary> /// Click event. /// </summary> /// <param name="sender">The Sender.</param> /// <param name="e">The EventArgs.</param> protected void ButtonVerenigingen_Click(object sender, EventArgs e) { // Validate this.Validate(); if (!this.IsValid) { return; } // We are valid // Register the database using (SPLongOperation operation = new SPLongOperation(this)) { operation.LeadingHTML = HttpContext.GetGlobalResourceObject("ClubCloud.Service.ServiceAdminResources", "UsersSettingsCreateOperationLeadingHtml", CultureInfo.CurrentCulture).ToString(); operation.TrailingHTML = HttpContext.GetGlobalResourceObject("ClubCloud.Service.ServiceAdminResources", "UsersSettingsCreateOperationTrailingHtml", CultureInfo.CurrentCulture).ToString(); operation.Begin(); int pageNum = 1; bool moreRecords = true; while (moreRecords) { try { moreRecords = ServiceClient.AccommodatiesUpdate("12073385", pageNum, true); pageNum++; } catch (Exception) { moreRecords = true; } } try { } catch { } pageNum = 1; moreRecords = true; while (moreRecords) { try { moreRecords = ServiceClient.VerenigingenUpdate("12073385", pageNum, true); pageNum++; } catch (Exception) { moreRecords = true; } } try { ServiceClient.BestuursOrganenUpdate("12073385", false); } catch { } operation.End(string.Format(CultureInfo.InvariantCulture, "/_admin/ClubCloud.Service/ManageMetaData.aspx?id={0}", SPHttpUtility.UrlKeyValueEncode(this.ServiceApplication.Id))); } }
/// <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("NVRConfigService.ServiceAdminResources", "ManageServiceRemoveOperationLeadingHtml", CultureInfo.CurrentCulture).ToString(); operation.TrailingHTML = HttpContext.GetGlobalResourceObject("NVRConfigService.ServiceAdminResources", "ManageServiceRemoveOperationTrailingHtml", CultureInfo.CurrentCulture).ToString(); operation.Begin(); NVRConfigService.RemoveService(); operation.End("/_admin/NVRConfigService/ManageService.aspx"); } }
// Uncomment the method below to handle the event raised after a feature has been activated. public override void FeatureActivated(SPFeatureReceiverProperties properties) { SPSite osite = ((SPSite)properties.Feature.Parent); SPSecurity.RunWithElevatedPrivileges(delegate() { try { using (SPSite elevatedSite = new SPSite(osite.ID)) { var web = elevatedSite.RootWeb; RemoveEventReceiverFromList(web); SPList list = web.GetList(web.ServerRelativeUrl + "/_catalogs/masterpage/"); bool oldWebAllowUnsafe = web.AllowUnsafeUpdates; web.AllowUnsafeUpdates = true; foreach (SPListItem item in list.Items) { if (item.File.CheckedOutByUser != null) { Page page = HttpContext.Current.Handler as Page; SPLongOperation operation = new SPLongOperation(page); operation.Begin(); try { operation.End("javascript:if(!alert('Cannot activate the feature of tracking, master page: " + Convert.ToString(item["Name"]) + " is checked out by user: "******" (" + item.File.CheckedOutByUser.LoginName + ").')) document.location = window.location.href.substring(0, window.location.href.indexOf('_layouts')) + '_catalogs/masterpage/Forms/AllItems.aspx';", SPRedirectFlags.Static, HttpContext.Current, null); } catch (ThreadAbortException ex) { Logger.WriteLog(Logger.Category.Information, "Piwik Master page is checked out: " + Convert.ToString(item["Name"]), ex.Message); } catch (Exception ex) { throw ex; } } } foreach (SPListItem item in list.Items) { if (Convert.ToString(item["Name"]).ToLower().EndsWith(".master")) { System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding(); EventDisabler eventDisabler = new EventDisabler(); SPFile file = item.File; byte[] byteArrayOfFile = file.OpenBinary(); if (byteArrayOfFile.Length > 0) { string strFileContentsBefore = enc.GetString(byteArrayOfFile); //check if javascript exists PropertyBagOperations pbos = new PropertyBagOperations(); string trackerJSScriptUrl = pbos.GetPropertyValueFromListByKey("piwik_trackerjsscripturl"); if (!strFileContentsBefore.ToLower().Contains(trackerJSScriptUrl.ToLower())) { if (item.File.CheckOutType == SPFile.SPCheckOutType.None) { SPFileLevel oldLevel = item.File.Level; string newStr = AddJSRefToFile(strFileContentsBefore, trackerJSScriptUrl); byte[] byteArrayFileContentsAfter = null; if (!newStr.Equals("")) { //after binary to string there are ??? chars at the first line, this is the action to replace it: if (newStr.Substring(0, 3).Equals("???")) { newStr = newStr.Replace("???", ""); } byteArrayFileContentsAfter = enc.GetBytes(newStr); eventDisabler.DisableEvents(); } if (list.ForceCheckout) { item.File.CheckOut(); } item.File.SaveBinary(byteArrayFileContentsAfter); item.File.Update(); if (list.ForceCheckout) { if (item.File.Level == SPFileLevel.Checkout) { if (oldLevel == SPFileLevel.Published) { item.File.CheckIn("", SPCheckinType.MajorCheckIn); } else { item.File.CheckIn("", SPCheckinType.MinorCheckIn); } } } try { if (oldLevel == SPFileLevel.Published) { if (item.File.DocumentLibrary.EnableModeration) { item.File.Approve(""); } else { item.File.Publish(""); } } } catch (Exception exp) { Logger.WriteLog(Logger.Category.Unexpected, "Piwik FeatureActivating publish or approve master", exp.Message); } } } } } } CreateOrUpdateValueInPropertyBag("false", web, web.Properties, ConfigValues.PiwikPro_PropertyBag_PiwikIsTrackingActive); web.AllowUnsafeUpdates = oldWebAllowUnsafe; } bool ifWasntDeactivatingAndActive = true; PropertyBagOperations pbo = new PropertyBagOperations(); Configuration cfg = new Configuration(); using (SPSite elevatedSite = new SPSite(cfg.PiwikAdminSiteUrl)) { ClientContext context = new ClientContext(pbo.GetPropertyValueFromListByKey(ConfigValues.PiwikPro_PropertyBag_AdminSiteUrl)); ListProcessor sdlo = new ListProcessor(context, cfg, new SPLogger()); ifWasntDeactivatingAndActive = sdlo.AddOrUpdateElementInList(osite.RootWeb.Title, ConfigValues.PiwikPro_SiteDirectory_Column_Status_New, osite.RootWeb.Url, "", osite.RootWeb.ServerRelativeUrl, ""); } if (!ifWasntDeactivatingAndActive) { using (SPSite elevatedSite = new SPSite(osite.ID)) { var web = elevatedSite.RootWeb; CreateOrUpdateValueInPropertyBag("true", web, web.Properties, ConfigValues.PiwikPro_PropertyBag_PiwikIsTrackingActive); } } } catch (Exception exc) { Logger.WriteLog(Logger.Category.Unexpected, "Piwik FeatureActivating Full in elevated", exc.Message); } }); }
protected void btnCreate_Click(object sender, EventArgs e) { if (Page.IsValid) { btnCreate.Text = "One Moment..."; } using (SPLongOperation siteIsProvisioning = new SPLongOperation(this.Page)) { siteIsProvisioning.LeadingHTML = "Provisioning your new site..."; siteIsProvisioning.TrailingHTML = "You will be directed to your site shortly."; siteIsProvisioning.Begin(); Project project = new Project(); SPSecurity.RunWithElevatedPrivileges(delegate() { try { bool siteCreated = false; project.ProjectId = Utility.generateSiteId(_parentWebUrl); project.ProjectName = txtProjectName.Text.ToString(); project.ProjectDescription = txtProjectDesc.Text.ToString(); project.ProjectLeadSPUser = Utility.retrieveUsersFromPeoplePicker(ppProjectLead, _parentWebUrl).FirstOrDefault(); project.ProjectLead = project.ProjectLeadSPUser.Name; project.ProjectStatus = ddStatus.Text.ToString(); List <SPUser> additionalUsers = Utility.retrieveUsersFromPeoplePicker(ppAdditionalMembers, _parentWebUrl); #if DEBUG project.ProjectId = "test"; siteCreated = true; #endif #if !DEBUG SPUtility.ValidateFormDigest(); using (var web = new SPSite(_parentWebUrl).OpenWeb()) { try { web.AllowUnsafeUpdates = true; siteCreated = provisioning.createSiteFromTemplateSolution(project, _templateSolutionName); web.AllowUnsafeUpdates = false; } catch (Exception ex) { throw new SPException("Your request to create a Project Site '" + txtProjectName.Text.ToString() + "' could not be completed.", ex); } } #endif if (siteCreated) { using (var web = new SPSite(_parentWebUrl + "/" + project.ProjectId).OpenWeb()) { siteIsProvisioning.LeadingHTML = "Setting site properties..."; SPUtility.ValidateFormDigest(); web.AllowUnsafeUpdates = true; web.AllProperties["Site_Created"] = DateTime.Now.ToString("g"); web.AllProperties["Project_ID"] = project.ProjectId; web.AllProperties["Project_Name"] = project.ProjectName; web.AllProperties["Project_Description"] = project.ProjectDescription; web.AllProperties["Project_Status"] = project.ProjectStatus; web.AllProperties["Project_Lead"] = project.ProjectLead; //provisioning.updateProperties(project); //not working? web.Update(); siteIsProvisioning.LeadingHTML = "Assigning users to site..."; provisioning.setSiteSecurity(project, "Litigation Management Owners", "Site Manager", "Read Only Users", "Additional Contributors"); if (additionalUsers.Count > 0) { SPUtility.ValidateFormDigest(); SPGroup grpAdditionalUsers = web.SiteGroups[project.ProjectId + " - Additional Contributors"]; foreach (SPUser user in additionalUsers) { grpAdditionalUsers.AddUser(user); } web.AllowUnsafeUpdates = false; } } } } catch (Exception ex) { Utility.HandleException(ex, Controls); } }); siteIsProvisioning.End(_parentWebUrl + "/" + project.ProjectId); } }
protected void BtnNext_Click(object sender, EventArgs e) { using (SPLongOperation longOperation = new SPLongOperation(this.Page)) { longOperation.LeadingHTML = "请稍等,这不会花费很长的时间..."; longOperation.TrailingHTML = "请稍等,这不会花费很长的时间..."; longOperation.Begin(); var redirectURL = string.Concat(SPContext.Current.Web.Url, HttpContext.Current.Request.Url.AbsolutePath); longOperation.End(redirectURL); } }
protected void btnCreate_Click(object sender, EventArgs e) { if (Page.IsValid) btnCreate.Text = "One Moment..."; using (SPLongOperation siteIsProvisioning = new SPLongOperation(this.Page)) { siteIsProvisioning.LeadingHTML = "Provisioning your new site..."; siteIsProvisioning.TrailingHTML = "You will be directed to your site shortly."; siteIsProvisioning.Begin(); Matter matter = new Matter(); SPSecurity.RunWithElevatedPrivileges(delegate () { try { bool siteCreated = false; matter.LMNumber = Utility.generateSiteId(_parentWebUrl); matter.MatterName = txtMatterName.Text; matter.AccountName = txtAccountName.Text; matter.Affiliate = GetMMValue(mmAffiliate); matter.CaseCaption = txtCaseCaption.Text; matter.Country = txtCountry.Text; matter.DocketNumber = txtDocketNumber.Text; matter.LitigationManagerSPUser = Utility.retrieveUsersFromPeoplePicker(ppLitigationManager, _parentWebUrl).FirstOrDefault(); matter.LitigationManagerName = matter.LitigationManagerSPUser.Name; matter.LitigationManagerUserId = matter.LitigationManagerSPUser.LoginName.ToString().Split('\\')[1].ToUpper(); matter.LitigationType = GetMMValue(mmLitigationType); matter.MatterStatus = ddStatus.Text.ToString(); matter.StateFiled = GetMMValue(mmStateFiled); matter.Venue = GetMMValue(mmVenue); matter.WorkMatterType = GetMMValue(mmWorkMatterType); List<SPUser> additionalContributors = Utility.retrieveUsersFromPeoplePicker(ppAdditionalContributors, _parentWebUrl); #if DEBUG matter.LMNumber = "test"; siteCreated = true; #endif #if !DEBUG SPUtility.ValidateFormDigest(); using (var web = new SPSite(_parentWebUrl).OpenWeb()) { try { web.AllowUnsafeUpdates = true; web.Webs.Add( siteCreated = provisioning.createSiteFromTemplateSolution(matter, _templateSolutionName); web.AllowUnsafeUpdates = false; } catch (Exception ex) { throw new SPException("Your request to create Matter Site '" + txtMatterName.Text.ToString() + "' could not be completed.", ex); } } #endif if (siteCreated) { using (var web = new SPSite(_parentWebUrl + "/" + matter.LMNumber).OpenWeb()) { siteIsProvisioning.LeadingHTML = "Setting site properties..."; SPUtility.ValidateFormDigest(); web.AllowUnsafeUpdates = true; web.AllProperties["Site_Created"] = DateTime.Now.ToString("g"); web.AllProperties["Matter_Number"] = matter.LMNumber; web.AllProperties["Affiliate"] = matter.Affiliate; web.AllProperties["Case_Caption"] = matter.CaseCaption; web.AllProperties["Matter_Name"] = matter.MatterName; web.AllProperties["Account_Name"] = matter.AccountName; web.AllProperties["Litigation_Manager"] = matter.LitigationManagerName; web.AllProperties["LMUserID"] = matter.LitigationManagerUserId; web.AllProperties["Matter_Status"] = matter.MatterStatus; web.AllProperties["Docket_Number"] = matter.DocketNumber; web.AllProperties["Litigation_Type"] = matter.LitigationType; web.AllProperties["State_Filed"] = matter.StateFiled; web.AllProperties["Venue"] = matter.Venue; web.AllProperties["Country"] = matter.Country; web.AllProperties["Work_Matter_Type"] = matter.WorkMatterType; // provisioning.updateProperties(matter); //not working? web.Update(); siteIsProvisioning.LeadingHTML = "Assigning users to site..."; provisioning.setSiteSecurity(matter, "Litigation Management Owners", "Site Manager", "Read Only Users", "Additional Contributors"); if (additionalContributors.Count > 0) { SPUtility.ValidateFormDigest(); SPGroup grpAdditionalContributors = web.SiteGroups[matter.LMNumber + " - Additional Contributors"]; foreach (SPUser user in additionalContributors) { grpAdditionalContributors.AddUser(user); } web.AllowUnsafeUpdates = false; } } } } catch (Exception ex) { Utility.HandleException(ex, Controls); } }); siteIsProvisioning.End(_parentWebUrl + "/" + matter.LMNumber); } }
protected void createNewButton_OnClick(object sender, EventArgs e) { Hashtable metadataProblems = checkMetadataState(); if (metadataProblems.Count > 0) { RecordsTypeFieldMessage.Text = metadataProblems[WorkBox.COLUMN_NAME__RECORDS_TYPE].WBxToString(); FunctionalAreaFieldMessage.Text = metadataProblems[WorkBox.COLUMN_NAME__FUNCTIONAL_AREA].WBxToString(); WorkBoxShortTitleMessage.Text = metadataProblems[WorkBox.COLUMN_NAME__WORK_BOX_SHORT_TITLE].WBxToString(); ReferenceIDMessage.Text = metadataProblems[WorkBox.COLUMN_NAME__REFERENCE_ID].WBxToString();; ReferenceDateMessage.Text = metadataProblems[WorkBox.COLUMN_NAME__REFERENCE_DATE].WBxToString();; SeriesTagFieldMessage.Text = metadataProblems[WorkBox.COLUMN_NAME__SERIES_TAG].WBxToString(); OwningTeamFieldMessage.Text = metadataProblems[WorkBox.COLUMN_NAME__OWNING_TEAM].WBxToString(); InvolvedTeamsFieldMessage.Text = metadataProblems[WorkBox.COLUMN_NAME__INVOLVED_TEAMS].WBxToString(); pageRenderingRequired = true; } else { pageRenderingRequired = false; } // The event should only be processed if there is no other need to render the page again if (pageRenderingRequired) { renderPage(); } else { WBCollection collection = new WBCollection(WorkBoxCollectionUrl.Value); collection.Web.AllowUnsafeUpdates = true; WBUtils.logMessage("OK so we've set to allow unsafe updates of the WorkBoxCollectionWeb"); string selectedWorkBoxTemplateValue = WorkBoxTemplateID.Value; if (selectedWorkBoxTemplateValue == "") { selectedWorkBoxTemplateValue = WorkBoxTemplates.SelectedValue; } int templateID = Convert.ToInt32(selectedWorkBoxTemplateValue); WBTemplate template = collection.GetTypeByID(templateID); WBTeam owningTeam = new WBTeam(teams, OwningTeamUIControlValue.Value); WBTermCollection <WBTeam> involvedTeams = new WBTermCollection <WBTeam>(teams, InvolvedTeamsField.Text); Hashtable extraValues = null; extraValues = new Hashtable(); if (ReferenceID.Text != "") { extraValues.Add(WorkBox.COLUMN_NAME__REFERENCE_ID, ReferenceID.Text); } if (!ReferenceDate.IsDateEmpty) { extraValues.Add(WorkBox.COLUMN_NAME__REFERENCE_DATE, ReferenceDate.SelectedDate); } if (SeriesTagDropDownList.SelectedValue != "") { extraValues.Add(WorkBox.COLUMN_NAME__SERIES_TAG, SeriesTagDropDownList.SelectedValue); } if (functionalAreaFieldIsEditable) { extraValues.Add(WorkBox.COLUMN_NAME__FUNCTIONAL_AREA, FunctionalAreaField.Text); } else { extraValues.Add(WorkBox.COLUMN_NAME__FUNCTIONAL_AREA, workBoxRecordsType.DefaultFunctionalArea(functionalAreas).UIControlValue); } WBLogging.Generic.Unexpected("Owning team has values: " + owningTeam.Name + " " + owningTeam.Id); WorkBox newWorkBox = collection.RequestNewWorkBox(WorkBoxShortTitle.Text, "", template, owningTeam, involvedTeams, extraValues); if (newWorkBox == null) { string pageTitle = Uri.EscapeDataString("Failed to create new work box"); string pageText = Uri.EscapeDataString("Your request to create a new work box was not successful."); string redirectUrl = "WorkBoxFramework/GenericOKPage.aspx"; string queryString = "pageTitle=" + pageTitle + "&pageText=" + pageText; SPUtility.Redirect(redirectUrl, SPRedirectFlags.RelativeToLayoutsPage, Context, queryString); } collection.Web.AllowUnsafeUpdates = false; using (SPLongOperation longOperation = new SPLongOperation(this.Page)) { longOperation.LeadingHTML = "Creating your new work box."; longOperation.TrailingHTML = "Please wait while the work box is being created."; longOperation.Begin(); newWorkBox.Open("Requested via NewWorkBox.aspx."); if (relatedWorkBox != null) { switch (RelationType.Value) { case WorkBox.RELATION_TYPE__DYNAMIC: break; case WorkBox.RELATION_TYPE__MANUAL_LINK: { relatedWorkBox.LinkToWorkBox(newWorkBox, WorkBox.RELATION_TYPE__MANUAL_LINK); break; } case WorkBox.RELATION_TYPE__CHILD: { relatedWorkBox.LinkToWorkBox(newWorkBox, WorkBox.RELATION_TYPE__CHILD); newWorkBox.LinkToWorkBox(relatedWorkBox, WorkBox.RELATION_TYPE__PARENT); break; } default: { WBUtils.shouldThrowError("Did not recognise the relation type: " + RelationType.Value); break; } } relatedWorkBox.Dispose(); } collection.Dispose(); string html = "<h1>Successfully created</h1><p>Your new work box has been successfully created.</p>"; html += String.Format("<p>Go to your new work box: <a href=\"#\" onclick=\"javascript: dialogReturnOKAndRedirect('{0}');\">{1}</a></p>", newWorkBox.Url, newWorkBox.Title); string pageTitle = Uri.EscapeDataString("Created new work box"); string pageText = Uri.EscapeDataString(html); string okPageUrl = "WorkBoxFramework/GenericOKPage.aspx"; string refreshQueryString = "?recordsTypeGUID=" + newWorkBox.RecordsType.Id.ToString(); newWorkBox.Dispose(); string queryString = "pageTitle=" + pageTitle + "&pageText=" + pageText + "&refreshQueryString=" + refreshQueryString; longOperation.End(okPageUrl, SPRedirectFlags.RelativeToLayoutsPage, Context, queryString); } } }
public int SendMail() { int processed = 0; using (SPLongOperation operation = new SPLongOperation(this.Parent)) { operation.Begin(); using (new SPMonitoredScope("Mailing SendMail")) { if (SPContext.Current.Web.CurrentUser != null) { try { if (ZimbraConfiguration == null) { return(0); } SmtpClient client = new SmtpClient(ZimbraConfiguration.Server.SendMailHost, zimbraconfiguration.Server.SendMailPort); client.Credentials = new System.Net.NetworkCredential(ZimbraConfiguration.Server.SendMailUserName, ZimbraConfiguration.Server.SendMailPassword); client.DeliveryMethod = SmtpDeliveryMethod.Network; client.DeliveryFormat = SmtpDeliveryFormat.International; //client.SendCompleted += client_SendCompleted; bool more = true; int startRowIndex = SelectOnlineVersions() - 10; int maximumRows = 200; int totalrows = 0; List <Parameter> collection = new List <Parameter>(); ClubCloud_Vereniging_View queryresult = null; while (more) { try { queryresult = Client.GetVerenigingenByQuery("00000000", Guid.NewGuid(), new DataSourceSelectArguments { MaximumRows = maximumRows, StartRowIndex = startRowIndex, RetrieveTotalRowCount = true, SortExpression = "" }, collection); if (queryresult != null && queryresult.ClubCloud_Vereniging != null) { totalrows = queryresult.TotalRowCount; foreach (ClubCloud_Vereniging vereniging in queryresult.ClubCloud_Vereniging) { if (vereniging.Nummer == "09399" || vereniging.Nummer == "61424") { continue; } try { int nummer; if (int.TryParse(vereniging.Nummer, out nummer)) { MailMessage message = BuidMailMessage(vereniging); if (message == null) { continue; } List <string> emails = new List <string>(); if (!string.IsNullOrWhiteSpace(vereniging.EmailKNLTB)) { emails.Add(vereniging.EmailKNLTB); } if (!string.IsNullOrWhiteSpace(vereniging.EmailOverig)) { emails.Add(vereniging.EmailKNLTB); } if (!string.IsNullOrWhiteSpace(vereniging.EmailWebSite)) { emails.Add(vereniging.EmailWebSite); } foreach (string email in emails.Distinct()) { try { //message.To.Add(new MailAddress("*****@*****.**","Rutger Hemrika", Encoding.UTF8)); message.To.Add(new MailAddress(email.ToLower(), vereniging.Naam, Encoding.UTF8)); } catch (Exception ex) { Logger.WriteLog(Logger.Category.Unexpected, ex.Source, ex.Message); } } message.CC.Add(new MailAddress("*****@*****.**", "ClubCloud")); message.From = new MailAddress("*****@*****.**", "ClubCloud"); message.Sender = new MailAddress("*****@*****.**", "ClubCloud"); message.ReplyToList.Add(new MailAddress("*****@*****.**", "ClubCloud")); message.Priority = MailPriority.Normal; message.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure | DeliveryNotificationOptions.OnSuccess | DeliveryNotificationOptions.Delay; message.Subject = string.Format("ClubCloud : De slimme keuze voor {0}", vereniging.Naam); try { HostingEnvironment.QueueBackgroundWorkItem(ct => Email.SendAsync(message, client)); //Email.Send(message, client); Thread.Sleep(100); } catch (Exception ex) { Logger.WriteLog(Logger.Category.Unexpected, ex.Source, ex.Message); } finally { //message.Dispose(); } Thread.Sleep(200); } } catch (Exception ex) { Logger.WriteLog(Logger.Category.Unexpected, ex.Source, ex.Message); } } } processed += maximumRows; startRowIndex += maximumRows; if (processed >= totalrows || (queryresult != null && queryresult.ClubCloud_Vereniging.Count == 0)) { more = false; } //more = false; } catch (Exception ex) { Logger.WriteLog(Logger.Category.Unexpected, ex.Source, ex.Message); } //selectArgs = new DataSourceSelectArguments { MaximumRows = maximumRows, StartRowIndex = startRowIndex, RetrieveTotalRowCount = false, SortExpression = "" }; //queryresult = Client.GetVerenigingenByQuery("00000000", Guid.NewGuid(), new DataSourceSelectArguments { MaximumRows = maximumRows, StartRowIndex = startRowIndex, RetrieveTotalRowCount = false, SortExpression = "" }, collection); } } catch (Exception ex) { Logger.WriteLog(Logger.Category.Unexpected, ex.Source, ex.Message); } } } operation.End(this.Parent.Request.Url.AbsolutePath); } return(processed); }
/// <summary> /// Click event. /// </summary> /// <param name="sender">The Sender.</param> /// <param name="e">The EventArgs.</param> protected void ButtonOk_Click(object sender, EventArgs e) { // Validate this.Validate(); if (!this.IsValid) { return; } ContentDatabaseSection databaseSectionControl = this.databaseSection as ContentDatabaseSection; // We are valid // Register the database using (SPLongOperation operation = new SPLongOperation(this)) { operation.LeadingHTML = HttpContext.GetGlobalResourceObject("ClubCloud.Service.ServiceAdminResources", "DatabaseSettingsCreateOperationLeadingHtml", CultureInfo.CurrentCulture).ToString(); operation.TrailingHTML = HttpContext.GetGlobalResourceObject("ClubCloud.Service.ServiceAdminResources", "DatabaseSettingsCreateOperationTrailingHtml", CultureInfo.CurrentCulture).ToString(); operation.Begin(); if (databaseSectionControl.DisplayMode == ContentDatabaseSectionMode.AuthenticationEdit) { // We are only changing credentials here, do not reprovision. if (string.Equals(this.ServiceApplication.Database.DatabaseConnectionString, databaseSectionControl.ConnectionString, StringComparison.OrdinalIgnoreCase)) { // No change made, exit the application. operation.End(string.Format(CultureInfo.InvariantCulture, "/_admin/ClubCloud.Service/ManageApplication.aspx?id={0}", SPHttpUtility.UrlKeyValueEncode(this.ServiceApplication.Id))); } else { if (databaseSectionControl.UseWindowsAuthentication) { // Switching to windows authentication. this.ServiceApplication.Database.Username = string.Empty; this.ServiceApplication.Database.Password = string.Empty; } else { this.ServiceApplication.Database.Username = databaseSectionControl.DatabaseUserName; this.ServiceApplication.Database.Password = databaseSectionControl.DatabasePassword; } this.ServiceApplication.Database.GrantOwnerAccessToDatabaseAccount(); } // Set the failover instance this.ServiceApplication.Database.AddFailoverServiceInstance(databaseSectionControl.FailoverDatabaseServer); this.ServiceApplication.Database.Update(); operation.End(string.Format(CultureInfo.InvariantCulture, "/_admin/ClubCloud.Service/ManageApplication.aspx?id={0}", SPHttpUtility.UrlKeyValueEncode(this.ServiceApplication.Id))); } // Create the database ClubCloudDatabase database = new ClubCloudDatabase(this.databaseParameters); // Provision the database (runs the Create scripts) database.Provision(); // Grant the database the proper permissions database.GrantApplicationPoolAccess(this.ServiceApplication.ApplicationPool.ProcessAccount.SecurityIdentifier); // Add the failover server instance (the base class does not do this for you) if (!string.IsNullOrEmpty(this.databaseParameters.FailoverPartner)) { database.AddFailoverServiceInstance(this.databaseParameters.FailoverPartner); } // Establish a relationship between the service application and the database this.ServiceApplication.Database = database; this.ServiceApplication.Update(); operation.End(string.Format(CultureInfo.InvariantCulture, "/_admin/ClubCloud.Service/ManageApplication.aspx?id={0}", SPHttpUtility.UrlKeyValueEncode(this.ServiceApplication.Id))); } }