public virtual void OrganisationAttachmentDelete(OrganisationAttachment entity) { TraceCallEnterEvent.Raise(); try { m_DataContext.BeginNestedTran(); try { m_DataContext.ndihdOrganisationAttachmentDelete(entity.ID); m_DataContext.CommitNested(); } catch { m_DataContext.RollbackNested(); throw; } TraceCallReturnEvent.Raise(); return; } catch (Exception ex) { ExceptionManager.Publish(ex); TraceCallReturnEvent.Raise(false); throw; } }
// ------------------------------------------------------------------------------------- /// <summary> /// Constructor /// </summary> // ------------------------------------------------------------------------------------- public frmKefFilesEdit(DBGuid OrganisationID) { // Required for Windows Form Designer support InitializeComponent(); CurrentID = new DBGuid(); CurrentAttachment = null; m_OrganisationID = OrganisationID; m_strUrl = ""; txtUrl.ReadOnly = true; pHeader.Text2 = "Csatolt dokumentum létrehozása"; }
public virtual void OrganisationAttachmentUpdate(OrganisationAttachment entity) { TraceCallEnterEvent.Raise(); try { m_DataContext.BeginNestedTran(); try { int count; m_DataContext.ndihdOrganisationAttachmentUpdate(entity.ID, entity.OrganisationRef, entity.Path, entity.Name, entity.Description, entity.Author, entity.Publisher, entity.PublishedYear, entity.Keywords, entity.CreatedDate, entity.FileSize, entity.IsActive, entity.KefFileTypeRef, entity.Rank, out count); if (count == 0) throw new ServiceUpdateException(); m_DataContext.CommitNested(); } catch { m_DataContext.RollbackNested(); throw; } TraceCallReturnEvent.Raise(); return; } catch (Exception ex) { ExceptionManager.Publish(ex); TraceCallReturnEvent.Raise(false); throw; } }
public virtual OrganisationAttachment OrganisationAttachmentSelect(DBGuid IDVal) { TraceCallEnterEvent.Raise(); try { OrganisationAttachment result = null; DataSet entitySet = m_DataContext.ndihdOrganisationAttachmentSelect(IDVal); if (entitySet.Tables[0].Rows.Count != 0) { result = new OrganisationAttachment(entitySet); } TraceCallReturnEvent.Raise(); return result; } catch (Exception ex) { ExceptionManager.Publish(ex); TraceCallReturnEvent.Raise(false); throw; } }
protected void btnCreate_Click(object sender, EventArgs e) { try { if (!Page.IsValid) { return; } string orgID = Request["orgID"]; Guid orgGuid = new Guid(orgID); if (fileUpload.PostedFile == null) { throw new ApplicationException("Nincs feltöltött fájl."); } if (fileUpload.PostedFile.ContentLength == 0) { throw new ApplicationException("Nincs feltöltött fájl."); } OrganisationAttachment attachment = new OrganisationAttachment(Guid.NewGuid()); attachment.OrganisationRef = orgGuid; attachment.Name = txtName.Text; attachment.Description = txtDescription.Text; attachment.Author = txtAuthor.Text; attachment.Publisher = txtPublisher.Text; attachment.PublishedYear = txtPublishedYear.Text; attachment.Keywords = txtKeyword.Text; string fileType = Request["fileType"]; if (fileType != "org") { attachment.KefFileTypeRef = cmbKefFileType.SelectedValue; } else attachment.KefFileTypeRef = "ORG_ATTACH"; string fileName = Path.GetFileName(fileUpload.PostedFile.FileName); attachment.Path = fileName; BinaryReader reader = new BinaryReader(fileUpload.PostedFile.InputStream); byte[] buffer = new byte[fileUpload.PostedFile.ContentLength]; reader.Read(buffer, 0, fileUpload.PostedFile.ContentLength); attachment.DownloadData = buffer; IOrganisationAttachmentService srv = ServiceFactory.GetOrganisationAttachmentService(); srv.OrganisationAttachmentInsert(attachment); #region : KEF dokumentum - utolsó mentés idõpontjának frissítése : IOrganisationService srvOrg = ServiceFactory.GetOrganisationService(); Organisation org = srvOrg.OrganisationSelect(attachment.OrganisationRef); org.KefDownloadsLastModified = DateTime.Now; org.LastModified = DateTime.Now; srvOrg.OrganisationUpdateBase(org); #endregion if (fileType != "org") { Response.Redirect("KefOrganisationData.aspx?orgID=" + orgID.ToString()); } else Response.Redirect("OrganisationData.aspx?orgID=" + attachment.OrganisationRef.ToString()); } catch (Exception ex) { errorPanel.Exception = ex; } }
// ------------------------------------------------------------------------------------- /// <summary> /// Constructor /// </summary> // ------------------------------------------------------------------------------------- public frmKefFilesEdit(OrganisationAttachment Attachment) { // Required for Windows Form Designer support InitializeComponent(); CurrentID = Attachment.ID; CurrentAttachment = Attachment; m_OrganisationID = Attachment.OrganisationRef; m_strUrl = ""; txtUrl.ReadOnly = true; pHeader.Text2 = "Csatolt dokumentum módosítása"; }
// ------------------------------------------------------------------------------------- /// <summary> /// Create new or modify existing News item /// </summary> // ------------------------------------------------------------------------------------- private void SaveData() { if (CurrentID.IsNull) { // Create a new document CurrentID = new DBGuid(Guid.NewGuid()); CurrentAttachment = new OrganisationAttachment(CurrentID); CurrentAttachment.OrganisationRef = m_OrganisationID; } // Get control values CurrentAttachment.Name = txtName.Text; CurrentAttachment.Path = txtUrl.Text; if (txtUrl.Text.Length > 0 && m_strUrl.Length > 0 && File.Exists(m_strUrl)) { // Get file content FileStream stream = new FileStream(m_strUrl, FileMode.Open, FileAccess.Read); int fileSize = Convert.ToInt32(stream.Length); byte[] result = new byte[fileSize]; stream.Read(result, 0, fileSize); stream.Close(); CurrentAttachment.DownloadData = result; CurrentAttachment.CreatedDate = DBDateTime.Now; } CurrentAttachment.FileSize = Convert.ToInt32(txtSize.Text); CurrentAttachment.Description = txtDescription.Text; CurrentAttachment.Author = txtAuthor.Text; CurrentAttachment.Publisher = txtPublisher.Text; CurrentAttachment.PublishedYear = txtPublishedYear.Text; CurrentAttachment.Keywords = txtKeywords.Text; CurrentAttachment.IsActive = cbxActivate.Checked; if (cmbKefFileType.Enabled == false) //szervezethez csatolunk file -t azért van letiltva CurrentAttachment.KefFileTypeRef = "ORG_ATTACH"; else CurrentAttachment.KefFileTypeRef = cmbKefFileType.SelectedValue.ToString(); }
public new void OrganisationAttachmentUpdate(OrganisationAttachment entity) { // check permission: admin, writer PrincipalPermission permReg = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Registered"); PrincipalPermission permAdmin = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Administrator"); permReg.Union(permAdmin).Demand(); TraceCallEnterEvent.Raise(); try { OrganisationService srvOrg = new OrganisationService(); Organisation selectedOrg = srvOrg.OrganisationSelect(entity.OrganisationRef); if (selectedOrg == null) throw new ApplicationException("A megadott azonosítóval nem létezik szervezet."); string writerRole = selectedOrg.ID.Value.ToString() + ".Writer"; PrincipalPermission permWriter = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, writerRole); permWriter.Union(permAdmin).Demand(); // check required fields: if (entity.Name.Length == 0) throw new ArgumentNullException("OrganisationAttachment.Name", "A csatolt fájl neve nincs megadva."); if (entity.Description.Length == 0) throw new ArgumentNullException("OrganisationAttachment.Description", "A csatolt fájl leírása nincs megadva."); OrganisationAttachment selected = base.OrganisationAttachmentSelect(entity.ID); if (selected == null) throw new ApplicationException("A csatolt dokumentum nem létezik."); if (!selected.IsActive) throw new ApplicationException("A csatolt dokumentum nem aktív."); // save data if (entity.DownloadData != null && entity.DownloadData.Length > 0) { if (entity.Path.Length == 0 || entity.Path == DBString.Null ) throw new ArgumentNullException("OrganisationAttachment.Path", "A fájlnév nincs megadva."); OrganisationAttachment newAttachment = new OrganisationAttachment(Guid.NewGuid(), entity); string fileName = newAttachment.ID.Value.ToString() + Path.GetExtension(newAttachment.Path); FileDataContext fileDataContext = new FileDataContext(); fileDataContext.OrganisationAttachmentInsert(newAttachment.OrganisationRef, fileName, entity.DownloadData); newAttachment.CreatedDate = DBDateTime.Now; newAttachment.IsActive = true; newAttachment.FileSize = entity.DownloadData.Length; newAttachment.KefFileTypeRef = entity.KefFileTypeRef; selected.IsActive = false; m_DataContext.BeginNestedTran(); try { base.OrganisationAttachmentInsert(newAttachment); OrganisationAttachmentDelete(selected); m_DataContext.CommitNested(); } catch { m_DataContext.RollbackNested(); throw; } } else { selected.Name = entity.Name; selected.Description = entity.Description; selected.Author = entity.Author; selected.Publisher = entity.Publisher; selected.PublishedYear = entity.PublishedYear; selected.Keywords = entity.Keywords; selected.KefFileTypeRef = entity.KefFileTypeRef; base.OrganisationAttachmentUpdate(selected); } BusinessAuditEvent.Success( new EventParameter("OrganisationAttachmentID", entity.ID.ToString()), new EventParameter("OrganisationAttachmentName", entity.Name), new EventParameter("OrganisationID", entity.OrganisationRef.ToString()) ); TraceCallReturnEvent.Raise(); return; } catch (Exception ex) { ExceptionManager.Publish(ex); BusinessAuditEvent.Fail( new EventParameter("Exception", ex.ToString()), new EventParameter("OrganisationAttachmentID", entity.ID.ToString()), new EventParameter("OrganisationAttachmentName", entity.Name), new EventParameter("OrganisationID", entity.OrganisationRef.ToString()) ); TraceCallReturnEvent.Raise(false); throw; } }
public new void OrganisationAttachmentInsert(OrganisationAttachment entity) { // check permission: admin PrincipalPermission permReg = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Registered"); PrincipalPermission permAdmin = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Administrator"); permReg.Union(permAdmin).Demand(); TraceCallEnterEvent.Raise(); try { // check required fields: if (entity.Path.Length == 0 || entity.Path== DBString.Null) throw new ArgumentNullException("OrganisationAttachment.PictureUrl", "A fájl útvonal nincs megadva."); if (entity.DownloadData == null || entity.DownloadData.Length == 0) throw new ArgumentNullException("OrganisationAttachment.DownloadData", "A file nincs megadva."); if (entity.Description.Length == 0) throw new ArgumentNullException("OrganisationAttachment.Description", "A csatolt fájl leírása nincs megadva."); string fileName = entity.ID.ToString() + Path.GetExtension(entity.Path).ToLower(); // logical checks: FileDataContext fileDataContext = new FileDataContext(); fileDataContext.OrganisationAttachmentInsert(entity.OrganisationRef, fileName, entity.DownloadData); entity.CreatedDate = DBDateTime.Now; entity.IsActive = true; entity.FileSize = entity.DownloadData.Length; base.OrganisationAttachmentInsert(entity); BusinessAuditEvent.Success(); TraceCallReturnEvent.Raise(); return; } catch (Exception ex) { ExceptionManager.Publish(ex); BusinessAuditEvent.Fail( new EventParameter("Exception", ex.ToString()) ); TraceCallReturnEvent.Raise(false); throw; } }
public new void OrganisationAttachmentDelete(OrganisationAttachment entity) { TraceCallEnterEvent.Raise(); try { FileDataContext fileDataContext = new FileDataContext(); string ext = Path.GetExtension(entity.Path).ToLower(); string fileName = entity.ID.ToString() + ext; fileDataContext.OrganisationAttachmentDelete(entity.OrganisationRef, fileName); base.OrganisationAttachmentDelete(entity); BusinessAuditEvent.Success(); TraceCallReturnEvent.Raise(); return; } catch (Exception ex) { ExceptionManager.Publish(ex); BusinessAuditEvent.Fail( new EventParameter("Exception", ex.ToString()) ); TraceCallReturnEvent.Raise(false); throw; } }
// ------------------------------------------------------------------------------------- /// <summary> /// Copy constructor. /// </summary> /// <param name="origInstance">Original document data to copy.</param> // ------------------------------------------------------------------------------------- public OrganisationAttachment(OrganisationAttachment origInstance) : base(origInstance) { }
// ------------------------------------------------------------------------------------- /// <summary> /// Copy constructor. /// </summary> /// <param name="IDVal">Value of 'uID' field</param> /// <param name="origInstance">Original document data to copy.</param> // ------------------------------------------------------------------------------------- public OrganisationAttachment(DBGuid IDVal, OrganisationAttachment origInstance) : base(IDVal, origInstance) { }