Exemplo n.º 1
0
        public EmailContainer EmailSelectFiltered(Email filter)
        {
            // Check permission: admin
              PrincipalPermission permAdmin = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Administrator");
              permAdmin.Demand();

              TraceCallEnterEvent.Raise();
              try
              {
            EmailContainer result;
            DataSet entitySet = m_DataContext.ndihdEmailSelectFiltered(
              filter.Category,
              filter.FilterOnSentFrom,
              filter.FilterOnSentTo,
              filter.FilterOnActivityPrevention,
              filter.FilterOnActivityResearch,
              filter.FilterOnActivityRehabilitation,
              filter.FilterOnActivityOther,
              filter.FilterOnNDI,
              filter.FilterOnActivityAll
              );
            result = new EmailContainer(entitySet.Tables[0]);
            TraceCallReturnEvent.Raise();
            return result;
              }
              catch (Exception ex)
              {
            ExceptionManager.Publish(ex);
            TraceCallReturnEvent.Raise(false);
            throw;
              }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Sends the mail to subscriber.
        /// </summary>
        /// <param name="category">The category.</param>
        /// <param name="body">The body.</param>
        /// <param name="subject">The subject.</param>
        /// <param name="emailTo">The email to.</param>
        /// <param name="mustUpdate">if set to <c>true</c> [must update].</param>
        /// <param name="answer">The id.</param>
        private void SendMailToSender(string category, string body, string subject, string emailTo, bool mustUpdate, JobAnswer answer)
        {
            //set mail:
              Email mail = new Email(Guid.NewGuid());

              mail.Category = category;
              mail.Subject = subject;
              mail.To = emailTo;
              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);
              JobAnswerService srv = new JobAnswerService(m_DataContext);
              JobAnswer job = srv.JobAnswerSelect(answer.JobRef, answer.Type, answer.SubscriberNameRef, answer.SenderNameRef);
              if (job != null)
              {
            if (mustUpdate)
            {
              job.IsActive = false;

            }
            else
            {
              job.SenderNotificationSend = true;
            }
            srv.JobAnswerUpdate(job);
              }
              m_DataContext.CommitNested();
            }
            catch
            {
              m_DataContext.RollbackNested();
              throw;
            }

            // Sending mail:
            try
            {
              emailSrv.EmailSend(mail.ID);
            }
            catch (Exception ex)
            {
              ExceptionManager.Publish(ex);
              return;
            }
              }
        }
        public bool RegisterOrganisationToUserAccept(RegisterOrganisation entity)
        {
            //Check permission: Admin
              PrincipalPermission permissionAdm =
            new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Administrator");
              permissionAdm.Demand();

              TraceCallEnterEvent.Raise();
              try
              {
            // Check required fields
            // Organisation
            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 regisztrálandó szervezet megyéje nincs megadva.");
            if (entity.WorkingAreaRef.Length == 0)
              throw new ArgumentNullException("RegisterOrganisation.WorkingAreaRef",
                                          "A regisztrálandó szervezet mûködési területe nincs megadva.");
            if (entity.OrganisationFormRef.Length == 0)
              throw new ArgumentNullException("RegisterOrganisation.OrganisationFormRef",
                                          "A regisztrálandó szervezet szervezeti formája nincs megadva.");
            if (entity.ReasonOfRegistration.Length == 0)
              throw new ArgumentNullException("RegisterOrganisation.ReasonOfRegistration",
                                          "Az adatbázis használatának célja 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.");

            // User
            if (entity.LoginName.Length == 0)
              throw new ArgumentNullException("RegisterOrganisation.LoginName",
                                          "A regisztrálandó felhasználó bejelentkezési neve nincs megadva.");
            if (entity.UserName.Length == 0)
              throw new ArgumentNullException("RegisterOrganisation.UserName",
                                          "A regisztrálandó felhasználó neve nincs megadva.");
            if (entity.UserSex.Length == 0)
              throw new ArgumentNullException("RegisterOrganisation.UserSex",
                                          "A regisztrálandó felhasználó neme nincs megadva.");
            if (entity.UserBirthYear.Length == 0)
              throw new ArgumentNullException("RegisterOrganisation.UserBirthYear",
                                          "A regisztrálandó felhasználó születési éve nincs megadva.");
            if (entity.UserEmail.Length == 0)
              throw new ArgumentNullException("RegisterOrganisation.UserEmail",
                                          "A regisztrálandó 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.");

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

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

            Organisation newOrg = new Organisation(entity.ID);
            newOrg.Name = entity.Name;
            newOrg.Department = entity.Department;
            newOrg.PostCode = entity.PostCode;
            newOrg.City = entity.City;
            newOrg.Address = entity.Address;
            newOrg.Country = entity.Country;
            newOrg.Phone1 = entity.Phone1;
            newOrg.Fax = entity.Fax;
            newOrg.Email1 = entity.Email1;
            newOrg.HomePage = entity.HomePage;
            newOrg.RegionRef = entity.RegionRef;
            newOrg.WorkingAreaRef = entity.WorkingAreaRef;
            newOrg.WorkingAreaOther = entity.WorkingAreaOther;
            newOrg.OrganisationFormRef = entity.OrganisationFormRef;
            newOrg.ActivityPrevention = entity.ActivityPrevention;
            newOrg.ActivityRehabilitation = entity.ActivityRehabilitation;
            newOrg.ActivityResearch = entity.ActivityResearch;
            newOrg.ActivityOther = entity.ActivityOther;
            newOrg.SourceGovernment = 0;
            newOrg.SourceCompetition = 0;
            newOrg.SourceSponsor = 0;
            newOrg.SourceDonation = 0;
            newOrg.SourceTax = 0;
            newOrg.SourceOther = 0;
            newOrg.IsActive = true;
            // defaults
            newOrg.WorkersFix = 0;
            newOrg.WorkersExternal = 0;
            newOrg.WorkersVolunteer = 0;
            newOrg.JobPsychologist = 0;
            newOrg.JobPsychiater = 0;
            newOrg.JobDoctor = 0;
            newOrg.JobMedicalExpert = 0;
            newOrg.JobHealthExpert = 0;
            newOrg.JobSociologist = 0;
            newOrg.JobSocialPolitician = 0;
            newOrg.JobSocialWorker = 0;
            newOrg.JobSocialPedagogist = 0;
            newOrg.JobPedagogist = 0;
            newOrg.JobManualist = 0;
            newOrg.JobLawyer = 0;
            newOrg.JobPoliceman = 0;
            newOrg.JobMentalhygiene = 0;
            newOrg.JobCultureOrganizer = 0;
            newOrg.JobOther1 = 0;
            newOrg.JobOther2 = 0;
            newOrg.JobOther3 = 0;
            newOrg.IsActual = true;
            newOrg.LastModified = DateTime.Now;
            //set mail:
            Email mail = new Email(Guid.NewGuid());
            mail.Category = EmailCategory.OrganisationRegistrationAccept;
            mail.To = entity.UserEmail;

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

            mail.Subject = subject;

            body = body.Replace("<FULL_USER_NAME>", entity.Name);
            body = body.Replace("<LOGIN_NAME>", entity.LoginName);
            body = body.Replace("<ORGANIZATION>", newOrg.Name);

            mail.MailBody = body;

            // Save data to database
            EmailService emailSrv = new EmailService(m_DataContext);
            m_DataContext.BeginNestedTran();
            try
            {
              //elmentjük a szervezet adatait
              OrganisationService orgSrv = new OrganisationService(m_DataContext);
              orgSrv.OrganisationInsert(newOrg);

              //eltároljuk a szervezet-felhasználó kapcsolatot
              OrganisationUserService orgUserSrv = new OrganisationUserService(m_DataContext);
              OrganisationUser orgUser = new OrganisationUser(newOrg.ID, entity.LoginName);
              orgUser.Right = UserRights.Write;
              orgUserSrv.OrganisationUserInsert(orgUser);

              base.RegisterOrganisationUpdate(entity);
              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("OrganisationID", newOrg.ID.ToString()),
              new EventParameter("OrganisationName", entity.Name),
              new EventParameter("LoginName", entity.LoginName)
              );
            TraceCallReturnEvent.Raise();
            return true;
              }
              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 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;
              }
        }
