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;
              }
        }
示例#2
0
        public News NewsSelectPicture(DBGuid IDVal)
        {
            TraceCallEnterEvent.Raise();
              try
              {
            News result = base.NewsSelect(IDVal);
            if (!result.PictureUrl.IsNull)
            {
              FileDataContext fileDataContext = new FileDataContext();
              result.PictureData = fileDataContext.NewsSelect(result.ID);
            }

            TraceCallReturnEvent.Raise();
            return result;
              }
              catch (Exception ex)
              {
            ExceptionManager.Publish(ex);
            TraceCallReturnEvent.Raise(false);
            throw;
              }
        }
示例#3
0
        public new void NewsInsert(News entity)
        {
            // check permission: admin
              PrincipalPermission permAdmin = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Administrator");
              permAdmin.Demand();

              TraceCallEnterEvent.Raise();
              try
              {
            // check required fields:
            if (entity.Title.Length == 0) throw new ArgumentNullException("News.Title", "A hír címe nincs megadva.");
            if (entity.Abstract.Length == 0)
              throw new ArgumentNullException("News.Abstract", "A hír abstract nincs megadva.");
            if (entity.NewsBody.Length == 0)
              throw new ArgumentNullException("News.NewsBody", "A hír szövege nincs megadva.");

            // logical checks:
            if (entity.PictureUrl.Length > 0 && entity.PictureUrl != DBString.Null)
            {
              string ext = Path.GetExtension(entity.PictureUrl).ToLower();
              if (!(ext.Equals(".gif") || ext.Equals(".jpg") || ext.Equals("jpeg")))
            throw new ApplicationException("Csak jpeg vagy gif formátumú kép csatolható.");
              if (entity.PictureData == null || entity.PictureData.Length == 0)
            throw new ApplicationException("A fájlnévhez nem tartozik adat.");
            }
            if (entity.PictureData != null && entity.PictureData.Length > 0)
            {
              if (entity.PictureUrl.Length == 0)
            throw new ApplicationException("A kép adathoz nem tartozik fájlnév.");
            }

            // save data
            entity.CreatedDate = DBDateTime.Now;

            NewsPictureService newsPictureSrv = new NewsPictureService(m_DataContext);
            m_DataContext.BeginNestedTran();
            try
            {
              // News
              base.NewsInsert(entity);

              if (entity.PictureData != null && entity.PictureData.Length > 0)
              {

            FileDataContext fileDataContext = new FileDataContext();
            fileDataContext.NewsInsert(entity.ID, entity.PictureData);
              }

              // NewsPictures
              foreach (NewsPicture pic in entity.NewsPictures.Current)
              {
            if (/*pic.PicturePath.Length > 0 &&*/  entity.PictureUrl != DBString.Null && entity.PictureData != null && pic.PictureData.Length > 0)
            newsPictureSrv.NewsPictureInsert(pic);
              }
              NewsAttachmentService attSrv = new NewsAttachmentService(m_DataContext);

              // EDocumentAttachments - insert:
              foreach (NewsAttachment file in entity.NewsAttachments.Current)
              {
            file.NewsRef = entity.ID;
            file.IsActive = true;
            file.CreatedDate = DateTime.Now;
            attSrv.NewsAttachmentInsert(file);
              }
              m_DataContext.CommitNested();
            }
            catch
            {
              m_DataContext.RollbackNested();
              throw;
            }

            BusinessAuditEvent.Success(
              new EventParameter("NewsID", entity.ID.ToString()),
              new EventParameter("NewsTitle", entity.Title)
              );
            TraceCallReturnEvent.Raise();
            return;
              }
              catch (Exception ex)
              {
            ExceptionManager.Publish(ex);
            BusinessAuditEvent.Fail(
              new EventParameter("Exception", ex.ToString()),
              new EventParameter("NewsID", entity.ID.ToString()),
              new EventParameter("NewsTitle", entity.Title)
              );
            TraceCallReturnEvent.Raise(false);
            throw;
              }
        }
        public new void KefWebDataUpdate(KefWebData entity)
        {
            // Check permission: Admin
              PrincipalPermission permAdmin = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Administrator");
              permAdmin.Demand();

              TraceCallEnterEvent.Raise();
              try
              {
            // Check required fields:
            if (entity.Title.Length == 0)
              throw new ArgumentNullException("KefWebData.Title", "Az oldal címe nincs megadva.");
            if (entity.KefCategoryRef.Length == 0)
              throw new ArgumentNullException("KefWebData.KefWebDataRef", "Az oldal típusa nincs megadva.");

            // Logical checks
            KefWebData selected = KefWebDataSelect(entity.ID);
            if (selected == null)
              throw new ApplicationException("A megadott azonosítóval nem létezik KEF oldal.");

            // Save data
            selected.KefCategoryRef = entity.KefCategoryRef;
            selected.Title = entity.Title;
            selected.SubTitle = entity.SubTitle;
            selected.ShortDescription = entity.ShortDescription;
            selected.Description = entity.Description;
            selected.Link = entity.Link;
            selected.IsActive = entity.IsActive;
            selected.IsManual = entity.IsManual;

            KefDownloadService srvKefDownload = new KefDownloadService(m_DataContext);
            FileDataContext fileDataContext = new FileDataContext();

            m_DataContext.BeginNestedTran();

            try
            {
              // Clear old files:
              KefDownloadContainer oldFiles = base.SelectChildrenByKefWebDataOfKefDownload(entity.ID);
              foreach (KefDownload oldFile in oldFiles.All)
              {
            srvKefDownload.KefDownloadDelete(oldFile);
              }

              // NewsPicture - insert:
              foreach (KefDownload file in entity.KefDownloads.Current)
              {
            srvKefDownload.KefDownloadInsert(file);
              }

              if (selected.IsManual) //ha KEF kézikönyv akkor minden elõzõt törlünk
            m_DataContext.ndihdKefWebDataUpdateManual(selected.KefCategoryRef);

              // News - save
              base.KefWebDataUpdate(selected);

              m_DataContext.CommitNested();
            }
            catch
            {
              m_DataContext.RollbackNested();
              throw;
            }

            BusinessAuditEvent.Success(
              new EventParameter("NewsID", entity.ID.ToString()),
              new EventParameter("NewsTitle", entity.Title)
              );
            TraceCallReturnEvent.Raise();
            return;
              }
              catch (Exception ex)
              {
            ExceptionManager.Publish(ex);
            BusinessAuditEvent.Fail(
              new EventParameter("Exception", ex.ToString()),
              new EventParameter("NewsID", entity.ID.ToString()),
              new EventParameter("NewsTitle", entity.Title)
              );
            TraceCallReturnEvent.Raise(false);
            throw;
              }
        }
        public EDocumentPicture EDocumentPictureSelectPicture(DBGuid IDVal)
        {
            TraceCallEnterEvent.Raise();
              try
              {
            EDocumentPicture result = base.EDocumentPictureSelect(IDVal);
            if (!result.PictureUrl.IsNull)
            {
              FileDataContext fileDataContext = new FileDataContext();
              string ext = Path.GetExtension(result.PictureUrl).ToLower();
              string fileName = result.ID.ToString() + ext;
              result.PictureData = fileDataContext.EDocumentPictureSelect(result.EDocumentRef, fileName);
            }

            TraceCallReturnEvent.Raise();
            return result;
              }
              catch (Exception ex)
              {
            ExceptionManager.Publish(ex);
            TraceCallReturnEvent.Raise(false);
            throw;
              }
        }
