Union() public method

public Union ( IPermission other ) : IPermission
other IPermission
return IPermission
 public new void JobAnswerDelete(JobAnswer entity)
 {
     PrincipalPermission permReg = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Registered");
       PrincipalPermission permAdmin = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Administrator");
       permReg.Union(permAdmin).Demand();
       base.JobAnswerDelete(entity);
 }
Beispiel #2
0
 //[PrincipalPermission(SecurityAction.Demand, Name="aa")]
 protected void testRoleBtn_Click(object sender, EventArgs e)
 {
     var aPermission = new PrincipalPermission("a", null);
     var bPermission = new PrincipalPermission("b", null);
     aPermission.Union(bPermission).Demand();
     //permission.Demand();
 }
        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 void ProgramAttachmentInactivate(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();

              ProgramAttachment selected = base.ProgramAttachmentSelect(IdVal);
              if (selected == null)
            throw new ApplicationException("A megadott azonosítóval nem létezik csatolt fájl.");

              ProgramService progSrv = new ProgramService();
              Program selectedProgram = progSrv.ProgramSelect(selected.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();

              TraceCallEnterEvent.Raise();
              try
              {
            // save data
            selected.IsActive = false;
            base.ProgramAttachmentUpdate(selected);

            BusinessAuditEvent.Success(
              new EventParameter("ProgramAttachmentID", IdVal.ToString()),
              new EventParameter("ProgramAttachmentName", selected.Name),
              new EventParameter("ProgramID", selected.ProgramRef.ToString())
              );
            TraceCallReturnEvent.Raise();
            return;
              }
              catch (Exception ex)
              {
            ExceptionManager.Publish(ex);
            BusinessAuditEvent.Fail(
              new EventParameter("Exception", ex.ToString()),
              new EventParameter("ProgramAttachmentID", IdVal.ToString())
              );
            TraceCallReturnEvent.Raise(false);
            throw;
              }
        }
        public new void ProgramPartnerDelete(ProgramPartner entity)
        {
            TraceCallEnterEvent.Raise();
              try
              {
            // logical checks:
            ProgramService progSrv = new ProgramService();
            Program selected = progSrv.ProgramSelect(entity.ProgramRef);
            if (selected == null)
              throw new ApplicationException("Ezzel az azonosítóval nem létezik program.");
            if (!selected.IsActive)
              throw new ApplicationException("A program nem aktív.");

            // check permission: Writer or Admin
            string writerRole = selected.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();

            // save data:
            base.ProgramPartnerDelete(entity);

            BusinessAuditEvent.Success(
              new EventParameter("ProgramID", entity.ProgramRef.ToString()),
              new EventParameter("OrganisationID", entity.OrganisationRef.ToString())
              );
            TraceCallReturnEvent.Raise();
            return;
              }
              catch (Exception ex)
              {
            ExceptionManager.Publish(ex);
            BusinessAuditEvent.Fail(
              new EventParameter("Exception", ex.ToString()),
              new EventParameter("ProgramID", entity.ProgramRef.ToString()),
              new EventParameter("OrganisationID", entity.OrganisationRef.ToString())
              );
            TraceCallReturnEvent.Raise(false);
            throw;
              }
        }
        public override IPermission CreatePermission()
        {
            IList<string> roles = (this.Roles ?? string.Empty).Split(',', ';')
                                    .Select(s => s.Trim())
                                    .Where(s => s.Length > 0)
                                    .Distinct()
                                    .ToList();

            IPermission result;
            if (roles.Count == 0)
            {
                result = new PrincipalPermission(null, null, true);
            }
            else
            {
                result = new PrincipalPermission(null, roles[0]);
                for (int i = 1; i < roles.Count; i++)
                {
                    result = result.Union(new PrincipalPermission(null, roles[i]));
                }
            }

            return result;
        }
        public JobOfferContainer JobOfferSelectBySubscriber(DBString SubscriberIDVal, DBString TypeIdRef)
        {
            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
              {
            JobOfferContainer result = new JobOfferContainer();
            DataSet entitySet = m_DataContext.ndihdJobOfferSelectBySubscriber(SubscriberIDVal, TypeIdRef);
            result = new JobOfferContainer(entitySet.Tables[0]);
            TraceCallReturnEvent.Raise();
            return result;
              }
              catch (Exception ex)
              {
            ExceptionManager.Publish(ex);
            TraceCallReturnEvent.Raise(false);
            throw;
              }
        }
 public new JobOffer JobOfferSelect(DBGuid IDVal)
 {
     PrincipalPermission permReg = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Registered");
       PrincipalPermission permAdmin = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Administrator");
       permReg.Union(permAdmin).Demand();
       return base.JobOfferSelect(IDVal);
 }
        public void OrganisationKefUpdate(Organisation org, KefEventContainer kefEvents, DataTable kefMembers)
        {
            // check permission: Writer or Admin
              string writerRole = org.ID.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 (org.Name.Length == 0)
              throw new ArgumentNullException("Organisation.Name", "A szervezet neve nincs megadva.");
            if (org.PostCode.Length == 0)
              throw new ArgumentNullException("Organisation.PostCode", "A szervezet címének irányítószáma nincs megadva.");
            if (org.City.Length == 0)
              throw new ArgumentNullException("Organisation.City", "A szervezet címének települése nincs megadva.");
            if (org.Address.Length == 0)
              throw new ArgumentNullException("Organisation.Address",
                                          "A szervezet címének utca, házszám része nincs megadva.");
            if (org.OrganisationFormRef.Length == 0)
              throw new ArgumentNullException("Organisation.OrganisationFormRef", "A szervezeti forma kódja nincs megadva.");
            if (org.WorkingAreaRef.Length == 0)
              throw new ArgumentNullException("Organisation.WorkingAreaRef", "A mûködési terület nincs megadva.");

            // logical checks:
            Organisation selected = base.OrganisationSelect(org.ID);
            if (selected == null)
              throw new ApplicationException("Ezzel az azonosítóval nem létezik szervezet.");

            NdiPrincipal principal = (NdiPrincipal) Thread.CurrentPrincipal;
            if (!selected.IsActive && !principal.IsInRole("Administrator"))
              throw new ApplicationException("A szervezet nem aktív.");
            // save data:
            org.IsActive = selected.IsActive;

            try
            {

              //elmentjük a szervezet módosított adatokat
              base.OrganisationUpdate(org);
              m_DataContext.BeginNestedTran();
              //töröljük az összes kapcsolódó eseményt ...
              OrganisationService srvOrg = new OrganisationService(m_DataContext);
              KefEventService srvKefEvent = new KefEventService(m_DataContext);
              srvOrg.DeleteChildrenByOrganisationOfKefEvent(org.ID);

              //majd beszúrjuk az újakat
              foreach (KefEvent item in kefEvents.Current)
              {
            srvKefEvent.KefEventInsert(item);
              }

              //töröljük az összes kapcsolódó tagot ...
              srvOrg.DeleteChildrenByKefOrgOfOrg(org.ID);
              OrgMemberOfOrgService srvKefMember = new OrgMemberOfOrgService(m_DataContext);

              //majd beszúrjuk az újakat
              foreach (DataRow row in kefMembers.Rows)
              {
            OrgMemberOfOrg member = new OrgMemberOfOrg(Guid.NewGuid());

            member.OrganisationKefRef = new Guid(row["uOrganisationKefRef"].ToString());
            member.OrganisationMemberRef = new Guid(row["uOrganisationMemberRef"].ToString());
            member.ContactName = row["cContactName"].ToString();
            member.ContactInstitution = row["cContactInstitution"].ToString();
            member.ContactZipCode = row["cContactZipCode"].ToString();
            member.ContactTownShip = row["cContactTownShip"].ToString();
            member.ContactAddress = row["cContactAddress"].ToString();
            member.ContactPhone1 = row["cContactPhone1"].ToString();
            member.ContactPhone2 = row["cContactPhone2"].ToString();
            member.ContactPhone3 = row["cContactPhone3"].ToString();
            member.ContactFax = row["cContactFax"].ToString();
            member.ContactPosition = row["cContactPosition"].ToString();
            member.ContactPositionInKef = row["cContactPositionInKef"].ToString();
            member.ContactEmail1 = row["cContactEmail1"].ToString();
            member.ContactEmail2 = row["cContactEmail2"].ToString();
            member.ContactEmail3 = row["cContactEmail3"].ToString();
            member.ContactQualification = row["cContactQualification"].ToString();
            member.KefContactTypeRef = row["cKefContactTypeRef"].ToString();

            srvKefMember.OrgMemberOfOrgInsert(member);
              }

              //elmentjük a szervezethez tartozó feltöltött fileokat
              OrganisationAttachmentService srvOrgAtt = new OrganisationAttachmentService(m_DataContext);

              // Clear old files:
              OrganisationAttachmentContainer oldFiles = base.SelectChildrenByAttachmentOfOrganisation(org.ID);

              foreach (OrganisationAttachment oldFile in oldFiles.All)
              {
            srvOrgAtt.OrganisationAttachmentDelete(oldFile);
              }

              foreach (OrganisationAttachment file in org.OrgAttachments.Current)
              {
            if(file.DownloadData != null)
              srvOrgAtt.OrganisationAttachmentInsert(file);
              }

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

            BusinessAuditEvent.Success(
              new EventParameter("OrganisationID", org.ID.ToString()),
              new EventParameter("OrganisationName", org.Name)
              );
            TraceCallReturnEvent.Raise();
            return;
              }
              catch (Exception ex)
              {
            ExceptionManager.Publish(ex);
            BusinessAuditEvent.Fail(
              new EventParameter("Exception", ex.ToString()),
              new EventParameter("OrganisationID", org.ID.ToString()),
              new EventParameter("OrganisationName", org.Name)
              );
            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 void UnionWithBadPermission () 
		{
			PrincipalPermission p1 = new PrincipalPermission ("user", null);
			EnvironmentPermission ep2 = new EnvironmentPermission (PermissionState.Unrestricted);
			PrincipalPermission p3 = (PrincipalPermission) p1.Union (ep2);
		}
		public void UnionWithUnrestricted () 
		{
			PrincipalPermission p1 = new PrincipalPermission (PermissionState.Unrestricted);
			PrincipalPermission p2 = new PrincipalPermission ("user", "role");
			PrincipalPermission p3 = (PrincipalPermission) p1.Union (p2);
			Assert ("Unrestricted U P2 == Unrestricted", p3.IsUnrestricted ());
			p3 = (PrincipalPermission) p2.Union (p1);
			Assert ("P2 U Unrestricted == Unrestricted", p3.IsUnrestricted ());
		}
        public new void JobOfferUpdate(JobOffer entity)
        {
            // check permission: Writer or 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.Description.Length == 0)
              throw new ArgumentNullException("JobOffer.Description", "A hirdetés leírása nincs megadva.");

            // Logical checks
            JobOffer selected = base.JobOfferSelect(entity.ID);
            if (selected == null)
              throw new ApplicationException("A megadott azonosítóval nem létezik hirdetés.");

            // Save data

            selected.Requirements = entity.Requirements;
            selected.QualificationMinRef = entity.QualificationMinRef;
            selected.IdealEmployee = entity.IdealEmployee;
            selected.EmployeeCount = entity.EmployeeCount;
            selected.HomePage = entity.HomePage;
            selected.ContactName = entity.ContactName;
            selected.ContactPhone = entity.ContactPhone;
            selected.ContactEmail = entity.ContactEmail;

            selected.Description = entity.Description;
            selected.City = entity.City;
            selected.RegionRef = entity.RegionRef;
            selected.Status = entity.Status;

            selected.ActivityPrevention = entity.ActivityPrevention;
            selected.ActivityResearch = entity.ActivityResearch;
            selected.ActivityRehabilitation = entity.ActivityRehabilitation;
            selected.ActivityOther = entity.ActivityOther;
            selected.Expiredate = entity.Expiredate;
            selected.NotificationSend = entity.NotificationSend;
            selected.NotificationDate = entity.NotificationDate;

            selected.LastModified = DateTime.Now;
            selected.JobOfferAttachments = entity.JobOfferAttachments;

            JobOfferAttachmentService attSrv = new JobOfferAttachmentService(m_DataContext);

            // Clear old files:
            JobOfferAttachmentContainer oldFiles = base.SelectChildrenByAttachmentOfJobOffer(entity.ID);
            foreach (JobOfferAttachment oldFile in oldFiles.All)
            {
              attSrv.JobOfferAttachmentDelete(oldFile);
            }
            JobOfferAttachment newFile;
            // EDocumentAttachments - insert:
            foreach (JobOfferAttachment file in selected.JobOfferAttachments.Current)
            {
              if (file.FileData.Length == 0)
              {
            newFile = attSrv.JobOfferAttachmentSelectFile(file.ID);
              }
              else
              {
            newFile = file;
              }
              newFile.JobOfferRef = selected.ID;
              newFile.Name = file.Name;
              newFile.Description = file.Description;
              newFile.CreatedDate = DateTime.Now;

              if (attSrv.JobOfferAttachmentSelect(newFile.ID) != null)
              {
            attSrv.JobOfferAttachmentUpdate(newFile);
              }
              else
              {
            attSrv.JobOfferAttachmentInsert(newFile);
              }
            }

            base.JobOfferUpdate(selected);

            BusinessAuditEvent.Success(
              new EventParameter("JobOfferID", entity.ID.ToString()),
              new EventParameter("JobOfferLogin", entity.Sender)
              );
            TraceCallReturnEvent.Raise();
            return;
              }
              catch (Exception ex)
              {
            ExceptionManager.Publish(ex);
            BusinessAuditEvent.Fail(
              new EventParameter("Exception", ex.ToString()),
              new EventParameter("JobOfferID", entity.ID.ToString()),
               new EventParameter("JobOfferLogin", entity.Sender)
              );
            TraceCallReturnEvent.Raise(false);
            throw;
              }
        }
   public new JobAnswer JobAnswerSelect(DBGuid JobRefVal, DBString TypeVal,
 DBString SubscriberNameRefVal,
 DBString SenderNameRefVal)
   {
       PrincipalPermission permReg = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Registered");
         PrincipalPermission permAdmin = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Administrator");
         permReg.Union(permAdmin).Demand();
         return base.JobAnswerSelect(JobRefVal, TypeVal, SubscriberNameRefVal, SenderNameRefVal);
   }
        public new void JobAnswerInsert(JobAnswer entity)
        {
            try
              {
            PrincipalPermission permReg = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Registered");
            PrincipalPermission permAdmin = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Administrator");
            permReg.Union(permAdmin).Demand();

            JobAnswer ja = base.JobAnswerSelect(entity.JobRef, entity.Type, entity.SubscriberNameRef, entity.SenderNameRef);
            if(ja != null)
            {
              if(ja.IsActive)
              throw new ApplicationException("Erre a hirdetésre már válaszolt.");
            }

            //entity.SubscriberNameRef = Thread.CurrentPrincipal.Identity.Name;
            entity.Created = DateTime.Now;
            entity.IsActive = true;
            if (ja == null)
            {
              base.JobAnswerInsert(entity);
            }
            else
            {
              ja = entity;
              base.JobAnswerUpdate(ja);
            }
            //értesítjük a feladót, hogy valaki válaszolt a hirdetésére
            //set mail:
            Email mail = new Email(Guid.NewGuid());
            //Subject és body lekérdezése
            string body = "";
            string subject = "";
            EmailTemplateService srvTemplate = new EmailTemplateService();
            srvTemplate.GetEmailTemplateByCode(ref subject, ref body, EmailCategory.JobAnswerCreated);
            mail.Category = EmailCategory.JobAnswerCreated;
            mail.Subject = subject;
            UserService srvUser = new UserService();
            User subscriber = srvUser.UserSelect(entity.SubscriberNameRef);
            //Ha keresés hirdetésre jelentkezett valaki
            if (entity.Type == JobAnswerTypeEnum.FIN)
            {
              User sender = srvUser.UserSelect(entity.SenderNameRef);

              if (sender != null && sender.Email.Length > 0)
              {
            JobFindService srvJob = new JobFindService();
            JobFind find = srvJob.JobFindSelect(entity.JobRef);
            mail.To = sender.Email;
            body = body.Replace("<FULL_USER_NAME>", sender.Name);
            if (find != null)
            {
              body = body.Replace("<JOB_REFID>", find.RefId.ToString());
              body = body.Replace("<JOB_DESCRIPTION>", find.Description);
            }
              }
            }
            else
            {
              //ajánlat
              JobOfferService srvJob = new JobOfferService();
              JobOffer offer = srvJob.JobOfferSelect(entity.JobRef);
              if (offer != null && offer.ContactEmail.Length > 0)
              {
            mail.To = offer.ContactEmail;
            body = body.Replace("<FULL_USER_NAME>", offer.ContactName);
            body = body.Replace("<JOB_REFID>", offer.RefId.ToString());
            body = body.Replace("<JOB_DESCRIPTION>", offer.Description);
              }
            }
            if (subscriber != null)
            {
              body = body.Replace("<SUBSCRIBER_NAME>", subscriber.Name);
              body = body.Replace("<SUBSCRIBER_MAIL>", subscriber.Email);
              body = body.Replace("<MOTIVATION>", entity.Motivation);
            }

            mail.MailBody = body;

            if (mail.MailBody != null && mail.To != null && mail.Subject != null)
            {
              // Save data to database
              EmailService emailSrv = new EmailService(m_DataContext);
              m_DataContext.BeginNestedTran();
              try
              {
            emailSrv.EmailInsert(mail);
            m_DataContext.CommitNested();
              }
              catch
              {
            m_DataContext.RollbackNested();
            throw;
              }

              // Sending mail:
              try
              {
            emailSrv.EmailSend(mail.ID);
              }
              catch (Exception ex)
              {
            ExceptionManager.Publish(ex);
            return;
              }
            }
            // Log success
            BusinessAuditEvent.Success(
              new EventParameter("JobRef", entity.JobRef.ToString()),
              new EventParameter("OrganisationID", Thread.CurrentPrincipal.Identity.Name)
              );
            TraceCallReturnEvent.Raise();
            return;
              }
              catch (Exception ex)
              {
            ExceptionManager.Publish(ex);
            BusinessAuditEvent.Fail(
              new EventParameter("JobRef", entity.JobRef.ToString()),
              new EventParameter("OrganisationID", Thread.CurrentPrincipal.Identity.Name)
              );
            TraceCallReturnEvent.Raise(false);
            throw;
              }
        }
        public static bool currentPrincipalInRoles(string Roles)
        {
            IList<string> roles = (Roles ?? string.Empty).Split(',', ';')
                        .Select(s => s.Trim())
                        .Where(s => s.Length > 0)
                        .Distinct()
                        .ToList();

            IPermission result;
            if (roles.Count == 0)
            {
                result = new PrincipalPermission(null, null, true);
            }
            else
            {
                result = new PrincipalPermission(null, roles[0]);
                for (int i = 1; i < roles.Count; i++)
                {
                    result = result.Union(new PrincipalPermission(null, roles[i]));
                }
            }

            try
            {
                result.Demand();
            }
            catch (SecurityException securityEx)
            {
                string messageInner = securityEx.InnerException != null ? securityEx.InnerException.ToString() : "";
                string message = "Ошибка безопасности" + Environment.NewLine + securityEx.Message + Environment.NewLine + messageInner;
                PException pexception = StaticInformation.ninjectKernel.Get<PException>(new ConstructorArgument("MessageText", message, false));
                pexception.Show();
                return false;
            }
            return true;
        }
        public void OrganisationUpdateBase(Organisation entity)
        {
            // check permission: Writer or Admin
              string writerRole = entity.ID.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.Name.Length == 0)
              throw new ArgumentNullException("Organisation.Name", "A szervezet neve nincs megadva.");
            if (entity.PostCode.Length == 0)
              throw new ArgumentNullException("Organisation.PostCode", "A szervezet címének irányítószáma nincs megadva.");
            if (entity.City.Length == 0)
              throw new ArgumentNullException("Organisation.City", "A szervezet címének települése nincs megadva.");
            if (entity.Address.Length == 0)
              throw new ArgumentNullException("Organisation.Address",
                                          "A szervezet címének utca, házszám része nincs megadva.");
            if (entity.OrganisationFormRef.Length == 0)
              throw new ArgumentNullException("Organisation.OrganisationFormRef", "A szervezeti forma kódja nincs megadva.");
            if (entity.WorkingAreaRef.Length == 0)
              throw new ArgumentNullException("Organisation.WorkingAreaRef", "A mûködési terület nincs megadva.");

            // logical checks:
            Organisation selected = base.OrganisationSelect(entity.ID);
            if (selected == null)
              throw new ApplicationException("Ezzel az azonosítóval nem létezik szervezet.");

            NdiPrincipal principal = (NdiPrincipal) Thread.CurrentPrincipal;
            if (!selected.IsActive && !principal.IsInRole("Administrator"))
              throw new ApplicationException("A szervezet nem aktív.");
            // save data:
            entity.IsActive = selected.IsActive;
            entity.LastValidationDate = selected.LastValidationDate;
            entity.ValidationState = selected.ValidationState;
            //entity.LastModified = DateTime.Now; //Ezt azért vettem ki, hogyha az admin módosít, akkor ne tűnjön módosításnak
            try
            {
              m_DataContext.BeginNestedTran();
              //elmentjük a szervezet módosított adatokat
              base.OrganisationUpdate(entity);
              m_DataContext.CommitNested();
            }
            catch
            {
              m_DataContext.RollbackNested();
              throw;
            }

            BusinessAuditEvent.Success(
              new EventParameter("OrganisationID", entity.ID.ToString()),
              new EventParameter("OrganisationName", entity.Name)
              );
            TraceCallReturnEvent.Raise();
            return;
              }
              catch (Exception ex)
              {
            ExceptionManager.Publish(ex);
            BusinessAuditEvent.Fail(
              new EventParameter("Exception", ex.ToString()),
              new EventParameter("OrganisationID", entity.ID.ToString()),
              new EventParameter("OrganisationName", entity.Name)
              );
            TraceCallReturnEvent.Raise(false);
            throw;
              }
        }
        public new void OrganisationUpdate(Organisation entity)
        {
            // check permission: Writer or Admin
              string writerRole = entity.ID.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.Name.Length == 0)
              throw new ArgumentNullException("Organisation.Name", "A szervezet neve nincs megadva.");
            if (entity.PostCode.Length == 0)
              throw new ArgumentNullException("Organisation.PostCode", "A szervezet címének irányítószáma nincs megadva.");
            if (entity.City.Length == 0)
              throw new ArgumentNullException("Organisation.City", "A szervezet címének települése nincs megadva.");
            if (entity.Address.Length == 0)
              throw new ArgumentNullException("Organisation.Address",
                                          "A szervezet címének utca, házszám része nincs megadva.");
            //if(entity.MailingPostCode.Length == 0)  throw new ArgumentNullException("Organisation.MailingPostCode", "A szervezet levelezési címének irányítószáma nincs megadva.");
            //if(entity.MailingCity.Length == 0)  throw new ArgumentNullException("Organisation.MailingCity", "A szervezet levelezési címének települése nincs megadva.");
            //if(entity.MailingAddress.Length == 0)  throw new ArgumentNullException("Organisation.MailingAddress", "A szervezet levelezési címének utca, házszám része nincs megadva.");
            if (entity.OrganisationFormRef.Length == 0)
              throw new ArgumentNullException("Organisation.OrganisationFormRef", "A szervezeti forma kódja nincs megadva.");
            //if(entity.EstablishmentYear.Length == 0)  throw new ArgumentNullException("Organisation.EstablishmentYear", "A szervezet alapításának éve nincs megadva.");
            if (entity.WorkingAreaRef.Length == 0)
              throw new ArgumentNullException("Organisation.WorkingAreaRef", "A mûködési terület nincs megadva.");

            // logical checks:
            Organisation selected = base.OrganisationSelect(entity.ID);
            if (selected == null)
              throw new ApplicationException("Ezzel az azonosítóval nem létezik szervezet.");

            NdiPrincipal principal = (NdiPrincipal) Thread.CurrentPrincipal;
            if (!selected.IsActive && !principal.IsInRole("Administrator"))
              throw new ApplicationException("A szervezet nem aktív.");
            // save data:
            entity.IsActive = selected.IsActive;

            //entity.LastModified = DateTime.Now; ide csak az user módosítás lesz beírva, és ezt nem hívja az user
            try
            {
              m_DataContext.BeginNestedTran();

              //elmentjük a szervezet módosított adatokat
              base.OrganisationUpdate(entity);

              //elmentjük a szervezethez tartozó feltöltött fileokat
              OrganisationAttachmentService srvOrgAtt = new OrganisationAttachmentService(m_DataContext);

              // Clear old files:
              OrganisationAttachmentContainer oldFiles = base.SelectChildrenByAttachmentOfOrganisation(entity.ID);

              foreach (OrganisationAttachment oldFile in oldFiles.All)
              {
            srvOrgAtt.OrganisationAttachmentDelete(oldFile);
              }

              foreach (OrganisationAttachment file in entity.OrgAttachments.Current)
              {
            srvOrgAtt.OrganisationAttachmentInsert(file);
              }

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

            BusinessAuditEvent.Success(
              new EventParameter("OrganisationID", entity.ID.ToString()),
              new EventParameter("OrganisationName", entity.Name)
              );
            TraceCallReturnEvent.Raise();
            return;
              }
              catch (Exception ex)
              {
            ExceptionManager.Publish(ex);
            BusinessAuditEvent.Fail(
              new EventParameter("Exception", ex.ToString()),
              new EventParameter("OrganisationID", entity.ID.ToString()),
              new EventParameter("OrganisationName", entity.Name)
              );
            TraceCallReturnEvent.Raise(false);
            throw;
              }
        }
        public JobOfferContainer JobOfferSelectFiltered(JobOffer filter)
        {
            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
              {
            JobOfferContainer result = new JobOfferContainer();
            DataSet entitySet = m_DataContext.ndihdJobOfferSelectFiltered(filter.FilterOnRefId, filter.ID, filter.Sender, filter.Description, filter.Message,
              filter.Requirements,
              filter.City,
                                                                     filter.RegionRef, filter.QualificationMinRef, filter.Status,
                                                                     filter.FilterOnActivityPrevention,
                                                                     filter.FilterOnActivityResearch,
                                                                     filter.FilterOnActivityRehabilitation,
                                                                     filter.FilterOnActivityOther,
                                                                     filter.FilterOnNotificationsent, filter.Expiredate, filter.NotificationDate, filter.ExpireDatexpired);
            result = new JobOfferContainer(entitySet.Tables[0]);
            TraceCallReturnEvent.Raise();
            return result;
              }
              catch (Exception ex)
              {
            ExceptionManager.Publish(ex);
            TraceCallReturnEvent.Raise(false);
            throw;
              }
        }
        public JobAnswerContainer JobAnswerSelectFiltered(JobAnswer filter)
        {
            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
              {
            JobAnswerContainer result = new JobAnswerContainer();
            DataSet entitySet = m_DataContext.ndihdJobAnswerSelectFiltered(filter.JobRef,filter.Type, filter.SenderNameRef, filter.SubscriberNameRef, filter.FilterOnSenderNotificationSend, filter.FilterOnSubscriberNotificationSend, filter.Expiredate, filter.FilterOnIsActive);
            result = new JobAnswerContainer(entitySet.Tables[0]);
            TraceCallReturnEvent.Raise();
            return result;
              }
              catch (Exception ex)
              {
            ExceptionManager.Publish(ex);
            TraceCallReturnEvent.Raise(false);
            throw;
              }
        }
        public void JobOfferSetStatus(JobOffer 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
              {
            // Logical checks
            JobOffer selected = base.JobOfferSelect(entity.ID);
            if (selected == null)
              throw new ApplicationException("A megadott azonosítóval nem létezik hirdetés.");

            selected.LastModified = DateTime.Now;
            // Save data
            m_DataContext.ndihdJobOfferSetStatus(entity.ID, entity.Status);

            BusinessAuditEvent.Success(
              new EventParameter("JobOfferID", entity.ID.ToString()),
              new EventParameter("JobOfferStatus", entity.Status),
              new EventParameter("JobOfferLogin", entity.Sender)
              );
            TraceCallReturnEvent.Raise();
            return;
              }
              catch (Exception ex)
              {
            ExceptionManager.Publish(ex);
            BusinessAuditEvent.Fail(
              new EventParameter("Exception", ex.ToString()),
              new EventParameter("JobOfferID", entity.ID.ToString()),
              new EventParameter("JobOfferStatus", entity.Status),
              new EventParameter("JobOfferLogin", entity.Sender)
              );
            TraceCallReturnEvent.Raise(false);
            throw;
              }
        }
