using System; using System.Collections.Generic; using System.Data; using System.Diagnostics; using System.Linq; using System.Threading; using System.Threading.Tasks; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using BLL; using Model; using Newtonsoft.Json; using static System.Windows.Forms.VisualStyles.VisualStyleElement.ListView; namespace FineUIPro.Web.common { public partial class mainMenu_HSSE2 : PageBase { public Model.HSSEData_HSSE hSSEData_HSSE; public List hiddenDangerDetailList; public List< Base_Project> projectList; public string zgl1; public string zgl2; public string dataYHQ; public string dataYHZ; public string xArrYH; public string projectData; protected async void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { MainSevice mainSevice = new MainSevice(this.CurrUser.UserId); try { hSSEData_HSSE = await mainSevice.GetHsseDataAsync().ConfigureAwait(false); } catch (Exception ex) { throw; } hiddenDangerDetailList = mainSevice.GetDataHiddenDangerDetailItems(); int unitType = CommonService.GetUnitTypeByUserId(this.CurrUser.UserId); if (unitType == 0) { projectList = Funs.DB.Base_Project.Where(x => x.MapCoordinates != null && (x.IsDelete == null || x.IsDelete == false)).ToList(); } else if (unitType == 1) { projectList = Funs.DB.Base_Project.Where(x => x.UnitId == this.CurrUser.UnitId && x.MapCoordinates != null && (x.IsDelete == null || x.IsDelete == false)).ToList(); } else if (unitType == 2) { hSSEData_HSSE = new HSSEData_HSSE(); hiddenDangerDetailList = new List(); projectList = new List(); } zgl1 = "0"; zgl2 = "0"; if (hSSEData_HSSE.GeneralClosedNum.HasValue && hSSEData_HSSE.GeneralNotClosedNum.HasValue) { zgl1 = String.Format("{0:N2}", 100.0 * hSSEData_HSSE.GeneralClosedNum.Value / (hSSEData_HSSE.GeneralClosedNum.Value + hSSEData_HSSE.GeneralNotClosedNum.Value)); } else { zgl1 = "0"; } if (hSSEData_HSSE.MajorClosedNum.HasValue && hSSEData_HSSE.MajorNotClosedNum.HasValue) { zgl2 = String.Format("{0:N2}", 100.0 * hSSEData_HSSE.MajorClosedNum.Value / (hSSEData_HSSE.MajorClosedNum.Value + hSSEData_HSSE.MajorNotClosedNum.Value)); } else { zgl2 = "0"; } if (hSSEData_HSSE.GeneralClosedNum.HasValue && hSSEData_HSSE.GeneralNotClosedNum.HasValue) { zgl1 = String.Format("{0:N2}", 100.0 * hSSEData_HSSE.GeneralClosedNum.Value / (hSSEData_HSSE.GeneralClosedNum.Value + hSSEData_HSSE.GeneralNotClosedNum.Value)); } else { zgl1 = "0"; } /*var reportDate = Funs.DB.HSSEData_HiddenDangerDetail.Max(x => x.ReportDate); if (reportDate.HasValue) { var details = Funs.DB.HSSEData_HiddenDangerDetail.Where(x => x.ReportDate == reportDate.Value).ToList(); if (details != null && details.Count > 0) { foreach (var d in details) { dataYHQ += d.TotalNum + ","; dataYHZ += d.NeedRectifyNum + ","; xArrYH += "'" + d.TypeName + "',"; } dataYHQ = dataYHQ.TrimEnd(','); dataYHZ = dataYHZ.TrimEnd(','); xArrYH = xArrYH.TrimEnd('\'').TrimEnd(','); } }*/ if (hiddenDangerDetailList.Count>0) { foreach (var d in hiddenDangerDetailList) { dataYHQ += d.TotalNum + ","; dataYHZ += d.NeedRectifyNum + ","; xArrYH += "'" + d.TypeName + "',"; } dataYHQ = dataYHQ.TrimEnd(','); dataYHZ = dataYHZ.TrimEnd(','); xArrYH = xArrYH.TrimEnd('\'').TrimEnd(','); } if (projectList != null && projectList.Count > 0) { foreach (var p in projectList) { string unit_yz = ProjectService.getProjectUnitNameByUnitType(p.ProjectId, Const.ProjectUnitType_4); string unit_JL = ProjectService.getProjectUnitNameByUnitType(p.ProjectId, Const.ProjectUnitType_3); string unit_FB = ProjectService.getProjectUnitNameByUnitType(p.ProjectId, Const.ProjectUnitType_2); projectData += "{\"name\":\"" + p.ShortName + "\",\"value\":[" + p.MapCoordinates + "],\"address\":\"" + p.ProjectAddress + "\",\"id\":\"" + p.ProjectId + "\",\"ownUnit\":\"" + unit_yz + "\",\"jLUnit\":\"" + unit_JL + "\",\"SGUnit\":\"" + unit_FB + "\",\"ProjectMoney\":\"" + p.ProjectMoney.ToString() + "\"},"; } projectData = projectData.TrimEnd(','); } } } protected string VideoURL { get { string video_Url = Funs.VideoHost; if (!string.IsNullOrEmpty(Funs.VideoPassWord)) { return video_Url + "#/screen?username="+ Funs.VideoAccount+"&password=" + Funs.EncryptionPassword(Funs.VideoPassWord); } else { return ""; } } } protected string VideoHost { get { string video_Url = string.Empty; var sysSet16 = (from x in Funs.DB.Sys_Set where x.SetName == "视频监控地址" select x).ToList().FirstOrDefault(); if (sysSet16 != null) { video_Url = sysSet16.SetValue; } return video_Url; } } protected string VideoPassWord { get { var sysSet17 = (from x in Funs.DB.Sys_Set where x.SetName == "视频监控密码" select x).ToList().FirstOrDefault(); return Funs.EncryptionPassword(sysSet17.SetValue); } } public void getVideo() { var sysSet16 = (from x in Funs.DB.Sys_Set where x.SetName == "视频监控地址" select x).ToList().FirstOrDefault(); var sysSet17 = (from x in Funs.DB.Sys_Set where x.SetName == "视频监控密码" select x).ToList().FirstOrDefault(); if (sysSet16 == null) { return; } if (sysSet17 == null) { return; } string url = sysSet16.SetValue; string username = "admin"; string password = sysSet17.SetValue; String res = BLL.CommonService.CreateGetHttpResponse(url + "api/v1/login?username=" + username + "&password=" + Funs.EncryptionPassword(password)); Dictionary dicres = JsonConvert.DeserializeObject>(res); string URLToken = dicres["URLToken"]; DataTable dt = new DataTable(); dt.Columns.Add("id"); dt.Columns.Add("name"); dt.Columns.Add("serial"); dt.Columns.Add("deviceName"); List urls = new List(); res = APIGetHttpService.Http(url + "api/v1/device/channeltree?token=" + URLToken); List> jsonNvr = JsonConvert.DeserializeObject>>(res); foreach (Dictionary nvr in jsonNvr) { string jsonCameras = APIGetHttpService.Http(url + "api/v1/device/channeltree?token=" + URLToken + "&serial=" + nvr["serial"]); List> jsonDiv = JsonConvert.DeserializeObject>>(jsonCameras); foreach (Dictionary div in jsonDiv) { var rowDiv = dt.NewRow(); rowDiv["id"] = div["id"]; rowDiv["deviceName"] = nvr["customName"]; if (!string.IsNullOrEmpty(div["customName"])) { rowDiv["name"] = div["customName"]; } else { rowDiv["name"] = div["name"]; } rowDiv["serial"] = div["code"]; dt.Rows.Add(rowDiv); } } } private async Task LoadDataAsync() { try { MainSevice mainSevice = new MainSevice(this.CurrUser.UserId); hSSEData_HSSE = await mainSevice.GetHsseDataAsync().ConfigureAwait(false); hiddenDangerDetailList = mainSevice.GetDataHiddenDangerDetailItems(); } catch (Exception ex) { // 处理异常 // ... } } public string showData(int? value, string format) { if (value.HasValue) { return value.Value.ToString(); } else { return format; } } public string showDecimalData(decimal? value, string format) { if (value.HasValue) { return value.Value.ToString(); } else { return format; } } } }