Exemplo n.º 5
0
        // -------------------------------------------------------------------------------------
        /// <summary>
        /// Form load event. If CurrentID is specified we are in update mode, so we must init
        /// then control's values.
        /// </summary>
        // -------------------------------------------------------------------------------------
        private void frmEmailEdit_Load(object sender, EventArgs e)
        {
            if (m_IsNewsMail == true)
              {
            IEmailTemplateService srvTemplate = ServiceFactory.GetEmailTemplateService();
            txtCategory.Text = srvTemplate.EmailTemplateSelect(EmailCategory.Newsmail).Name;

            //CurrentID = new DBGuid(Guid.NewGuid());
            m_currentMail = new Email(CurrentID);
            FillDatagrid(DBGuid.Null);

            btnSend.Enabled = false;
            btnOk.Enabled = false;
              }
              else
              {
            IEmailService srv = ServiceFactory.GetEmailService();
            m_currentMail = srv.EmailSelect(CurrentID);

            // Fill controls
            RetrieveData();
              }
        }
Exemplo n.º 6
0
        // -------------------------------------------------------------------------------------
        /// <summary>
        /// fill edit window controls
        /// </summary>
        // -------------------------------------------------------------------------------------
        private void RetrieveData()
        {
            try
              {
            IEmailAttachmentService attSrv = ServiceFactory.GetEmailAttachmentService();
            IEmailService srv = ServiceFactory.GetEmailService();

            // Get data
            if (m_currentMail == null)
            {
              m_currentMail = srv.EmailSelect(CurrentID);
            }
            m_currentMail.EmailAttachments = srv.SelectChildrenByAttachmentOfEmail(CurrentID);
            EmailAttachmentContainer avaiableFiles = new EmailAttachmentContainer();
            foreach (EmailAttachment file in m_currentMail.EmailAttachments.All)
            {
              EmailAttachment oldFile = attSrv.EmailAttachmentSelectFile(file.ID);
              if (oldFile.FileData != null && oldFile.FileData.Length > 0)
              {
            file.FileData = oldFile.FileData;
            file.FileSize = oldFile.FileSize;
            if (!avaiableFiles.All.Items.Contains(file))
            {
              avaiableFiles.Add(file);
            }
              }
            }
            m_currentMail.EmailAttachments = avaiableFiles;
            // Fill the controls
            if (! m_currentMail.To.IsNull)
            {
              string[] sTos = ((string) m_currentMail.To.ToString()).Split(';');
              Array arTo = (Array) sTos;
              for (int i = 0; i < arTo.Length; i ++)
              {
            lstTo.Items.Add((object) arTo.GetValue(i));
              }
            }
            txtCC.Text = m_currentMail.Cc;
            txtSubject.Text = m_currentMail.Subject;
            txtMailBody.Text = m_currentMail.MailBody;

            IEmailTemplateService srvTemplate = ServiceFactory.GetEmailTemplateService();

            txtCategory.Text = srvTemplate.EmailTemplateSelect(m_currentMail.Category.ToString()).Name;
            if (!m_currentMail.Category.Equals(EmailCategory.Newsmail))
            {
              tabPageAttachment.Parent.Controls.Remove(tabPageAttachment);
              m_IsNewsMail = false;
              btnOk.Visible = false;
              txtMailBody.Enabled = false;
              txtSubject.Enabled = false;
              grpCategory.Enabled = false;
              cbxOrgActOther.Enabled = false;
              cbxOrgActPrevention.Enabled = false;
              cbxOrgActRehabilitation.Enabled = false;
              cbxOrgActResearch.Enabled = false;
              cbxAll.Enabled = false;
            }
            else
            {
              grpCategory.Enabled = true;
              cbxOrgActOther.Checked = m_currentMail.ActivityOther;
              cbxOrgActPrevention.Checked = m_currentMail.ActivityPrevention;
              cbxOrgActRehabilitation.Checked = m_currentMail.ActivityRehabilitation;
              cbxOrgActResearch.Checked = m_currentMail.ActivityResearch;
              cbxAll.Checked = m_currentMail.ActivityAll;

              GetEmailRecipients();
            }
            if (!m_currentMail.Sent.IsNull)
            {
              txtSent.Text = m_currentMail.Sent.ToString();
              btnSend.Visible = false;
              btnOk.Visible = false;
              btnCancel.Text = "Bezár";
              txtMailBody.Enabled = false;
              txtSubject.Enabled = false;
              grpCategory.Enabled = false;
              cbxOrgActOther.Enabled = false;
              cbxOrgActPrevention.Enabled = false;
              cbxOrgActRehabilitation.Enabled = false;
              cbxOrgActResearch.Enabled = false;
              cbxAll.Enabled = false;
              if (tabPageAttachment != null)
              {
            tabPageAttachment.Enabled = false;
              }
            }
            FillDatagrid(DBGuid.Null);
              }
              catch (Exception ex)
              {
            //	---	Log exception
            ExceptionManager.Publish(ex);
            //	---	Display Exception
            ErrorHandler.DisplayError("Hiba lépett fel az adatok lekérdezése során", ex);
            //	---	invisible btnOk button
            btnOk.Visible = false;
              }
        }
