private void alarmClick(object sender, RoutedEventArgs e)//报警日志 { try { listType = _listType.alarm; AIS.IsChecked = false; radar.IsChecked = false; fuse.IsChecked = false; login.IsChecked = false; operation.IsChecked = false; alarm.IsChecked = false; device.IsChecked = false; alarm.IsChecked = true; long startTime = dataTime()[0]; //开始时间 long endTime = dataTime()[1]; //结束时间 AISList.Visibility = Visibility.Collapsed; radarList.Visibility = Visibility.Collapsed; fuseList.Visibility = Visibility.Collapsed; userLoginList.Visibility = Visibility.Collapsed; operateList.Visibility = Visibility.Collapsed; alarmList.Visibility = Visibility.Visible; deviceList.Visibility = Visibility.Collapsed; alarmp = new dataAnadll.AlarmLogProvider(getTimeStamp(startTime), getTimeStamp(endTime)); List <dataAnadll.AlarmLog> list; alarmp.GetPageNum(out PageIndex.Total); PageIndex.Current = 1; //alarmp.GetFirtstPage(out list); alarmDataList.Clear(); for (int j = 0; j < PageIndex.Total; j++) { alarmp.GetPage(j + 1, out list); for (int i = 0; i < list.Count; i++) { alarmData alarmTarget = new alarmData(); string a = ""; if (list[i].alarm_area_num == 201) { a = alarmType[0]; } else if (list[i].alarm_area_num == 202) { a = alarmType[1]; } else if (list[i].alarm_area_num == 203) { a = alarmType[2]; } else if (list[i].alarm_area_num >= 210 && list[i].alarm_area_num <= 215) { a = alarmType[3]; } else if (list[i].alarm_area_num >= 220 && list[i].alarm_area_num <= 225) { a = alarmType[4]; } else if (list[i].alarm_area_num == 255) { a = alarmType[5]; } alarmTarget.DisplayNumber = (i + (j) * 1000).ToString(); alarmTarget.alarmNumber = a; alarmTarget.time = list[i].time.ToString(); alarmTarget.radarNumber = list[i].radar_batch_id.ToString(); alarmTarget.radarNumber2 = list[i].radar_batch_id2.ToString();//告警日志添加雷达2 批号 alarmTarget.IMO = list[i].ais_batch_id.ToString(); switch (list[i].alarm_type) { case 1: alarmTarget.alarmString = "驶入"; break; case 2: alarmTarget.alarmString = "驶出"; break; default: alarmTarget.alarmString = "未知报警"; break; } switch (list[i].country) { case 412: case 413: alarmTarget.country = "中国"; break; case 574: case 576: alarmTarget.country = "越南"; break; case 533: alarmTarget.country = "马拉西亚"; break; default: alarmTarget.country = "其他"; break; } alarmTarget.Atrrib = state[list[i].iff_attrib]; alarmDataList.Add(alarmTarget); } } alarmList.DataContext = alarmDataList; } catch (Exception ee) { } }
private void exportClick(object sender, RoutedEventArgs e)//导出 { try { if (string.IsNullOrWhiteSpace(filePathText.Text)) { MessageBoxX.Show("导出提示", "未设置文件路径"); return; } long startTime = dataTime()[0]; //开始时间 long endTime = dataTime()[1]; //结束时间 int allPage = 0; int cnt = 0; string filePath = ""; if (listType == _listType.ais) { //List<dataAnadll.FUS_ICD_MySql.AISMsg_SS> list = MainWindow.data.AIS(startTime, endTime, MainWindow.mycon, 1, 10); dataAnadll.AISDataProvider dataprovider = new dataAnadll.AISDataProvider((uint)startTime, (uint)endTime); dataprovider.GetPageNum(out allPage); List <dataAnadll.FUS_ICD_MySql.AISMsg_SS> list; for (int i = 0; i < allPage; i++) { dataprovider.GetPage(i + 1, out list); //alldata.Add(); cnt += dataAnadll.SaveToExcel.Save_AISdata(filePathText.Text + "\\ais.xls", list, AIStitle, 14); } filePath = "AIS.xls"; } else if (listType == _listType.radar) { dataAnadll.RadarDataProvider radarp = new dataAnadll.RadarDataProvider((uint)startTime, (uint)endTime); radarp.GetPageNum(out allPage); List <dataAnadll.FUS_ICD_MySql.RdDetectMsg_SS> list; for (int i = 0; i < allPage; i++) { radarp.GetPage(i + 1, out list); cnt += dataAnadll.SaveToExcel.Save_Radardata(filePathText.Text + "\\radar.xls", list, radartitle, 6); } filePath = "radar.xls"; } else if (listType == _listType.fus) { dataAnadll.FUSDataProvider radarp = new dataAnadll.FUSDataProvider((uint)startTime, (uint)endTime); radarp.GetPageNum(out allPage); List <dataAnadll.FUS_ICD_MySql.FusTarget_SS> list; for (int i = 0; i < allPage; i++) { radarp.GetPage(i + 1, out list); //SaveToExcel.Save_Fusedata(filePathText.Text + "/radar.xls", list, radartitle, 6); cnt += dataAnadll.SaveToExcel.Save_Fusedata(filePathText.Text + "\\fuse.xls", list, fusetitle, 15); } //List<dataAnadll.FUS_ICD_MySql.FusTarget_SS> list = MainWindow.data.Fuse(startTime, endTime, MainWindow.mycon); filePath = "fuse.xls"; } else if (listType == _listType.ope1) { dataAnadll.OperationLogProvider radarp = new dataAnadll.OperationLogProvider(); radarp.SearchLog(1, DataQuery.getTimeStamp(startTime), DataQuery.getTimeStamp(endTime), out allPage); List <dataAnadll.OperationLog> list; List <string[]> loginList = new List <string[]>(); for (int i = 0; i < allPage; i++) { radarp.GetPage(i + 1, out list); for (int j = 0; j < list.Count; j++) { string[] str = new string[8]; // str[0] = "#############"; str[0] = list[j].UserName.ToString(); str[1] = list[j].OptionName.ToString(); str[2] = list[j].OptionTime.ToString(); str[3] = list[j].Result.ToString(); str[4] = list[j].Note.ToString(); str[5] = list[j].IP.ToString(); str[6] = logNumber[list[j].LogType].ToString(); loginList.Add(str); } } cnt += dataAnadll.SaveToExcel.Save_Optionlog(filePathText.Text + "\\login.xls", loginList, logintitle, 7); filePath = "login.xls"; } else if (listType == _listType.ope2) { dataAnadll.OperationLogProvider radarp = new dataAnadll.OperationLogProvider(); radarp.SearchLog(2, DataQuery.getTimeStamp(startTime), DataQuery.getTimeStamp(endTime), out allPage); List <dataAnadll.OperationLog> list; List <string[]> opeList = new List <string[]>(); for (int i = 0; i < allPage; i++) { radarp.GetPage(i + 1, out list); for (int j = 0; j < list.Count; j++) { string[] str = new string[7]; //str[0] = "#############"; str[0] = list[j].UserName.ToString(); str[1] = list[j].OptionName.ToString(); str[2] = list[j].OptionTime.ToString(); str[3] = list[j].Result.ToString(); str[4] = list[j].Note.ToString(); str[5] = list[j].IP.ToString(); str[6] = logNumber[list[j].LogType].ToString(); opeList.Add(str); } } cnt += dataAnadll.SaveToExcel.Save_Optionlog(filePathText.Text + "\\operate.xls", opeList, opearatetitle, 7); filePath = "operate.xls"; } else if (listType == _listType.alarm) { dataAnadll.AlarmLogProvider radarp = new dataAnadll.AlarmLogProvider(DataQuery.getTimeStamp(startTime), DataQuery.getTimeStamp(endTime)); radarp.GetPageNum(out allPage); List <dataAnadll.AlarmLog> list; List <string[]> loginList = new List <string[]>(); for (int i = 0; i < allPage; i++) { radarp.GetPage(i + 1, out list); for (int j = 0; j < list.Count; j++) { string[] str = new string[8]; //str[0] = "###############"; alarmData alarmTarget = new alarmData(); string a = ""; if (list[j].alarm_area_num == 201) { a = alarmType[0]; } else if (list[j].alarm_area_num == 202) { a = alarmType[1]; } else if (list[j].alarm_area_num == 203) { a = alarmType[2]; } else if (list[j].alarm_area_num >= 210 && list[j].alarm_area_num <= 215) { a = alarmType[3]; } else if (list[j].alarm_area_num >= 220 && list[j].alarm_area_num <= 225) { a = alarmType[4]; } else if (list[j].alarm_area_num == 255) { a = alarmType[5]; } alarmTarget.alarmNumber = a; alarmTarget.time = list[j].time.ToString(); alarmTarget.radarNumber = list[j].radar_batch_id.ToString(); alarmTarget.radarNumber2 = list[i].radar_batch_id2.ToString();//告警日志添加雷达2 批号 alarmTarget.IMO = list[j].ais_batch_id.ToString(); switch (list[j].alarm_type) { case 1: alarmTarget.alarmString = "驶入"; break; case 2: alarmTarget.alarmString = "驶出"; break; default: alarmTarget.alarmString = "未知报警"; break; } switch (list[j].country) { case 412: case 413: alarmTarget.country = "中国"; break; case 574: case 576: alarmTarget.country = "越南"; break; case 533: alarmTarget.country = "马拉西亚"; break; default: alarmTarget.country = "其他"; break; } alarmTarget.Atrrib = state[list[j].iff_attrib]; str[0] = alarmTarget.time; str[1] = alarmTarget.radarNumber; // list[j].radar_batch_id.ToString(); str[2] = alarmTarget.radarNumber2; str[3] = alarmTarget.IMO; // list[j].ais_batch_id.ToString(); str[4] = alarmTarget.alarmNumber; // list[j].alarm_area_num.ToString(); str[5] = alarmTarget.alarmString; // list[j].alarm_type.ToString(); str[6] = alarmTarget.country; // list[j].country.ToString(); str[7] = alarmTarget.Atrrib; // list[j].iff_attrib.ToString(); loginList.Add(str); } } cnt += dataAnadll.SaveToExcel.Save_AlarmLog(filePathText.Text + "\\alarm.xls", loginList, alarmtitle, 8); filePath = "alarm.xls"; } else if (listType == _listType.dev) { dataAnadll.SystemLogProvider sysp = new dataAnadll.SystemLogProvider(DataQuery.getTimeStamp(startTime), DataQuery.getTimeStamp(endTime)); sysp.GetPageNum(out allPage); List <dataAnadll.SystemLog> list; List <string[]> sysList = new List <string[]>(); for (int i = 0; i < allPage; i++) { sysp.GetPage(i + 1, out list); for (int j = 0; j < list.Count; j++) { string[] str = new string[6]; //str[0] = "###########"; str[0] = list[j].machine_IP.ToString(); str[1] = list[j].machine_Name.ToString(); str[2] = type[list[j].machine_Network]; str[3] = type[list[j].machine_Workstate]; str[4] = list[j].machine_time.ToString(); str[5] = list[j].reason.ToString(); sysList.Add(str); } } cnt += dataAnadll.SaveToExcel.Save_SystemLog(filePathText.Text + "\\device.xls", sysList, devicetitle, 6); filePath = "device.xls"; } if (cnt > 0) { MessageBoxX.Show("导出提示", string.Format("导出至{0}!", filePath)); } else { MessageBoxX.Show("导出提示", string.Format("数据为空,导出失败")); } } catch (Exception ee) { } }
void changeContent(_listType type, int currentPage) //将表格的内容进行切换 { try { PageIndex.Current = currentPage; switch (type) { case _listType.alarm: List <dataAnadll.AlarmLog> list; alarmp.GetPage(currentPage, out list); alarmDataList.Clear(); for (int i = 0; i < list.Count; i++) { alarmData alarmTarget = new alarmData(); string a = ""; if (list[i].alarm_area_num == 201) { a = alarmType[0]; } else if (list[i].alarm_area_num == 202) { a = alarmType[1]; } else if (list[i].alarm_area_num == 203) { a = alarmType[2]; } else if (list[i].alarm_area_num >= 210 && list[i].alarm_area_num <= 215) { a = alarmType[3]; } else if (list[i].alarm_area_num >= 220 && list[i].alarm_area_num <= 225) { a = alarmType[4]; } else if (list[i].alarm_area_num == 255) { a = alarmType[5]; } alarmTarget.DisplayNumber = (i + (PageIndex.Current - 1) * 1000).ToString(); alarmTarget.alarmNumber = a; alarmTarget.time = list[i].time.ToString(); alarmTarget.radarNumber = list[i].radar_batch_id.ToString(); alarmTarget.radarNumber2 = list[i].radar_batch_id2.ToString(); //告警日志添加雷达2 批号 alarmTarget.IMO = list[i].ais_batch_id.ToString(); switch (list[i].alarm_type) { case 1: alarmTarget.alarmString = "驶入"; break; case 2: alarmTarget.alarmString = "驶出"; break; default: alarmTarget.alarmString = "未知报警"; break; } switch (list[i].country) { case 412: case 413: alarmTarget.country = "中国"; break; case 574: case 576: alarmTarget.country = "越南"; break; case 533: alarmTarget.country = "马拉西亚"; break; default: alarmTarget.country = "其他"; break; } alarmTarget.Atrrib = state[list[i].iff_attrib]; alarmDataList.Add(alarmTarget); } alarmList.DataContext = alarmDataList; break; case _listType.ais: List <dataAnadll.FUS_ICD_MySql.AISMsg_SS> list_ais; aisp.GetPage(currentPage, out list_ais); AISDataList.Clear(); for (int i = 0; i < list_ais.Count; i++) { AISData AISTarget = new AISData(); AISTarget.boatName = list_ais[i].cName; AISTarget.IMO = list_ais[i].ulIMO; AISTarget.MMSI = list_ais[i].ulRecoCode; AISTarget.call = list_ais[i].cCall_ID; AISTarget.country = list_ais[i].country; AISTarget.longitude = list_ais[i].dLong; AISTarget.latitude = list_ais[i].dLat; AISTarget.angle = list_ais[i].fDirectCourse; AISTarget.speed = list_ais[i].fDirectSpeed; AISTarget.time = (GetTime((list_ais[i].ulTime).ToString())).ToString(); AISTarget.trackState = list_ais[i].ucSailStatus; AISTarget.high = list_ais[i].fMaxDeep; AISTarget.people = list_ais[i].ulCount; AISTarget.destance = list_ais[i].cDestination; AISDataList.Add(AISTarget); } AISList.DataContext = AISDataList; break; case _listType.dev: List <dataAnadll.SystemLog> list_dev; devp.GetPage(currentPage, out list_dev); deviceDataList.Clear(); for (int i = 0; i < list_dev.Count; i++) { deviceData deviceTarget = new deviceData(); deviceTarget.number = i.ToString(); deviceTarget.ip = list_dev[i].machine_IP.ToString(); deviceTarget.device = list_dev[i].machine_Name.ToString(); deviceTarget.networkState = this.type[list_dev[i].machine_Network]; deviceTarget.workState = this.type[list_dev[i].machine_Workstate]; deviceTarget.time = list_dev[i].machine_time.ToString(); deviceTarget.other = list_dev[i].reason.ToString(); deviceDataList.Add(deviceTarget); } deviceList.DataContext = deviceDataList; break; case _listType.fus: List <dataAnadll.FUS_ICD_MySql.FusTarget_SS> list_fus; fusp.GetPage(currentPage, out list_fus); fuseDataList.Clear(); for (int i = 0; i < list_fus.Count; i++) { fuseData fuseTarget = new fuseData(); fuseTarget.number = list_fus[i].lFusBatchID; fuseTarget.time = (GetTime((list_fus[i].lTime).ToString())).ToString(); string a = ""; if (list_fus[i].FusDataType == "2") { a = mix[0]; } else if (list_fus[i].FusDataType == "3") { a = mix[1]; } else if (list_fus[i].FusDataType == "100") { a = mix[2]; } fuseTarget.type = a; fuseTarget.dataNumber = list_fus[i].SrcNum; fuseTarget.longitude = list_fus[i].dLongti; fuseTarget.latitude = list_fus[i].dLati; fuseTarget.angle = list_fus[i].dNorthCourse; fuseTarget.name = list_fus[i].cName; fuseTarget.call = list_fus[i].cCall_ID; fuseTarget.country = list_fus[i].country; fuseTarget.Atrrbi = state[Convert.ToInt32(list_fus[i].ucIFFAttrib)]; fuseTarget.high = list_fus[i].fMaxDeep; fuseTarget.people = list_fus[i].ulCount; fuseTarget.IMO = list_fus[i].ulAISBatchID; fuseTarget.radar_batch_id = list_fus[i].ulRdbatchID; fuseTarget.radar_batch_id2 = list_fus[i].ulOpticalID; fuseDataList.Add(fuseTarget); } fuseList.DataContext = fuseDataList; break; case _listType.radar: List <dataAnadll.FUS_ICD_MySql.RdDetectMsg_SS> list_rd; radarp.GetPage(currentPage, out list_rd); radarDataList.Clear(); for (int i = 0; i < list_rd.Count; i++) { radarData radarTarget = new radarData(); radarTarget.radarID = list_rd[i].PardPara.ucRadarID.ToString(); radarTarget.number = list_rd[i].lTargetNo; radarTarget.distance = list_rd[i].ulTargetDis; radarTarget.longitude = list_rd[i].dLongti; radarTarget.latitude = list_rd[i].dLati; radarTarget.angle = list_rd[i].ulTargetCourse; radarTarget.north = list_rd[i].dNorthCourse; radarTarget.speed = list_rd[i].ulTargetSpeed; // if (list_rd[i].radar_count == 70.ToString()) { // radarTarget.time = list_rd[i].lFoundTime; } // else { radarTarget.time = (GetTime((list_rd[i].lFoundTime).ToString())).ToString(); } radarDataList.Add(radarTarget); } radarList.DataContext = radarDataList; break; case _listType.ope1: List <dataAnadll.OperationLog> list_ope1; opep.GetPage(currentPage, out list_ope1); loginDataList.Clear(); for (int i = 0; i < list_ope1.Count; i++) { loginData loginTarget = new loginData(); loginTarget.logNumber = (i + (PageIndex.Current - 1) * 1000).ToString(); loginTarget.userName = list_ope1[i].UserName.ToString(); loginTarget.operate = list_ope1[i].OptionName; loginTarget.time = list_ope1[i].OptionTime.ToString(); loginTarget.result = list_ope1[i].Result.ToString(); loginTarget.other = list_ope1[i].Note; loginTarget.ip = list_ope1[i].IP.ToString(); loginTarget.type = logType[list_ope1[i].LogType].ToString(); loginDataList.Add(loginTarget); } userLoginList.DataContext = loginDataList; break; case _listType.ope2: List <dataAnadll.OperationLog> list_ope2; opep.GetPage(currentPage, out list_ope2); operateDataList.Clear(); for (int i = 0; i < list_ope2.Count; i++) { operateData operateTarget = new operateData(); operateTarget.logNumber = (i + (PageIndex.Current - 1) * 1000).ToString(); operateTarget.userName = list_ope2[i].UserName.ToString(); operateTarget.operate = list_ope2[i].OptionName.ToString(); operateTarget.time = list_ope2[i].OptionTime.ToString(); operateTarget.result = list_ope2[i].Result; operateTarget.other = list_ope2[i].Note.ToString(); operateTarget.ip = list_ope2[i].IP.ToString(); operateTarget.type = logType[list_ope2[i].LogType].ToString(); operateDataList.Add(operateTarget); } operateList.DataContext = operateDataList; break; } } catch (Exception ee) { } }