public bool OrganisationPendingUserAccept(Guid OrgPendingUseID, Guid OrganisationID, string LoginName,
                                              string RejectText)
        {
            //Check permission: Admin
              PrincipalPermission permissionAdm =
            new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Administrator");
              permissionAdm.Demand();

              TraceCallEnterEvent.Raise();
              try
              {
            // Check required fields
            if (OrgPendingUseID == Guid.Empty)
              throw new ArgumentNullException("OrganisationPendingUser.OrgPendingUseID",
                                          "A jóváhagyás azonosítója nincs megadva.");
            if (OrganisationID == Guid.Empty)
              throw new ArgumentNullException("OrganisationPendingUser.OrganisationRef",
                                          "A regisztrálandó szervezet azonosítója nincs megadva.");
            if (LoginName.Length == 0)
              throw new ArgumentNullException("OrganisationPendingUser.LoginNameRef",
                                          "A regisztrálandó felhasználó nincs megadva.");

            // Logical checks
            OrganisationPendingUser selected = base.OrganisationPendingUserSelect(OrgPendingUseID);
            if (selected == null)
              throw new ApplicationException("A megadott azonosítóval nem létezik regisztráció.");
            if (! selected.Status.Equals(RegistrationStatus.New))
              throw new ApplicationException("Csak új státuszú regisztráció bírálható el.");

            // Frissitjük a regisztráció adatait
            selected.SentDate = selected.SentDate;
            selected.DecidedBy = Thread.CurrentPrincipal.Identity.Name;
            selected.DecidedDate = DBDateTime.Now;
            selected.Status = RegistrationStatus.Accepted;
            selected.RejectComment = RejectText;

            //Emailben szereplõ adatok lekkérdezése
            string userEmail = "";
            string userFullName = "";
            string organisationName = "";
            OrganisationService srvOrg = new OrganisationService();
            UserService srvUser = new UserService();
            Organisation org = srvOrg.OrganisationSelect(OrganisationID);
            User u = srvUser.UserSelect(LoginName);

            userEmail = u.Email;
            userFullName = u.Name;
            organisationName = org.Name;

            //set mail:
            Email mail = new Email(Guid.NewGuid());
            mail.Category = EmailCategory.OrganisationPendingUserAccept;
            mail.To = userEmail;

            //Subject és body lekérdezése
            string body = "";
            string subject = "";
            IEmailTemplateService srvTemplate = new EmailTemplateService();
            srvTemplate.GetEmailTemplateByCode(ref subject, ref body, EmailCategory.OrganisationPendingUserAccept);

            mail.Subject = subject;

            body = body.Replace("<FULL_USER_NAME>", userFullName);
            body = body.Replace("<LOGIN_NAME>", LoginName);
            body = body.Replace("<ORGANISATION>", organisationName);
            mail.MailBody = body;

            // Save data to database
            EmailService emailSrv = new EmailService(m_DataContext);
            m_DataContext.BeginNestedTran();
            try
            {
              //eltároljuk a szervezet-felhasználó kapcsolatot
              OrganisationUserService orgUserSrv = new OrganisationUserService(m_DataContext);
              OrganisationUser orgUser = new OrganisationUser(OrganisationID, LoginName);
              orgUser.Right = selected.Right;
              orgUserSrv.OrganisationUserInsert(orgUser);

              base.OrganisationPendingUserUpdate(selected);
              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 false;
            }

            // Log success
            BusinessAuditEvent.Success(
              new EventParameter("OrganisationPendingUser", OrgPendingUseID.ToString()),
              new EventParameter("OrganisationID", OrganisationID.ToString()),
              new EventParameter("LoginName", LoginName)
              );
            TraceCallReturnEvent.Raise();
            return true;
              }
              catch (Exception ex)
              {
            ExceptionManager.Publish(ex);
            BusinessAuditEvent.Fail(
              new EventParameter("OrganisationPendingUser", OrgPendingUseID.ToString()),
              new EventParameter("OrganisationID", OrganisationID.ToString()),
              new EventParameter("LoginName", LoginName)
              );
            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 bool OrganisationPendingUserReject(OrganisationPendingUser entity)
        {
            //Check permission: Admin
              PrincipalPermission permissionAdm =
            new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Administrator");
              permissionAdm.Demand();

              TraceCallEnterEvent.Raise();
              try
              {
            // Check required fields
            if (entity.RejectComment.Length == 0)
              throw new ArgumentNullException("OrganisationPendingUser.RejectComment",
                                          "Az elutasítás indoklása nincs megadva.");

            // Logical checks
            OrganisationPendingUser selected = base.OrganisationPendingUserSelect(entity.ID);
            if (selected == null)
              throw new ApplicationException("A megadott azonosítóhoznemtartozik igénylés.");
            if (! selected.Status.Equals(RegistrationStatus.New))
              throw new ApplicationException("Csak új státuszú regisztráció bírálható el.");

            // Set properties
            selected.DecidedBy = Thread.CurrentPrincipal.Identity.Name;
            selected.DecidedDate = DBDateTime.Now;
            selected.Status = RegistrationStatus.Rejected;
            selected.RejectComment = entity.RejectComment;

            //Emailben szereplõ adatok lekkérdezése
            string userEmail = "";
            string userFullName = "";
            string organisationName = "";
            IOrganisationPendingUserService srvOpu = new OrganisationPendingUserService();
            OrganisationPendingUser opu = srvOpu.OrganisationPendingUserSelect(entity.ID);
            IOrganisationService srvOrg = new OrganisationService();
            IUserService srvUser = new UserService();
            Organisation org = srvOrg.OrganisationSelect(opu.OrganisationRef);
            User u = srvUser.UserSelect(opu.LoginNameRef);

            userEmail = u.Email;
            userFullName = u.Name;
            organisationName = org.Name;

            //set mail:
            Email mail = new Email(Guid.NewGuid());
            mail.Category = EmailCategory.OrganisationRegistrationReject;
            mail.To = userEmail;

            //Subject és body lekérdezése
            string body = "";
            string subject = "";
            IEmailTemplateService srvTemplate = new EmailTemplateService();
            srvTemplate.GetEmailTemplateByCode(ref subject, ref body, EmailCategory.OrganisationRegistrationReject);

            mail.Subject = subject;

            body = body.Replace("<FULL_USER_NAME>", userFullName);
            body = body.Replace("<LOGIN_NAME>", u.LoginName);
            body = body.Replace("<ORGANISATION>", organisationName);
            body = body.Replace("<REJECT_COMMENT>", entity.RejectComment);
            mail.MailBody = body;

            // Save data to database
            EmailService emailSrv = new EmailService(m_DataContext);
            m_DataContext.BeginNestedTran();
            try
            {
              base.OrganisationPendingUserUpdate(selected);
              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 false;
            }

            // Log success
            BusinessAuditEvent.Success(
              new EventParameter("RegisterOrganisationID", entity.ID.ToString()),
              new EventParameter("OrganisationName", organisationName),
              new EventParameter("LoginName", u.LoginName)
              );
            TraceCallReturnEvent.Raise();
            return true;
              }
              catch (Exception ex)
              {
            ExceptionManager.Publish(ex);
            BusinessAuditEvent.Fail(
              new EventParameter("Exception", ex.ToString()),
              new EventParameter("RegisterOrganisationID", entity.ID.ToString())
              );
            TraceCallReturnEvent.Raise(false);
            throw;
              }
        }
        public void JobAnswerInactivateExpired()
        {
            TraceCallEnterEvent.Raise();
              try
              {
            // Save data
            //m_DataContext.ndihdJobFindSetStatus(entity.ID, entity.Status);
            // Save data
            //m_DataContext.ndihdJobFindSetStatus(entity.ID, entity.Status);

            //ki kell keresni azokat az aktív hirdetéseket, amiknek a lejárati dátuma már eljött, de még aktívak
            JobAnswer filter = new JobAnswer(Guid.Empty, "", "", "");
            filter.FilterOnIsActive = 1;
            filter.Expiredate = DateTime.Now;
            //filter.FilterOnSubscriberNotificationSend = 0;
            JobAnswerContainer answers = JobAnswerSelectFiltered(filter);

            string body = "";
            string subject = "";
            EmailTemplateService srvTemplate = new EmailTemplateService();
            srvTemplate.GetEmailTemplateByCode(ref subject, ref body, EmailCategory.JobExpired);
            UserService srvUser = new UserService();
            JobFindService srvFind = new JobFindService();
            JobOfferService srvOff = new JobOfferService();
            foreach (JobAnswer answer in answers.All)
            {
              User subscriber = srvUser.UserSelect(answer.SubscriberNameRef);

              string refId = "";
              string description = "";
              if (answer.Type == JobAnswerTypeEnum.FIN)
              {
            JobFind job = srvFind.JobFindSelect(answer.JobRef);
            if (job != null)
            {
              refId = job.RefId.ToString();
              description = job.Description;
            }
              }
              else
              {
            JobOffer job = srvOff.JobOfferSelect(answer.JobRef);
            if (job != null)
            {
              refId = job.RefId.ToString();
              description = job.Description;
            }
              }
              string bodynew = "";
              //küldünk egy levelet a barátunknak
              bodynew = body.Replace("<FULL_USER_NAME>", subscriber == null ? answer.SubscriberNameRef : subscriber.Name);
              bodynew = bodynew.Replace("<JOB_REFID>", refId);
              bodynew = bodynew.Replace("<JOB_DESCRIPTION>", description);
              bodynew = bodynew.Replace("<JOB_TYPE>", "állásajánlat");
              bodynew = bodynew.Replace("<JOB_DATE>", answer.Expiredate.ToShortDateString());
              if (subscriber == null)
            break;
              SendMailToSender(EmailCategory.JobExpired, bodynew, subject, subscriber.Email, true, answer);
            }
            BusinessAuditEvent.Success();
            TraceCallReturnEvent.Raise("JobAnswerInactivateExpired");
            return;
              }
              catch (Exception ex)
              {
            ExceptionManager.Publish(ex);
            BusinessAuditEvent.Fail("JobAnswerInactivateExpired",
              new EventParameter("Exception", ex.ToString()));
            TraceCallReturnEvent.Raise(false);
            throw;
              }
        }
Beispiel #5
0
        public void NewsmailSend(DBGuid IDVal, bool activityOther,
            bool activityPrevention,
            bool activityRehabilitation,
            bool activityResearch,
            bool  activityNDI,
            bool activityAll)
        {
            // Check permission: admin
              PrincipalPermission permAdmin = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Administrator");
              permAdmin.Demand();

              TraceCallEnterEvent.Raise();
              try
              {
            // Logical checks
            Email selected = base.EmailSelect(IDVal);
            if (selected == null)
              throw new ApplicationException("A megadott azonosítóval nem létezik hírlevél.");
            if (!selected.Sent.IsNull)
              throw new ApplicationException("Ez a levél már el lett küldve.");
            if (!selected.Category.Equals(EmailCategory.Newsmail))
              throw new ApplicationException("Csak hírlevél kategóriájú levél küldhetõ ki.");

            // Get recipients
            string sTo = "";
            //sTo += "*****@*****.**";
            UserService srv = new UserService(m_DataContext);
            UserContainer allData =
              srv.UserSelectOfEmailRecipient(activityOther, activityPrevention, activityRehabilitation, activityResearch, activityNDI,
                                         activityAll);
            for (int i = 0; i < allData.All.Count; i++)
            {
              string sEmail = ((User) allData.All.Items[i]).Email;
              if (sEmail.Length > 0)
              {
            sTo += sEmail;
            sTo += ";";
              }
            }

            if (sTo.Length == 0)
              throw new ApplicationException("Nincs megadható címzett.");
            selected.To = sTo;

            base.EmailUpdate(selected);

            //Itt még az attachementeket is fel kell olvasni
            selected.EmailAttachments = base.SelectChildrenByAttachmentOfEmail(selected.ID);
            // Send mail
            Send(selected);
            selected.Sent = DBDateTime.Now;
            base.EmailUpdate(selected);

            BusinessAuditEvent.Success(
              new EventParameter("EmailID", IDVal),
              new EventParameter("EmailSubject", selected.Subject)
              );
            TraceCallReturnEvent.Raise();
            return;
              }
              catch (Exception ex)
              {
            ExceptionManager.Publish(ex);
            BusinessAuditEvent.Fail(
              new EventParameter("Exception", ex.ToString()),
              new EventParameter("EmailID", IDVal)
              );
            TraceCallReturnEvent.Raise(false);
            throw;
              }
        }
        public bool OrganisationValidateSendEmailByCategory(Organisation entity, string category, string adminMail)
        {
            //Check permission: Admin
              PrincipalPermission permissionAdm =
            new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Administrator");
              permissionAdm.Demand();

              TraceCallEnterEvent.Raise();
              try
              {
            // Logical checks:
            Organisation selected = base.OrganisationSelect(entity.ID);
            if (selected == null)
              throw new ApplicationException("A megadott azonosítóval nem létezik szervezet.");

            //Subject és body lekérdezése
            string body = "";
            string subject = "";
            EmailTemplateService srvTemplate = new EmailTemplateService();
            srvTemplate.GetEmailTemplateByCode(ref subject, ref body, category);

            // Le kell kérdezni a szervezethez tartozó irási joggal rendelkező felhasználókat
            User filter = new User(DBString.Empty);

            filter.Right = "W";
            filter.OrganisationRef = entity.ID;
            filter.IsActive = true;
            filter.FilterOnIsactive = DBInt.Null;
            filter.FilterOnLockedOut = 0;

            // Retrieving data from BusinessServices
            UserService srvUser = new UserService();

            UserContainer allUser = srvUser.UserSelectFiltered(filter);
            if (allUser.AllCount == 0)
            {
              OrganisationService srvOrgUser = new OrganisationService();
              OrganisationUserContainer orgUsers = srvOrgUser.SelectChildrenByOrganisationOfOrganisationUser(selected.ID);
              foreach (OrganisationUser orguser in orgUsers.All)
              {
            User user = srvUser.UserSelect(orguser.LoginNameRef);
            if (allUser[user.HashString()] == null)
              allUser.Add(user);

              }
            }

            foreach (User user in allUser.All)
            {
              string tmpBody = body;

              //set mail:
              Email mail = new Email(Guid.NewGuid());
              mail.Category = category;
              mail.To = user.Email; //"*****@*****.**";
              mail.OrganisationRef = entity.ID;

              tmpBody = tmpBody.Replace("<FULL_USER_NAME>", user.Name);
              tmpBody = tmpBody.Replace("<LOGIN_NAME>", user.LoginName);
              tmpBody = tmpBody.Replace("<ORGANISATION>", selected.Name);

              mail.MailBody = tmpBody;
              mail.Subject = subject;

              SendMail(mail);

            }

            if (!string.IsNullOrEmpty(adminMail)) //küldünk mailt az adminna is
            {
              string tmpBody = body;

              //set mail:
              Email mail = new Email(Guid.NewGuid());
              mail.Category = EmailCategory.ValidationInactivationAdmin;
              mail.To = adminMail; //"*****@*****.**";
              mail.OrganisationRef = entity.ID;

              tmpBody = tmpBody.Replace("<ORGANISATION>", selected.Name);

              mail.MailBody = tmpBody;
              mail.Subject = subject;

              SendMail(mail);
            }
            // Log success
            BusinessAuditEvent.Success(new EventParameter("OrganisationID", entity.ID.ToString()));

            TraceCallReturnEvent.Raise();
            return true;
              }
              catch (Exception ex)
              {
            ExceptionManager.Publish(ex);
            BusinessAuditEvent.Fail(
              new EventParameter("Exception", ex.ToString()),
              new EventParameter("RegisterUserID", entity.ID.ToString())
              );
            TraceCallReturnEvent.Raise(false);
            throw;
              }
        }
        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 void JobFindInactivateExpired()
        {
            TraceCallEnterEvent.Raise();
              try
              {
            // Save data
            //m_DataContext.ndihdJobFindSetStatus(entity.ID, entity.Status);

            //ki kell keresni azokat az aktív hirdetéseket, amiknek a lejárati dátuma már eljött, de még aktívak
            JobFind filter = new JobFind(Guid.Empty);
            filter.Status = JobStatusEnum.ACT;
            filter.Expiredate = DateTime.Now;

            JobFindContainer finds = JobFindSelectFiltered(filter);

            string body = "";
            string subject = "";
            EmailTemplateService srvTemplate = new EmailTemplateService();
            srvTemplate.GetEmailTemplateByCode(ref subject, ref body, EmailCategory.JobExpired);

            UserService srvUser = new UserService();

            foreach (JobFind find in finds.All)
            {
              string bodynew;
              User sender = srvUser.UserSelect(find.Sender);
              find.LastModified = DateTime.Now;
              find.Status = JobStatusEnum.EXP;
              JobFindSetStatus(find); //inaktiváljuk
              //küldünk egy levelet a barátunknak
              bodynew = body.Replace("<FULL_USER_NAME>", sender == null ? find.Sender : sender.Name);
              bodynew = bodynew.Replace("<JOB_REFID>", find.RefId.ToString());
              bodynew = bodynew.Replace("<JOB_DESCRIPTION>", find.Description);
              bodynew = bodynew.Replace("<JOB_TYPE>", "álláskeresés");
              if (sender == null)
            break;
              SendMailToSender(EmailCategory.JobExpired, bodynew, subject, sender.Email, false, find.ID);
            }

            BusinessAuditEvent.Success();
            TraceCallReturnEvent.Raise("JobFindInactivateExpired");
            return;
              }
              catch (Exception ex)
              {
            ExceptionManager.Publish(ex);
            BusinessAuditEvent.Fail("JobFindInactivateExpired",
              new EventParameter("Exception", ex.ToString()));
            TraceCallReturnEvent.Raise(false);
            throw;
              }
        }
        public new void RegisterUserInsert(RegisterUser entity)
        {
            // Check permission: anybody
              TraceCallEnterEvent.Raise();
              try
              {
            if (entity.LoginName.Length == 0)
              throw new ArgumentNullException("RegisterUser.LoginName",
                                          "A regisztrálandó felhasználó bejelentkezési neve nincs megadva.");
            if (entity.Name.Length == 0)
              throw new ArgumentNullException("RegisterUser.Name", "A regisztrálandó felhasználó neve nincs megadva.");
            if (entity.Sex.Length == 0)
              throw new ArgumentNullException("RegisterUser.Sex", "A regisztrálandó felhasználó neme nincs megadva.");
            if (entity.BirthYear.Length == 0)
              throw new ArgumentNullException("RegisterUser.BirthYear",
                                          "A regisztrálandó felhasználó születési éve nincs megadva.");
            if (entity.Email.Length == 0)
              throw new ArgumentNullException("RegisterUser.Email",
                                          "A regisztrálandó felhasználó e-mail címe nincs megadva.");
            if (entity.QualificationRef.Length == 0)
              throw new ArgumentNullException("RegisterUser.QualificationRef",
                                          "A regisztrálandó felhasználó legmagasabb iskolai végzettsége nincs megadva.");
            if (entity.ReasonOfRegistration.Length == 0)
              throw new ArgumentNullException("RegisterUser.ReasonOfRegistration",
                                          "Az adatbázis használatának célja nincs megadva.");

            // Logical checks
            UserService userService = new UserService(m_DataContext);
            if (userService.UserCheckLoginName(entity.LoginName))
              throw new ApplicationException("A megadott bejelentkezési név már foglalt. Kérem válasszon másikat.");

            if (entity.OrganisationRef.IsNull)
            {
              entity.Right = UserRights.NonOrganisation;
            }
            else
            {
              string writerRole = entity.OrganisationRef.Value.ToString() + ".Writer";
              PrincipalPermission permWriter = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, writerRole);
              permWriter.Demand();
              if (entity.Right.Length == 0) entity.Right = UserRights.Read;
            }

            entity.SentDate = DBDateTime.Now;
            entity.Status = RegistrationStatus.New;

            base.RegisterUserInsert(entity);
            // Log success
            BusinessAuditEvent.Success(
              new EventParameter("RegisterUserID", entity.ID.ToString()),
              new EventParameter("LoginName", entity.LoginName)
              );
            TraceCallReturnEvent.Raise();
            return;
              }
              catch (Exception ex)
              {
            ExceptionManager.Publish(ex);
            BusinessAuditEvent.Fail(
              new EventParameter("Exception", ex.ToString()),
              new EventParameter("RegisterUserID", entity.ID.ToString()),
              new EventParameter("LoginName", entity.LoginName)
              );
            TraceCallReturnEvent.Raise(false);
            throw;
              }
        }
        public bool PendingQuestionFormSendBackNew(PendingQuestionForm entity)
        {
            //Check permission: Admin
              PrincipalPermission permissionAdm =
            new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Administrator");
              permissionAdm.Demand();

              TraceCallEnterEvent.Raise();
              try
              {
            //Check required fields
            if (entity.ID.IsNull)
              throw new ArgumentNullException("PendingQuestionForm.ID", "Az elbírálandó kérdõív azonosítója nincs megadva.");
            if (entity.ProgramCategoryId.Length == 0)
              throw new ArgumentNullException("PendingQuestionForm.ProgramCategoryId",
                                          "Az elbírálandó kérdõív kategóriája nincs megadva.");
            if (entity.TemplateRef.IsNull)
              throw new ArgumentNullException("PendingQuestionForm.TemplateRef", "A sablon azonosítója nincs megadva.");
            if (entity.RejectComment.Length == 0)
              throw new ArgumentNullException("PendingQuestionForm.RejectComment", "A visszaküldés indoklása nincs megadva.");

            // Logical checks:
            PendingQuestionForm selected = base.PendingQuestionFormSelect(entity.ID);
            if (selected == null)
              throw new ApplicationException("A megadott azonosítóval nem létezik elbírálandó kérdõív.");
            if (!selected.Status.Equals(QuestionFormStatus.New_WaitingForDecision))
              throw new ApplicationException("Csak jóváhagyásra váró státuszú kérdõív bírálható el.");

            // Set properties
            selected.DecidedBy = Thread.CurrentPrincipal.Identity.Name;
            selected.DecidedDate = DBDateTime.Now;
            selected.Status = QuestionFormStatus.New_SendBack;
            selected.RejectComment = entity.RejectComment;
            selected.QuestionFormRef = entity.QuestionFormRef;
            selected.IsActual = false;
            //Set mail:
            UserService userSrv = new UserService(m_DataContext);
            User sentBy = userSrv.UserSelect(selected.SentBy);
            Email mail = new Email(Guid.NewGuid());
            mail.Category = EmailCategory.QuestionFormInsertSendBack;
            mail.To = sentBy.Email;

            //Subject és body lekérdezése
            string body = "";
            string subject = "";
            EmailTemplateService srvTemplate = new EmailTemplateService();
            srvTemplate.GetEmailTemplateByCode(ref subject, ref body, EmailCategory.QuestionFormInsertSendBack);

            mail.Subject = subject;

            body = body.Replace("<FULL_USER_NAME>", sentBy.Name);
            body = body.Replace("<SENT_DATE>", entity.SentDate.ToString());
            body = body.Replace("<TEMPLATE_NAME>", entity.TemplateName);
            body = body.Replace("<REJECT_COMMENT>", entity.RejectComment);
            mail.MailBody = body;

            // Save data to database
            EmailService emailSrv = new EmailService(m_DataContext);
            m_DataContext.BeginNestedTran();
            try
            {
              base.PendingQuestionFormUpdate(selected);
              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 false;
            }

            // Log success
            BusinessAuditEvent.Success(
              new EventParameter("PendingQuestionFormID", entity.ID.ToString()),
              new EventParameter("ProgramID", entity.ProgramID.ToString()),
              new EventParameter("OrganisationID", entity.OrganisationID.ToString())
              );
            TraceCallReturnEvent.Raise();
            return true;
              }
              catch (Exception ex)
              {
            ExceptionManager.Publish(ex);
            BusinessAuditEvent.Fail(
              new EventParameter("Exception", ex.ToString()),
              new EventParameter("PendingQuestionFormID", entity.ID.ToString()),
              new EventParameter("ProgramID", entity.ProgramID.ToString()),
              new EventParameter("OrganisationID", entity.OrganisationID.ToString())
              );
            TraceCallReturnEvent.Raise(false);
            throw;
              }
        }
        public bool PendingQuestionFormAcceptNew(PendingQuestionForm entity)
        {
            //Check permission: Admin
              PrincipalPermission permissionAdm =
            new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Administrator");
              permissionAdm.Demand();

              TraceCallEnterEvent.Raise();
              try
              {
            //Check required fields
            if (entity.ID.IsNull)
              throw new ArgumentNullException("PendingQuestionForm.ID", "Az elbírálandó kérdõív azonosítója nincs megadva.");
            if (entity.ProgramCategoryId.Length == 0)
              throw new ArgumentNullException("PendingQuestionForm.ProgramCategoryId",
                                          "Az elbírálandó kérdõív kategóriája nincs megadva.");
            if (entity.TemplateRef.IsNull)
              throw new ArgumentNullException("PendingQuestionForm.TemplateRef", "A sablon azonosítója nincs megadva.");
            if (entity.Details.AllCount == 0)
              throw new ArgumentNullException("PendingQuestionForm.Details", "A válaszok nincsenek megadva.");
            if (entity.ProgramCategoryId.Equals("ORG"))
            {
              if (entity.OrganisationID.IsNull)
            throw new ArgumentNullException("PendingQuestionForm.OrganisationID",
                                            "A szervezet azonosítója nincs megadva.");
            }
            else
            {
              if (entity.ProgramID.IsNull)
            throw new ArgumentNullException("PendingQuestionForm.ProgramID", "A program azonosítója nincs megadva.");
            }

            // Logical checks:
            PendingQuestionForm selected = base.PendingQuestionFormSelect(entity.ID);
            if (selected == null)
              throw new ApplicationException("A megadott azonosítóval nem létezik elbírálandó kérdõív.");
            if (!selected.Status.Equals(QuestionFormStatus.New_WaitingForDecision))
              throw new ApplicationException("Csak jóváhagyásra váró státuszú kérdõív bírálható el.");

            // Set properties
            DBGuid questionFormID = Guid.NewGuid();
            QuestionForm questionForm = new QuestionForm(questionFormID);
            questionForm.TemplateRef = entity.TemplateRef;

            selected.DecidedBy = Thread.CurrentPrincipal.Identity.Name;
            selected.DecidedDate = DBDateTime.Now;
            selected.Status = QuestionFormStatus.New_Accepted;
            selected.QuestionFormRef = questionFormID;
            selected.IsActual = true;
            //utolsó módosítás, és elfogadás dátuma
            questionForm.LastModifiedDate = selected.SentDate;
            questionForm.DecidedDate = selected.DecidedDate;
            questionForm.LastModifiedByUser = selected.LastModifiedByUser;
            questionForm.IsActual = true;
            //Set mail:
            string modifiedAnswers = "";
            PendingQuestionFormDetailContainer origAnswers = base.SelectChildrenByDetailOfPendingQuestionForm(entity.ID);
            TemplateDetailService templateDetailService = new TemplateDetailService(m_DataContext);
            foreach (PendingQuestionFormDetail origDetail in origAnswers.All)
            {
              string hash = origDetail.HashString();
              PendingQuestionFormDetail currentDetail = (PendingQuestionFormDetail) entity.Details[hash];
              if (currentDetail != null)
              {
            if (!origDetail.Answer.Equals(currentDetail.Answer))
            {
              TemplateDetail question =
                templateDetailService.TemplateDetailSelect(origDetail.TemplateDetailRef, origDetail.TemplateRef);
              modifiedAnswers += "Kérdés:  " + question.Question + "\n";
              modifiedAnswers += "  Eredeti válasz:    " + origDetail.Answer + "\n";
              modifiedAnswers += "  Módosított válasz: " + currentDetail.Answer + "\n\n";
            }
              }
            }
            if (modifiedAnswers.Length == 0)
            {
              modifiedAnswers = "  A jóváhagyó módosítás nélkül fogadta el a kitöltött kérdõívet.\n";
            }

            UserService userSrv = new UserService(m_DataContext);
            User sentBy = userSrv.UserSelect(selected.SentBy);
            Email mail = new Email(Guid.NewGuid());
            mail.Category = EmailCategory.QuestionFormInsertAccept;
            mail.To = sentBy.Email;

            //Subject és body lekérdezése
            string body = "";
            string subject = "";
            EmailTemplateService srvTemplate = new EmailTemplateService();
            srvTemplate.GetEmailTemplateByCode(ref subject, ref body, EmailCategory.QuestionFormInsertAccept);

            mail.Subject = subject;

            body = body.Replace("<FULL_USER_NAME>", sentBy.Name);
            body = body.Replace("<SENT_DATE>", entity.SentDate.ToString());
            body = body.Replace("<TEMPLATE_NAME>", entity.TemplateName);
            body = body.Replace("<MODIFIED_ANSWERS>", modifiedAnswers);
            mail.MailBody = body;

            // Save data to database
            EmailService emailSrv = new EmailService(m_DataContext);
            QuestionFormService questionFormService = new QuestionFormService(m_DataContext);
            ProgramQuestionFormService programQuestionFormService = new ProgramQuestionFormService(m_DataContext);
            OrganisationQuestionFormService organisationQuestionFormService =
              new OrganisationQuestionFormService(m_DataContext);
            QuestionFormDetailService questionFormDetailService = new QuestionFormDetailService(m_DataContext);
            m_DataContext.BeginNestedTran();
            try
            {
              questionFormService.QuestionFormInsert(questionForm);
              base.PendingQuestionFormUpdate(selected);

              if (entity.ProgramCategoryId.Equals("ORG"))
              {
            OrganisationQuestionForm organisationQuestionForm =
              new OrganisationQuestionForm("ORG", entity.OrganisationID, questionFormID);

            //organisationQuestionForm.QuestionFormRef = questionFormID;
            organisationQuestionFormService.OrganisationQuestionFormInsert(organisationQuestionForm);
              }
              else
              {
            ProgramQuestionForm programQuestionForm =
              new ProgramQuestionForm(entity.ProgramCategoryId, entity.ProgramID, questionFormID);
            //programQuestionForm.QuestionFormRef = questionFormID;
            programQuestionFormService.ProgramQuestionFormInsert(programQuestionForm);
              }

              foreach (PendingQuestionFormDetail pendingDetail in entity.Details.All)
              {
            QuestionFormDetail detail =
              new QuestionFormDetail(questionFormID, pendingDetail.TemplateDetailRef, entity.TemplateRef);
            detail.Answer = pendingDetail.Answer;
            detail.FreetextId = Guid.NewGuid();
            questionFormDetailService.QuestionFormDetailInsert(detail);
              }

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

            // Log success
            BusinessAuditEvent.Success(
              new EventParameter("PendingQuestionFormID", entity.ID.ToString()),
              new EventParameter("ProgramID", entity.ProgramID.ToString()),
              new EventParameter("OrganisationID", entity.OrganisationID.ToString())
              );
            TraceCallReturnEvent.Raise();
            return true;
              }
              catch (Exception ex)
              {
            ExceptionManager.Publish(ex);
            BusinessAuditEvent.Fail(
              new EventParameter("Exception", ex.ToString()),
              new EventParameter("PendingQuestionFormID", entity.ID.ToString()),
              new EventParameter("ProgramID", entity.ProgramID.ToString()),
              new EventParameter("OrganisationID", entity.OrganisationID.ToString())
              );
            TraceCallReturnEvent.Raise(false);
            throw;
              }
        }
        /// Megállítja az órát amíg lekérdezi az adatbázisból a leveleket, kiválogatja közülük az el nem
        /// küldötteket és meghívja rájuk a SendMail metodust, majd újraindítja az órát.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="System.Timers.ElapsedEventArgs"/> instance containing the event data.</param>
        private void NewsMailServiceTimerTick(object sender, ElapsedEventArgs e)
        {
            if (_firstNews)
              {

            #region időzítő beállítása a mail funkcióhoz
            try
            {
              string intervallString = ConfigurationManager.AppSettings["RssNewsMailTimerIntervall"];
              double intervall = 150000;
              try
              {
            intervall = Convert.ToDouble(intervallString);
            _newsMailTimer.Interval = intervall;
              }
              catch (Exception)
              {

              }
              _newsMailTimer.AutoReset = true;
              _newsMailTimer.Enabled = true;
              EventLog.WriteEntry("Ndi.HelpDesk.HostingServiceNewsMailServiceTimerTick started!");
              _firstNews = false;
            }

            catch (Exception ex)
            {
              EventLog.WriteEntry("Ndi.HelpDesk.HostingService_NewsMailServiceTimerTick", ex.ToString(), EventLogEntryType.Error, 2001);
            }
            #endregion

              }
              try
              {
            _newsMailTimer.Stop();
            //meg kell nézni, hogy kell-e most küldeni
            string intervallString = ConfigurationManager.AppSettings["RssNewsMailSendingDay"];
            DayOfWeek dayOfweek = DayOfWeek.Monday;
            switch (intervallString)
            {
              case "H":
            dayOfweek = DayOfWeek.Monday;
            break;
              case "K":
            dayOfweek = DayOfWeek.Tuesday;
            break;
              case "SZE":
            dayOfweek = DayOfWeek.Wednesday;
            break;
              case "CS":
            dayOfweek = DayOfWeek.Thursday;
            break;
              case "P":
            dayOfweek = DayOfWeek.Friday;
            break;
              case "SZO":
            dayOfweek = DayOfWeek.Saturday;
            break;
              case "V":
            dayOfweek = DayOfWeek.Sunday;
            break;
            }
            //ha ma az a nap van
            if (DateTime.Today.DayOfWeek == dayOfweek)
            {
              NameValueCollection collServFact = (NameValueCollection)ConfigurationManager.GetSection("PafiCompetition");
              if (collServFact != null)
              {
            string rssFeddUrl = collServFact["RssUrl"];
            string template = collServFact["RssTemplate"];
            string itemTemplate = collServFact["RssItemTemplate"];
            IIdentity identity = new GenericIdentity("NDIService");
            string[] roles = { "Administrator" };
            NdiPrincipal principal =
              new NdiPrincipal(identity, roles, "NDIService");
            Thread.CurrentPrincipal = principal;

            //megnézzük, hogy mamár próbáltunk-e küldeni
            IEmailService srvEmail = ServiceFactory.GetEmailService();
            Email filter = new Email(Guid.Empty);
            filter.Category = EmailCategory.NewsMailRSS;
            DateTime dateFrom = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day - 1, 23, 59, 59);
            DateTime dateTo = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 23, 59, 59);
            filter.FilterOnSentFrom = dateFrom;
            filter.FilterOnSentTo = dateTo;
            EmailContainer emails = srvEmail.EmailSelectFiltered(filter);
            if (emails.AllCount == 0) // ma még nem küldtünk
            {
              RssFeedPafi feed = RssReaderPafi.GetFeed(rssFeddUrl);
              if (feed.ErrorMessage == null || feed.ErrorMessage == "")
              {
                string html = RssReaderPafi.CreateHtml(feed, template, itemTemplate, "", 5);
                html = html.Replace("\\n", "\n");
                string body = "";
                string subject = "";
                IEmailTemplateService srvTemplate = ServiceFactory.GetEmailTemplateService();
                srvTemplate.GetEmailTemplateByCode(ref subject, ref body, EmailCategory.NewsMailRSS);
                UserService srvUser = new UserService();
                UserContainer users = srvUser.UserSelectOfEmailRecipient(true, true, true, true, true, true);
                string to = "";
                for (int i = 0; i < users.All.Count; i++)
                {
                  string sEmail = ((User)users.All.Items[i]).Email;
                  if (sEmail.Length > 0)
                  {
                    if (to.IndexOf(sEmail) == -1)
                    {
                      to += sEmail;
                      to += ";";
                    }
                  }
                }
                if (to.Length > 0)
                {
                  //set mail:
                  Email mail = new Email(Guid.NewGuid());

                  mail.Category = EmailCategory.NewsMailRSS;
                  mail.Subject = subject;
                  mail.To = to;
                  mail.MailBody = html;

                  if (mail.MailBody != null && mail.To != null && mail.Subject != null)
                  {
                    // Save data to database
                    IEmailService emailSrv = ServiceFactory.GetEmailService();
                    emailSrv.EmailInsert(mail);
                    try
                    {
                      // Sending mail:
                      emailSrv.EmailSend(mail.ID);
                    }
                    catch (Exception)
                    {

                    }

                  }
                }
              }
            }
              }
            }
              }
              catch (Exception ex)
              {
            EventLog.WriteEntry("Ndi.HelpDesk.HostingService_NewsMailServiceTimerTick", ex.ToString(),
                            EventLogEntryType.Error, 2001);
              }
              finally
              {
            _newsMailTimer.Start();
              }
        }
        public void RegisterOrganisationInsertToLogin(RegisterOrganisation entity)
        {
            // Check permission: anybody

              TraceCallEnterEvent.Raise();
              try
              {
            // Check required fields
            if (entity.Name.Length == 0)
              throw new ArgumentNullException("RegisterOrganisation.Name", "A regisztrálandó szervezet neve nincs megadva.");
            if (entity.RegionRef.Length == 0)
              throw new ArgumentNullException("RegisterOrganisation.RegionRef", "A megye kódja nincs megadva.");
            if (entity.WorkingAreaRef.Length == 0)
              throw new ArgumentNullException("RegisterOrganisation.WorkingAreaRef", "A mûködési terület nincs megadva.");
            if (entity.OrganisationFormRef.Length == 0)
              throw new ArgumentNullException("RegisterOrganisation.OrganisationFormRef",
                                          "A szervezeti forma nincs megadva.");
            if (entity.PostCode.Length == 0)
              throw new ArgumentNullException("RegisterOrganisation.PostCode",
                                          "A szervezet címének irányítószáma nincs megadva.");
            if (entity.City.Length == 0)
              throw new ArgumentNullException("RegisterOrganisation.City",
                                          "A szervezet címének település része nincs megadva.");
            if (entity.Address.Length == 0)
              throw new ArgumentNullException("RegisterOrganisation.Address",
                                          "A szervezet címének utca, házszám része nincs megadva.");

            if (entity.LoginName.Length == 0)
              throw new ArgumentNullException("RegisterOrganisation.LoginName", "A felhasználó login neve nincs megadva.");

            // Logical checks
            UserService userService = new UserService(m_DataContext);
            if (userService.UserCheckLoginName(entity.LoginName) == false)
            {
              throw new ApplicationException("A megadott bejelentkezési név nem létezik.");
            }

            // Set properties
            entity.SentDate = DBDateTime.Now;
            entity.Status = RegistrationStatus.New;

            //egy már létezõ regisztrált felhasználóhoz rendeljük a szervezetet
            entity.IsUserRegistred = true;

            // Save data to database
            base.RegisterOrganisationInsert(entity);

            // Log success
            BusinessAuditEvent.Success(
              new EventParameter("RegisterOrganisationID", entity.ID.ToString()),
              new EventParameter("OrganisationName", entity.Name),
              new EventParameter("LoginName", entity.LoginName)
              );
            TraceCallReturnEvent.Raise();
            return;
              }
              catch (Exception ex)
              {
            ExceptionManager.Publish(ex);
            BusinessAuditEvent.Fail(
              new EventParameter("Exception", ex.ToString()),
              new EventParameter("RegisterOrganisationID", entity.ID.ToString()),
              new EventParameter("OrganisationName", entity.Name),
              new EventParameter("LoginName", entity.LoginName)
              );
            TraceCallReturnEvent.Raise(false);
            throw;
              }
        }
        public new void RegisterOrganisationInsert(RegisterOrganisation entity)
        {
            // Check permission: anybody

              TraceCallEnterEvent.Raise();
              try
              {
            // Check required fields
            if (entity.Name.Length == 0)
              throw new ArgumentNullException("RegisterOrganisation.Name", "A regisztrálandó szervezet neve nincs megadva.");
            if (entity.RegionRef.Length == 0)
              throw new ArgumentNullException("RegisterOrganisation.RegionRef", "A megye kódja nincs megadva.");
            if (entity.WorkingAreaRef.Length == 0)
              throw new ArgumentNullException("RegisterOrganisation.WorkingAreaRef", "A mûködési terület nincs megadva.");
            if (entity.OrganisationFormRef.Length == 0)
              throw new ArgumentNullException("RegisterOrganisation.OrganisationFormRef",
                                          "A szervezeti forma nincs megadva.");
            if (entity.PostCode.Length == 0)
              throw new ArgumentNullException("RegisterOrganisation.PostCode",
                                          "A szervezet címének irányítószáma nincs megadva.");
            if (entity.City.Length == 0)
              throw new ArgumentNullException("RegisterOrganisation.City",
                                          "A szervezet címének település része nincs megadva.");
            if (entity.Address.Length == 0)
              throw new ArgumentNullException("RegisterOrganisation.Address",
                                          "A szervezet címének utca, házszám része nincs megadva.");

            if (entity.LoginName.Length == 0)
              throw new ArgumentNullException("RegisterOrganisation.LoginName", "A felhasználó login neve nincs megadva.");
            if (entity.UserName.Length == 0)
              throw new ArgumentNullException("RegisterOrganisation.UserName", "A felhasználó neve nincs megadva.");
            if (entity.UserSex.Length == 0)
              throw new ArgumentNullException("RegisterOrganisation.Sex", "A regisztrálandó felhasználó neme nincs megadva.");
            if (entity.UserBirthYear.Length == 0)
              throw new ArgumentNullException("RegisterOrganisation.BirthYear",
                                          "A regisztrálandó felhasználó születési éve nincs megadva.");
            if (entity.UserEmail.Length == 0)
              throw new ArgumentNullException("RegisterOrganisation.UserEmail", "A felhasználó e-mail címe nincs megadva.");
            if (entity.QualificationRef.Length == 0)
              throw new ArgumentNullException("RegisterOrganisation.QualificationRef",
                                          "A regisztrálandó felhasználó legmagasabb iskolai végzettsége nincs megadva.");
            if (entity.ReasonOfRegistration.Length == 0)
              throw new ArgumentNullException("RegisterOrganisation.ReasonOfRegistration",
                                          "Az adatbázis használatának célja nincs megadva.");

            // Logical checks
            UserService userService = new UserService(m_DataContext);
            if (userService.UserCheckLoginName(entity.LoginName))
              throw new ApplicationException("A megadott bejelentkezési név már foglalt. Kérem válasszon másikat.");

            // Set properties
            entity.SentDate = DBDateTime.Now;
            entity.Status = RegistrationStatus.New;

            // Save data to database
            base.RegisterOrganisationInsert(entity);

            // Log success
            BusinessAuditEvent.Success(
              new EventParameter("RegisterOrganisationID", entity.ID.ToString()),
              new EventParameter("OrganisationName", entity.Name),
              new EventParameter("LoginName", entity.LoginName)
              );
            TraceCallReturnEvent.Raise();
            return;
              }
              catch (Exception ex)
              {
            ExceptionManager.Publish(ex);
            BusinessAuditEvent.Fail(
              new EventParameter("Exception", ex.ToString()),
              new EventParameter("RegisterOrganisationID", entity.ID.ToString()),
              new EventParameter("OrganisationName", entity.Name),
              new EventParameter("LoginName", entity.LoginName)
              );
            TraceCallReturnEvent.Raise(false);
            throw;
              }
        }