Пример #1
0
        internal bool UpdateStatus(string code, FailMqMessageStatus status, int count = 0)
        {
            DataCenterHelper dataCenter = new DataCenterHelper();
            var paramList = new List <SqlParameter> {
                new SqlParameter()
                {
                    ParameterName = "@status", Value = (int)status, SqlDbType = System.Data.SqlDbType.Int
                },
                new SqlParameter()
                {
                    ParameterName = "@code", Value = code, SqlDbType = System.Data.SqlDbType.VarChar, Size = 36
                },
            };

            if (count == 0)
            {
                return(dataCenter.ExecuteNonQuery("UPDATE FailMqMessage SET STATUS=@status,UpdateTime=GetDate() WHERE Code = @code", paramList.ToArray()));
            }
            else
            {
                paramList.Add(new SqlParameter()
                {
                    ParameterName = "@RetryNumber", Value = count, SqlDbType = System.Data.SqlDbType.Int
                });
                return(dataCenter.ExecuteNonQuery("UPDATE FailMqMessage SET STATUS=@status,UpdateTime=GetDate(),RetryNumber=RetryNumber+@RetryNumber WHERE Code = @code", paramList.ToArray()));
            }
        }
Пример #2
0
        internal List <FailMqMessageModel> GetFailMqMessageModels(int topTotal, FailMqMessageStatus status)
        {
            DataTable dt = new DataTable();

            using (SqlConnection connection = new SqlConnection(ConnectionString))
            {
                string commandText = "select top(@total) [Code],[MessageContext],[ApiUrl],[RetryNumber],[Status],[CreateTime],[UpdateTime] from FailMqMessage where Status = @status order by Code";
                using (SqlCommand command = new SqlCommand(commandText, connection))
                {
                    command.Parameters.Add(new SqlParameter()
                    {
                        ParameterName = "@status",
                        SqlDbType     = SqlDbType.Int,
                        Size          = 4,
                        Value         = status
                    });
                    command.Parameters.Add(new SqlParameter()
                    {
                        ParameterName = "@total",
                        SqlDbType     = SqlDbType.Int,
                        Size          = 4,
                        Value         = topTotal
                    });
                    using (SqlDataAdapter sda = new SqlDataAdapter(command))
                    {
                        sda.Fill(dt);
                    }
                }
            }
            List <FailMqMessageModel> models = new List <FailMqMessageModel>();

            foreach (DataRow row in dt.Rows)
            {
                models.Add(ToFailMqMessageModel(row));
            }
            return(models);
        }