Exemplo n.º 7
0
        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;
              }
        }
Exemplo n.º 8
0
        /// <summary>
        /// Sends an e-mail via SMTP.
        /// </summary>
        /// <param name="entity">Email entity to send</param>
        public void Send(Email entity)
        {
            MailMessage mailMessage = new MailMessage();
              mailMessage.From = Configuration.MailFrom;

              //entity.To = "[email protected];[email protected];";

              //mailMessage.Bcc = entity.To;
              if (entity.Cc.Length > 0)
              {
            mailMessage.Cc = entity.Cc;
              }
              mailMessage.Subject = entity.Subject;
              mailMessage.Body = entity.MailBody;
              mailMessage.BodyFormat = MailFormat.Text;
              mailMessage.BodyEncoding = Encoding.UTF8;
              entity.EmailAttachments = base.SelectChildrenByAttachmentOfEmail(entity.ID);

              //
              // A csatolt file-ok küldéséhez egy  könyvtat hozunk létre és majd ide másoljuk a
              // levélhez csatolandó file-okat
              //
              string sendEmailTempDirPath = "EmailAttachments";
              string fileDir = Path.Combine(Configuration.FileStoreFolder, "Emails\\" + entity.ID.Value.ToString());
              DirectoryInfo di = new DirectoryInfo(fileDir);

              di.CreateSubdirectory(sendEmailTempDirPath);

              foreach (EmailAttachment attachment in entity.EmailAttachments.All)
              {
            string fileFullPath = Path.Combine(fileDir, attachment.ID.Value.ToString());

            //
            // Átmásoljuk és átnevezzük a file-okat
            //
            EmailAttachmentService s = new EmailAttachmentService();
            EmailAttachment ea = s.EmailAttachmentSelect(attachment.ID);

            string sendFileFullPath = Path.Combine(fileDir, Path.Combine(sendEmailTempDirPath, ea.Path));
            string fileExtension = ea.Path.Substring(ea.Path.LastIndexOf("."));

            // File-ok másolása ...
            File.Copy(fileFullPath + fileExtension, sendFileFullPath, true);

            MailAttachment mailAttachment = new MailAttachment(sendFileFullPath);
            mailMessage.Attachments.Add(mailAttachment);
              }

              // TODO: ReplyTo mezot így lehet kitölteni
              // Ezt a konfigba is ki kell vezetni
              //mailMessage.Headers.Add( "Reply-To", "*****@*****.**");

              // elmentjük az entitást ... sikertelen küldé esetére
              base.EmailUpdate(entity);
            #if (!DEBUG)
              //
              // A spamszűrés elkerülése érdekében egyessével küldjük ki az e-mail-eket
              //
              SmtpMail.SmtpServer = Configuration.SmtpServer;
              string origSendTo = entity.To;
              string[] sendTo = origSendTo.Split(';');

              for (int i = 0; i < sendTo.Length; i++)
              {
            if (sendTo[i] != "")
            {
              mailMessage.To = sendTo[i];

              SmtpMail.Send(mailMessage);

            }
              }
            #endif
        }
