C2021-026 Parent/Child applicability in RO Editor

This commit is contained in:
2021-07-29 18:28:12 +00:00
parent 697490d5bf
commit ce9e9e182e
16 changed files with 1103 additions and 263 deletions

View File

@@ -1,5 +1,5 @@
/*********************************************************************************************
* Copyright 2002 - Volian Enterprises, Inc. All rights reserved.
* Copyright 2021 - Volian Enterprises, Inc. All rights reserved.
* Volian Enterprises - Proprietary Information - DO NOT COPY OR DISTRIBUTE
* ------------------------------------------------------------------------------
* $Workfile: VlnXml.cs $ $Revision: 23 $
@@ -689,13 +689,78 @@ namespace RODBInterface
return rtnval;
}
private ArrayList GetApplcFieldListForElement(RODB roDatabase, VlnXmlElement elem, bool pcApplicability)
{
ArrayList rtnval = null;
ArrayList InUseApplcList = null;
ArrayList AvailList = null;
ArrayList InUseList = null;
string origFieldsInUse = "";
string origApplicFields = "";
ArrayList tmp = roDatabase.RODB_GetFields((VlnXmlElement)elem.ParentNode, (uint)RecordType.Schema);
// put the items in the AvailList box.
if (AvailList == null) AvailList = new ArrayList();
for (int i = 0; i < tmp.Count; i++) AvailList.Add(tmp[i]); // don't modify the list returned from RODB_GetFields since it is part of dictionary
InUseList = roDatabase.RODB_GetFieldsInUse((VlnXmlElement)elem.ParentNode, AvailList, "FieldsInUse", ref origFieldsInUse, false);
InUseApplcList = roDatabase.RODB_GetApplicabilityEnabledFields((VlnXmlElement)elem.ParentNode, InUseList, ref origApplicFields, pcApplicability);
rtnval = new ArrayList();
foreach (ROField rof in InUseApplcList)
rtnval.Add(rof.GetFieldname);
return rtnval;
}
private string GetPCReturnValues(RODB theDb, string[] pcChildern, VlnXmlElement elm, bool PCApplicability, string inusename, string defValue)
{
string applicValues = defValue;
ArrayList FieldsWithApplic = GetApplcFieldListForElement(theDb, elm, PCApplicability);
if (FieldsWithApplic.Contains(CvtFldToUserFld(inusename))) // C2021-026 returns True if field should show Parent/Child Applicability fields
{
XmlNode elmnode = (XmlNode)elm;
XmlNode nd = elmnode.SelectSingleNode(inusename);
string parentName = inusename;
string parentValue = "";
public string GetReturnValue(RODB theDb, string TableName,string RtnValTemplate, ArrayList InUseList, ref ushort ValueType)
if (nd == null)
{
XmlNode radNode = elmnode.FirstChild;
string radNodeName = radNode.Name;
while (radNode != null && !radNodeName.StartsWith(inusename))
{
radNode = radNode.NextSibling;
radNodeName = radNode.Name;
}
parentValue = radNode.InnerText;
parentName = radNodeName;
}
else
parentValue = nd.InnerText;
//applicValues = "";
applicValues = string.Format("<APL DefaultVal={0}", parentValue);
int pcChildIdx = 0;
foreach (string c in pcChildern)
{
//string csufx = CvtUserFldToFld(c);
pcChildIdx++;
string csufx = string.Format("_PCCHILD{0}", pcChildIdx);
applicValues += ",";
XmlNode cn = elmnode.SelectSingleNode(parentName + csufx);
if (cn == null)
applicValues += string.Format("UnitIdx={0} Value={1}", pcChildIdx, parentValue); // use parent value as default
else
applicValues += string.Format("UnitIdx={0} Value={1}", pcChildIdx, cn.InnerText);
}
applicValues += " /APL>";
}
return applicValues;
}
public string GetReturnValue(RODB theDb, string TableName, string RtnValTemplate, ArrayList InUseList, ref ushort ValueType, string[] pcChildern)
{
string RtnValStr = "";
VlnXmlElement elm = this;
StringBuilder strbld = new StringBuilder();
bool PCApplicability = (pcChildern != null && pcChildern.Length > 0);
// Parse the template for the fields and generate a return string
int left = RtnValTemplate.IndexOf("<"); // look for begining of field
int right = -1;
@@ -762,6 +827,8 @@ namespace RODBInterface
}
ValueType |= FldType;
if (PCApplicability)
text = GetPCReturnValues(theDb, pcChildern, elm, PCApplicability, inusename, text); // C2021-026 Get P/C Children return values
strbld.Append(text);
}
else
@@ -789,6 +856,7 @@ namespace RODBInterface
return RtnValStr;
}
public string GetComboFieldValueAndType(XmlNode CurNode, string Fld, ref ushort FldTyp, bool ForMenu)
{
string RtnVal = "";
@@ -929,52 +997,52 @@ namespace RODBInterface
///
// ShowGroupDetail sends to print.tmp the data for a Group level.
private bool ShowGroupDetail(RODB myrodb)
{
ROField rof;
XmlNode nd;
VlnXmlDocument xmldoc = (VlnXmlDocument) this.OwnerDocument;
string nm;
//private bool ShowGroupDetail(RODB myrodb)
//{
// ROField rof;
// XmlNode nd;
// VlnXmlDocument xmldoc = (VlnXmlDocument) this.OwnerDocument;
// string nm;
// First get the fields used for this Group.
string tmp=null; // needed for inuse call
ArrayList AvailList = myrodb.RODB_GetFields(this, 0);
ArrayList InUseList = myrodb.RODB_GetFieldsInUse(this, AvailList, "GroupFieldsInUse", ref tmp, false);
// // First get the fields used for this Group.
// string tmp=null; // needed for inuse call
// ArrayList AvailList = myrodb.RODB_GetFields(this, 0);
// ArrayList InUseList = myrodb.RODB_GetFieldsInUse(this, AvailList, "GroupFieldsInUse", ref tmp, false);
// For each field, print the header (field name) & then print data if it exists.
if (InUseList != null)
{
xmldoc.writeRROBegin();
xmldoc.writeInt(7);
xmldoc.writeText(" ");
// // For each field, print the header (field name) & then print data if it exists.
// if (InUseList != null)
// {
// xmldoc.writeRROBegin();
// xmldoc.writeInt(7);
// xmldoc.writeText(" ");
for (int i=0; i< InUseList.Count; i++)
{
rof = (ROField) InUseList[i];
if (rof.GetFieldname != null)
{
string nm0 = rof.GetFieldname;
nm = rof.MakeFieldName(nm0);
xmldoc.pushHeader(nm0);
// see if it has data in the ro.
nd = this.SelectSingleNode(nm);
// if not found with just the string, search the tree.
if (nd==null)nd = this.SelectSingleNode("*/"+nm);
if (nd == null) // not found, write out a '0'.
xmldoc.writeInt(0);
else
{
VlnXmlElement end;
end = (VlnXmlElement) nd;
xmldoc.writeTextValue(end.InnerText);
}
xmldoc.popHeader();
}
}
xmldoc.writeRROEnd();
}
return true;
}
// for (int i=0; i< InUseList.Count; i++)
// {
// rof = (ROField) InUseList[i];
// if (rof.GetFieldname != null)
// {
// string nm0 = rof.GetFieldname;
// nm = rof.MakeFieldName(nm0);
// xmldoc.pushHeader(nm0);
// // see if it has data in the ro.
// nd = this.SelectSingleNode(nm);
// // if not found with just the string, search the tree.
// if (nd==null)nd = this.SelectSingleNode("*/"+nm);
// if (nd == null) // not found, write out a '0'.
// xmldoc.writeInt(0);
// else
// {
// VlnXmlElement end;
// end = (VlnXmlElement) nd;
// xmldoc.writeTextValue(end.InnerText);
// }
// xmldoc.popHeader();
// }
// }
// xmldoc.writeRROEnd();
// }
// return true;
//}
public XmlNode GetCurrentOfMultiFields(VlnXmlElement CurElement, string FldName)
{
@@ -997,6 +1065,19 @@ namespace RODBInterface
return nd;
}
private bool ContainedInArrayList(ROField rof, ArrayList aryList)
{
bool isInList = false;
foreach (ROField arof in aryList)
{
if (arof.GetRecID == rof.GetRecID)
{
isInList = true;
break;
}
}
return isInList;
}
// ShowRRO writes data for the input RO.
private bool ShowRRO(RODB myrodb, ArrayList headers)
{
@@ -1010,7 +1091,8 @@ namespace RODBInterface
string tmp=null; // needed for inuse call
ArrayList AvailList = myrodb.RODB_GetFields(this, 0);
ArrayList InUseList = myrodb.RODB_GetFieldsInUse(this, AvailList, "FieldsInUse", ref tmp, false);
ArrayList InUseApplcList = myrodb.RODB_GetApplicabilityEnabledFields(this, InUseList, ref tmp, HasApplicabilityEnabled); // C2021-026 get fields that have P/C Children
string defPCROval = "";
// put out the stored headers, i.e. the group titles up the tree.
xmldoc.doHeader(headers);
@@ -1094,13 +1176,33 @@ namespace RODBInterface
if (doingplot)
xmldoc.writePlot(end.InnerText);
else
{
xmldoc.writeTextValue(end.InnerText);
defPCROval = end.InnerText;
}
}
}
// C2021_026 put out PC children values
if (ContainedInArrayList(rof,InUseApplcList))
{
XmlNode pcn;
int pcChildIdx = 0;
foreach (string s in PCChildren)
{
pcChildIdx++;
string pcName = nd.Name + string.Format("_PCCHILD{0}", pcChildIdx); // create child field name
string pcField = rof.MakeFieldName(pcName);
xmldoc.pushHeader(" "+s); // put out the PC Child name (indented 5 spaces) for complete RO Report
// see if it has data in the ro.
pcn = this.SelectSingleNode(pcField);
if (pcn != null)
xmldoc.writeTextValue(pcn.InnerText); // use PC Child value
else
xmldoc.writeTextValue(defPCROval); // use default value
}
}
xmldoc.popHeader();
}
}
xmldoc.writeRROEnd();
}
@@ -1184,12 +1286,21 @@ namespace RODBInterface
headers.RemoveAt(headers.Count-1);
return true;
}
private static string[] PCChildren = null; //C2021-026 holds list of P/C children names
public bool HasApplicabilityEnabled
{
get
{
return (PCChildren != null && PCChildren.Length > 0);
}
}
// put this element, and if a group all it's subelements out to the 'print.tmp'
// file for complete reports.
public bool Show(RODB myrodb, ArrayList headers, VlnStatusMessage showStat)
public bool Show(RODB myrodb, ArrayList headers, VlnStatusMessage showStat, string [] pcChildren)
{
bool success;
PCChildren = pcChildren; // C2021-026 list of P/C children
VlnXmlDocument xmldoc = (VlnXmlDocument) this.OwnerDocument;
success = xmldoc.OpenTemp();
if (success==false) return false;