Ejemplo n.º 1
0
        public async Task<IEnumerable<CisDto>> GetPendingCdaAnalysisAsync(OperationType opType, OperationStatus pendingStatus, string sqlWhereConditions)
        {
            return await WithConnectionPool(async connection =>
            {
                var response = new List<CisDto>();
                var getPendingCdaAnalysisSql = string.Format(@"SELECT   Id
                                                                        ,IdCis                                                                        
                                                                        ,CASE WHEN [Transformations].exist('/TRANSFORMATIONS/TRANSFORMATION[@NAME=""{1}""]/CIS') = 1 then ([Transformations].query('/TRANSFORMATIONS/TRANSFORMATION[@NAME=""{1}""]/CIS')) else NULL end as Transformations
                                                                        ,CdaAnalysisList
                                                                FROM [dbo].[{0}] with (NOLOCK)
                                                                WHERE CdaAnalysisStatus = @pending
                                                                {2}", opType.ReferenceTable, CisTransformationName, sqlWhereConditions);

                var reader = connection.Query<dynamic>(getPendingCdaAnalysisSql, new { pending = pendingStatus.Id }, buffered: false);

                foreach (var item in reader)
                {
                    response.Add(new CisDto()
                    {
                        Id = item.Id,
                        IdCis = item.IdCis,
                        Transformations = string.IsNullOrEmpty(item.Transformations) ? null : TryParseToXNode(item.Transformations, "Transformations"),
                        CdaAnalysisList = string.IsNullOrEmpty(item.CdaAnalysisList) ? null : TryParseXmlString(item.CdaAnalysisList, "CdaAnalysisList"),
                    });
                }

                ObjectPoolPutConnection(connection);

                return await Task.FromResult(response);
            });
        }
Ejemplo n.º 2
0
        public async Task<int> SetCompleteCdaAnalysisAsync(IOperationsGroup operationGroup, ICollection<int> idCisList, OperationType opType, OperationStatus completeStatus)
        {
            //TODO [ActivityLog] [ErrorsLog] [FailureCounter]

            var tbl = new DynamicModel(DbConnectionName, tableName: CdaManagerOperationsTableName);

            return await tbl.UpdateAsync(new
            {
                Status = completeStatus.Id,
                operationGroup.LastStatusChangedTime,
                operationGroup.CompleteTime,
                ErrorsLog = operationGroup.ErrorLog.Root
            }, $"Id = {operationGroup.SourceOperationGroupId}");
        }
Ejemplo n.º 3
0
        public async Task<int> SetInProgressCdaAnalysisAsync(IOperationsGroup operationGroup, ICollection<int> idCisList, OperationType opType, OperationStatus inProgressStatus)
        {
            //TODO [ActivityLog] [ErrorsLog] [FailureCounter]

            return await WithConnectionPool(async connection =>
            {
                int groupId = operationGroup.SourceOperationGroupId;

                var sb = new StringBuilder();
                if (CheckConcurrencyCdaAnalysis)
                {
                    sb.AppendFormat(@"UPDATE [dbo].[{0}] SET CdaAnalysisStatus = @inProgress WHERE IdCis IN @idCisList", opType.ReferenceTable).AppendLine();
                }
                sb.AppendFormat(@"UPDATE [dbo].[{0}] SET Status = @inProgress, LastStatusChangedTime = @changedTime WHERE Id = @operationGroupId", CdaManagerOperationsTableName);
                var updateCommand = sb.ToString();

                var response = await connection.ExecuteAsync(updateCommand, 
                    new {
                        inProgress = inProgressStatus.Id,
                        idCisList = idCisList.ToArray(),
                        operationGroupId = groupId,
                        changedTime = operationGroup.LastStatusChangedTime
                    });

                ObjectPoolPutConnection(connection);
                return response;
            });
        }