public ImportDataFrm() { InitializeComponent(); TxbLableMin.Text = CIni.ReadINI("DrawCAD", "LableMin"); TxbArrowMin.Text = CIni.ReadINI("DrawCAD", "ArrowMin"); //this.FormClosing += ImportDataFrm_FormClosing; //AcadApp = (AcadApplication)System.Runtime.InteropServices.Marshal.GetActiveObject("AutoCAD.Application"); //AcadApp.Application.Visible = false; //AcadDoc = AcadApp.ActiveDocument; //AcadDoc.Close(false); }
private bool VerificationXY() { double MinX, MinY, MaxX, MaxY; //string[] MinPoint = System.Configuration.ConfigurationSettings.AppSettings["MinPoint"].Split(','); MinX = double.Parse(CIni.ReadINI("XYExtent", "MinX")); MinY = double.Parse(CIni.ReadINI("XYExtent", "MinY")); //string[] MaxPoint = System.Configuration.ConfigurationSettings.AppSettings["MaxPoint"].Split(','); MaxX = double.Parse(CIni.ReadINI("XYExtent", "MaxX")); MaxY = double.Parse(CIni.ReadINI("XYExtent", "MaxY")); double C_X = double.Parse(this.X); double C_Y = double.Parse(this.Y); if (C_X < MinX || C_X > MaxX || C_Y < MinY || C_Y > MaxY) { return(false); } return(true); }
private string GetPCRecordTable() { string json = ""; try { string PostParam = "querySql=select * from view_ps_gxpc_gx "; //string id = "id=" + ID; string url = CIni.ReadINI("updateconfig", "DataUrl"); Encoding encoding = Encoding.UTF8; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request.Method = "POST"; //request.Accept = "text/html, application/xhtml+xml, */*"; request.Accept = "application/json"; request.ContentType = "application/x-www-form-urlencoded"; //request.Connection = "Keep-Alive"; byte[] buffer = encoding.GetBytes(PostParam); request.ContentLength = buffer.Length; Stream requestStream = request.GetRequestStream(); requestStream.Write(buffer, 0, buffer.Length); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); Stream responseStream = response.GetResponseStream(); using (StreamReader reader = new StreamReader(responseStream, Encoding.UTF8)) { json = reader.ReadToEnd(); } requestStream.Close(); responseStream.Close(); } catch (Exception e) { throw e; //ExceptionLog.LogError(ID, e); //return ""; //json = e.Message; } //ExceptionLog.LogError(ID + ":" + json, null); return(json); }
private void BtnStart_Click(object sender, EventArgs e) { if (txbExcelPath.Text == string.Empty) { MessageBox.Show("请选择普查数据表格"); return; } if (TxbCoordFile.Text == string.Empty) { MessageBox.Show("请选择坐标数据表格"); return; } CIni.WriterINI("DrawCAD", "LableMin", TxbLableMin.Text); CIni.WriterINI("DrawCAD", "ArrowMin", TxbArrowMin.Text); pWorkArgument = new WorkArgument(); pWorkArgument.ExcelPath = txbExcelPath.Text; pWorkArgument.DwgSavePath = TxbSaveDir.Text; pWorkArgument.CoordExcelpath = TxbCoordFile.Text; //pWorkArgument.ProjectName = txbProject.Text; this.DialogResult = System.Windows.Forms.DialogResult.OK; }
public void Edit() { try { string serverIP = CIni.ReadINI("updateconfig", "ServerIP"); int serverPort = int.Parse(CIni.ReadINI("updateconfig", "ServerPort")); if (VersionHelper.HasNewVersion(serverIP, serverPort)) { if (MessageBox.Show("服务器端发布了更新,请退出AutoCAD然后运行获取更新程序", "提示", MessageBoxButtons.OKCancel , MessageBoxIcon.Warning) == DialogResult.OK) { AcadApplication AcadApp = (AcadApplication)System.Runtime.InteropServices.Marshal.GetActiveObject("AutoCAD.Application"); AcadApp.Quit(); return; } } } finally { CADObjectEditCtrl pCADObjectEditCtrl = new CADObjectEditCtrl(); Autodesk.AutoCAD.Windows.PaletteSet ps = new Autodesk.AutoCAD.Windows.PaletteSet("管网管理"); ps.Style = PaletteSetStyles.ShowTabForSingle; ps.Style = PaletteSetStyles.NameEditable; ps.Style = PaletteSetStyles.ShowPropertiesMenu; ps.Style = PaletteSetStyles.ShowAutoHideButton; ps.Style = PaletteSetStyles.ShowCloseButton; ps.Dock = DockSides.Left; ps.Visible = true; ps.MinimumSize = new System.Drawing.Size(556, 490); ps.Size = new System.Drawing.Size(556, 490); AcadApplication AcadApp = (AcadApplication)System.Runtime.InteropServices.Marshal.GetActiveObject("AutoCAD.Application"); Autodesk.AutoCAD.Interop.AcadDocument AcadDoc = AcadApp.ActiveDocument; string CurCadfile = AcadDoc.FullName; string CurMdbName = System.IO.Path.GetDirectoryName(CurCadfile) + "\\" + System.IO.Path.GetFileNameWithoutExtension(CurCadfile) + ".db"; //MessageBox.Show(CurMdbName); if (!System.IO.File.Exists(CurMdbName)) { System.Windows.Forms.OpenFileDialog pDlg = new System.Windows.Forms.OpenFileDialog(); pDlg.Filter = "数据库文件|*.db|所有文件(*.*)|*.*"; pDlg.Multiselect = false; if (pDlg.ShowDialog() == DialogResult.OK) { SysDBUnitiy.MDBPath = pDlg.FileName; ps.Add("管网管理", pCADObjectEditCtrl); ps.Activate(0); } } else { SysDBUnitiy.MDBPath = CurMdbName; ps.Add("管网管理", pCADObjectEditCtrl); ps.Activate(0); } } }
public override void DrawCADObject(Autodesk.AutoCAD.Interop.AcadDocument AcadDoc) { string Linetype = "合流"; int LayerID = GetLayerIndex("YSLine", AcadDoc); if (this.US_SURVEY_ID.StartsWith("WS")) { LayerID = GetLayerIndex("WSLine", AcadDoc); Linetype = "污水"; } else if (this.US_SURVEY_ID.StartsWith("YS")) { Linetype = "雨水"; } AcadDoc.ActiveLayer = AcadDoc.Layers.Item(LayerID); IPCPoint SPoint = GetPointByID(this.US_SURVEY_ID); IPCPoint EPoint = GetPointByID(this.DS_SURVEY_ID); double[] StartPoint = new double[3] { double.Parse(SPoint.X), double.Parse(SPoint.Y), 0 }; double[] EndPoint = new double[3] { double.Parse(EPoint.X), double.Parse(EPoint.Y), 0 }; AcadLine pAcadLine = AcadDoc.ModelSpace.AddLine(StartPoint, EndPoint); AcadDictionary pAcadDictionary = pAcadLine.GetExtensionDictionary(); //pAcadDictionary.AddXRecord(ClassName); pAcadDictionary.AddXRecord(ID); string MinArrowVal = CIni.ReadINI("DrawCAD", "ArrowMin"); bool IsDrawArrow = false; if (string.IsNullOrEmpty(MinArrowVal)) { IsDrawArrow = true; } else { double MinArrow = double.Parse(MinArrowVal); if (pAcadLine.Length < MinArrow) { IsDrawArrow = false; } else { IsDrawArrow = true; } } double[] MidPoint = new double[3] { (double.Parse(SPoint.X) + double.Parse(EPoint.X)) / 2, (double.Parse(SPoint.Y) + double.Parse(EPoint.Y)) / 2, 0 }; if (IsDrawArrow) { string WidthValue = this.Width; AcadMInsertBlock pBlock = AcadDoc.ModelSpace.AddMInsertBlock(MidPoint, "GP4", 1, 1, 1, 0, 1, 1, 1, 1); pBlock.Rotate(MidPoint, pAcadLine.Angle); pAcadDictionary = pBlock.GetExtensionDictionary(); pAcadDictionary.AddXRecord(ID); } string MinLableVal = CIni.ReadINI("DrawCAD", "LableMin"); if (!string.IsNullOrEmpty(MinLableVal)) { double MinLable = double.Parse(MinLableVal); if (pAcadLine.Length < MinLable) { return; } } string pUS_INVERT_LEVEL = double.Parse(SPoint.INVERT_LEVEL).ToString("0.000"); string pDS_INVERT_LEVEL = double.Parse(EPoint.INVERT_LEVEL).ToString("0.000"); string LineLable = string.Format("{0} {1}m {2}Φ{3} {4}m", Linetype, pUS_INVERT_LEVEL, this.MATERIAL, this.Width, pDS_INVERT_LEVEL); LayerID = GetLayerIndex("YSZJ", AcadDoc); if (this.US_SURVEY_ID.StartsWith("WS")) { LayerID = GetLayerIndex("WSZJ", AcadDoc); } else { LayerID = GetLayerIndex("YSZJ", AcadDoc); } AcadDoc.ActiveLayer = AcadDoc.Layers.Item(LayerID); AcadText pAcadText = AcadDoc.ModelSpace.AddText(LineLable, MidPoint, 2.0); double LineAngle = pAcadLine.Angle; if (LineAngle > Math.PI / 2 && LineAngle < 3 * Math.PI / 2) { LineAngle = LineAngle - Math.PI; } pAcadText.Rotate(MidPoint, LineAngle); pAcadDictionary = pAcadText.GetExtensionDictionary(); //pAcadDictionary.AddXRecord(ClassName); pAcadDictionary.AddXRecord(ID); //} AcadDoc.Save(); }
public void New() { try { string serverIP = CIni.ReadINI("updateconfig", "ServerIP"); int serverPort = int.Parse(CIni.ReadINI("updateconfig", "ServerPort")); if (VersionHelper.HasNewVersion(serverIP, serverPort)) { if (MessageBox.Show("服务器端发布了更新,请退出AutoCAD然后运行获取更新程序", "提示", MessageBoxButtons.OKCancel , MessageBoxIcon.Warning) == DialogResult.OK) { AcadApplication AcadApp = (AcadApplication)System.Runtime.InteropServices.Marshal.GetActiveObject("AutoCAD.Application"); AcadApp.Quit(); return; //MessageBox.Show("完成关闭"); } } } finally { ImportDataFrm pImportDataFrm = new ImportDataFrm(); if (pImportDataFrm.ShowDialog() == DialogResult.OK) { pWork = new BackgroundWorker(); pWork.WorkerReportsProgress = true; pWork.WorkerSupportsCancellation = true; pWork.DoWork += PWork_DoWork; pWork.ProgressChanged += PWork_ProgressChanged; pWork.RunWorkerCompleted += new RunWorkerCompletedEventHandler(pWork_RunWorkerCompleted); pProgressFrm = HR.Controls.ProgressFrm.GetInstance(); pProgressFrm.CanCancle = false; pProgressFrm.FormClosed += new FormClosedEventHandler(pProgressFrm_FormClosed); pProgressFrm.SetProgressStyle(ProgressBarStyle.Blocks); pProgressFrm.Text = "数据成图"; pWork.RunWorkerAsync(pImportDataFrm.pWorkArgument); //pProgressFrm.FormClosing += new FormClosingEventHandler(pProgressFrm_FormClosing); /* pCADObjectEditCtrl = new CADObjectEditCtrl(); * * Autodesk.AutoCAD.Windows.PaletteSet ps = new Autodesk.AutoCAD.Windows.PaletteSet("管网管理"); * * ps.Style = PaletteSetStyles.ShowTabForSingle; * ps.Style = PaletteSetStyles.NameEditable; * ps.Style = PaletteSetStyles.ShowPropertiesMenu; * ps.Style = PaletteSetStyles.ShowAutoHideButton; * ps.Style = PaletteSetStyles.ShowCloseButton; * * ps.Dock = DockSides.Left; * ps.Visible = true; * ps.MinimumSize = new System.Drawing.Size(230, 490); * ps.Size = new System.Drawing.Size(230, 490); * * ps.Add("管网管理", pCADObjectEditCtrl); * ps.Activate(0);*/ } } }
private void PWork_DoWork(object sender, DoWorkEventArgs e) { //pProgressFrm.TopMost = true; pProgressFrm.ShowDialog(); WorkArgument pWorkArgument = e.Argument as WorkArgument; string ExcelPath = pWorkArgument.ExcelPath; string ExcelName = System.IO.Path.GetFileNameWithoutExtension(ExcelPath); //string ProjectName = pWorkArgument.ProjectName; string DwgPath = pWorkArgument.DwgSavePath; SysDBUnitiy.MDBPath = Path.GetDirectoryName(DwgPath) + string.Format("\\{0}.db", Path.GetFileNameWithoutExtension(DwgPath)); string TemplateDwg = SysDBUnitiy.RootDir + "\\Template\\template.dwg"; string TemplateMdb = SysDBUnitiy.RootDir + "\\Template\\Template.db"; AcadApplication AcadApp = (AcadApplication)System.Runtime.InteropServices.Marshal.GetActiveObject("AutoCAD.Application"); pWork.ReportProgress(0, "正在创建数据文件"); if (File.Exists(SysDBUnitiy.MDBPath)) { File.Delete(SysDBUnitiy.MDBPath); } if (!File.Exists(SysDBUnitiy.MDBPath)) { File.Copy(TemplateMdb, SysDBUnitiy.MDBPath, false); } if (File.Exists(DwgPath)) { try { File.Delete(DwgPath); } catch (System.Exception ex) { MessageBox.Show("删除旧dwg文件失败,请检查该文件是否被占用"); return; } } if (!File.Exists(DwgPath)) { File.Copy(TemplateDwg, DwgPath, false); } //List<TableConfig> LineTableName = new List<TableConfig>(); //List<TableConfig> PointTableName = new List<TableConfig>(); pWork.ReportProgress(0, "正在准备写入dwg文件数据"); Autodesk.AutoCAD.Interop.AcadDocument AcadDoc = AcadApp.Documents.Open(DwgPath); double MinX, MinY, MaxX, MaxY; //string[] MinPoint = System.Configuration.ConfigurationSettings.AppSettings["MinPoint"].Split(','); MinX = double.Parse(CIni.ReadINI("XYExtent", "MinX")); MinY = double.Parse(CIni.ReadINI("XYExtent", "MinY")); //string[] MaxPoint = System.Configuration.ConfigurationSettings.AppSettings["MaxPoint"].Split(','); MaxX = double.Parse(CIni.ReadINI("XYExtent", "MaxX")); MaxY = double.Parse(CIni.ReadINI("XYExtent", "MaxY")); pWork.ReportProgress(0, "正在读取表格数据"); DataTable PCTable = ExcelClass.ReadExcelFile(ExcelPath); DataTable CoordTable = ExcelClass.ReadExcelFile(pWorkArgument.CoordExcelpath); CoordTable.Columns[0].ColumnName = "ID"; //CoordTable.PrimaryKey = new DataColumn[] { CoordTable.Columns[0] }; DataRow FirstRow = CoordTable.Rows[0]; for (int j = 1; j < FirstRow.ItemArray.Length; j++) { string value = FirstRow.ItemArray[j].ToString(); double V_num = 0; if (double.TryParse(value, out V_num)) { if (V_num > MinX && V_num < MaxX) { CoordTable.Columns[j].ColumnName = "CO_X"; } else if (V_num > MinY && V_num < MaxY) { CoordTable.Columns[j].ColumnName = "CO_Y"; } else { CoordTable.Columns[j].ColumnName = "CO_Z"; } } } Dictionary <string, DataRow> CoordBHTable = new Dictionary <string, DataRow>(); foreach (DataRow pCoordRow in CoordTable.Rows) { string key = pCoordRow["ID"].ToString(); if (!CoordBHTable.ContainsKey(key)) { CoordBHTable.Add(key, pCoordRow); } } DataTable ErrorTable = PCTable.Clone(); if (!ErrorTable.Columns.Contains("错误消息")) { ErrorTable.Columns.Add("错误消息"); } #region 循环遍历表 //int SumCount = PCTable.Rows.Count; //int CurNum =0; DataTable PCTab2 = PCTable.Copy(); for (int i = 0; i < PCTable.Rows.Count; i++) { //CurNum++; DataRow pDataRow = PCTable.Rows[i]; try { pWork.ReportProgress(i * 100 / PCTable.Rows.Count, string.Format("正在导入第: {0}/{1}条", i + 1, PCTable.Rows.Count)); string ErrorMsg = string.Empty; string SPointID = GetValue(pDataRow, "起点点号"); if (string.IsNullOrEmpty(SPointID)) { ErrorMsg += "起点号不能为空;"; } IPipePoint SPoint = null; DataRow SPointRow = IsExistSURVEYID(SPointID); if (SPointRow == null) { if (!CoordBHTable.ContainsKey(SPointID)) { ErrorMsg += "起点对应的坐标不存在;"; } if (ErrorMsg != string.Empty) { goto a1; } //DataRow pCoordRow = CoordBHTable[SPointID]; SPoint = GetPipePoint(SPointID, pDataRow, CoordBHTable[SPointID]); SPoint.AddNew(); SPoint.DrawCADObject(AcadDoc); //CoordBHTable.ContainsKey(SPointID) CoordBHTable.Remove(SPointID); } else { //string ClassName = SPointRow["ClassName"].ToString(); //string ID = SPointRow["ID"].ToString(); SPoint = new PCPoint(); //string sql = string.Format("select * from Points where ID='{0}'" , ID); //DataTable pTable = SysDBUnitiy.OleDataBase.ExecuteQuery(sql).Tables[0]; //if (pTable.Rows.Count > 0) //{ SPoint.FillValueByRow(SPointRow); //} } string EPointID = GetValue(pDataRow, "终点点号"); if (EPointID == string.Empty) { goto a1; } IPipePoint EPoint = null; DataRow EPointRow = IsExistSURVEYID(EPointID); if (EPointRow == null) { EPointRow = FindRow(PCTable, EPointID, i + 1); if (EPointRow == null) { ErrorMsg += "终点对应的信息不存在;"; goto a1; } // DataRow[] ECoordRows = CoordTable.Select(string.Format("ID='{0}'", EPointID)); if (!CoordBHTable.ContainsKey(EPointID)) { ErrorMsg += "终点对应的坐标不存在;"; goto a1; } /* string EPointType = GetValue(EPointRow, "起点类型"); * if (EPointType == string.Empty) * { * ErrorMsg += "终点类型不能为空"; * } * string ClassName = GetTrueType(EPointType); * if (ClassName == string.Empty) * { * ErrorMsg += "终点类型无法识别"; * * } */ if (ErrorMsg != string.Empty) { goto a1; } EPoint = GetPipePoint(EPointID, EPointRow, CoordBHTable[EPointID]); EPoint.AddNew(); EPoint.DrawCADObject(AcadDoc); CoordBHTable.Remove(EPointID); } else { //string ClassName = EPointRow["ClassName"].ToString(); //string ID = EPointRow["ID"].ToString(); EPoint = new PCPoint(); //string sql = string.Format("select * from Points where ID='{0}'", ID); //DataTable pTable = SysDBUnitiy.OleDataBase.ExecuteQuery(sql).Tables[0]; //if (pTable.Rows.Count > 0) //{ EPoint.FillValueByRow(EPointRow); //} } string GJ = GetValue(pDataRow, "管径"); IPIPELine pPIPELine = new PIPELineClass(); if (!pPIPELine.isExistSURVEY_ID(SPointID, EPointID)) { pPIPELine.Width = GJ; pPIPELine.US_SURVEY_ID = SPointID; pPIPELine.DS_SURVEY_ID = EPointID; //pPIPELine.ID = pPIPELine.GetHead() + SPointID.Substring(2, 3) + pPIPELine.GetNextNO(); pPIPELine.ID = Guid.NewGuid().ToString("N"); pPIPELine.US_OBJECT_ID = SPoint.ID; pPIPELine.DS_OBJECT_ID = EPoint.ID; //pPIPELine.SYSTEM_TYPE = SPoint.SYSTEM_TYPE; double D_X = double.Parse(EPoint.X) - double.Parse(SPoint.X); double D_Y = double.Parse(EPoint.Y) - double.Parse(EPoint.Y); double Len = Math.Round(Math.Sqrt(D_X * D_X + D_Y * D_Y), 2); pPIPELine.Pipe_Length = Len.ToString(); //pPIPELine.US_POINT_INVERT_LEVEL = SPoint.INVERT_LEVEL; /* string US_NS = GetValue(pDataRow, "起点管口泥深"); * if (US_NS != string.Empty) * pPIPELine.US_INVERT_LEVEL = (double.Parse(SPoint.GROUND_LEVEL) - double.Parse(US_NS)/100).ToString("0.00"); * string DS_NS = GetValue(pDataRow, "终点管口泥深"); * if (DS_NS != string.Empty) * pPIPELine.DS_INVERT_LEVEL = (double.Parse(EPoint.GROUND_LEVEL) - double.Parse(DS_NS)/100).ToString("0.00"); */ pPIPELine.SEDIMENT_DEPTH = GetValue(pDataRow, "泥深"); pPIPELine.MATERIAL = GetValue(pDataRow, "材质"); pPIPELine.PRESSURE = GetValue(pDataRow, "管道形式"); pPIPELine.STATE = GetValue(pDataRow, "设施状态"); pPIPELine.ROAD_NAME = GetValue(pDataRow, "所在道路"); pPIPELine.Remark = GetValue(pDataRow, "线备注"); pPIPELine.WATER_LEVEL = GetValue(pDataRow, "泥深"); pPIPELine.WATER_QUALITY = GetValue(pDataRow, "水质"); pPIPELine.WATER_State = GetValue(pDataRow, "水体状态"); pPIPELine.Dirtcion = GetValue(pDataRow, "流向"); pPIPELine.AddNew(); pPIPELine.DrawCADObject(AcadDoc); } a1: if (ErrorMsg != string.Empty) { DataRow ErrorRow = ErrorTable.NewRow(); List <object> ItemList = new List <object>(); if (pDataRow.Table.Columns.Contains("错误消息")) { pDataRow["错误消息"] = ErrorMsg; ItemList.AddRange(pDataRow.ItemArray); } else { ItemList.AddRange(pDataRow.ItemArray); ItemList.Add(ErrorMsg); } ErrorRow.ItemArray = ItemList.ToArray(); ErrorTable.Rows.Add(ErrorRow); } //PCTable.Rows.RemoveAt(i); } catch (System.Exception ex) { DataRow ErrorRow = ErrorTable.NewRow(); List <object> ItemList = new List <object>(); if (pDataRow.Table.Columns.Contains("错误消息")) { pDataRow["错误消息"] = ex.Message; ItemList.AddRange(pDataRow.ItemArray); } else { ItemList.AddRange(pDataRow.ItemArray); ItemList.Add(ex.Message); } ErrorRow.ItemArray = ItemList.ToArray(); ErrorTable.Rows.Add(ErrorRow); } pWork.ReportProgress((i + 1) * 100 / PCTable.Rows.Count); } int n = 0; //pProgressFrm.SafeCallDisplayProgress(0); foreach (KeyValuePair <string, DataRow> CoordBH in CoordBHTable) { pWork.ReportProgress(n * 100 / CoordBHTable.Count, string.Format("正在导入第: {0}/{1}个多余点", n, CoordBHTable.Count)); n++; // pProgressFrm.SafeCallDisplayText(string.Format("正在导入第: {0}/{1}个多余点", n, CoordBHTable.Count)); IPCPoint pPCPoint = new PCPoint(); if (IsExistSURVEYID(CoordBH.Key) == null) { try { pPCPoint.ID = Guid.NewGuid().ToString("N"); pPCPoint.SURVEY_ID = CoordBH.Key; pPCPoint.X = CoordBH.Value["CO_X"].ToString(); pPCPoint.Y = CoordBH.Value["CO_Y"].ToString(); pPCPoint.GROUND_LEVEL = CoordBH.Value["CO_Z"].ToString(); pPCPoint.AddNew(); pPCPoint.DrawCADObject(AcadDoc); } catch (System.Exception ex) { } } pWork.ReportProgress(n * 100 / CoordBHTable.Count); // pProgressFrm.SafeCallDisplayProgress(n * 100 / CoordBHTable.Count); } //pProgressFrm.SafeCallCloseDialog(); MessageBox.Show(string.Format("总共导入{0}条管线数据,{3}个多余点,其中成功{1}条,失败{2}条。", PCTab2.Rows.Count, PCTab2.Rows.Count - ErrorTable.Rows.Count, ErrorTable.Rows.Count, CoordBHTable.Count ), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); if (ErrorTable.Rows.Count > 0) { string ReportXls = System.IO.Path.GetDirectoryName(pWorkArgument.DwgSavePath) + string.Format("\\未导入{0}.xls", DateTime.Now.ToString("MMddHHmm")); ExcelClass.ExpReport(ErrorTable, ReportXls); if (MessageBox.Show("已导出失败记录到输出目录,是否查看", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { System.Diagnostics.Process pExecuteEXE = new System.Diagnostics.Process(); pExecuteEXE.StartInfo.FileName = ReportXls; pExecuteEXE.Start(); } } #endregion }