Exemplo n.º 9
0
 public virtual void EmailUpdate(Email entity)
 {
     TraceCallEnterEvent.Raise();
       try
       {
     m_DataContext.BeginNestedTran();
     try
     {
       int count;
       m_DataContext.ndihdEmailUpdate(entity.ID,
                                  entity.Subject,
                                  entity.To,
                                  entity.Cc,
                                  entity.MailBody,
                                  entity.Sent,
                                  entity.Category,
                                  entity.ActivityPrevention,
                                  entity.ActivityResearch,
                                  entity.ActivityRehabilitation,
                                  entity.ActivityOther, entity.ActivityNDI,
                                  entity.ActivityAll,
                                  entity.OrganisationRef, out count);
       if (count == 0) throw new ServiceUpdateException();
       m_DataContext.CommitNested();
     }
     catch
     {
       m_DataContext.RollbackNested();
       throw;
     }
     TraceCallReturnEvent.Raise();
     return;
       }
       catch (Exception ex)
       {
     ExceptionManager.Publish(ex);
     TraceCallReturnEvent.Raise(false);
     throw;
       }
 }
Exemplo n.º 10
0
 public virtual Email EmailSelect(DBGuid IDVal)
 {
     TraceCallEnterEvent.Raise();
       try
       {
     Email result = null;
     DataSet entitySet = m_DataContext.ndihdEmailSelect(IDVal);
     if (entitySet.Tables[0].Rows.Count != 0)
     {
       result = new Email(entitySet);
     }
     TraceCallReturnEvent.Raise();
     return result;
       }
       catch (Exception ex)
       {
     ExceptionManager.Publish(ex);
     TraceCallReturnEvent.Raise(false);
     throw;
       }
 }
Exemplo n.º 11
0
 public virtual void EmailDelete(Email entity)
 {
     TraceCallEnterEvent.Raise();
       try
       {
     m_DataContext.BeginNestedTran();
     try
     {
       m_DataContext.ndihdEmailDelete(entity.ID);
       m_DataContext.CommitNested();
     }
     catch
     {
       m_DataContext.RollbackNested();
       throw;
     }
     TraceCallReturnEvent.Raise();
     return;
       }
       catch (Exception ex)
       {
     ExceptionManager.Publish(ex);
     TraceCallReturnEvent.Raise(false);
     throw;
       }
 }
