Exemplo n.º 1
0
        static void TestMemDb()
        {
            MemDB             db   = MemDBEngin.GetDB();
            List <TestEntity> list = db.Get <TestEntity>();

            Console.WriteLine("加载数据 {0}条", list.Count);

            TestEntity[] entitys = new TestEntity[10000];
            for (int i = 0; i < 10000; i++)
            {
                entitys[i] = new TestEntity()
                {
                    ID     = i,
                    Name   = "Name" + i,
                    AtTime = DateTime.Now
                };
            }

            bool flag = db.SaveEntity <TestEntity>(entitys);

            if (flag)
            {
                Console.WriteLine("保存数据成功!");
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 导入数据至远程作业库(BS端)
        /// </summary>
        /// <param name="dbName"></param>
        /// <param name="projectID"></param>
        /// <param name="targetDataSource">提交复核/提交归档</param>
        private static void Import(string dbName, string projectID, string targetDataSource)
        {
            string dataSource    = MemDBEngin.DbSource;
            string objDataSource = System.IO.Path.Combine(dataSource, dbName + "_" + projectID);

            Console.WriteLine("数据源:" + objDataSource);
            using (MemDB mem = MemDBEngin.GetDB(objDataSource))
            {
                ImportData(mem, targetDataSource, projectID);
                Console.WriteLine("向目标数据源{0} 导入数据完成", targetDataSource);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 导出数据,返回数据文件路径和成功标记
        /// </summary>
        /// <param name="dbName"></param>
        /// <param name="projectID"></param>
        /// <returns></returns>
        private static Tuple <string, bool> Export(string dbName, string projectID)
        {
            string DbPath = string.Empty;
            bool   result;
            string dataSource    = MemDBEngin.DbSource;
            string objDataSource = System.IO.Path.Combine(dataSource, dbName + "_" + projectID);

            //在此路径下写入标记文件,如果文件存在表示曾经导出了数据包但是上传导入没有成功,需要再次上传和导入,本次不导出。
            //考虑合并没有上传完成的内存数据库数据
            using (MemDB mem = MemDBEngin.GetDB(objDataSource))
            {
                result = ExportData(mem, dbName, projectID);
                Console.WriteLine("数据源{0} 导出数据完成,结果:{1}", dbName, result);
                DbPath = mem.Path;
            }
            return(new Tuple <string, bool>(DbPath, result));
        }