I have two lists:
The first one called _listData
and with structure:
public List<GraphData> _gData = new List<GraphData>();
public struct GraphData
{
public double Temp1;
public double Temp2;
public DateTime Date;
public string Type;
}
The second is populated with data in the same time than the first one (in other words, they will have the same amount of lines - this is important because I want to use Index):
FormA_DataType.GraphDataWithID newData2 = new FormA_DataType.GraphDataWithID();
FormA_DataType.GraphDataWithID();
public struct GraphDataWithID
{
public int IdHeader;
public string Type;
}
The information is populated this way:
FormA_DataType.GraphDataWithID newData2 = new FormA_DataType.GraphDataWithID();
FormA_DataType.GraphDataWithID();
public struct GraphDataWithID
{
public int IdHeader;
public string Type;
}
if (!item.Full_File_Name.EndsWith("-B") && !item.Full_File_Name.StartsWith("Load_"))
{
FormA_DataType.GraphData newData = new FormA_DataType.GraphData();
FormA_DataType.GraphDataWithID newData2 = new FormA_DataType.GraphDataWithID();
newData.Date = item.Time;
newData.Temp1 = item.Start_temp;
newData.Temp2 = item.Start_temp;
newData.Type = item.Cycle_Type.Replace("Unknown", "");
newData2.Type = item.Cycle_Type.Replace("Unknown", "");
newData2.IdHeader = item.Id_Tbl_Data_Type_Ro_Header;
_gData.Add(newData);
}
I send a table clone of _gData
to be used in a Graph. There, the user will change the field "type" with some interaction. Then, I compared what I sent to the graph and what I received from the graph
public bool CheckForDifferenceListInPointCycle()
{
List<FormA_DataType.GraphData> secondNotFirst = Graph._listData.Except(_gData).ToList();
if (secondNotFirst.Count>0) // there are differences between the lists
{
return true;
}
return false;
}
So, I have the Lines with the difference between what I send to the graph and what I received back from the graph. I need to update these differences in the table "newData2"
- I know what changed because I can compare the Table before and after "Graph interaction". With this difference, I should get the index of this change and use this index to update the table "NewData2". The Index from _gData and newData2 are the same.
Is there any help that you can think of?
To better understand:
- I create two lists at the same time: _gData and newData2;
_gData =
12:45:00 | 140 | 160 | "Unknown"
12:45:00 | 140 | 180| "Temp"
newData2 =
"Unknown" | 45
"Temp" | 49
- I send _gData to graph... Then I return:
_listData
12:45:00 | 140 | 160 | "New1"
12:45:00 | 140 | 180| "New2"
I need to update, based on the index, "New1" and "New2" in newData2. So, I will have:
newData2 =
"New1" | 45
"New2" | 49
Finally, the question is:
I need to know how to create the loop to update table "newData2" based on the information from "_gData ".
It will be something similar to this
private void button3_Click(object sender, EventArgs e)
{
if(CheckForDifferenceListInPointCycle())
{
foreach (var x in Graph._listData)
{
var itemToChange = newData2.First(d => d.Type == x.Type).Type = x.Type;
}
}
}