Save a correct xml-file from extract
This commit is contained in:
15
tomcatAnalys/frmFileShower.Designer.cs
generated
15
tomcatAnalys/frmFileShower.Designer.cs
generated
@ -31,6 +31,8 @@
|
|||||||
this.txtFileShower = new System.Windows.Forms.TextBox();
|
this.txtFileShower = new System.Windows.Forms.TextBox();
|
||||||
this.lblShowerFileName = new System.Windows.Forms.Label();
|
this.lblShowerFileName = new System.Windows.Forms.Label();
|
||||||
this.btnClose = new System.Windows.Forms.Button();
|
this.btnClose = new System.Windows.Forms.Button();
|
||||||
|
this.btnSave = new System.Windows.Forms.Button();
|
||||||
|
this.saveXMLfileDialog = new System.Windows.Forms.SaveFileDialog();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// txtFileShower
|
// txtFileShower
|
||||||
@ -67,11 +69,22 @@
|
|||||||
this.btnClose.UseVisualStyleBackColor = true;
|
this.btnClose.UseVisualStyleBackColor = true;
|
||||||
this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
|
this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
|
||||||
//
|
//
|
||||||
|
// btnSave
|
||||||
|
//
|
||||||
|
this.btnSave.Location = new System.Drawing.Point(626, 513);
|
||||||
|
this.btnSave.Name = "btnSave";
|
||||||
|
this.btnSave.Size = new System.Drawing.Size(75, 23);
|
||||||
|
this.btnSave.TabIndex = 3;
|
||||||
|
this.btnSave.Text = "Spara fil";
|
||||||
|
this.btnSave.UseVisualStyleBackColor = true;
|
||||||
|
this.btnSave.Click += new System.EventHandler(this.btnSave_Click);
|
||||||
|
//
|
||||||
// frmFileShower
|
// frmFileShower
|
||||||
//
|
//
|
||||||
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(813, 551);
|
this.ClientSize = new System.Drawing.Size(813, 551);
|
||||||
|
this.Controls.Add(this.btnSave);
|
||||||
this.Controls.Add(this.btnClose);
|
this.Controls.Add(this.btnClose);
|
||||||
this.Controls.Add(this.lblShowerFileName);
|
this.Controls.Add(this.lblShowerFileName);
|
||||||
this.Controls.Add(this.txtFileShower);
|
this.Controls.Add(this.txtFileShower);
|
||||||
@ -87,5 +100,7 @@
|
|||||||
private System.Windows.Forms.TextBox txtFileShower;
|
private System.Windows.Forms.TextBox txtFileShower;
|
||||||
private System.Windows.Forms.Label lblShowerFileName;
|
private System.Windows.Forms.Label lblShowerFileName;
|
||||||
private System.Windows.Forms.Button btnClose;
|
private System.Windows.Forms.Button btnClose;
|
||||||
|
private System.Windows.Forms.Button btnSave;
|
||||||
|
private System.Windows.Forms.SaveFileDialog saveXMLfileDialog;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@ -12,8 +13,11 @@ namespace tomcatAnalys
|
|||||||
{
|
{
|
||||||
public partial class frmFileShower : Form
|
public partial class frmFileShower : Form
|
||||||
{
|
{
|
||||||
public string FileShowerFileName {
|
public bool SparaMoejlighet { get; set; }
|
||||||
set { lblShowerFileName.Text = value; } }
|
public string FileShowerFileName
|
||||||
|
{
|
||||||
|
set { lblShowerFileName.Text = value; }
|
||||||
|
}
|
||||||
public TextBox FileShowerBox { get; set; }
|
public TextBox FileShowerBox { get; set; }
|
||||||
public frmFileShower()
|
public frmFileShower()
|
||||||
{
|
{
|
||||||
@ -25,5 +29,30 @@ namespace tomcatAnalys
|
|||||||
{
|
{
|
||||||
this.Close();
|
this.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void btnSave_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
string extraLine = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" standalone=\"yes\"?>";
|
||||||
|
string saveFilePath = "";
|
||||||
|
List<string> extract = new List<string>();
|
||||||
|
extract.Add(extraLine);
|
||||||
|
saveXMLfileDialog.Title = "Spara XML-filen";
|
||||||
|
if (saveXMLfileDialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
saveFilePath = saveXMLfileDialog.FileName;
|
||||||
|
foreach (var row in txtFileShower.Lines)
|
||||||
|
{
|
||||||
|
extract.Add(row);
|
||||||
|
}
|
||||||
|
File.WriteAllLines(saveFilePath, extract.ToArray());
|
||||||
|
txtFileShower.Text = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnShown(EventArgs e)
|
||||||
|
{
|
||||||
|
btnSave.Visible = SparaMoejlighet;
|
||||||
|
base.OnShown(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -117,4 +117,7 @@
|
|||||||
<resheader name="writer">
|
<resheader name="writer">
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
|
<metadata name="saveXMLfileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>17, 17</value>
|
||||||
|
</metadata>
|
||||||
</root>
|
</root>
|
||||||
@ -115,7 +115,9 @@ namespace tomcatAnalys
|
|||||||
ListItem aktRad = (ListItem)lbInstances.Items[lbInstances.SelectedIndex];
|
ListItem aktRad = (ListItem)lbInstances.Items[lbInstances.SelectedIndex];
|
||||||
fileWindow.FileShowerFileName = aktRad.GarantiNr + "-" + aktRad.GarantiJob;
|
fileWindow.FileShowerFileName = aktRad.GarantiNr + "-" + aktRad.GarantiJob;
|
||||||
fileWindow.FileShowerBox.Lines = aktRad.xmlRader;
|
fileWindow.FileShowerBox.Lines = aktRad.xmlRader;
|
||||||
|
fileWindow.SparaMoejlighet = true;
|
||||||
fileWindow.ShowDialog();
|
fileWindow.ShowDialog();
|
||||||
|
fileWindow.SparaMoejlighet = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void lbInstances_Click(object sender, EventArgs e)
|
private void lbInstances_Click(object sender, EventArgs e)
|
||||||
|
|||||||
Reference in New Issue
Block a user