public ActionResult DisplayByName(string projectname) { try { Session["ReturnURL"] = System.Web.HttpContext.Current.Request.Url.PathAndQuery; if (!ScreenViewer.SignInHelper.ValidateSignIn()) { return(RedirectToAction("Login", "Account", new { ReturnUrl = Session["ReturnURL"].ToString() })); } ScreenViewer.API.ProjectController PC = new API.ProjectController(); int projectId = PC.GetProjectId(projectname); SessionManager.ClearSessionData(HttpContext.Session); AddProgramParameter(); TempData["addparams"] = true; return(RedirectToAction("Display", "Project", new { id = projectId })); } catch (Exception ex) { Data.Log log = ex.Save(HttpContext.Session, WorkflowHelper.BuildCallData(HttpContext.Session), ImpactLevel.High); ViewBag.URL = System.Web.HttpContext.Current.Request.Url; return(View("Error", new HandleErrorInfo(ex, "ProjectController", "DisplayByName"))); } }
public string Render(int ID, ControllerContext ContCont) { ScreenViewer.API.ProjectController PC = new API.ProjectController(); var scriptMenu = PC.GetScriptProjectMenu(ID); var menuResponse = scriptMenu as OkNegotiatedContentResult <Data.ScriptMenu>; Data.ScriptMenu theLinkGroup = menuResponse.Content; DataTable menuTable = new DataTable(); menuTable.Columns.Add("Item", typeof(string)); menuTable.Columns.Add("Url", typeof(string)); menuTable.Columns.Add("Window", typeof(string)); using (StringReader sr = new StringReader(menuResponse.Content.MenuXML)) { XmlSerializer xs = new XmlSerializer(typeof(ScriptUL)); ScriptUL ul = (ScriptUL)xs.Deserialize(sr); List <MenuItem> lstMenuItem = new List <MenuItem>(); foreach (ScriptLI li in ul.LIArray) { lstMenuItem.Add(PopulateMenuItem(li)); } ViewBag.LinkGroup = lstMenuItem; ViewBag.Orientation = theLinkGroup.MenuOrientation; } return(RenderHelper.RenderViewToString(ContCont, "~/Views/LinkGroup/_LinkGroup.cshtml", theLinkGroup, ViewData)); }
public string GetMenu(int MenuID) { ScreenViewer.API.ProjectController PC = new API.ProjectController(); var scriptMenu = PC.GetScriptProjectMenu(MenuID); var menuResponse = scriptMenu as OkNegotiatedContentResult <ScriptMenu>; ScriptUL ul; using (StringReader sr = new StringReader(menuResponse.Content.MenuXML)) { XmlSerializer xs = new XmlSerializer(typeof(ScriptUL)); ul = (ScriptUL)xs.Deserialize(sr); // SessionControl.SessionManager.StoreMenu(HttpContext.Session, lstMenuItem); } StringWriter stringWriter = new StringWriter(); string menuType = "Navbar"; string addClass = ""; using (HtmlTextWriter writer = new HtmlTextWriter(stringWriter)) { switch (menuType) { case "Tabbed": addClass = "nav nav-tabs"; break; case "Pills": addClass = "nav nav-pills"; break; case "Navbar": writer.AddAttribute(HtmlTextWriterAttribute.Class, "navbar navbar-default"); writer.RenderBeginTag("nav"); writer.AddAttribute(HtmlTextWriterAttribute.Class, "container"); writer.RenderBeginTag(HtmlTextWriterTag.Div); addClass = "nav navbar-nav"; break; } writer.AddAttribute(HtmlTextWriterAttribute.Class, addClass); writer.RenderBeginTag(HtmlTextWriterTag.Ul); // Begin #1 foreach (ScriptLI li in ul.LIArray) { writer.Write(PopulateLItem(li)); } writer.RenderEndTag(); if (menuType == "Navbar") { writer.RenderEndTag(); } } return(stringWriter.ToString()); }
public ActionResult Display(int id) { try { ScreenViewer.API.ProjectController PC = new API.ProjectController(); var actionResult = PC.GetScriptProject(id); var response = actionResult as OkNegotiatedContentResult <ScriptProject>; ScriptProject scriptProject = response.Content; if (TempData["addparams"] == null || !(bool)TempData["addparams"]) { SessionManager.ClearSessionData(HttpContext.Session); if (!ScreenViewer.SignInHelper.ValidateSignIn()) { return(RedirectToAction("Login", "Account", new { ReturnUrl = System.Web.HttpContext.Current.Request.Url.ToString() })); } AddProgramParameter(); } SessionControl.SessionManager.StoreProjectId(HttpContext.Session, id); SessionControl.SessionManager.StoreProjectName(HttpContext.Session, scriptProject.ProjectName); SessionControl.SessionManager.StoreProjectDescription(HttpContext.Session, scriptProject.ProjectDesc); SessionControl.SessionManager.StoreScreenLayout(HttpContext.Session, scriptProject.ScreenLayout); SessionControl.SessionManager.StoreNotificationText(HttpContext.Session, scriptProject.NotificationText); if (!string.IsNullOrEmpty(scriptProject.ScreenLayout)) { ScreenViewer.API.WorkflowLayoutsController WLC = new ScreenViewer.API.WorkflowLayoutsController(); var actionResult2 = WLC.GetWorkflowLayoutString(SessionManager.GetScreenLayout(HttpContext.Session), SessionManager.GetClientId(HttpContext.Session)); if (actionResult2 != null && actionResult2 != actionResult2 as System.Web.Http.Results.NotFoundResult) { var layoutResponse = actionResult2 as OkNegotiatedContentResult <string>; SessionControl.SessionManager.StoreLayoutHTML(HttpContext.Session, layoutResponse.Content); } } if (scriptProject.ScriptProjectWorkflows.Count > 0) { if (scriptProject.RequireKey.Value) { string key = SessionControl.SessionManager.GetScriptParameterByKey("key", HttpContext.Session); if (!string.IsNullOrEmpty(key)) { if (!key.Equals(scriptProject.KeyText.ToString())) { throw new Exception(string.Format("Unable to verify the project key {0}.", key)); } } else { throw new Exception(string.Format("Project key is missing.")); } } // Create the contact record CreateContactRecord(scriptProject.ProjectName); if (scriptProject.LogoImageID != null && scriptProject.LogoImageID != 0) { var imageResult = PC.GetScriptProjectImage(scriptProject.LogoImageID.Value); var imageResponse = imageResult as OkNegotiatedContentResult <ScriptImage>; SessionControl.SessionManager.StoreLogoImage(HttpContext.Session, ((ScriptImage)imageResponse.Content).Image); } if (scriptProject.ScriptMenuID != null && scriptProject.ScriptMenuID != 0) { var scriptMenu = PC.GetScriptProjectMenu(scriptProject.ScriptMenuID.Value); var menuResponse = scriptMenu as OkNegotiatedContentResult <ScriptMenu>; ScriptUL ul; using (StringReader sr = new StringReader(menuResponse.Content.MenuXML)) { XmlSerializer xs = new XmlSerializer(typeof(ScriptUL)); ul = (ScriptUL)xs.Deserialize(sr); } StringWriter stringWriter = new StringWriter(); string menuType = "Navbar"; string addClass = ""; using (HtmlTextWriter writer = new HtmlTextWriter(stringWriter)) { switch (menuType) { case "Tabbed": addClass = "nav nav-tabs"; break; case "Pills": addClass = "nav nav-pills"; break; case "Navbar": writer.AddAttribute(HtmlTextWriterAttribute.Class, "navbar navbar-default"); writer.RenderBeginTag("nav"); writer.AddAttribute(HtmlTextWriterAttribute.Class, "container"); writer.RenderBeginTag(HtmlTextWriterTag.Div); addClass = "nav navbar-nav"; break; } writer.AddAttribute(HtmlTextWriterAttribute.Class, addClass); writer.RenderBeginTag(HtmlTextWriterTag.Ul); // Begin #1 foreach (ScriptLI li in ul.LIArray) { writer.Write(PopulateLItem(li)); } writer.RenderEndTag(); if (menuType == "Navbar") { writer.RenderEndTag(); } } SessionControl.SessionManager.StoreMenu(HttpContext.Session, stringWriter.ToString()); } if (scriptProject.ShowWorkflowSection.Value) { SessionControl.SessionManager.StoreProgramParameter("Section", "Yes", HttpContext.Session); } if (scriptProject.ShowWorkflowSection.Value) { SessionControl.SessionManager.StoreProgramParameter("Workflow", "Yes", HttpContext.Session); } if (scriptProject.ShowNotification.Value) { SessionControl.SessionManager.StoreProgramParameter("Notification", "Yes", HttpContext.Session); } if (scriptProject.ShowNotes.Value) { SessionControl.SessionManager.StoreProgramParameter("CallNotes", "Yes", HttpContext.Session); } if (scriptProject.ShowLead.Value) { SessionControl.SessionManager.StoreProgramParameter("LeadInformation", "Yes", HttpContext.Session); } if (scriptProject.ShowCallback.Value) { SessionControl.SessionManager.StoreProgramParameter("ScheduleCallback", "Yes", HttpContext.Session); } if (scriptProject.ShowLanguage != null && scriptProject.ShowLanguage.Value) { SessionControl.SessionManager.StoreProgramParameter("ShowLanguage", "Yes", HttpContext.Session); } ScriptProjectWorkflow workFlow = scriptProject.ScriptProjectWorkflows.Where(c => c.ScriptWorkflowActiveDate <= DateTime.Now).OrderByDescending(t => t.ScriptWorkflowActiveDate).FirstOrDefault(); return(RedirectToAction("Display", "Workflow", new { id = workFlow.ScriptWorkflowID })); } else { return(View("Display")); } } catch (Exception ex) { Data.Log log = ex.Save(HttpContext.Session, WorkflowHelper.BuildCallData(HttpContext.Session), ImpactLevel.High); ViewBag.URL = SessionManager.GetScriptURL(Session); return(View("Error", new HandleErrorInfo(ex, "ProjectController", "DisplayByName"))); } }