public ActionResult Display(string id) { ScreenViewer.API.Elements.QuestionareController QC = new API.Elements.QuestionareController(); var actionResult = QC.GetScriptQuestionare(Convert.ToDecimal(id)); var response = actionResult as OkNegotiatedContentResult <Data.ScriptQuestionare>; QuestionController QuestController = new QuestionController(); if (response != null) { Data.ScriptQuestionare theQuestionare = response.Content; List <QuestionLayout> QuestionLayout = new List <QuestionLayout>(); ViewBag.QID = theQuestionare.ScriptQuestionareID; string qincluded = ""; //StringBuilder SBstyles = new StringBuilder(""); //if (theQuestionare.BackColor != "Not Selected") //{ // SBstyles.Append("background-color:" + theQuestionare.BackColor + "; "); //} //if (theQuestionare.FontColor != "Not Selected") //{ // SBstyles.Append("color:" + theQuestionare.FontColor + "; "); //} //if (theQuestionare.BorderColor != "Not Selected") //{ // SBstyles.Append("border-color:" + theQuestionare.BorderColor + "; "); //} //SBstyles.Append(theQuestionare.FontFamily + " "); //SBstyles.Append("font-size:" + theQuestionare.FontSize); //@ViewBag.Tablestyle = SBstyles.ToString(); foreach (Data.ScriptQuestionareDetail questionitem in theQuestionare.ScriptQuestionareDetails) { if (questionitem.ShowWhen > 0) { ClauseEvaluator CE = new ClauseEvaluator(HttpContext.Session); bool continueSection = CE.EvaluateClause(questionitem.ShowWhen.ToString(), Convert.ToInt32(questionitem.Showif)); if (continueSection) { QuestionLayout.Add(QuestController.RenderQuestionParts((decimal)questionitem.ScriptQuestionID, false, ControllerContext)); qincluded = qincluded == "" ? questionitem.ScriptQuestionID.ToString() : qincluded + "," + questionitem.ScriptQuestionID.ToString(); } } else { QuestionLayout.Add(QuestController.RenderQuestionParts((decimal)questionitem.ScriptQuestionID, false, ControllerContext)); qincluded = qincluded == "" ? questionitem.ScriptQuestionID.ToString() : qincluded + "," + questionitem.ScriptQuestionID.ToString(); } } ViewBag.QuestionList = qincluded; ViewBag.QuestionLayout = QuestionLayout; ViewBag.Heading = theQuestionare.QuestionareDesc; string[] layout = theQuestionare.LayoutType.Split(':'); if (layout[0] == "S") { return(PartialView("_QuestionareView" + layout[1] + "col", QuestionLayout)); } else { return(PartialView("_QuestionareView" + layout[1] + "colover", QuestionLayout)); } } else { return(null); } }
public string RenderQuestionParts(decimal id, ScreenViewer.Models.CriticalElements criticalelement, ControllerContext ContCont) { ScreenViewer.API.Elements.QuestionareController QC = new API.Elements.QuestionareController(); var actionResult = QC.GetScriptQuestionare(Convert.ToDecimal(id)); var response = actionResult as OkNegotiatedContentResult <Data.ScriptQuestionare>; QuestionController QuestController = new QuestionController(); if (response != null) { Data.ScriptQuestionare theQuestionare = response.Content; List <QuestionLayout> QuestionLayout = new List <QuestionLayout>(); ViewBag.QID = theQuestionare.ScriptQuestionareID; string qincluded = ""; StringBuilder SBstyles = new StringBuilder(""); //SBstyles.Append("border-spacing: 10px;border-collapse: separate;"); //if (theQuestionare.BackColor != "Not Selected") //{ // SBstyles.Append("background-color:" + theQuestionare.BackColor + "; "); //} //if (theQuestionare.FontColor != "Not Selected") //{ // SBstyles.Append("color:" + theQuestionare.FontColor + "; "); //} //if (theQuestionare.BorderColor != "Not Selected") //{ // SBstyles.Append("border-color:" + theQuestionare.BorderColor + "; "); //} //if (theQuestionare.GridLines.Value) // @ViewBag.GridLine = "1"; //else // @ViewBag.GridLine = "0"; //SBstyles.Append(theQuestionare.FontFamily + " "); //SBstyles.Append("font-size:" + theQuestionare.FontSize); @ViewBag.Tablestyle = SBstyles.ToString(); foreach (Data.ScriptQuestionareDetail questionitem in theQuestionare.ScriptQuestionareDetails) { if (questionitem.ShowWhen > 0) { ClauseEvaluator CE = new ClauseEvaluator(ContCont.HttpContext.Session); bool continueSection = CE.EvaluateClause(questionitem.ShowWhen.ToString(), Convert.ToInt32(questionitem.Showif)); if (continueSection) { bool crit = false; if (criticalelement.CriticalItems) { if (criticalelement.CriticalQuestions.Contains(questionitem.ScriptQuestionID.ToString())) { crit = true; } } QuestionLayout.Add(QuestController.RenderQuestionParts((decimal)questionitem.ScriptQuestionID, crit, ContCont)); qincluded = qincluded == "" ? questionitem.ScriptQuestionID.ToString() : qincluded + "," + questionitem.ScriptQuestionID.ToString(); } } else { bool crit = false; if (criticalelement.CriticalItems) { if (criticalelement.CriticalQuestions.Contains(questionitem.ScriptQuestionID.ToString())) { crit = true; } } QuestionLayout.Add(QuestController.RenderQuestionParts((decimal)questionitem.ScriptQuestionID, crit, ContCont)); qincluded = qincluded == "" ? questionitem.ScriptQuestionID.ToString() : qincluded + "," + questionitem.ScriptQuestionID.ToString(); } } ViewBag.QuestionList = qincluded; ViewBag.QuestionCount = QuestionLayout.Count; ViewBag.QuestionLayout = QuestionLayout; ViewBag.Title = theQuestionare.QuestionareDesc; string[] layout = theQuestionare.LayoutType.Split(':'); string vname = ""; if (layout[0] == "S") { vname = "~/Views/Questionare/_QuestionareView" + layout[1] + "col" + ".cshtml"; } else { vname = "~/Views/Questionare/_QuestionareView" + layout[1] + "colover" + ".cshtml"; } return(RenderHelper.RenderViewToString(ContCont, vname, QuestionLayout, ViewData)); } else { return(null); } }
public string Render(Int32 id, ScreenViewer.Models.CriticalElements criticalelement, ControllerContext ContCont) { ScreenViewer.API.ScriptLayoutsController SC = new API.ScriptLayoutsController(); var actionResult = SC.GetScriptLayout(Convert.ToInt32(id)); var response = actionResult as OkNegotiatedContentResult <ScriptLayout>; if (response != null) { ScriptLayout SL = response.Content; string qincluded = ""; bool critItems = false; QuestionController QuestController = new QuestionController(); QuestionLayout questionLayout = null; List <ScriptLayoutE> ScriptLayouts = new List <ScriptLayoutE>(); foreach (ScriptLayoutDetail slitem in SL.ScriptLayoutDetails) { ScriptLayoutE layout = new ScriptLayoutE(); string aclass = ""; switch (slitem.ElementAlignment) { case "top-left": aclass = "div_top text-left"; break; case "top-center": aclass = "div_top text-center"; break; case "top-right": aclass = "div_top text-right"; break; case "middle-left": aclass = "div_middle text-left"; break; case "middle-center": aclass = "div_middle text-center"; break; case "middle-right": aclass = "div_middle text-right"; break; case "bottom-left": aclass = "div_bottom text-left"; break; case "bottom-center": aclass = "div_bottom text-center"; break; case "bottom-right": aclass = "div_bottom text-right"; break; default: aclass = "div_top text-left"; break; } layout.Scriptlayoutdetail = slitem; layout.AlignClass = aclass; if (slitem.ElementType == "Question") { qincluded = qincluded == "" ? slitem.ElementID.ToString() : qincluded + "," + slitem.ElementID.ToString(); if (criticalelement.CriticalItems) { if (criticalelement.CriticalQuestions.Contains(slitem.ElementID.ToString())) { layout.CriticalElement = true; } } } else if (slitem.ElementType == "OrderItem" && critItems) { layout.CriticalElement = true; } else { layout.CriticalElement = false; } switch (slitem.ElementType) { case "Question": questionLayout = QuestController.RenderQuestionParts((decimal)layout.Scriptlayoutdetail.ElementID, layout.CriticalElement, ContCont); questionLayout.QuestionHTML = questionLayout.QuestionHTML.Replace("\r", ""); questionLayout.QuestionHTML = questionLayout.QuestionHTML.Replace("\n", ""); questionLayout.QuestionHTML = questionLayout.QuestionHTML.Replace(@"""", @"\"""); questionLayout.QuestionHTML = questionLayout.QuestionHTML.Replace("</script>", string.Format("\" + {0} + \"", "unescape('%3C/script%3E')")); questionLayout.QuestionLabelText = questionLayout.QuestionLabelText.Replace("\r", ""); questionLayout.QuestionLabelText = questionLayout.QuestionLabelText.Replace("\n", ""); questionLayout.QuestionLabelText = questionLayout.QuestionLabelText.Replace(@"""", @"\"""); layout.QuestionLayout = questionLayout; break; case "TextHTML": TextHTMLController THC = new TextHTMLController(); layout.TextHTMLLayout = THC.Render(Convert.ToInt32(layout.Scriptlayoutdetail.ElementID), ContCont); layout.TextHTMLLayout = HttpUtility.HtmlDecode(layout.TextHTMLLayout); layout.TextHTMLLayout = layout.TextHTMLLayout.Replace("\r", ""); layout.TextHTMLLayout = layout.TextHTMLLayout.Replace("\n", ""); layout.TextHTMLLayout = layout.TextHTMLLayout.Replace(@"""", @"\"""); layout.TextHTMLLayout = layout.TextHTMLLayout.Replace(@"\\", @"\"); layout.TextHTMLLayout = layout.TextHTMLLayout.Replace("</script>", string.Format("\" + {0} + \"", "unescape('%3C/script%3E')")); layout.TextHTMLLayout = layout.TextHTMLLayout.Replace("'s", "'s"); break; case "Link": LinkController LC = new LinkController(); layout.LinkLayout = LC.Render(Convert.ToInt32(layout.Scriptlayoutdetail.ElementID), ContCont); layout.LinkLayout = layout.LinkLayout.Replace("\r", ""); layout.LinkLayout = layout.LinkLayout.Replace("\n", ""); layout.LinkLayout = layout.LinkLayout.Replace(@"""", @"\"""); layout.LinkLayout = layout.LinkLayout.Replace("</script>", string.Format("\" + {0} + \"", "unescape('%3C/script%3E')")); break; } ScriptLayouts.Add(layout); } List <ScriptLayoutE> orderedLayout = ScriptLayouts.OrderBy(o => o.Scriptlayoutdetail.RowNumber).ThenBy(o => o.Scriptlayoutdetail.Sequence).ToList(); ViewBag.QuestionList = qincluded; return(RenderHelper.RenderViewToString(ContCont, "~/Views/ScriptLayout/_ScriptLayout.cshtml", orderedLayout, ViewData)); } else { return(""); } }