Ejemplo n.º 1
0
        public static string InitDB()
        {
            try
            {
                if (!Directory.Exists(DbConfig.DBPath))
                {
                    Directory.CreateDirectory(DbConfig.DBPath);
                }

                if (!File.Exists(DbConfig.DBFileFullName))
                {
                    File.Create(DbConfig.DBFileFullName).Close();
                }

                DBTableCorrector.CorrectDBTableByDtos();

                InitTableFieldInfoDto();
            }
            catch (Exception e)
            {
                Log.Error(e.ToString(), MethodBase.GetCurrentMethod());
                return(e.ToString());
            }

            return(string.Empty);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 构造
        /// </summary>
        private DBService()
        {
            try
            {
                //包含所有数据库表的type数组
                List <Type> tableList = new List <Type> {
                    typeof(ProjectInfoDto),
                    typeof(UnitBasicDataDto),
                    typeof(UnitDevelopDataDto),
                    typeof(WellDevelopDataDto),
                };

                DBTableCorrector.CreateTable(tableList.ToArray());
            }
            catch (Exception ex)
            {
                Trace.TraceError(ex.ToString());
            }
        }