public static bool AddUpdateQuestion(string[] qid, string responsevalue, string responsetext, HttpSessionStateBase Session) { string thevalue = string.Empty; if (responsevalue.Contains("|")) { string[] responses = responsevalue.Split('|'); for (int i = 0; i < qid.Length; i++) { thevalue = SPutilities.ReplaceObjectsandQuestions(Session, responses[i], false); if (thevalue.Contains("Value was not found")) { thevalue = string.Empty; } AddUpdateQuestion(qid[i], thevalue, thevalue, Session); } } else { thevalue = SPutilities.ReplaceObjectsandQuestions(Session, responsevalue, false); foreach (string q in qid) { AddUpdateQuestion(q, responsevalue, responsetext, Session); } } return(true); }
public ActionResult Display(int ID) { ScreenViewer.API.Elements.TextHTMLController TC = new API.Elements.TextHTMLController(); var actionResult = TC.GetScriptTextHTML(Convert.ToDecimal(ID)); var tresponse = actionResult as OkNegotiatedContentResult <Data.ScriptTextHTML>; //Assert.IsNotNull(response); Data.ScriptTextHTML theText = tresponse.Content; var TextHTML = SPutilities.ReplaceObjectsandQuestions(HttpContext.Session, theText.TextHTMLContent, true); ViewBag.TextTitle = theText.TextHTMLDesc; ViewBag.Content = TextHTML; ViewBag.TextID = theText.ScriptTextHTMLID; bool whatif; try { whatif = (bool)theText.ShowDescTooltip; } catch { whatif = false; } if (whatif) { return(PartialView("_TextHTMLpop")); } else { return(PartialView("_TextHTML")); } }
public string RenderHtml(int ID, ControllerContext ContCont) { ScreenViewer.API.Elements.TextHTMLController TC = new API.Elements.TextHTMLController(); var actionResult = TC.GetScriptHTML(Convert.ToDecimal(ID)); var tresponse = actionResult as OkNegotiatedContentResult <Data.ScriptHTML>; Data.ScriptHTML theText = tresponse.Content; var TextHTML = SPutilities.ReplaceObjectsandQuestions(ContCont.HttpContext.Session, theText.HTMLContent, true); ViewBag.TextID = theText.ScriptHTMLID; ViewBag.TextTitle = theText.HTMLDesc; ViewBag.Content = TextHTML; bool whatif; try { whatif = (bool)theText.ShowDescTooltip; } catch { whatif = false; } if (whatif) { return(RenderHelper.RenderViewToString(ContCont, "~/Views/TextHTML/_TextHTMLpop.cshtml", theText, ViewData)); } else { return(RenderHelper.RenderViewToString(ContCont, "~/Views/TextHTML/_TextHTML.cshtml", theText, ViewData)); } }
public string Render(int ID, ControllerContext ContCont) { ScreenViewer.API.Elements.TextHTMLController TC = new API.Elements.TextHTMLController(); var actionResult = TC.GetScriptTextHTML(Convert.ToDecimal(ID)); var tresponse = actionResult as OkNegotiatedContentResult <Data.ScriptTextHTML>; //Assert.IsNotNull(response); Data.ScriptTextHTML theText = tresponse.Content; var TextHTML = SPutilities.ReplaceObjectsandQuestions(ContCont.HttpContext.Session, theText.TextHTMLContent, true); var TextHTML2 = SPutilities.ReplaceObjectsandQuestions(ContCont.HttpContext.Session, theText.TextHTMLAltContent, true); ViewBag.TextID = theText.ScriptTextHTMLID; ViewBag.TextTitle = theText.TextHTMLDesc; if (!string.IsNullOrEmpty(SessionControl.SessionManager.ReturnParameter(ContCont.HttpContext.Session, "SwitchLanguage"))) { ViewBag.Content = !string.IsNullOrEmpty(TextHTML2) ? TextHTML2 : TextHTML; } else { ViewBag.Content = TextHTML; } bool whatif; try { whatif = (bool)theText.ShowDescTooltip; } catch { whatif = false; } if (whatif) { return(RenderHelper.RenderViewToString(ContCont, "~/Views/TextHTML/_TextHTMLpop.cshtml", theText, ViewData)); } else { return(RenderHelper.RenderViewToString(ContCont, "~/Views/TextHTML/_TextHTML.cshtml", theText, ViewData)); } }
public ActionResult SearchKnowledgeBase(string SearchPhrase) { ScreenViewer.API.Elements.TextHTMLController TC = new API.Elements.TextHTMLController(); string clientID = SessionControl.SessionManager.GetClientId(HttpContext.Session); var actionResult = TC.GetKBSearchResults(SearchPhrase, clientID); var tresponse = actionResult as OkNegotiatedContentResult <List <Data.KBSearch_Result> >; List <Data.KBSearch_Result> sr = tresponse.Content; foreach (Data.KBSearch_Result KR in sr) { KR.TextHTMLContent = SPutilities.ReplaceObjectsandQuestions(HttpContext.Session, KR.TextHTMLContent, true); KR.TextHTMLContent = KR.TextHTMLContent.Replace("\r", ""); KR.TextHTMLContent = KR.TextHTMLContent.Replace("\n", ""); KR.TextHTMLContent = KR.TextHTMLContent.Replace(@"""", @"\"""); KR.TextHTMLContent = KR.TextHTMLContent.Replace(@"\\", @"\"); KR.TextHTMLContent = KR.TextHTMLContent.Replace("</script>", string.Format("\" + {0} + \"", "unescape('%3C/script%3E')")); KR.TextHTMLContent = KR.TextHTMLContent.Replace("'s", "'s"); } ViewBag.SearchTerm = SearchPhrase; return(PartialView("KBResultView", sr)); }
//public ActionResult Display(decimal ID) //{ // ViewBag.QuestionID = ID; // var pview = RenderQuestion(ID); // ViewBag.PartialView = pview; // //return RedirectToAction(RenderQuestion(ID)); // return RedirectToAction("RenderQuestion", new { ID = ID }); // //return View("_Question"); //} //public ActionResult Display(decimal ID) //{ // return Display(ID, "false"); //} //public ActionResult Display(decimal ID,bool criticalelement) //{ // ViewBag.QuestionID = ID; // ViewBag.DisplayLabel = true; // ScreenViewer.API.Elements.QuestionController QC = new API.Elements.QuestionController(); // var actionResult = QC.GetScriptQuestion(ID); // var response = actionResult as OkNegotiatedContentResult<Data.ScriptQuestion>; // //Assert.IsNotNull(response); // Data.ScriptQuestion theQuestion = response.Content; // ViewBag.QuestionDisplay = SPutilities.ReplaceObjectsandQuestions(HttpContext.Session, theQuestion.QuestionText,true); // ViewBag.QuestionID = theQuestion.ScriptQuestionID; // ViewBag.ControlName = "SPQuestion_" + theQuestion.ScriptQuestionID; // if (criticalelement) // { // ViewBag.ControlName += "_C"; // } // string cresp = SessionControl.SessionManager.GetQuestionResponse(ID.ToString(), HttpContext.Session); // ViewBag.ReturnType = theQuestion.ResponseType; // ViewBag.AnswerRequired = theQuestion.AnswerRequired.Value ? "required" : string.Empty; // switch (theQuestion.QuestionType) // { // case FREE_TEXT: // ViewBag.CurrentResponse = cresp; // ViewBag.ValidatorRegex = null; // if (theQuestion.ScriptValidatorID != null && theQuestion.ScriptValidatorID != 0) // { // var result = QC.GetScriptTextValidator(theQuestion.ScriptValidatorID.Value); // var ValidatorResponse = result as OkNegotiatedContentResult<Data.ScriptValidator>; // Data.ScriptValidator scriptTextValidator = ValidatorResponse.Content; // ViewBag.ValidatorRegex = scriptTextValidator.ValidatorRegex; // ViewBag.ValidatorDesc = scriptTextValidator.ValidatorDesc; // } // switch (theQuestion.ResponseType) // { // case "Date": // case "DateTime": // case "Time": // return PartialView("_DateTimeQuestion"); // case "Number": // if (theQuestion.MinimumValue != null) // { // ViewBag.MinValue = theQuestion.MinimumValue; // } // if (theQuestion.MaximumValue != null) // { // ViewBag.MaxValue = theQuestion.MaximumValue; // } // return PartialView("_NumericQuestion"); // case "String": // ViewBag.MaxLength = theQuestion.MaxLength; // return PartialView("_TextQuestion"); // } // break; // case CONFIRM: // ViewBag.CurrentResponse = cresp; // ViewBag.Checked = cresp == "True" ? "Checked" : ""; // return PartialView("_ConfirmQuestion"); // case YES_NO: // ViewBag.CurrentResponse = cresp; // ViewBag.YesCheck = cresp == "Yes" ? "Checked" : ""; // ViewBag.NoCheck = cresp == "No" ? "Checked" : ""; // return PartialView("_YesNoQuestion"); // case PICK_ONE_ALT: // case PICK_ONE: // ViewBag.CurrentResponse = cresp == null ? null :cresp; // if (!string.IsNullOrEmpty(theQuestion.DataObjectField)) // { // } // else // { // List<SelectListItem> pickList = CreateDOList(theQuestion.Choices); // ViewBag.PickList = pickList; // ViewBag.PickLength = pickList.Count; // ViewBag.ControlID = "listquestion_" + theQuestion.ScriptQuestionID.ToString(); // return PartialView("_PickOneQuestion"); // } // break; // case PICK_MANY: // ViewBag.CurrentResponse = cresp == null ? null : Regex.Split(cresp, ",").ToList(); // if (!string.IsNullOrEmpty(theQuestion.DataObjectField)) // { // } // else // { // List<SelectListItem> pickList = CreateDOList(theQuestion.Choices); // ViewBag.PickList = pickList; // ViewBag.PickLength = pickList.Count; // ViewBag.ID = theQuestion.ScriptQuestionID.ToString(); // ViewBag.ControlID = "listquestion_" + theQuestion.ScriptQuestionID.ToString(); // return PartialView("_PickManyQuestion"); // } // break; // default: // break; // } // return Content("Blah Blah"); //} public ScreenViewer.Models.Elements.QuestionLayout RenderQuestionParts(decimal ID, bool criticalelement, ControllerContext ContCont) { ScreenViewer.Models.Elements.QuestionLayout questionLayout = new Models.Elements.QuestionLayout(); ViewBag.QuestionID = ID; ViewBag.DisplayLabel = false; ScreenViewer.API.Elements.QuestionController QC = new API.Elements.QuestionController(); var actionResult = QC.GetScriptQuestion(ID); var response = actionResult as OkNegotiatedContentResult <Data.ScriptQuestion>; //Assert.IsNotNull(response); Data.ScriptQuestion theQuestion = response.Content; ViewBag.QuestionDisplay = SPutilities.ReplaceObjectsandQuestions(ContCont.HttpContext.Session, theQuestion.QuestionText, true); ViewBag.QuestionID = theQuestion.ScriptQuestionID; ViewBag.ControlName = "SPQuestion_" + theQuestion.ScriptQuestionID; if (criticalelement) { ViewBag.ControlName += "_C"; } string cresp = SessionControl.SessionManager.GetQuestionResponse(ID.ToString(), ContCont.HttpContext.Session); if (string.IsNullOrEmpty(cresp) && !string.IsNullOrEmpty(theQuestion.KeyCodes)) { if (theQuestion.KeyCodes.StartsWith("DO.")) { string[] holdKeyCode = theQuestion.KeyCodes.Split('.'); string dataObject = holdKeyCode[1]; ScreenViewer.Models.DataObjects ScriptDataObject = (ScreenViewer.Models.DataObjects)SessionControl.SessionManager.GetDataObject(ContCont.HttpContext.Session, dataObject); if (ScriptDataObject != null) { foreach (var detail in ScriptDataObject.Details) { if (detail.DetailName == holdKeyCode[2] && detail.DetailValue != null) { cresp = detail.DetailValue.ToString(); } } } } } ViewBag.ReturnType = theQuestion.ResponseType; try { ViewBag.AnswerRequired = ((bool)theQuestion.AnswerRequired) ? "required" : string.Empty; } catch { ViewBag.AnswerRequired = string.Empty; } questionLayout.QuestionLabelText = ViewBag.QuestionDisplay;//theQuestion.QuestionText; switch (theQuestion.QuestionType) { case FREE_TEXT: ViewBag.Type = "text"; ViewBag.CurrentResponse = cresp; ViewBag.ValidatorRegex = null; if (theQuestion.QuestionDesc.Substring(theQuestion.QuestionDesc.Length - 1) == "$") { ViewBag.Type = "password"; } if (theQuestion.ScriptValidatorID != null && theQuestion.ScriptValidatorID != 0) { var result = QC.GetScriptTextValidator(theQuestion.ScriptValidatorID.Value); var ValidatorResponse = result as OkNegotiatedContentResult <Data.ScriptValidator>; Data.ScriptValidator scriptTextValidator = ValidatorResponse.Content; ViewBag.ValidatorRegex = scriptTextValidator.ValidatorRegex; ViewBag.ValidatorDesc = scriptTextValidator.ValidatorDesc; } switch (theQuestion.ResponseType) { case "Date": case "DateTime": case "Time": questionLayout.QuestionHTML = RenderHelper.RenderViewToString(ContCont, "~/Views/Question/_DateTimeQuestion.cshtml", theQuestion, ViewData); break; case "Number": if (theQuestion.MinimumValue != null) { ViewBag.MinValue = theQuestion.MinimumValue; } if (theQuestion.MaximumValue != null) { ViewBag.MaxValue = theQuestion.MaximumValue; } questionLayout.QuestionHTML = RenderHelper.RenderViewToString(ContCont, "~/Views/Question/_NumericQuestion.cshtml", theQuestion, ViewData); break; case "String": ViewBag.MaxLength = theQuestion.MaxLength; questionLayout.QuestionHTML = RenderHelper.RenderViewToString(ContCont, "~/Views/Question/_TextQuestion.cshtml", theQuestion, ViewData); break; } break; case CONFIRM: ViewBag.CurrentResponse = cresp; ViewBag.Checked = cresp == "True" ? "Checked" : ""; questionLayout.QuestionHTML = RenderHelper.RenderViewToString(ContCont, "~/Views/Question/_ConfirmQuestion.cshtml", theQuestion, ViewData); break; case YES_NO: ViewBag.CurrentResponse = cresp; ViewBag.YesCheck = cresp == "Yes" ? "Checked" : ""; ViewBag.NoCheck = cresp == "No" ? "Checked" : ""; questionLayout.QuestionHTML = RenderHelper.RenderViewToString(ContCont, "~/Views/Question/_YesNoQuestion.cshtml", theQuestion, ViewData); break; case PICK_ONE_ALT: case PICK_ONE: ViewBag.CurrentResponse = cresp == null ? null : cresp; ViewBag.QuestionType = theQuestion.QuestionType; ViewBag.MaxLength = theQuestion.MaxLength; if (!string.IsNullOrEmpty(theQuestion.DataObjectField)) { List <string> displayItems = Regex.Split(theQuestion.DODisplayColumns, "~").ToList(); if (displayItems.Count > 1) { DataTable listtable = CreateObjectSelectList(theQuestion, ContCont.HttpContext.Session); ViewBag.ValueColumn = theQuestion.DOValueColumn; ViewBag.DataTable = listtable; ViewBag.ControlID = "gridquestion_" + theQuestion.ScriptQuestionID.ToString(); ViewBag.OID = theQuestion.ScriptQuestionID.ToString(); questionLayout.QuestionHTML = RenderHelper.RenderViewToString(ContCont, "~/Views/Question/_ObjectSelector.cshtml", theQuestion, ViewData); } else { List <SelectListItem> pickList = CreateDobList(theQuestion, ContCont.HttpContext.Session); ViewBag.PickList = pickList; ViewBag.PickLength = pickList.Count; ViewBag.ControlID = "listquestion_" + theQuestion.ScriptQuestionID.ToString(); questionLayout.QuestionHTML = RenderHelper.RenderViewToString(ContCont, "~/Views/Question/_PickOneQuestion.cshtml", theQuestion, ViewData); break; } } else if (theQuestion.ScriptLookupID != null && theQuestion.ScriptLookupID.Value != 0.0M) { List <SelectListItem> pickList = CreateLookupList(theQuestion, ContCont.HttpContext.Session); ViewBag.PickList = pickList; ViewBag.PickLength = pickList.Count; ViewBag.ControlID = "listquestion_" + theQuestion.ScriptQuestionID.ToString(); questionLayout.QuestionHTML = RenderHelper.RenderViewToString(ContCont, "~/Views/Question/_PickOneQuestion.cshtml", theQuestion, ViewData); break; } else { List <SelectListItem> pickList = CreateDOList(theQuestion.Choices); ViewBag.PickList = pickList; ViewBag.PickLength = pickList.Count; ViewBag.ControlID = "listquestion_" + theQuestion.ScriptQuestionID.ToString(); questionLayout.QuestionHTML = RenderHelper.RenderViewToString(ContCont, "~/Views/Question/_PickOneQuestion.cshtml", theQuestion, ViewData); break; } break; case PICK_MANY: ViewBag.CurrentResponse = cresp == null ? null : Regex.Split(cresp, ",").ToList(); ViewBag.CurrentResponse = cresp == null ? null : Regex.Split(cresp, "~").ToList(); ViewBag.MaxLength = theQuestion.MaxLength; //string pmResponse = string.Empty; //List<string> holdList = cresp == null ? null : Regex.Split(cresp, ",").ToList(); //if (holdList != null && holdList.Count > 0) //{ // foreach (var item in holdList) // { // pmResponse = string.Format("{0}'{1}',", pmResponse, item); // } // pmResponse = pmResponse.TrimEnd(','); // ViewBag.CurrentResponse = System.Web.HttpUtility.JavaScriptStringEncode(pmResponse); //} //else // ViewBag.CurrentResponse = pmResponse; List <string> displayItems2 = null; if (theQuestion.DODisplayColumns != null) { displayItems2 = Regex.Split(theQuestion.DODisplayColumns, "~").ToList(); } if (!string.IsNullOrEmpty(theQuestion.DataObjectField)) { if (displayItems2.Count > 1) { DataTable listtable = CreateObjectSelectList(theQuestion, ContCont.HttpContext.Session); ViewBag.DataTable = listtable; ViewBag.ControlID = "gridquestion_" + theQuestion.ScriptQuestionID.ToString(); questionLayout.QuestionHTML = RenderHelper.RenderViewToString(ContCont, "~/Views/Question/_ObjectSelector.cshtml", theQuestion, ViewData); } else { List <SelectListItem> pickList = CreateDobList(theQuestion, ContCont.HttpContext.Session); ViewBag.PickList = pickList; ViewBag.PickLength = pickList.Count; ViewBag.ID = theQuestion.ScriptQuestionID.ToString(); ViewBag.ControlID = "listquestion_" + theQuestion.ScriptQuestionID.ToString(); questionLayout.QuestionHTML = RenderHelper.RenderViewToString(ContCont, "~/Views/Question/_PickManyQuestion.cshtml", theQuestion, ViewData); } } else if (theQuestion.ScriptLookupID != null && theQuestion.ScriptLookupID.Value != 0.0M) { List <SelectListItem> pickList = CreateLookupList(theQuestion, ContCont.HttpContext.Session); ViewBag.PickList = pickList; ViewBag.PickLength = pickList.Count; ViewBag.ID = theQuestion.ScriptQuestionID.ToString(); ViewBag.ControlID = "listquestion_" + theQuestion.ScriptQuestionID.ToString(); questionLayout.QuestionHTML = RenderHelper.RenderViewToString(ContCont, "~/Views/Question/_PickManyQuestion.cshtml", theQuestion, ViewData); } else { List <SelectListItem> pickList = CreateDOList(theQuestion.Choices); ViewBag.PickList = pickList; ViewBag.PickLength = pickList.Count; ViewBag.ID = theQuestion.ScriptQuestionID.ToString(); ViewBag.ControlID = "listquestion_" + theQuestion.ScriptQuestionID.ToString(); questionLayout.QuestionHTML = RenderHelper.RenderViewToString(ContCont, "~/Views/Question/_PickManyQuestion.cshtml", theQuestion, ViewData); break; } break; default: break; } return(questionLayout); }