Exemplo n.º 1
0
        public int Insert(XmlDbUpdateLogModel entry)
        {
            var context = QPContext.EFContext;
            var entity  = MapperFacade.XmlDbUpdateLogMapper.GetDalObject(entry);

            context.Entry(entity).State = EntityState.Added;
            context.SaveChanges();

            return(entity.Id);
        }
Exemplo n.º 2
0
        public int Insert(XmlDbUpdateLogModel entry)
        {
            var context = QPContext.EFContext;
            var entity  = MapperFacade.XmlDbUpdateLogMapper.GetDalObject(entry);

            context.XML_DB_UPDATE.AddObject(entity);
            context.SaveChanges();

            return(entity.Id);
        }
Exemplo n.º 3
0
        public virtual void Process(string xmlString, IList <string> filePathes = null)
        {
            Ensure.Argument.NotNullOrWhiteSpace(xmlString, nameof(xmlString));

            var filteredXmlDocument = FilterFromSubRootNodeDuplicates(xmlString);
            var currentDbVersion    = String.Empty;

            using (new QPConnectionScope(ConnectionInfo, _identityInsertOptions))
            {
                currentDbVersion = _appInfoRepository.GetCurrentDbVersion();
                ValidateReplayInput(filteredXmlDocument, currentDbVersion);
            }

            var filteredXmlString = filteredXmlDocument.ToNormalizedString(SaveOptions.DisableFormatting);
            var dbLogEntry        = new XmlDbUpdateLogModel
            {
                UserId   = _userId,
                Body     = filteredXmlString,
                FileName = filePathes == null ? null : string.Join(",", filePathes),
                Applied  = DateTime.Now,
                Hash     = HashHelpers.CalculateMd5Hash(filteredXmlString)
            };

            using (new ThreadStorageScopeContext())
                using (var ts = QPConfiguration.CreateTransactionScope(IsolationLevel.ReadCommitted))
                    using (new QPConnectionScope(ConnectionInfo, _identityInsertOptions))
                    {
                        if (_dbLogService.IsFileAlreadyReplayed(dbLogEntry.Hash))
                        {
                            var throwEx = new XmlDbUpdateLoggingException("XmlDbUpdate conflict: current xml document(s) already applied and exist at database.");
                            throwEx.Data.Add("LogEntry", dbLogEntry.ToJsonLog());
                            throw throwEx;
                        }

                        var updateId = _dbLogService.InsertFileLogEntry(dbLogEntry);
                        ReplayActionsFromXml(filteredXmlDocument.Root?.Elements(), currentDbVersion, filteredXmlDocument.Root?.Attribute(XmlDbUpdateXDocumentConstants.RootBackendUrlAttribute)?.Value, updateId);
                        ts.Complete();
                    }
        }
Exemplo n.º 4
0
 public int InsertFileLogEntry(XmlDbUpdateLogModel dbLogEntry) => _dbUpdateLogRepository.Insert(dbLogEntry);