/// <summary> /// Proceeds the uploaded file. /// </summary> /// <param name="radFileUpload">The RAD file upload.</param> /// <param name="fileName">Name of the file.</param> /// <returns></returns> protected string ProceedUploadedFile(RadAsyncUpload radFileUpload, string fileName) { if (radFileUpload.UploadedFiles.Count > 0) { var fsp = new FileSystemProvider(); if (!string.IsNullOrEmpty(fileName)) { try { fsp.Delete(CurrentUser.Instance.SiteID, "CompanyLegalAccounts", fileName, FileType.Attachment); } catch (Exception ex) { Log.Error("Ошибка удаления файла", ex); } } var bmp = new Bitmap(radFileUpload.UploadedFiles[0].InputStream); bmp.MakeTransparent(); var filter = new ExtractBiggestBlob(); var biggestBlobsImage = filter.Apply(bmp); var ms = new MemoryStream(); biggestBlobsImage.Save(ms, ImageFormat.Png); ms.Position = 0; return(fsp.Upload(CurrentUser.Instance.SiteID, "CompanyLegalAccounts", Path.ChangeExtension(radFileUpload.UploadedFiles[0].FileName, "png"), ms, FileType.Attachment)); } return(string.Empty); }
/// <summary> /// Handles the DeleteCommand event of the rgCompanyLegalAccounts control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="Telerik.Web.UI.GridCommandEventArgs"/> instance containing the event data.</param> protected void rgCompanyLegalAccounts_DeleteCommand(object sender, GridCommandEventArgs e) { var id = Guid.Parse((e.Item as GridDataItem).GetDataKeyValue("ID").ToString()); var companyLegalAccount = CompanyLegalAccountList.FirstOrDefault(s => s.ID == id); if (companyLegalAccount != null && !string.IsNullOrEmpty(companyLegalAccount.HeadSignatureFileName)) { var fsp = new FileSystemProvider(); fsp.Delete(CurrentUser.Instance.SiteID, "CompanyLegalAccounts", companyLegalAccount.HeadSignatureFileName, FileType.Attachment); } if (companyLegalAccount != null && !string.IsNullOrEmpty(companyLegalAccount.AccountantSignatureFileName)) { var fsp = new FileSystemProvider(); fsp.Delete(CurrentUser.Instance.SiteID, "CompanyLegalAccounts", companyLegalAccount.AccountantSignatureFileName, FileType.Attachment); } CompanyLegalAccountList.Remove(CompanyLegalAccountList.FirstOrDefault(s => s.ID == id)); if (CompanyLegalAccountsChanged != null) { CompanyLegalAccountsChanged(this, new EventArgs()); } }
protected void lbDeleteFile_Click(object sender, EventArgs e) { txtFile.Text = ""; if (((LinkButton)sender).CommandArgument != null && ((LinkButton)sender).CommandArgument != Guid.Empty.ToString()) { var fsp = new FileSystemProvider(); if (!string.IsNullOrEmpty(((LinkButton)sender).CommandArgument)) { fsp.Delete(CurrentUser.Instance.SiteID, "KnowledgeBases", ((LinkButton)sender).CommandArgument, FileType.Attachment); } } pFile.Visible = false; pUploadFile.Visible = true; }
/// <summary> /// Saves the specified save and continue. /// </summary> /// <param name="saveAndContinue">if set to <c>true</c> [save and continue].</param> protected void Save(bool saveAndContinue = false) { if (!Access.Write) { return; } var webSite = DataManager.WebSite.SelectById(SiteId, _webSiteId) ?? new tbl_WebSite(); webSite.Title = txtTitle.Text; webSite.Description = txtDescription.Text; webSite.SiteDomainID = dcbSiteDomain.SelectedIdNullable; if (rauFavIcon.UploadedFiles.Count > 0) { var fsp = new FileSystemProvider(); if (!string.IsNullOrEmpty(webSite.FavIcon)) { fsp.Delete(SiteId, "WebSites", webSite.FavIcon, FileType.Image); } webSite.FavIcon = fsp.Upload(SiteId, "WebSites", rauFavIcon.UploadedFiles[0].FileName, rauFavIcon.UploadedFiles[0].InputStream, FileType.Image); } if (webSite.ID == Guid.Empty) { webSite.SiteID = SiteId; DataManager.WebSite.Add(webSite); } else { DataManager.WebSite.Update(webSite); } DataManager.ExternalResource.Update(ucExternalResources.ExternalResourceList, webSite.ID); if (!saveAndContinue) { Response.Redirect(_webSiteId != Guid.Empty ? UrlsData.AP_WebSites() : UrlsData.AP_WebSiteEdit(webSite.ID)); } else { Response.Redirect(UrlsData.AP_WebSiteEdit(webSite.ID)); } }
/// <summary> /// Handles the DeleteCommand event of the rgExternalResource control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="Telerik.Web.UI.GridCommandEventArgs"/> instance containing the event data.</param> protected void rgExternalResource_DeleteCommand(object sender, GridCommandEventArgs e) { var id = Guid.Parse((e.Item as GridDataItem).GetDataKeyValue("ID").ToString()); var externalResource = ExternalResourceList.FirstOrDefault(s => s.ID == id); if (externalResource != null && !string.IsNullOrEmpty(externalResource.File)) { var fsp = new FileSystemProvider(); fsp.Delete(CurrentUser.Instance.SiteID, "ExternalResource", externalResource.File, FileType.Attachment); } ExternalResourceList.Remove(ExternalResourceList.FirstOrDefault(s => s.ID == id)); if (ExternalResourceChanged != null) { ExternalResourceChanged(this, new EventArgs()); } }
public static bool DeleteComment(string commentId, string commentType) { try { var contentComment = ContentCommentRepository.SelectById(CurrentUser.Instance.SiteID, Guid.Parse(commentId), commentType.ToEnum <CommentTables>()); if (contentComment != null && !string.IsNullOrEmpty(contentComment.FileName)) { var fsp = new FileSystemProvider(); fsp.Delete(CurrentUser.Instance.SiteID, EnumHelper.GetEnumDescription(commentType.ToEnum <CommentTables>()), contentComment.FileName, FileType.Attachment); } ContentCommentRepository.Delete(CurrentUser.Instance.SiteID, Guid.Parse(commentId), commentType.ToEnum <CommentTables>()); return(true); } catch (Exception ex) { Log.Error(string.Format("ContentComment DeleteComment({0}, {1})", commentId, commentType), ex); return(false); } }
/// <summary> /// Saves the state of to view. /// </summary> /// <param name="orderProductId">The order product id.</param> /// <param name="item">The item.</param> private void SaveToViewState(Guid orderProductId, GridEditableItem item) { var externalResource = ExternalResourceList.FirstOrDefault(s => s.ID == orderProductId) ?? new ExternalResourceMap(); externalResource.Title = ((TextBox)item.FindControl("txtTitle")).Text; externalResource.ResourcePlaceID = int.Parse(((DropDownList)item.FindControl("ddlResourcePlace")).SelectedValue); externalResource.ExternalResourceTypeID = int.Parse(((DropDownList)item.FindControl("ddlExternalResourceType")).SelectedValue); externalResource.Text = ((TextBox)item.FindControl("txtResourceText")).Text; externalResource.Url = ((TextBox)item.FindControl("txtResourceUrl")).Text; var rauResourceFile = (RadAsyncUpload)item.FindControl("rauResourceFile"); if (rauResourceFile.UploadedFiles.Count > 0) { var fsp = new FileSystemProvider(); if (externalResource.ID != Guid.Empty && !string.IsNullOrEmpty(externalResource.File)) { fsp.Delete(CurrentUser.Instance.SiteID, "ExternalResource", externalResource.File, FileType.Attachment); } var fileName = fsp.Upload(CurrentUser.Instance.SiteID, "ExternalResource", rauResourceFile.UploadedFiles[0].FileName, rauResourceFile.UploadedFiles[0].InputStream, FileType.Attachment); externalResource.File = fileName; } if (externalResource.ID == Guid.Empty) { externalResource.ID = Guid.NewGuid(); ExternalResourceList.Add(externalResource); } if (ExternalResourceChanged != null) { ExternalResourceChanged(this, new EventArgs()); } }
protected void BtnUpdate_Click(object sender, EventArgs e) { tbl_Publication publicationData = DataManager.Publication.SelectById(SiteId, _publicationID) ?? new tbl_Publication(); publicationData.Title = txtTitle.Text; publicationData.Code = txtCode.Text; publicationData.Date = rdpDate.SelectedDate; publicationData.AuthorID = (Guid)ucAuthor.SelectedValue; publicationData.PublicationStatusID = Guid.Parse(rcbPublicationStatus.SelectedValue); publicationData.PublicationCategoryID = sccPublicationCategory.SelectedCategoryId; publicationData.PublicationTypeID = Guid.Parse(rcbPublicationType.SelectedValue); publicationData.Noun = txtNoun.Text; publicationData.Text = ucHtmlEditor.Content; publicationData.SiteID = SiteId; publicationData.AccessRecord = int.Parse(ddlAccessRecord.SelectedValue); publicationData.AccessComment = int.Parse(ddlAccessComment.SelectedValue); if (publicationData.AccessRecord == (int)PublicationAccessRecord.Company) { publicationData.AccessCompanyID = ucCompany.SelectedValue; } else { publicationData.AccessCompanyID = null; } if (RadUpload1.UploadedFiles.Count > 0) { byte[] imageData = new byte[RadUpload1.UploadedFiles[0].InputStream.Length]; RadUpload1.UploadedFiles[0].InputStream.Read(imageData, 0, (int)RadUpload1.UploadedFiles[0].InputStream.Length); publicationData.Img = imageData; } var fsp = new FileSystemProvider(); if (!string.IsNullOrEmpty(publicationData.FileName)) { fsp.Delete(CurrentUser.Instance.SiteID, "KnowledgeBases", publicationData.FileName, FileType.Attachment); } string fileName = null; if (RadUpload2.UploadedFiles.Count > 0) { fileName = fsp.Upload(CurrentUser.Instance.SiteID, "KnowledgeBases", RadUpload2.UploadedFiles[0].FileName, RadUpload2.UploadedFiles[0].InputStream, FileType.Attachment); } publicationData.FileName = fileName; if (publicationData.ID == Guid.Empty) { DataManager.Publication.Add(publicationData); } else { DataManager.Publication.Update(publicationData); } RelatedPublication.Save(publicationData.ID); PublicationTerms.Save(publicationData.ID); PublicationComment.Save(publicationData.ID); PublicationMark.Save(publicationData.ID); tagsPublication.SaveTags(publicationData.ID); Response.Redirect(UrlsData.AP_KnowledgeBase()); }
public void OnDelete(string parameter) { FileSystemProvider.Delete(parameter); }
/// <summary> /// Handles the OnClick event of the lbtnAddPublication control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void lbtnAddPublication_OnClick(object sender, EventArgs e) { var publicationId = !string.IsNullOrEmpty(lbtnAddPublication.CommandArgument) ? Guid.Parse(lbtnAddPublication.CommandArgument) : Guid.Empty; var publication = _dataManager.Publication.SelectById(CurrentUser.Instance.SiteID, publicationId) ?? new tbl_Publication(); publication.Title = txtTitle.Text; publication.Text = txtComment.Text; publication.PublicationStatusID = Guid.Parse(rcbPublicationStatus.SelectedValue); publication.PublicationTypeID = Guid.Parse(rcbPublicationType.SelectedValue); publication.PublicationCategoryID = sccPublicationCategory.SelectedCategoryId; publication.AccessRecord = int.Parse(ddlAccessRecord.SelectedValue); publication.AccessComment = int.Parse(ddlAccessComment.SelectedValue); if (publication.AccessRecord == (int)PublicationAccessRecord.Company) { publication.AccessCompanyID = ucCompany.SelectedValue; } else { publication.AccessCompanyID = null; } var fsp = new FileSystemProvider(); if (rauFile.UploadedFiles.Count > 0) { if (!string.IsNullOrEmpty(publication.FileName)) { fsp.Delete(CurrentUser.Instance.SiteID, "Publications", publication.FileName, FileType.Attachment); } publication.FileName = fsp.Upload(CurrentUser.Instance.SiteID, "Publications", rauFile.UploadedFiles[0].FileName, rauFile.UploadedFiles[0].InputStream, FileType.Attachment); } if (publicationId == Guid.Empty) { publication.SiteID = CurrentUser.Instance.SiteID; publication.Date = DateTime.Now; publication.AuthorID = (Guid)CurrentUser.Instance.ContactID; publication.OwnerID = CurrentUser.Instance.ContactID; _dataManager.Publication.Add(publication); if (PublicationAdded != null) { PublicationAdded(this); } if (!Page.ClientScript.IsStartupScriptRegistered("CloseAddPublicationRadWindow")) { ScriptManager.RegisterStartupScript(Page, typeof(Page), "CloseAddPublicationRadWindow", "CloseAddPublicationRadWindow(true);", true); } } else { _dataManager.Publication.Update(publication); if (!Page.ClientScript.IsStartupScriptRegistered("CloseUpdatePublicationRadWindow")) { ScriptManager.RegisterStartupScript(Page, typeof(Page), "CloseUpdatePublicationRadWindow", "CloseUpdatePublicationRadWindow('" + publicationId + "');", true); } } }
/// <summary> /// Handles the OnClick event of the lbtnAddPublication control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void lbtnAddPublication_OnClick(object sender, EventArgs e) { var publicationId = !string.IsNullOrEmpty(lbtnAddPublication.CommandArgument) ? Guid.Parse(lbtnAddPublication.CommandArgument) : Guid.Empty; var publication = _dataManager.Publication.SelectByIdForPortal(((LeadForcePortalBasePage)Page).SiteId, publicationId) ?? new tbl_Publication(); publication.Title = txtTitle.Text; publication.Text = txtComment.Text; publication.PublicationTypeID = Guid.Parse(rcbPublicationType.SelectedValue); var publicationStatuses = _dataManager.PublicationStatus.SelectByPublicationTypeID(publication.PublicationTypeID); var publicationStatus = publicationStatuses.FirstOrDefault(ps => ps.isFirst.HasValue && (bool)ps.isFirst && ps.isActive.HasValue && (bool)ps.isActive); if (publicationStatus != null) { var defaultPublicationStatusId = publicationStatus.ID; publication.PublicationStatusID = defaultPublicationStatusId; } publication.PublicationCategoryID = sccPublicationCategory.SelectedCategoryId; var fsp = new FileSystemProvider(); if (rauFile.UploadedFiles.Count > 0) { if (!string.IsNullOrEmpty(publication.FileName)) { fsp.Delete(((LeadForcePortalBasePage)Page).SiteId, "Publications", publication.FileName, FileType.Attachment); } publication.FileName = fsp.Upload(((LeadForcePortalBasePage)Page).SiteId, "Publications", rauFile.UploadedFiles[0].FileName, rauFile.UploadedFiles[0].InputStream, FileType.Attachment); } if (publicationId == Guid.Empty) { publication.SiteID = ((LeadForcePortalBasePage)Page).SiteId; publication.Date = DateTime.Now; publication.AuthorID = (Guid)CurrentUser.Instance.ContactID; publication.OwnerID = CurrentUser.Instance.ContactID; var publicationType = _dataManager.PublicationType.SelectById(publication.PublicationTypeID); publication.AccessRecord = publicationType.PublicationAccessRecordID; publication.AccessComment = publicationType.PublicationAccessCommentID; if (publicationType.PublicationAccessRecordID == (int)PublicationAccessRecord.Company) { publication.AccessCompanyID = CurrentUser.Instance.CompanyID; } _dataManager.Publication.Add(publication); if (PublicationAdded != null) { PublicationAdded(this); } txtPublicationText.Text = string.Empty; if (!Page.ClientScript.IsStartupScriptRegistered("CloseAddPublicationRadWindow")) { ScriptManager.RegisterStartupScript(Page, typeof(Page), "CloseAddPublicationRadWindow", "CloseAddPublicationRadWindow(true);", true); } } else { _dataManager.Publication.Update(publication); if (!Page.ClientScript.IsStartupScriptRegistered("CloseUpdatePublicationRadWindow")) { ScriptManager.RegisterStartupScript(Page, typeof(Page), "CloseUpdatePublicationRadWindow", "CloseUpdatePublicationRadWindow('" + publicationId + "');", true); } } }