コード例 #1
0
        public static IEnumerable <SubscribeMessage> LoadMessages(MessageQueryFilter filter, out int totalCount)
        {
            var sql = DataCommandHelper.GetDataCommandSql("LoadMessages", out string connectionString);

            using (IDbConnection conn = MysqlFactory.CreateConnection(connectionString))
            {
                string whereStr = "WHERE 1 = 1";
                if (!string.IsNullOrWhiteSpace(filter.Topic))
                {
                    whereStr += " AND `subscribemessage`.`Topic`=@Topic";
                }
                if (!string.IsNullOrWhiteSpace(filter.ReferenceIdentifier))
                {
                    whereStr += " AND `message`.`ReferenceIdentifier`=@ReferenceIdentifier";
                }
                if (filter.CreateDateFrom.HasValue)
                {
                    whereStr += " AND `message`.`CreateDate`>=@CreateDateFrom";
                }
                if (filter.CreateDateTo.HasValue)
                {
                    whereStr += " AND `message`.`CreateDate`<@CreateDateTo";
                }
                whereStr += " Order By `message`.`CreateDate` DESC";
                sql       = sql.Replace("#StrWhere#", whereStr);
                var result   = conn.QueryMultiple(sql, filter);
                var messages = result.Read <SubscribeMessage>();
                totalCount = result.ReadFirstOrDefault <int>();
                return(messages);
            }
        }
コード例 #2
0
        public static void CreateProcessFailRecord(ProcessFailRecord record)
        {
            var sql = DataCommandHelper.GetDataCommandSql("CreateProcessFailRecord", out string connectionString);

            using (IDbConnection conn = MysqlFactory.CreateConnection(connectionString))
            {
                conn.Execute(sql, record);
            }
        }
コード例 #3
0
        public static void UpdateMessageStatusToSuccess(Guid messageId, string topic, long milliseconds)
        {
            var sql = DataCommandHelper.GetDataCommandSql("UpdateMessageStatusToSuccess", out string connectionString);

            using (IDbConnection conn = MysqlFactory.CreateConnection(connectionString))
            {
                conn.Execute(sql, new { MessageId = messageId, Topic = topic, TimePeriod = milliseconds });
            }
        }
コード例 #4
0
        public static void UpdateMessageStatusToFail(Guid messageId, string topic)
        {
            var sql = DataCommandHelper.GetDataCommandSql("UpdateMessageStatusToFail", out string connectionString);

            using (IDbConnection conn = MysqlFactory.CreateConnection(connectionString))
            {
                conn.Execute(sql, new { MessageId = messageId, Topic = topic });
            }
        }
コード例 #5
0
        public static void UpdateMessageStatusToPrepared(Guid messageId)
        {
            var sql = DataCommandHelper.GetDataCommandSql("UpdateMessageStatusToPrepared", out string connectionString);

            using (IDbConnection conn = MysqlFactory.CreateConnection(connectionString))
            {
                conn.Execute(sql, new { MessageId = messageId });
            }
        }
コード例 #6
0
        public static bool ExistsMessage(string hashFingerprint)
        {
            var sql = DataCommandHelper.GetDataCommandSql("ExistsMessage", out string connectionString);

            using (IDbConnection conn = MysqlFactory.CreateConnection(connectionString))
            {
                return(conn.ExecuteScalar <bool>(sql, new { HashFingerprint = hashFingerprint }));
            }
        }
コード例 #7
0
        public static IEnumerable <ProcessFailRecord> LoadProcessFailRecords(Guid messageId)
        {
            var sql = DataCommandHelper.GetDataCommandSql("LoadProcessFailRecords", out string connectionString);

            using (IDbConnection conn = MysqlFactory.CreateConnection(connectionString))
            {
                return(conn.Query <ProcessFailRecord>(sql, new { MessageId = messageId }));
            }
        }
コード例 #8
0
ファイル: AppDA.cs プロジェクト: yangjipeng/HPMessageCenter
        public static void CreateApp(App app)
        {
            var sql = DataCommandHelper.GetDataCommandSql("CreateApp", out string connectionString);

            using (IDbConnection conn = MysqlFactory.CreateConnection(connectionString))
            {
                conn.Execute(sql, app);
            }
        }
コード例 #9
0
ファイル: AppDA.cs プロジェクト: yangjipeng/HPMessageCenter
        public static bool ExistsApp(string appId)
        {
            var sql = DataCommandHelper.GetDataCommandSql("ExistsApp", out string connectionString);

            using (IDbConnection conn = MysqlFactory.CreateConnection(connectionString))
            {
                return(conn.ExecuteScalar <bool>(sql, new { AppID = appId }));
            }
        }
