public virtual void PendingQuestionFormDetailDelete(PendingQuestionFormDetail entity) { TraceCallEnterEvent.Raise(); try { m_DataContext.BeginNestedTran(); try { m_DataContext.ndihdPendingQuestionFormDetailDelete(entity.QuestionFormRef, entity.TemplateDetailRef, entity.TemplateRef); m_DataContext.CommitNested(); } catch { m_DataContext.RollbackNested(); throw; } TraceCallReturnEvent.Raise(); return; } catch (Exception ex) { ExceptionManager.Publish(ex); TraceCallReturnEvent.Raise(false); throw; } }
public new void PendingQuestionFormDetailInsert(PendingQuestionFormDetail entity) { TraceCallEnterEvent.Raise(); try { base.PendingQuestionFormDetailInsert(entity); BusinessAuditEvent.Success( new EventParameter("QuestionFormRef", entity.QuestionFormRef.ToString()), new EventParameter("QuestionFormTemplateRef", entity.TemplateRef.ToString()), new EventParameter("QuestionFormTemplateDetailRef", entity.TemplateDetailRef) ); TraceCallReturnEvent.Raise(); return; } catch (Exception ex) { ExceptionManager.Publish(ex); BusinessAuditEvent.Fail( new EventParameter("Exception", ex.ToString()), new EventParameter("QuestionFormRef", entity.QuestionFormRef.ToString()), new EventParameter("QuestionFormTemplateRef", entity.TemplateRef.ToString()), new EventParameter("QuestionFormTemplateDetailRef", entity.TemplateDetailRef) ); 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; } }
// ------------------------------------------------------------------------------------- /// <summary> /// Copy constructor. /// </summary> /// <param name="QuestionFormRefVal">Value of 'uQuestionFormRef' field</param> /// <param name="TemplateDetailRefVal">Value of 'cTemplateDetailRef' field</param> /// <param name="TemplateRefVal">Value of 'uTemplateRef' field</param> /// <param name="origInstance">Original document data to copy.</param> // ------------------------------------------------------------------------------------- public PendingQuestionFormDetail(DBGuid QuestionFormRefVal, DBString TemplateDetailRefVal, DBGuid TemplateRefVal, PendingQuestionFormDetail origInstance) : base(QuestionFormRefVal, TemplateDetailRefVal, TemplateRefVal, origInstance) { }
// ------------------------------------------------------------------------------------- /// <summary> /// Copy constructor. /// </summary> /// <param name="origInstance">Original document data to copy.</param> // ------------------------------------------------------------------------------------- public PendingQuestionFormDetail(PendingQuestionFormDetail origInstance) : base(origInstance) { }
public virtual void PendingQuestionFormDetailUpdate(PendingQuestionFormDetail entity) { TraceCallEnterEvent.Raise(); try { m_DataContext.BeginNestedTran(); try { int count; m_DataContext.ndihdPendingQuestionFormDetailUpdate(entity.QuestionFormRef, entity.TemplateDetailRef, entity.TemplateRef, entity.Answer, 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 virtual PendingQuestionFormDetail PendingQuestionFormDetailSelect(DBGuid QuestionFormRefVal, DBString TemplateDetailRefVal, DBGuid TemplateRefVal) { TraceCallEnterEvent.Raise(); try { PendingQuestionFormDetail result = null; DataSet entitySet = m_DataContext.ndihdPendingQuestionFormDetailSelect(QuestionFormRefVal, TemplateDetailRefVal, TemplateRefVal); if (entitySet.Tables[0].Rows.Count != 0) { result = new PendingQuestionFormDetail(entitySet); } TraceCallReturnEvent.Raise(); return result; } 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 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; } }
private void AcceptQuestionForm() { IPendingQuestionFormService srv = ServiceFactory.GetPendingQuestionFormService(); m_PendingQuestionForm.Details = new PendingQuestionFormDetailContainer(); foreach (IQuestion question in templCtrlEdit.Questions) { TemplateDetail detail = (TemplateDetail) question; PendingQuestionFormDetail questionDetail = new PendingQuestionFormDetail(m_PendingQuestionForm.ID, detail.ID, m_PendingQuestionForm.TemplateRef); questionDetail.Answer = detail.Answer; m_PendingQuestionForm.Details.Add(questionDetail); } if (m_PendingQuestionForm.Status.Equals(QuestionFormStatus.New_WaitingForDecision)) { if (!srv.PendingQuestionFormAcceptNew(m_PendingQuestionForm)) { MessageBox.Show("Az elfogadás megtörtént, de az értesítõ levél kiküldése nem sikerült.", "NDI HelpDesk Administrator", MessageBoxButtons.OK, MessageBoxIcon.Warning); } SaveProgramInGlobalSearch(); } if (m_PendingQuestionForm.Status.Equals(QuestionFormStatus.Updated_WaitingForDecision)) { if (!srv.PendingQuestionFormAcceptUpdated(m_PendingQuestionForm)) { MessageBox.Show("Az elfogadás megtörtént, de az értesítõ levél kiküldése nem sikerült.", "NDI HelpDesk Administrator", MessageBoxButtons.OK, MessageBoxIcon.Warning); } SaveProgramInGlobalSearch(); } }
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)); } } }