Beispiel #1
0
        public int Insert(XmlDbUpdateActionsLogModel entry)
        {
            var context = QPContext.EFContext;
            var entity  = MapperFacade.XmlDbUpdateActionsLogMapper.GetDalObject(entry);

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

            return(entity.Id);
        }
Beispiel #2
0
        public int Insert(XmlDbUpdateActionsLogModel entry)
        {
            var context = QPContext.EFContext;
            var entity  = MapperFacade.XmlDbUpdateActionsLogMapper.GetDalObject(entry);

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

            return(entity.Id);
        }
        private void ReplayActionsFromXml(IEnumerable <XElement> actionElements, string currentDbVersion, string backendUrl, int updateId)
        {
            foreach (var xmlAction in actionElements)
            {
                XmlDbUpdateRecordedAction action;
                var xmlActionString = xmlAction.ToNormalizedString(SaveOptions.DisableFormatting, true);

                try
                {
                    action = XmlDbUpdateSerializerHelpers.DeserializeAction(xmlAction);
                }
                catch (Exception ex)
                {
                    var throwEx = new XmlDbUpdateReplayActionException("Error while deserializing xml action string.", ex);
                    throwEx.Data.Add(LoggerData.XmlDbUpdateExceptionXmlActionStringData, xmlActionString.ToJsonLog());
                    throw throwEx;
                }

                var logEntry = new XmlDbUpdateActionsLogModel
                {
                    UserId    = _userId,
                    Applied   = DateTime.Now,
                    ParentId  = action.ParentId,
                    UpdateId  = updateId,
                    SourceXml = xmlActionString,
                    Hash      = HashHelpers.CalculateMd5Hash(xmlActionString)
                };

                if (_dbLogService.IsActionAlreadyReplayed(logEntry.Hash))
                {
                    Logger.Log.Warn($"XmlDbUpdateAction conflict: Current action already applied and exist at database. Entry: {logEntry.ToJsonLog()}");
                    continue;
                }

                var xmlActionStringLog = xmlAction.RemoveDescendants().ToString(SaveOptions.DisableFormatting);
                Logger.Log.Debug($"-> Begin replaying action [{logEntry.Hash}]: -> {xmlActionStringLog}");
                var replayedAction = ReplayAction(action, backendUrl);
                Logger.Log.Debug($"End replaying action [{logEntry.Hash}]: {xmlActionStringLog}");

                logEntry.Ids       = string.Join(",", replayedAction.Ids);
                logEntry.ResultXml = XmlDbUpdateSerializerHelpers.SerializeAction(replayedAction, currentDbVersion, backendUrl, true).ToNormalizedString(SaveOptions.DisableFormatting, true);
                _dbLogService.InsertActionLogEntry(logEntry);
            }
        }
Beispiel #4
0
 public void InsertActionLogEntry(XmlDbUpdateActionsLogModel logEntry)
 {
     _dbUpdateActionsLogRepository.Insert(logEntry);
 }