コード例 #1
0
ファイル: X2Error.cs プロジェクト: tevfikoguz/LineBudget
        public static List <string> GetFileListByDay(DateTime date)
        {
            string dateFolder = rootPath + "//" + GetDateFolderName(date);

            if (!Directory.Exists(dateFolder))
            {
                return(null);
            }
            else
            {
                return(X2File.GetFileNames(dateFolder));
            }
        }
コード例 #2
0
ファイル: X2Error.cs プロジェクト: tevfikoguz/LineBudget
        /// <summary>
        /// 记录错误日志
        /// </summary>
        /// <param name="ErrorMessage">错误信息</param>
        /// <param name="Mode">模块名称</param>
        public static void Log(string errorMessage, Exception ex, string moduleName)
        {
            ///写入日志
            if (string.IsNullOrEmpty(rootPath))
            {
                try
                {
                    if (System.Web.HttpContext.Current == null)
                    {
                        return;
                    }
                    else
                    {
                        rootPath = System.Web.HttpContext.Current.Request.MapPath(@"\Documentation\SYSLOG\");
                    }
                }
                catch
                {
                    return;
                }
                /*end  /*单号:00009_00040*/
            }

            try
            {
                if (!Directory.Exists(rootPath))
                {
                    Directory.CreateDirectory(rootPath);
                }
                string ErroLogFileName = GetTodayFileName();

                if (!X2File.IsExist(ErroLogFileName))
                {
                    X2File.AppendFile(ErroLogFileName, "<meta http-equiv=content-type content='charset=utf8'/>");
                }

                ///here should save this file into readable code
                string fileContent = GetErrorContent(errorMessage, ex, moduleName);
                lock (errorLock)
                {
                    X2File.AppendFile(ErroLogFileName, fileContent);
                }
            }
            catch (Exception exthis)
            {
                return;
            }
        }
コード例 #3
0
 /// <summary>
 /// 图形保存
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void button5_Click(object sender, EventArgs e)
 {
     if (this.saveFileDialog1.ShowDialog() == DialogResult.OK)
     {
         try
         {
             string cadFileDir = string.Concat(System.AppDomain.CurrentDomain.BaseDirectory, "TmpFile\\");
             X2Directory.CreatDir(cadFileDir);
             string cadFilePath = string.Concat(cadFileDir, "TmpCadFile.dxf");
             X2File.CopyFile(this.saveFileDialog1.FileName, cadFilePath);
             MessageBox.Show("保存完毕!");
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
     }
 }
コード例 #4
0
        /// <summary>
        /// 自动绘制cad图形
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button4_Click(object sender, EventArgs e)
        {
            #region 暂时删除
            //DxfDocument dxf = new DxfDocument();
            //List<PolyfaceMeshVertex> vertexes = new List<PolyfaceMeshVertex>
            //                                        {
            //                                            new PolyfaceMeshVertex(0, 0, 0),
            //                                            new PolyfaceMeshVertex(10, 0, 0),
            //                                            new PolyfaceMeshVertex(10, 10, 0),
            //                                            new PolyfaceMeshVertex(5, 15, 0),
            //                                            new PolyfaceMeshVertex(0, 10, 0)
            //                                        };
            //List<PolyfaceMeshFace> faces = new List<PolyfaceMeshFace>
            //                                   {
            //                                       new PolyfaceMeshFace(new[] {1, 2, -3}),
            //                                       new PolyfaceMeshFace(new[] {-1, 3, -4}),
            //                                       new PolyfaceMeshFace(new[] {-1, 4, 5})
            //                                   };

            //PolyfaceMesh mesh = new PolyfaceMesh(vertexes, faces);
            //dxf.AddEntity(mesh);
            //dxf.Save("mesh.dxf", DxfVersion.AutoCad2000);
            #endregion

            string cadFileDir = string.Concat(System.AppDomain.CurrentDomain.BaseDirectory, "TmpFile\\");
            X2Directory.CreatDir(cadFileDir);
            string cadFilePath = string.Concat(cadFileDir, "TmpCadFile.dxf");
            if (X2File.IsExist(cadFilePath))
            {
                X2File.DeleteFile(cadFilePath);
            }

            //Polyline(cadFilePath);
            DrawLine();
            MessageBox.Show("绘制完成");
            //string newFilePath = cadFilePath;
            //if (!X2File.IsExist(newFilePath))
            //{
            //    MessageBox.Show("未找到CAD图:" + newFilePath);
            //}
        }
コード例 #5
0
ファイル: ExcelAdapter.cs プロジェクト: tevfikoguz/LineBudget
        /// <summary>
        /// 读取excel表单数据
        /// </summary>
        /// <param name="fileInfo">excel文件信息</param>
        /// <param name="currentUser">用户信息</param>
        /// <returns>表格的形式返回</returns>
        public DataTable GetExcelDataTable(string fielName)
        {
            ///文件信息异常处理
            if (string.IsNullOrEmpty(fielName) || !X2File.IsExist(fielName))
            {
                return(null);
            }

            ///连接字符串
            string connectionString = "Provider=Microsoft.Ace.OleDb.12.0;" + "Data Source=" + fielName + ";" + "Extended Properties='Excel 12.0;HDR=Yes;IMEX=1';";

            ///97-03版excel
            if (fielName.EndsWith(".xls"))
            {
                connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Extended Properties=Excel 8.0;" + "data source=" + fielName + ";Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=1\"";
            }
            OleDbConnection conn = new OleDbConnection(connectionString);

            try
            {
                ///新建内存表单存储excel数据量
                DataTable dt = new DataTable();
                if (conn.State != ConnectionState.Open)
                {
                    conn.Open();
                }

                ///新建内存表单存储
                DataTable dtData = new DataTable();
                ///获取所有的数据
                string           strExcel = "select * from [Sheet1$]";
                OleDbDataAdapter adapter  = new OleDbDataAdapter(strExcel, conn);
                adapter.Fill(dtData);
                if (conn.State != ConnectionState.Closed)
                {
                    conn.Close();
                }

                if (dtData == null || dtData.Rows == null || dtData.Rows.Count <= 1)
                {
                    if (conn.State != ConnectionState.Closed)
                    {
                        conn.Close();
                    }
                    return(null);
                }

                return(dtData);
            }
            catch (Exception ex)
            {
                return(null);
            }
            finally
            {
                ///关闭连接
                if (conn.State != ConnectionState.Closed)
                {
                    conn.Close();
                }
            }
        }