Example #1
0
        private static void AddGeno(IDBHelper dBHelper, string id, string geneIndexid, string server)
        {
            string sqlindex = @"select g.id,g.server,g.idsampling,g.idper  from geneindex g,sampling s,per p,commitment c  
                                    where g.idsampling<> 0 and g.idper<> 0 and s.perid<> 0 and s.commitid<> 0 and p.category<>98 
                                    and g.deleted = 0 and p.deleted = 0 and c.deleted = 0 and s.deleted = 0 
                                    and c.`server`= g.`server` and p.`server`= g.`server`and s.`server`= g.`server` 
                                    and s.perid = p.id and s.id = g.idsampling and c.id = s.commitid and g.id='" + geneIndexid + "' and g.`server`='" + server + "'";
            var    dtIndex  = dBHelper.getDataTable(sqlindex);

            if (dtIndex.Rows.Count > 0)
            {
                //log.Log($"获取基因信息成功 compareId:{id} server:{server} 开始同步");
                for (int k = 0; k < dtIndex.Rows.Count; k++)
                {
                    var sampId = dtIndex.Rows[k]["idsampling"].ToString();
                    var perId  = dtIndex.Rows[k]["idper"].ToString();

                    string sqlType    = "select * from genotype where id =" + geneIndexid + " and `server`=" + server;
                    var    limsGenedt = dBHelper.getDataTable(sqlType);
                    var    drList     = limsGenedt.Select("id=" + geneIndexid + " and server=" + server);

                    //添加进mongo
                    GenoWork.GetGeneInfo(null, null, SyncManage.Marker, drList, 1, 0, perId, sampId);

                    string updSql = "UPDATE comparedatatask SET  `ex8` = 1 WHERE `id` = " + id + " AND `server` = " + server + ";";
                    dBHelper.execSql(updSql);
                    Console.WriteLine($"{id} 同步成功");
                }
            }
            else
            {
                Console.WriteLine($"{id} 为脏数据");
                //脏数据
                string updSql = "UPDATE comparedatatask SET  `ex8` = 3 WHERE `id` = " + id + " AND `server` = " + server + ";";
                dBHelper.execSql(updSql);
            }
        }
Example #2
0
        private static void CacheSync_Family(string table, short key)
        {
            IMongoDatabase mongobase  = MongoDBHelper.createMongoConnection(DBConfig.ConnectionString, DBConfig.LDBNAME);
            string         LDBCNAME   = table + "_" + key;
            var            collection = mongobase.GetCollection <BsonDocument>(LDBCNAME);

            //TODO:测试不减8小时
            //var maxTime = DateTime.MinValue;
            //var time = GenoItems_Family[key].ISODateTime;
            //maxTime = time != DateTime.MinValue ? time.AddHours(-8) : DateTime.MinValue;
            var maxTime = DateTime.MinValue;
            var time    = Program.GenoItems_Family[key].ISODateTime;

            maxTime = time != DateTime.MinValue ? time.AddHours(-8) : DateTime.MinValue;
            var bsonList = collection
                           .Find(Builders <BsonDocument> .Filter.And(Builders <BsonDocument> .Filter.Gte("ISODATE", maxTime))).ToList();

            Program.wrls.EnterReadLock();
            foreach (var item in bsonList)
            {
                try
                {
                    string guid = item.GetValue("_id").AsString;
                    string id   = item.GetValue("PERID").AsString;
                    if (Convert.ToInt32(item.GetValue("DELETE_FLAG")) == 1)
                    {
                        //    lock (DeleteFamilyList)
                        //    {
                        //        Dictionary<string, string> dict = new Dictionary<string, string>();
                        //        dict["_id"] = guid;
                        //        dict["GENEID"] = id.Split(":")[0];
                        //        dict["SERVER"] = id.Split(":")[1];
                        //        dict["TYPE"] = item.GetValue("DICTTYPE").AsString;
                        //        dict["MONGOINDEX"] = item.GetValue("MONGOINDEX").AsString;
                        //        DeleteFamilyList.Add(dict);
                        //    }
                        continue;
                    }
                    List <GenoPer> genoPerls = new List <GenoPer>();
                    BsonDocument   bsonRelF;
                    BsonDocument   bsonRelM;
                    BsonDocument   bsonRelC;

                    BsonValue dictType    = item.GetValue("DICTTYPE");
                    short     mongoIndex  = Convert.ToInt16(item.GetValue("MONGOINDEX"));
                    DateTime  isoDateTime = Convert.ToDateTime(item.GetValue("ISODATE").AsBsonDateTime);
                    //TODO:稍后提取通用方法
                    GenoPer gp = new GenoPer();
                    switch (dictType.AsInt32)
                    {
                    case 0:
                        gp.GenoFather = GenoWork.SetGenoRel(item["F"].AsBsonDocument);
                        gp.GenoChild  = GenoWork.SetGenoRel(item["C"].AsBsonDocument);
                        genoPerls.Add(gp);

                        Program.GenoItems_Family[mongoIndex].DictFAC[id] = genoPerls;
                        Program.GenoItems_Family[mongoIndex].ISODateTime = isoDateTime;
                        break;

                    case 1:
                        gp.GenoMother = GenoWork.SetGenoRel(item["M"].AsBsonDocument);
                        gp.GenoChild  = GenoWork.SetGenoRel(item["C"].AsBsonDocument);
                        genoPerls.Add(gp);

                        Program.GenoItems_Family[mongoIndex].DictMAC[id] = genoPerls;
                        Program.GenoItems_Family[mongoIndex].ISODateTime = isoDateTime;
                        break;

                    case 2:
                        gp.GenoFather = GenoWork.SetGenoRel(item["F"].AsBsonDocument);
                        gp.GenoMother = GenoWork.SetGenoRel(item["M"].AsBsonDocument);
                        genoPerls.Add(gp);

                        Program.GenoItems_Family[mongoIndex].DictFAM[id] = genoPerls;
                        Program.GenoItems_Family[mongoIndex].ISODateTime = isoDateTime;
                        break;
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
            Program.wrls.ExitReadLock();
        }