示例#6
0
        public new void EDocumentInsert(EDocument entity)
        {
            // check permission: admin
              PrincipalPermission permAdmin = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Administrator");
              permAdmin.Demand();

              TraceCallEnterEvent.Raise();
              try
              {
            // check required fields:
            if (entity.Title.Length == 0)
              throw new ArgumentNullException("EDocument.Title", "A dokumentum címe nincs megadva.");

            // save data
            entity.CreatedDate = DBDateTime.Now;
            entity.ModifiedDate = DBDateTime.Now;

            // logical checks:
            if (entity.PictureUrl.Length > 0 && entity.PictureUrl != DBString.Null)
            {
              string ext = Path.GetExtension(entity.PictureUrl).ToLower();
              if (!(ext.Equals(".gif") || ext.Equals(".jpg") || ext.Equals("jpeg")))
            throw new ApplicationException("Csak jpeg vagy gif formátumú kép csatolható.");
              if (entity.PictureData == null || entity.PictureData.Length == 0)
            throw new ApplicationException("A fájlnévhez nem tartozik adat.");

            }
            if (entity.PictureData != null && entity.PictureData.Length > 0)
            {
              if (entity.PictureUrl.Length == 0)
            throw new ApplicationException("A kép adathoz nem tartozik fájlnév.");
            }

            EDocumentAttachmentsService attachSrv = new EDocumentAttachmentsService(m_DataContext);
            EDocumentCommendationService commSrv = new EDocumentCommendationService(m_DataContext);
            EDocumentPublisherService pubSrv = new EDocumentPublisherService(m_DataContext);
            EDocumentPictureService pictureSrv = new EDocumentPictureService(m_DataContext);

            m_DataContext.BeginNestedTran();

            try
            {
              // EDocuments
              base.EDocumentInsert(entity);
              EDocumentPictureContainer oldPicts = base.SelectChildrenByPictureOfEdocument(entity.ID);
              foreach (EDocumentPicture oldFile in oldPicts.All)
              {
            pictureSrv.EDocumentPictureDelete(oldFile);
              }

              if (entity.PictureData != null && entity.PictureData.Length > 0)
              {
            FileDataContext fileDataContext = new FileDataContext();
            fileDataContext.EDocumentInsert(entity.ID, entity.PictureData);
              }

              // EDocumentPictures
              foreach (EDocumentPicture pic in entity.EDocumentPictures.Current)
              {
            pictureSrv.EDocumentPictureInsert(pic);
              }
              // Files
              foreach (EDocumentAttachments attach in entity.EDocumentAttachments.Current)
              {
            attachSrv.EDocumentAttachmentsInsert(attach);
              }

              // Commendation
              foreach (EDocumentCommendation comm in entity.EDocumentCommendations.Current)
              {
            commSrv.EDocumentCommendationInsert(comm);
              }

              // Publisher
              foreach (EDocumentPublisher pub in entity.EDocumentPublishers.Current)
              {
            pub.CreatedDate = DateTime.Now;
            pubSrv.EDocumentPublisherInsert(pub);
              }
              m_DataContext.CommitNested();
            }
            catch
            {
              m_DataContext.RollbackNested();
              throw;
            }

            BusinessAuditEvent.Success(
              new EventParameter("EDocumentID", entity.ID.ToString()),
              new EventParameter("EDocumentTitle", entity.Title)
              );
            TraceCallReturnEvent.Raise();
            return;
              }
              catch (Exception ex)
              {
            ExceptionManager.Publish(ex);
            BusinessAuditEvent.Fail(
              new EventParameter("Exception", ex.ToString()),
              new EventParameter("EDocumentID", entity.ID.ToString()),
              new EventParameter("EDocumentTitle", entity.Title)
              );
            TraceCallReturnEvent.Raise(false);
            throw;
              }
        }
        public NewsAttachment NewsAttachmentSelectFile(DBGuid IDVal)
        {
            TraceCallEnterEvent.Raise();
              try
              {
            NewsAttachment result = base.NewsAttachmentSelect(IDVal);
            if (result != null && !result.Path.IsNull)
            {
              FileDataContext fileDataContext = new FileDataContext();
              string ext = Path.GetExtension(result.Path).ToLower();
              string fileName = result.ID.ToString() + ext;
              result.FileData = fileDataContext.NewsAttachmentSelect(result.NewsRef, fileName);
            }

            TraceCallReturnEvent.Raise();
            return result;
              }
              catch (Exception ex)
              {
            ExceptionManager.Publish(ex);
            TraceCallReturnEvent.Raise(false);
            throw;
              }
        }
        public JobOfferAttachment JobOfferAttachmentSelectFile(DBGuid IDVal)
        {
            // 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
              {
            JobOfferAttachment result = base.JobOfferAttachmentSelect(IDVal);
            if (result != null && !result.Path.IsNull)
            {
              FileDataContext fileDataContext = new FileDataContext();
              string ext = Path.GetExtension(result.Path).ToLower();
              string fileName = result.ID.ToString() + ext;
              result.FileData = fileDataContext.JobOfferAttachmentSelect(result.JobOfferRef, fileName);
            }

            TraceCallReturnEvent.Raise();
            return result;
              }
              catch (Exception ex)
              {
            ExceptionManager.Publish(ex);
            TraceCallReturnEvent.Raise(false);
            throw;
              }
        }
        public KefDownload KefDownloadsSelectFile(DBGuid IDVal)
        {
            TraceCallEnterEvent.Raise();
              try
              {
            KefDownload result = base.KefDownloadSelect(IDVal);
            if (!result.Path.IsNull)
            {
              FileDataContext fileDataContext = new FileDataContext();
              string ext = Path.GetExtension(result.Path).ToLower();
              string fileName = result.ID.ToString() + ext;
              result.DownloadData = fileDataContext.KefDownloadSelect(result.KefWebDataRef, fileName);
            }

            TraceCallReturnEvent.Raise();
            return result;
              }
              catch (Exception ex)
              {
            ExceptionManager.Publish(ex);
            TraceCallReturnEvent.Raise(false);
            throw;
              }
        }
