Option 'LoadAllValues' dazu
- Legt fest, ob alle Gruppen oder nur die angegeben Gruppe geladen wird
This commit is contained in:
parent
afc1be5b5b
commit
58200095f4
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -131,7 +131,7 @@ namespace Eugen.ESystem.IO
|
||||
// Das Dokument in eine neue XElement-Instanz laden
|
||||
XElement rootElement = XElement.Load(FileName);
|
||||
|
||||
//Nur wenn das 'rootElement' so beginnt wie 'Topi' heißt oder 'LoadAllValues' 'Yes' ist, dann die Elemente laden
|
||||
//Nur wenn das 'rootElement' so beginnt wie 'Topic' heißt oder 'LoadAllValues' 'Yes' ist, dann die Elemente laden
|
||||
if (rootElement.ToString().Remove(rootElement.ToString().IndexOf(" ")) == "<" + Topic || LoadAllValues == LoadAll.Yes)
|
||||
{
|
||||
// Auflistung für die Gruppe erzeugen
|
||||
@ -141,10 +141,17 @@ namespace Eugen.ESystem.IO
|
||||
//var personElements = rootElement.Elements(Group);
|
||||
var groupElements = rootElement.Elements();
|
||||
|
||||
if (LoadAllValues == LoadAll.Yes)
|
||||
{
|
||||
Group = "";
|
||||
}
|
||||
|
||||
if (String.IsNullOrEmpty(Group))
|
||||
{
|
||||
string[] temp = new string[5];
|
||||
|
||||
List<string> lgroups = new List<string>();
|
||||
List<string> lid = new List<string>();
|
||||
List<string> lkeys = new List<string>();
|
||||
List<string> lvalues = new List<string>();
|
||||
List<string> lstandard = new List<string>();
|
||||
@ -178,17 +185,24 @@ namespace Eugen.ESystem.IO
|
||||
|
||||
Group = ExtractGroup(temp);
|
||||
Key = ExtractKey(temp);
|
||||
lgroups.Add(ExtractGroup(temp));
|
||||
lid.Add(ExtractId(temp));
|
||||
lkeys.Add(ExtractKey(temp));
|
||||
lvalues.Add(ExtractValue(temp));
|
||||
lstandard.Add(ExtractStandard(temp));
|
||||
}
|
||||
}
|
||||
|
||||
string[,] values = new string[lvalues.Count, 3];
|
||||
string[,] values = new string[lvalues.Count, 5];
|
||||
int standard = 0;
|
||||
|
||||
for (int i = 0; i < lvalues.Count; i++)
|
||||
{
|
||||
values[i, 2] = lvalues[i];
|
||||
values[i, 0] = lgroups[i];
|
||||
values[i, 1] = lid[i];
|
||||
values[i, 2] = lkeys[i];
|
||||
values[i, 3] = lvalues[i];
|
||||
values[i, 4] = lstandard[i];
|
||||
|
||||
if (lstandard[i] == "yes")
|
||||
{
|
||||
@ -210,6 +224,9 @@ namespace Eugen.ESystem.IO
|
||||
Topics group = new Topics();
|
||||
groups.Add(group);
|
||||
|
||||
//Den Gruppennamen extrahieren
|
||||
group.GroupName = groupElement.ToString().Remove(groupElement.ToString().IndexOf(" ")).Remove(0, 1);
|
||||
|
||||
//Das Attribut id einlesen
|
||||
XAttribute idAttribute = groupElement.Attribute("Id");
|
||||
if (idAttribute != null)
|
||||
@ -248,6 +265,11 @@ namespace Eugen.ESystem.IO
|
||||
return temp[0].Remove(0, 1);
|
||||
}
|
||||
|
||||
private string ExtractId(string[] temp)
|
||||
{
|
||||
return temp[1].Remove(temp[1].LastIndexOf("\"")).Remove(0, 4);
|
||||
}
|
||||
|
||||
private string ExtractKey(string[] temp)
|
||||
{
|
||||
return temp[2].Remove(temp[2].IndexOf("="));
|
||||
@ -265,13 +287,14 @@ namespace Eugen.ESystem.IO
|
||||
|
||||
private void DataPreperation(List<Topics> groups)
|
||||
{
|
||||
string[,] values = new string[groups.Count, 3];
|
||||
string[,] values = new string[groups.Count, 4];
|
||||
|
||||
for (int i = 0; i < groups.Count; i++)
|
||||
{
|
||||
values[i, 0] = groups[i].Id;
|
||||
values[i, 1] = groups[i].Key;
|
||||
values[i, 2] = groups[i].Standard;
|
||||
values[i, 0] = groups[i].GroupName;
|
||||
values[i, 1] = groups[i].Id;
|
||||
values[i, 2] = groups[i].Key;
|
||||
values[i, 3] = groups[i].Standard;
|
||||
|
||||
if (groups[i].Standard == "yes")
|
||||
{
|
||||
@ -285,6 +308,7 @@ namespace Eugen.ESystem.IO
|
||||
|
||||
class Topics
|
||||
{
|
||||
public string GroupName;
|
||||
public string Id;
|
||||
public string Key;
|
||||
public string Standard;
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
45
Test_LoadXMLFile/Form1.Designer.cs
generated
45
Test_LoadXMLFile/Form1.Designer.cs
generated
@ -33,7 +33,9 @@
|
||||
this.labelProgramInfo = new System.Windows.Forms.Label();
|
||||
this.groupBoxDLLInfo = new System.Windows.Forms.GroupBox();
|
||||
this.labelDLLInfo = new System.Windows.Forms.Label();
|
||||
this.labelResult = new System.Windows.Forms.Label();
|
||||
this.labelResult1 = new System.Windows.Forms.Label();
|
||||
this.labelResult2 = new System.Windows.Forms.Label();
|
||||
this.checkBoxLoadAllValues = new System.Windows.Forms.CheckBox();
|
||||
this.groupBoxProgramInfo.SuspendLayout();
|
||||
this.groupBoxDLLInfo.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
@ -88,21 +90,42 @@
|
||||
this.labelDLLInfo.TabIndex = 0;
|
||||
this.labelDLLInfo.Text = "...";
|
||||
//
|
||||
// labelResult
|
||||
// labelResult1
|
||||
//
|
||||
this.labelResult.AutoSize = true;
|
||||
this.labelResult.Location = new System.Drawing.Point(12, 13);
|
||||
this.labelResult.Name = "labelResult";
|
||||
this.labelResult.Size = new System.Drawing.Size(16, 13);
|
||||
this.labelResult.TabIndex = 13;
|
||||
this.labelResult.Text = "...";
|
||||
this.labelResult1.AutoSize = true;
|
||||
this.labelResult1.Location = new System.Drawing.Point(12, 13);
|
||||
this.labelResult1.Name = "labelResult1";
|
||||
this.labelResult1.Size = new System.Drawing.Size(16, 13);
|
||||
this.labelResult1.TabIndex = 13;
|
||||
this.labelResult1.Text = "...\r\n";
|
||||
//
|
||||
// labelResult2
|
||||
//
|
||||
this.labelResult2.AutoSize = true;
|
||||
this.labelResult2.Location = new System.Drawing.Point(410, 26);
|
||||
this.labelResult2.Name = "labelResult2";
|
||||
this.labelResult2.Size = new System.Drawing.Size(16, 13);
|
||||
this.labelResult2.TabIndex = 14;
|
||||
this.labelResult2.Text = "...";
|
||||
//
|
||||
// checkBoxLoadAllValues
|
||||
//
|
||||
this.checkBoxLoadAllValues.AutoSize = true;
|
||||
this.checkBoxLoadAllValues.Location = new System.Drawing.Point(12, 264);
|
||||
this.checkBoxLoadAllValues.Name = "checkBoxLoadAllValues";
|
||||
this.checkBoxLoadAllValues.Size = new System.Drawing.Size(97, 17);
|
||||
this.checkBoxLoadAllValues.TabIndex = 15;
|
||||
this.checkBoxLoadAllValues.Text = "Load all values";
|
||||
this.checkBoxLoadAllValues.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// Form1
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.Controls.Add(this.labelResult);
|
||||
this.Controls.Add(this.checkBoxLoadAllValues);
|
||||
this.Controls.Add(this.labelResult2);
|
||||
this.Controls.Add(this.labelResult1);
|
||||
this.Controls.Add(this.groupBoxProgramInfo);
|
||||
this.Controls.Add(this.groupBoxDLLInfo);
|
||||
this.Controls.Add(this.buttonShowInfo);
|
||||
@ -125,7 +148,9 @@
|
||||
private System.Windows.Forms.Label labelProgramInfo;
|
||||
private System.Windows.Forms.GroupBox groupBoxDLLInfo;
|
||||
private System.Windows.Forms.Label labelDLLInfo;
|
||||
private System.Windows.Forms.Label labelResult;
|
||||
private System.Windows.Forms.Label labelResult1;
|
||||
private System.Windows.Forms.Label labelResult2;
|
||||
private System.Windows.Forms.CheckBox checkBoxLoadAllValues;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -126,46 +126,74 @@ namespace Test_LoadXMLFile
|
||||
load.Group = "Management";
|
||||
load.Key = "Method";
|
||||
//load.LoadAllValues = LoadXMLFile.LoadAll.Yes; //Es werden alle Elemente geladen
|
||||
load.LoadAllValues = LoadXMLFile.LoadAll.No; //Es werden nur die Elemente geladen, die unter 'Group' gespeichert sind
|
||||
load.Load();
|
||||
//load.LoadAllValues = LoadXMLFile.LoadAll.No; //Es werden nur die Elemente geladen, die unter 'Group' gespeichert sind
|
||||
//load.Load();
|
||||
|
||||
if (load.Values != null)
|
||||
if (checkBoxLoadAllValues.Checked)
|
||||
{
|
||||
labelResult.Text = Ausgabe(load.FileName, load.Topic, load.Group, load.Key, load.Values);
|
||||
}
|
||||
load.LoadAllValues = LoadXMLFile.LoadAll.Yes; //Es werden alle Elemente geladen
|
||||
load.Load();
|
||||
|
||||
load.Group = "NX";
|
||||
load.Key = "Version";
|
||||
load.Load();
|
||||
|
||||
if (load.Values != null)
|
||||
{
|
||||
labelResult.Text += Ausgabe2(load.Group, load.Key, load.Values);
|
||||
if (load.Values != null)
|
||||
{
|
||||
labelResult1.Text = Ausgabe("Yes", load.FileName, load.Topic, load.Group, load.Key, load.Values);
|
||||
labelResult2.Text = "";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
labelResult.Text = "Keine Werte";
|
||||
load.LoadAllValues = LoadXMLFile.LoadAll.No; //Es werden nur die Elemente geladen, die unter 'Group' gespeichert sind
|
||||
load.Load();
|
||||
|
||||
if (load.Values != null)
|
||||
{
|
||||
labelResult1.Text = Ausgabe1(load.FileName, load.Topic, load.Group, load.Key, load.Values);
|
||||
}
|
||||
|
||||
//Neue Gruppe setzen
|
||||
load.Group = "NX";
|
||||
load.Key = "Version";
|
||||
load.Load();
|
||||
|
||||
if (load.Values != null)
|
||||
{
|
||||
labelResult2.Text = Ausgabe2(load.Group, load.Key, load.Values);
|
||||
}
|
||||
else
|
||||
{
|
||||
labelResult1.Text = "Keine Werte";
|
||||
labelResult2.Text = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private string Ausgabe(string fileName, string topic, string group, string key, string[,] values)
|
||||
private string Ausgabe(string loadAll, string fileName, string topic, string group, string key, string[,] values)
|
||||
{
|
||||
string result = "";
|
||||
|
||||
result = "Filename: " + fileName;
|
||||
result += "\r\nTopic: " + topic;
|
||||
result += "\r\nGroup: " + group;
|
||||
result += "\r\nKey: " + key;
|
||||
result += "\r\n\r\nValues (ID - Methode - Standard): ";
|
||||
result += "\r\nLoad all values: " + loadAll;
|
||||
result += "\r\n\r\nValues (Group - ID - Key - Keyvalue - Standard): ";
|
||||
|
||||
int z = 0;
|
||||
|
||||
foreach (var item in values)
|
||||
{
|
||||
if (z == 3)
|
||||
if (z == 5)
|
||||
{
|
||||
z = 0;
|
||||
}
|
||||
if (z == 4)
|
||||
{
|
||||
result += " - " + item;
|
||||
z++;
|
||||
}
|
||||
if (z == 3)
|
||||
{
|
||||
result += " - " + item;
|
||||
z++;
|
||||
}
|
||||
if (z == 2)
|
||||
{
|
||||
result += " - " + item;
|
||||
@ -186,6 +214,48 @@ namespace Test_LoadXMLFile
|
||||
return result;
|
||||
}
|
||||
|
||||
private string Ausgabe1(string fileName, string topic, string group, string key, string[,] values)
|
||||
{
|
||||
string result = "";
|
||||
|
||||
result = "Filename: " + fileName;
|
||||
result += "\r\nTopic: " + topic;
|
||||
result += "\r\n\r\nGroup: " + group;
|
||||
result += "\r\nKey: " + key;
|
||||
result += "\r\n\r\nValues (ID - Management - Standard): ";
|
||||
|
||||
int z = 0;
|
||||
|
||||
foreach (var item in values)
|
||||
{
|
||||
if (z == 4)
|
||||
{
|
||||
z = 0;
|
||||
}
|
||||
if (z == 3)
|
||||
{
|
||||
result += " - " + item;
|
||||
z++;
|
||||
}
|
||||
if (z == 2)
|
||||
{
|
||||
result += " - " + item;
|
||||
z++;
|
||||
}
|
||||
if (z == 1)
|
||||
{
|
||||
result += "\r\n" + item;
|
||||
z++;
|
||||
}
|
||||
if (z == 0)
|
||||
{
|
||||
z++;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private string Ausgabe2(string group, string key, string[,] values)
|
||||
{
|
||||
string result = "";
|
||||
@ -198,10 +268,15 @@ namespace Test_LoadXMLFile
|
||||
|
||||
foreach (var item in values)
|
||||
{
|
||||
if (z == 3)
|
||||
if (z == 4)
|
||||
{
|
||||
z = 0;
|
||||
}
|
||||
if (z == 3)
|
||||
{
|
||||
result += " - " + item;
|
||||
z++;
|
||||
}
|
||||
if (z == 2)
|
||||
{
|
||||
result += " - " + item;
|
||||
@ -209,12 +284,11 @@ namespace Test_LoadXMLFile
|
||||
}
|
||||
if (z == 1)
|
||||
{
|
||||
result += " - " + item;
|
||||
result += "\r\n" + item;
|
||||
z++;
|
||||
}
|
||||
if (z == 0)
|
||||
{
|
||||
result += "\r\n" + item;
|
||||
z++;
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user