Exemplo n.º 12
0
        /// <summary>
        /// Fill datagrid with data
        /// </summary>
        private void FillDatagrid(DBGuid ID)
        {
            try
              {
            string sSortColumn = "Sent DESC";
            int nSelectedRow = -1;

            // Storing the previous sort order
            if (dtgMain.DataSource != null)
            {
              sSortColumn = ((DataTable) dtgMain.DataSource).DefaultView.Sort;
            }

            // Set filter
            Email filter = new Email(Guid.Empty);
            if (cmbCategory.SelectedIndex > 0)
            {
              filter.Category = cmbCategory.SelectedValue.ToString();
            }
            if (dtpSentFrom.Checked)
            {
              filter.FilterOnSentFrom = new DBDateTime(dtpSentFrom.Value);
            }
            if (dtpSentTo.Checked)
            {
              DBDateTime dateTo = new DBDateTime(dtpSentTo.Value);
              filter.FilterOnSentTo = dateTo.AddDays(1).AddMilliseconds(-1);
            }
            if (cbxNDI.Checked)
            {
              filter.FilterOnNDI = 1;
            }
            if (cbxOrgActOther.Checked)
            {
              filter.FilterOnActivityOther = 1;
            }
            if (cbxOrgActPrevention.Checked)
            {
              filter.FilterOnActivityPrevention = 1;
            }
            if (cbxOrgActRehabilitation.Checked)
            {
              filter.FilterOnActivityRehabilitation = 1;
            }
            if (cbxOrgActResearch.Checked)
            {
              filter.FilterOnActivityResearch = 1;
            }
            if (cbxAll.Checked)
            {
              filter.FilterOnActivityAll = 1;
            }

            // Retrieving data from BusinessServices
            IEmailService srv = ServiceFactory.GetEmailService();
            EmailContainer allData = srv.EmailSelectFiltered(filter);
            DataTable dt = allData.AllAsDatatable;
            dt.DefaultView.Sort = sSortColumn;

            dtgMain.DataSource = dt;

            // Locates the row specified by ID param
            if (!ID.IsNull)
            {
              BindingManagerBase bm = dtgMain.BindingContext[dtgMain.DataSource, dtgMain.DataMember];
              DataRow dr;
              for (int i = 0; i < bm.Count; i++)
              {
            dr = ((DataRowView) bm.Current).Row;
            if (ID.Value.Equals(dr["ID"]))
            {
              nSelectedRow = i;
              break;
            }
            bm.Position += 1;
              }
            }

            // Makes the row selected
            if (nSelectedRow <= ((DataTable) dtgMain.DataSource).DefaultView.Count && nSelectedRow > -1)
            {
              dtgMain.Select(nSelectedRow);
              dtgMain.CurrentRowIndex = nSelectedRow;
            }
            else if (((DataTable) dtgMain.DataSource).DefaultView.Count != 0)
            {
              dtgMain.Select(0);
            }

            // Enabling or disabling the buttons according to record count.
            // And is because of previous disable state.
            bool bIsEmptyGrid = (((DataTable) dtgMain.DataSource).DefaultView.Count == 0);
            tbbModify.Enabled = ! bIsEmptyGrid;
              }
              catch (Exception ex)
              {
            //	---	Log exception
            ExceptionManager.Publish(ex);
            //	---	Display Exception
            ErrorHandler.DisplayError("Nem várt hiba lépett fel a lista frissítése során.", ex);
              }
        }
Exemplo n.º 13
0
 // -------------------------------------------------------------------------------------
 /// <summary>
 /// Copy constructor.
 /// </summary>
 /// <param name="IDVal">Value of 'uID' field</param>
 /// <param name="origInstance">Original document data to copy.</param>
 // -------------------------------------------------------------------------------------
 public Email(DBGuid IDVal,
          Email origInstance)
     : base(IDVal, origInstance)
 {
 }
Exemplo n.º 14
0
 // -------------------------------------------------------------------------------------
 /// <summary>
 /// Copy constructor.
 /// </summary>
 /// <param name="origInstance">Original document data to copy.</param>
 // -------------------------------------------------------------------------------------
 public Email(Email origInstance)
     : base(origInstance)
 {
 }
        /// 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();
              }
        }
Exemplo n.º 16
0
        public new void EmailUpdate(Email entity)
        {
            // Check permission: admin
              PrincipalPermission permAdmin = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Administrator");
              permAdmin.Demand();

              TraceCallEnterEvent.Raise();
              try
              {
            // Check required fields
            if (entity.Subject.Length == 0)
              throw new ArgumentNullException("Email.Subject", "A hírlevél tárgya nincs megadva.");
            if (entity.MailBody.Length == 0)
              throw new ArgumentNullException("Email.MailBody", "A hírlevél szövege nincs megadva.");

            // Logical checks
            Email selected = base.EmailSelect(entity.ID);
            if (selected == null)
              throw new ApplicationException("A megadott azonosítóval nem létezik hírlevél.");
            if (!selected.Category.Equals(EmailCategory.Newsmail))
              throw new ApplicationException("Csak hírlevél kategóriájú levél módosítható.");

            // Save data
            selected.Subject = entity.Subject;
            selected.MailBody = entity.MailBody;
            selected.ActivityAll = entity.ActivityAll;
            selected.ActivityOther = entity.ActivityOther;
            selected.ActivityPrevention = entity.ActivityPrevention;
            selected.ActivityRehabilitation = entity.ActivityRehabilitation;
            selected.ActivityResearch = entity.ActivityResearch;
            selected.ActivityNDI = entity.ActivityNDI;
            selected.To = entity.To;

            EmailAttachmentService attSrv = new EmailAttachmentService(m_DataContext);

            m_DataContext.BeginNestedTran();
            try
            {
              // Clear old files:
              EmailAttachmentContainer oldFiles = base.SelectChildrenByAttachmentOfEmail(entity.ID);
              foreach (EmailAttachment oldFile in oldFiles.All)
              {
            attSrv.EmailAttachmentDelete(oldFile);
              }

              // EmailAttachments - insert:
              foreach (EmailAttachment file in  entity.EmailAttachments.Current)
              {
            attSrv.EmailAttachmentInsert(file);
              }
              base.EmailUpdate(selected);
              m_DataContext.CommitNested();
            }
            catch
            {
              m_DataContext.RollbackNested();
              throw;
            }
            BusinessAuditEvent.Success(
              new EventParameter("EmailID", entity.ID),
              new EventParameter("EmailSubject", entity.Subject)
              );
            TraceCallReturnEvent.Raise();
            return;
              }
              catch (Exception ex)
              {
            ExceptionManager.Publish(ex);
            BusinessAuditEvent.Fail(
              new EventParameter("Exception", ex.ToString()),
              new EventParameter("EmailID", entity.ID),
              new EventParameter("EmailSubject", entity.Subject)
              );
            TraceCallReturnEvent.Raise(false);
            throw;
              }
        }