示例#10
0
        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;
              }
        }
        public new void DesignerDrogUpdate( DesignerDrog entity )
        {
            // Check permission: Admin
            PrincipalPermission permAdmin = new PrincipalPermission( Thread.CurrentPrincipal.Identity.Name, "Administrator" );
            permAdmin.Demand();

            TraceCallEnterEvent.Raise();
            try
            {
            // Check required fields:
              if (entity.Title.Length == 0) throw new ArgumentNullException( "DesignerDrog.Title", "A Designer drog elem címe nincs megadva." );
            if (entity.Abstract.Length == 0)
              throw new ArgumentNullException( "DesignerDrog.Abstract", "A Designer drog elem abstract nincs megadva." );
            if (entity.Body.Length == 0)
              throw new ArgumentNullException( "DesignerDrog.Body", "A Designer drog elem szövege nincs megadva." );

            if (entity.PictureUrl.Length > 0 && entity.PictureUrl != DBString.Null)
            {
                string ext = Path.GetExtension( entity.PictureUrl ).ToLower();
                if (!(ext.Equals( ".gif" ) || ext.Equals( ".jpg" ) || ext.Equals( ".jpeg" )))
                    throw new ApplicationException( "Csak jpeg vagy gif formátumú kép csatolható." );
                if (entity.PictureData == null || entity.PictureData.Length == 0)
                {
                  entity.PictureUrl = "";
                  //throw new ApplicationException("A fájlnévhez nem tartozik adat.");
                }
              if (entity.PictureData != null && entity.PictureData.Length > 0)
                {
                    if (entity.PictureUrl.Length == 0)
                        throw new ApplicationException( "A kép adathoz nem tartozik fájlnév." );
                }
            }
            // Logical checks
            DesignerDrog selected = DesignerDrogSelect( entity.ID );
            if (selected == null)
                throw new ApplicationException( "A megadott azonosítóval nem létezik hír." );

            //string oldFileName = selected.PictureUrl;

            // Save data
            selected.Title = entity.Title;
            selected.Abstract = entity.Abstract;
            selected.Body = entity.Body;
            selected.Source = entity.Source;
            selected.Author = entity.Author;
            selected.IsActive = entity.IsActive;
            selected.PictureUrl = entity.PictureUrl;
            selected.IsActual = entity.IsActual;
            selected.CategoryRef = entity.CategoryRef;

            DesignerDrogPictureService designerDrogPictureSrv = new DesignerDrogPictureService( m_DataContext );
                      DesignerDrogLinkService designerDrogLinkSrv = new DesignerDrogLinkService( m_DataContext );
            FileDataContext fileDataContext = new FileDataContext();
            m_DataContext.BeginNestedTran();
            try
            {
                // Clear old files:
                DesignerDrogPictureContainer oldPics = base.SelectChildrenByPictureOfDesignerDrogItems( entity.ID );
                foreach (DesignerDrogPicture oldPic in oldPics.All)
                {
                    designerDrogPictureSrv.DesignerDrogPictureDelete( oldPic );
                }

                // DesignerDrogPicture - insert:
                foreach (DesignerDrogPicture pic in entity.DesignerDrogPictures.Current)
                {
                  if (/*pic.PicturePath.Length > 0 &&*/  entity.PictureUrl != DBString.Null && entity.PictureData != null && pic.PictureData.Length > 0)
                        designerDrogPictureSrv.DesignerDrogPictureInsert( pic );
                }

                #region Links
                // Clear old files:
                DesignerDrogLinkContainer oldLinks = base.SelectChildrenByLinkOfDesignerDrogItem( entity.ID );
                foreach (DesignerDrogLink oldLink in oldLinks.All)
                {
                  designerDrogLinkSrv.DesignerDrogLinkDelete( oldLink );
                }

                // DesignerDrogPicture - insert:
                foreach (DesignerDrogLink link in entity.DesignerDrogLinks.Current)
                {
                  designerDrogLinkSrv.DesignerDrogLinkInsert( link );
                }
                #endregion

              selected.DesignerDrogLinks = entity.DesignerDrogLinks;
                selected.DesignerDrogAttachments = entity.DesignerDrogAttachments;

                DesignerDrogAttachmentService attSrv = new DesignerDrogAttachmentService( m_DataContext );

                // Clear old files:
                DesignerDrogAttachmentContainer oldFiles = base.SelectChildrenByAttachmentOfDesignerDrogItem( entity.ID );
                foreach (DesignerDrogAttachment oldFile in oldFiles.All)
                {
                    attSrv.DesignerDrogAttachmentDelete( oldFile );
                }
                DesignerDrogAttachment newFile;
                // EDocumentAttachments - insert:
                foreach (DesignerDrogAttachment file in selected.DesignerDrogAttachments.Current)
                {
                    if (file.FileData.Length == 0)
                    {
                        newFile = attSrv.DesignerDrogAttachmentSelectFile( file.ID );
                    }
                    else
                    {
                        newFile = file;
                    }
                    newFile.ItemRef = selected.ID;
                    newFile.Name = file.Name;
                    newFile.Description = file.Description;
                    newFile.CreatedDate = DateTime.Now;

                    if (attSrv.DesignerDrogAttachmentSelect( newFile.ID ) != null)
                    {
                        attSrv.DesignerDrogAttachmentUpdate( newFile );
                    }
                    else
                    {
                        attSrv.DesignerDrogAttachmentInsert( newFile );
                    }
                }
                // DesignerDrog
                base.DesignerDrogUpdate( selected );

                // DesignerDrog base picture update
                fileDataContext.DesignerDrogDelete( selected.ID );
                if (entity.PictureData != null && entity.PictureData.Length > 0)
                {
                    fileDataContext.DesignerDrogInsert( entity.ID, entity.PictureData );
                }

                m_DataContext.CommitNested();
            }
            catch
            {
                m_DataContext.RollbackNested();
                throw;
            }

            BusinessAuditEvent.Success(
              new EventParameter( "DesignerDrogID", entity.ID.ToString() ),
              new EventParameter( "DesignerDrogTitle", entity.Title )
              );
            TraceCallReturnEvent.Raise();
            return;
            }
            catch (Exception ex)
            {
            ExceptionManager.Publish( ex );
            BusinessAuditEvent.Fail(
              new EventParameter( "Exception", ex.ToString() ),
              new EventParameter( "DesignerDrogID", entity.ID.ToString() ),
              new EventParameter( "DesignerDrogTitle", entity.Title )
              );
            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;
              }
        }
