示例#1
0
        private static DBData ParsarBanco(FileInfo banco)
        {
            DBData dados = new DBData();

            if (banco.Exists)
            {
                using (var reader = banco.OpenText()) {
                    string rawLine;
                    while ((rawLine = reader.ReadLine()) != null)
                    {
                        dados.Add(Entrada.Parsar(rawLine));
                    }
                }
            }
            return(dados);
        }
示例#2
0
 public void Update(Entrada entrada, Action <DBException> onCompleted)
 {
     SGDB.Locks.Request(entrada.Id.Value, false, (toRelease) => {
         if (SGDB.MinhaVisão(this).FromID(entrada.Id.Value) == null)
         {
             onCompleted(new DBException($"Não é possível alterar o registro de ID {entrada.Id.Value} pois o mesmo não existe."));
             toRelease.Release();
         }
         else
         {
             Ações.Add(new Ação(Classes.Ações.Modificar, entrada));
             OnAçãoChanged?.Invoke(this, null);
             onCompleted.Invoke(null);
             Logger.Log($"Transação {Id}: Update {entrada}");
         }
     }, this);
 }
示例#3
0
 public void Insert(Entrada entrada, Action <DBException> onCompleted)
 {
     SGDB.Locks.Request(entrada.Id.Value, false, (toRelease) => {
         foreach (Entrada ent in SGDB.MinhaVisão(this))
         {
             if (ent.Id == entrada.Id)
             {
                 onCompleted.Invoke(new DBException("Não é possível inserir esse registro. Um com o mesmo ID já existe."));
                 toRelease.Release();
                 return;
             }
         }
         Ações.Add(new Ação(Classes.Ações.Inserir, entrada));
         OnAçãoChanged?.Invoke(this, null);
         onCompleted.Invoke(null);
         Logger.Log($"Transação {Id}: Insert {entrada}");
     }, this);
 }
示例#4
0
 public LogEvent(string fromLog)
 {
     if (fromLog.StartsWith("Checkpoint"))
     {
         Type = LogEventTypes.Checkpoint;
     }
     else
     {
         var regex = Regex.Match(fromLog, "(\\S*) (\\S*): (\\S*) ?(.*)?");
         Id = regex.Groups[2].Value;
         if (!Enum.TryParse(regex.Groups[3].Value, out _LogEventTypes))
         {
             throw new Exception($"Evento '{regex.Groups[3].Value}' do log não foi reconhecido");
         }
         if (regex.Groups[4].Success && regex.Groups[4].Value.Length > 0)
         {
             Data = Entrada.Parsar(regex.Groups[4].Value);
         }
     }
 }
示例#5
0
文件: Ação.cs 项目: ThFnsc/JinxDB
 public Ação(Ações tipo, Entrada diferença)
 {
     Tipo  = tipo;
     Dados = diferença;
 }