Пример #1
0
        public static void LoadMarker()
        {
            IDBHelper dBHelper = new DBHelperMySQL("", Program.Settings.DNALims);
            string    marker   = "select locus_type,locus_name,national_locus_name,alias,ord from locus_info  order by locus_type, ord";
            DataTable dtMarker = dBHelper.getDataTable(marker);

            if (dtMarker != null && dtMarker.Rows.Count > 0)
            {
                Marker = dtMarker;
            }
            dBHelper.closeConn();
        }
Пример #2
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;
            }
        }
Пример #3
0
        private static void DBSync(int minId, int maxId)
        {
            IDBHelper dBHelper = new DBHelperMySQL("", Program.Settings.DNALims);

            try
            {
                string sql    = $"SELECT * from comparedatatask where id BETWEEN {minId} and {maxId}  and ex8=0  and `type`=0 order by updatetime desc,`level`";
                var    dtGene = dBHelper.getDataTable(sql);
                if (dtGene != null && dtGene.Rows.Count > 0)
                {
                    for (int i = 0; i < dtGene.Rows.Count; i++)
                    {
                        var status      = Convert.ToInt32(dtGene.Rows[i]["status"]);
                        var id          = dtGene.Rows[i]["id"].ToString();
                        var geneIndexid = dtGene.Rows[i]["geneindexid"].ToString();
                        var server      = dtGene.Rows[i]["server"].ToString();

                        if (status == 1)
                        {
                            Console.WriteLine($"接收到删除数据 compare:{id}  {DateTime.Now}");
                            DeleteGeno(dBHelper, id, geneIndexid, server);
                        }
                        else if (status == 0 || status == 2)
                        {
                            Console.WriteLine($"接收到新增数据 compare:{id}  {DateTime.Now}");
                            AddGeno(dBHelper, id, geneIndexid, server);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                dBHelper.closeConn();
            }
        }