Example #1
0
        public bool SaveSetting(GameSetting setting)
        {
            if (this.ReadDB.Exists <GameSetting>(t => t.Code == setting.Code && t.ID != setting.ID))
            {
                return(this.FaildMessage("代码重复"));
            }
            using (DbExecutor db = NewExecutor(IsolationLevel.ReadUncommitted))
            {
                if (db.Exists <GameSetting>(t => t.ID == setting.ID))
                {
                    db.Update(setting);
                }
                else
                {
                    db.InsertIdentity(setting);

                    //保存游戏时默认开启所有商户该游戏
                    IEnumerable <Site> list = ReadDB.ReadList <Site>();
                    foreach (Site site in list)
                    {
                        SiteGameSetting siteGameSetting = new SiteGameSetting()
                        {
                            SiteID = site.ID,
                            GameID = setting.ID,
                            Status = SiteGameSetting.SiteGameStatus.Open
                        };

                        siteGameSetting.Add(db);
                    }
                }

                db.Commit();
            }
            return(this.AccountInfo.Log(LogType.Setting, $"保存游戏设置:{setting.Name}"));
        }
Example #2
0
        /// <summary>
        /// 加载游戏配置
        /// </summary>
        public bool LoadSiteGameSetting(int siteId)
        {
            using (DbExecutor db = NewExecutor(IsolationLevel.ReadUncommitted))
            {
                IEnumerable <GameSetting> list = ReadDB.ReadList <GameSetting>(t => t.Status != GameStatus.Close);

                foreach (GameSetting gameSetting in list)
                {
                    if (this.ReadDB.Exists <SiteGameSetting>(t => t.SiteID == siteId && t.GameID == gameSetting.ID))
                    {
                        continue;
                    }
                    SiteGameSetting siteGameSetting = new SiteGameSetting()
                    {
                        SiteID = siteId,
                        GameID = gameSetting.ID,
                        Status = SiteGameStatus.Open
                    };

                    siteGameSetting.Add(db);
                }

                db.Commit();
            }

            return(this.AccountInfo.Log(SystemAdminLog.LogType.Site, $"加载商户游戏配置成功{siteId}"));
        }