diff --git a/CobXmlSupport/GenCobCode.cs b/CobXmlSupport/GenCobCode.cs index 64427e4..ad4795d 100644 --- a/CobXmlSupport/GenCobCode.cs +++ b/CobXmlSupport/GenCobCode.cs @@ -40,7 +40,7 @@ namespace CobXmlSupport private string indTemp = ""; private char[] splitChars = { '#' }; private int ClientSizeMinWidth; - private codeCompleter Cc; + private codeCompleter Cc; Dictionary setObjs; // = new Dictionary(); SaverListener sl; @@ -103,7 +103,7 @@ namespace CobXmlSupport else { S.ettingList = null; - } + } runXMLgen(); } @@ -130,7 +130,7 @@ namespace CobXmlSupport // setLocalValues(); //} - S.ettingFilePath = cmbLastFile.Text.Substring(0,cmbLastFile.Text.LastIndexOf("\\")); + S.ettingFilePath = cmbLastFile.Text.Substring(0, cmbLastFile.Text.LastIndexOf("\\")); uniqueTags = new Dictionary(); uniqueAttr = new Dictionary(); uniqueVars = new Dictionary(); @@ -211,7 +211,7 @@ namespace CobXmlSupport private void showRows() { - // codeCompleter Cc = new codeCompleter(cmbLastFile.Text, txtPrefix.Text); + // codeCompleter Cc = new codeCompleter(cmbLastFile.Text, txtPrefix.Text); Cc = new codeCompleter(cmbLastFile.Text, txtPrefix.Text); Cc.TryFill_In_Dic(); Cc.TryFill_Out_Dic(); @@ -734,7 +734,7 @@ namespace CobXmlSupport setObjs.Add(g.ActualFile, g); } } - + sl.dict = setObjs; } @@ -834,7 +834,7 @@ namespace CobXmlSupport savedFile SF = new savedFile(); SF.idConnect = "A472C801-2A7A-4A09-B432-8F16504964C3"; SF.usageName = S.ettingActualFile.Substring(0, S.ettingActualFile.LastIndexOf(".")) + "_Init"; - SF.fNameSaved = "Init_" + S.ettingActualFile.Substring(0, S.ettingActualFile.LastIndexOf(".")) + ".cbl"; + SF.fNameSaved = S.ettingActualFile.Substring(0, S.ettingActualFile.LastIndexOf(".")) + "_Init.cbl"; genCode.SavedFile = SF; @@ -891,7 +891,7 @@ namespace CobXmlSupport savedFile SF = new savedFile(); SF.idConnect = "15E1040B-2206-4F02-8212-FE9DF6B209B8"; SF.usageName = S.ettingActualFile.Substring(0, S.ettingActualFile.LastIndexOf(".")) + "_Init"; - SF.fNameSaved = "Init_" + S.ettingActualFile.Substring(0, S.ettingActualFile.LastIndexOf(".")) + ".cbl"; + SF.fNameSaved = S.ettingActualFile.Substring(0, S.ettingActualFile.LastIndexOf(".")) + "_Init.cbl"; genCode.SavedFile = SF; string inFile = cmbLastFile.Text.Substring(cmbLastFile.Text.LastIndexOf("\\") + 1); @@ -905,24 +905,24 @@ namespace CobXmlSupport 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"; - //} -// } + // 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 @@ -953,7 +953,7 @@ namespace CobXmlSupport 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 = ""; } } @@ -971,9 +971,9 @@ namespace CobXmlSupport } } - - - // get optionally occuring last END-PERFORMs... + + + // get optionally occuring last END-PERFORMs... indSt.handleStatus(null); for (int i = 0; i < indSt.Returns; i++) @@ -1098,9 +1098,10 @@ namespace CobXmlSupport /// /// /// - public void CreateComment(TextBox outView, string typeComm, string Author, string Firm, string sourceFile = "",bool showJson=false) + public void CreateComment(TextBox outView, string typeComm, string Author, string Firm, string sourceFile = "", bool showJson = false) { outView.Text = " *----------------------------------------------------------------*"; + string part1 = string.Empty, part2 = string.Empty; centeredComment(outView, typeComm.ToUpper()); if (sourceFile.Length > 0) { @@ -1113,13 +1114,26 @@ namespace CobXmlSupport outView.Text += "\r\n * Company : " + Firm.PadRight(51) + "*"; if (showJson) { - outView.Text += "\r\n * Json-pth : " + Cc.jsonPathId.PadRight(51) + "*"; + if (Cc.jsonPathId.PadRight(51).Length > 51) + { + MapSplit(Cc.jsonPathId, 51, out part1, out part2); + outView.Text += "\r\n * Json-path: " + part1.PadRight(51) + "*"; + outView.Text += "\r\n * --> : " + part2.PadRight(51) + "*"; + } + else outView.Text += "\r\n * Json-pth : " + Cc.jsonPathId.PadRight(51) + "*"; outView.Text += "\r\n * Json-in : " + Cc.CcFileInId.PadRight(51) + "*"; outView.Text += "\r\n * Json-Out : " + Cc.CcFileOutId.PadRight(51) + "*"; } outView.Text += "\r\n *----------------------------------------------------------------*"; } + private void MapSplit(string inStr, int chrs, out string prt1, out string prt2) + { + int locLen = inStr.Substring(0, chrs).LastIndexOf("\\"); + prt1 = inStr.Substring(0, locLen); + prt2 = inStr.Substring(locLen); + } + private static void centeredComment(TextBox outView, string centeredText) { int marg = (64 - centeredText.Length); @@ -1185,7 +1199,11 @@ namespace CobXmlSupport { if (!chkDisplays.Checked) { - createXMLMoveCode(true); + savedFile SF = new savedFile(); + SF.idConnect = "598A5F20-9A8A-415D-81B2-BBFE04465381"; + SF.usageName = S.ettingActualFile.Substring(0, S.ettingActualFile.LastIndexOf(".")) + "_Unload"; + SF.fNameSaved = S.ettingActualFile.Substring(0, S.ettingActualFile.LastIndexOf(".")) + "_Unload.cbl"; + createXMLMoveCode(SF,true); } else { @@ -1208,7 +1226,7 @@ namespace CobXmlSupport private void cmbLastFile_SelectedIndexChanged(object sender, EventArgs e) { - if ( S.ettingActualFile != null) + if (S.ettingActualFile != null) { GenSetting tmpSetting = new GenSetting(); this.sl.Subscribe(tmpSetting); @@ -1226,7 +1244,7 @@ namespace CobXmlSupport else { S.ettingList = null; - } + } runXMLgen(); } @@ -1247,8 +1265,8 @@ namespace CobXmlSupport Properties.Settings.Default.CompanyName = S.ettingCompany; Properties.Settings.Default.UserName = S.ettingUserName; Properties.Settings.Default.Save(); - - + + SerializeMetadata(); } @@ -1384,8 +1402,8 @@ namespace CobXmlSupport private void setLocalValues() { eventRun = true; - chkAnaTag.Checked = S.ettingAnaTag; chkAnaTag.Refresh(); - chkCountVars.Checked = S.ettingCountVars; chkCountVars.Refresh(); + chkAnaTag.Checked = S.ettingAnaTag; chkAnaTag.Refresh(); + chkCountVars.Checked = S.ettingCountVars; chkCountVars.Refresh(); chkDisplays.Checked = S.ettingDisplays; chkDisplays.Refresh(); chkNoNsRef.Checked = S.ettingNoNsRef; @@ -1428,7 +1446,7 @@ namespace CobXmlSupport savedFile SF = new savedFile(); SF.idConnect = "6EFF8B31-7F88-4A81-B94E-41D54A3D3197"; SF.usageName = S.ettingActualFile.Substring(0, S.ettingActualFile.LastIndexOf(".")) + "_Load"; - SF.fNameSaved = "Load_" + S.ettingActualFile.Substring(0, S.ettingActualFile.LastIndexOf(".")) + ".cbl"; + SF.fNameSaved = S.ettingActualFile.Substring(0, S.ettingActualFile.LastIndexOf(".")) + "_Load.cbl"; genMoves.SavedFile = SF; foreach (CobRow cr in rowList) @@ -1477,7 +1495,7 @@ namespace CobXmlSupport savedFile SF = new savedFile(); SF.idConnect = "6EFF8B31-7F88-4A81-B94E-41D54A3D3197"; SF.usageName = S.ettingActualFile.Substring(0, S.ettingActualFile.LastIndexOf(".")) + "_Load"; - SF.fNameSaved = "Load_" + S.ettingActualFile.Substring(0, S.ettingActualFile.LastIndexOf(".")) + ".cbl"; + SF.fNameSaved = S.ettingActualFile.Substring(0, S.ettingActualFile.LastIndexOf(".")) + "_Load.cbl"; genExtMoves.SavedFile = SF; bool adj = false; @@ -1722,7 +1740,7 @@ namespace CobXmlSupport savedFile SF = new savedFile(); SF.idConnect = "9C3E8CC7-FA20-4E11-8E81-73BE8D2E9CFB"; SF.usageName = S.ettingActualFile.Substring(0, S.ettingActualFile.LastIndexOf(".")) + "_Unload"; - SF.fNameSaved = "Unload_" + S.ettingActualFile.Substring(0, S.ettingActualFile.LastIndexOf(".")) + ".cbl"; + SF.fNameSaved = S.ettingActualFile.Substring(0, S.ettingActualFile.LastIndexOf(".")) + "_Unload.cbl"; fromMoves.SavedFile = SF; bool adj = false; @@ -1900,7 +1918,7 @@ namespace CobXmlSupport savedFile SF = new savedFile(); SF.idConnect = "0A975654-75C6-4A8C-8534-AA16F46BC740"; SF.usageName = S.ettingActualFile.Substring(0, S.ettingActualFile.LastIndexOf(".")) + "_Transfer"; - SF.fNameSaved = "Transfer_" + S.ettingActualFile.Substring(0, S.ettingActualFile.LastIndexOf(".")) + ".cbl"; + SF.fNameSaved = S.ettingActualFile.Substring(0, S.ettingActualFile.LastIndexOf(".")) + "_Transfer.cbl"; fromMoves.SavedFile = SF; bool adj = false; @@ -2144,19 +2162,24 @@ namespace CobXmlSupport } - private void createXMLMoveCode(bool justOut = false) + private void createXMLMoveCode(savedFile SF, bool justOut = false) { bool loopTyp = false; //Create showing window fromToMoves = new ShowCode(); fromToMoves.Parent = this; - fromToMoves.Labeltext = "Created \"move From \" Code"; + if (!justOut) + { + fromToMoves.Labeltext = "Created \"move From To\" Code"; + } + else fromToMoves.Labeltext = "Created \"move From \" Code"; - savedFile SF = new savedFile(); - SF.idConnect = "598A5F20-9A8A-415D-81B2-BBFE04465381"; - SF.usageName = S.ettingActualFile.Substring(0, S.ettingActualFile.LastIndexOf(".")) + "_Unload"; - SF.fNameSaved = "Unload_" + S.ettingActualFile.Substring(0, S.ettingActualFile.LastIndexOf(".")) + ".cbl"; + + //savedFile SF = new savedFile(); + //SF.idConnect = "598A5F20-9A8A-415D-81B2-BBFE04465381"; + //SF.usageName = S.ettingActualFile.Substring(0, S.ettingActualFile.LastIndexOf(".")) + "_Unload"; + //SF.fNameSaved = S.ettingActualFile.Substring(0, S.ettingActualFile.LastIndexOf(".")) + "_Unload.cbl"; fromToMoves.SavedFile = SF; @@ -2207,7 +2230,8 @@ namespace CobXmlSupport { //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; + 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 " + @@ -2221,8 +2245,10 @@ namespace CobXmlSupport { //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"; + 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) @@ -2236,7 +2262,8 @@ namespace CobXmlSupport if (tmpQfh.qualCobRow.MoveFromCode.IndexOf("") > -1 || tmpQfh.qualCobRow.MoveFromCode.IndexOf("") > -1) { fromToMoves.CodeShower.Text += " *>" + tmpQfh.qualCobRow.MoveFromCode + "\r\n"; - fromToMoves.CodeShower.Text += " TO " + (string)(tmpQfh.qualCobRow.FieldDef.ToUpper().Contains("X") ? "MoveToStringVar" : "MoveToNumVar") + "\r\n"; + fromToMoves.CodeShower.Text += " TO " + + (string)(tmpQfh.qualCobRow.FieldDef.ToUpper().Contains("X") ? "MoveToStringVar" : "MoveToNumVar") + "\r\n"; } else { @@ -2245,7 +2272,8 @@ namespace CobXmlSupport } else { - fromToMoves.CodeShower.Text += " TO " + (string)(tmpQfh.qualCobRow.FieldDef.ToUpper().Contains("X") ? "MoveToStringVar" : "MoveToNumVar") + "\r\n"; + fromToMoves.CodeShower.Text += " TO " + + (string)(tmpQfh.qualCobRow.FieldDef.ToUpper().Contains("X") ? "MoveToStringVar" : "MoveToNumVar") + "\r\n"; } } @@ -2254,10 +2282,15 @@ namespace CobXmlSupport 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 += " 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 += " 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"; } } @@ -2283,12 +2316,16 @@ namespace CobXmlSupport private void btnFrXMLTo_Click(object sender, EventArgs e) { - createXMLMoveCode(); + savedFile SF = new savedFile(); + SF.idConnect = "598A5F20-9A8A-415D-81B2-BBFE04465381"; + SF.usageName = S.ettingActualFile.Substring(0, S.ettingActualFile.LastIndexOf(".")) + "_Transfer"; + SF.fNameSaved = S.ettingActualFile.Substring(0, S.ettingActualFile.LastIndexOf(".")) + "_Transfer.cbl"; + createXMLMoveCode(SF); } private void btnTestThings_Click(object sender, EventArgs e) { - //Create showing window + //Create showing window loadResWords(); fromToMoves = new ShowCode(); fromToMoves.Parent = this; @@ -2308,8 +2345,8 @@ namespace CobXmlSupport } fromToMoves.Show(); - //createXMLMoveCode(); - func_exit:; + //createXMLMoveCode(); + func_exit: ; } private void loadResWords() @@ -2331,8 +2368,8 @@ namespace CobXmlSupport SaveRegCopyFile srcf = new SaveRegCopyFile(); savedFile localSaver = new savedFile(); localSaver.idConnect = "4B0E5C02-B2D0-4755-B4EC-AF449D513582"; - localSaver.usageName = "XMLCOBfrom_"+S.ettingActualFile; - localSaver.fNameSaved = S.ettingActualFile.Substring(0, S.ettingActualFile.LastIndexOf(".")) + "_COBXML.cpy"; + localSaver.usageName = S.ettingActualFile + "_XMLCOBfrom"; + localSaver.fNameSaved = S.ettingActualFile.Substring(0, S.ettingActualFile.LastIndexOf(".")) + ".cpy"; srcf.SavedFile = localSaver; srcf.FileData = this.outCob.Text; srcf.ShowDialog(); @@ -2358,9 +2395,8 @@ namespace CobXmlSupport savedFile SF = new savedFile(); SF.idConnect = "1C1FAE9D-39DD-4A24-A6C2-8696EAE3CB32"; - SF.usageName = ""; SF.usageName = S.ettingActualFile.Substring(0, S.ettingActualFile.LastIndexOf(".")) + "_Crossref"; - SF.fNameSaved = "Crossref_" + S.ettingActualFile.Substring(0, S.ettingActualFile.LastIndexOf(".")) + ".txt"; + SF.fNameSaved = S.ettingActualFile.Substring(0, S.ettingActualFile.LastIndexOf(".")) + "_Crossref.txt"; fromToMoves.SavedFile = SF; @@ -2429,17 +2465,17 @@ namespace CobXmlSupport S.ettingDisplays = chkDisplays.Checked; } - private void btnRerun_Click(object sender, EventArgs e) + private void btnRerun_Click(object sender, EventArgs e) { runXMLgen(); } - private void btnShowWorkFiles_Click(object sender, EventArgs e) - { - CheckWorkItems cwi = new CheckWorkItems(); - cwi.FileList = setObjs; - cwi.ShowDialog(); - } + private void btnShowWorkFiles_Click(object sender, EventArgs e) + { + CheckWorkItems cwi = new CheckWorkItems(); + cwi.FileList = setObjs; + cwi.ShowDialog(); + } } }