/// <summary> /// Executes the CopyAllItems command. /// </summary> /// <param name="sender">The sender.</param> /// <param name="eventArgs">Event arguments</param> public void ExecuteCopyAllItemsCommand(object sender, ExecutedRoutedEventArgs eventArgs) { foreach (var item in List1) { List2.Add(item); } List1.Clear(); OnPropertyChanged(() => List1); OnPropertyChanged(() => List2); }
private void ListView_Drop(object sender, DragEventArgs e) { if (list == 1) { if (e.Data.GetDataPresent("myFormat")) { Model.Softver soft = e.Data.GetData("myFormat") as Model.Softver; List1.Remove(soft); List2.Add(soft); //SaveList2.Add(soft); } } }
private void Text_Changed(object sender, TextChangedEventArgs e) { var textBox = sender as TextBox; // MessageBox.Show("Search "+ textBox.Text); if (SaveList2 != null) { foreach (Softver s in SaveList2) { if (!List2.Contains(s)) { List2.Add(s); } } } if (textBox.Text != "") { SaveList2 = new List <Softver>(); foreach (Softver s in List2) { if (s != null) { SaveList2.Add(s); } } //MessageBox.Show("Savelist: "+ SaveList2.Count); List <Softver> filtered = new List <Softver>(); foreach (Softver s in List2) { if (!s.Naziv.Contains(textBox.Text) && !s.Oznaka.Contains(textBox.Text)) { filtered.Add(s); } } if (filtered.Count != 0) { foreach (Softver f in filtered) { List2.Remove(f); } //List2.Remove(s => s); // List2 = new ObservableCollection<Softver>(filtered); // MessageBox.Show("jepp: "+filtered.Count); } } }
private void Execute_List1_SelectedIndexChanged(object o) { My_thread thread = list1_SelectedIndex; list1_SelectedIndex = null; if (thread != null) { List1.Remove(thread); OnPropertyChanged(nameof(List1)); List2.Add(thread); OnPropertyChanged(nameof(List2)); thread.isWeit = true; thread.temp.Start(); } }
public ICollection<float>[] GetDataAt(float position, bool horizontal, bool forOutLinesOnly, out int axis1, out int axis2) { Type.GetDataAt(ref List1, ref List2, data, ai, position, horizontal, forOutLinesOnly, out axis1, out axis2); if (AttachedCurve != null) { if (position <= AttachedCurve.GetMaxPosition(horizontal)) { var attachList = AttachedCurve.GetDataAt(position, horizontal, forOutLinesOnly, out _, out _); foreach (var item in attachList[0]) List1.Add(item); foreach (var item in attachList[1]) List2.Add(item); } } return new ICollection<float>[] { List1, List2 }; }
public Task TransformAsync(object item, TypeAccessor typeAccessor, IGraphRequestContext context) { if (item.GetType() == typeof(MockModel1)) { List1.Add((MockModel1)item); } if (item.GetType() == typeof(MockModel2)) { List2.Add((MockModel2)item); } if (item.GetType() == typeof(MockModel3)) { List3.Add((MockModel3)item); } if (item.GetType() == typeof(MockModel4)) { List4.Add((MockModel4)item); } return(Task.CompletedTask); }
void Init() { //initialize cs1, cs2 to suit the database connection details. try { string servername1 = server1.ToString(); string uname1 = uid1.ToString(); string pass1 = pwd1.ToString(); string dbName1 = dbname1.ToString(); string tbl1 = table1.ToString(); string tbl2 = table2.ToString(); conn1 = new MySqlConnection(cs1); conn1.Open(); conn2 = new MySqlConnection(cs2); conn2.Open(); tbl1 = "abc"; tbl2 = "def"; // Load target list's ids and timestamps string stmt1 = "SELECT seriennummer, DATE_FORMAT(fdate, '%Y-%M-%D %H:%i:%s') FROM " + tbl1; MySqlCommand cmd1 = new MySqlCommand(stmt1, conn1); List& lt; IdTsEntry> A = new List & lt; IdTsEntry> (); using (MySqlDataReader reader = cmd1.ExecuteReader()) { //while (reader.Read()) //{ // I assume the fields are set to NOT NULL // A.Add(new IdTsEntry() // { // fid = reader.GetInt64(0), // fdate = reader.GetString(1) // }); //} while (reader.Read()) { // I assume the fields are set to NOT NULL A.Add(new IdTsEntry() { fid = reader.IsDBNull(0) ? -1L : reader.GetInt64(0), fdate = reader.IsDBNull(1) ? "" : reader.GetString(1) }); } } // Load source list's ids and timestamps string stmt2 = "SELECT fid, DATE_FORMAT(fdate, '%Y-%M-%D %H:%i:%s') FROM " + tbl2; MySqlCommand cmd2 = new MySqlCommand(stmt2, conn2); List< IdTsEntry> B = new List & lt; IdTsEntry> (); using (MySqlDataReader reader = cmd2.ExecuteReader()) { while (reader.Read()) { // I assume the fields are set to NOT NULL B.Add(new IdTsEntry() { fid = reader.GetInt64(0), fdate = reader.GetString(1) }); } } // Filter lists List< Int64> List1 = new List & lt; Int64> (); List< Int64> List2 = new List & lt; Int64> (); foreach (IdTsEntry b in B) { var a = A.FirstOrDefault(e = > e.fid.Equals(b.fid)); if (a == null) { List2.Add(b.fid); // b.id not in A -&gt; new row } else if (!a.fdate.Equals(b.fdate)) { List1.Add(b.fid); // b.id in A but other timestamp -&gt; altered row } } // Update altered rows //string ct1 = "SELECT variante,charge,DATE_FORMAT(fdate, '%Y-%M-%D %H:%i:%s') FROM " + tbl2 + " WHERE fid = {0}"; //string ct2 = "UPDATE " + tbl1 + " SET variante = @val1,charge = @val2, fdate = @val3 WHERE seriennummer = {0}"; foreach (Int64 id in List1) { // Read all entry values into parameters // cmd1.CommandText = String.Format(ct1, id); cmd1.CommandText = "SELECT variante,charge,DATE_FORMAT(fdate, '%Y-%M-%D %H:%i:%s') FROM " + tbl2 + " WHERE fid = " + id.ToString(); // MessageBox.Show(cmd1.CommandText); cmd2.Parameters.Clear(); int i = 0; using (MySqlDataReader reader = cmd1.ExecuteReader()) { if (!reader.Read()) { continue; } for (int n = 0; n< reader.FieldCount; n++) { cmd2.Parameters.AddWithValue(String.Format("val{0}", ++i), reader.IsDBNull(n) ? DBNull.Value : reader.GetValue(n)); } } // Update row //cmd2.CommandText = String.Format(ct2, id); cmd2.CommandText = "UPDATE " + tbl1 + " SET variante = @val1,charge = @val2, fdate = @val3 WHERE seriennummer = " + id.ToString(); cmd2.ExecuteNonQuery(); } // Insert new rows //ct1 = "SELECT fid, variante,charge,DATE_FORMAT(fdate, '%Y-%M-%D %H:%i:%s') FROM " + tbl2 + " WHERE fid = {0}"; //ct2 = "INSERT INTO " + tbl1 + " (seriennummer, variante,charge,fdate) " + // "VALUES (@val1, @val2, @val3, @val4)"; // cmd2.CommandText = ct2; cmd2.CommandText = "INSERT INTO " + tbl1 + " (seriennummer,variante,charge,fdate) " + "VALUES (@val1, @val2, @val3, @val4)"; foreach (Int64 id in List2) { // Read all values into parameters //cmd1.CommandText = String.Format(ct1, id); cmd1.CommandText = "SELECT fid,variante,charge,DATE_FORMAT(fdate, '%Y-%M-%D %H:%i:%s') FROM " + tbl2 + " WHERE fid = " + id.ToString(); cmd2.Parameters.Clear(); int i = 0; using (MySqlDataReader reader = cmd1.ExecuteReader()) { if (!reader.Read()) { continue; } for (int n = 0; n< reader.FieldCount; n++) { cmd2.Parameters.AddWithValue(String.Format("val{0}", ++i), reader.IsDBNull(n) ? DBNull.Value : reader.GetValue(n)); } } // Insert row cmd2.ExecuteNonQuery(); } } catch (MySqlException ex) { MessageBox.Show("Error: " + ex.ToString()); } }