Added code to handle Table ROs.

Used generic (static) VlnFlexGrid.ROTableUpdate to determine if the table contents are updated.
Added Error Handling around the code that shuts down PROMs
Added function to ROFSTLookup to retrieve the Accessory Page ID.
Corrected code to handle value changes for Table ROs
Created generic (static) VlnFlexGrid.ROTableUpdate to determine if the table contents are updated.
This commit is contained in:
Rich 2014-03-19 15:30:26 +00:00
parent cf79d6a313
commit 0376212e09
9 changed files with 200 additions and 109 deletions

View File

@ -83,9 +83,9 @@ namespace DataLoader
ContentInfo myContentInfo = ContentInfo.Get(cid);
DocVersionInfo dvi = myContentInfo.ContentItems[0].MyProcedure.MyDocVersion;
int versionId = dvi.VersionID;
ROFstInfo myRoFst = dvi.DocVersionAssociations[0].MyROFst;
if (!roFstLookups.ContainsKey(versionId))
{
ROFstInfo myRoFst = dvi.DocVersionAssociations[0].MyROFst;
roFstLookups.Add(versionId, myRoFst.GetROFSTLookup(dvi));
}
ROFSTLookup myLookup = roFstLookups[versionId];
@ -94,26 +94,28 @@ namespace DataLoader
ItemInfo ii = myContentInfo.ContentItems[0];
foreach (RoUsageInfo ru in myContentInfo.ContentRoUsages)
{
//ROFSTLookup.rochild rocc = myLookup.GetRoChild12(ru.ROID);
//if (rocc.value == null)
ROFSTLookup.rochild rocc = myLookup.GetRoChild(ru.ROID);
//string myValue = rocc.value;
ROFSTLookup.rochild rocc = myLookup.GetRoChild12(ru.ROID);
if (rocc.value == null)
rocc = myLookup.GetRoChild(ru.ROID);
int myType = rocc.type;
string myValue = myLookup.GetTranslatedRoValue(ru.ROID, ii.ActiveFormat.PlantFormat.FormatData.SectData.ConvertCaretToDelta);
myValue = myValue.Replace(@"\up2 \u8209?", @"\up2\u8209?");// Remove space between superscript command and non-breaking hyphen
myValue = myValue.Replace("\n", "");// Remove newlines in Figure data
string oldval = ctmp.FixContentText(ru, myValue, myType, null);
if (myType == 8 && myValue.Contains("\n"))
myValue = myValue.Replace("\n", "");// Remove newlines in Figure data
myRoFst.ROTableUpdate += new ROFstInfoROTableUpdateEvent(myRoFst_ROTableUpdate);
string oldval = ctmp.FixContentText(ru, myValue, myType, myRoFst);
myRoFst.ROTableUpdate -= new ROFstInfoROTableUpdateEvent(myRoFst_ROTableUpdate);
if (ctmp.IsDirty)
{
changeCount++;
//Console.WriteLine("'{0}', '{1}', '{2}', '{3}'", replace(oldval, @"\u8209?", "-"), replace(myValue, @"\u8209?", "-"), ru.ROID, rocc.appid);
frmMain.AddInfo("'{0}','{1}','R{2}'", (oldval??"").Replace(@"\u8209?", "-"), myValue.Replace(@"\u8209?", "-"), ru.ROID);
changeCount++;
//Console.WriteLine("'{0}', '{1}', '{2}', '{3}'", replace(oldval, @"\u8209?", "-"), replace(myValue, @"\u8209?", "-"), ru.ROID, rocc.appid);
frmMain.AddInfo("'{0}','{1}','{2}','{3}','R{4}','{5}'", ii.MyDocVersion.MyFolder.Name, ii.ShortPath,
(oldval ?? "").Replace(@"\u8209?", "-"), myValue.Replace(@"\u8209?", "-"), ru.ROID, myLookup.GetAccPageID(ru.ROID));
}
}
if (ctmp.IsDirty)
{
ctmp.DTS = DateTime.Now;
//ctmp.DTS = DateTime.Now;
ctmp.Save();
ContentInfo.Refresh(ctmp);
}
@ -122,5 +124,9 @@ namespace DataLoader
frmMain.AddInfo("{0} RO Values Updated", changeCount);
MessageBox.Show(String.Format("{0} RO Values Updated", changeCount), "RO Value Update Complete", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
private List<string> myRoFst_ROTableUpdate(object sender, ROFstInfoROTableUpdateEventArgs args)
{
return Volian.Controls.Library.VlnFlexGrid.ROTableUpdate(sender,args);
}
}
}

