From 77764a39f356d226f5fbd4646dc9bbdbaf44781a Mon Sep 17 00:00:00 2001 From: tfoman Date: Wed, 10 Dec 2014 00:19:06 +0100 Subject: [PATCH] Commented solution now working --- CobXmlSupport/GenCobCode.Designer.cs | 14 ++++ CobXmlSupport/GenCobCode.cs | 95 ++++++++++++++++++--------- CobXmlSupport/frmSettings.Designer.cs | 38 +++++------ 3 files changed, 98 insertions(+), 49 deletions(-) diff --git a/CobXmlSupport/GenCobCode.Designer.cs b/CobXmlSupport/GenCobCode.Designer.cs index f5a27b4..3b35984 100644 --- a/CobXmlSupport/GenCobCode.Designer.cs +++ b/CobXmlSupport/GenCobCode.Designer.cs @@ -63,6 +63,7 @@ this.txtExpPrefix = new System.Windows.Forms.TextBox(); this.chkAttribs = new System.Windows.Forms.CheckBox(); this.btnTestThings = new System.Windows.Forms.Button(); + this.btnFrXMLTo = new System.Windows.Forms.Button(); this.SuspendLayout(); // // button1 @@ -387,6 +388,7 @@ this.chkNewArea.TabIndex = 29; this.chkNewArea.Text = "Till Area"; this.chkNewArea.UseVisualStyleBackColor = true; + this.chkNewArea.Visible = false; this.chkNewArea.CheckedChanged += new System.EventHandler(this.chkNewArea_CheckedChanged); // // label5 @@ -428,11 +430,22 @@ this.btnTestThings.UseVisualStyleBackColor = true; this.btnTestThings.Click += new System.EventHandler(this.btnTestThings_Click); // + // btnFrXMLTo + // + this.btnFrXMLTo.Location = new System.Drawing.Point(673, 655); + this.btnFrXMLTo.Name = "btnFrXMLTo"; + this.btnFrXMLTo.Size = new System.Drawing.Size(92, 22); + this.btnFrXMLTo.TabIndex = 34; + this.btnFrXMLTo.Text = "Kopiera XML"; + this.btnFrXMLTo.UseVisualStyleBackColor = true; + this.btnFrXMLTo.Click += new System.EventHandler(this.btnFrXMLTo_Click); + // // GenCobCode // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(951, 686); + this.Controls.Add(this.btnFrXMLTo); this.Controls.Add(this.btnTestThings); this.Controls.Add(this.chkAttribs); this.Controls.Add(this.txtExpPrefix); @@ -512,6 +525,7 @@ private System.Windows.Forms.TextBox txtExpPrefix; private System.Windows.Forms.CheckBox chkAttribs; private System.Windows.Forms.Button btnTestThings; + private System.Windows.Forms.Button btnFrXMLTo; } } diff --git a/CobXmlSupport/GenCobCode.cs b/CobXmlSupport/GenCobCode.cs index cbd25f7..e16c544 100644 --- a/CobXmlSupport/GenCobCode.cs +++ b/CobXmlSupport/GenCobCode.cs @@ -1680,79 +1680,114 @@ namespace CobXmlSupport } } - private void btnTestThings_Click(object sender, EventArgs e) + + private void createXMLMoveCode() { bool loopTyp = false; + + //Create showing window fromToMoves = new ShowCode(); fromToMoves.Parent = this; - fromToMoves.Labeltext = "Testing to Creat \"move From \" Code"; - + fromToMoves.Labeltext = "Created \"move From \" Code"; + //Dictionary for indexes, init IndexState class and list for qualifiedHelper class Dictionary testIndexes = new Dictionary(); - IndexState lIs = new IndexState(testIndexes,rowList); - //if (qldList == null) - //{ - qldList = new List(); - //} + IndexState lIs = new IndexState(testIndexes, rowList); + qldList = new List(); + + //Build the qualified helper object for each xml-record fieal (eg XMLTag) foreach (CobRow zRow in rowList) { qualifieldhlp tmpQlh = new qualifieldhlp(zRow, lIs.Indexes); qldList.Add(tmpQlh); } + //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) { - //obs under development + //Create header information on created text + if (tmpQfh.qualCobRow.CobLevel < 2) + { + string inFile = cmbLastFile.Text.Substring(cmbLastFile.Text.LastIndexOf("\\") + 1); + CreateComment(fromToMoves.CodeShower, "Moves from " + tmpQfh.qualCobRow.FieldName, S.ettingUserName, S.ettingCompany, inFile); + 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++) { 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) { - fromToMoves.CodeShower.Text += " MOVE " + tmpQfh.qualCobRow.CountIn + "\r\n" + tmpQfh.indexRedText; + //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; } } - //obs under development - //if (tmpQfh.qualCobRow.FieldDef != "") - //{ - if (tmpQfh.qualCobRow.FieldName.ToUpper().Contains("_VALUE")) { } - else { - loopTyp = tmpQfh.qualCobRow.isOccurs ;//&& tmpQfh.qualCobRow.FieldDef == ""; - fromToMoves.CodeShower.Text += " IF " + tmpQfh.qualCobRow.CountIn.ToString() + "\r\n" + (string)(loopTyp ? tmpQfh.indexRedText : tmpQfh.indexText) + " > 0 \r\n"; - } - fromToMoves.CodeShower.Text += " MOVE " + tmpQfh.ToString(); - fromToMoves.CodeShower.Text += " TO " + tmpQfh.ToExpString(); - 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 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(); + fromToMoves.CodeShower.Text += " TO " + tmpQfh.ToExpString(); + + 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"; + } } + // get optionally occuring last END-PERFORMs... indSt.handleStatus(null); for (int i = 0; i < indSt.Returns; i++) { fromToMoves.CodeShower.Text += " END-PERFORM" + "\r\n"; } + //List all used indexes + string tempIndText = ""; + fromToMoves.CodeShower.Text = addOccursVars(testIndexes, fromToMoves.CodeShower.Text, tempIndText); fromToMoves.Show(); } + private void btnTestThings_Click(object sender, EventArgs e) + { + createXMLMoveCode(); + } + + private void btnFrXMLTo_Click(object sender, EventArgs e) + { + createXMLMoveCode(); + } + + } } diff --git a/CobXmlSupport/frmSettings.Designer.cs b/CobXmlSupport/frmSettings.Designer.cs index 45e3baa..edccada 100644 --- a/CobXmlSupport/frmSettings.Designer.cs +++ b/CobXmlSupport/frmSettings.Designer.cs @@ -49,13 +49,13 @@ this.chkValues = new System.Windows.Forms.CheckBox(); this.chkAnaTag = new System.Windows.Forms.CheckBox(); this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.txtExpPrefix = new System.Windows.Forms.TextBox(); + this.label8 = new System.Windows.Forms.Label(); this.groupBox2 = new System.Windows.Forms.GroupBox(); this.label6 = new System.Windows.Forms.Label(); this.txtLogPost = new System.Windows.Forms.TextBox(); this.txtLogSection = new System.Windows.Forms.TextBox(); this.label7 = new System.Windows.Forms.Label(); - this.txtExpPrefix = new System.Windows.Forms.TextBox(); - this.label8 = new System.Windows.Forms.Label(); this.groupBox1.SuspendLayout(); this.groupBox2.SuspendLayout(); this.SuspendLayout(); @@ -271,6 +271,23 @@ this.groupBox1.TabStop = false; this.groupBox1.Text = "Utgångs inställningar"; // + // txtExpPrefix + // + this.txtExpPrefix.Location = new System.Drawing.Point(213, 51); + this.txtExpPrefix.Name = "txtExpPrefix"; + this.txtExpPrefix.Size = new System.Drawing.Size(57, 20); + this.txtExpPrefix.TabIndex = 40; + this.txtExpPrefix.Text = "GWX_"; + // + // label8 + // + this.label8.AutoSize = true; + this.label8.Location = new System.Drawing.Point(137, 52); + this.label8.Name = "label8"; + this.label8.Size = new System.Drawing.Size(70, 13); + this.label8.TabIndex = 39; + this.label8.Text = "export prefix :"; + // // groupBox2 // this.groupBox2.Controls.Add(this.label6); @@ -317,23 +334,6 @@ this.label7.TabIndex = 37; this.label7.Text = "Namn log section"; // - // txtExpPrefix - // - this.txtExpPrefix.Location = new System.Drawing.Point(213, 51); - this.txtExpPrefix.Name = "txtExpPrefix"; - this.txtExpPrefix.Size = new System.Drawing.Size(57, 20); - this.txtExpPrefix.TabIndex = 40; - this.txtExpPrefix.Text = "GWX_"; - // - // label8 - // - this.label8.AutoSize = true; - this.label8.Location = new System.Drawing.Point(137, 52); - this.label8.Name = "label8"; - this.label8.Size = new System.Drawing.Size(70, 13); - this.label8.TabIndex = 39; - this.label8.Text = "export prefix :"; - // // frmSettings // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);