public async Task <PersistedCounts> GetPersistedCounts()
        {
            var counts = new PersistedCounts();

            using (var session = _store.QuerySession())
            {
                using (var reader = await session.Connection
                                    .CreateCommand(
                           $"select status, count(*) from {_tables.Incoming} group by status")
                                    .ExecuteReaderAsync())
                {
                    while (await reader.ReadAsync())
                    {
                        var status = await reader.GetFieldValueAsync <string>(0);

                        var count = await reader.GetFieldValueAsync <int>(1);

                        if (status == TransportConstants.Incoming)
                        {
                            counts.Incoming = count;
                        }
                        else if (status == TransportConstants.Scheduled)
                        {
                            counts.Scheduled = count;
                        }
                    }
                }

                counts.Outgoing = (int)(long)await session.Connection
                                  .CreateCommand($"select count(*) from {_tables.Outgoing}").ExecuteScalarAsync();
            }


            return(counts);
        }
Example #2
0
        public async Task <PersistedCounts> GetPersistedCounts()
        {
            var counts = new PersistedCounts();

            using (var conn = new SqlConnection(_settings.ConnectionString))
            {
                await conn.OpenAsync();



                using (var reader = await conn
                                    .CreateCommand(
                           $"select status, count(*) from {_settings.SchemaName}.{IncomingTable} group by status")
                                    .ExecuteReaderAsync())
                {
                    while (await reader.ReadAsync())
                    {
                        var status = await reader.GetFieldValueAsync <string>(0);

                        var count = await reader.GetFieldValueAsync <int>(1);

                        if (status == TransportConstants.Incoming)
                        {
                            counts.Incoming = count;
                        }
                        else if (status == TransportConstants.Scheduled)
                        {
                            counts.Scheduled = count;
                        }
                    }
                }

                counts.Outgoing = (int)await conn
                                  .CreateCommand($"select count(*) from {_settings.SchemaName}.{OutgoingTable}").ExecuteScalarAsync();
            }



            return(counts);
        }
        public async Task <PersistedCounts> GetPersistedCounts()
        {
            var counts = new PersistedCounts();

            using (var conn = new NpgsqlConnection(_connectionString))
            {
                await conn.OpenAsync();


                using (var reader = await conn
                                    .CreateCommand(
                           $"select status, count(*) from {SchemaName}.{IncomingTable} group by status")
                                    .ExecuteReaderAsync())
                {
                    while (await reader.ReadAsync())
                    {
                        var status = Enum.Parse <EnvelopeStatus>(await reader.GetFieldValueAsync <string>(0));
                        var count  = await reader.GetFieldValueAsync <int>(1);

                        if (status == EnvelopeStatus.Incoming)
                        {
                            counts.Incoming = count;
                        }
                        else if (status == EnvelopeStatus.Scheduled)
                        {
                            counts.Scheduled = count;
                        }
                    }
                }

                var longCount = await conn
                                .CreateCommand($"select count(*) from {SchemaName}.{OutgoingTable}").ExecuteScalarAsync();

                counts.Outgoing = Convert.ToInt32(longCount);
            }


            return(counts);
        }
Example #4
0
        public void LogPersistedCounts(PersistedCounts counts)
        {
            _client.TrackMetric(new MetricTelemetry
            {
                Name       = "PersistedIncomingCount",
                Properties = { { "Node", _settings.NodeId } },
                Count      = counts.Incoming
            });

            _client.TrackMetric(new MetricTelemetry
            {
                Name       = "PersistedScheduledCount",
                Properties = { { "Node", _settings.NodeId } },
                Count      = counts.Scheduled
            });

            _client.TrackMetric(new MetricTelemetry
            {
                Name       = "PersistedOutgoingCount",
                Properties = { { "Node", _settings.NodeId } },
                Count      = counts.Outgoing
            });
        }