public static string QueryAllLayerByPoint(string sLon, string sLat) { try { double x = double.Parse(sLon); double y = double.Parse(sLat); string str = WebGis.QueryAllLayerByPoint(x, y); string[] separator = new string[] { ":::" }; string[] strArray2 = str.Split(separator, StringSplitOptions.RemoveEmptyEntries); if (strArray2.Length <= 1) { return("未知"); } return(strArray2[1]); } catch (WebException exception) { Record.execFileRecord("取得详细位置信息(WebService)", sLon + "," + sLat + " " + exception.Message); return("未知"); } catch (Exception exception2) { Record.execFileRecord("取得详细位置信息(WebService)", sLon + "," + sLat + " " + exception2.Message); return("未知"); } }
public static bool WriteIniFile() { try { WriteIniFileString("User", "UserId", Variable.sUserId); WriteIniFileString("User", "AdcNo", Variable.sAdcNo); WriteIniFileString("Server", "ServerIp", Variable.sServerIp); WriteIniFileString("Server", "Port", Variable.sPort); WriteIniFileString("Server", "UseHttpProxy", Variable.sUseHttpProxy); WriteIniFileString("Server", "HttpProxyIp", Variable.sHttpProxyIp); WriteIniFileString("Server", "HttpProxyPort", Variable.sHttpProxyPort); WriteIniFileString("Server", "GpsIp", Variable.sGpsIp); WriteIniFileString("Server", "GpsPort", Variable.sGpsPort); WriteIniFileString("Map", "MapIp", Variable.sMapIp); WriteIniFileString("Map", "MapPort", Variable.sMapPort); WriteIniFileString("Map", "MapSign", Variable.sMapSign); WriteIniFileString("Map", "SelectedMap", Variable.sSelectedMap); WriteIniFileString("Terminal", "GetPhotoMax", Variable.sGetPhotoMax); WriteIniFileString("Terminal", "SavePicDays", Variable.sSavePicDays); WriteIniFileString("Terminal", "SaveLogDays", Variable.sSaveLogDays); WriteIniFileString("Terminal", "SkinDataIndex", Variable.sSkinDataIndex); WriteIniFileString("Terminal", "RecsPerPage", Variable.sRecsPerPage); WriteIniFileString("Terminal", "GetUpDateTime", Variable.sGetUpDateTime); WriteIniFileString("Terminal", "QueryPointTimeDiff", Variable.sQueryPointTimeDiff); WriteIniFileString("Terminal", "QueryPointGetInt", Variable.sQueryPointGetInt); WriteIniFileString("MenuSelect", "MaxSendCount", Variable.sMaxSendCount); WriteIniFileString("MenuSelect", "ImportCarMax", Variable.sImportCarMax); WriteIniFileString("TreeNode", "GetNodeTipShowType", Variable.sGetNodeTipShowType); WriteIniFileString("TreeNode", "GetNodeDetailShowType", Variable.sGetNodeDetailShowType); WriteIniFileString("Other", "AlarmSoundStatus", Variable.sAlarmSoundStatus); WriteIniFileString("Other", "CarListTextColunmsVisibleType", Variable.sCarListTextColunmsVisibleType); WriteIniFileString("Other", "CompressDownCarInfo", Variable.sCompressDownCarInfo); WriteIniFileString("Other", "AlarmPopupWindow", Variable.sAlarmPopupWindow); WriteIniFileString("Other", "CustomAlarmSound", Variable.sCustomAlarmSound); WriteIniFileString("Other", "LogFilterAlarmType", Variable.sLogFilterAlarmType); WriteIniFileString("Other", "MapCarLegendShowAreaName", Variable.sMapCarLegendShowAreaName); WriteIniFileString("Other", "CarServerTimeRemind", Variable.sCarServerTimeRemind); WriteIniFileString("Other", "LogListAreaVisible", Variable.sLogListAreaVisible); WriteIniFileString("Other", "ShowUnCheckedCarInfo", Variable.sShowUnCheckedCarInfo); WriteIniFileString("Other", "AutoCancelAlarm", Variable.sAutoCancelAlarm); WriteIniFileString("Other", "ShowManagerSystem", Variable.sShowManagerSystem); WriteIniFileString("Other", "ShowCarPlayTrackTime", Variable.sGetNodeTrackShowType); WriteIniFileString("Other", "sLonLatDis", Variable.sLonLatDis); WriteIniFileString("Other", "MaxPicMonitorTime", string.IsNullOrEmpty(Variable.sNumMaxPicMonitorTime) ? "65535" : Variable.sNumMaxPicMonitorTime); WriteIniFileString("Other", "UserLevel", Variable.sLevelInfo); WriteIniFileString("Other", "JGShowCarNum", Variable.sJGShowCar); return(true); } catch (Exception exception) { Record.execFileRecord("读取配置文件", exception.ToString()); return(false); } }
public static string[] GetDistrictInfo(string[] sIdlonLats) { try { return(WebGis.GetDistrictInfo(sIdlonLats)); } catch (WebException exception) { Record.execFileRecord("取得县市区级位置(WebService)", sIdlonLats + " " + exception.Message); return(null); } catch (Exception exception2) { Record.execFileRecord("取得县市区级位置(WebService)", sIdlonLats + " " + exception2.Message); return(null); } }
public static void OutputExcelChk_Microsoft(DataGridView dgvCarPlay, string Title, string savePath) { Microsoft.Office.Interop.Excel.Application o = null; try { o = new ApplicationClass(); } catch (Exception exception) { MessageBox.Show("Excel无法启动,请确保已安装Excel 2003 及以上版本!"); Record.execFileRecord("导出报表", exception.ToString()); return; } try { int num = 4; int num2 = 1; int num3 = 0; int num4 = 2; _Workbook workbook = o.Workbooks.Add(true); _Worksheet activeSheet = (_Worksheet)workbook.ActiveSheet; activeSheet.Name = Title; num3 = num2; foreach (DataGridViewColumn column in dgvCarPlay.Columns) { if (column.Visible && (column.CellType != typeof(DataGridViewCheckBoxCell))) { num3++; activeSheet.Cells[num, num3] = column.HeaderText; activeSheet.get_Range(activeSheet.Cells[num, num3], activeSheet.Cells[num, num3]).HorizontalAlignment = XlVAlign.xlVAlignCenter; if (column.CellType == typeof(DataGridViewTextBoxCell)) { activeSheet.get_Range(activeSheet.Cells[num, num3], activeSheet.Cells[num + dgvCarPlay.Rows.Count, num3]).HorizontalAlignment = XlVAlign.xlVAlignCenter; } } } foreach (DataGridViewRow row in (IEnumerable)dgvCarPlay.Rows) { if ((row.Cells["colSelect"].Value != null) && "true".Equals(row.Cells["colSelect"].Value.ToString().ToLower())) { num++; num3 = num2; foreach (DataGridViewColumn column2 in dgvCarPlay.Columns) { if (column2.Visible && (column2.CellType != typeof(DataGridViewCheckBoxCell))) { num3++; activeSheet.Cells[num, num3] = "'" + row.Cells[column2.Index].Value; } } continue; } } int num5 = num + 1; num3 = num2; foreach (DataGridViewColumn column3 in dgvCarPlay.Columns) { if (column3.Visible) { num3++; } } num5 = num + 2; activeSheet.Cells[num5, 2] = "合计:"; activeSheet.get_Range(activeSheet.Cells[num5, 2], activeSheet.Cells[num5, 2]).HorizontalAlignment = XlHAlign.xlHAlignCenter; activeSheet.Cells[num5, 3] = ((num - 4)).ToString() + "条记录"; activeSheet.get_Range(activeSheet.Cells[num5, 3], activeSheet.Cells[num5, 3]).HorizontalAlignment = XlHAlign.xlHAlignLeft; activeSheet.Cells[2, num4] = Title; num4 = 1; activeSheet.get_Range(activeSheet.Cells[2, num4], activeSheet.Cells[2, num4]).Font.Bold = true; activeSheet.get_Range(activeSheet.Cells[2, num4], activeSheet.Cells[2, num4]).Font.Size = 0x16; activeSheet.get_Range(activeSheet.Cells[2, num4], activeSheet.Cells[2, num4]).Font.ColorIndex = 14; activeSheet.get_Range(activeSheet.Cells[4, num4], activeSheet.Cells[num5, num3]).Select(); activeSheet.get_Range(activeSheet.Cells[4, num4], activeSheet.Cells[num5, num3]).Columns.AutoFit(); activeSheet.get_Range(activeSheet.Cells[2, num4], activeSheet.Cells[2, num3]).Select(); activeSheet.get_Range(activeSheet.Cells[2, num4], activeSheet.Cells[2, num3]).HorizontalAlignment = XlHAlign.xlHAlignCenterAcrossSelection; if (string.IsNullOrEmpty(savePath)) { savePath = @"C:\Documents and Settings\Administrator\My Documents\Report.xls"; } workbook.SaveCopyAs(savePath); workbook.Close(false, null, null); o.Quit(); Marshal.ReleaseComObject(workbook); Marshal.ReleaseComObject(o); Marshal.ReleaseComObject(activeSheet); workbook = null; o = null; activeSheet = null; GC.Collect(); MessageBox.Show("数据已经成功导出到:" + savePath, "导出完成", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } catch (Exception exception2) { MessageBox.Show(exception2.Message); } }
public static void OutputExcel(DataGridView dgv, string Title, string savePath, string sSTName, bool IsConver) { try { HSSFWorkbook workbook = new HSSFWorkbook(); { int num = 5; int num2 = 0x106; DocumentSummaryInformation information = PropertySetFactory.CreateDocumentSummaryInformation(); information.Company = ""; workbook.DocumentSummaryInformation = information; SummaryInformation information2 = PropertySetFactory.CreateSummaryInformation(); information2.Subject = ""; workbook.SummaryInformation = information2; if (sSTName.Length > 0x1f) { sSTName = "报表"; } ISheet sheet = workbook.CreateSheet(sSTName); int rownum = 3; int num4 = 0; int num5 = 0; int num6 = 1; ICellStyle style = workbook.CreateCellStyle(); style.Alignment = NPOI.SS.UserModel.HorizontalAlignment.CENTER; style.VerticalAlignment = VerticalAlignment.CENTER; style.ShrinkToFit = true; NPOI.SS.UserModel.IFont font = workbook.CreateFont(); font.FontName = "宋体"; font.FontHeightInPoints = 11; style.SetFont(font); IRow row = sheet.CreateRow(rownum); num5 = num4; foreach (DataGridViewColumn column in dgv.Columns) { if (column.Visible && (column.CellType != typeof(DataGridViewCheckBoxCell))) { num5++; ICell cell = row.CreateCell(num5); cell.SetCellValue(column.HeaderText); cell.CellStyle = style; style.WrapText = true; sheet.AutoSizeColumn(num5); } } if (IsConver) { for (int i = dgv.Rows.Count - 1; i >= 0; i--) { DataGridViewRow row2 = dgv.Rows[i]; if (!row2.IsNewRow) { rownum++; num5 = num4; IRow row3 = sheet.CreateRow(rownum); foreach (DataGridViewColumn column2 in dgv.Columns) { if (column2.Visible && (column2.CellType != typeof(DataGridViewCheckBoxCell))) { num5++; if ((row2.Cells[column2.Index].Value != null) && !row2.IsNewRow) { row3.CreateCell(num5).SetCellValue(row2.Cells[column2.Index].Value.ToString()); int num8 = sheet.GetColumnWidth(row3.GetCell(num5).ColumnIndex); int num9 = (Encoding.GetEncoding("gb2312").GetBytes(row2.Cells[column2.Index].Value.ToString()).Length + num) * num2; num8 = (num9 < num8) ? num8 : num9; sheet.SetColumnWidth(num5, num8); if (column2.CellType == typeof(DataGridViewTextBoxCell)) { sheet.GetRow(rownum).GetCell(num5).CellStyle = style; } } } } } } } else { foreach (DataGridViewRow row4 in (IEnumerable)dgv.Rows) { if (!row4.IsNewRow) { rownum++; num5 = num4; IRow row5 = sheet.CreateRow(rownum); foreach (DataGridViewColumn column3 in dgv.Columns) { if (column3.Visible && (column3.CellType != typeof(DataGridViewCheckBoxCell))) { num5++; if ((row4.Cells[column3.Index].Value != null) && !row4.IsNewRow) { row5.CreateCell(num5).SetCellValue(row4.Cells[column3.Index].Value.ToString()); int num10 = sheet.GetColumnWidth(row5.GetCell(num5).ColumnIndex); int num11 = (Encoding.GetEncoding("gb2312").GetBytes(row4.Cells[column3.Index].Value.ToString()).Length + num) * num2; num10 = (num11 < num10) ? num10 : num11; sheet.SetColumnWidth(num5, num10); if (column3.CellType == typeof(DataGridViewTextBoxCell)) { sheet.GetRow(rownum).GetCell(num5).CellStyle = style; } } } } continue; } } } int num12 = rownum + 1; num5 = num4; foreach (DataGridViewColumn column4 in dgv.Columns) { if (column4.Visible) { num5++; } } num12 = rownum + 2; IRow row6 = sheet.CreateRow(num12); ICell cell2 = row6.CreateCell(1); cell2.SetCellValue("合计:"); ICellStyle style2 = workbook.CreateCellStyle(); style2.Alignment = NPOI.SS.UserModel.HorizontalAlignment.CENTER; style2.VerticalAlignment = VerticalAlignment.CENTER; cell2.CellStyle = style2; int columnWidth = sheet.GetColumnWidth(1); int num14 = (Encoding.GetEncoding("gb2312").GetBytes("合计:").Length + num) * num2; columnWidth = (num14 < columnWidth) ? columnWidth : num14; sheet.SetColumnWidth(1, columnWidth); cell2 = row6.CreateCell(2); cell2.SetCellValue(dgv.Rows.Count.ToString() + "条记录"); style2 = workbook.CreateCellStyle(); style2.Alignment = NPOI.SS.UserModel.HorizontalAlignment.LEFT; style2.VerticalAlignment = VerticalAlignment.CENTER; cell2.CellStyle = style2; int width = sheet.GetColumnWidth(2); int num16 = (Encoding.GetEncoding("gb2312").GetBytes(dgv.Rows.Count.ToString() + "条记录").Length + num) * num2; width = (num16 < columnWidth) ? width : num16; sheet.SetColumnWidth(2, width); num6 = 1; ICell cell3 = sheet.CreateRow(1).CreateCell(num6); cell3.SetCellValue(Title); ICellStyle style3 = workbook.CreateCellStyle(); style3.Alignment = NPOI.SS.UserModel.HorizontalAlignment.CENTER; style3.VerticalAlignment = VerticalAlignment.CENTER; NPOI.SS.UserModel.IFont font2 = workbook.CreateFont(); font2.FontName = "宋体"; font2.FontHeightInPoints = 11; style3.SetFont(font2); cell3.CellStyle = style3; sheet.AddMergedRegion(new CellRangeAddress(1, 1, num6, num5)); sheet.GetRow(1).HeightInPoints = 35f; if (string.IsNullOrEmpty(savePath)) { savePath = @"C:\Documents and Settings\Administrator\My Documents\Report.xls"; } FileStream stream = new FileStream(savePath, FileMode.Create); workbook.Write(stream); stream.Close(); MessageBox.Show("数据已经成功导出到:" + savePath, "导出完成", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } } catch (Exception exception) { MessageBox.Show(exception.Message); Record.execFileRecord("导出报表", exception.ToString()); } }
public static bool ReadIniFile() { try { GetIniFileString("User", "UserId", ref Variable.sUserId); GetIniFileString("User", "AutoCheckAllCar", ref Variable.sAutoCheckAllCar); GetIniFileString("User", "Title", ref Variable.sLoginTitle); GetIniFileString("User", "CheckAdc", ref Variable.sCheckAdc); GetIniFileString("User", "AdcNo", ref Variable.sAdcNo); GetIniFileString("Server", "ServerIp", ref Variable.sServerIp); GetIniFileString("Server", "Port", ref Variable.sPort); GetIniFileString("Server", "UseHttpProxy", ref Variable.sUseHttpProxy); GetIniFileString("Server", "HttpProxyIp", ref Variable.sHttpProxyIp); GetIniFileString("Server", "HttpProxyPort", ref Variable.sHttpProxyPort); GetIniFileString("Server", "GpsIp", ref Variable.sGpsIp); GetIniFileString("Server", "GpsPort", ref Variable.sGpsPort); GetIniFileString("Map", "MapIp", ref Variable.sMapIp); GetIniFileString("Map", "MapPort", ref Variable.sMapPort); GetIniFileString("Map", "MapSign", ref Variable.sMapSign); GetIniFileString("Map", "SelectedMap", ref Variable.sSelectedMap); GetIniFileString("Terminal", "GetPhotoMax", ref Variable.sGetPhotoMax); GetIniFileString("Terminal", "SavePicDays", ref Variable.sSavePicDays); GetIniFileString("Terminal", "SkinDataIndex", ref Variable.sSkinDataIndex); GetIniFileString("Terminal", "RecsPerPage", ref Variable.sRecsPerPage); GetIniFileString("Terminal", "GetUpDateTime", ref Variable.sGetUpDateTime); GetIniFileString("Terminal", "QueryPointGetInt", ref Variable.sQueryPointGetInt); GetIniFileString("Terminal", "QueryPointTimeDiff", ref Variable.sQueryPointTimeDiff); GetIniFileString("MenuSelect", "MaxSendCount", ref Variable.sMaxSendCount); GetIniFileString("MenuSelect", "ImportCarMax", ref Variable.sImportCarMax); GetIniFileString("TreeNode", "GetNodeTipShowType", ref Variable.sGetNodeTipShowType); GetIniFileString("TreeNode", "GetNodeDetailShowType", ref Variable.sGetNodeDetailShowType); GetIniFileString("Other", "AlarmSoundStatus", ref Variable.sAlarmSoundStatus); GetIniFileString("Other", "CarListTextColunmsVisibleType", ref Variable.sCarListTextColunmsVisibleType); GetIniFileString("Other", "CompressDownCarInfo", ref Variable.sCompressDownCarInfo); GetIniFileString("Other", "ShippingEnable", ref Variable.sShippingEnable); GetIniFileString("Other", "ShowTogether", ref Variable.sShowTogether); GetIniFileString("Other", "AllowMultiShoot", ref Variable.sAllowMultiShoot); GetIniFileString("Other", "AllowRefresh", ref Variable.sAllowRefresh); GetIniFileString("Other", "AllowLCSType", ref Variable.sAllowLCSType); GetIniFileString("Other", "AlarmPopupWindow", ref Variable.sAlarmPopupWindow); GetIniFileString("Other", "CustomAlarmSound", ref Variable.sCustomAlarmSound); GetIniFileString("Other", "AdminSystemState", ref Variable.sAdminSystemState); GetIniFileString("Other", "LogFilterAlarmType", ref Variable.sLogFilterAlarmType); GetIniFileString("Other", "MapCarLegendShowAreaName", ref Variable.sMapCarLegendShowAreaName); GetIniFileString("Other", "CarServerTimeRemind", ref Variable.sCarServerTimeRemind); GetIniFileString("Other", "LogListAreaVisible", ref Variable.sLogListAreaVisible); GetIniFileString("Other", "ProjectID", ref Variable.sProjectID); GetIniFileString("Other", "WebMenuList", ref Variable.sWebMenuList); GetIniFileString("Other", "ShowManagerSystem", ref Variable.sShowManagerSystem); GetIniFileString("Other", "ShowCarPlayTrackTime", ref Variable.sGetNodeTrackShowType); GetIniFileString("Other", "ShowUnCheckedCarInfo", ref Variable.sShowUnCheckedCarInfo); GetIniFileString("Other", "ShowUnCheckedCarInfoDetail", ref Variable.sShowUnCheckedCarInfoDetail); GetIniFileString("Other", "AutoCancelAlarm", ref Variable.sAutoCancelAlarm); GetIniFileString("Other", "LCSPosInterval", ref Variable.sLCSPosInterval); GetIniFileString("Other", "CustomMenuTitle", ref Variable.sCustomMenuTitle); GetIniFileString("Other", "CustomSoftwarePath", ref Variable.sCustomSoftwarePath); GetIniFileString("Other", "sLonLatDis", ref Variable.sLonLatDis); GetIniFileString("Other", "MaxPicMonitorTime", ref Variable.sNumMaxPicMonitorTime); GetIniFileString("Other", "UserLevel", ref Variable.sLevelInfo); GetIniFileString("ToolBar", "ItemState", ref Variable.sToolBarItemState); GetIniFileString("Other", "JGShowCarNum", ref Variable.sJGShowCar);//建工显示车牌和或者自编号 return(true); } catch (Exception exception) { Record.execFileRecord("读取配置文件", exception.ToString()); return(false); } }