コード例 #10
0
        public static IEnumerable <Topic> LoadTopics()
        {
            var sql = DataCommandHelper.GetDataCommandSql("LoadTopics", out string connectionString);

            using (IDbConnection conn = MysqlFactory.CreateConnection(connectionString))
            {
                return(conn.Query <Topic>(sql));
            }
        }
コード例 #11
0
        /// <summary>
        /// 获取单位时间内发布失败的消息,单位小时
        /// </summary>
        /// <param name="publishReloadTimeSpan"></param>
        /// <returns></returns>
        public static IEnumerable <Message> LoadPublishFailedMessage(int publishReloadTimeSpan)
        {
            var sql = DataCommandHelper.GetDataCommandSql("LoadPublishFailedMessage", out string connectionString);

            using (IDbConnection conn = MysqlFactory.CreateConnection(connectionString))
            {
                return(conn.Query <Message>(sql, new { PublishReloadTimeSpan = publishReloadTimeSpan }));
            }
        }
コード例 #12
0
        public static Topic LoadTopicBySysNo(int sysno)
        {
            var sql = DataCommandHelper.GetDataCommandSql("LoadTopicBySysNo", out string connectionString);

            using (IDbConnection conn = MysqlFactory.CreateConnection(connectionString))
            {
                return(conn.QueryFirstOrDefault <Topic>(sql, new { SysNo = sysno }));
            }
        }
コード例 #13
0
        public static Topic LoadTopicByTopicName(string name)
        {
            var sql = DataCommandHelper.GetDataCommandSql("LoadTopicByTopicName", out string connectionString);

            using (IDbConnection conn = MysqlFactory.CreateConnection(connectionString))
            {
                return(conn.QueryFirstOrDefault <Topic>(sql, new { Name = name }));
            }
        }
コード例 #14
0
        public static bool ExistsTopic(string topic)
        {
            var sql = DataCommandHelper.GetDataCommandSql("ExistsTopic", out string connectionString);

            using (IDbConnection conn = MysqlFactory.CreateConnection(connectionString))
            {
                return(conn.ExecuteScalar <bool>(sql, new { Name = topic }));
            }
        }
コード例 #15
0
        public static void EditTopic(Topic topic)
        {
            var sql = DataCommandHelper.GetDataCommandSql("EditTopic", out string connectionString);

            using (IDbConnection conn = MysqlFactory.CreateConnection(connectionString))
            {
                conn.Execute(sql, topic);
            }
        }
コード例 #16
0
        public static void UpdateTopicStatusToInValid(int sysno)
        {
            var sql = DataCommandHelper.GetDataCommandSql("UpdateTopicStatusToInValid", out string connectionString);

            using (IDbConnection conn = MysqlFactory.CreateConnection(connectionString))
            {
                conn.Execute(sql, new { SysNo = sysno });
            }
        }
コード例 #17
0
        public static void CreateExchange(Exchange exchange)
        {
            var sql = DataCommandHelper.GetDataCommandSql("CreateExchange", out string connectionString);

            using (IDbConnection conn = MysqlFactory.CreateConnection(connectionString))
            {
                conn.Execute(sql, exchange);
            }
        }
コード例 #18
0
        public static void RemoveServerNode(string server)
        {
            var sql = DataCommandHelper.GetDataCommandSql("RemoveServerNode", out string connectionString);

            using (IDbConnection conn = MysqlFactory.CreateConnection(connectionString))
            {
                conn.Execute(sql, new { ServerHost = server });
            }
        }
コード例 #19
0
        public static bool ExistsServer(string server)
        {
            var sql = DataCommandHelper.GetDataCommandSql("ExistsServer", out string connectionString);

            using (IDbConnection conn = MysqlFactory.CreateConnection(connectionString))
            {
                return(conn.ExecuteScalar <bool>(sql, new { ServerHost = server }));
            }
        }
コード例 #20
0
        public static SubscribeMessage LoadMessage(Guid messageId, string topic)
        {
            var sql = DataCommandHelper.GetDataCommandSql("LoadMessage", out string connectionString);

            using (IDbConnection conn = MysqlFactory.CreateConnection(connectionString))
            {
                var result  = conn.QueryMultiple(sql, new { MessageId = messageId, Topic = topic });
                var message = result.ReadFirstOrDefault <SubscribeMessage>();
                message.ProcessFailRecords = result.Read <ProcessFailRecord>().AsList();
                return(message);
            }
        }