示例#14
0
        public new void EDocumentUpdate(EDocument entity)
        {
            // Check permission: Admin
              PrincipalPermission permAdmin = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Administrator");
              permAdmin.Demand();

              TraceCallEnterEvent.Raise();
              try
              {
            // Check required fields:
            if (entity.Title.Length == 0) throw new ArgumentNullException("News.Title", "A dokumentum címe nincs megadva.");

            // Logical checks
            EDocument selected = EDocumentSelect(entity.ID);
            if (selected == null)
              throw new ApplicationException("A megadott azonosítóval nem létezik dokumentum.");

            if (entity.PictureUrl.Length > 0 && entity.PictureUrl != DBString.Null)
            {
              string ext = Path.GetExtension(entity.PictureUrl).ToLower();
              if (!(ext.Equals(".gif") || ext.Equals(".jpg") || ext.Equals(".jpeg")))
            throw new ApplicationException("Csak jpeg vagy gif formátumú kép csatolható.");
              if (entity.PictureData == null || entity.PictureData.Length == 0)
            throw new ApplicationException("A fájlnévhez nem tartozik adat.");

              if (entity.PictureData != null && entity.PictureData.Length > 0)
              {
            if (entity.PictureUrl.Length == 0)
              throw new ApplicationException("A kép adathoz nem tartozik fájlnév.");
              }
            }

            // Save data
            selected.Title = entity.Title;
            selected.Abstract = entity.Abstract;
            selected.Author = entity.Author;
            selected.CategoryRef = entity.CategoryRef;
            selected.CreatedDate = entity.CreatedDate;
            selected.IsVirtual = entity.IsVirtual;
            selected.LanguageRef = entity.LanguageRef;
            selected.Link = entity.Link;
            selected.SubTypeRef = entity.SubTypeRef;
            selected.Title = entity.Title;
            selected.TypeRef = entity.TypeRef;
            selected.VisibleForRegistered = entity.VisibleForRegistered;
            selected.VisibleForVisitor = entity.VisibleForVisitor;
            selected.ModifiedDate = DateTime.Now;
            selected.Summary = entity.Summary;
            selected.PictureUrl = entity.PictureUrl;

            EDocumentAttachmentsService attSrv = new EDocumentAttachmentsService(m_DataContext);
            EDocumentCommendationService commSrv = new EDocumentCommendationService(m_DataContext);
            EDocumentPublisherService pubSrv = new EDocumentPublisherService(m_DataContext);
            EDocumentPictureService pictureSrv = new EDocumentPictureService(m_DataContext);
            FileDataContext fileDataContext = new FileDataContext();
            m_DataContext.BeginNestedTran();
            try
            {

              // Clear old files:
              EDocumentPictureContainer oldPics = base.SelectChildrenByPictureOfEdocument(entity.ID);
              foreach (EDocumentPicture oldPic in oldPics.All)
              {
            pictureSrv.EDocumentPictureDelete(oldPic);
              }
              // EDocumentPictures
              foreach (EDocumentPicture pic in entity.EDocumentPictures.Current)
              {
            if (pic.PicturePath.Length > 0 && entity.PictureUrl != DBString.Null && entity.PictureData != null && pic.PictureData.Length > 0)
             pictureSrv.EDocumentPictureInsert(pic);
              }

              // Clear old files:
              EDocumentAttachmentsContainer oldFiles = base.SelectChildrenByAttachmentOfEDocument(entity.ID);
              foreach (EDocumentAttachments oldFile in oldFiles.All)
              {
            attSrv.EDocumentAttachmentsDelete(oldFile);
              }

              // EDocumentAttachments - insert:
              foreach (EDocumentAttachments file in  entity.EDocumentAttachments.Current)
              {
            attSrv.EDocumentAttachmentsInsert(file);
              }
              EDocumentCommendationContainer oldComms = base.SelectChildrenByCommendationOfEDocument(entity.ID);

              // Commendation
              foreach (EDocumentCommendation comm in entity.EDocumentCommendations.Current)
              {
            if (oldComms[comm.ID.Value.ToString()] != null)
            {
              commSrv.EDocumentCommendationUpdate(comm);
            }
            else
            {
              commSrv.EDocumentCommendationInsert(comm);
            }
              }
              // Commendation
              foreach (EDocumentCommendation comm in entity.EDocumentCommendations.Deleted)
              {
            commSrv.EDocumentCommendationDelete(comm);
              }

              EDocumentPublisherContainer oldpubs = base.SelectChildrenByPublisherOfEDocument(entity.ID);

              // Publisher
              foreach (EDocumentPublisher pub in entity.EDocumentPublishers.Current)
              {
            if (oldpubs[pub.ID.Value.ToString()] != null)
            {
              pubSrv.EDocumentPublisherUpdate(pub);
            }
            else
            {
              pub.CreatedDate = DateTime.Now;
              pubSrv.EDocumentPublisherInsert(pub);
            }
              }
              // Publisher
              foreach (EDocumentPublisher pub in entity.EDocumentPublishers.Deleted)
              {
            pubSrv.EDocumentPublisherDelete(pub);
              }
              // EDocument
              base.EDocumentUpdate(selected);

              // News base picture update
              fileDataContext.EDocumentDelete(selected.ID);
              if (entity.PictureData != null && entity.PictureData.Length > 0)
              {
            fileDataContext.EDocumentInsert(entity.ID, entity.PictureData);
              }

              m_DataContext.CommitNested();
            }
            catch
            {
              m_DataContext.RollbackNested();
              throw;
            }

            BusinessAuditEvent.Success(
              new EventParameter("EDocumentID", entity.ID.ToString()),
              new EventParameter("EDocumentTitle", entity.Title)
              );
            TraceCallReturnEvent.Raise();
            return;
              }
              catch (Exception ex)
              {
            ExceptionManager.Publish(ex);
            BusinessAuditEvent.Fail(
              new EventParameter("Exception", ex.ToString()),
              new EventParameter("EDocumentID", entity.ID.ToString()),
              new EventParameter("EDocumentTitle", entity.Title)
              );
            TraceCallReturnEvent.Raise(false);
            throw;
              }
        }
