B2017-082 Added a check for a RO Path being assigned at the working draft node

This commit is contained in:
John Jenko 2017-05-05 14:53:47 +00:00
parent 243779476c
commit 3b03233003

View File

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