public virtual void KefDownloadDelete(KefDownload entity)
 {
     TraceCallEnterEvent.Raise();
       try
       {
     m_DataContext.BeginNestedTran();
     try
     {
       m_DataContext.ndihdKefDownloadDelete(entity.ID);
       m_DataContext.CommitNested();
     }
     catch
     {
       m_DataContext.RollbackNested();
       throw;
     }
     TraceCallReturnEvent.Raise();
     return;
       }
       catch (Exception ex)
       {
     ExceptionManager.Publish(ex);
     TraceCallReturnEvent.Raise(false);
     throw;
       }
 }
 public virtual void KefDownloadUpdate(KefDownload entity)
 {
     TraceCallEnterEvent.Raise();
       try
       {
     m_DataContext.BeginNestedTran();
     try
     {
       int count;
       m_DataContext.ndihdKefDownloadUpdate(entity.ID,
                                        entity.KefWebDataRef,
                                        entity.Path,
                                        entity.Name,
                                        entity.Description,
                                        entity.Author,
                                        entity.Publisher,
                                        entity.PublishedYear,
                                        entity.Keywords,
                                        entity.CreatedDate,
                                        entity.FileSize,
     entity.IsActive,
     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;
       }
 }
Esempio n. 3
0
 // -------------------------------------------------------------------------------------
 /// <summary>
 /// Copy constructor.
 /// </summary>
 /// <param name="origInstance">Original document data to copy.</param>
 // -------------------------------------------------------------------------------------
 public KefDownload(KefDownload origInstance)
     : base(origInstance)
 {
 }
 public virtual KefDownload KefDownloadSelect(DBGuid IDVal)
 {
     TraceCallEnterEvent.Raise();
       try
       {
     KefDownload result = null;
     DataSet entitySet = m_DataContext.ndihdKefDownloadSelect(IDVal);
     if (entitySet.Tables[0].Rows.Count != 0)
     {
       result = new KefDownload(entitySet);
     }
     TraceCallReturnEvent.Raise();
     return result;
       }
       catch (Exception ex)
       {
     ExceptionManager.Publish(ex);
     TraceCallReturnEvent.Raise(false);
     throw;
       }
 }
Esempio n. 5
0
 // -------------------------------------------------------------------------------------
 /// <summary>
 /// Copy constructor.
 /// </summary>
 /// <param name="IDVal">Value of 'uID' field</param>
 /// <param name="origInstance">Original document data to copy.</param>
 // -------------------------------------------------------------------------------------
 public KefDownload(DBGuid IDVal,
                KefDownload origInstance)
     : base(IDVal, origInstance)
 {
 }
Esempio n. 6
0
        /// <summary>
        /// Method responsible for changing ranks.
        /// </summary>
        private void ChangeRankDoc(string uid1, string uid2, string rank1, string rank2)
        {
            Guid guid1 = new Guid(uid1);
              Guid guid2 = new Guid(uid2);
              KefDownload item1 = new KefDownload(DBGuid.Null);
              KefDownload item2 = new KefDownload(DBGuid.Null);

              int rank1temp = 0;

              foreach (KefDownload kefDownload in m_CurrentKefWebData.KefDownloads.Current)
              {
            if (kefDownload.ID.ToString() ==    guid1.ToString())
            {
              item1 = kefDownload;
            }
            if (kefDownload.ID.ToString() == guid2.ToString())
            {
              item2 = kefDownload;
            }
              }
              rank1temp = item1.Rank;
              item1.Rank = int.Parse(rank2);
              item2.Rank = int.Parse(rank1);
        }
Esempio n. 7
0
        /// <summary>
        /// Add a NewsPicture to the list.
        /// </summary>
        private void AddDownloads()
        {
            // Validate controls
              /*
            if (txtUrl.Text.Length == 0)
            {
                MessageBox.Show ("A fájl nincs megadva. Válassza ki a kívánt file-t!",
                    "NDI HelpDesk Adminisztrátor", MessageBoxButtons.OK, MessageBoxIcon.Information);
                btnDownloadUrl.Select();
                return;
            }
            if (txtFileDescription.Text.Length == 0)
            {
                MessageBox.Show ("A fájl leírása nincs megadva. Adjon meg egy rövíd leírást a beviteli mezõben!",
                    "NDI HelpDesk Adminisztrátor", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtFileDescription.Select ();
                return;
            }
            */

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

              try
              {
            // Add to container
            KefDownload item = new KefDownload(new DBGuid(Guid.NewGuid()));
            item.KefWebDataRef = CurrentID;
            item.Description = txtFileDescription.Text;
            item.Path = Path.GetFileName(txtUrl.Text);
            item.Name = Path.GetFileName(txtFileName.Text);

            // Get downloads data
            FileStream stream = new FileStream(txtUrl.Text, FileMode.Open, FileAccess.Read);
            int fileSize = Convert.ToInt32(stream.Length);
            item.DownloadData = new byte[fileSize];
            stream.Read(item.DownloadData, 0, fileSize);
            stream.Close();
            int maxRank = 0;
            foreach (KefDownload kefDownload in m_CurrentKefWebData.KefDownloads.Current)
            {
               if(kefDownload.Rank > maxRank)
               {
             maxRank = kefDownload.Rank;
               }
            }
            item.Rank = maxRank + 1;
            //item.PicturePath = this.m_strPictureUrlOther;
            m_CurrentKefWebData.KefDownloads.Add(item);

            // Refresh grid
            FillDatagrid(item.ID);

            txtUrl.Text = "";
            txtFileDescription.Text = "";
            txtFileName.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 new void KefDownloadDelete(KefDownload entity)
        {
            // check permission: admin
              PrincipalPermission permAdmin = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Administrator");
              permAdmin.Demand();

              TraceCallEnterEvent.Raise();
              try
              {
            FileDataContext fileDataContext = new FileDataContext();
            string ext = Path.GetExtension(entity.Path).ToLower();
            string fileName = entity.ID.ToString() + ext;
            fileDataContext.KefDownloadDelete(entity.KefWebDataRef, fileName);
            base.KefDownloadDelete(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 KefDownloadInsert(KefDownload entity)
        {
            // check permission: admin
              PrincipalPermission permAdmin = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Administrator");
              permAdmin.Demand();

              TraceCallEnterEvent.Raise();
              try
              {
            // check required fields:
            //if(entity.Name.Length == 0) throw new ArgumentNullException("KefDownload.Title", "A fájlnév nincs megadva.");
            if (entity.Path.Length == 0 || entity.Path == DBString.Null)
              throw new ArgumentNullException("KefDownload.PictureUrl", "A fájl útvonal nincs megadva.");
            if (entity.DownloadData == null || entity.DownloadData.Length == 0)
              throw new ArgumentNullException("KefDownload.DownloadData", "A file nincs megadva.");
            if (entity.Description.Length == 0)
              throw new ArgumentNullException("KefDownload.Description", "A csatolt fájl leírása nincs megadva.");

            string fileName = entity.ID.ToString() + Path.GetExtension(entity.Path).ToLower();

            // save data
            FileDataContext fileDataContext = new FileDataContext();
            fileDataContext.KefDownloadInsert(entity.KefWebDataRef, fileName, entity.DownloadData);

            entity.CreatedDate = DBDateTime.Now;
            entity.IsActive = true;
            entity.FileSize = entity.DownloadData.Length;
            base.KefDownloadInsert(entity);

            BusinessAuditEvent.Success(
              new EventParameter("KefDownloadID", entity.ID.ToString()),
              new EventParameter("KefDownloadName", entity.Name),
              new EventParameter("KefWebDataID", entity.KefWebDataRef.ToString())
              );

            TraceCallReturnEvent.Raise();
            return;
              }
              catch (Exception ex)
              {
            ExceptionManager.Publish(ex);
            BusinessAuditEvent.Fail(
              new EventParameter("Exception", ex.ToString())
              );
            TraceCallReturnEvent.Raise(false);
            throw;
              }
        }