diff --git a/PROMS/VEPROMS User Interface/dlgExportImport.cs b/PROMS/VEPROMS User Interface/dlgExportImport.cs index da94dd94..2545a4ff 100644 --- a/PROMS/VEPROMS User Interface/dlgExportImport.cs +++ b/PROMS/VEPROMS User Interface/dlgExportImport.cs @@ -144,6 +144,7 @@ namespace VEPROMS private ZipFile MyExpxZipFile = null; private ZipFile MyImpxZipFile = null; private DateTime MyStart; + private bool successfullExport = true; private void btnDoExport_Click(object sender, EventArgs e) { btnExport.Enabled = false; @@ -177,7 +178,10 @@ namespace VEPROMS this.Cursor = Cursors.Default; } // added message to user when export of a procedure or procedure set has completed - msg += MyProcedure; + if (successfullExport) + msg += MyProcedure; + else + msg = "Could not complete export"; MessageBox.Show(msg, "Export", MessageBoxButtons.OK, MessageBoxIcon.Information); btnCloseExport.Enabled = true; } @@ -1416,65 +1420,78 @@ namespace VEPROMS // MyWriter.WriteEndElement(); // MyWriter.WriteEndDocument(); //} - private void ExportDocVersion(XmlElement xn, DocVersionInfo dvi, string nodename) - { - /* - VersionID - FolderID - VersionType - Name - Title - ItemID - FormatID - Config - DTS - UserID - */ - lblExportStatus.Text = "Exporting DocVersion..."; - Application.DoEvents(); + + // bug fix: B2017-082 don't export if no RO Path - display an message to the user to assign a RO Path + private bool ValidDocVersionAssociation(DocVersionInfo dvi) + { + if (dvi.DocVersionAssociationCount <= 0) + { + MessageBox.Show("Assign a Referenced Object path to the Working Draft tree node before exporting.", "RO Path not assigned"); + successfullExport = false; + return false; + } + return true; + } + private void ExportDocVersion(XmlElement xn, DocVersionInfo dvi, string nodename) + { + /* + VersionID + FolderID + VersionType + Name + Title + ItemID + FormatID + Config + DTS + UserID + */ + lblExportStatus.Text = "Exporting DocVersion..."; + Application.DoEvents(); string formatFileName = (dvi.MyFormat != null) ? dvi.MyFormat.Name : ""; - XmlElement xe = xn.OwnerDocument.CreateElement(nodename); - xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "versionid", dvi.VersionID.ToString())); - xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "folderid", dvi.FolderID.ToString())); - xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "versiontype", dvi.VersionType.ToString())); - xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "name", dvi.Name)); - xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "title", dvi.Title)); - xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "itemid", dvi.ItemID.ToString())); - xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "formatid", dvi.FormatID.ToString())); - xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "config", dvi.Config)); - xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "dts", dvi.DTS.ToString("MM/dd/yyyy HH:mm:ss.fff"))); - xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "userid", dvi.UserID.ToString())); + XmlElement xe = xn.OwnerDocument.CreateElement(nodename); + xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "versionid", dvi.VersionID.ToString())); + xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "folderid", dvi.FolderID.ToString())); + xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "versiontype", dvi.VersionType.ToString())); + xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "name", dvi.Name)); + xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "title", dvi.Title)); + xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "itemid", dvi.ItemID.ToString())); + xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "formatid", dvi.FormatID.ToString())); + xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "config", dvi.Config)); + xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "dts", dvi.DTS.ToString("MM/dd/yyyy HH:mm:ss.fff"))); + xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "userid", dvi.UserID.ToString())); xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "formatfilename", formatFileName)); - xn.AppendChild(xe); - if (dvi.DocVersionAssociationCount > 0) - foreach (AssociationInfo ai in dvi.DocVersionAssociations) - ExportAssociation(xe, ai, "association"); - string fn = PEIPath + @"\folder.xml"; - xn.OwnerDocument.Save(fn); - MyExpxZipFile.AddFile(fn, "folder"); - MyExpxZipFile.Save(); - File.Delete(fn); - //here - lblExportStatus.Text = "Exporting Procedures..."; - Application.DoEvents(); - if (dvi.Procedures.Count > 0) - { - pbExportProcedure.Value = 0; - pbExportProcedure.Maximum = dvi.Procedures.Count; - lblExportProcedure.Text = pbExportProcedure.Maximum.ToString() + " Procedures"; - foreach (ItemInfo ii in dvi.Procedures) - { - XmlDocument xd = new XmlDocument(); - ExportItem(xd, ii, "procedure"); - fn = string.Format(@"{0}\proc{1}.xml", PEIPath, pbExportProcedure.Value.ToString().PadLeft(4, '0')); - xd.Save(fn); - MyExpxZipFile.AddFile(fn, "procedures"); - MyExpxZipFile.Save(); - File.Delete(fn); - xd = null; - } - } - } + xn.AppendChild(xe); + if (!ValidDocVersionAssociation(dvi)) return; // bug fix: B2017-082 don't export if no RO Path + if (dvi.DocVersionAssociationCount > 0) + foreach (AssociationInfo ai in dvi.DocVersionAssociations) + ExportAssociation(xe, ai, "association"); + string fn = PEIPath + @"\folder.xml"; + xn.OwnerDocument.Save(fn); + MyExpxZipFile.AddFile(fn, "folder"); + MyExpxZipFile.Save(); + File.Delete(fn); + //here + lblExportStatus.Text = "Exporting Procedures..."; + Application.DoEvents(); + if (dvi.Procedures.Count > 0) + { + pbExportProcedure.Value = 0; + pbExportProcedure.Maximum = dvi.Procedures.Count; + lblExportProcedure.Text = pbExportProcedure.Maximum.ToString() + " Procedures"; + foreach (ItemInfo ii in dvi.Procedures) + { + XmlDocument xd = new XmlDocument(); + ExportItem(xd, ii, "procedure"); + fn = string.Format(@"{0}\proc{1}.xml", PEIPath, pbExportProcedure.Value.ToString().PadLeft(4, '0')); + xd.Save(fn); + MyExpxZipFile.AddFile(fn, "procedures"); + MyExpxZipFile.Save(); + File.Delete(fn); + xd = null; + } + } + } private void ExportDocVersion(DocVersionInfo dvi, string nodename) { /* @@ -1678,6 +1695,7 @@ namespace VEPROMS MyWriter.WriteAttributeString("userid", db.UserID.ToString()); MyWriter.WriteEndElement(); } + public void ExportItem(XmlDocument xd, ItemInfo ii, string nodename) { XmlElement xe = xd.CreateElement(nodename);