async Task OnChanged(FileChangedEventArgs e) { try { Files = new List <SaveBytesInput>(); foreach (var file in e.Files) { FileName = file.Name; Percentage = 0; var stream1 = file.OpenReadStream(file.Size); var bytes = await stream1.GetAllBytesAsync(); var fileInput = new SaveBytesInput { Bytes = bytes, EntityId = DateTime.Now.ToString("yyyyMMddHHmmssfff"), EntityType = "common-attachment", FileName = file.Name }; Files.Add(fileInput); } } catch (Exception exc) { Console.WriteLine(exc.Message); } finally { this.StateHasChanged(); } }
protected async Task OnChanged(FileChangedEventArgs e) { try { foreach (var file in e.Files) { using (var stream = new MemoryStream()) { await file.WriteToStreamAsync(stream); stream.Seek(0, SeekOrigin.Begin); Cuentas = await ReadExcel(stream); if (Cuentas.Any()) { DisabledButtonImport = false; } } } } catch (Exception exc) { await Notify.Error("Error al cargar el archivo."); Logger.LogError(exc.Message); } finally { StateHasChanged(); } }
protected virtual void OnFileChanged(FileChangedEventArgs e) { if (FileChanged != null) { FileChanged(this, e); } }
protected void SubscribeFolderEvents(object sender, FileChangedEventArgs <SoundEvent> e) { if (e.Change == FileChange.Add) { foreach (SoundEvent soundEvent in e.Files) { soundEvent.CollectionChanged += SoundEventSoundsChanged; soundEvent.ValidateProperty += OnSoundEventValidate; soundEvent.PropertyChanged += OnSoundEventPropertyChanged; soundEvent.FilePropertyChanged += OnSoundPropertyChanged; soundEvent.FilesChanged += OnSoundEventFileChanged; } } else if (e.Change == FileChange.Remove) { foreach (SoundEvent soundEvent in e.Files) { soundEvent.CollectionChanged -= SoundEventSoundsChanged; soundEvent.ValidateProperty -= OnSoundEventValidate; soundEvent.PropertyChanged -= OnSoundEventPropertyChanged; soundEvent.FilePropertyChanged -= OnSoundPropertyChanged; soundEvent.FilesChanged -= OnSoundEventFileChanged; } } }
protected async Task OnFileInputChanged(FileChangedEventArgs e) { this.Block(); try { foreach (var file in e.Files) { using (var stream = new MemoryStream()) { this.CurrentDocument.FILE_NAME = file.Name; if (!this.MapFileExtension()) { this.CurrentDocument.FILE_NAME = null; this.CurrentDocument.FILE = null; this.IsUploading = false; this.UploadProgress = 0; return; } await file.WriteToStreamAsync(stream); this.CurrentDocument.FILE.FILE = stream.ToArray(); } } } catch (Exception) { this.ShowToast("Erro ao tentar selecionar o arquivo!"); } finally { this.Unblock(); this.StateHasChanged(); } }
public virtual void OnFileMetadataChanged(FileChangedEventArgs args) { if (FileMetadataChanged != null) { FileMetadataChanged(this, args); } }
public virtual void OnFileOverwritten(FileChangedEventArgs args) { if (FileOverwritten != null) { FileOverwritten(this, args); } }
public bool IsMatch(FileChangedEventArgs @event) { if (@event?.Name != null) { return(@event.Name.EndsWith($".{_ext}")); } return(false); }
private void FileChanged(object sender, FileChangedEventArgs args) { if (args.FileInfo.FullName == _currentFileInfo.FullName) { _args = args; _signal.Release(); } }
/// <inheritdoc/> public virtual void OnFileChanged(FileChangedEventArgs args) { if (this.FileChanged != null) { this.FileChanged(this, args); } this.AddLog(args.FileInfo, args.UserId, EventLogType.FILE_CHANGED); }
/// <summary> /// Raises the <see cref="Deleted"/> event. /// </summary> /// <param name="args">Arguments for the event.</param> public void RaiseDeleted(FileChangedEventArgs args) { if (!ShouldRaiseEvent(args)) { return; } Deleted?.Invoke(this, args); }
public virtual void OnFileMetadataChanged(FileChangedEventArgs args) { if (FileMetadataChanged != null) { FileMetadataChanged(this, args); } AddLog(args.FileInfo, args.UserId, EventLogController.EventLogType.FILE_METADATACHANGED); }
public virtual void OnFileOverwritten(FileChangedEventArgs args) { if (FileOverwritten != null) { FileOverwritten(this, args); } AddLog(args.FileInfo, args.UserId, EventLogController.EventLogType.FILE_OVERWRITTEN); }
private void OnSoundEventFileChanged(object sender, FileChangedEventArgs <Sound> e) { if (e.Change == FileChange.Remove) { if (((SoundEvent)sender).Count == 0) { RaisePropertyChanged(nameof(HasEmptyFolders)); } } }
private void UpdateInformation(object sender, FileChangedEventArgs e) { if (e.CurrentPath == null) { Dispose(); return; } Information = File.Create(_accessor.FilePath); }
private void Notify(IObserver <FileChangedEventArgs> observer, FileChangedEventArgs evt) { if (_filter == null) { observer.OnNext(evt); } else if (_filter.IsMatch(evt)) { observer.OnNext(evt); } }
private void DirectoryWatcher_OnFileChanged(object sender, FileChangedEventArgs e) { switch(e.FileInfo.status) { case Status.Added_Modified: runtime.ReloadController(e.FileInfo.FileName); break; case Status.Removed: runtime.RemoveController(e.FileInfo.FileName); break; } }
private void OnDeleted(object sender, FileChangedEventArgs args) { var newPath = TryConvertPath(args.FullPath); if (!newPath.HasValue) { return; } var newArgs = new FileChangedEventArgs(FileSystem, args.ChangeType, newPath.Value); RaiseDeleted(newArgs); }
public async Task OnChanged(FileChangedEventArgs e) { try { ErrorMessage = string.Empty; Status = PageStatus.Uploading; FileUploadStatus = ValidationStatus.None; StateHasChanged(); foreach (var file in e.Files) { string requestId = await BorderCrossingServiceWebWrapper.AddNewRequestAsync(ConnectionInfo?.RemoteIpAddress, ConnectionInfo?.UserAgent); if (Path.GetExtension(file.Name) != ".zip") { throw new Exception(L["ZipWarning"]); } await using (var memoryStream = new MemoryStream()) { await file.WriteToStreamAsync(memoryStream); PercentageLoad = 100; StateHasChanged(); Status = PageStatus.Deserializing; await BorderCrossingServiceWebWrapper.PrepareLocationHistoryAsync(memoryStream, file.Name, requestId, (sender, progressChangedEventArgs) => { PercentagePrep = progressChangedEventArgs.ProgressPercentage; InvokeAsync(StateHasChanged); }); NavigationManager.NavigateTo($"query/{requestId}"); } } } catch (Exception exception) { ErrorMessage = exception.Message; FileUploadStatus = ValidationStatus.Error; Status = PageStatus.ReadyToUpload; PercentageLoad = 0; PercentagePrep = 0; } finally { this.StateHasChanged(); } }
public void ShouldNotifyWhenFileWasModifiedInSpecifiedPath() { //Given FileChangedEventArgs createdEvent = null; var fileWatchDog = _kernel.Get <IFileSystemWatchDog>(); //When var disp = fileWatchDog.Watch(ObserverDirPath).Subscribe(e => createdEvent = e); _monitorService.Modified += Raise.EventWith(new FileModifiedEventArgs(FileModifiedEventMessage, FileName)); disp.Dispose(); //Then _monitorService.Received(1).Dispose(); Assert.Equal(FileModifiedEventMessage, createdEvent.Message); }
void XMLHandle_FileChange(FileChangedEventArgs e) { foreach (Record record in m_GasRecords) { if (record.FileName == e.oldFileName) { record.FileName = e.newFileName; } } foreach (Record record in m_ElectricRecords) { if (record.FileName == e.oldFileName) { record.FileName = e.newFileName; } } }
protected void SubscribeFolderEvents(object sender, FileChangedEventArgs <ObservableFolder <Recipe> > e) { if (e.Change == FileChange.Add) { foreach (ObservableFolder <Recipe> folder in e.Files) { folder.FilesChanged += OnFilesChanged; } } else if (e.Change == FileChange.Remove) { foreach (ObservableFolder <Recipe> folder in e.Files) { folder.FilesChanged -= OnFilesChanged; } } }
public void ShouldNotifyWhenFileWasCreatedAndCustomPredicateMatch() { //Given FileChangedEventArgs createdEvent = null; var fileWatchDog = _kernel.Get <IFileSystemWatchDog>(); //When var disp = fileWatchDog.Watch(ObserverDirPath) .Filter(Filters.Custom(e => e.Name == "index.html")) .Subscribe(e => createdEvent = e); _monitorService.Created += Raise.EventWith(new FileCreatedEventArgs(FileCreatedEventMessage, FileName)); _monitorService.Created += Raise.EventWith(new FileCreatedEventArgs(FileCreatedEventMessage, "index.html")); disp.Dispose(); //Then _monitorService.Received(1).Dispose(); Assert.Equal("index.html", createdEvent.Name); }
public void ShouldNotifyWhenFileWasCreatedAndExtsIncludedInFilter() { //Given FileChangedEventArgs createdEvent = null; var fileWatchDog = _kernel.Get <IFileSystemWatchDog>(); //When var disp = fileWatchDog.Watch(ObserverDirPath) .Filter(Filters.Complex(Filters.ExtFilter("js"), Filters.ExtFilter("txt"))) .Subscribe(e => createdEvent = e); _monitorService.Created += Raise.EventWith(new FileCreatedEventArgs(FileCreatedEventMessage, FileName)); _monitorService.Created += Raise.EventWith(new FileCreatedEventArgs(FileCreatedEventMessage, "index.txt")); disp.Dispose(); //Then _monitorService.Received(1).Dispose(); Assert.Equal("index.txt", createdEvent.Name); }
private static void OnFileChangedEvent(object sender, FileChangedEventArgs e) { //lock (Lock) { var file = new FileInfo(e.FilePath); foreach (var log in watching) { if (log.File.Name == file.Name) { var line = ReadLastLine(e.FilePath); if (string.IsNullOrWhiteSpace(line)) { return; } Logger.Trace(file.Name, line); return; } } //} }
private void OnFileChanged(FileChangedEventArgs args) { string resourceName = args.ResourceName; Component instance = CreateComponent(resourceName, true); // compilation succeeded so replace the components on the nodes if (instance != null) { System.Type type = instance.GetType(); Node[] nodes = GetChildrenWithComponent(instance.GetType()); foreach (Node node in nodes) { RemoveComponent(node, instance.GetType()); Component comp = CreateComponent(resourceName); if (comp != null) { node.AddComponent(comp); } } } }
private void PersistanceModelOnFileChanged(object sender, FileChangedEventArgs fileChangedEventArgs) { if (fileChangedEventArgs.File.Name != Name) { return; } Tags.Clear(); AvailableTags.Clear(); foreach (var tag in _tagsModel.Tags.Select(t => t.Text)) { if (fileChangedEventArgs.File.Tags.Contains(tag)) { Tags.Add(new TagViewModel(this, tag)); } else { AvailableTags.Add(new TagViewModel(this, tag)); } } }
private void FileProviderOnFileChangedEvent(object sender, FileChangedEventArgs e) { IFile file = e.File; switch (e.ChangeKind) { case FileChangedEventArgs.FileChangeKind.Modified: break; case FileChangedEventArgs.FileChangeKind.Added: currentDirectoryFiles.Add(file); break; case FileChangedEventArgs.FileChangeKind.Deleted: currentDirectoryFiles.Remove(file); break; default: throw new ArgumentOutOfRangeException(); } }
private void OnFileSystemEvent(object sender, FileChangedEventArgs e) { // Don't log events until the thread is started if (!_threadStarted) { return; } var dir = new DirectoryEntry(e.FileSystem, e.FullPath); if (IsOutputDirectory(e.FullPath)) { return; } lock (_watchers) { var isDirectory = dir.Exists; switch (e.ChangeType) { case WatcherChangeTypes.Deleted: if (isDirectory) { DisposeWatcher(dir); } break; case WatcherChangeTypes.Created: // Create watcher only for top-level directories if (isDirectory && dir.Parent != null && dir.Parent == _siteDirectory) { WatchFolder(dir); } break; case WatcherChangeTypes.Renamed: var renamed = (FileRenamedEventArgs)e; if (isDirectory) { var previousDirectory = new DirectoryEntry(renamed.FileSystem, renamed.OldFullPath); if (_watchers.TryGetValue(previousDirectory, out _)) { DisposeWatcher(previousDirectory); // Create watcher only for top-level directories if (dir.Parent != null && dir.Parent == _siteDirectory) { WatchFolder(dir); } } } break; } } lock (_batchLock) { _clock.Restart(); if (_batchEvents == null) { _batchEvents = new FileSystemEventBatchArgs(); } _batchEvents.FileEvents.Add(e); } }
public SimpleFileChangedEventArgs(FileChangedEventArgs args) : this() { FileSystem = args.FileSystem; FullPath = args.FullPath; Args = args; }
/// <summary> /// Respond to changes in any test file's contents /// </summary> private void OnTestFileChanged(object sender, FileChangedEventArgs e) { Caption = BaseCaption + "*"; Vm.HasAnyTestFileChanged = true; SpectNetPackage.UpdateCommandUi(); }
private void OnDependencyChanged(FileChangedEventArgs e) { _directoryCatalog.Refresh(); }