Exemplo n.º 17
0
        public void NewsmailInsert(Email entity)
        {
            // Check permission: admin
              PrincipalPermission permAdmin = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Administrator");
              permAdmin.Demand();

              TraceCallEnterEvent.Raise();
              try
              {
            // Check required fields
            if (entity.ID.IsNull) throw new ArgumentNullException("Email.ID", "A hírlevél azonosítója nincs megadva.");
            if (entity.Subject.Length == 0)
              throw new ArgumentNullException("Email.Subject", "A hírlevél tárgya nincs megadva.");
            if (entity.MailBody.Length == 0)
              throw new ArgumentNullException("Email.MailBody", "A hírlevél szövege nincs megadva.");

            // Save data
            entity.Category = EmailCategory.Newsmail;
            m_DataContext.BeginNestedTran();

            EmailAttachmentService attSrv = new EmailAttachmentService(m_DataContext);

            try
            {
              base.EmailInsert(entity);
              // Files
              foreach (EmailAttachment attach in entity.EmailAttachments.Current)
              {
            attSrv.EmailAttachmentInsert(attach);
              }

              m_DataContext.CommitNested();
            }
            catch
            {
              m_DataContext.RollbackNested();
              throw;
            }
            BusinessAuditEvent.Success(
              new EventParameter("EmailID", entity.ID),
              new EventParameter("EmailSubject", entity.Subject)
              );
            TraceCallReturnEvent.Raise();
            return;
              }
              catch (Exception ex)
              {
            ExceptionManager.Publish(ex);
            BusinessAuditEvent.Fail(
              new EventParameter("Exception", ex.ToString()),
              new EventParameter("EmailID", entity.ID),
              new EventParameter("EmailSubject", entity.Subject)
              );
            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;
              }
        }
        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;
              }
        }
Exemplo n.º 20
0
        public bool RegisterUserAccept(RegisterUser entity)
        {
            //Check permission: Admin
              PrincipalPermission permissionAdm =
            new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Administrator");
              permissionAdm.Demand();

              TraceCallEnterEvent.Raise();
              try
              {
            // Check required fields
            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.");
            if (entity.Right.Length == 0)
              throw new ArgumentNullException("RegisterUser.Right", "A jogosultság nincs megadva.");

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

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

            User newUser = new User(entity.LoginName);
            string generatedPassword = Password.Generate();
            newUser.Password = Password.ComputeHash(generatedPassword);

            newUser.OrganisationRef = entity.OrganisationRef;
            newUser.Name = entity.Name;
            newUser.Sex = entity.Sex;
            newUser.BirthYear = entity.BirthYear;
            newUser.Phone = entity.Phone;
            newUser.Email = entity.Email;
            newUser.PostCode = entity.PostCode;
            newUser.City = entity.City;
            newUser.Address = entity.Address;
            newUser.Country = entity.Country;
            newUser.QualificationRef = entity.QualificationRef;
            newUser.ReasonOfRegistration = entity.ReasonOfRegistration;
            newUser.Right = entity.Right;
            newUser.IsActive = true;
            newUser.NewsMail = entity.NewsMail;
            newUser.MustChangePassword = true;
            newUser.LockedOut = false;
            newUser.FailedAttemptCount = 0;

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

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

            mail.Subject = subject;

            body = body.Replace("<FULL_USER_NAME>", entity.Name);
            body = body.Replace("<LOGIN_NAME>", entity.LoginName);
            body = body.Replace("<PASSWORD>", generatedPassword);
            mail.MailBody = body;

            // Save data to database
            EmailService emailSrv = new EmailService(m_DataContext);
            m_DataContext.BeginNestedTran();
            try
            {
              UserServiceBase userSrv = new UserServiceBase(m_DataContext);
              userSrv.UserInsert(newUser);
              base.RegisterUserUpdate(entity);
              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("RegisterUserID", entity.ID.ToString()),
              new EventParameter("LoginName", entity.LoginName)
              );
            TraceCallReturnEvent.Raise();
            return true;
              }
              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;
              }
        }
