private void ClearObjects(AcObjectType t, params string[] names) { foreach (string name in names) { _application.DoCmd.DeleteObject(t, name); } }
private string[] GetConflictObjectName(FileInfo[] files, string[] names, AcObjectType acType) { IEnumerable <string> conflictObjects = names.Except( (from f in files select Path.GetFileNameWithoutExtension(f.Name)).ToList() ); return(conflictObjects.ToArray()); }
internal void Close(AcObjectType objectType, string objectName, bool?save) { application.DoCmd.Close( objectType, objectName, save.HasValue ? save.Value ? AcCloseSave.acSaveYes : AcCloseSave.acSaveNo : AcCloseSave.acSavePrompt ); }
private void SaveObjects(string baseDirectory, string subDirectoryName, Container acContainer, AcObjectType acType) { DirectoryInfo di = Directory.CreateDirectory(Path.Combine(baseDirectory, subDirectoryName)); foreach (Document document in acContainer.Documents) { _application.Application.SaveAsText(acType, document.Name, Path.Combine(baseDirectory, di.Name, document.Name + ".txt")); } }
private void LoadObjects(string baseDirectory, string subDirectoryName, Container acContainer, AcObjectType acType) { // to avoid loading file which have the same name as existing object in the database // first compare the names of files and objects, get a list of conflicts DirectoryInfo di = Directory.CreateDirectory(Path.Combine(baseDirectory, subDirectoryName)); FileInfo[] files = di.GetFiles("*" + EXTENSION); IList <string> existingObjects = new List <String>(); foreach (Document d in acContainer.Documents) { existingObjects.Add(d.Name); } string[] conflictObjects = GetConflictObjectName(files, existingObjects.ToArray(), acType); // then remove those conflicting objects ClearObjects(acType, conflictObjects); foreach (FileInfo f in files) { _application.LoadFromText(acType, Path.GetFileNameWithoutExtension(f.Name), f.FullName); } }