public HttpResponseMessage GetAlertLogForMobileByRange(string startDate, string endDate, string deviceID) { List<Hashtable> allAlertLog = new List<Hashtable>(); AlertLogController ctrl = new AlertLogController(); List<AlertLogInfoForMobile> lstAlertLog = ctrl.GetAlertLogForMobileByRange(startDate, endDate, deviceID); foreach (AlertLogInfoForMobile info in lstAlertLog) { Hashtable ht = new Hashtable(); ht.Add("AlertDate", info.AlertDate); ht.Add("countMildly", info.countMildly); ht.Add("countModerately", info.countModerately); ht.Add("countSeverely", info.countSeverely); ht.Add("TotalSevere", info.TotalSevere); allAlertLog.Add(ht); } var jsonToReturn = JsonConvert.SerializeObject(allAlertLog); return Request.CreateResponse(HttpStatusCode.OK, jsonToReturn); }
public HttpResponseMessage GetAlertLogForMobileByPortal(string startDate, string endDate, string portalID) { Type objectType = Type.GetType("Keywin.DNN.Modules.Common.InternalService.Components.InternalServiceController, Keywin.DNN.Modules.Common.InternalService", true, true); Object objComponent = Activator.CreateInstance(objectType); MethodInfo mi = objectType.GetMethod("FetchSubPortalByPortalID"); int pID = PortalSettings.PortalId; if (!string.IsNullOrEmpty(portalID)) pID = int.Parse(portalID); object[] param = { pID }; List<int> portals = (List<int>)mi.Invoke(objComponent, param); portals.Add(pID); System.Text.StringBuilder modules = new System.Text.StringBuilder(); List<int> allModules = new List<int>(); ModuleController mc = new ModuleController(); TabController tc = new TabController(); foreach (int subPortalID in portals) { TabCollection alltc = tc.GetTabsByPortal(subPortalID); foreach (TabInfo tinfo in alltc.Values) { bool canView = DotNetNuke.Security.Permissions.TabPermissionController.CanViewPage(tinfo); Dictionary<int, ModuleInfo> allmcInTab = mc.GetTabModules(tinfo.TabID); foreach (ModuleInfo minfo in allmcInTab.Values) { if (minfo.FriendlyName.Equals("fleetSetting_CARInfo")) if (!allModules.Contains(minfo.ModuleID)) allModules.Add(minfo.ModuleID); } } } foreach (int moduleID in allModules) { modules.Append(moduleID).Append(","); } if (modules.Length > 0) modules.Remove(modules.Length - 1, 1); List<Hashtable> allAlertLog = new List<Hashtable>(); AlertLogController ctrl = new AlertLogController(); List<AlertLogInfoForMobile> lstAlertLog = ctrl.FetchAlertLogForMobileByPortal(startDate, endDate, modules.ToString()); foreach (AlertLogInfoForMobile info in lstAlertLog) { Hashtable ht = new Hashtable(); ht.Add("DeviceID", info.DeviceID); ht.Add("fleetSetting_CARInfoID", info.fleetSetting_CARInfoID); ht.Add("countMildly", info.countMildly); ht.Add("countModerately", info.countModerately); ht.Add("countSeverely", info.countSeverely); ht.Add("TotalSevere", info.TotalSevere); ht.Add("CarNo", info.CarNo); ht.Add("Plate", info.Plate); ht.Add("CompanyID", info.CompanyID); ht.Add("fleetID", info.fleetID); ht.Add("FleetName", info.FleetName); ht.Add("DriverName", info.DriverName); ht.Add("DriverNo", info.DriverNo); ht.Add("Phone", info.Phone); allAlertLog.Add(ht); } var jsonToReturn = JsonConvert.SerializeObject(allAlertLog); return Request.CreateResponse(HttpStatusCode.OK, jsonToReturn); }
public HttpResponseMessage GetAlertLogForMobileByDevice(string startDate, string endDate, string deviceID) { List<Hashtable> allAlertLog = new List<Hashtable>(); AlertLogController ctrl = new AlertLogController(); List<AlertLogInfoForMobile> lstAlertLog = ctrl.FetchAlertLogForMobileByDevice(startDate, endDate, deviceID); foreach (AlertLogInfoForMobile info in lstAlertLog) { Hashtable ht = new Hashtable(); ht.Add("AlarmCreateDate", Convert.ToDateTime(info.AlarmCreateDate).ToString("yyyy/MM/dd HH:mm:ss")); ht.Add("RuleName", info.RuleName); ht.Add("AlertDate", info.AlertDate); ht.Add("Severity", info.Severity); ht.Add("AlarmTypeName", info.AlarmTypeName); ht.Add("AlarmMsg", info.AlarmMsg); allAlertLog.Add(ht); } var jsonToReturn = JsonConvert.SerializeObject(allAlertLog); return Request.CreateResponse(HttpStatusCode.OK, jsonToReturn); }