diff --git a/PROMS/VEPROMS User Interface/dlgExportImport.cs b/PROMS/VEPROMS User Interface/dlgExportImport.cs index 66cd2489..55058930 100644 --- a/PROMS/VEPROMS User Interface/dlgExportImport.cs +++ b/PROMS/VEPROMS User Interface/dlgExportImport.cs @@ -99,6 +99,10 @@ namespace VEPROMS MyProcedure = procedureInfo; InitializeComponent(); this.Text = mode + " Dialog for " + procedureInfo.DisplayNumber; + + //Preset path for single procedures. + PEIPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\VEPROMS\PEI_" + Database.VEPROMS_SqlConnection.Database; + txtExport.Text = string.Format(@"{0}\{1}.pxml", PEIPath, MyProcedure.DisplayNumber.Replace("/", "_").Replace("\\", "_")); } private void dlgExportImport_Load(object sender, EventArgs e) { @@ -172,6 +176,7 @@ namespace VEPROMS } else if (MyProcedure != null) { + txtExport.Enabled = true; txtExport.Text = string.Format(@"{0}\{1}.pxml", PEIPath, MyProcedure.DisplayNumber.Replace("/", "_").Replace("\\", "_")); } } @@ -190,6 +195,8 @@ namespace VEPROMS private bool successfullExport = true; private void btnDoExport_Click(object sender, EventArgs e) { + + btnExport.Enabled = false; string msg = "Finished Exporting:\n\n"; if (_MyMode.ToUpper().Contains("FORMAT")) @@ -220,6 +227,27 @@ namespace VEPROMS } else if (MyProcedure != null) { + var fileLocation = txtExport.Text; + + if (File.Exists(fileLocation)) + { // C2022-029 if an existing export of the same name is found, provide option to overwrite it + DialogResult ovewriteEx = FlexibleMessageBox.Show("There is already another export file with the same name, would you like to overwrite it?\r\n\r\nSelecting 'Cancel' will cancel the export.", "Overwrite the export change", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);// == DialogResult.Yes; + + if (ovewriteEx == DialogResult.Cancel) btnCloseExport.Enabled = true; + else + { + // Extract directory, filename, and extension + string directory = Path.GetDirectoryName(fileLocation); + string filename = Path.GetFileNameWithoutExtension(fileLocation); + string extension = Path.GetExtension(fileLocation); + + // Generate the new filename with a datestamp + string datestamp = DateTime.Now.ToString("yyyyMMddHHmmss"); + fileLocation = $"{directory}\\{filename}_{datestamp}{extension}"; + } + + } + this.Cursor = Cursors.WaitCursor; MyStart = DateTime.Now; btnDoExport.Enabled = false; @@ -230,7 +258,7 @@ namespace VEPROMS XmlElement xe = xd.CreateElement("formats"); xd.DocumentElement.AppendChild(xe); ExportFormats(FormatInfoList.GetFormatInfoListUsed(), xe, "formats", false); - xd.Save(txtExport.Text); + xd.Save(fileLocation); TimeSpan elapsed = DateTime.Now.Subtract(MyStart); lblExportStatus.Text = "Export Completed in " + elapsed.ToString(); this.Cursor = Cursors.Default; diff --git a/PROMS/VEPROMS User Interface/dlgExportImport.designer.cs b/PROMS/VEPROMS User Interface/dlgExportImport.designer.cs index cb3f8404..4e6f1ec4 100644 --- a/PROMS/VEPROMS User Interface/dlgExportImport.designer.cs +++ b/PROMS/VEPROMS User Interface/dlgExportImport.designer.cs @@ -400,6 +400,7 @@ namespace VEPROMS this.pnlImport.PerformLayout(); this.ResumeLayout(false); + } #endregion