public new void JobOfferUpdate(JobOffer entity) { // check permission: Writer or Admin PrincipalPermission permReg = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Registered"); PrincipalPermission permAdmin = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Administrator"); permReg.Union(permAdmin).Demand(); TraceCallEnterEvent.Raise(); try { // Check required fields: if (entity.Description.Length == 0) throw new ArgumentNullException("JobOffer.Description", "A hirdetés leírása nincs megadva."); // Logical checks JobOffer selected = base.JobOfferSelect(entity.ID); if (selected == null) throw new ApplicationException("A megadott azonosítóval nem létezik hirdetés."); // Save data selected.Requirements = entity.Requirements; selected.QualificationMinRef = entity.QualificationMinRef; selected.IdealEmployee = entity.IdealEmployee; selected.EmployeeCount = entity.EmployeeCount; selected.HomePage = entity.HomePage; selected.ContactName = entity.ContactName; selected.ContactPhone = entity.ContactPhone; selected.ContactEmail = entity.ContactEmail; selected.Description = entity.Description; selected.City = entity.City; selected.RegionRef = entity.RegionRef; selected.Status = entity.Status; selected.ActivityPrevention = entity.ActivityPrevention; selected.ActivityResearch = entity.ActivityResearch; selected.ActivityRehabilitation = entity.ActivityRehabilitation; selected.ActivityOther = entity.ActivityOther; selected.Expiredate = entity.Expiredate; selected.NotificationSend = entity.NotificationSend; selected.NotificationDate = entity.NotificationDate; selected.LastModified = DateTime.Now; selected.JobOfferAttachments = entity.JobOfferAttachments; JobOfferAttachmentService attSrv = new JobOfferAttachmentService(m_DataContext); // Clear old files: JobOfferAttachmentContainer oldFiles = base.SelectChildrenByAttachmentOfJobOffer(entity.ID); foreach (JobOfferAttachment oldFile in oldFiles.All) { attSrv.JobOfferAttachmentDelete(oldFile); } JobOfferAttachment newFile; // EDocumentAttachments - insert: foreach (JobOfferAttachment file in selected.JobOfferAttachments.Current) { if (file.FileData.Length == 0) { newFile = attSrv.JobOfferAttachmentSelectFile(file.ID); } else { newFile = file; } newFile.JobOfferRef = selected.ID; newFile.Name = file.Name; newFile.Description = file.Description; newFile.CreatedDate = DateTime.Now; if (attSrv.JobOfferAttachmentSelect(newFile.ID) != null) { attSrv.JobOfferAttachmentUpdate(newFile); } else { attSrv.JobOfferAttachmentInsert(newFile); } } base.JobOfferUpdate(selected); BusinessAuditEvent.Success( new EventParameter("JobOfferID", entity.ID.ToString()), new EventParameter("JobOfferLogin", entity.Sender) ); TraceCallReturnEvent.Raise(); return; } catch (Exception ex) { ExceptionManager.Publish(ex); BusinessAuditEvent.Fail( new EventParameter("Exception", ex.ToString()), new EventParameter("JobOfferID", entity.ID.ToString()), new EventParameter("JobOfferLogin", entity.Sender) ); TraceCallReturnEvent.Raise(false); throw; } }
public new 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; } }