Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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 });
            }
        }
Ejemplo n.º 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 });
            }
        }
Ejemplo n.º 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 });
            }
        }
Ejemplo n.º 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 }));
            }
        }
Ejemplo n.º 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 }));
            }
        }
Ejemplo n.º 8
0
        public static void CreateApp(App app)
        {
            var sql = DataCommandHelper.GetDataCommandSql("CreateApp", out string connectionString);

            using (IDbConnection conn = MysqlFactory.CreateConnection(connectionString))
            {
                conn.Execute(sql, app);
            }
        }
Ejemplo n.º 9
0
        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 }));
            }
        }
Ejemplo n.º 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));
            }
        }
Ejemplo n.º 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 }));
            }
        }
Ejemplo n.º 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 }));
            }
        }
Ejemplo n.º 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 }));
            }
        }
Ejemplo n.º 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 }));
            }
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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 });
            }
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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 });
            }
        }
Ejemplo n.º 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 }));
            }
        }
Ejemplo n.º 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);
            }
        }