Exemple #1
0
    protected override void Awake()
    {
        base.Awake();
        if (Instance == null)
        {
            Instance = this;
        }

        Statics.Pools[(int)Statics.KnownPools.BONUS] = Instance;
    }
Exemple #2
0
        /// <summary>
        /// 奖金池录入
        /// </summary>
        /// <param name="gameName"></param>
        /// <param name="info"></param>
        /// <returns></returns>
        public bool BonusPoolStart(string gameName, OpenDataInfo info)
        {
            bool         bol       = true;
            string       tablename = Lottery.CrawGetters.InitConfigInfo.MongoSettings["BonusPoolTableName"].ToString();
            string       content   = KaSon.FrameWork.Common.JSON.JsonHelper.Serialize(info);
            BsonDocument bson      = new BsonDocument();

            bson.Add("GameCode", info.GameCode);
            bson.Add("IssuseNumber", info.IssuseNumber);
            bson.Add("Content", content);
            //  new BsonDocument { { "GameCode", info.GameCode }, { "Age", 20 } }
            var fileName = string.Format("{0}_{1}.json", info.GameCode, info.IssuseNumber);
            //  this.WriteLog(string.Format("已成功采集到{0}第{1}期奖池数据,开始写入文件{2}", info.GameCode, info.IssuseNumber, fileName));
            var coll = mDB.GetCollection <BsonDocument>(tablename);
            //var options = new UpdateOptions { IsUpsert = true };
            var mFilter = MongoDB.Driver.Builders <MongoDB.Bson.BsonDocument> .Filter.Eq("GameCode", info.GameCode) & Builders <BsonDocument> .Filter.Eq("IssuseNumber", info.IssuseNumber);

            // var mUpdateDocument =Builders<MongoDB.Bson.BsonDocument>.Update.Set("Content", content);

            var count = coll.Find(mFilter).CountDocuments();

            try
            {
                if (count > 0)
                {
                    //Thread.Sleep(2000);
                }
                else
                {
                    coll.DeleteMany(mFilter);
                    coll.InsertOne(bson);
                }
                try
                {
                    BonusPoolManager bm = new BonusPoolManager(content);
                    bm.UpdateBonusPool_SZC(info.GameCode, info.IssuseNumber);
                }
                catch (Exception)
                {
                    bol = false;
                }
            }
            catch (Exception)
            {
                bol = false;
            }



            return(bol);
        }