Ejemplo n.º 1
0
        public async Task ProcessAsync(CancellationToken cancellationToken = default)
        {
            _logger.LogTrace("Processing cleanup job");

            await _dataSession
            .StoredProcedure("[Log].[PurgeLogs]")
            .Parameter("@daysToKeep", 30)
            .ExecuteAsync(cancellationToken);

            await _dataSession
            .StoredProcedure("[IQ].[PurgeEmailDelivery]")
            .Parameter("@daysToKeep", 90)
            .ExecuteAsync(cancellationToken);

            _logger.LogTrace("Completed cleanup job");
        }
Ejemplo n.º 2
0
        protected override async Task <EntityPagedResult <LogEventModel> > Process(LogEventQuery request, CancellationToken cancellationToken)
        {
            int page     = request.Page == 0 ? 1 : request.Page;
            int pageSize = request.PageSize == 0 ? 100 : request.PageSize;
            int offset   = Math.Max(pageSize * (page - 1), 0);

            long total = 0;

            var rows = await _dataSession
                       .StoredProcedure("[Log].[SearchLogs]")
                       .Parameter("@Date", request.Date)
                       .Parameter("@Level", request.Level)
                       .Parameter("@Search", request.Search)
                       .Parameter("@Offset", offset)
                       .Parameter("@Size", pageSize)
                       .ParameterOut("@Total", (Action <long>)(v => total = v))
                       .QueryAsync(r =>
            {
                return(new LogEventModel
                {
                    TimeStamp = r.GetDateTime("TimeStamp"),
                    Level = r.GetString("Level"),
                    Message = r.GetString("Message"),
                    Exception = r.GetString("Exception"),
                    Properties = GetJson(r, "LogEvent")
                });
            });

            return(new EntityPagedResult <LogEventModel>
            {
                Total = total,
                Data = rows.ToList()
            });
        }
Ejemplo n.º 3
0
        internal static DataVaultCommand ReadOnlyStoredProcedure(IDataSession dataSession, string stpName)
        {
            var dataVaultCommandBuilder = new DataVaultCommand(dataSession.StoredProcedure(stpName));

            dataVaultCommandBuilder.DataCommand
            .ParameterOut <string>(DataVaultParams.StatusCode, p => dataVaultCommandBuilder.DataVaultResult.StatusCode = p.ToEnumOrDefault(DataVaultBusinessErrorCode.Failed))
            .ParameterOut <string>(DataVaultParams.Result, p => dataVaultCommandBuilder.DataVaultResult.JsonResult     = p);

            return(dataVaultCommandBuilder);
        }
Ejemplo n.º 4
0
        private async Task ImportUsers(ImportJob importJob, List <MemberImportModel> dataList, CancellationToken cancellationToken)
        {
            if (dataList.Count == 0)
            {
                _logger.LogWarning("No data to import");
                return;
            }

            var dataTable = dataList.ToDataTable();

            await _dataSession.StoredProcedure("[IQ].[ImportUsers]")
            .SqlParameter("@userTable", dataTable)
            .Parameter("@tenantId", importJob.TenantId)
            .Parameter("@roleName", Data.Constants.Role.MemberName)
            .ExecuteAsync(cancellationToken);
        }
        protected override async Task <IReadOnlyCollection <SessionFrequentTimeModel> > Process(SessionFrequentTimeQuery request, CancellationToken cancellationToken)
        {
            var results = await _dataSession
                          .StoredProcedure("[IQ].[FrequentSessionTimes]")
                          .Parameter("@tenantId", request.TenantId)
                          .QueryAsync(r =>
            {
                var reader = r as SqlDataReader;
                return(new SessionFrequentTimeModel
                {
                    StartTime = reader.GetTimeSpan(0),
                    EndTime = reader.GetTimeSpan(1),
                    Count = r.GetInt32(2)
                });
            }, cancellationToken);

            return(results.ToList());
        }