Example #1
0
        /// <summary>
        /// 添加或替换项目
        /// </summary>
        /// <param name="zipFile">压缩包</param>
        /// <param name="catalogNumber">编号</param>
        /// <param name="sourceFile">源文件</param>
        /// <returns>CatalogID</returns>
        public string addOrReplaceProject(string zipFile, string catalogNumber, string sourceFile)
        {
            //SQLite数据库工厂
            System.Data.SQLite.SQLiteFactory factory = new System.Data.SQLite.SQLiteFactory();

            //NDEY数据库连接
            Noear.Weed.DbContext context = new Noear.Weed.DbContext("main", "Data Source = " + sourceFile, factory);
            //是否在执入后执行查询(主要针对Sqlite)
            context.IsSupportSelectIdentityAfterInsert = false;
            //是否在Dispose后执行GC用于解决Dispose后无法删除的问题(主要针对Sqlite)
            context.IsSupportGCAfterDispose = true;

            try
            {
                return(importDB(zipFile, catalogNumber, sourceFile, context));
            }
            catch (Exception ex)
            {
                PublicManager.Modules.Module_A.PkgImporter.Forms.ImporterForm.writeImportLog(PublicManager.Modules.Module_A.PkgImporter.Forms.ImporterForm.errorlogFilePath, "错误", "对不起,压缩文件(" + sourceFile + ")导入时出错!请检查!Ex:" + ex.ToString());
                BaseModuleMainFormWithNoUIConfig.writeLog(ex.ToString());
                return(string.Empty);
            }
            finally
            {
                factory.Dispose();
                context.Dispose();
            }
        }
Example #2
0
        /// <summary>
        /// 添加或替换项目
        /// </summary>
        /// <param name="catalogNumber">catalogNumber</param>
        /// <param name="sourceFile">源文件</param>
        /// <returns>CatalogID</returns>
        public string addOrReplaceProject(string catalogNumber, string sourceFile)
        {
            //SQLite数据库工厂
            System.Data.SQLite.SQLiteFactory factory = new System.Data.SQLite.SQLiteFactory();

            //NDEY数据库连接
            Noear.Weed.DbContext context = new Noear.Weed.DbContext("main", "Data Source = " + sourceFile, factory);
            //是否在执入后执行查询(主要针对Sqlite)
            context.IsSupportSelectIdentityAfterInsert = false;
            //是否在Dispose后执行GC用于解决Dispose后无法删除的问题(主要针对Sqlite)
            context.IsSupportGCAfterDispose = true;

            try
            {
                return(importDB(catalogNumber, sourceFile, context));
            }
            catch (Exception ex)
            {
                System.Console.WriteLine(ex.ToString());
                return(string.Empty);
            }
            finally
            {
                factory.Dispose();
                context.Dispose();
            }
        }
Example #3
0
 /// <summary>
 /// 执行一条SQL
 /// </summary>
 /// <param name="context"></param>
 /// <param name="sql"></param>
 /// <returns></returns>
 protected virtual Noear.Weed.DbQuery newSql(Noear.Weed.DbContext context, string sql)
 {
     Noear.Weed.DbQuery query = context.sql(sql, new object[] { });
     return(query.onCommandBuilt((cmd) =>
     {
         cmd.tag = "table" + DateTime.Now.Ticks;
         cmd.isLog = true;
     }));
 }
        /// <summary>
        /// 获得项目信息
        /// </summary>
        /// <param name="projectDir"></param>
        /// <returns></returns>
        public JiBenXinXiBiao getProjectObject(string projectDir)
        {
            JiBenXinXiBiao proj   = null;
            string         dbFile = System.IO.Path.Combine(projectDir, "static.db");

            if (System.IO.File.Exists(dbFile))
            {
                System.Data.SQLite.SQLiteFactory factory = new System.Data.SQLite.SQLiteFactory();
                Noear.Weed.DbContext             context = new Noear.Weed.DbContext("main", "Data Source=" + dbFile, factory);
                context.IsSupportInsertAfterSelectIdentity = false;
                context.IsSupportGCAfterDispose            = true;
                try
                {
                    proj = context.table("JiBenXinXiBiao").select("*").getItem <JiBenXinXiBiao>(new JiBenXinXiBiao());
                }
                catch (Exception ex)
                {
                    throw new Exception(ex.ToString());
                }
                finally
                {
                    try
                    {
                        factory.Dispose();
                    }
                    catch (Exception ex) { }
                    factory = null;

                    try
                    {
                        context.Dispose();
                    }
                    catch (Exception ex) { }
                    context = null;
                }
            }

            return(proj);
        }
Example #5
0
 /// <summary>
 /// 导入数据库
 /// </summary>
 /// <param name="zipFile">压缩包</param>
 /// <param name="catalogNumber">编号</param>
 /// <param name="sourceFile">源文件</param>
 /// <param name="localContext">数据库访问对象</param>
 /// <returns>CatalogID</returns>
 protected abstract string importDB(string zipFile, string catalogNumber, string sourceFile, Noear.Weed.DbContext localContext);
Example #6
0
 /// <summary>
 /// 判断是否存在需要的表格
 /// </summary>
 /// <param name="context"></param>
 protected abstract bool isExistsTables(Noear.Weed.DbContext context);