View File

@ -687,7 +687,14 @@ namespace VEPROMS
// RHM 20121010
// Something was causing the process to remain in memory for an extended period of time
// after printing procedures. The following lines kills the process immediately.
System.Diagnostics.Process.GetCurrentProcess().Kill();
try
{
System.Diagnostics.Process.GetCurrentProcess().Kill();
}
catch (Exception ex)
{
_MyLog.Warn("Attempting to Close", ex);
}
}
// Get the "Procedures" Panel Heading (title).
// by default the heading is "Procedures" (handled in the getting from the config)

View File

@ -161,6 +161,22 @@ namespace VEPROMS.CSLA.Library
if (dicRos != null)dicRos.Clear();
dicRos = null;
}
private Dictionary<string, string> _dicROAPIDLookup;
public string GetAccPageID(string roid)
{
if(_dicROAPIDLookup==null)
{
_dicROAPIDLookup = new Dictionary<string,string>();
if (_dicROAPID == null)
BuildROAPIDDictionary();
foreach (string appid in _dicROAPID.Keys)
_dicROAPIDLookup.Add(_dicROAPID[appid].roid,appid);
}
String roidkey = roid.Substring(0, 12).ToUpper();
if(_dicROAPIDLookup.ContainsKey(roidkey))
return _dicROAPIDLookup[roidkey];
return null;
}
public List<string> GetValueDifferences(ROFSTLookup origROFst, ref List<string> delList)
{
// use this list to see what differences are between it and the original

View File

@ -1550,12 +1550,12 @@ namespace VEPROMS.CSLA.Library
if (InfoRestored != null)
InfoRestored(this);
}
public ItemInfo RestoreSibling(ItemAuditInfo iai)
public ItemInfo RestoreSibling(ItemAuditInfo iai,ROFstInfo myRoFst)
{
if (iai.DeleteStatus == 0)
return null;
int nextID = iai.Level == 0 ? ItemID : NextItem == null ? 0 : NextItem.ItemID;
ItemInfo tmp = RestoreItem(iai);
ItemInfo tmp = RestoreItem(iai, myRoFst);
if(nextID > 0)
using (Item item = Item.Get(nextID)) ItemInfo.Refresh(item);
if (iai.Level == 0)
@ -1567,7 +1567,7 @@ namespace VEPROMS.CSLA.Library
tmp.OnInfoRestored(tmp);
return tmp;
}
public ItemInfo RestoreItem(ItemAuditInfo iai)
public ItemInfo RestoreItem(ItemAuditInfo iai, ROFstInfo myRoFst)
{
ItemInfo tmp2 = null;
try
@ -1606,15 +1606,15 @@ namespace VEPROMS.CSLA.Library
}
if (cont.ContentRoUsageCount > 0)
{
ROFstInfo myrofst = tmp.MyContent.ContentItems[0].MyProcedure.MyDocVersion.DocVersionAssociations[0].MyROFst;
ROFSTLookup mylookup = myrofst.GetROFSTLookup(tmp.MyContent.ContentItems[0].MyProcedure.MyDocVersion);
//ROFstInfo myrofst = tmp.MyDocVersion.DocVersionAssociations[0].MyROFst;
ROFSTLookup mylookup = myRoFst.GetROFSTLookup(tmp.MyContent.ContentItems[0].MyProcedure.MyDocVersion);
foreach (ContentRoUsage ro in cont.ContentRoUsages)
{
RoUsageInfo rou = RoUsageInfo.Get(ro.ROUsageID);
string myvalue = mylookup.GetTranslatedRoValue(rou.ROID, tmp.ActiveFormat.PlantFormat.FormatData.SectData.ConvertCaretToDelta);
ROFSTLookup.rochild rocc = mylookup.GetRoChild(rou.ROID);
int mytype = rocc.type;
cont.FixContentText(rou, myvalue, mytype, null);
cont.FixContentText(rou, myvalue, mytype, myRoFst);
}
Content cctmp = cont;
if (cont.IsDirty)
@ -1770,7 +1770,7 @@ namespace VEPROMS.CSLA.Library
public partial class ContentInfo
{
public static ContentInfo RestoreContent(ContentAuditInfo cai)
public static ContentInfo RestoreContent(ContentAuditInfo cai,ROFstInfo myRoFst)
{
try
{
@ -1800,14 +1800,14 @@ namespace VEPROMS.CSLA.Library
}
ctmp.Save();
}
ROFstInfo myrofst = tmp.ContentItems[0].MyProcedure.MyDocVersion.DocVersionAssociations[0].MyROFst;
ROFSTLookup mylookup = myrofst.GetROFSTLookup(tmp.ContentItems[0].MyProcedure.MyDocVersion);
//ROFstInfo myrofst = tmp.ContentItems[0].MyProcedure.MyDocVersion.DocVersionAssociations[0].MyROFst;
ROFSTLookup mylookup = myRoFst.GetROFSTLookup(tmp.ContentItems[0].MyProcedure.MyDocVersion);
foreach(RoUsageInfo rou in tmp.ContentRoUsages)
{
string myvalue = mylookup.GetTranslatedRoValue(rou.ROID, tmp.ContentItems[0].ActiveFormat.PlantFormat.FormatData.SectData.ConvertCaretToDelta);
ROFSTLookup.rochild rocc = mylookup.GetRoChild(rou.ROID);
int mytype = rocc.type;
ctmp.FixContentText(rou, myvalue, mytype, null);
ctmp.FixContentText(rou, myvalue, mytype, myRoFst);
}
Content cctmp = ctmp;
if (ctmp.IsDirty)

View File

@ -79,9 +79,17 @@ namespace VEPROMS.CSLA.Library
{
if (rotype == (int)E_ROValueType.Table) // if change in rotable data...
{
List<string> retlist = origROFstInfo.OnROTableUpdate(this, new ROFstInfoROTableUpdateEventArgs(newvalue, MyGrid.Data));
if (Text != retlist[0]) Text = retlist[0];
if (MyGrid.Data != retlist[1]) MyGrid.Data = retlist[1];
if (origROFstInfo != null)
{
List<string> retlist = origROFstInfo.OnROTableUpdate(this, new ROFstInfoROTableUpdateEventArgs(newvalue, MyGrid.Data));
if (MyGrid.Data != retlist[1])
{
MyGrid.Data = retlist[1];
retval = Text;
if (Text != retlist[0])
Text = retlist[0];
}
}
}
else
{

View File

@ -591,7 +591,10 @@ namespace Volian.Controls.Library
ContentAuditInfo cai = tn.Tag as ContentAuditInfo;
if (MessageBox.Show(this, "Do you want to restore this content change?", "Confirm Content Change Restore", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) == DialogResult.Yes)
{
ContentInfo ci = ContentInfo.RestoreContent(cai);
ROFstInfo myRoFst = MyItemInfo.MyDocVersion.DocVersionAssociations[0].MyROFst;
myRoFst.ROTableUpdate += new ROFstInfoROTableUpdateEvent(myRoFst_ROTableUpdate);
ContentInfo ci = ContentInfo.RestoreContent(cai,myRoFst);
myRoFst.ROTableUpdate += new ROFstInfoROTableUpdateEvent(myRoFst_ROTableUpdate);
RefreshRequired = true;
UpdateHistory();
myRTB.Clear();
@ -609,8 +612,10 @@ namespace Volian.Controls.Library
ItemInfo ii = null;
if (iai.Level == 2)
{
ii = MyItemInfo.RestoreItem(iai);
ROFstInfo myRoFst = MyItemInfo.MyDocVersion.DocVersionAssociations[0].MyROFst;
myRoFst.ROTableUpdate += new ROFstInfoROTableUpdateEvent(myRoFst_ROTableUpdate);
ii = MyItemInfo.RestoreItem(iai,myRoFst);
myRoFst.ROTableUpdate -= new ROFstInfoROTableUpdateEvent(myRoFst_ROTableUpdate);
//_MyEditItem.AddChild((E_FromType)fromtype, contenttype);
//ii.ItemParts[0].FromType
//ii.MyContent.Type
@ -674,7 +679,10 @@ namespace Volian.Controls.Library
}
else
{
ii = MyItemInfo.RestoreSibling(iai);
ROFstInfo myRoFst = MyItemInfo.MyDocVersion.DocVersionAssociations[0].MyROFst;
myRoFst.ROTableUpdate += new ROFstInfoROTableUpdateEvent(myRoFst_ROTableUpdate);
ii = MyItemInfo.RestoreSibling(iai,myRoFst);
myRoFst.ROTableUpdate -= new ROFstInfoROTableUpdateEvent(myRoFst_ROTableUpdate);
if (ii.IsStep)
ii = StepInfo.Get(ii.ItemID);
else if (ii.IsSection)
@ -729,7 +737,10 @@ namespace Volian.Controls.Library
if (MessageBox.Show(this, "Do you want to restore this table?", "Confirm Table Restore", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) == DialogResult.Yes)
{
ContentAuditInfo cai = ContentAuditInfo.Get(gai.ContentAuditID);
ContentInfo ci = ContentInfo.RestoreContent(cai);
ROFstInfo myRoFst = MyItemInfo.MyDocVersion.DocVersionAssociations[0].MyROFst;
myRoFst.ROTableUpdate += new ROFstInfoROTableUpdateEvent(myRoFst_ROTableUpdate);
ContentInfo ci = ContentInfo.RestoreContent(cai,myRoFst);
myRoFst.ROTableUpdate -= new ROFstInfoROTableUpdateEvent(myRoFst_ROTableUpdate);
RefreshRequired = true;
UpdateHistory();
myRTB.Clear();
@ -737,6 +748,11 @@ namespace Volian.Controls.Library
}
}
}
List<string> myRoFst_ROTableUpdate(object sender, ROFstInfoROTableUpdateEventArgs args)
{
return VlnFlexGrid.ROTableUpdate(sender, args);
}
private void DisplayTagRTF(TreeNode tn)
{
if (tn.Tag != null)

View File

@ -1759,45 +1759,46 @@ namespace Volian.Controls.Library
public List<string> roFstInfo_ROTableUpdate(object sender, ROFstInfoROTableUpdateEventArgs args)
{
string xml = null;
string srchtxt = null;
Content content = (Content)sender;
using (VlnFlexGrid myGrid = new VlnFlexGrid(content.ContentItems[0]))
{
using (StringReader sr = new StringReader(args.OldGridXml))
{
myGrid.ReadXml(sr);
sr.Close();
}
string roid = content.ContentRoUsages[0].ROID; //myGrid.ROID;
int rodbid = content.ContentRoUsages[0].RODbID; //myGrid.RODbId;
////Font GridFont = myGrid.Font;
//myGrid.MergedRanges.Clear();
//myGrid.Clear();
//myGrid.ParseTableFromText(args.ROText);
//myGrid.AutoSizeCols();
//myGrid.AutoSizeRows();
//myGrid.MakeRTFcells();
//myGrid.RODbId = rodbid;
//myGrid.ROID = roid;
//myGrid.IsRoTable = true;
myGrid.Visible = false;
myGrid.ConvertTableROToGrid(args.ROText, rodbid, roid);
myGrid.FixTableCellsHeightWidth();
myGrid.AdjustGridControlSize();
myGrid.Visible = true;
using (StringWriter sw = new StringWriter())
{
myGrid.WriteXml(sw);
xml = sw.GetStringBuilder().ToString();
sw.Close();
}
srchtxt = myGrid.GetSearchableText();
}
List<string> retlist = new List<string>();
retlist.Add(srchtxt);
retlist.Add(xml);
return retlist;
return VlnFlexGrid.ROTableUpdate(sender, args);
//string xml = null;
//string srchtxt = null;
//Content content = (Content)sender;
//using (VlnFlexGrid myGrid = new VlnFlexGrid(content.ContentItems[0]))
//{
// using (StringReader sr = new StringReader(args.OldGridXml))
// {
// myGrid.ReadXml(sr);
// sr.Close();
// }
// string roid = content.ContentRoUsages[0].ROID; //myGrid.ROID;
// int rodbid = content.ContentRoUsages[0].RODbID; //myGrid.RODbId;
// ////Font GridFont = myGrid.Font;
// //myGrid.MergedRanges.Clear();
// //myGrid.Clear();
// //myGrid.ParseTableFromText(args.ROText);
// //myGrid.AutoSizeCols();
// //myGrid.AutoSizeRows();
// //myGrid.MakeRTFcells();
// //myGrid.RODbId = rodbid;
// //myGrid.ROID = roid;
// //myGrid.IsRoTable = true;
// myGrid.Visible = false;
// myGrid.ConvertTableROToGrid(args.ROText, rodbid, roid);
// myGrid.FixTableCellsHeightWidth();
// myGrid.AdjustGridControlSize();
// myGrid.Visible = true;
// using (StringWriter sw = new StringWriter())
// {
// myGrid.WriteXml(sw);
// xml = sw.GetStringBuilder().ToString();
// sw.Close();
// }
// srchtxt = myGrid.GetSearchableText();
//}
//List<string> retlist = new List<string>();
//retlist.Add(srchtxt);
//retlist.Add(xml);
//return retlist;
}
private void rtabAdmin_Click(object sender, EventArgs e)

View File

@ -114,10 +114,10 @@ namespace Volian.Controls.Library
{
get
{
return IsGridChanged(this._MyItemInfo.MyContent.MyGrid.Data, this.GetXMLData());
return IsGridChanged(this._MyItemInfo.MyContent.MyGrid.Data, this.GetXMLData(), true);
}
}
private bool IsGridChanged(string oldXml, string newXml)
private bool IsGridChanged(string oldXml, string newXml, bool checkFormat)
{
if (this.TableCellEditor.Text.Contains("<NewID>"))
return false;
@ -126,16 +126,16 @@ namespace Volian.Controls.Library
XmlDocument XdNew = new XmlDocument();
XdNew.LoadXml(AdjustHeightAndWidthForDPI(newXml));
//check volian borders 1st
if (XdNew.SelectSingleNode("C1FlexGrid/Control/MyBorderDetailString").InnerText != XdOld.SelectSingleNode("C1FlexGrid/Control/MyBorderDetailString").InnerText)
if (checkFormat && XdNew.SelectSingleNode("C1FlexGrid/Control/MyBorderDetailString").InnerText != XdOld.SelectSingleNode("C1FlexGrid/Control/MyBorderDetailString").InnerText)
return true;
//check row/col sizes 2nd
if (GetRowColSizeString(XdNew) != GetRowColSizeString(XdOld))
if (checkFormat && ( GetRowColSizeString(XdNew) != GetRowColSizeString(XdOld)))
return true;
//check for cell data changes 3rd
if (GetCellDataString(XdNew) != GetCellDataString(XdOld))
return true;
//check for cell format changes 4th
if (GetCellFormatString(XdNew) != GetCellFormatString(XdOld))
if (checkFormat && GetCellFormatString(XdNew) != GetCellFormatString(XdOld))
return true;
//check for merged cells 5th
if (GetCellMergeString(XdNew) != GetCellMergeString(XdOld))
@ -3589,7 +3589,43 @@ namespace Volian.Controls.Library
rtn = ofd.SafeFileName;
return rtn;
}
public static List<string> ROTableUpdate(object sender, ROFstInfoROTableUpdateEventArgs args)
{
string xml = null;
string srchtxt = null;
Content content = (Content)sender;
bool isdirty = false;
using (VlnFlexGrid myGrid = new VlnFlexGrid(content.ContentItems[0]))
{
using (StringReader sr = new StringReader(args.OldGridXml))
{
myGrid.ReadXml(sr);
sr.Close();
}
string roid = content.ContentRoUsages[0].ROID; //myGrid.ROID;
int rodbid = content.ContentRoUsages[0].RODbID; //myGrid.RODbId;
myGrid.Visible = false;
myGrid.ConvertTableROToGrid(args.ROText, rodbid, roid);
myGrid.FixTableCellsHeightWidth();
myGrid.AdjustGridControlSize();
myGrid.Visible = true;
using (StringWriter sw = new StringWriter())
{
myGrid.WriteXml(sw);
xml = sw.GetStringBuilder().ToString();
sw.Close();
}
srchtxt = myGrid.GetSearchableText();
isdirty = myGrid.IsGridChanged(args.OldGridXml, xml, false);
}
List<string> retlist = new List<string>();
retlist.Add(srchtxt);
if(isdirty)
retlist.Add(xml);
else
retlist.Add(args.OldGridXml);
return retlist;
}
public void ConvertTableROToGrid(string valtext, int rodbid, string roid)
{
VE_Font vefont = _MyItemInfo.GetItemFont();

View File

@ -1302,39 +1302,40 @@ namespace Volian.Controls.Library
}
public List<string> roFstInfo_ROTableUpdate(object sender, ROFstInfoROTableUpdateEventArgs args)
{
string xml = null;
string srchtxt = null;
using (VlnFlexGrid myGrid = new VlnFlexGrid())
{
using (StringReader sr = new StringReader(args.OldGridXml))
{
myGrid.ReadXml(sr);
myGrid.KeyActionTab = C1.Win.C1FlexGrid.KeyActionEnum.MoveAcross;
sr.Close();
}
string roid = myGrid.ROID;
int rodbid = myGrid.RODbId;
Font GridFont = myGrid.Font;
myGrid.Clear();
myGrid.ParseTableFromText(args.ROText, GridLinePattern.Single);
myGrid.AutoSizeCols();
myGrid.AutoSizeRows();
myGrid.MakeRTFcells();
myGrid.RODbId = rodbid;
myGrid.ROID = roid;
myGrid.IsRoTable = true;
using (StringWriter sw = new StringWriter())
{
myGrid.WriteXml(sw);
xml = sw.GetStringBuilder().ToString();
sw.Close();
}
srchtxt = myGrid.GetSearchableText();
}
List<string> retlist = new List<string>();
retlist.Add(srchtxt);
retlist.Add(xml);
return retlist;
return VlnFlexGrid.ROTableUpdate(sender, args);
//string xml = null;
//string srchtxt = null;
//using (VlnFlexGrid myGrid = new VlnFlexGrid())
//{
// using (StringReader sr = new StringReader(args.OldGridXml))
// {
// myGrid.ReadXml(sr);
// myGrid.KeyActionTab = C1.Win.C1FlexGrid.KeyActionEnum.MoveAcross;
// sr.Close();
// }
// string roid = myGrid.ROID;
// int rodbid = myGrid.RODbId;
// Font GridFont = myGrid.Font;
// myGrid.Clear();
// myGrid.ParseTableFromText(args.ROText, GridLinePattern.Single);
// myGrid.AutoSizeCols();
// myGrid.AutoSizeRows();
// myGrid.MakeRTFcells();
// myGrid.RODbId = rodbid;
// myGrid.ROID = roid;
// myGrid.IsRoTable = true;
// using (StringWriter sw = new StringWriter())
// {
// myGrid.WriteXml(sw);
// xml = sw.GetStringBuilder().ToString();
// sw.Close();
// }
// srchtxt = myGrid.GetSearchableText();
//}
//List<string> retlist = new List<string>();
//retlist.Add(srchtxt);
//retlist.Add(xml);
//return retlist;
}
private void RunROEditor(VETreeNode tn)