Added code to fix error regarding importing procedure

Added initial code in preparation for allowing exporting/importing procedure sets with or without audit history
This commit is contained in:
Rich 2014-08-26 01:12:18 +00:00
parent 907ff47e5d
commit 293fcb2f1c
2 changed files with 81 additions and 20 deletions

View File

@ -192,6 +192,7 @@ namespace VEPROMS
xd.Load(txtImport.Text);
bool isImported = false;
pbImportProcedure.Maximum = 1;
MyRODb = RODb.GetByFolderPath(MyDocVersion.DocVersionAssociations[0].MyROFst.MyRODb.FolderPath);
foreach (ProcedureInfo pi in MyDocVersion.Procedures)
{
if (pi.ItemID == int.Parse(xd.SelectSingleNode("procedure/@itemid").InnerText) || pi.MyContent.Number == xd.SelectSingleNode("procedure/content/@number").InnerText)
@ -1364,11 +1365,37 @@ namespace VEPROMS
xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "previousid", ii.PreviousID.ToString()));
xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "contentid", ii.ContentID.ToString()));
xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "dts", ii.DTS.ToString("MM/dd/yyyy HH:mm:ss.fff")));
//item audits
ExportItemAudits(xe, ii);
ExportContent(xe, ii.MyContent, "content");
if (ii.ItemAnnotationCount > 0)
foreach (AnnotationInfo ai in ii.ItemAnnotations)
ExportAnnotation(xe, ai, "annotation");
}
private void ExportItemAudits(XmlElement xn, ItemInfo ii)
{
if (cbxExportAudits.Checked)
{
ItemAuditInfoList audits = ItemAuditInfoList.Get(ii.ItemID);
if (audits.Count > 0)
{
XmlElement xe = xn.OwnerDocument.CreateElement("audits");
foreach (ItemAuditInfo audit in audits)
{
XmlElement xee = xn.OwnerDocument.CreateElement("audit");
xee.Attributes.SetNamedItem(AddAttribute(xee.OwnerDocument, "auditid", audit.AuditID.ToString()));
xee.Attributes.SetNamedItem(AddAttribute(xee.OwnerDocument, "contentid", audit.ContentID.ToString()));
xee.Attributes.SetNamedItem(AddAttribute(xee.OwnerDocument, "deletestatus", audit.DeleteStatus.ToString()));
xee.Attributes.SetNamedItem(AddAttribute(xee.OwnerDocument, "dts", audit.DTS.ToString("MM/dd/yyyy HH:mm:ss.fff")));
xee.Attributes.SetNamedItem(AddAttribute(xee.OwnerDocument, "itemid", audit.ItemID.ToString()));
xee.Attributes.SetNamedItem(AddAttribute(xee.OwnerDocument, "previousid", audit.PreviousID.ToString()));
xee.Attributes.SetNamedItem(AddAttribute(xee.OwnerDocument, "userid", audit.UserID));
xe.AppendChild(xee);
}
xn.AppendChild(xe);
}
}
}
private void ExportItem(ItemInfo ii, string nodename)
{
/*
@ -1433,6 +1460,7 @@ namespace VEPROMS
xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "config", ci.Config));
xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "dts", ci.DTS.ToString("MM/dd/yyyy HH:mm:ss.fff")));
xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "userid", ci.UserID.ToString()));
//content audits
xn.AppendChild(xe);
if (ci.ContentTransitionCount > 0)
foreach (TransitionInfo ti in ci.ContentTransitions)
@ -1499,6 +1527,7 @@ namespace VEPROMS
xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "config", gi.Config));
xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "dts", gi.DTS.ToString("MM/dd/yyyy HH:mm:ss.fff")));
xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "userid", gi.UserID.ToString()));
//grid audits
xn.AppendChild(xe);
}
private void ExportGrid(GridInfo gi, string nodename)
@ -1531,6 +1560,7 @@ namespace VEPROMS
xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "docid", ei.DocID.ToString()));
xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "dts", ei.DTS.ToString("MM/dd/yyyy HH:mm:ss.fff")));
xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "userid", ei.UserID.ToString()));
//entry audits
xn.AppendChild(xe);
ExportDocument(xe, ei.MyDocument, "document");
}
@ -1571,6 +1601,7 @@ namespace VEPROMS
xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "dts", di.DTS.ToString("MM/dd/yyyy HH:mm:ss.fff")));
xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "userid", di.UserID.ToString()));
xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "fileextension", di.FileExtension));
//document audits
xn.AppendChild(xe);
}
private void ExportDocument(DocumentInfo di, string nodename)
@ -1615,6 +1646,7 @@ namespace VEPROMS
xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "dts", ri.DTS.ToString("MM/dd/yyyy HH:mm:ss.fff")));
xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "userid", ri.UserID.ToString()));
xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "rodbid", ri.RODbID.ToString()));
//rousage audits
xn.AppendChild(xe);
}
private void ExportROUsage(RoUsageInfo ri, string nodename)
@ -1653,6 +1685,7 @@ namespace VEPROMS
xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "itemid", pi.ItemID.ToString()));
xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "dts", pi.DTS.ToString("MM/dd/yyyy HH:mm:ss.fff")));
xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "userid", pi.UserID.ToString()));
//part audits
xn.AppendChild(xe);
foreach (ItemInfo ii in pi.MyItems)
ExportItem(xe, ii, pi.PartType.ToString().ToLower());
@ -1699,6 +1732,7 @@ namespace VEPROMS
xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "config", ti.Config));
xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "dts", ti.DTS.ToString("MM/dd/yyyy HH:mm:ss.fff")));
xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "userid", ti.UserID.ToString()));
//transition audits
xn.AppendChild(xe);
}
private void ExportTransition(TransitionInfo ti, string nodename)
@ -1762,6 +1796,7 @@ namespace VEPROMS
xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "config", ai.Config));
xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "dts", ai.DTS.ToString("MM/dd/yyyy HH:mm:ss.fff")));
xe.Attributes.SetNamedItem(AddAttribute(xe.OwnerDocument, "userid", ai.UserID.ToString()));
//annotation audits
xn.AppendChild(xe);
}
private void ExportAnnotation(AnnotationInfo ai, string nodename)

View File

@ -29,6 +29,7 @@ namespace VEPROMS
private void InitializeComponent()
{
this.pnlExport = new System.Windows.Forms.Panel();
this.btnCloseExport = new System.Windows.Forms.Button();
this.lblExportTime = new System.Windows.Forms.Label();
this.lblExportStatus = new System.Windows.Forms.Label();
this.pbExportStep = new System.Windows.Forms.ProgressBar();
@ -42,6 +43,7 @@ namespace VEPROMS
this.txtExport = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.pnlImport = new System.Windows.Forms.Panel();
this.btnCloseImport = new System.Windows.Forms.Button();
this.lblImportTime = new System.Windows.Forms.Label();
this.lblImportStatus = new System.Windows.Forms.Label();
this.pbImportStep = new System.Windows.Forms.ProgressBar();
@ -56,14 +58,15 @@ namespace VEPROMS
this.label2 = new System.Windows.Forms.Label();
this.ofd = new System.Windows.Forms.OpenFileDialog();
this.sfd = new System.Windows.Forms.SaveFileDialog();
this.btnCloseExport = new System.Windows.Forms.Button();
this.btnCloseImport = new System.Windows.Forms.Button();
this.cbxExportAudits = new System.Windows.Forms.CheckBox();
this.cbxImportAudits = new System.Windows.Forms.CheckBox();
this.pnlExport.SuspendLayout();
this.pnlImport.SuspendLayout();
this.SuspendLayout();
//
// pnlExport
//
this.pnlExport.Controls.Add(this.cbxExportAudits);
this.pnlExport.Controls.Add(this.btnCloseExport);
this.pnlExport.Controls.Add(this.lblExportTime);
this.pnlExport.Controls.Add(this.lblExportStatus);
@ -82,6 +85,17 @@ namespace VEPROMS
this.pnlExport.Size = new System.Drawing.Size(618, 199);
this.pnlExport.TabIndex = 0;
//
// btnCloseExport
//
this.btnCloseExport.Enabled = false;
this.btnCloseExport.Location = new System.Drawing.Point(562, 32);
this.btnCloseExport.Name = "btnCloseExport";
this.btnCloseExport.Size = new System.Drawing.Size(53, 23);
this.btnCloseExport.TabIndex = 12;
this.btnCloseExport.Text = "Close";
this.btnCloseExport.UseVisualStyleBackColor = true;
this.btnCloseExport.Click += new System.EventHandler(this.btnCloseExport_Click);
//
// lblExportTime
//
this.lblExportTime.AutoSize = true;
@ -193,6 +207,7 @@ namespace VEPROMS
//
// pnlImport
//
this.pnlImport.Controls.Add(this.cbxImportAudits);
this.pnlImport.Controls.Add(this.btnCloseImport);
this.pnlImport.Controls.Add(this.lblImportTime);
this.pnlImport.Controls.Add(this.lblImportStatus);
@ -211,6 +226,17 @@ namespace VEPROMS
this.pnlImport.Size = new System.Drawing.Size(618, 225);
this.pnlImport.TabIndex = 1;
//
// btnCloseImport
//
this.btnCloseImport.Enabled = false;
this.btnCloseImport.Location = new System.Drawing.Point(562, 33);
this.btnCloseImport.Name = "btnCloseImport";
this.btnCloseImport.Size = new System.Drawing.Size(53, 23);
this.btnCloseImport.TabIndex = 18;
this.btnCloseImport.Text = "Close";
this.btnCloseImport.UseVisualStyleBackColor = true;
this.btnCloseImport.Click += new System.EventHandler(this.btnCloseImport_Click);
//
// lblImportTime
//
this.lblImportTime.AutoSize = true;
@ -332,27 +358,25 @@ namespace VEPROMS
this.sfd.Filter = "PROMS Export Files|*.expx";
this.sfd.Title = "Export File Name";
//
// btnCloseExport
// cbxExportAudits
//
this.btnCloseExport.Enabled = false;
this.btnCloseExport.Location = new System.Drawing.Point(562, 32);
this.btnCloseExport.Name = "btnCloseExport";
this.btnCloseExport.Size = new System.Drawing.Size(53, 23);
this.btnCloseExport.TabIndex = 12;
this.btnCloseExport.Text = "Close";
this.btnCloseExport.UseVisualStyleBackColor = true;
this.btnCloseExport.Click += new System.EventHandler(this.btnCloseExport_Click);
this.cbxExportAudits.AutoSize = true;
this.cbxExportAudits.Location = new System.Drawing.Point(141, 47);
this.cbxExportAudits.Name = "cbxExportAudits";
this.cbxExportAudits.Size = new System.Drawing.Size(123, 17);
this.cbxExportAudits.TabIndex = 13;
this.cbxExportAudits.Text = "Include Audit History";
this.cbxExportAudits.UseVisualStyleBackColor = true;
//
// btnCloseImport
// cbxImportAudits
//
this.btnCloseImport.Enabled = false;
this.btnCloseImport.Location = new System.Drawing.Point(562, 33);
this.btnCloseImport.Name = "btnCloseImport";
this.btnCloseImport.Size = new System.Drawing.Size(53, 23);
this.btnCloseImport.TabIndex = 18;
this.btnCloseImport.Text = "Close";
this.btnCloseImport.UseVisualStyleBackColor = true;
this.btnCloseImport.Click += new System.EventHandler(this.btnCloseImport_Click);
this.cbxImportAudits.AutoSize = true;
this.cbxImportAudits.Location = new System.Drawing.Point(140, 47);
this.cbxImportAudits.Name = "cbxImportAudits";
this.cbxImportAudits.Size = new System.Drawing.Size(182, 17);
this.cbxImportAudits.TabIndex = 19;
this.cbxImportAudits.Text = "Include Audit History (if available)";
this.cbxImportAudits.UseVisualStyleBackColor = true;
//
// dlgExportImport
//
@ -408,6 +432,8 @@ namespace VEPROMS
private System.Windows.Forms.Label lblImportTime;
private System.Windows.Forms.Button btnCloseExport;
private System.Windows.Forms.Button btnCloseImport;
private System.Windows.Forms.CheckBox cbxExportAudits;
private System.Windows.Forms.CheckBox cbxImportAudits;
}
}