// Public Methods (1) public bool Export(out string file, out string message) { file = string.Empty; message = string.Empty; try { SPList resourcePool = _spWeb.Lists["Resources"]; ValidateAccess(); Dictionary <string, object[]> fieldDictionary = BuildFieldDictionary(resourcePool); DataTable dataTable = GetResources(resourcePool); using (MemoryStream memoryStream = CreateSpreadsheet(fieldDictionary, dataTable)) { using (var epmLiveFileStore = new EPMLiveFileStore(_spWeb)) { file = epmLiveFileStore.Add(memoryStream.ToArray()); } } return(true); } catch (Exception exception) { message = exception.Message; return(false); } }
protected void UploadPictureButton_Click(object sender, EventArgs e) { if (!PictureFileUpload.HasFile) { return; } using (var fileStore = new EPMLiveFileStore(Web)) { FileNameField.Value = fileStore.Add(PictureFileUpload.FileBytes, Path.GetExtension(PictureFileUpload.FileName)); } UploadPanel.Visible = false; ResizePanel.Visible = true; }
protected void ImportMain(bool cancelExistingJob) { if (cancelExistingJob) { // Again calling this method to fetch currently running job id to cancel it. IsImportResourceAlreadyRunning(); Timer.CancelTimerJob(SPContext.Current.Web, jobUid); } if (!FileUpload.HasFile) { return; } string extension = Path.GetExtension(FileUpload.FileName); if (string.IsNullOrEmpty(extension)) { return; } if (!extension.ToLower().Equals(".xlsm")) { CustomValidator.ErrorMessage = "Files with extension " + extension + " are not allowed."; CustomValidator.IsValid = false; } else { string fileId; SPWeb spWeb = SPContext.Current.Web; using (var epmLiveFileStore = new EPMLiveFileStore(spWeb)) { fileId = epmLiveFileStore.Add(FileUpload.FileBytes); } SPSite spSite = spWeb.Site; Guid jobId = Timer.AddTimerJob(spSite.ID, spWeb.ID, "Import Resources", 60, fileId, string.Empty, -1, 9, string.Empty); Timer.Enqueue(jobId, 0, spSite); Response.Redirect(spWeb.Url + "/_layouts/epmlive/importresourcestatus.aspx?isdlg=1&jobid=" + jobId); } }