예제 #1
0
        public static void DBSyncManage()
        {
            if (SyncManage.sync_status_db_str == STATUS.Initing)
            {
                return;
            }
            SyncManage.sync_status_db_str = STATUS.Initing;

            //验证位点
            if (SyncManage.Marker == null || SyncManage.Marker.Rows.Count <= 0)
            {
                SyncManage.LoadMarker();
            }
            IDBHelper dBHelper = new DBHelperMySQL("", Program.Settings.DNALims);

            try
            {
                //分页同步
                //状态,默认0 插入,1 删除,2 更新
                string maxIdSql = "SELECT max(id) FROM `comparedatatask` where ex8=0  and `type`=0 order by updatetime desc,`level`";
                var    maxId    = dBHelper.execScalar(maxIdSql);
                if (maxId.Equals(DBNull.Value))
                {
                    SyncManage.sync_status_db_str = STATUS.Exiting;
                    return;
                }

                string minIdSql = "select min(id) from comparedatatask where ex8=0  and `type`=0 order by updatetime desc,`level`";
                var    minId    = dBHelper.execScalar(minIdSql);
                if (minId.Equals(DBNull.Value))
                {
                    minId = 0;
                }

                DBSync(Convert.ToInt32(minId), Convert.ToInt32(maxId));
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                dBHelper.closeConn();
                SyncManage.sync_status_db_str = STATUS.Exiting;
            }
        }