public void DeleteMasterForm(IMasterForm masterForm) { // Check if (masterForm == null) { throw new ArgumentNullException("masterForm"); } DiskMasterFormExample diskMasterForm = masterForm as DiskMasterFormExample; if (diskMasterForm == null) { throw new Exception("Invalid master form type"); // cast above failed } // Remove it from its parent list _masterForms.Remove(masterForm); // Delete attributes file string file = diskMasterForm.Path + ".bin"; if (File.Exists(file)) { File.Delete(file); } // Delete fields file file = diskMasterForm.Path + ".xml"; if (File.Exists(file)) { File.Delete(file); } // Delete image file file = diskMasterForm.Path + ".tif"; if (File.Exists(file)) { File.Delete(file); } }
internal void Refresh() { // Clear the collections _childCategories.Clear(); _masterForms.Clear(); // Read all the master forms in here string[] files = Directory.GetFiles(_path, "*.bin"); foreach (string file in files) { string name = System.IO.Path.GetFileNameWithoutExtension(file); DiskMasterFormExample masterForm = new DiskMasterFormExample(_repository, name, System.IO.Path.Combine(_path, name), this); _masterForms.AddMasterForm(masterForm); } // Read all the directories string[] dirs = Directory.GetDirectories(_path); foreach (string dir in dirs) { DiskMasterFormsCategoryExample category = new DiskMasterFormsCategoryExample(_repository, System.IO.Path.GetFileNameWithoutExtension(dir), dir, this); _childCategories.AddCategory(category); category.Refresh(); } }
public IMasterForm AddMasterForm(FormRecognitionAttributes attributes, FormPages fields, Uri url) { if (attributes == null) { throw new ArgumentException(string.Format("Master Form attributes should be available"), "attributes"); } // Create the file(s) FormRecognitionProperties properties = _recognitionEngine.GetFormProperties(attributes); DiskMasterFormExample masterForm = new DiskMasterFormExample(_repository, properties.Name, System.IO.Path.Combine(_path, properties.Name), this); // Create the file masterForm.WriteAttributes(attributes); if (fields != null) { masterForm.WriteFields(fields); } if (url != null) { masterForm.WriteForm(_repository.RasterCodecsInstance.Load(url, 1, CodecsLoadByteOrder.Bgr, 1, -1)); } _masterForms.AddMasterForm(masterForm); return(masterForm); }