Exemplo n.º 21
0
        /// <summary>
        /// Sends the mail to sender.
        /// </summary>
        /// <param name="category">The category.</param>
        /// <param name="body">The body.</param>
        /// <param name="subject">The subject.</param>
        /// <param name="offer">The offer.</param>
        /// <param name="mustUpdate">if set to <c>true</c> [must update].</param>
        private void SendMailToSender(string category, string body, string subject, JobOffer offer, bool mustUpdate)
        {
            //set mail:
              Email mail = new Email(Guid.NewGuid());

              mail.Category = category;
              mail.Subject = subject;

              mail.To = offer.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);
              if (mustUpdate)
              {

            JobOfferService srv = new JobOfferService(m_DataContext);
            JobOffer job = srv.JobOfferSelect(offer.ID);
            if (job != null)
            {
              job.NotificationSend = true;
              job.LastModified = DateTime.Now;
              srv.JobOfferUpdate(job);
            }

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

            // Sending mail:
            try
            {
              emailSrv.EmailSend(mail.ID);
            }
            catch (Exception ex)
            {
              ExceptionManager.Publish(ex);
              return;
            }
              }
        }
Exemplo n.º 22
0
        private void SendMail(Email mail)
        {
            // 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);
              }
        }
Exemplo n.º 23
0
        // -------------------------------------------------------------------------------------
        /// <summary>
        /// Modifies existing item
        /// </summary>
        // -------------------------------------------------------------------------------------
        private void UpdateData()
        {
            IEmailService srv = ServiceFactory.GetEmailService();
              // Get data
              if (m_currentMail == null)
              {
            m_currentMail = srv.EmailSelect(CurrentID);
              }

              // Get control values
              m_currentMail.Subject = txtSubject.Text;
              m_currentMail.MailBody = txtMailBody.Text;
              m_currentMail.ActivityOther = cbxOrgActOther.Checked;
              m_currentMail.ActivityPrevention = cbxOrgActPrevention.Checked;
              m_currentMail.ActivityRehabilitation = cbxOrgActRehabilitation.Checked;
              m_currentMail.ActivityResearch = cbxOrgActResearch.Checked;
              m_currentMail.ActivityAll = cbxAll.Checked;
              m_currentMail.ActivityNDI = cbxNDI.Checked;
              m_currentMail.To = m_SendEmailTo;

              srv.EmailUpdate(m_currentMail);
        }
Exemplo n.º 24
0
        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;
              }
        }
Exemplo n.º 25
0
        /// <summary>
        /// Default constructor (new)
        /// </summary>
        public frmEmailEdit()
        {
            // Required for Windows Form Designer support
              InitializeComponent();
              m_UpdateAction = false;
              CurrentID = new DBGuid(Guid.NewGuid());
              m_IsNewsMail = true;
              pHeader.Text2 = "Új hírlevél létrehozása";

              m_currentMail = new Email(CurrentID);
        }
