public void LoadFiles(bool _use_a_watcher = true) { if (!File.Exists(this.SummaryFileName)) { return; } try { // read and parse file this.FStream = new StreamReader(this.SummaryFileName); bool reached_eof = false; while (this.HasNext()) { this.Next(); if (this.FValue == ParamStructTypes.EOF) { reached_eof = true; if (this.current_file_record != null) { this.loaded_file_records.Add(this.current_file_record); } this.ReleaseRessources(); break; } this.ParseSummaryFile(); } if (!reached_eof) { this.ReleaseRessources(); } // load components from the files according to user role and ... StringBuilder sb_new = new StringBuilder(); DXFDecoder dxf_decoder = new DXFDecoder(this.MV_Factory, this.P_Factory, this.COMP_Factory); foreach (PartialFileRecord fr in this.loaded_file_records) { if (File.Exists(fr.FileName)) { // adjust the locks on the file (06.02.2017) bool lock_edit = true; this.nr_locks_record[(int)fr.Manager] = fr.NrLocks; if (DXFDistributedDecoder.HasEditingRights(this.manager, fr.Manager)) { lock_edit = (fr.NrLocks > 0); this.nr_locks_record[(int)fr.Manager] = fr.NrLocks + 1; fr.NrLocks++; } dxf_decoder.LoadFromFile(fr.FileName, lock_edit); } fr.AddToExport(ref sb_new); } dxf_decoder.DoDeferredOperations(); // connects components and networks saved in different partial files this.COMP_Factory.RestoreReferencesWithinRecord(); this.COMP_Factory.MakeParameterOutsideBoundsVisible(); // ... modify the summary file accordingly this.WriteSummaryFile(this.SummaryFileName, ref sb_new); this.FileRecordsOpen = true; // ... set a watcher on the file if (_use_a_watcher) { this.SetWatcher(); } } catch (Exception ex) { this.ReleaseRessources(); MessageBox.Show(ex.Message, "Error reading simultan file: " + this.SummaryFileName, MessageBoxButton.OK, MessageBoxImage.Error); } }