Beispiel #22
0
        public new void UserUpdate(User entity)
        {
            // Check permission: Registered or Administrator
              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.LoginName.Length == 0)
              throw new ArgumentNullException("User.LoginName", "A felhasználó bejelentkezési neve nincs megadva.");
            if (entity.Name.Length == 0)
              throw new ArgumentNullException("User.Name", "A felhasználó neve nincs megadva.");
            if (entity.Sex.Length == 0)
              throw new ArgumentNullException("User.Sex", "A felhasználó neme nincs megadva.");
            if (entity.BirthYear.Length == 0)
              throw new ArgumentNullException("User.BirthYear", "A felhasználó születési éve nincs megadva.");
            if (entity.Email.Length == 0)
              throw new ArgumentNullException("User.Email", "A felhasználó e-mail címe nincs megadva.");
            if (entity.QualificationRef.Length == 0)
              throw new ArgumentNullException("User.QualificationRef",
                                          "A felhasználó legmagasabb iskolai végzettsége nincs megadva.");

            // Logical checks
            User selected = base.UserSelect(entity.LoginName);
            if (selected == null)
              throw new ApplicationException("Ezzel a bejelentkezési névvel nem létezik felhasználó.");
            if (! Thread.CurrentPrincipal.IsInRole("Administrator"))
            {
              if (! selected.IsActive)
            throw new ApplicationException("A felhasználó nem aktív.");
            }

            // Save data
            selected.Name = entity.Name;
            selected.Sex = entity.Sex;
            selected.BirthYear = entity.BirthYear;
            selected.Phone = entity.Phone;
            selected.Email = entity.Email;
            selected.Country = entity.Country;
            selected.PostCode = entity.PostCode;
            selected.City = entity.City;
            selected.Address = entity.Address;
            selected.QualificationRef = entity.QualificationRef;
            selected.Graduation = entity.Graduation;
            selected.Profession = entity.Profession;
            selected.Job = entity.Job;
            selected.NewsMail = entity.NewsMail;
            selected.StyleSheet = entity.StyleSheet;
            selected.OrganisationRef = entity.OrganisationRef;
            selected.Right = entity.Right;
            selected.UserAttachments = entity.UserAttachments;
              UserAttachmentService attSrv = new UserAttachmentService(m_DataContext);

            //Csak akkor töröljük a régit, ha volt új
            UserAttachmentContainer oldFiles = base.SelectChildrenByAttachementOfUser(entity.LoginName);
            foreach (UserAttachment oldFile in oldFiles.All)
            {
              if (selected.UserAttachments.CurrentCount > 0)
              {
            attSrv.UserAttachmentDelete(oldFile);
              }
            }
            UserAttachment newFile;
            // EDocumentAttachments - insert:
            foreach (UserAttachment file in  selected.UserAttachments.Current)
            {
              if (file.FileData.Length == 0)
              {
            newFile = attSrv.UserAttachmentSelectFile(file.ID);
              }
              else
              {
            newFile = file;
              }
              newFile.LoginNameRef = selected.LoginName;
              newFile.Name = file.Name;
              newFile.Description = file.Description;
              newFile.CreatedDate = DateTime.Now;

              if (attSrv.UserAttachmentSelect(newFile.ID) != null)
              {
            attSrv.UserAttachmentUpdate(newFile);
              }
              else
              {
            attSrv.UserAttachmentInsert(newFile);
              }
            };

            base.UserUpdate(selected);

            BusinessAuditEvent.Success(
              new EventParameter("LoginName", entity.LoginName)
              );
            TraceCallReturnEvent.Raise();
              }
              catch (Exception ex)
              {
            ExceptionManager.Publish(ex);
            BusinessAuditEvent.Fail(
              new EventParameter("Exception", ex.ToString()),
              new EventParameter("LoginName", entity.LoginName)
              );
            TraceCallReturnEvent.Raise(false);
            throw;
              }
        }
		public void UnionWithNull () 
		{
			PrincipalPermission p1 = new PrincipalPermission ("user", null);
			PrincipalPermission p2 = null;
			PrincipalPermission p3 = (PrincipalPermission) p1.Union (p2);
			AssertEquals ("P1 U null == P1", p1.ToXml ().ToString (), p3.ToXml ().ToString ());
		}
        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;
              }
        }
		public void Union () 
		{
			PrincipalPermission p1 = new PrincipalPermission ("user A", "role A");
			PrincipalPermission p2 = new PrincipalPermission ("user B", "role B", false);
			PrincipalPermission p3 = (PrincipalPermission) p1.Union (p2);
			Assert ("Union.UserA", p3.ToString ().IndexOf ("user A") >= 0);
			Assert ("Union.UserB", p3.ToString ().IndexOf ("user B") >= 0);
		}
        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 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 new void JobOfferInsert(JobOffer entity)
        {
            // check permission: Writer or 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();
              m_DataContext.BeginNestedTran();
              try
              {
            // check required fields:
            if (entity.Description.Length == 0)
              throw new ArgumentNullException("JobOffer.Description", "A hirdetés leírása nincs megadva.");

            entity.Sender = Thread.CurrentPrincipal.Identity.Name;
            entity.Status = JobStatusEnum.ACT;
            entity.NotificationSend = false;
            entity.LastModified = DateTime.Now;
            entity.Created = DateTime.Now;
            base.JobOfferInsert(entity);

            JobOfferAttachmentService attSrv = new JobOfferAttachmentService(m_DataContext);

            // EDocumentAttachments - insert:
            foreach (JobOfferAttachment file in entity.JobOfferAttachments.Current)
            {
              file.JobOfferRef = entity.ID;
              file.IsActive = true;
              file.CreatedDate = DateTime.Now;
              attSrv.JobOfferAttachmentInsert(file);
            }
            m_DataContext.CommitNested();

            #region Találati mail
            entity = JobOfferSelect(entity.ID); // a refid miatt kell

            //Ellenõrizni kell, hogy van-epárja megye, végzettség szerint. Ha van levelet kell küldeni
            //a pár feladójának
            JobFindService srvJobFind = new JobFindService();
            JobFind filter = new JobFind(Guid.Empty);
            filter.RegionRef = entity.RegionRef;
            filter.Qualification = entity.QualificationMinRef;
            filter.Status = JobStatusEnum.ACT;
            //filter.Expiredate = DateTime.Now;
            QualificationService srvQualification = new QualificationService();
            UserService srvUser = new UserService();

            JobFindContainer finds = srvJobFind.JobFindSelectFiltered(filter);
            //Van pár
            foreach (JobFind find in finds.All)
            {
              //Itt meg kell nézni azt is, hogy nem õ-e a másik hirdetés feladója
              if (find.Sender != entity.Sender)
              {

            //értesítjük a feladót, hogy valaki válaszolt a hirdetésére
            //set mail:
            Email mail = new Email(Guid.NewGuid());
            //Subject és body lekérdezése
            string body = "";
            string subject = "";
            EmailTemplateService srvTemplate = new EmailTemplateService();
            srvTemplate.GetEmailTemplateByCode(ref subject, ref body, EmailCategory.JobFindMatchCreated);
            mail.Category = EmailCategory.JobFindMatchCreated;
            mail.Subject = subject;

            User findSender = srvUser.UserSelect(find.Sender);
            if (findSender != null)
            {
              mail.To = findSender.Email;
              body = body.Replace("<FULL_USER_NAME>", findSender.Name);
              body = body.Replace("<JOB_REFID>", entity.RefId.ToString());
              body = body.Replace("<JOB_DESCRIPTION>", entity.Description);
              body = body.Replace("<SENDER_NAME>", entity.ContactName);
              body = body.Replace("<SENDER_MAIL>", entity.ContactEmail);
            }
            mail.MailBody = body;

            if (mail.MailBody != null && mail.To != null && mail.Subject != null)
            {
              // Save data to database
              EmailService emailSrv = new EmailService(m_DataContext);
              m_DataContext.BeginNestedTran();
              try
              {
                emailSrv.EmailInsert(mail);
                m_DataContext.CommitNested();
              }
              catch
              {
                m_DataContext.RollbackNested();
                throw;
              }

              // Sending mail:
              try
              {
                emailSrv.EmailSend(mail.ID);
              }
              catch (Exception ex)
              {
                ExceptionManager.Publish(ex);
                return;
              }
            }
              }
            }

            #endregion
            BusinessAuditEvent.Success(
              new EventParameter("JobOfferID", entity.ID.ToString()),
              new EventParameter("JobOfferLogin", entity.Sender)
              );
            TraceCallReturnEvent.Raise();
            return;
              }
              catch (Exception ex)
              {
            m_DataContext.RollbackNested();
            ExceptionManager.Publish(ex);
            BusinessAuditEvent.Fail(
              new EventParameter("Exception", ex.ToString()),
              new EventParameter("JobOfferID", entity.ID.ToString()),
              new EventParameter("JobOfferLogin", entity.Sender)
              );
            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 ForumItemInsert(ForumItem entity)
        {
            TraceCallEnterEvent.Raise();
              try
              {
            // check required fields:
            if (entity.ID.IsNull)
              throw new ArgumentNullException("ForumItem.ID", "A hozzászólás azonosítója nincs megadva.");
            if (entity.ItemText.Length == 0)
              throw new ArgumentNullException("ForumItem.ItemText", "A hozzászólás neve nincs megadva.");
            if (entity.ForumThreadRef.IsNull)
              throw new ArgumentNullException("ForumItem.ForumThreadRef", "A fórum szál azonosítója nincs megadva.");

            // logical checks:
            ForumThreadService threadSrv = new ForumThreadService();
            ForumThread forumThread = threadSrv.ForumThreadSelect(entity.ForumThreadRef);
            if (forumThread == null)
              throw new ApplicationException("A megadott azonosítóval nem létezik fórum szál.");
            if (!forumThread.IsActive)
              throw new ApplicationException("A fórum szál nem aktív.");

            ForumGroupService groupSrv = new ForumGroupService();
            ForumGroup group = groupSrv.ForumGroupSelect(forumThread.ForumGroupRef);
            if (group == null)
              throw new ApplicationException("A megadott azonosítóval nem létezik fórum téma.");

            // check permission:
            if (!group.VisibleForVisitor)
            {
              PrincipalPermission permReg = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Registered");
              PrincipalPermission permAdmin =
            new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Administrator");
              permReg.Union(permAdmin).Demand();
            }

            // save data:
            entity.IsModerated = false;
            entity.CreatedDate = DBDateTime.Now;
            if (Thread.CurrentPrincipal.Identity.IsAuthenticated)
            {
              entity.CreatedBy = Thread.CurrentPrincipal.Identity.Name;
            }
            else
            {
              if (entity.CreatedBy.Length == 0)
              {
            entity.CreatedBy = "Anonymous";
              }
            }
            base.ForumItemInsert(entity);

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