- Changed code to use entire (16 Character) ROID to get the Multiple Return Values

- Added code to eliminate duplicate entries for Appedix Page IDs for Multiple Return Values
Trim whitespace from beginning and end of Plot Text.
This commit is contained in:
Rich 2011-01-12 21:30:46 +00:00
parent 41e5e5d523
commit bd99a0f55c
2 changed files with 104 additions and 21 deletions

View File

@ -155,17 +155,51 @@ namespace VEPROMS.CSLA.Library
//}
// this only gets rochild values. Later we may want another
// dictionary to get groups.
public string GetRoValue(string ROID)
public string GetRoValue(string ROID16)
{
string ROID = ROID16.Substring(0,12);
if (dicRos == null) ParseIntoDictionary(_ROFst!=null?_ROFst.ROLookup:_ROFstInfo.ROLookup);
// Use the ROID to get the value from the dictionary
if (dicRos.ContainsKey(ROID))
{
rochild rochld = (rochild)dicRos[ROID];
return rochld.value;
if (rochld.value != null && rochld.value != string.Empty)
return rochld.value;
if (rochld.children != null)
{
foreach (rochild child in rochld.children)
if (child.roid.ToUpper() == ROID16)
return child.value;
}
}
return null;
}
public void ListROIDs()
{
Console.WriteLine("'roid','ParentID','ID','Value','Title'");
foreach (string roid in dicRos.Keys)
{
rochild child = dicRos[roid];
if (child.children != null)
{
Console.WriteLine("'Group','R{0}',{1},{2},{3},'{4}'", child.roid, child.ParentID, child.ID, child.type, child.title);
foreach (rochild child1 in child.children)
{
if (child1.type == 1)
Console.WriteLine("'RO','R{0}',{1},{2},{3},'{4}'", child1.roid, child1.ParentID, child1.ID, child1.type, child1.value);
else
Console.WriteLine("'RO','R{0}',{1},{2},{3}", child1.roid, child1.ParentID, child1.ID, child1.type);
}
}
else
{
if(child.type == 1)
Console.WriteLine("'RO','R{0}',{1},{2},{3},'{4}'", child.roid, child.ParentID, child.ID, child.type, child.value);
else
Console.WriteLine("'RO','R{0}',{1},{2},{3}", child.roid, child.ParentID, child.ID, child.type);
}
}
}
public rochild GetRoChild(string ROID)
{
if (dicRos == null) ParseIntoDictionary(_ROFst != null ? _ROFst.ROLookup : _ROFstInfo.ROLookup);
@ -426,7 +460,7 @@ namespace VEPROMS.CSLA.Library
for (int i = 0; i < lstROVals.Count; i++)
{
myGrp.children[i].value = lstROVals[i];
myGrp.children[i].roid = TableID.ToString("X4") + myGrp.ID.ToString("X8") + i.ToString("X4");
myGrp.children[i].roid = TableID.ToString("X4") + myGrp.ID.ToString("X8") + (0x41+i).ToString("X4");
myGrp.children[i].type = -1; // Multiple return value inherit type from parent
myGrp.children[i].title = lstROVals[i];
}
@ -704,12 +738,36 @@ namespace VEPROMS.CSLA.Library
{
foreach (rochild child in children)
{
if (child.appid != null)
_dicROAPID.Add(string.Format("{0}-{1}", prefix, child.appid), child);
if (child.appid != null && child.appid != "" && child.ID != 0)
{
string key = string.Format("{0}-{1}", prefix, child.appid);
if (_dicROAPID.ContainsKey(key))
{
rochild child1 = _dicROAPID[key];
Console.WriteLine("'Dupicate AppID','{0}',{1},'{2}',{3},{4},'{5}','{6}','{7}'",
key, child.type, child.roid, child.ParentID, child.ID, child.title, child.appid, child.value);
Console.WriteLine("'Dupicate AppID','{0}',{1},'{2}',{3},{4},'{5}','{6}','{7}'",
key, child1.type, child1.roid, child1.ParentID, child1.ID, child1.title, child1.appid, child1.value);
}
else
_dicROAPID.Add(key, child);
}
if (child.children != null)
BuildROAPIDDictionary(prefix, child.children);
}
}
private bool IsFirstReturn(rochild child)
{
if (child.roid.Length < 13) return true;
string SubID = child.roid.Substring(12);
if (SubID == "") return true;
if (SubID == "0000") return true;
if (SubID == "0001") return true;
if (SubID == "0002") return true;
Console.WriteLine("'Not First','{0}',{1},'{2}',{3},{4},'{5}','{6}'",
SubID, child.type, child.roid, child.ParentID, child.ID, child.title, child.appid);
return false;
}
private void ProcessMultiReturnValues(string str, int len)
{
string tstr = str.Substring(0, len);

View File

@ -250,9 +250,11 @@ namespace XYPlots
{
string rtnval;
int ptr;
while (BuffPtr >= 0 && Buff[BuffPtr] != 0 && isWhiteSpace(Buff[BuffPtr])) BuffPtr++;
while (BuffPtr >= 0 && BuffPtr < Buff.Length && Buff[BuffPtr] != 0 && isWhiteSpace(Buff[BuffPtr]))
BuffPtr++;
ptr = BuffPtr;
while (BuffPtr >= 0 && Buff[BuffPtr] != 0 && !isWhiteSpace(Buff[BuffPtr])) BuffPtr++;
while (BuffPtr >= 0 && BuffPtr < Buff.Length && Buff[BuffPtr] != 0 && !isWhiteSpace(Buff[BuffPtr]))
BuffPtr++;
if (EndOfCommand()) EndFlag = 1;
rtnval = Buff.Substring(ptr, BuffPtr - ptr);
BuffPtr++;
@ -261,13 +263,17 @@ namespace XYPlots
private bool EndOfCommand()
{
int tmpPtr = BuffPtr;
while (!Buff[tmpPtr].Equals('\0') && Buff[tmpPtr].Equals(' ')) tmpPtr++;
while (tmpPtr < Buff.Length && !Buff[tmpPtr].Equals('\0') && Buff[tmpPtr].Equals(' '))
tmpPtr++;
if (tmpPtr >= Buff.Length)
return true;
if (!Buff[tmpPtr].Equals('\0') && !isWhiteSpace(Buff[tmpPtr]))
return false;
else if (Buff[tmpPtr] == '\r' || Buff[tmpPtr] == '\n' || Buff[tmpPtr] == '\0')
if (Buff[tmpPtr] == '\r' || Buff[tmpPtr] == '\n' )
return true;
else
return false;
if(Buff[tmpPtr] == '\0')
return true;
return false;
}
private bool LoadBuff(string FileName)
{
@ -358,7 +364,14 @@ namespace XYPlots
double x, y;
char[] sepchar = { ',' };
string[] xystr = NextPiece().Split(sepchar);
x = double.Parse(xystr[0]);
try
{
x = double.Parse(xystr[0]);
}
catch (Exception ex)
{
throw new Exception("Error Parsing XYPlot", ex);
}
y = double.Parse(xystr[1]);
if (doLOG10[flag, X])
retval.xyValue[X] = (int)(Offset[flag, X] + Scale[flag, X] * Math.Log10(x) + .5);
@ -410,6 +423,7 @@ namespace XYPlots
private void FixBuffIfNeeded()
{
int ptr = 0;
Buff = Buff.Trim(" \r\n".ToCharArray());
if (Buff.StartsWith("<<G "))
{
Buff = Buff.Substring(4);
@ -426,14 +440,18 @@ namespace XYPlots
if (Buff[ptr + 3] == ' ')
Buff = Buff.Remove(ptr, 3);
}
ptr = Buff.Length - 5; // back up past >>\r\n
if (Buff.IndexOf(">>\r\n", ptr) > 0)
{
Buff = Buff.Remove(ptr, 2);
Buff = Buff.Insert(ptr, " ");
}
else if (Buff.EndsWith(">>")) // doesn't end with return chars...
//ptr = Buff.IndexOf(">>\r\n", Buff.Length - 5); // back up past >>\r\n
//if (ptr > 0)
//{
// Buff = Buff.Remove(ptr, 2);
// Buff = Buff.Insert(ptr, " ");
// Buff += "\0x00";
//}
//else
if (Buff.EndsWith(">>")) // doesn't end with return chars...
Buff = Buff.Substring(0, Buff.Length - 2) + " \r\n\0x00"; // needs to end with null
else
Console.WriteLine("Oopsie!");
}
private void CloseGraph()
{
@ -1795,8 +1813,15 @@ namespace XYPlots
/// <param name="PlotCommands">Plot Commands</param>
public XYPlot(string PlotCommands)
{
LoadBuffFromString(PlotCommands);
Setup();
try
{
LoadBuffFromString(PlotCommands);
Setup();
}
catch (Exception ex)
{
Console.WriteLine("{0}\r\n{1}", ex.Message, ex.StackTrace);
}
//#if DEBUG
//VG.VG_Arc.iColor = 0;
//#endif