public virtual void NewsAttachmentDelete(NewsAttachment entity)
 {
     TraceCallEnterEvent.Raise();
       try
       {
     m_DataContext.BeginNestedTran();
     try
     {
       m_DataContext.ndihdNewsAttachmentDelete(entity.ID);
       m_DataContext.CommitNested();
     }
     catch
     {
       m_DataContext.RollbackNested();
       throw;
     }
     TraceCallReturnEvent.Raise();
     return;
       }
       catch (Exception ex)
       {
     ExceptionManager.Publish(ex);
     TraceCallReturnEvent.Raise(false);
     throw;
       }
 }
        public new void NewsAttachmentDelete(NewsAttachment 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
              {
            FileDataContext fileDataContext = new FileDataContext();
            string ext = Path.GetExtension(entity.Path).ToLower();
            string fileName = entity.ID.ToString() + ext;
            fileDataContext.NewsAttachmentDelete(entity.NewsRef, fileName);
            base.NewsAttachmentDelete(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 NewsAttachmentUpdate(NewsAttachment 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
              {
            base.NewsAttachmentUpdate(entity);

            BusinessAuditEvent.Success(
              new EventParameter("NewsAttachmentID", entity.ID)
              );
            TraceCallReturnEvent.Raise();
            return;
              }
              catch (Exception ex)
              {
            ExceptionManager.Publish(ex);
            BusinessAuditEvent.Fail(
              new EventParameter("Exception", ex.ToString()),
              new EventParameter("ContinuativeID", entity.ID));
            TraceCallReturnEvent.Raise(false);
            throw;
              }
        }
        public new void NewsAttachmentInsert(NewsAttachment 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.Name.Length == 0)
              throw new ArgumentNullException("NewsAttachment.Name", "A csatolt fájl aláírása nincs megadva.");
            if (entity.Path.Length == 0)
              throw new ArgumentNullException("NewsAttachment.Path", "A csatolt fájl neve nincs megadva.");
            if (entity.FileData == null || entity.FileData.Length == 0)
              throw new ArgumentNullException("NewsAttachment.FileData", "A csatolt fájl nincs megadva, vagy nem létezik.");

            // logical checks:
            string ext = Path.GetExtension(entity.Path).ToLower();
            FileDataContext fileDataContext = new FileDataContext();
            string fileName = entity.ID.ToString() + ext;
            fileDataContext.NewsAttachmentInsert(entity.NewsRef, fileName, entity.FileData);
            entity.FileSize = entity.FileData.Length;
            entity.CreatedDate = DateTime.Now;
            base.NewsAttachmentInsert(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 NewsAttachment(NewsAttachment 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 NewsAttachment(DBGuid IDVal,
                   NewsAttachment origInstance)
     : base(IDVal, origInstance)
 {
 }
Beispiel #7
0
        /// <summary>
        /// Add a NewsPicture to the list.
        /// </summary>
        private void AddFile()
        {
            // Validate controls
              if (txtFilePath.Text.Length == 0)
              {
            MessageBox.Show("A fájl nincs megadva. Válassza ki a kívánt fájlt!",
                        "NDI HelpDesk Adminisztrátor", MessageBoxButtons.OK, MessageBoxIcon.Information);
            btnFile.Select();
            return;
              }
              if (txtFileTitle.Text.Length == 0)
              {
            MessageBox.Show("A fájlaláírás nincs megadva. Adja meg a fájlaláírást a beviteli mezõben!",
                        "NDI HelpDesk Adminisztrátor", MessageBoxButtons.OK, MessageBoxIcon.Information);
            txtFileTitle.Select();
            return;
              }

              if (!File.Exists(txtFilePath.Text))
              {
            MessageBox.Show("A fájl nem található. Válassza ki a fájlt!",
                        "NDI HelpDesk Adminisztrátor", MessageBoxButtons.OK, MessageBoxIcon.Information);
            btnFile.Select();
            return;
              }

              try
              {
            // Add to container
            NewsAttachment item = new NewsAttachment(new DBGuid(Guid.NewGuid()));
            item.NewsRef = CurrentID;
            item.Name = txtFileTitle.Text;
            item.Path = Path.GetFileName(txtFilePath.Text);
            item.Description = txtDescription.Text;
            item.IsActive = true;

            // Get picture data
            FileStream stream = new FileStream(txtFilePath.Text, FileMode.Open, FileAccess.Read);
            int fileSize = Convert.ToInt32(stream.Length);
            item.FileData = new byte[fileSize];
            stream.Read(item.FileData, 0, fileSize);
            stream.Close();
            item.FileSize = fileSize;

            //item.PicturePath = this.m_strPictureUrlOther;
            m_CurrentNews.NewsAttachments.Add(item);

            // Refresh grid
            FillFileDatagrid(item.ID);

            txtFileTitle.Text = "";
            txtDescription.Text = "";
            txtFilePath.Text = "";
              }
              catch (Exception ex)
              {
            //	---	Log exception
            ExceptionManager.Publish(ex);
            //	---	Display Exception
            ErrorHandler.DisplayError("Nem várt hiba lépett fel a kép hozzáadása során.", ex);
              }
        }
 public virtual void NewsAttachmentUpdate(NewsAttachment entity)
 {
     TraceCallEnterEvent.Raise();
       try
       {
     m_DataContext.BeginNestedTran();
     try
     {
       int count;
       m_DataContext.ndihdNewsAttachmentUpdate(entity.ID,
                                           entity.NewsRef,
                                           entity.Path,
                                           entity.Name,
                                           entity.Description,
                                           entity.CreatedDate,
                                           entity.FileSize,
                                           entity.IsActive, 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 NewsAttachment NewsAttachmentSelect(DBGuid IDVal)
 {
     TraceCallEnterEvent.Raise();
       try
       {
     NewsAttachment result = null;
     DataSet entitySet = m_DataContext.ndihdNewsAttachmentSelect(IDVal);
     if (entitySet.Tables[0].Rows.Count != 0)
     {
       result = new NewsAttachment(entitySet);
     }
     TraceCallReturnEvent.Raise();
     return result;
       }
       catch (Exception ex)
       {
     ExceptionManager.Publish(ex);
     TraceCallReturnEvent.Raise(false);
     throw;
       }
 }