コード例 #1
0
        public override void KefEventInsert(KefEvent entity)
        {
            //
              // Esemény beszúrás elõtt frissíteni kell az utolsó módosítás dátumát
              //
              OrganisationService srvOrg = new OrganisationService();
              Organisation org = srvOrg.OrganisationSelect(entity.OrganisationRef);

              org.KefEventsLastModified = DateTime.Now;
              srvOrg.OrganisationUpdateBase(org);

              //
              // Beszúrjuk az eseményt
              //
              base.KefEventInsert(entity);
        }
コード例 #2
0
        public override void OrgMemberOfOrgUpdate(OrgMemberOfOrg entity)
        {
            TraceCallEnterEvent.Raise();
              try
              {
            m_DataContext.BeginNestedTran();

            try
            {
              #region : Frissítjük a dKefMembersLastModified idõpontot :

              OrganisationService srvOrg = new OrganisationService(m_DataContext);
              Organisation org = srvOrg.OrganisationSelect(entity.OrganisationKefRef);

              org.KefMembersLastModified = DateTime.Now;

              srvOrg.OrganisationUpdateBase(org);

              #endregion

              //elmentjük az entitás adatait
              base.OrgMemberOfOrgUpdate(entity);

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

            TraceCallReturnEvent.Raise();

            return;
              }
              catch (Exception ex)
              {
            ExceptionManager.Publish(ex);
            TraceCallReturnEvent.Raise(false);
            throw;
              }
        }
コード例 #3
0
        public new void ProgramInsert(Program entity)
        {
            // check permission: Writer or Admin
              string writerRole = entity.OrganisationRef.Value.ToString() + ".Writer";
              PrincipalPermission permWriter = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, writerRole);
              PrincipalPermission permAdmin = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Administrator");
              permWriter.Union(permAdmin).Demand();

              TraceCallEnterEvent.Raise();
              try
              {
            // check required fields:
            if (entity.ID.IsNull) throw new ArgumentNullException("Program.ID", "A program azonosítója nincs megadva.");
            if (entity.OrganisationRef.IsNull)
              throw new ArgumentNullException("Program.OrganisationRef", "A szervezet azonosítója nincs megadva.");
            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.");
            if (entity.ProgramCategoryRef.Length == 0)
              throw new ArgumentNullException("Program.ProgramCategoryRef", "A program típusa nincs megadva.");

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

            OrganisationService orgSrv = new OrganisationService(m_DataContext);
            Organisation orgSelected = orgSrv.OrganisationSelect(entity.OrganisationRef);
            if (orgSelected == null)
              throw new ApplicationException("Ezzel az azonosítóval nem létezik szervezet.");

            bool orgNeedToUpdate = false;

            switch (entity.ProgramCategoryRef)
            {
              case "PRE":
            if (!orgSelected.ActivityPrevention)
            {
              orgSelected.ActivityPrevention = true;
              orgNeedToUpdate = true;
            }
            break;
              case "TRE":
            if (!orgSelected.ActivityRehabilitation)
            {
              orgSelected.ActivityRehabilitation = true;
              orgNeedToUpdate = true;
            }
            break;
              case "RES":
            if (!orgSelected.ActivityResearch)
            {
              orgSelected.ActivityResearch = true;
              orgNeedToUpdate = true;
            }
            break;
              case "OTH":
            if (!orgSelected.ActivityOther)
            {
              orgSelected.ActivityOther = true;
              orgNeedToUpdate = true;
            }
            break;
            }

            // save data:
            entity.IsActive = true;

            m_DataContext.BeginNestedTran();
            try
            {
              entity.LastModifiedDate = DateTime.Now;
              base.ProgramInsert(entity);
              if (orgNeedToUpdate)
              {
            orgSrv.OrganisationUpdateBase(orgSelected);
              }

              #region Megyék

              // Program partner - delete and insert
              //if (entity.Regions.AllCount > 0)
              {
            //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

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

              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;
              }
        }