diff --git a/PROMS/ReferencedObjects/Exe/RefObj/ROEditor/ROEditor.cs b/PROMS/ReferencedObjects/Exe/RefObj/ROEditor/ROEditor.cs index 8bc2bc5f..43361914 100644 --- a/PROMS/ReferencedObjects/Exe/RefObj/ROEditor/ROEditor.cs +++ b/PROMS/ReferencedObjects/Exe/RefObj/ROEditor/ROEditor.cs @@ -1556,10 +1556,25 @@ namespace ROEditor if (StartupROEditor) { - // open an existing file, or create a new one + // The ROEditor.OWN file assures that only one individual at a time can edit the RO database. + // The file is opened and kept open while the user is editing the database. The contents of the + // file will identify the current user and state when the edit session began. try { fiown = new FileInfo("RoEditor.own"); + try { + // Try to delete the owner file. If another process has the file open, this delete will fail. + // If the file is closed, it will be deleted, and the user will be placed in the editor. The users + // name and the time when this session began will be placed in the owner file. + fiown.Delete(); + } + catch(Exception ex) + { + fsown = fiown.Open(FileMode.Open, FileAccess.Read, FileShare.ReadWrite); + TextReader tr1 = new StreamReader(fsown); + string who1 = tr1.ReadToEnd(); + MessageBox.Show(ex.Message + "\r\n\r\n" + who1, "RO Editor In Use", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + } fsown = fiown.Open(FileMode.OpenOrCreate, FileAccess.Read, FileShare.ReadWrite); TextReader tr = new StreamReader(fsown); string who = tr.ReadToEnd();