public void Send(ICommandAble cmmd) { var cmmdStr = _ser.Ser(cmmd); var filePath = CommandFile.GetFilePath(cmmd); File.WriteAllText(filePath, cmmdStr); }
public void Save(ICommandAble entity) { using var dbContext = new NetCoreSqliteDB.SqliteDBContext(_filePath); if (entity.BasedOnUpdatedDateTime == default(DateTime)) { dbContext.Table1.Add(entity as Entity1); } else { var preEntity = dbContext.Table1.SingleOrDefault(e => e.Id == entity.Id); if (preEntity.UpdatedDateTime > entity.BasedOnUpdatedDateTime) { throw new Exception(); } else { _mapper.Map(entity, preEntity); } } dbContext.SaveChanges(); }
public CommandExecutedEventArg(ICommandAble entity) { Entity = entity ?? throw new ArgumentNullException(nameof(entity)); IsSuccess = true; ErrorMessage = string.Empty; }
private static void CheckData(Command cmd, IEntityRepository entityRepository, ICommandAble lastUpdatedEntity) { if (lastUpdatedEntity.LastUpdateDateTime > cmd.UpdateEntity.Entity.LastUpdateDateTime) { throw new DataUpdateConflictException(cmd.UpdateEntity.Entity.GetType().Name, cmd.UpdateEntity.Entity.Id, cmd.UpdateEntity.Entity.LastUpdateDateTime, lastUpdatedEntity.LastUpdateDateTime, lastUpdatedEntity.LastUpdatedUser); } var newerReferences = entityRepository.NewerReferences; if (newerReferences.Any()) { var newerReference = newerReferences.First(); var reference = cmd.UpdateEntity.References.Single(i => i.Id == newerReference.Id); throw new ReferenceObsoleteException( newerReference.GetType().Name, newerReference.Id, reference.LastUpdateDateTime, newerReference.LastUpdatedUser, newerReference.LastUpdateDateTime); } }
internal static string GetFilePath(ICommandAble cmmd) { return(Path.Combine(SharedFolder, GetFileName(cmmd))); }
internal static string GetFileName(ICommandAble cmmd) { return($"{cmmd.Id} {cmmd.UpdatedDateTime.ToString("yyMMdd hhmmss")} {cmmd.UpdatedUserName}{FileExtension}"); }
public void Save(ICommandAble entity, string currentUpdateUser, DateTime currentUpdateDateTime) { throw new NotImplementedException(); }
public string Ser(ICommandAble cmmd) { return(JsonConvert.SerializeObject(cmmd, _setting)); }