Exemplo n.º 1
0
        public void SetUp()
        {
            sqLiteDbAccessor = new SQLiteDbAccessor(Connstr);
            var loadxml = new LoadDbConfigXml(Xmlpath);

            sqLiteDbAccessor.UpdateTables(loadxml.GetTableMaps());
        }
Exemplo n.º 2
0
        public void SetUp()
        {
            msDbAccessor = new MsDbAccessor(Connstr);
            var loadxml = new LoadDbConfigXml(Xmlpath);

            msDbAccessor.UpdateTables(loadxml.GeTableInfos());
        }
Exemplo n.º 3
0
 public void TestLoadDbConfigXml()
 {
     try
     {
         var loadDbConfig = new LoadDbConfigXml(string.Empty);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         Assert.AreEqual(" is not exist !", ex.Message);
     }
 }
Exemplo n.º 4
0
 public void msDbAccessorTest()
 {
     try
     {
         MsDbAccessor msDbAccessor = new MsDbAccessor(Connstr);
         var          loadxml      = new LoadDbConfigXml(string.Empty);
         msDbAccessor.UpdateTables(loadxml.GeTableInfos());
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         Assert.True(true);
     }
 }
Exemplo n.º 5
0
        public void Init(Dictionary <string, string> args)
        {
            if (_initialized)
            {
                return;
            }
            _initialized = true;
            string dbMapFile = args["dbcongxml"];

            Log.DebugFormat("Loading mapping from {0}", dbMapFile);
            var ldcx = new LoadDbConfigXml(dbMapFile);

            DataSourseTableInfo[] tableInfos = ldcx.GetDataSourseTableInfo("/config/databases");
            this.DoUpdateAsNecessary(tableInfos);
        }
        public void TestHasMoreData()
        {
            DbDacDataProvider           p    = new DbDacDataProvider();
            Dictionary <string, string> args = new Dictionary <string, string>();

            args.Add("sqlitedbcongxml", this.path);
            p.Init_Sqlite(args);
            // 5.
            // var cs = connstr.Split(',');
            LoadDbConfigXml lc = new LoadDbConfigXml(this.path);

            string[] sonstr = lc.GetSqlConnectionStrings("/config/databases");

            ISqlHelper sqlHelper = SqlHelperFactory.Create(DbType.SQLite, sonstr[0]);

            sqlHelper.Query("update D_OriginalWindData set lastSyncTime = null");

            Assert.IsTrue(p.HasMoreData());
            Console.WriteLine("TotalReminder: {0} records.", p.Remainder);
            Assert.IsTrue(p.Remainder > 0);

            int len = 0;

            TranMsg[] msgs = p.NextPackages(out len);
            Assert.IsNotNull(msgs);
            byte[] buff = msgs[0].Data;
            Console.WriteLine(ValueHelper.BytesToHexStr(buff, 0, len, ""));
            // Record 4.
            Assert.IsTrue(len > 0);

            // Data Sent
            p.OnPackageSent();

            var ds =
                sqlHelper.Query("select count(ID) from D_OriginalWindData where lastSyncTime is null");

            Assert.AreEqual(0, Convert.ToInt32(ds.Tables[0].Rows[0][0]));
        }
Exemplo n.º 7
0
        /// <summary>
        /// 统一采集软件
        /// </summary>
        /// <param name="args"></param>
        public void Init_Sqlite(Dictionary <string, string> args)
        {
            if (_initialized)
            {
                return;
            }
            _initialized = true;
            string dbMapFile = args["sqlitedbcongxml"];

            Log.DebugFormat("Loading mapping from {0}", dbMapFile);
            var ldcx = new LoadDbConfigXml(dbMapFile);

            string[] connStrs = ldcx.GetSqlConnectionStrings("/config/databases");
            if (connStrs == null || connStrs.Length == 0)
            {
                return;
            }

            sqlHelper = SqlHelperFactory.Create(DbType.SQLite, connStrs[0]);
            //DbAccessorHelper.Init(new SQLiteDbAccessor(connStrs[0]));
            DataSourseTableInfo[] tableInfos = ldcx.GetDataSourseTableInfo("/config/databases");
            this.DoUpdateAsNecessary_Sqlite(tableInfos);
        }
Exemplo n.º 8
0
        public void TestLoadDbConfigxml()
        {
            var ldcx = new LoadDbConfigXml(this.path);

            DataSourseTableInfo[] tables = ldcx.GetDataSourseTableInfo("/config/databases");
            if (tables.Length != 1)
            {
                Assert.Fail();
                return;
            }
            Assert.AreEqual(tables[0].DataBaseName, "DW_iSecureCloud_Empty");
            Assert.AreEqual(tables[0].DbType, DbType.MSSQL);
            string connectionString =
                "Initial Catalog=DW_iSecureCloud_Empty;Data Source=192.168.1.128;User Id=sa;Password=861004";

            Assert.AreEqual(tables[0].ConnectionString, connectionString);
            Assert.AreEqual(tables[0].TableName, "T_THEMES_ENVI_WIND");
            Assert.AreEqual(tables[0].Type, ProtocolType.GPS_ZHD);
            Assert.AreEqual(tables[0].Colums.Length, 6);
            if (tables[0].Colums.Length == 6)
            {
                Assert.AreEqual(tables[0].Colums[0], "ID");
                Assert.AreEqual(tables[0].StandardFields[0], "ID");
                Assert.AreEqual(tables[0].Colums[1], "SENSOR_ID");
                Assert.AreEqual(tables[0].StandardFields[1], "SID");
                Assert.AreEqual(tables[0].Colums[2], "ACQUISITION_DATETIME");
                Assert.AreEqual(tables[0].StandardFields[2], "AcqTime");
                Assert.AreEqual(tables[0].Colums[3], "WIND_SPEED_VALUE");
                Assert.AreEqual(tables[0].StandardFields[3], "Value1");
                Assert.AreEqual(tables[0].Colums[4], "WIND_DIRECTION_VALUE");
                Assert.AreEqual(tables[0].StandardFields[4], "Value2");
                Assert.AreEqual(tables[0].Colums[5], "WIND_ELEVATION_VALUE");
                Assert.AreEqual(tables[0].StandardFields[5], "Value3");
            }
            Assert.AreEqual(tables[0].DataCount, 3);
            Assert.AreEqual(tables[0].Filter, "where lastSyncTime is null");
        }
Exemplo n.º 9
0
 public void LoadXml()
 {
     loadxml = new LoadDbConfigXml(path);
 }
Exemplo n.º 10
0
 public void LoadXml()
 {
     this.loadxml = new LoadDbConfigXml(this.path);
 }