diff --git a/CobProgAid/CobProgAid/CodeChanger.cs b/CobProgAid/CobProgAid/CodeChanger.cs index cb7674a..f419a43 100644 --- a/CobProgAid/CobProgAid/CodeChanger.cs +++ b/CobProgAid/CobProgAid/CodeChanger.cs @@ -15,9 +15,14 @@ namespace CobProgAid //------------------------------------------- private string template; + private string templateName; private string filename; private string progname; + private string xmlcopy; + private string xmlreadcopy; + private string xmlfilename; + public string Template { get { @@ -29,6 +34,18 @@ namespace CobProgAid process(); } } + public string TemplateName + { + get + { + return templateName; + } + set + { + templateName = value; + } + } + public string CodeOut { get; set; } public string FileName @@ -57,6 +74,53 @@ namespace CobProgAid } } +//------------------------------------------------------ + public string XMLcopy + { + get + { + return xmlcopy; + } + + set + { + xmlcopy = value; + process(); + } + } + public string XMLfilename + { + get + { + return xmlfilename; + } + + set + { + xmlfilename = value; + process(); + } + } + public string XMLReadCopy + { + get + { + return xmlreadcopy; + } + + set + { + xmlreadcopy = value; + process(); + } + } + + + +//------------------------------------------------------ + + + private void process() { string workText = Template; @@ -64,12 +128,31 @@ namespace CobProgAid { workText = workText.Replace("XXXXX", filename); } - if (filename != null && progname != null && progname != "" && filename != "") + if ((templateName != "CobMallLasFil" && (filename == null || filename == "") + && progname != null && progname != "") || filename != null && filename != "" && progname != null && progname != "") { workText = workText.Replace("YYYYYYY", progname); - workText = workText.Replace("TO" + filename.Trim(), progname); + if (templateName == "CobMallLasFil") + { + workText = workText.Replace("TO" + filename.Trim(), progname); + } workText = workText.Replace("$FNL", progname.Length.ToString("00")); } + if (xmlcopy != null && xmlcopy != "") + { + workText = workText.Replace("$copyxmlxd", xmlcopy); + } + + if (xmlreadcopy != null && xmlreadcopy != "") + { + workText = workText.Replace("$copyxmlrun", xmlreadcopy); + } + + if (xmlfilename != null && xmlfilename != "") + { + workText = workText.Replace("$xmlfilnamn", xmlfilename); + } + CodeOut = workText; Updated(this, e); } diff --git a/CobProgAid/CobProgAid/Properties/Resources.Designer.cs b/CobProgAid/CobProgAid/Properties/Resources.Designer.cs index 9e5b145..2f08bc8 100644 --- a/CobProgAid/CobProgAid/Properties/Resources.Designer.cs +++ b/CobProgAid/CobProgAid/Properties/Resources.Designer.cs @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.42000 +// Runtime Version:4.0.30319.34209 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -76,11 +76,25 @@ namespace CobProgAid.Properties { } /// - /// Looks up a localized string similar to hejhopp. + /// Looks up a localized string similar to $set p(prexml) (htmlpp) endp + /// *================================================================= + /// copy "cblproto". + /// *----------------------------------------------------------------- + /// * + /// * FUNKTION PROGRAM MALL XML + /// * SYSTEM $SYSTEM + /// * PROGRAM-ID YYYYYYY + /// * AUTHOR TOMMY ÖMAN, FordonsData AB + /// * DATUM 150908 + /// * $BESKRIVNING + /// * + /// * + /// *$$ + /// *----------------------------------------------- [rest of string was truncated]";. /// - internal static string hejhopptest { + internal static string CobMallXML { get { - return ResourceManager.GetString("hejhopptest", resourceCulture); + return ResourceManager.GetString("CobMallXML", resourceCulture); } } } diff --git a/CobProgAid/CobProgAid/Properties/Resources.resx b/CobProgAid/CobProgAid/Properties/Resources.resx index a37225c..0ed4808 100644 --- a/CobProgAid/CobProgAid/Properties/Resources.resx +++ b/CobProgAid/CobProgAid/Properties/Resources.resx @@ -372,8 +372,331 @@ EXIT. Normalt genomläsningsprogram för idx-fil - - hejhopp - bara en testrad + + $set p(prexml) (htmlpp) endp + *================================================================= + copy "cblproto". + *----------------------------------------------------------------- + * + * FUNKTION PROGRAM MALL XML + * SYSTEM $SYSTEM + * PROGRAM-ID YYYYYYY + * AUTHOR TOMMY ÖMAN, FordonsData AB + * DATUM 150908 + * $BESKRIVNING + * + * + *$$ + *---------------------------------------------------------------- + *$DATUM SIGN ÄNDRING + * ------ ---- ------------------------------------------------- + *$ÄNDRINGAR + * 150908 TO Nytt program + *$$ + *---------------------------------------------------------------- + + /----------------------------------------------------------------- + identification division. + *----------------------------------------------------------------- + program-id. YYYYYYY. + + /----------------------------------------------------------------- + input-output section. + *----------------------------------------------------------------- + file-control. + select loggfil assign to logg-id + organization line sequential + status f-status. + + select xml-stream + assign w-url + organization xml + document-type omitted + file status stream-status. + + /----------------------------------------------------------------- + data division. + *----------------------------------------------------------------- + file section. + + fd loggfil. + 01 logg-post pic x(5000). + + xd xml-stream. + copy "$copyxmlxd". + + + *----------------------------------------------------------------- + working-storage section. + *----------------------------------------------------------------- + + 78 WINMACH value "COMPUTERNAME". + 78 UNIXMACH value "HOSTNAME". + 78 NoName value "No Name". + 78 ENVTVARVALUELEN VALUE 200. + 78 KOBRALIB VALUE "KOBRADIR". + *----------------------------------------------------------------- + 77 tx-program pic x($FNL) value "YYYYYYY". + 77 w-kobradir pic x(50) value space. + 77 urltrace-dyn pic x(50) value space. + 77 procinstr-value pic x(200) value space. + 01 int-felkod pic s9(9) comp-5 value 0. + + ****************************************************************** + * + * STATUSAR + * + ****************************************************************** + + *xml file status + 01 STREAM-STATUS PIC S9(9). + 01 config-found-x pic x(01) value space. + 88 config-default value space. + 88 config-found value "X". + 01 W-CBL-RETURN-CODE PIC X(02) COMP-5 VALUE 0. + + 01 CGOI_parameter-block cblt-os-info-params. + 01 processId cblt-x4-comp5. + 01 processIdNum pic 9(8). + 01 separator pic x. + 88 separatorWindows value "\". + 88 separatorUnix value "/". + 01 LSSEQterminator pic xx value x"0D0A". + 88 LSSEQterminatorWindows value x"0D0A". + 88 LSSEQterminatorUnix value x"0A". + 01 LSSEQterminatorLen pic 9 value 2. + 01 status-code cblt-x4-comp5. + 01 machine-name pic x(10) value space. + *----------- LOGGING ---------------------------------------- + 01 ws-logg-open pic 9 value 0. + 88 loggopen value 1. + 88 loggclosed value 0. + + 01 logdata. + 03 logdatetime. + 05 filler pic x value "<". + 05 log-aar pic 9(04). + 05 filler pic x value "-". + 05 log-man pic 9(02). + 05 filler pic x value "-". + 05 log-dag pic 9(02). + 05 filler pic x value "_". + 05 logtid. + 07 MSK-TIMME pic 9(02). + 07 filler pic x value ":". + 07 MSK-MINUT pic 9(02). + 07 filler pic x value ":". + 07 MSK-SEKUND pic 9(02). + 07 filler pic x value ",". + 07 MSK-HUNDRADEL pic 9(02). + 05 filler pic x value ">". + 03 lograder pic 9 . + 03 kx-rad pic 9 . + 03 kx-ptr cblt-sx4-comp5 value 0. + 03 loginfo. + 05 logstr occurs 5 pic x(200). + 05 logradut pic x(230). + + 01 logg-post-save pic x(5000). + *----------- LOGGING ---------------------------------------- + 01 ENVTVARNAME PIC X(20) VALUE KOBRALIB. + 01 ENVTVARVALUE PIC X( ENVTVARVALUELEN ) + VALUE SPACES. + 01 w-url pic x(100). + + *----------------------------------------------------------------- + copy copwsstd. + + *----------------------------------------------------------------- + linkage section. + copy coplsmeny. + copy coplsglobal. + copy coplssystem. + + /---------------------------------------------------------------- + procedure division using meny-area glob-area syst-area. + *----------------------------------------------------------------- + program-styr section. + perform get-os-info + perform initdatum + + move "Nu startar vi programmet" to logstr (1) + move 1 to lograder + perform display-log + + move "$xmlfilnamn" to w-url + open input xml-stream + + perform laes-xmldata + + close xml-stream + perform end-program. + program-styr-ex. + exit. + + laes-xmldata section. + move "Start av xml-läsning" to logstr (1) + move 1 to lograder + perform display-log + + copy "$copyxmlrun" + + move "Avslutar xml-läsning" to logstr (1) + move 1 to lograder + perform display-log + . + laes-xmldata-ex. + exit. + + *----------------------------------------------------------------- + display-log section. + perform log-date-time + if loggclosed + perform openlogfile + end-if + if lograder > 0 + perform varying kx-rad from 1 by 1 + until kx-rad > lograder + move space to logradut + move 1 to kx-ptr + string logdatetime delimited by size + " (" delimited by size + kx-rad + ") " + logstr (kx-rad) delimited by " " + into logradut + with pointer kx-ptr + end-string + move logradut (1:kx-ptr) to logg-post + write logg-post + move space to logg-post + initialize loginfo + end-perform + else + write logg-post + move space to logg-post + initialize loginfo + end-if + . + display-log-ex. + exit. + + OpenLogFile SECTION. + + string + w-env-kobradir delimited by space + separator + "log" + separator + "YYYYYYYWS.log" + into logg-id + end-string + open extend loggfil + set loggopen to true. + + move logg-post to logg-post-save + initialize logg-post + + string + logdatetime + " företag: " + meny-fornr + " avdelning: " + syst-avdnrhem + " --------------------------------------------" + into logg-post + end-string + write logg-post + move logg-post-save to logg-post + . + OpenLogFile-EX. + EXIT. + + log-date-time section. + move mskss-ar to log-aar + move mskss-man to log-man + move mskss-dag to log-dag + accept maskintid from time + move corr maskintid-r to logtid + . + log-date-time-ex. + exit. + + GET-OS-INFO SECTION. + move length of CGOI_parameter-block + to cblte-osi-length of CGOI_parameter-block + call CBL-GET-OS-INFO using CGOI_parameter-block + returning status-code + evaluate cblte-osi-os-type of CGOI_parameter-block + when 131 + perform FetchWinProcessId + when 128 + perform FetchUnixProcessId + when other + move 999999 to processIdNum *> abnormal to go here! + end-evaluate + move processId to processIdNum + . + GET-OS-INFO-EX. + EXIT. + + FetchWinProcessId section. + call "_getpid" returning processId + set separatorWindows to true + set LSSEQterminatorWindows to true + move 2 to LSSEQterminatorLen + + move WINMACH TO EnvtVarName + perform FetchEnvironmentVar + if EnvtVarValue = space + move NoName to machine-name + else + move EnvtVarValue to machine-name + end-if + . + FetchWinProcessId-ex. + exit. + *================================================================= + FetchUnixProcessId section. + call "getpid" returning processId + set separatorUnix to true + set LSSEQterminatorUnix to true + move 1 to LSSEQterminatorLen + + * perform fixHostName + . + FetchUnixProcessId-ex. + exit. + + *===== G E T E N V T V A R ====================================== + FetchEnvironmentVar section. + *--> read the value of environment variable + display EnvtVarName upon environment-name + move space to EnvtVarValue + accept EnvtVarValue from environment-value. + . + FetchEnvironmentVar-ex. + exit. + + *===== S E T E N V T V A R ======================================= + UpdateEnvironmentVar section. + display EnvtVarName upon environment-name + display EnvtVarValue upon environment-value + . + UpdateEnvironmentVar-ex. + exit. + + *----------------------------------------------------------------- + *> Avsluta programmet + end-program section. + close LOGGFIL + stop run + . + end-program-ex. + exit. + + + COPY COPPDINITSS. + mall för läsning xml \ No newline at end of file diff --git a/CobProgAid/CobProgAid/frmProgAidHome.Designer.cs b/CobProgAid/CobProgAid/frmProgAidHome.Designer.cs index 33217d4..f489c53 100644 --- a/CobProgAid/CobProgAid/frmProgAidHome.Designer.cs +++ b/CobProgAid/CobProgAid/frmProgAidHome.Designer.cs @@ -38,6 +38,12 @@ this.label3 = new System.Windows.Forms.Label(); this.txtProgramName = new System.Windows.Forms.TextBox(); this.label4 = new System.Windows.Forms.Label(); + this.txtXmlCopy = new System.Windows.Forms.TextBox(); + this.label5 = new System.Windows.Forms.Label(); + this.label6 = new System.Windows.Forms.Label(); + this.txtXmlReadCopy = new System.Windows.Forms.TextBox(); + this.label7 = new System.Windows.Forms.Label(); + this.txtXmlFilNamn = new System.Windows.Forms.TextBox(); this.SuspendLayout(); // // btnClose @@ -85,7 +91,7 @@ this.lstProgTyp.FormattingEnabled = true; this.lstProgTyp.Location = new System.Drawing.Point(19, 85); this.lstProgTyp.Name = "lstProgTyp"; - this.lstProgTyp.Size = new System.Drawing.Size(474, 95); + this.lstProgTyp.Size = new System.Drawing.Size(598, 95); this.lstProgTyp.TabIndex = 5; this.lstProgTyp.SelectedValueChanged += new System.EventHandler(this.clbProgType_SelectedIndexChanged); // @@ -134,11 +140,68 @@ this.label4.TabIndex = 10; this.label4.Text = "Välj programnamn"; // + // txtXmlCopy + // + this.txtXmlCopy.Location = new System.Drawing.Point(241, 210); + this.txtXmlCopy.Name = "txtXmlCopy"; + this.txtXmlCopy.Size = new System.Drawing.Size(100, 20); + this.txtXmlCopy.TabIndex = 11; + this.txtXmlCopy.TextChanged += new System.EventHandler(this.txtXmlCopy_TextChanged); + // + // label5 + // + this.label5.AutoSize = true; + this.label5.Location = new System.Drawing.Point(241, 191); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(83, 13); + this.label5.TabIndex = 12; + this.label5.Text = "Ange XML-copy"; + // + // label6 + // + this.label6.AutoSize = true; + this.label6.Location = new System.Drawing.Point(357, 191); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(107, 13); + this.label6.TabIndex = 14; + this.label6.Text = "Ange XML-read-copy"; + // + // txtXmlReadCopy + // + this.txtXmlReadCopy.Location = new System.Drawing.Point(357, 210); + this.txtXmlReadCopy.Name = "txtXmlReadCopy"; + this.txtXmlReadCopy.Size = new System.Drawing.Size(100, 20); + this.txtXmlReadCopy.TabIndex = 13; + this.txtXmlReadCopy.TextChanged += new System.EventHandler(this.txtXmlReadCopy_TextChanged); + // + // label7 + // + this.label7.AutoSize = true; + this.label7.Location = new System.Drawing.Point(470, 191); + this.label7.Name = "label7"; + this.label7.Size = new System.Drawing.Size(93, 13); + this.label7.TabIndex = 16; + this.label7.Text = "Ange XML-filnamn"; + // + // txtXmlFilNamn + // + this.txtXmlFilNamn.Location = new System.Drawing.Point(470, 210); + this.txtXmlFilNamn.Name = "txtXmlFilNamn"; + this.txtXmlFilNamn.Size = new System.Drawing.Size(100, 20); + this.txtXmlFilNamn.TabIndex = 15; + this.txtXmlFilNamn.TextChanged += new System.EventHandler(this.txtXmlFilNamn_TextChanged); + // // frmProgAidHome // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(766, 659); + this.Controls.Add(this.label7); + this.Controls.Add(this.txtXmlFilNamn); + this.Controls.Add(this.label6); + this.Controls.Add(this.txtXmlReadCopy); + this.Controls.Add(this.label5); + this.Controls.Add(this.txtXmlCopy); this.Controls.Add(this.label4); this.Controls.Add(this.txtProgramName); this.Controls.Add(this.label3); @@ -169,6 +232,12 @@ private System.Windows.Forms.Label label3; private System.Windows.Forms.TextBox txtProgramName; private System.Windows.Forms.Label label4; + private System.Windows.Forms.TextBox txtXmlCopy; + private System.Windows.Forms.Label label5; + private System.Windows.Forms.Label label6; + private System.Windows.Forms.TextBox txtXmlReadCopy; + private System.Windows.Forms.Label label7; + private System.Windows.Forms.TextBox txtXmlFilNamn; } } diff --git a/CobProgAid/CobProgAid/frmProgAidHome.cs b/CobProgAid/CobProgAid/frmProgAidHome.cs index b6d1549..04a5e8d 100644 --- a/CobProgAid/CobProgAid/frmProgAidHome.cs +++ b/CobProgAid/CobProgAid/frmProgAidHome.cs @@ -54,7 +54,7 @@ namespace CobProgAid workItem = resourceSet.GetString(lstProgTyp.SelectedItem.ToString()); //string comment = resourceSet. coch.Template = workItem; - + coch.TemplateName = lstProgTyp.SelectedItem.ToString(); } private void btnCreate_Click(object sender, EventArgs e) @@ -66,10 +66,6 @@ namespace CobProgAid ShCd.ShowDialog(); } - private void txtProgramName_TextChanged(object sender, EventArgs e) - { - coch.ProgName = txtProgramName.Text; - } private void cmbFilename_SelectedIndexChanged(object sender, EventArgs e) { @@ -85,5 +81,25 @@ namespace CobProgAid txtShow.Text = coch.CodeOut; } + private void txtProgramName_TextChanged(object sender, EventArgs e) + { + coch.ProgName = txtProgramName.Text; + } + + private void txtXmlCopy_TextChanged(object sender, EventArgs e) + { + coch.XMLcopy = txtXmlCopy.Text; + } + + private void txtXmlReadCopy_TextChanged(object sender, EventArgs e) + { + coch.XMLReadCopy = txtXmlReadCopy.Text; + } + + private void txtXmlFilNamn_TextChanged(object sender, EventArgs e) + { + coch.XMLfilename = txtXmlFilNamn.Text; + } + } }