public async Task <ActionResult> EquipmentClassDashboard() { ViewBag.Version = Global._sfAdminVersion; int EquipmentClassId = 0, DashboardId = 0; string endPoint = "", EquipmentId = ""; ViewBag.WidgetOutput = "<H2>Nothing Found.</H2>"; ViewBag.WidgetUpdateFunctions = ""; EmployeeSession empSession = null; if (Session["empSession"] != null) { empSession = EmployeeSession.LoadByJsonString(Session["empSession"].ToString()); } ViewBag.PermissionList = empSession.permissions; if (Request.QueryString["equipmentId"] != null || Request.Form["equipmentId"] != null) { try { RestfulAPIHelper apiHelper = new RestfulAPIHelper(); if (Request.QueryString["equipmentId"] != null) { EquipmentId = Request.QueryString["equipmentId"].ToString(); } else { EquipmentId = Request.Form["equipmentId"].ToString(); } endPoint = Global._equipmentEndPoint + "/" + EquipmentId; string equipmentString = await apiHelper.callAPIService("GET", endPoint, null); endPoint = Global._dashboardInCompanyEndPoint + "?type=equipmentclass"; string equipmentClassDashboardJson = await apiHelper.callAPIService("GET", endPoint, null); try { dynamic equipmentObj = JObject.Parse(equipmentString); EquipmentClassId = equipmentObj.EquipmentClassId; ViewBag.EquipmentId = (string)equipmentObj.EquipmentId; dynamic dashboardObjs = JsonConvert.DeserializeObject(equipmentClassDashboardJson); foreach (var dashboard in dashboardObjs) { if (dashboard.EquipmentClassId == EquipmentClassId) { DashboardId = dashboard.Id; break; } } if (DashboardId > 0) { ViewBag.WidgetCatalogList = await apiHelper.callAPIService("GET", Global._widgetCatalogInCompanyEndPoint + "?level=equipment", null); ViewBag.DashboardId = DashboardId; endPoint = Global._widgetInDashboardEndPoint + "/" + DashboardId; string widgetJson = await apiHelper.callAPIService("GET", endPoint, null); if (!string.IsNullOrEmpty(widgetJson)) { DashboardModel dashboardModel = new DashboardModel(); dashboardModel.GenerateWidgetHTMLContent(equipmentString, widgetJson); ViewBag.WidgetOutput = dashboardModel.GetWidgetHTMLContent(); ViewBag.WidgetUpdateFunctions = dashboardModel.GetWidgetJavaScriptFunction(); ViewBag.AlarmWidgetUpdateFunctions = dashboardModel.GetAlarmWidgetJavaScriptFunction(); } } } catch (Exception) { ; } ViewBag.CompanyId = empSession.companyId; } catch (Exception ex) { LoginMsgSession loginMsgSession = new LoginMsgSession(); if (ex.Message.ToLower() == "invalid session") { loginMsgSession.toastLevel = "warning"; loginMsgSession.message = "[[[Please Login]]]"; } else { loginMsgSession.toastLevel = "error"; loginMsgSession.message = "[[[Authentication Fail]]]."; StringBuilder logMessage = new StringBuilder(); logMessage.AppendLine("audit: Authentication Fail."); logMessage.AppendLine("email:" + empSession.email); logMessage.AppendLine("password:"******"loginMsgSession"] = loginMsgSession.Serialize(); return(RedirectToAction("Index", "Home")); } } return(View()); }