new cobol template (XML)

This commit is contained in:
2015-09-08 12:31:56 +02:00
parent 257a0f9a13
commit e886b4f24a
5 changed files with 520 additions and 15 deletions

View File

@ -15,9 +15,14 @@ namespace CobProgAid
//------------------------------------------- //-------------------------------------------
private string template; private string template;
private string templateName;
private string filename; private string filename;
private string progname; private string progname;
private string xmlcopy;
private string xmlreadcopy;
private string xmlfilename;
public string Template public string Template
{ {
get { get {
@ -29,6 +34,18 @@ namespace CobProgAid
process(); process();
} }
} }
public string TemplateName
{
get
{
return templateName;
}
set
{
templateName = value;
}
}
public string CodeOut { get; set; } public string CodeOut { get; set; }
public string FileName 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() private void process()
{ {
string workText = Template; string workText = Template;
@ -64,12 +128,31 @@ namespace CobProgAid
{ {
workText = workText.Replace("XXXXX", filename); 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("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")); 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; CodeOut = workText;
Updated(this, e); Updated(this, e);
} }

View File

@ -1,7 +1,7 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// This code was generated by a tool. // 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 // Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated. // the code is regenerated.
@ -76,11 +76,25 @@ namespace CobProgAid.Properties {
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to hejhopp. /// Looks up a localized string similar to $set p(prexml) (htmlpp) endp
/// *=================================================================
/// copy &quot;cblproto&quot;.
/// *-----------------------------------------------------------------
/// *
/// * FUNKTION PROGRAM MALL XML
/// * SYSTEM $SYSTEM
/// * PROGRAM-ID YYYYYYY
/// * AUTHOR TOMMY ÖMAN, FordonsData AB
/// * DATUM 150908
/// * $BESKRIVNING
/// *
/// *
/// *$$
/// *----------------------------------------------- [rest of string was truncated]&quot;;.
/// </summary> /// </summary>
internal static string hejhopptest { internal static string CobMallXML {
get { get {
return ResourceManager.GetString("hejhopptest", resourceCulture); return ResourceManager.GetString("CobMallXML", resourceCulture);
} }
} }
} }

View File

@ -372,8 +372,331 @@
EXIT.</value> EXIT.</value>
<comment>Normalt genomläsningsprogram för idx-fil</comment> <comment>Normalt genomläsningsprogram för idx-fil</comment>
</data> </data>
<data name="hejhopptest" xml:space="preserve"> <data name="CobMallXML" xml:space="preserve">
<value>hejhopp</value> <value> $set p(prexml) (htmlpp) endp
<comment>bara en testrad</comment> *=================================================================
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 "&lt;".
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 "&gt;".
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 &gt; 0
perform varying kx-rad from 1 by 1
until kx-rad &gt; 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 *&gt; 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.
*--&gt; 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.
*-----------------------------------------------------------------
*&gt; Avsluta programmet
end-program section.
close LOGGFIL
stop run
.
end-program-ex.
exit.
COPY COPPDINITSS.</value>
<comment>mall för läsning xml</comment>
</data> </data>
</root> </root>

View File

@ -38,6 +38,12 @@
this.label3 = new System.Windows.Forms.Label(); this.label3 = new System.Windows.Forms.Label();
this.txtProgramName = new System.Windows.Forms.TextBox(); this.txtProgramName = new System.Windows.Forms.TextBox();
this.label4 = new System.Windows.Forms.Label(); 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(); this.SuspendLayout();
// //
// btnClose // btnClose
@ -85,7 +91,7 @@
this.lstProgTyp.FormattingEnabled = true; this.lstProgTyp.FormattingEnabled = true;
this.lstProgTyp.Location = new System.Drawing.Point(19, 85); this.lstProgTyp.Location = new System.Drawing.Point(19, 85);
this.lstProgTyp.Name = "lstProgTyp"; 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.TabIndex = 5;
this.lstProgTyp.SelectedValueChanged += new System.EventHandler(this.clbProgType_SelectedIndexChanged); this.lstProgTyp.SelectedValueChanged += new System.EventHandler(this.clbProgType_SelectedIndexChanged);
// //
@ -134,11 +140,68 @@
this.label4.TabIndex = 10; this.label4.TabIndex = 10;
this.label4.Text = "Välj programnamn"; 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 // frmProgAidHome
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(766, 659); 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.label4);
this.Controls.Add(this.txtProgramName); this.Controls.Add(this.txtProgramName);
this.Controls.Add(this.label3); this.Controls.Add(this.label3);
@ -169,6 +232,12 @@
private System.Windows.Forms.Label label3; private System.Windows.Forms.Label label3;
private System.Windows.Forms.TextBox txtProgramName; private System.Windows.Forms.TextBox txtProgramName;
private System.Windows.Forms.Label label4; 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;
} }
} }

View File

@ -54,7 +54,7 @@ namespace CobProgAid
workItem = resourceSet.GetString(lstProgTyp.SelectedItem.ToString()); workItem = resourceSet.GetString(lstProgTyp.SelectedItem.ToString());
//string comment = resourceSet. //string comment = resourceSet.
coch.Template = workItem; coch.Template = workItem;
coch.TemplateName = lstProgTyp.SelectedItem.ToString();
} }
private void btnCreate_Click(object sender, EventArgs e) private void btnCreate_Click(object sender, EventArgs e)
@ -66,10 +66,6 @@ namespace CobProgAid
ShCd.ShowDialog(); ShCd.ShowDialog();
} }
private void txtProgramName_TextChanged(object sender, EventArgs e)
{
coch.ProgName = txtProgramName.Text;
}
private void cmbFilename_SelectedIndexChanged(object sender, EventArgs e) private void cmbFilename_SelectedIndexChanged(object sender, EventArgs e)
{ {
@ -85,5 +81,25 @@ namespace CobProgAid
txtShow.Text = coch.CodeOut; 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;
}
} }
} }