示例#15
0
        public new void NewsUpdate(News entity)
        {
            // Check permission: Admin
              PrincipalPermission permAdmin = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Administrator");
              permAdmin.Demand();

              TraceCallEnterEvent.Raise();
              try
              {
            // Check required fields:
            if (entity.Title.Length == 0) throw new ArgumentNullException("News.Title", "A hír címe nincs megadva.");
            if (entity.Abstract.Length == 0)
              throw new ArgumentNullException("News.Abstract", "A hír abstract nincs megadva.");
            if (entity.NewsBody.Length == 0)
              throw new ArgumentNullException("News.NewsBody", "A hír szövege nincs megadva.");

            if (entity.PictureUrl.Length > 0 && entity.PictureUrl != DBString.Null)
            {
              string ext = Path.GetExtension(entity.PictureUrl).ToLower();
              if (!(ext.Equals(".gif") || ext.Equals(".jpg") || ext.Equals(".jpeg")))
            throw new ApplicationException("Csak jpeg vagy gif formátumú kép csatolható.");
              if (entity.PictureData == null || entity.PictureData.Length == 0)
            throw new ApplicationException("A fájlnévhez nem tartozik adat.");

              if (entity.PictureData != null && entity.PictureData.Length > 0)
              {
            if (entity.PictureUrl.Length == 0)
              throw new ApplicationException("A kép adathoz nem tartozik fájlnév.");
              }
            }
            // Logical checks
            News selected = NewsSelect(entity.ID);
            if (selected == null)
              throw new ApplicationException("A megadott azonosítóval nem létezik hír.");

            //string oldFileName = selected.PictureUrl;

            // Save data
            selected.Title = entity.Title;
            selected.Abstract = entity.Abstract;
            selected.NewsBody = entity.NewsBody;
            selected.VisibleForVisitor = entity.VisibleForVisitor;
            selected.VisibleForRegistered = entity.VisibleForRegistered;
            selected.IsActive = entity.IsActive;
            selected.PictureUrl = entity.PictureUrl;
            selected.IsActual = entity.IsActual;
            selected.CategoryRef = entity.CategoryRef;

            NewsPictureService newsPictureSrv = new NewsPictureService(m_DataContext);
            FileDataContext fileDataContext = new FileDataContext();
            m_DataContext.BeginNestedTran();
            try
            {
              // Clear old files:
              NewsPictureContainer oldPics = base.SelectChildrenByPictureOfNews(entity.ID);
              foreach (NewsPicture oldPic in oldPics.All)
              {
            newsPictureSrv.NewsPictureDelete(oldPic);
              }

              // NewsPicture - insert:
              foreach (NewsPicture pic in entity.NewsPictures.Current)
              {
            if (/*pic.PicturePath.Length > 0 &&*/  entity.PictureUrl != DBString.Null && entity.PictureData != null && pic.PictureData.Length > 0)
              newsPictureSrv.NewsPictureInsert(pic);
              }

              selected.NewsAttachments = entity.NewsAttachments;

              NewsAttachmentService attSrv = new NewsAttachmentService(m_DataContext);

              // Clear old files:
              NewsAttachmentContainer oldFiles = base.SelectChildrenByAttachmentOfNews(entity.ID);
              foreach (NewsAttachment oldFile in oldFiles.All)
              {
            attSrv.NewsAttachmentDelete(oldFile);
              }
              NewsAttachment newFile;
              // EDocumentAttachments - insert:
              foreach (NewsAttachment file in selected.NewsAttachments.Current)
              {
            if (file.FileData.Length == 0)
            {
              newFile = attSrv.NewsAttachmentSelectFile(file.ID);
            }
            else
            {
              newFile = file;
            }
            newFile.NewsRef = selected.ID;
            newFile.Name = file.Name;
            newFile.Description = file.Description;
            newFile.CreatedDate = DateTime.Now;

            if (attSrv.NewsAttachmentSelect(newFile.ID) != null)
            {
              attSrv.NewsAttachmentUpdate(newFile);
            }
            else
            {
              attSrv.NewsAttachmentInsert(newFile);
            }
              }
              // News
              base.NewsUpdate(selected);

              // News base picture update
              fileDataContext.NewsDelete(selected.ID);
              if (entity.PictureData != null && entity.PictureData.Length > 0)
              {
            fileDataContext.NewsInsert(entity.ID, entity.PictureData);
              }

              m_DataContext.CommitNested();
            }
            catch
            {
              m_DataContext.RollbackNested();
              throw;
            }

            BusinessAuditEvent.Success(
              new EventParameter("NewsID", entity.ID.ToString()),
              new EventParameter("NewsTitle", entity.Title)
              );
            TraceCallReturnEvent.Raise();
            return;
              }
              catch (Exception ex)
              {
            ExceptionManager.Publish(ex);
            BusinessAuditEvent.Fail(
              new EventParameter("Exception", ex.ToString()),
              new EventParameter("NewsID", entity.ID.ToString()),
              new EventParameter("NewsTitle", entity.Title)
              );
            TraceCallReturnEvent.Raise(false);
            throw;
              }
        }
