Ejemplo n.º 1
0
 /// <summary>
 /// 在接受到群消息时使用
 /// </summary>
 /// <param name="sender">sender object</param>
 /// <param name="eventArgs">CQAppEnableEventArgs类</param>
 public SuiseiDBHelper(object sender, CQGroupMessageEventArgs eventArgs)
 {
     this.QQID    = eventArgs.FromQQ.Id;
     this.GroupId = eventArgs.FromGroup.Id;
     this.Sender  = sender;
     this.SuiseiGroupMessageEventArgs = eventArgs;
     this.TriggerTime = Utils.GetTodayStamp();//触发日期
     DBPath           = SugarUtils.GetDBPath(eventArgs.CQApi.GetLoginQQ().Id.ToString());
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 初始化数据库
        /// </summary>
        /// <param name="eventArgs">CQAppEnableEventArgs</param>
        public static void Init(ConnectEventArgs eventArgs)
        {
            string DBPath = SugarUtils.GetDBPath(eventArgs.LoginUid.ToString());

            ConsoleLog.Debug("IO", $"获取数据路径{DBPath}");
            if (!File.Exists(DBPath))//查找数据文件
            {
                //数据库文件不存在,新建数据库
                ConsoleLog.Warning("数据库初始化", "未找到数据库文件,创建新的数据库");
                Directory.CreateDirectory(Path.GetPathRoot(DBPath) ?? String.Empty);
                File.Create(DBPath).Close();
            }
            SqlSugarClient dbClient = new SqlSugarClient(new ConnectionConfig()
            {
                ConnectionString      = $"DATA SOURCE={DBPath}",
                DbType                = DbType.Sqlite,
                IsAutoCloseConnection = true,
                InitKeyType           = InitKeyType.Attribute
            });

            try
            {
                if (!SugarUtils.TableExists <SuiseiData>(dbClient)) //彗酱数据库初始化
                {
                    ConsoleLog.Warning("数据库初始化", "未找到慧酱数据表 - 创建一个新表");
                    SugarUtils.CreateTable <SuiseiData>(dbClient);
                }
                if (!SugarUtils.TableExists <MemberInfo>(dbClient)) //成员状态表的初始化
                {
                    ConsoleLog.Warning("数据库初始化", "未找到成员状态表 - 创建一个新表");
                    SugarUtils.CreateTable <MemberInfo>(dbClient);
                }
                if (!SugarUtils.TableExists <BiliSubscription>(dbClient)) //动态记录表的初始化
                {
                    ConsoleLog.Warning("数据库初始化", "未找到动态记录表 - 创建一个新表");
                    SugarUtils.CreateTable <BiliSubscription>(dbClient);
                }
                if (!SugarUtils.TableExists <GuildBattleBoss>(dbClient)) //会战数据表的初始化
                {
                    ConsoleLog.Warning("数据库初始化", "未找到会战数据表 - 创建一个新表");
                    SugarUtils.CreateTable <GuildBattleBoss>(dbClient);
                    //写入初始化数据
                    dbClient.Insertable(GuildBattleBoss.GetInitBossInfos()).ExecuteCommand();
                }
                if (!SugarUtils.TableExists <GuildInfo>(dbClient)) //会战状态表的初始化
                {
                    ConsoleLog.Warning("数据库初始化", "未找到会战状态表 - 创建一个新表");
                    SugarUtils.CreateTable <GuildInfo>(dbClient);
                }
            }
            catch (Exception exception)
            {
                ConsoleLog.Fatal("数据库初始化错误", ConsoleLog.ErrorLogBuilder(exception));
                Thread.Sleep(5000);
                throw;
            }
        }
Ejemplo n.º 3
0
        private static string DBPath;                                              //数据库路径

        #endregion

        #region 构造函数

        /// <summary>
        /// 在接受到群消息时使用
        /// </summary>
        /// <param name="sender">sender object</param>
        /// <param name="eventArgs">CQAppEnableEventArgs类</param>
        /// <param name="time">触发时间</param>
        public GuildManagerDBHelper(object sender, CQGroupMessageEventArgs eventArgs)
        {
            this.QQID      = eventArgs.FromQQ.Id;
            this.GroupId   = eventArgs.FromGroup.Id;
            this.Sender    = sender;
            this.EventArgs = eventArgs;
            GuildId        = new string[] //公会信息
            {
                GroupId.ToString(),       //公会所在群号
            };
            DBPath = SugarUtils.GetDBPath(eventArgs.CQApi.GetLoginQQ().Id.ToString());
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 初始化数据库
        /// </summary>
        /// <param name="e">CQAppEnableEventArgs</param>
        public static void Init(CQAppEnableEventArgs e)
        {
            string DBPath = SugarUtils.GetDBPath(e.CQApi.GetLoginQQ().Id.ToString());

            ConsoleLog.Info("IO", $"获取数据路径{DBPath}");
            if (!File.Exists(DBPath))//查找数据文件
            {
                //数据库文件不存在,新建数据库
                ConsoleLog.Warning("数据库初始化", "未找到数据库文件,创建新的数据库");
                Directory.CreateDirectory(Path.GetPathRoot(DBPath));
                File.Create(DBPath).Close();
            }
            SqlSugarClient dbClient = new SqlSugarClient(new ConnectionConfig()
            {
                ConnectionString      = $"DATA SOURCE={DBPath}",
                DbType                = DbType.Sqlite,
                IsAutoCloseConnection = true,
                InitKeyType           = InitKeyType.Attribute
            });

            if (!SugarUtils.TableExists <SuiseiData>(dbClient)) //彗酱数据库初始化
            {
                ConsoleLog.Warning("数据库初始化", "未找到慧酱数据表 - 创建一个新表");
                SugarUtils.CreateTable <SuiseiData>(dbClient);
            }
            if (!SugarUtils.TableExists <GuildData>(dbClient)) //公会数据库初始化
            {
                ConsoleLog.Warning("数据库初始化", "未找到公会表数据表 - 创建一个新表");
                SugarUtils.CreateTable <GuildData>(dbClient);
            }
            if (!SugarUtils.TableExists <MemberData>(dbClient)) //公会成员数据库初始化
            {
                ConsoleLog.Warning("数据库初始化", "未找到成员表数据表 - 创建一个新表");
                SugarUtils.CreateTable <MemberData>(dbClient);
            }
            if (!SugarUtils.TableExists <MemberStatus>(dbClient))//成员状态表的初始化
            {
                ConsoleLog.Warning("数据库初始化", "未找到成员状态表 - 创建一个新表");
                SugarUtils.CreateTable <MemberStatus>(dbClient);
            }
            if (!SugarUtils.TableExists <BossInfo>(dbClient))//Boss信息表的初始化
            {
                ConsoleLog.Warning("数据库初始化", "未找到Boss信息表 - 创建一个新表");
                SugarUtils.CreateTable <BossInfo>(dbClient);
            }
            if (!SugarUtils.TableExists <BiliSubscription>(dbClient)) //动态记录表的初始化
            {
                ConsoleLog.Warning("数据库初始化", "未找到动态记录表 - 创建一个新表");
                SugarUtils.CreateTable <BiliSubscription>(dbClient);
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 初始化数据库
        /// </summary>
        /// <param name="eventArgs">CQAppEnableEventArgs</param>
        public static void UserDataInit(ConnectEventArgs eventArgs)
        {
            string DBPath = SugarUtils.GetDBPath(eventArgs.LoginUid.ToString());

            Log.Debug("IO", $"获取用户数据路径{DBPath}");
            //检查文件是否存在
            IOUtils.CheckFileExists(DBPath);
            //创建数据库链接
            SqlSugarClient dbClient = SugarUtils.CreateSqlSugarClient(DBPath);

            try
            {
                if (!SugarUtils.TableExists <MemberInfo>(dbClient)) //成员状态表的初始化
                {
                    Log.Warning("数据库初始化", "未找到成员状态表 - 创建一个新表");
                    SugarUtils.CreateTable <MemberInfo>(dbClient);
                }

                if (!SugarUtils.TableExists <BiliDynamicSubscription>(dbClient)) //动态记录表的初始化
                {
                    Log.Warning("数据库初始化", "未找到动态订阅表 - 创建一个新表");
                    SugarUtils.CreateTable <BiliDynamicSubscription>(dbClient);
                }

                if (!SugarUtils.TableExists <GuildBattleBoss>(dbClient)) //会战数据表的初始化
                {
                    Log.Warning("数据库初始化", "未找到会战数据表 - 创建一个新表");
                    SugarUtils.CreateTable <GuildBattleBoss>(dbClient);
                }

                if (!SugarUtils.TableExists <BiliLiveSubscription>(dbClient))
                {
                    Log.Warning("数据库初始化", "未找到直播订阅表 - 创建一个新表");
                    SugarUtils.CreateTable <BiliLiveSubscription>(dbClient);
                }

                if (!SugarUtils.TableExists <GuildInfo>(dbClient)) //会战状态表的初始化
                {
                    Log.Warning("数据库初始化", "未找到会战状态表 - 创建一个新表");
                    SugarUtils.CreateTable <GuildInfo>(dbClient);
                }
            }
            catch (Exception exception)
            {
                Log.Fatal("数据库初始化错误", Log.ErrorLogBuilder(exception));
                Thread.Sleep(5000);
                Environment.Exit(-1);
            }
        }
Ejemplo n.º 6
0
        private readonly string DBPath; //数据库路径

        #endregion

        #region 构造函数

        public SubscriptionDBHelper(long uid)
        {
            DBPath = SugarUtils.GetDBPath(uid.ToString());
        }
Ejemplo n.º 7
0
 public GuildBattleMgrDBHelper(object sender, CQGroupMessageEventArgs eventArgs)
 {
     GroupId = eventArgs.FromGroup.Id;
     DBPath  = SugarUtils.GetDBPath(eventArgs.CQApi.GetLoginQQ().Id.ToString());
 }
Ejemplo n.º 8
0
 /// <summary>
 /// 在接受到群消息时使用
 /// </summary>
 /// <param name="guildEventArgs">CQAppEnableEventArgs类</param>
 public GuildManagerDBHelper(CQGroupMessageEventArgs guildEventArgs)
 {
     this.GuildEventArgs = guildEventArgs;
     this.DBPath         = SugarUtils.GetDBPath(guildEventArgs.CQApi.GetLoginQQ().Id.ToString());
 }
Ejemplo n.º 9
0
 public GuildBattleMgrDBHelper(CQGroupMessageEventArgs eventArgs)
 {
     GuildEventArgs  = eventArgs;
     DBPath          = SugarUtils.GetDBPath(eventArgs.CQApi.GetLoginQQ().Id.ToString());
     BattleTableName = $"{SugarTableUtils.GetTableName<GuildBattle>()}_{GuildEventArgs.FromGroup.Id}";
 }
Ejemplo n.º 10
0
 /// <summary>
 /// 基类构造函数
 /// </summary>
 /// <param name="eventArgs">群聊事件参数</param>
 protected BaseGuildBattleDBHelper(GroupMessageEventArgs eventArgs)
 {
     GuildEventArgs = eventArgs;
     DBPath         = SugarUtils.GetDBPath(eventArgs.LoginUid.ToString());
 }
 /// <summary>
 /// 基类构造函数
 /// </summary>
 /// <param name="loginUid">登录账号ID</param>
 protected BaseGuildBattleDBHelper(long loginUid)
 {
     DBPath = SugarUtils.GetDBPath(loginUid.ToString());
 }
Ejemplo n.º 12
0
        private readonly string DBPath;//数据库路径
        #endregion

        #region 构造函数
        public SubscriptionDBHelper(CQApi api)
        {
            DBPath = SugarUtils.GetDBPath(api.GetLoginQQ().Id.ToString());
        }