Several adjustments on filling xml with data
This commit is contained in:
@ -15,6 +15,12 @@ using System.Reflection;
|
||||
using System.IO;
|
||||
using System.Resources;
|
||||
|
||||
//---------------------------förändrings krav---------------------------
|
||||
// 1.) Indexerande mellannivåer där count-måste sättas får inte hoppas över !
|
||||
//
|
||||
//
|
||||
//
|
||||
//----------------------------------------------------------------------
|
||||
namespace CobXmlSupport
|
||||
{
|
||||
|
||||
@ -791,6 +797,113 @@ namespace CobXmlSupport
|
||||
|
||||
genCode.ShowDialog();
|
||||
}
|
||||
|
||||
private void btnGenICodeNew_Click(object sender, EventArgs e)
|
||||
{
|
||||
bool justOut = true;
|
||||
bool loopTyp = false;
|
||||
|
||||
Dictionary<string, string> indexNames = new Dictionary<string, string>();
|
||||
string IndVarText = " *--------------------------------------------------*\r\n * Extra indexvariabler för occurs-taggar --------*\r\n *--------------------------------------------------*";
|
||||
string slask = "";
|
||||
genCode = new ShowCode();
|
||||
genCode.Parent = this;
|
||||
genCode.Labeltext = "Creating Initialization Code";
|
||||
string inFile = cmbLastFile.Text.Substring(cmbLastFile.Text.LastIndexOf("\\") + 1);
|
||||
CreateComment(genCode.CodeShower, "Initializer", S.ettingUserName, S.ettingCompany, inFile);
|
||||
genCode.CodeShower.Text += "\r\n";
|
||||
|
||||
//Dictionary for indexes, init IndexState class and list for qualifiedHelper class
|
||||
Dictionary<string, string> testIndexes = new Dictionary<string, string>();
|
||||
IndexState lIs = new IndexState(testIndexes, rowList);
|
||||
qldList = new List<qualifieldhlp>();
|
||||
|
||||
foreach (CobRow cr in rowList)
|
||||
{
|
||||
// if (cr.isAttribute)
|
||||
// {
|
||||
qualifieldhlp tmpQlh = new qualifieldhlp(cr, lIs.Indexes);
|
||||
qldList.Add(tmpQlh);
|
||||
//string occParRows = "";
|
||||
//CobRow crTmp = cr;
|
||||
//genCode.CodeShower.Text += "\r\n " + "MOVE " + cr.Value + "\r\n TO " + cr.FieldName;
|
||||
//while (crTmp.LevelParent != null)
|
||||
//{
|
||||
// crTmp = crTmp.LevelParent;
|
||||
// genCode.CodeShower.Text += "\r\n OF " + crTmp.FieldName;
|
||||
// genCode.CodeShower.Text = checkForOccurs(indexNames, crTmp, genCode.CodeShower.Text, ref occParRows, ref slask);
|
||||
//}
|
||||
//if (occParRows.Length > 0)
|
||||
//{
|
||||
// genCode.CodeShower.Text += " (" + occParRows + " )\r\n";
|
||||
//}
|
||||
// }
|
||||
}
|
||||
|
||||
//Indstatus keep track on present changings concerning indexes qualifying each qualified XML-record-field
|
||||
|
||||
IndStatus indSt = new IndStatus();
|
||||
|
||||
//here comes the central work-loop
|
||||
foreach (qualifieldhlp tmpQfh in qldList)
|
||||
{
|
||||
//IndStatus-object takes care of optionally occuring indexes
|
||||
indSt.handleStatus(tmpQfh.indexStrings);
|
||||
|
||||
//If indexes get out of scope there will come an END-PERFORM for each
|
||||
for (int i = 0; i < indSt.Returns; i++)
|
||||
{
|
||||
genCode.CodeShower.Text += " END-PERFORM" + "\r\n";
|
||||
}
|
||||
|
||||
//Each index comming into scope will start a new PERFORM VARYING loop
|
||||
if (indSt.NewInds != null)
|
||||
{
|
||||
foreach (string indTxt in indSt.NewInds)
|
||||
{
|
||||
//Perform
|
||||
|
||||
//genCode.CodeShower.Text += " PERFORM VARYING " + indTxt + " FROM 1 BY 1\r\n UNTIL " +
|
||||
//indTxt + "\r\n > " + tmpQfh.qualCobRow.CountIn.ToString() + "\r\n" + tmpQfh.indexRedText;
|
||||
|
||||
genCode.CodeShower.Text += " PERFORM VARYING " + indTxt + " FROM 1 BY 1\r\n UNTIL " +
|
||||
indTxt + "\r\n > " + tmpQfh.qualCobRow.occNum.ToString() + "\r\n"; // +tmpQfh.indexRedText;
|
||||
|
||||
if (tmpQfh.qualCobRow.isOccurs) slask = "";
|
||||
}
|
||||
}
|
||||
|
||||
if (tmpQfh.qualCobRow.isAttribute)
|
||||
{
|
||||
//when xml-record-field with occurs, the last index shall not be used (then use tmpQfh.indexRedText instead of tmpQfh.indexText
|
||||
//loopTyp = tmpQfh.qualCobRow.isOccurs;
|
||||
//genCode.CodeShower.Text += " IF " + tmpQfh.qualCobRow.CountIn.ToString() + "\r\n" + (string)(loopTyp ? tmpQfh.indexRedText : tmpQfh.indexText) + " > 0 \r\n";
|
||||
|
||||
//The acutal move of present fields
|
||||
genCode.CodeShower.Text += " MOVE " + tmpQfh.qualCobRow.Value;
|
||||
|
||||
genCode.CodeShower.Text += "\r\n TO " + tmpQfh.ToString() + "\r\n";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// get optionally occuring last END-PERFORMs...
|
||||
|
||||
indSt.handleStatus(null);
|
||||
for (int i = 0; i < indSt.Returns; i++)
|
||||
{
|
||||
genCode.CodeShower.Text += " END-PERFORM" + "\r\n";
|
||||
}
|
||||
|
||||
|
||||
//List all used indexes
|
||||
string tempIndText = "";
|
||||
genCode.CodeShower.Text = addOccursVars(testIndexes, genCode.CodeShower.Text, tempIndText);
|
||||
|
||||
genCode.ShowDialog();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// creates declaration for generated index-variables (in checkForOccurs())
|
||||
/// </summary>
|
||||
@ -1103,7 +1216,6 @@ namespace CobXmlSupport
|
||||
setWindow.ShowDialog();
|
||||
S.ettingUserName = setWindow.UserName;
|
||||
S.ettingCompany = setWindow.CompanyName;
|
||||
|
||||
S.ettingNoNsRef = setWindow.ChkNoNsRef;
|
||||
S.ettingUniqueVars = setWindow.ChkUniqueVars;
|
||||
S.ettingUniqueAttrVars = setWindow.ChkUniqueAttrVars;
|
||||
@ -1511,7 +1623,7 @@ namespace CobXmlSupport
|
||||
|
||||
if (cr.MoveFromCode.Trim().Length > 0)
|
||||
{
|
||||
fromMoves.CodeShower.Text += "\r\n " + adjustIf(adj) + cr.MoveFromCode +" delimited by \" \" ";
|
||||
fromMoves.CodeShower.Text += "\r\n " + adjustIf(adj) + cr.MoveFromCode + " delimited by \" \" ";
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1878,61 +1990,80 @@ namespace CobXmlSupport
|
||||
fromToMoves.CodeShower.Text += "\r\n";
|
||||
}
|
||||
|
||||
//IndStatus-object takes care of optionally occuring indexes
|
||||
indSt.handleStatus(tmpQfh.indexStrings);
|
||||
|
||||
//If indexes get out of scope there will come an END-PERFORM for each
|
||||
for (int i = 0; i < indSt.Returns; i++)
|
||||
if (!tmpQfh.qualCobRow.isAttribute && !tmpQfh.qualCobRow.SampleStr.Equals(NOMOVE))
|
||||
{
|
||||
fromToMoves.CodeShower.Text += " END-PERFORM" + "\r\n";
|
||||
}
|
||||
|
||||
//Each index comming into scope will start a new PERFORM VARYING loop
|
||||
if (indSt.NewInds != null)
|
||||
{
|
||||
foreach (string indTxt in indSt.NewInds)
|
||||
//IndStatus-object takes care of optionally occuring indexes
|
||||
indSt.handleStatus(tmpQfh.indexStrings);
|
||||
|
||||
//If indexes get out of scope there will come an END-PERFORM for each
|
||||
for (int i = 0; i < indSt.Returns; i++)
|
||||
{
|
||||
if (!justOut)
|
||||
{
|
||||
//Before perform varying, move the count-value from old structure to new
|
||||
fromToMoves.CodeShower.Text += " MOVE " + tmpQfh.qualCobRow.CountIn + "\r\n" + tmpQfh.indexRedText;
|
||||
fromToMoves.CodeShower.Text += " TO " + tmpQfh.qualCobRow.CountIn.ToString().Replace(S.ettingPrefix, S.ettingExpPrefix) + "\r\n" + tmpQfh.indexRedText;
|
||||
}
|
||||
//Perform
|
||||
fromToMoves.CodeShower.Text += " PERFORM VARYING " + indTxt + " FROM 1 BY 1\r\n UNTIL " +
|
||||
indTxt + "\r\n > " + tmpQfh.qualCobRow.CountIn.ToString() + "\r\n" + tmpQfh.indexRedText;
|
||||
fromToMoves.CodeShower.Text += " END-PERFORM" + "\r\n";
|
||||
}
|
||||
}
|
||||
|
||||
//When count-variable is put on a "Value" XML-record-field the the count-value isnt correctly updated so better always move the value as is
|
||||
if (tmpQfh.qualCobRow.FieldName.ToUpper().Contains("_VALUE")) { }
|
||||
else
|
||||
{
|
||||
//when xml-record-field with occurs, the last index shall not be used (then use tmpQfh.indexRedText instead of tmpQfh.indexText
|
||||
loopTyp = tmpQfh.qualCobRow.isOccurs;
|
||||
fromToMoves.CodeShower.Text += " IF " + tmpQfh.qualCobRow.CountIn.ToString() + "\r\n" + (string)(loopTyp ? tmpQfh.indexRedText : tmpQfh.indexText) + " > 0 \r\n";
|
||||
}
|
||||
//The acutal move of present fields
|
||||
fromToMoves.CodeShower.Text += " MOVE " + tmpQfh.ToString();
|
||||
if (!justOut)
|
||||
{
|
||||
fromToMoves.CodeShower.Text += " TO " + tmpQfh.ToExpString();
|
||||
}
|
||||
else
|
||||
{
|
||||
fromToMoves.CodeShower.Text += " TO " + (string)(tmpQfh.qualCobRow.FieldDef.ToUpper().Contains("X") ? "MoveToStringVar" : "MoveToNumVar") + "\r\n";
|
||||
}
|
||||
//Each index comming into scope will start a new PERFORM VARYING loop
|
||||
if (indSt.NewInds != null)
|
||||
{
|
||||
foreach (string indTxt in indSt.NewInds)
|
||||
{
|
||||
if (!justOut)
|
||||
{
|
||||
//Before perform varying, move the count-value from old structure to new
|
||||
fromToMoves.CodeShower.Text += " MOVE " + tmpQfh.qualCobRow.CountIn + "\r\n" + tmpQfh.indexRedText;
|
||||
fromToMoves.CodeShower.Text += " TO " + tmpQfh.qualCobRow.CountIn.ToString().Replace(S.ettingPrefix, S.ettingExpPrefix) + "\r\n" + tmpQfh.indexRedText;
|
||||
}
|
||||
//Perform
|
||||
fromToMoves.CodeShower.Text += " PERFORM VARYING " + indTxt + " FROM 1 BY 1\r\n UNTIL " +
|
||||
indTxt + "\r\n > " + tmpQfh.qualCobRow.CountIn.ToString() + "\r\n" + tmpQfh.indexRedText;
|
||||
}
|
||||
}
|
||||
|
||||
if (!justOut)
|
||||
{
|
||||
//When count-variable is put on a "Value" XML-record-field the the count-value isnt correctly updated so better always move the value as is
|
||||
if (tmpQfh.qualCobRow.FieldName.ToUpper().Contains("_VALUE")) { }
|
||||
else
|
||||
{
|
||||
fromToMoves.CodeShower.Text += " MOVE " + tmpQfh.qualCobRow.CountIn + "\r\n" + (string)(loopTyp ? tmpQfh.indexRedText : tmpQfh.indexText);
|
||||
fromToMoves.CodeShower.Text += " TO " + tmpQfh.qualCobRow.CountIn.ToString().Replace(S.ettingPrefix, S.ettingExpPrefix) + "\r\n" + (string)(loopTyp ? tmpQfh.indexRedText : tmpQfh.indexText);
|
||||
fromToMoves.CodeShower.Text += " ELSE\r\n";
|
||||
fromToMoves.CodeShower.Text += " MOVE 0 TO " + tmpQfh.qualCobRow.CountIn.ToString().Replace(S.ettingPrefix, S.ettingExpPrefix) + "\r\n" + (string)(loopTyp ? tmpQfh.indexRedText : tmpQfh.indexText);
|
||||
fromToMoves.CodeShower.Text += " END-IF\r\n";
|
||||
//when xml-record-field with occurs, the last index shall not be used (then use tmpQfh.indexRedText instead of tmpQfh.indexText
|
||||
loopTyp = tmpQfh.qualCobRow.isOccurs;
|
||||
fromToMoves.CodeShower.Text += " IF " + tmpQfh.qualCobRow.CountIn.ToString() + "\r\n" + (string)(loopTyp ? tmpQfh.indexRedText : tmpQfh.indexText) + " > 0 \r\n";
|
||||
}
|
||||
//The acutal move of present fields
|
||||
fromToMoves.CodeShower.Text += " MOVE " + tmpQfh.ToString();
|
||||
if (!justOut)
|
||||
{
|
||||
fromToMoves.CodeShower.Text += " TO " + tmpQfh.ToExpString();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (tmpQfh.qualCobRow.MoveFromCode != null && tmpQfh.qualCobRow.MoveFromCode.Trim().Length > 0)
|
||||
{
|
||||
if (tmpQfh.qualCobRow.MoveFromCode.IndexOf("<?>") > -1 || tmpQfh.qualCobRow.MoveFromCode.IndexOf("<NYPOST>") > -1)
|
||||
{
|
||||
fromToMoves.CodeShower.Text += " *>" + tmpQfh.qualCobRow.MoveFromCode + "\r\n";
|
||||
fromToMoves.CodeShower.Text += " TO " + (string)(tmpQfh.qualCobRow.FieldDef.ToUpper().Contains("X") ? "MoveToStringVar" : "MoveToNumVar") + "\r\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
fromToMoves.CodeShower.Text += tmpQfh.qualCobRow.MoveFromCode + "\r\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fromToMoves.CodeShower.Text += " TO " + (string)(tmpQfh.qualCobRow.FieldDef.ToUpper().Contains("X") ? "MoveToStringVar" : "MoveToNumVar") + "\r\n";
|
||||
}
|
||||
}
|
||||
|
||||
if (!justOut)
|
||||
{
|
||||
if (tmpQfh.qualCobRow.FieldName.ToUpper().Contains("_VALUE")) { }
|
||||
else
|
||||
{
|
||||
fromToMoves.CodeShower.Text += " MOVE " + tmpQfh.qualCobRow.CountIn + "\r\n" + (string)(loopTyp ? tmpQfh.indexRedText : tmpQfh.indexText);
|
||||
fromToMoves.CodeShower.Text += " TO " + tmpQfh.qualCobRow.CountIn.ToString().Replace(S.ettingPrefix, S.ettingExpPrefix) + "\r\n" + (string)(loopTyp ? tmpQfh.indexRedText : tmpQfh.indexText);
|
||||
fromToMoves.CodeShower.Text += " ELSE\r\n";
|
||||
fromToMoves.CodeShower.Text += " MOVE 0 TO " + tmpQfh.qualCobRow.CountIn.ToString().Replace(S.ettingPrefix, S.ettingExpPrefix) + "\r\n" + (string)(loopTyp ? tmpQfh.indexRedText : tmpQfh.indexText);
|
||||
fromToMoves.CodeShower.Text += " END-IF\r\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user