示例#16
0
        public new void NewsPictureInsert(NewsPicture entity)
        {
            // check permission: admin
              PrincipalPermission permAdmin = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Administrator");
              permAdmin.Demand();

              TraceCallEnterEvent.Raise();
              try
              {
            // check required fields:
            if (entity.Title.Length == 0)
              throw new ArgumentNullException("NewsPicture.Title", "A képaláírás nincs megadva.");
            if (entity.PictureUrl.Length == 0 || entity.PictureUrl == DBString.Null)
              throw new ArgumentNullException("NewsPicture.PictureUrl", "A fájlnév nincs megadva.");

              if (entity.PictureData == null || entity.PictureData.Length == 0)
            throw new ArgumentNullException("NewsPicture.PictureData", "A kép nincs megadva.");

            // logical checks:
            string ext = Path.GetExtension(entity.PictureUrl).ToLower();
            if (!(ext.Equals(".gif") || ext.Equals(".jpg") || ext.Equals(".jpeg")))
              throw new ApplicationException("Csak jpeg vagy gif formátumú kép csatolható.");

            FileDataContext fileDataContext = new FileDataContext();
            string fileName = entity.ID.ToString() + ext;
            fileDataContext.NewsPictureInsert(entity.NewsRef, fileName, entity.PictureData);
            base.NewsPictureInsert(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 ProgramAttachmentInsert(ProgramAttachment 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
              {
            ProgramService progSrv = new ProgramService();
            Program selectedProgram = progSrv.ProgramSelect(entity.ProgramRef);
            if (selectedProgram == null)
              throw new ApplicationException("A megadott azonosítóval nem létezik program.");

            string writerRole = selectedProgram.OrganisationRef.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("ProgramAttachment.Name", "A csatolt fájl neve nincs megadva.");
            if (entity.Description.Length == 0)
              throw new ArgumentNullException("ProgramAttachment.Description", "A csatolt fájl leírása nincs megadva.");
            if (entity.Path.Length == 0  || entity.Path == DBString.Null)
              throw new ArgumentNullException("ProgramAttachment.Path", "A fájlnév nincs megadva.");
            if (entity.FileData == null || entity.FileData.Length == 0)
              throw new ArgumentNullException("ProgramAttachment.FileData", "A fájl tartalma nincs megadva.");

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

            // save data
            FileDataContext fileDataContext = new FileDataContext();
            fileDataContext.ProgramAttachmentInsert(entity.ProgramRef, fileName, entity.FileData);

            entity.CreatedDate = DBDateTime.Now;
            entity.IsActive = true;
            entity.FileSize = entity.FileData.Length;
            base.ProgramAttachmentInsert(entity);

            BusinessAuditEvent.Success(
              new EventParameter("ProgramAttachmentID", entity.ID.ToString()),
              new EventParameter("ProgramAttachmentName", entity.Name),
              new EventParameter("ProgramID", entity.ProgramRef.ToString())
              );
            TraceCallReturnEvent.Raise();
            return;
              }
              catch (Exception ex)
              {
            ExceptionManager.Publish(ex);
            BusinessAuditEvent.Fail(
              new EventParameter("Exception", ex.ToString()),
              new EventParameter("ProgramAttachmentID", entity.ID.ToString()),
              new EventParameter("ProgramAttachmentName", entity.Name),
              new EventParameter("ProgramID", entity.ProgramRef.ToString())
              );
            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;
              }
        }
        public ProgramAttachment ProgramAttachmentSelectFile(DBGuid IDVal)
        {
            TraceCallEnterEvent.Raise();
              try
              {
            ProgramAttachment result = base.ProgramAttachmentSelect(IDVal);
            FileDataContext fileDataContext = new FileDataContext();

            string fileName = result.ID.Value.ToString() + Path.GetExtension(result.Path);
            result.FileData = fileDataContext.ProgramAttachmentSelect(result.ProgramRef, fileName);

            TraceCallReturnEvent.Raise();
            return result;
              }
              catch (Exception ex)
              {
            ExceptionManager.Publish(ex);
            TraceCallReturnEvent.Raise(false);
            throw;
              }
        }
        public new void ProgramAttachmentUpdate(ProgramAttachment 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
              {
            ProgramService progSrv = new ProgramService();
            Program selectedProgram = progSrv.ProgramSelect(entity.ProgramRef);
            if (selectedProgram == null)
              throw new ApplicationException("A megadott azonosítóval nem létezik program.");

            string writerRole = selectedProgram.OrganisationRef.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("ProgramAttachment.Name", "A csatolt fájl neve nincs megadva.");
            if (entity.Description.Length == 0)
              throw new ArgumentNullException("ProgramAttachment.Description", "A csatolt fájl leírása nincs megadva.");

            ProgramAttachment selected = base.ProgramAttachmentSelect(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.FileData != null && entity.FileData.Length > 0)
            {
              if (entity.Path.Length == 0 || entity.Path == DBString.Null)
            throw new ArgumentNullException("ProgramAttachment.Path", "A fájlnév nincs megadva.");

              ProgramAttachment newAttachment = new ProgramAttachment(Guid.NewGuid(), entity);
              string fileName = newAttachment.ID.Value.ToString() + Path.GetExtension(newAttachment.Path);
              FileDataContext fileDataContext = new FileDataContext();
              fileDataContext.ProgramAttachmentInsert(newAttachment.ProgramRef, fileName, entity.FileData);
              newAttachment.CreatedDate = DBDateTime.Now;
              newAttachment.IsActive = true;
              newAttachment.FileSize = entity.FileData.Length;
              selected.IsActive = false;
              m_DataContext.BeginNestedTran();
              try
              {
            base.ProgramAttachmentInsert(newAttachment);
            base.ProgramAttachmentUpdate(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;
              base.ProgramAttachmentUpdate(selected);
            }

            BusinessAuditEvent.Success(
              new EventParameter("ProgramAttachmentID", entity.ID.ToString()),
              new EventParameter("ProgramAttachmentName", entity.Name),
              new EventParameter("ProgramID", entity.ProgramRef.ToString())
              );
            TraceCallReturnEvent.Raise();
            return;
              }
              catch (Exception ex)
              {
            ExceptionManager.Publish(ex);
            BusinessAuditEvent.Fail(
              new EventParameter("Exception", ex.ToString()),
              new EventParameter("ProgramAttachmentID", entity.ID.ToString()),
              new EventParameter("ProgramAttachmentName", entity.Name),
              new EventParameter("ProgramID", entity.ProgramRef.ToString())
              );
            TraceCallReturnEvent.Raise(false);
            throw;
              }
        }
示例#21
0
        public void ProgramUpdateAdmin(Program 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("Program.Name", "A program neve nincs megadva.");
            if (entity.Description.Length == 0)
              throw new ArgumentNullException("Program.Description", "A program leírása nincs megadva.");
            if (entity.ProgramStatus.Length == 0)
              throw new ArgumentNullException("Program.ProgramStatus", "A program státusza nincs megadva.");

            // Logical checks
            Program selected = base.ProgramSelect(entity.ID);
            if (selected == null)
              throw new ApplicationException("Ezzel az azonosítóval nem létezik program.");

            if (CheckProgramExistByName(entity.Name, selected.OrganisationRef, entity.ID))
            {
              throw new ApplicationException("Ezzel a névvel már létezik program!");
            }

            // Save data
            selected.Name = entity.Name;
            selected.Description = entity.Description;
            selected.ProgramStatus = entity.ProgramStatus;
            selected.StartDate = entity.StartDate;
            selected.FinishDate = entity.FinishDate;
            selected.NonregisteredPartners = entity.NonregisteredPartners;
            selected.ResponsibleRef = entity.ResponsibleRef;
            selected.Coordinator1Ref = entity.Coordinator1Ref;
            selected.Coordinator2Ref = entity.Coordinator2Ref;
            selected.ProgramStatus = entity.ProgramStatus;
            selected.IsActive = entity.IsActive;

            m_DataContext.BeginNestedTran();
            try
            {
              // Program participant - delete and insert
              if (entity.Experts.AllCount > 0)
              {
            m_DataContext.ndihdProgramParticipantDeleteBy(entity.ID);

            for (int i = 0; i < entity.Experts.Deleted.Count; i++)
            {
              DBGuid ExpertRef = ((Expert) entity.Experts.Deleted.Items[i]).ID;
              m_DataContext.ndihdProgramParticipantInsert(ExpertRef, entity.ID);
            }
              }

              // Program partner - delete and insert
              if (entity.Organisations.AllCount > 0)
              {
            m_DataContext.ndihdPartnerProgramDeleteBy(entity.ID);

            for (int i = 0; i < entity.Organisations.Deleted.Count; i++)
            {
              DBGuid PartnerRef = ((Organisation) entity.Organisations.Deleted.Items[i]).ID;
              m_DataContext.ndihdProgramPartnerInsert(PartnerRef, entity.ID);
            }
              }

              #region Megyék

              // Program partner - delete and insert
              //if (entity.Regions.AllCount > 0)
              {
            //összeset letöröljük
            m_DataContext.ndihdRegionOfProgramDeleteBy(entity.ID);
            //egyesével felvesszük
            for (int i = 0; i < entity.Regions.All.Count; i++)
            {
              DBString regionRef = ((ProgramRegion) entity.Regions.All.Items[i]).RegionRef;
              m_DataContext.ndihdProgramRegionInsert(entity.ID, regionRef);
            }
              }

              #endregion

              // Program attachment
              if (entity.ProgramAttachments.AllCount > 0)
              {
            for (int i = 0; i < entity.ProgramAttachments.All.Count; i++)
            {
              // Get item from container
              ProgramAttachment attEntity = (ProgramAttachment) entity.ProgramAttachments.All.Items[i];

              // Check item existance
              ProgramAttachmentService srv = new ProgramAttachmentService();
              ProgramAttachment attSelected = srv.ProgramAttachmentSelect(attEntity.ID);
              if (attSelected == null)
              {
                // Insert a new
                attEntity.CreatedDate = DBDateTime.Now;

                if (attEntity.FileData != null && attEntity.FileData.Length > 0)
                {
                  if (attEntity.Path.Length == 0 || attEntity.Path == DBString.Null )
                    throw new ArgumentNullException("ProgramAttachment.Path", "A fájlnév nincs megadva.");

                  string fileName = attEntity.ID.Value.ToString() + Path.GetExtension(attEntity.Path);
                  FileDataContext fileDataContext = new FileDataContext();
                  fileDataContext.ProgramAttachmentInsert(attEntity.ProgramRef, fileName, attEntity.FileData);
                }

                m_DataContext.ndihdProgramAttachmentInsert(attEntity.ID,
                                                           attEntity.ProgramRef,
                                                           attEntity.Path,
                                                           attEntity.Name,
                                                           attEntity.Description,
                                                           attEntity.Author,
                                                           attEntity.Publisher,
                                                           attEntity.PublishedYear,
                                                           attEntity.Keywords,
                                                           attEntity.CreatedDate,
                                                           attEntity.FileSize,
                                                           attEntity.IsActive);
              }
              else
              {
                // Update existing
                if (attEntity.FileData != null && attEntity.FileData.Length > 0)
                {
                  if (attEntity.Path.Length == 0 || attEntity.Path == DBString.Null)
                    throw new ArgumentNullException("ProgramAttachment.Path", "A fájlnév nincs megadva.");

                  ProgramAttachment newAttachment = new ProgramAttachment(Guid.NewGuid(), attEntity);

                  string fileName = newAttachment.ID.Value.ToString() + Path.GetExtension(newAttachment.Path);
                  FileDataContext fileDataContext = new FileDataContext();
                  fileDataContext.ProgramAttachmentInsert(newAttachment.ProgramRef, fileName, newAttachment.FileData);

                  newAttachment.CreatedDate = DBDateTime.Now;
                  m_DataContext.ndihdProgramAttachmentInsert(newAttachment.ID,
                                                             newAttachment.ProgramRef,
                                                             newAttachment.Path,
                                                             newAttachment.Name,
                                                             newAttachment.Description,
                                                             newAttachment.Author,
                                                             newAttachment.Publisher,
                                                             newAttachment.PublishedYear,
                                                             newAttachment.Keywords,
                                                             newAttachment.CreatedDate,
                                                             newAttachment.FileSize,
                                                             newAttachment.IsActive);

                  attSelected.IsActive = false;
                  m_DataContext.ndihdProgramAttachmentUpdate(attSelected.ID,
                                                             attSelected.ProgramRef,
                                                             attSelected.Path,
                                                             attSelected.Name,
                                                             attSelected.Description,
                                                             attSelected.Author,
                                                             attSelected.Publisher,
                                                             attSelected.PublishedYear,
                                                             attSelected.Keywords,
                                                             attSelected.CreatedDate,
                                                             attSelected.FileSize,
                                                             attSelected.IsActive);
                }
                else
                {
                  m_DataContext.ndihdProgramAttachmentUpdate(attEntity.ID,
                                                             attEntity.ProgramRef,
                                                             attEntity.Path,
                                                             attEntity.Name,
                                                             attEntity.Description,
                                                             attEntity.Author,
                                                             attEntity.Publisher,
                                                             attEntity.PublishedYear,
                                                             attEntity.Keywords,
                                                             attEntity.CreatedDate,
                                                             attEntity.FileSize,
                                                             attEntity.IsActive);
                }
              }
            }
              }

              // Program keyword - delete and insert
              if (entity.Thesauruses.AllCount > 0)
              {
            base.DeleteChildrenByProgramOfKeyword(entity.ID);

            for (int i = 0; i < entity.Thesauruses.Deleted.Count; i++)
            {
              DBString KeywordRef = ((Thesaurus) entity.Thesauruses.Deleted.Items[i]).Keyword;
              ProgramKeyword entityPK = new ProgramKeyword(KeywordRef, entity.ID);

              ProgramKeywordService srv = new ProgramKeywordService(m_DataContext);
              srv.ProgramKeywordInsert(entityPK);
            }
              }

              // Program
              selected.LastModifiedDate = DateTime.Now;
              base.ProgramUpdate(selected);

              //feltöltjük a szabadszöveges kereséshez a GlobalSearch táblát
              GlobalSearchService srvGlobalSearch = new GlobalSearchService(m_DataContext);
              srvGlobalSearch.SaveProgram(selected);

              m_DataContext.CommitNested();
            }
            catch
            {
              m_DataContext.RollbackNested();
              throw;
            }

            BusinessAuditEvent.Success(
              new EventParameter("ProgramID", entity.ID.ToString()),
              new EventParameter("ProgramName", entity.Name)
              );
            TraceCallReturnEvent.Raise();
            return;
              }
              catch (Exception ex)
              {
            ExceptionManager.Publish(ex);
            BusinessAuditEvent.Fail(
              new EventParameter("Exception", ex.ToString()),
              new EventParameter("ProgramID", entity.ID.ToString()),
              new EventParameter("ProgramName", entity.Name)
              );
            TraceCallReturnEvent.Raise(false);
            throw;
              }
        }