/// <inheritdoc /> private protected override CommandResult Execute(string model) { var targetLocationEntity = Context.TargetLocationEntities.FirstOrDefault(l => l.Path.StartsWith(model)); if (targetLocationEntity == null) { targetLocationEntity = new TargetLocationEntity(); } targetLocationEntity.Path = model; Context.Add(targetLocationEntity); Context.SaveChanges(); //try //{ // var beaconFilePath = Path.Combine(model, targetLocationEntity.Id.ToString()); // File.Create(beaconFilePath); // File.SetAttributes(beaconFilePath, FileAttributes.Hidden); //} //catch (Exception e) //{ // Context.Remove(targetLocationEntity); // Context.SaveChanges(); // return new CommandResult(e.Message); //} return(new CommandResult()); }
/// <inheritdoc /> private protected override void Validate(string model, CommandErrorBuilder errorBuilder) { targetLocation = Context.TargetLocationEntities.FirstOrDefault(x => x.Path == model); if (targetLocation == null) { errorBuilder.AddError("Директория, отправленная на сканирование, не зарегистрирована в базе."); return; } }