示例#1
0
        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();
            }
        }
示例#2
0
        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();
            }
        }
示例#3
0
 protected virtual void OnFileChanged(FileChangedEventArgs e)
 {
     if (FileChanged != null)
     {
         FileChanged(this, e);
     }
 }
示例#4
0
 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;
         }
     }
 }
示例#5
0
        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();
            }
        }
示例#6
0
 public virtual void OnFileMetadataChanged(FileChangedEventArgs args)
 {
     if (FileMetadataChanged != null)
     {
         FileMetadataChanged(this, args);
     }
 }
示例#7
0
 public virtual void OnFileOverwritten(FileChangedEventArgs args)
 {
     if (FileOverwritten != null)
     {
         FileOverwritten(this, args);
     }
 }
示例#8
0
 public bool IsMatch(FileChangedEventArgs @event)
 {
     if (@event?.Name != null)
     {
         return(@event.Name.EndsWith($".{_ext}"));
     }
     return(false);
 }
示例#9
0
 private void FileChanged(object sender, FileChangedEventArgs args)
 {
     if (args.FileInfo.FullName == _currentFileInfo.FullName)
     {
         _args = args;
         _signal.Release();
     }
 }
示例#10
0
        /// <inheritdoc/>
        public virtual void OnFileChanged(FileChangedEventArgs args)
        {
            if (this.FileChanged != null)
            {
                this.FileChanged(this, args);
            }

            this.AddLog(args.FileInfo, args.UserId, EventLogType.FILE_CHANGED);
        }
示例#11
0
        /// <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);
        }
示例#12
0
        public virtual void OnFileMetadataChanged(FileChangedEventArgs args)
        {
            if (FileMetadataChanged != null)
            {
                FileMetadataChanged(this, args);
            }

            AddLog(args.FileInfo, args.UserId, EventLogController.EventLogType.FILE_METADATACHANGED);
        }
示例#13
0
        public virtual void OnFileOverwritten(FileChangedEventArgs args)
        {
            if (FileOverwritten != null)
            {
                FileOverwritten(this, args);
            }

            AddLog(args.FileInfo, args.UserId, EventLogController.EventLogType.FILE_OVERWRITTEN);
        }
示例#14
0
 private void OnSoundEventFileChanged(object sender, FileChangedEventArgs <Sound> e)
 {
     if (e.Change == FileChange.Remove)
     {
         if (((SoundEvent)sender).Count == 0)
         {
             RaisePropertyChanged(nameof(HasEmptyFolders));
         }
     }
 }
示例#15
0
        private void UpdateInformation(object sender, FileChangedEventArgs e)
        {
            if (e.CurrentPath == null)
            {
                Dispose();
                return;
            }

            Information = File.Create(_accessor.FilePath);
        }
示例#16
0
 private void Notify(IObserver <FileChangedEventArgs> observer, FileChangedEventArgs evt)
 {
     if (_filter == null)
     {
         observer.OnNext(evt);
     }
     else if (_filter.IsMatch(evt))
     {
         observer.OnNext(evt);
     }
 }
示例#17
0
 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;
     }
 }
示例#18
0
        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);
        }
示例#19
0
        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();
            }
        }
示例#20
0
        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);
        }
示例#21
0
 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;
         }
     }
 }
示例#22
0
 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;
         }
     }
 }
示例#23
0
        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);
        }
示例#24
0
        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);
        }
示例#25
0
        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;
                }
            }
            //}
        }
示例#26
0
        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);
                    }
                }
            }
        }
示例#27
0
        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));
                }
            }
        }
示例#28
0
 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();
     }
 }
示例#29
0
        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);
            }
        }
示例#30
0
 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();
 }
示例#32
0
 private void OnDependencyChanged(FileChangedEventArgs e)
 {
     _directoryCatalog.Refresh();
 }