Exemplo n.º 26
0
        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 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 bool RegisterKefOrganisation(RegisterOrganisation entity, string regSearchCode, DBInt disSearchCode,
                                        string estYear, string estMonth, string areaHomePage)
        {
            //Check permission: Admin
              PrincipalPermission permissionAdm =
            new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Administrator");
              permissionAdm.Demand();

              TraceCallEnterEvent.Raise();
              try
              {
            // Check required fields
            // Organisation
            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 regisztrálandó szervezet megyéje nincs megadva.");
            if (entity.WorkingAreaRef.Length == 0)
              throw new ArgumentNullException("RegisterOrganisation.WorkingAreaRef",
                                          "A regisztrálandó szervezet mûködési területe nincs megadva.");
            if (entity.OrganisationFormRef.Length == 0)
              throw new ArgumentNullException("RegisterOrganisation.OrganisationFormRef",
                                          "A regisztrálandó szervezet szervezeti formája nincs megadva.");
            if (entity.ReasonOfRegistration.Length == 0)
              throw new ArgumentNullException("RegisterOrganisation.ReasonOfRegistration",
                                          "Az adatbázis használatának célja 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.");

            // User
            if (entity.LoginName.Length == 0)
              throw new ArgumentNullException("RegisterOrganisation.LoginName",
                                          "A regisztrálandó felhasználó bejelentkezési neve nincs megadva.");
            if (entity.UserName.Length == 0)
              throw new ArgumentNullException("RegisterOrganisation.UserName",
                                          "A regisztrálandó felhasználó neve nincs megadva.");
            if (entity.UserSex.Length == 0)
              throw new ArgumentNullException("RegisterOrganisation.UserSex",
                                          "A regisztrálandó felhasználó neme nincs megadva.");
            if (entity.UserBirthYear.Length == 0)
              throw new ArgumentNullException("RegisterOrganisation.UserBirthYear",
                                          "A regisztrálandó felhasználó születési éve nincs megadva.");
            if (entity.UserEmail.Length == 0)
              throw new ArgumentNullException("RegisterOrganisation.UserEmail",
                                          "A regisztrálandó 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.");

            Organisation newOrg = new Organisation(entity.ID);
            newOrg.Name = entity.Name;
            newOrg.Department = entity.Department;
            newOrg.PostCode = entity.PostCode;
            newOrg.City = entity.City;
            newOrg.Address = entity.Address;
            newOrg.Country = entity.Country;
            newOrg.Phone1 = entity.Phone1;
            newOrg.Fax = entity.Fax;
            newOrg.Email1 = entity.Email1;
            newOrg.HomePage = entity.HomePage;
            newOrg.RegionRef = entity.RegionRef;
            newOrg.WorkingAreaRef = entity.WorkingAreaRef;
            newOrg.WorkingAreaOther = entity.WorkingAreaOther;
            newOrg.OrganisationFormRef = entity.OrganisationFormRef;
            newOrg.ActivityPrevention = entity.ActivityPrevention;
            newOrg.ActivityRehabilitation = entity.ActivityRehabilitation;
            newOrg.ActivityResearch = entity.ActivityResearch;
            newOrg.ActivityOther = entity.ActivityOther;
            newOrg.SourceGovernment = 0;
            newOrg.SourceCompetition = 0;
            newOrg.SourceSponsor = 0;
            newOrg.SourceDonation = 0;
            newOrg.SourceTax = 0;
            newOrg.SourceOther = 0;
            newOrg.IsActive = true;
            // defaults
            newOrg.WorkersFix = 0;
            newOrg.WorkersExternal = 0;
            newOrg.WorkersVolunteer = 0;
            newOrg.JobPsychologist = 0;
            newOrg.JobPsychiater = 0;
            newOrg.JobDoctor = 0;
            newOrg.JobMedicalExpert = 0;
            newOrg.JobHealthExpert = 0;
            newOrg.JobSociologist = 0;
            newOrg.JobSocialPolitician = 0;
            newOrg.JobSocialWorker = 0;
            newOrg.JobSocialPedagogist = 0;
            newOrg.JobPedagogist = 0;
            newOrg.JobManualist = 0;
            newOrg.JobLawyer = 0;
            newOrg.JobPoliceman = 0;
            newOrg.JobMentalhygiene = 0;
            newOrg.JobCultureOrganizer = 0;
            newOrg.JobOther1 = 0;
            newOrg.JobOther2 = 0;
            newOrg.JobOther3 = 0;

            //It's a KEF -> set KEF specific data
            newOrg.IsKef = true;
            newOrg.RegionSearchCodeRef = regSearchCode;
            newOrg.DistrictSearchCodeRef = disSearchCode;
            newOrg.EstablishmentYear = estYear;
            newOrg.EstablishmentMonth = estMonth;
            newOrg.AreaHomePage = areaHomePage;
            newOrg.IsActual = true;
            newOrg.LastModified = DateTime.Now;

            //save the user
            User newUser = new User(entity.LoginName);
            newUser.OrganisationRef = entity.ID;

            string generatedPassword = Password.Generate();
            newUser.Password = Password.ComputeHash(generatedPassword);

            newUser.Address = entity.UserAddress;
            newUser.Name = entity.UserName;
            newUser.Sex = entity.UserSex;
            newUser.BirthYear = entity.UserBirthYear;
            newUser.Phone = entity.UserPhone;
            newUser.Email = entity.UserEmail;
            newUser.PostCode = entity.UserPostCode;
            newUser.City = entity.UserCity;
            newUser.Address = entity.UserAddress;
            newUser.Country = entity.UserCountry;
            newUser.QualificationRef = entity.QualificationRef;
            newUser.ReasonOfRegistration = entity.ReasonOfRegistration;
            newUser.Right = UserRights.Write;
            newUser.IsActive = true;
            newUser.NewsMail = false;
            newUser.MustChangePassword = true;
            newUser.FailedAttemptCount = 0;
            newUser.LockedOut = false;

            //set mail:
            Email mail = new Email(Guid.NewGuid());
            mail.Category = EmailCategory.OrganisationRegistrationAccept;
            mail.To = entity.UserEmail;

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

            mail.Subject = subject;

            body = body.Replace("<FULL_USER_NAME>", entity.Name);
            body = body.Replace("<LOGIN_NAME>", entity.LoginName);
            body = body.Replace("<ORGANIZATION>", newOrg.Name);
            body = body.Replace("<PASSWORD>", generatedPassword);
            mail.MailBody = body;

            // Save data to database
            EmailService emailSrv = new EmailService(m_DataContext);
            m_DataContext.BeginNestedTran();
            try
            {
              UserServiceBase userSrv = new UserServiceBase(m_DataContext);
              OrganisationService orgSrv = new OrganisationService(m_DataContext);
              orgSrv.OrganisationInsert(newOrg);
              userSrv.UserInsert(newUser);
              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("OrganisationID", newOrg.ID.ToString()),
              new EventParameter("OrganisationName", entity.Name),
              new EventParameter("LoginName", entity.LoginName)
              );
            TraceCallReturnEvent.Raise();
            return true;
              }
              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;
              }
        }