public frmPendingQuestionFormEdit(PendingQuestionForm form) { // Required for Windows Form Designer support InitializeComponent(); m_PendingQuestionForm = form; m_PendingQuestionFormID = form.ID; }
public virtual PendingQuestionForm PendingQuestionFormSelect(DBGuid IDVal) { TraceCallEnterEvent.Raise(); try { PendingQuestionForm result = null; DataSet entitySet = m_DataContext.ndihdPendingQuestionFormSelect(IDVal); if (entitySet.Tables[0].Rows.Count != 0) { result = new PendingQuestionForm(entitySet); } TraceCallReturnEvent.Raise(); return result; } catch (Exception ex) { ExceptionManager.Publish(ex); TraceCallReturnEvent.Raise(false); throw; } }
public virtual void PendingQuestionFormDelete(PendingQuestionForm entity) { TraceCallEnterEvent.Raise(); try { m_DataContext.BeginNestedTran(); try { m_DataContext.ndihdPendingQuestionFormDelete(entity.ID); m_DataContext.CommitNested(); } catch { m_DataContext.RollbackNested(); throw; } TraceCallReturnEvent.Raise(); return; } catch (Exception ex) { ExceptionManager.Publish(ex); TraceCallReturnEvent.Raise(false); throw; } }
protected void btnSave_Click(object sender, EventArgs e) { try { string mode = Request["mode"]; string templateId = Request["templId"]; Guid templateGuid = new Guid(templateId); string orgId = Request["orgId"]; Guid organisationGuid = new Guid(orgId); string origqfId = Request["qfID"]; DBGuid origQFGuid = DBGuid.Null; string pendingQFID = Request["pendingID"]; DBGuid pendingQFGuid = DBGuid.Null; string status = ""; string method = ""; IPendingQuestionFormService formSrv = ServiceFactory.GetPendingQuestionFormService(); switch (mode) { case "empty": pendingQFGuid = Guid.NewGuid(); status = "NEW"; method = "insert"; break; case "accepted": pendingQFGuid = Guid.NewGuid(); origQFGuid = new Guid(origqfId); status = "UPD"; method = "insert"; break; case "new": pendingQFGuid = new Guid(pendingQFID); status = "NEW"; method = "update"; break; case "upd": pendingQFGuid = new Guid(pendingQFID); PendingQuestionForm pqf = formSrv.PendingQuestionFormSelect(pendingQFGuid); origQFGuid = pqf.QuestionFormRef; status = "UPD"; method = "update"; break; } // Build document: TemplateControl1.SetAnswer(); PendingQuestionForm form = new PendingQuestionForm(pendingQFGuid); form.TemplateRef = templateGuid; form.Status = status; form.QuestionFormRef = origQFGuid; form.OrganisationID = organisationGuid; foreach (IQuestion question in TemplateControl1.Questions) { TemplateDetail detail = (TemplateDetail) question; PendingQuestionFormDetail questionDetail = new PendingQuestionFormDetail(form.ID, detail.ID, templateGuid); questionDetail.Answer = detail.Answer; form.Details.Add(questionDetail); } // Save data: if (method.Equals("insert")) { formSrv.PendingQuestionFormInsertForOrganisation(form); } if (method.Equals("update")) { //TODO: itt nem biztos, hogy pendingbe kell tenni, csak akkor kell, ha nem csak a naprakész flag változott formSrv.PendingQuestionFormUpdateForOrganisation(form); } // Go back to Organisation data: Response.Redirect("OrganisationData.aspx?orgID=" + orgId); } catch (Exception ex) { errorPanel.Exception = ex; } }
protected void btnSend_Click(object sender, EventArgs e) { try { IPendingQuestionFormService formSrv = ServiceFactory.GetPendingQuestionFormService(); string mode = Request["mode"]; string templateId = Request["templId"]; Guid templateGuid = new Guid(templateId); string orgId = Request["orgId"]; Guid organisationGuid = new Guid(orgId); string origqfId = Request["qfID"]; DBGuid origQFGuid = DBGuid.Null; string pendingQFID = Request["pendingID"]; DBGuid pendingQFGuid = DBGuid.Null; string status = ""; string method = ""; switch (mode) { case "empty": pendingQFGuid = Guid.NewGuid(); status = "NWD"; method = "insert"; break; case "accepted": pendingQFGuid = Guid.NewGuid(); origQFGuid = new Guid(origqfId); status = "UWD"; method = "insert"; break; case "new": case "nsb": pendingQFGuid = new Guid(pendingQFID); status = "NWD"; method = "update"; break; case "upd": case "usb": pendingQFGuid = new Guid(pendingQFID); PendingQuestionForm pqf = formSrv.PendingQuestionFormSelect(pendingQFGuid); origQFGuid = pqf.QuestionFormRef; status = "UWD"; method = "update"; break; } // Build document: // validate the whole form TemplateControl1.SetAnswer(); if (!TemplateControl1.Validate()) { return; } PendingQuestionForm form = new PendingQuestionForm(pendingQFGuid); form.TemplateRef = templateGuid; form.Status = status; form.QuestionFormRef = origQFGuid; form.OrganisationID = organisationGuid; foreach (IQuestion question in TemplateControl1.Questions) { TemplateDetail detail = (TemplateDetail) question; PendingQuestionFormDetail questionDetail = new PendingQuestionFormDetail(form.ID, detail.ID, templateGuid); questionDetail.Answer = detail.Answer; form.Details.Add(questionDetail); } // Save data: if (method.Equals("insert")) { formSrv.PendingQuestionFormInsertForOrganisation(form); } if (method.Equals("update")) { formSrv.PendingQuestionFormUpdateForOrganisation(form); } //Kell egy ellenõrzés, hogy csak a bIsActual változott-e // Go back to Organisation data: //Response.Redirect("OrganisationData.aspx?orgID=" + orgId); Response.Redirect("QuestionFormFinish.aspx?from=org&orgId=" + orgId); } catch (Exception ex) { errorPanel.Exception = ex; } }
public bool PendingQuestionFormSendBackNew(PendingQuestionForm entity) { //Check permission: Admin PrincipalPermission permissionAdm = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, "Administrator"); permissionAdm.Demand(); TraceCallEnterEvent.Raise(); try { //Check required fields if (entity.ID.IsNull) throw new ArgumentNullException("PendingQuestionForm.ID", "Az elbírálandó kérdõív azonosítója nincs megadva."); if (entity.ProgramCategoryId.Length == 0) throw new ArgumentNullException("PendingQuestionForm.ProgramCategoryId", "Az elbírálandó kérdõív kategóriája nincs megadva."); if (entity.TemplateRef.IsNull) throw new ArgumentNullException("PendingQuestionForm.TemplateRef", "A sablon azonosítója nincs megadva."); if (entity.RejectComment.Length == 0) throw new ArgumentNullException("PendingQuestionForm.RejectComment", "A visszaküldés indoklása nincs megadva."); // Logical checks: PendingQuestionForm selected = base.PendingQuestionFormSelect(entity.ID); if (selected == null) throw new ApplicationException("A megadott azonosítóval nem létezik elbírálandó kérdõív."); if (!selected.Status.Equals(QuestionFormStatus.New_WaitingForDecision)) throw new ApplicationException("Csak jóváhagyásra váró státuszú kérdõív bírálható el."); // Set properties selected.DecidedBy = Thread.CurrentPrincipal.Identity.Name; selected.DecidedDate = DBDateTime.Now; selected.Status = QuestionFormStatus.New_SendBack; selected.RejectComment = entity.RejectComment; selected.QuestionFormRef = entity.QuestionFormRef; selected.IsActual = false; //Set mail: UserService userSrv = new UserService(m_DataContext); User sentBy = userSrv.UserSelect(selected.SentBy); Email mail = new Email(Guid.NewGuid()); mail.Category = EmailCategory.QuestionFormInsertSendBack; mail.To = sentBy.Email; //Subject és body lekérdezése string body = ""; string subject = ""; EmailTemplateService srvTemplate = new EmailTemplateService(); srvTemplate.GetEmailTemplateByCode(ref subject, ref body, EmailCategory.QuestionFormInsertSendBack); mail.Subject = subject; body = body.Replace("<FULL_USER_NAME>", sentBy.Name); body = body.Replace("<SENT_DATE>", entity.SentDate.ToString()); body = body.Replace("<TEMPLATE_NAME>", entity.TemplateName); body = body.Replace("<REJECT_COMMENT>", entity.RejectComment); mail.MailBody = body; // Save data to database EmailService emailSrv = new EmailService(m_DataContext); m_DataContext.BeginNestedTran(); try { base.PendingQuestionFormUpdate(selected); emailSrv.EmailInsert(mail); m_DataContext.CommitNested(); } catch { m_DataContext.RollbackNested(); throw; } // Sending mail: try { emailSrv.EmailSend(mail.ID); } catch (Exception ex) { ExceptionManager.Publish(ex); return false; } // Log success BusinessAuditEvent.Success( new EventParameter("PendingQuestionFormID", entity.ID.ToString()), new EventParameter("ProgramID", entity.ProgramID.ToString()), new EventParameter("OrganisationID", entity.OrganisationID.ToString()) ); TraceCallReturnEvent.Raise(); return true; } catch (Exception ex) { ExceptionManager.Publish(ex); BusinessAuditEvent.Fail( new EventParameter("Exception", ex.ToString()), new EventParameter("PendingQuestionFormID", entity.ID.ToString()), new EventParameter("ProgramID", entity.ProgramID.ToString()), new EventParameter("OrganisationID", entity.OrganisationID.ToString()) ); TraceCallReturnEvent.Raise(false); throw; } }
public PendingQuestionFormContainer PendingQuestionFormSelectFiltered(PendingQuestionForm filter) { TraceCallEnterEvent.Raise(); try { if (filter.ProgramCategoryId.Length == 0) throw new ArgumentNullException("filter.ProgramCategoryId", "A program kategória nincs megadva."); PendingQuestionFormContainer result; if (filter.ProgramCategoryId.Equals("ORG")) { DataSet entitySet = m_DataContext.ndihdPendingQuestionFormOfOrganisationSelectFiltered( filter.OrganisationID, filter.Status, "ORG"); result = new PendingQuestionFormContainer(entitySet.Tables[0]); } else { DataSet entitySet = m_DataContext.ndihdPendingQuestionFormOfProgramSelectFiltered( filter.ProgramID, filter.OrganisationID, filter.Status, filter.ProgramCategoryId); result = new PendingQuestionFormContainer(entitySet.Tables[0]); } TraceCallReturnEvent.Raise(); return result; } catch (Exception ex) { ExceptionManager.Publish(ex); TraceCallReturnEvent.Raise(false); throw; } }
public void PendingQuestionFormUpdateForProgram(PendingQuestionForm entity) { TraceCallEnterEvent.Raise(); try { if (entity.ProgramID.IsNull) throw new ArgumentNullException("PendingQuestionForm.ProgramID", "A program azonosítója nincs megadva."); ProgramService programSrv = new ProgramService(m_DataContext); Program program = programSrv.ProgramSelect(entity.ProgramID); if (program == null) throw new ApplicationException("A megadott azonosítóval nem létezik program."); string writerRole = program.OrganisationRef.Value.ToString() + ".Writer"; PrincipalPermission permWriter = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, writerRole); permWriter.Demand(); // required: if (entity.TemplateRef.IsNull) throw new ArgumentNullException("PendingQuestionForm.TemplateRef", "A sablon azonosítója nincs megadva."); if (entity.Status.Length == 0) throw new ArgumentNullException("PendingQuestionForm.Status", "A státusz nincs megadva."); // logical check: TemplateCategoryService templCatSrv = new TemplateCategoryService(m_DataContext); TemplateCategory templCat = templCatSrv.TemplateCategorySelect(entity.TemplateRef, program.ProgramCategoryRef); if (templCat == null) throw new ApplicationException("A megadott programhoz nem tölthetõ ki ez a sablon."); PendingQuestionForm selectedPending = base.PendingQuestionFormSelect(entity.ID); if (selectedPending == null) throw new ApplicationException("A módosítani kívánt kérdõív nem létezik."); // set data: entity.SentBy = Thread.CurrentPrincipal.Identity.Name; entity.SentDate = DBDateTime.Now; entity.LastModifiedByUser = DBDateTime.Now; if (entity.Status == "UWD" || entity.Status == "NWD") entity.IsActual = true; else { entity.IsActual = false; } PendingQuestionFormDetailService detailService = new PendingQuestionFormDetailService(m_DataContext); ProgramPendingQuestionFormService programPendingSrv = new ProgramPendingQuestionFormService(m_DataContext); m_DataContext.BeginNestedTran(); try { base.PendingQuestionFormUpdate(entity); base.DeleteChildrenByDetailOfPendingQuestionForm(entity.ID); foreach (PendingQuestionFormDetail detail in entity.Details.All) { detailService.PendingQuestionFormDetailInsert(detail); } m_DataContext.CommitNested(); } catch { m_DataContext.RollbackNested(); throw; } // Log success BusinessAuditEvent.Success( new EventParameter("PendingQuestionFormID", entity.ID.ToString()), new EventParameter("ProgramID", entity.ProgramID.ToString()) ); TraceCallReturnEvent.Raise(); return; } 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()) ); TraceCallReturnEvent.Raise(false); throw; } }
public void PendingQuestionFormInsertForProgram(PendingQuestionForm entity) { TraceCallEnterEvent.Raise(); try { if (entity.ProgramID.IsNull) throw new ArgumentNullException("PendingQuestionForm.ProgramID", "A program azonosítója nincs megadva."); ProgramService programSrv = new ProgramService(m_DataContext); Program program = programSrv.ProgramSelect(entity.ProgramID); if (program == null) throw new ApplicationException("A megadott azonosítóval nem létezik program."); string writerRole = program.OrganisationRef.Value.ToString() + ".Writer"; PrincipalPermission permWriter = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, writerRole); permWriter.Demand(); // required: if (entity.TemplateRef.IsNull) throw new ArgumentNullException("PendingQuestionForm.TemplateRef", "A sablon azonosítója nincs megadva."); if (entity.Status.Length == 0) throw new ArgumentNullException("PendingQuestionForm.Status", "A státusz nincs megadva."); /* TODO módosításnál ez is kötelezõ: if(entity.QuestionFormRef.IsNull) throw new ArgumentNullException("PendingQuestionForm.QuestionFormRef", "Az eredeti kérdõív azonosítója nincs megadva."); */ // logical check: TemplateCategoryService templCatSrv = new TemplateCategoryService(m_DataContext); TemplateCategory templCat = templCatSrv.TemplateCategorySelect(entity.TemplateRef, program.ProgramCategoryRef); if (templCat == null) throw new ApplicationException("A megadott programhoz nem tölthetõ ki ez a sablon."); // ellenõrizzük, hogy nincs folyamatban ilyen kérdõív kitöltése: TemplateService srv = new TemplateService(m_DataContext); Template tmplCurrentPending = srv.TemplateSelectOfProgramPendingQuestionFormByTemplateID(program.ID, entity.TemplateRef); if (!tmplCurrentPending.Status.IsNull) { throw new ApplicationException("A kérdõív nem módosítható, mert a módosítás már folyamatban van."); } // set data: entity.SentBy = Thread.CurrentPrincipal.Identity.Name; entity.SentDate = DBDateTime.Now; entity.LastModifiedByUser = DBDateTime.Now; if (entity.Status == "UWD" || entity.Status == "NWD") entity.IsActual = true; else { entity.IsActual = false; } ProgramPendingQuestionForm programPending = new ProgramPendingQuestionForm(program.ID, entity.ID); PendingQuestionFormDetailService detailService = new PendingQuestionFormDetailService(m_DataContext); ProgramPendingQuestionFormService programPendingSrv = new ProgramPendingQuestionFormService(m_DataContext); m_DataContext.BeginNestedTran(); try { base.PendingQuestionFormInsert(entity); foreach (PendingQuestionFormDetail detail in entity.Details.All) { detailService.PendingQuestionFormDetailInsert(detail); } programPendingSrv.ProgramPendingQuestionFormInsert(programPending); m_DataContext.CommitNested(); } catch { m_DataContext.RollbackNested(); throw; } // Log success BusinessAuditEvent.Success( new EventParameter("PendingQuestionFormID", entity.ID.ToString()), new EventParameter("ProgramID", entity.ProgramID.ToString()) ); TraceCallReturnEvent.Raise(); return; } 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()) ); TraceCallReturnEvent.Raise(false); throw; } }
protected void btnSave_Click(object sender, EventArgs e) { try { string mode = Request["mode"]; string templateId = Request["templId"]; Guid templateGuid = new Guid(templateId); string progId = Request["progId"]; Guid programGuid = new Guid(progId); string origqfId = Request["qfID"]; DBGuid origQFGuid = DBGuid.Null; string pendingQFID = Request["pendingID"]; DBGuid pendingQFGuid = DBGuid.Null; string status = ""; string method = ""; IPendingQuestionFormService formSrv = ServiceFactory.GetPendingQuestionFormService(); switch (mode) { case "empty": pendingQFGuid = Guid.NewGuid(); status = "NEW"; method = "insert"; break; case "accepted": pendingQFGuid = Guid.NewGuid(); origQFGuid = new Guid(origqfId); status = "UPD"; method = "insert"; break; case "new": pendingQFGuid = new Guid(pendingQFID); status = "NEW"; method = "update"; break; case "upd": pendingQFGuid = new Guid(pendingQFID); PendingQuestionForm pqf = formSrv.PendingQuestionFormSelect(pendingQFGuid); origQFGuid = pqf.QuestionFormRef; status = "UPD"; method = "update"; break; case "nsb": goto case "new"; case "usb": goto case "upd"; } // Build document: TemplateControl1.SetAnswer(); PendingQuestionForm form = new PendingQuestionForm(pendingQFGuid); form.TemplateRef = templateGuid; form.Status = status; form.QuestionFormRef = origQFGuid; form.ProgramID = programGuid; foreach (IQuestion question in TemplateControl1.Questions) { TemplateDetail detail = (TemplateDetail) question; PendingQuestionFormDetail questionDetail = new PendingQuestionFormDetail(form.ID, detail.ID, templateGuid); questionDetail.Answer = detail.Answer.Replace("<br/>", "\r\n"); form.Details.Add(questionDetail); } // Save data: if (method.Equals("insert")) { formSrv.PendingQuestionFormInsertForProgram(form); } if (method.Equals("update")) { formSrv.PendingQuestionFormUpdateForProgram(form); } string qfId; if (mode == "accepted") { qfId = Request["qfID"]; } else { qfId = Request["pendingID"]; } //ViewState.Clear(); string modifyUrl = CreateModifyUrl(form); //Response.Redirect(modifyUrl); //Response.Redirect("Redirect.aspx?mode=" + status.ToLower() + "&templID=" + Request["templID"] + "&progID=" + Request["progID"] + "&pendingID=" + qfId + "&Page=" + TemplateControl1.CurrentPage); // Go back to program data: Response.Redirect("ProgramData.aspx?progId=" + progId); } catch (Exception ex) { errorPanel.Exception = ex; } }
public void PendingQuestionFormUpdateForOrganisation(PendingQuestionForm entity) { TraceCallEnterEvent.Raise(); try { if (entity.OrganisationID.IsNull) throw new ArgumentNullException("PendingQuestionForm.OrganisationID", "A szervezet azonosítója nincs megadva."); string writerRole = entity.OrganisationID.Value.ToString() + ".Writer"; PrincipalPermission permWriter = new PrincipalPermission(Thread.CurrentPrincipal.Identity.Name, writerRole); permWriter.Demand(); OrganisationService orgSrv = new OrganisationService(m_DataContext); Organisation organisation = orgSrv.OrganisationSelect(entity.OrganisationID); if (organisation == null) throw new ApplicationException("A megadott azonosítóval nem létezik szervezet."); // required: if (entity.TemplateRef.IsNull) throw new ArgumentNullException("PendingQuestionForm.TemplateRef", "A sablon azonosítója nincs megadva."); if (entity.Status.Length == 0) throw new ArgumentNullException("PendingQuestionForm.Status", "A státusz nincs megadva."); // logical check: TemplateCategoryService templCatSrv = new TemplateCategoryService(m_DataContext); TemplateCategory templCat = templCatSrv.TemplateCategorySelect(entity.TemplateRef, "ORG"); if (templCat == null) throw new ApplicationException("Szervezethez nem tölthetõ ki ez a sablon."); PendingQuestionForm selectedPending = base.PendingQuestionFormSelect(entity.ID); //Ez van az adatbázisban if (selectedPending == null) throw new ApplicationException("A módosítani kívánt kérdõív nem létezik."); PendingQuestionFormDetailService detailService = new PendingQuestionFormDetailService(m_DataContext); PendingQuestionFormDetailContainer selectedPendingDetails = base.SelectChildrenByDetailOfPendingQuestionForm(selectedPending.ID); // set data: entity.SentBy = Thread.CurrentPrincipal.Identity.Name; entity.SentDate = DBDateTime.Now; entity.LastModifiedByUser = DBDateTime.Now; bool onlyIsActualChanged = true; if (entity.Status == "UWD" || entity.Status == "NWD") { entity.IsActual = true; //Új- jóváhagyásra vár, módosítiott jóváhagyásra vár //Kell egy ellenõrzés, hogy csak a bIsActual változott-e //onlyIsActualChanged = // entity.QuestionFormRef == selectedPending.QuestionFormRef && entity.TemplateRef == selectedPending.TemplateRef; //foreach (PendingQuestionFormDetail detail in entity.Details.All) //{ // foreach (PendingQuestionFormDetail selectedDetail in selectedPendingDetails.All) // { // if(detail.TemplateDetailRef == selectedDetail.TemplateDetailRef && detail.TemplateRef == selectedDetail.TemplateRef) // { // onlyIsActualChanged &= detail.Answer == selectedDetail.Answer; // } // } //} //Ha az alapadatok és minden váasz egyforma, akkor csak a bIsActualt akarta menteni, tehát jóv kell hagyni a végén } else { entity.IsActual = false; } m_DataContext.BeginNestedTran(); try { base.PendingQuestionFormUpdate(entity); base.DeleteChildrenByDetailOfPendingQuestionForm(entity.ID); foreach (PendingQuestionFormDetail detail in entity.Details.All) { detailService.PendingQuestionFormDetailInsert(detail); } m_DataContext.CommitNested(); } catch { m_DataContext.RollbackNested(); throw; } // Log success BusinessAuditEvent.Success( new EventParameter("PendingQuestionFormID", entity.ID.ToString()), new EventParameter("OrganisationID", entity.OrganisationID.ToString()) ); TraceCallReturnEvent.Raise(); return; } catch (Exception ex) { ExceptionManager.Publish(ex); BusinessAuditEvent.Fail( new EventParameter("Exception", ex.ToString()), new EventParameter("PendingQuestionFormID", entity.ID.ToString()), new EventParameter("OrganisationID", entity.OrganisationID.ToString()) ); TraceCallReturnEvent.Raise(false); throw; } }
private string CreateModifyUrl(PendingQuestionForm form) { string ModifyingUrl = ""; if (form.Status.Equals("NEW")) { ModifyingUrl = "QuestionFormModify.aspx?mode=new"; ModifyingUrl += "&templID=" + form.TemplateRef.ToString(); ModifyingUrl += "&progID=" + form.ProgramID.ToString(); ModifyingUrl += "&pendingID=" + form.ID.ToString(); } if (form.Status.Equals("UPD")) { ModifyingUrl = "QuestionFormModify.aspx?mode=upd"; ModifyingUrl += "&templID=" + form.TemplateRef.ToString(); ModifyingUrl += "&progID=" + form.ProgramID.ToString(); ModifyingUrl += "&pendingID=" + form.ID.ToString(); } if (form.Status.Equals("NSB")) { ModifyingUrl = "QuestionFormModify.aspx?mode=nsb"; ModifyingUrl += "&templID=" + form.TemplateRef.ToString(); ModifyingUrl += "&progID=" + form.ProgramID.ToString(); ModifyingUrl += "&pendingID=" + form.ID.ToString(); } if (form.Status.Equals("USB")) { ModifyingUrl = "QuestionFormModify.aspx?mode=usb"; ModifyingUrl += "&templID=" + form.TemplateRef.ToString(); ModifyingUrl += "&progID=" + form.ProgramID.ToString(); ModifyingUrl += "&pendingID=" + form.ID.ToString(); } ModifyingUrl = ModifyingUrl + "&Page=" + TemplateControl1.CurrentPage; return ModifyingUrl; }
// ------------------------------------------------------------------------------------- /// <summary> /// Copy constructor. /// </summary> /// <param name="IDVal">Value of 'uID' field</param> /// <param name="origInstance">Original document data to copy.</param> // ------------------------------------------------------------------------------------- public PendingQuestionForm(DBGuid IDVal, PendingQuestionForm origInstance) : base(IDVal, origInstance) { }
// ------------------------------------------------------------------------------------- /// <summary> /// Copy constructor. /// </summary> /// <param name="origInstance">Original document data to copy.</param> // ------------------------------------------------------------------------------------- public PendingQuestionForm(PendingQuestionForm origInstance) : base(origInstance) { }
public virtual void PendingQuestionFormUpdate(PendingQuestionForm entity) { TraceCallEnterEvent.Raise(); try { m_DataContext.BeginNestedTran(); try { int count; m_DataContext.ndihdPendingQuestionFormUpdate(entity.ID, entity.QuestionFormRef, entity.TemplateRef, entity.Status, entity.SentBy, entity.SentDate, entity.DecidedBy, entity.DecidedDate, entity.RejectComment, entity.IsActual, entity.LastModifiedByUser, entity.LastValidationDate, 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; } }
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; } }
// ------------------------------------------------------------------------------------- /// <summary> /// Fill datagrid with data /// </summary> // ------------------------------------------------------------------------------------- private void FillDatagrid(DBGuid ID) { try { string sortColumn = "SentDate"; int selectedRow = -1; // storing the previous sort order if (dtgMain.DataSource != null) { sortColumn = ((DataTable) dtgMain.DataSource).DefaultView.Sort; } // retrieving data from BusinessServices PendingQuestionForm filter = new PendingQuestionForm(Guid.NewGuid()); filter.ProgramCategoryId = cmbCategory.SelectedValue.ToString(); filter.Status = cmbStatusFilter.SelectedValue.ToString(); if (cmbProgram.SelectedValue.ToString().Length > 0) { Guid prgId = new Guid(cmbProgram.SelectedValue.ToString()); filter.ProgramID = prgId; } if (cmbOrganisation.SelectedValue.ToString().Length > 0) { Guid orgId = new Guid(cmbOrganisation.SelectedValue.ToString()); filter.OrganisationID = orgId; } IPendingQuestionFormService pendingSrv = ServiceFactory.GetPendingQuestionFormService(); m_PendingQuestionFormContainer = pendingSrv.PendingQuestionFormSelectFiltered(filter); DataTable dt = m_PendingQuestionFormContainer.AllAsDatatable; dt.DefaultView.Sort = sortColumn; 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"])) { selectedRow = i; break; } bm.Position += 1; } } // makes the row selected if (selectedRow <= ((DataTable) dtgMain.DataSource).DefaultView.Count && selectedRow > -1) { dtgMain.Select(selectedRow); dtgMain.CurrentRowIndex = selectedRow; } 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. tbbDecide.Enabled = (((DataTable) dtgMain.DataSource).DefaultView.Count != 0); } catch (Exception ex) { // --- Log exception ExceptionManager.Publish(ex); // --- Display Exception ErrorHandler.DisplayError("Nem várt hiba a lista frissítése során.", ex); } }
protected void Page_Load(object sender, EventArgs e) { bool confirm = false; //végigmegyünk a felküldött XML file -on és beolvassuk a tartalmát egy string be foreach (string f in Request.Files.AllKeys) { HttpPostedFile file = Request.Files[f]; int FileLen; Stream MyStream; TextReader MyTextStream; String MyString = ""; FileLen = file.ContentLength; byte[] input = new byte[FileLen]; // Initialize the stream. MyStream = file.InputStream; MyTextStream = new StreamReader(MyStream, Encoding.UTF8); String line; while ((line = MyTextStream.ReadLine()) != null) { MyString = MyString + line; // a felküldött file tartalmát berakjuk a MyString -be } //a file tartalmát egy xml -be olvassuk XmlTextReader xmlReader = null; StringReader stringReader = new StringReader(MyString.Trim()); string strProgID = ""; // a file -ból kiolvasott Program ID string strTemplateID = ""; // és Template ID try { //Load the reader with the XML file. xmlReader = new XmlTextReader(stringReader); string strName; Boolean blnIsAnswer = false; //végigmegyünk az xml -en és végül kapunk egy listát ami a kérdések azonosítóit tartalmazza (arrQuestionID) // egy listát ami a kérdésekre adott válaszokat tartalmazza (arrAnswer) valamint megkapjuk még a // Program ID -t és a Template ID -t while (xmlReader.Read()) { switch (xmlReader.NodeType) { case XmlNodeType.Element: strName = xmlReader.Name; //különösen érdekesek számunkra az alábbi node -ok switch (strName) { case "Program": if (xmlReader.HasAttributes) { strProgID = xmlReader.GetAttribute("ID"); } break; case "Template": if (xmlReader.HasAttributes) { strTemplateID = xmlReader.GetAttribute("ID"); } break; case "TemplateDetail": arrQuestionID.Add(xmlReader.GetAttribute("ID")); break; case "Answer": blnIsAnswer = true; break; } break; case XmlNodeType.EndElement: strName = xmlReader.Name; break; case XmlNodeType.Text: break; case XmlNodeType.CDATA: if (blnIsAnswer) { arrAnswer.Add(xmlReader.Value); blnIsAnswer = false; } break; default: break; } } } catch (XmlException ee) { Console.WriteLine("ERROR : " + ee.Message); } finally { if (xmlReader != null) xmlReader.Close(); } //********************** TEST ***********************// // kiírjuk a kibányászott adatokat ... //Response.Write("\n ProgID :" + strProgID); //Response.Write("\n TemplateID :" + strTemplateID); /* //az alábbi résszel kiírathatjuk a felküldött válaszokat try { int i=1; if(arrQuestionID.Count == arrAnswer.Count) { for(i=1;i<=arrQuestionID.Count;i++) { Response.Write("\n\n"+i+" : "+arrQuestionID[i-1].ToString()+ " - " +arrAnswer[i-1].ToString()); } } else Response.Write("\n Hibás xml , a válaszok és a kérdések száma eltérõ"); } catch(Exception err) { Response.Write("\n"+err.Message); } */ //********************** TEST ***********************// //beállítjuk a securityt (szükséges a Template adatok lekérdezéséhez az adatbázisból) try { Guid progGuid = new Guid(strProgID); Guid templGuid = new Guid(strTemplateID); // string req = Request.Url.Query.Replace("?user="******""); // string userName = req.Substring(0,req.IndexOf("&passw=")); // string userPassw = req.Substring(req.IndexOf("&passw=")).Replace("&passw=",""); string req = Request.Url.Query.Replace("?user="******""); string userName = req.Substring(0, req.IndexOf("&passw=")); req = req.Substring(req.IndexOf("&passw=")).Replace("&passw=", ""); string userPassw = req.Substring(0, req.IndexOf("&confirm")); confirm = Convert.ToBoolean(Request["confirm"]); NdiPrincipal principal = HelpersOffline.AuthLogin(userName, userPassw, Context.User.Identity); if (principal != null) { Context.User = principal; Thread.CurrentPrincipal = principal; string mode = ""; //pogID és templateID alapján visszaadja az adott template hez tartozó ID -t, QF ID -t , PQF ID -t és státuszt ITemplateService srv = ServiceFactory.GetTemplateService(); Template tmplCurrentPending = srv.TemplateSelectOfProgramPendingQuestionFormByTemplateID(progGuid, templGuid); //Response.Write("\n PQF ID : "+tmplCurrentPending.PendingQuestionFormID.ToString()); //Response.Write("\n QF ID : "+tmplCurrentPending.QuestionFormID.ToString()); //Response.Write("\n Status : "+tmplCurrentPending.Status.Value.ToString()); //------------------------------------------------------------------------- // QF | PQF | akt. státusz | mûvelet | új státusz | //------------------------------------------------------------------------- // null | null | - | insert | NWD | I.eset //------------------------------------------------------------------------- // null | X | NEW | update | NWD | II.eset //------------------------------------------------------------------------- // null | X | NWD | exception | - | III.eset //------------------------------------------------------------------------- // X | null | - | insert | UWD | IV.eset //------------------------------------------------------------------------- // X | X | UPD | update | UWD | V.eset //------------------------------------------------------------------------- // X | X | UWD | exception | - | VI.eset //------------------------------------------------------------------------- if (tmplCurrentPending.Status.IsNull) { if (tmplCurrentPending.QuestionFormID.IsNull) { mode = "empty"; // I. eset } else { // kitöltve elfogadva // --- A felhasználótól megerõsítést kér, ha még nem tette if (!confirm) throw new Exception("ELFOGADVA"); mode = "accepted"; // IV. eset } } else { mode = "pending"; // III. és VI. eset if (tmplCurrentPending.Status.Equals("NEW")) { mode = "new"; // II. eset // --- A felhasználótól megerõsítést kér, ha még nem tette if (!confirm) throw new Exception("CONFIRM"); } if (tmplCurrentPending.Status.Equals("UPD")) { mode = "upd"; // V. eset // --- A felhasználótól megerõsítést kér, ha még nem tette if (!confirm) throw new Exception("CONFIRM"); } } //ha pending akkor nem megyünk tovább mert nem módosítható if (mode.ToString() == "pending") { //Response.Write("\n PENDING - ELFOGADÁSRA VÁR -> NEM MÓDOSÍTHATÓ"); throw new Exception( "A portálon ez a kérdõív már kitöltött és jóváhagyásra vár. Ebben a státuszban a kérdõív nem módosítható, illetve írható felül."); } ITemplateService templateService = ServiceFactory.GetTemplateService(); Template tmplCurrent = templateService.TemplateSelect(templGuid); foreach (TemplateDetail templateDetail in tmplCurrent.Details.All) { if (templateDetail.IsActive) { //Response.Write("\n "+templateDetail.ID+" - "+templateDetail.Question.Value.ToString()); templateDetail.Answer = SearchForAnsver(templateDetail.ID); if (!templateDetail.Validate()) { throw new Exception(templateDetail.ID + "##" + templateDetail.ValidationSummary); } } } IPendingQuestionFormService formSrv = ServiceFactory.GetPendingQuestionFormService(); DBGuid pendingQFGuid = DBGuid.Null; string status = ""; string method = ""; string pendingQFID = tmplCurrentPending.PendingQuestionFormID.ToString(); Guid templateGuid = new Guid(tmplCurrentPending.ID.ToString()); DBGuid origQFGuid = DBGuid.Null; //Response.Write("\nMode : "+ mode); switch (mode.ToLower()) { case "empty": pendingQFGuid = Guid.NewGuid(); status = "NWD"; method = "insert"; break; case "accepted": pendingQFGuid = Guid.NewGuid(); origQFGuid = new Guid(tmplCurrentPending.QuestionFormID.ToString()); status = "UWD"; method = "insert"; break; case "new": pendingQFGuid = new Guid(pendingQFID); status = "NWD"; method = "update"; break; case "upd": pendingQFGuid = new Guid(pendingQFID); PendingQuestionForm pqf = formSrv.PendingQuestionFormSelect(pendingQFGuid); origQFGuid = pqf.QuestionFormRef; status = "UWD"; method = "update"; break; } // Build document: //TemplateControl1.SetAnswer(); PendingQuestionForm form = new PendingQuestionForm(pendingQFGuid); form.TemplateRef = templateGuid; form.Status = status; form.QuestionFormRef = origQFGuid; form.ProgramID = progGuid; foreach (TemplateDetail templateDetail in tmplCurrent.Details.All) { PendingQuestionFormDetail questionDetail = new PendingQuestionFormDetail(form.ID, templateDetail.ID, templateGuid); questionDetail.Answer = templateDetail.Answer; //Response.Write("\n Answer : "+templateDetail.Answer); form.Details.Add(questionDetail); } // Save data: if (method.ToString() == "insert") { Response.Write("INSERT_OK"); formSrv.PendingQuestionFormInsertForProgram(form); } if (method.ToString() == "update") { Response.Write("UPDATE_OK"); formSrv.PendingQuestionFormUpdateForProgram(form); } //Response.Write("\n Status : "+form.Status.Value.ToString()); } else { Response.Write(HelpersOffline.ErrorXML("AUTH")); } } catch (Exception ex) { Response.Clear(); Response.Write(HelpersOffline.ErrorXML(ex.Message)); } } }