public async void LoadData() { var golfs = await _adminDataUnit.GolfsRepository.GetAllAsync(); AvailableGolfResources = new ObservableCollection<GolfModel>(golfs.Select(x => new GolfModel(x)).OrderBy(x => x.Name)); GolfFollowResources = new ObservableCollection<GolfModel>(Golf.Golf.GolfFollowResources.Select(x => AvailableGolfResources.Where(p => p.Golf.ID == x.FollowResourceID).FirstOrDefault())); RaisePropertyChanged("AddSelectedItems"); }
public void send() { Console.WriteLine("sending the messsages"); App.Current.Dispatcher.Invoke((Action)delegate() { InputBlock.Text = InputBlock.Text + Environment.NewLine + "sending the messsages" + " " + DateTime.Now.ToString(); }); _networkList = new ObservableCollection<Network>(App.am.Networks); foreach (Network n in _networkList) { if (n.Status == "connected") { Console.WriteLine(" we are sending the messsages to " + n.Names + " Network:"); App.Current.Dispatcher.Invoke((Action)delegate() { InputBlock.Text = InputBlock.Text + Environment.NewLine + " we are sending the messsages to " + n.Names + " Network:" + " " + DateTime.Now.ToString(); Scroller.ScrollToBottom(); InputBlock.ScrollToEnd(); }); _prefixList = new ObservableCollection<Prefix>(App.am.Prefixs); foreach (Prefix p in _prefixList) { if (p.Provider == n.Names) { _messageList = new ObservableCollection<Message>(App.am.Messages); if (_messageList.Where(y => y.Sent == "F").Count() > 0) { Console.WriteLine("sending for :" + n.Names); foreach (Message u in _messageList) { if (u.Sent == "F" && u.Numbers.Contains(p.Pre)) { // myQs.Enqueue(n.Comm,u.Numbers,u.Messages); App.Current.Dispatcher.Invoke((Action)delegate() { InputBlock2.Text = InputBlock2.Text + Environment.NewLine + "Number: " + u.Numbers + " : " + u.Messages + " " + DateTime.Now.ToString(); Scroller.ScrollToBottom(); InputBlock2.ScrollToEnd(); }); try { //Sender(DBObject parent, string id, string message, string number, string network) // if (Messenger.SendUpdate(App.am, u.Id, u.Messages, u.Numbers, n.Names,n.Comm)) //{ if (Messenger.Sender(App.am, u.Id, u.Messages, u.Numbers, n.Names)) { App.Current.Dispatcher.Invoke((Action)delegate() { InputBlock2.Text = InputBlock2.Text + Environment.NewLine + "Message sent:... " + u.Numbers + " " + DateTime.Now.ToString(); Scroller.ScrollToBottom(); InputBlock2.ScrollToEnd(); }); } else { App.Current.Dispatcher.Invoke((Action)delegate() { InputBlock2.Text = InputBlock2.Text + Environment.NewLine + " Message not sent:... " + u.Numbers + " " + DateTime.Now.ToString(); Scroller.ScrollToBottom(); InputBlock2.ScrollToEnd(); }); } Console.WriteLine("Sending process:-number:" + u.Numbers + " : " + u.Messages); } catch { App.Current.Dispatcher.Invoke((Action)delegate() { InputBlock.Text = InputBlock2.Text + Environment.NewLine + "there is an error somewhere....." + DateTime.Now.ToString(); Scroller.ScrollToBottom(); InputBlock2.ScrollToEnd(); }); } } } } } } } } }
/// <summary> /// Get category details from database /// </summary> /// <param name="categoryName">Category name to filter records</param> private void GetCategoryDetails(string categoryName) { LstCategoryName = new ObservableCollection<ProductCategoryDTO>(from item in ServiceFactory.ServiceClient.GetCategories() select item).ToList(); if (!string.IsNullOrEmpty(categoryName)) { LstCategoryName = LstCategoryName.Where(item => item.Name.Contains(categoryName)).ToList(); } }
private void Button_Click(object sender, RoutedEventArgs e) { // Open file system to select file(s) Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog(); dlg.Multiselect = true; Nullable<bool> result = dlg.ShowDialog(); // Display OpenFileDialog by calling ShowDialog method byte[] rawData; List<Tuple<string, byte[]>> dataList = new List<Tuple<string, byte[]>>(); string ext = ""; string filename = ""; // Add all files selected into the the db. If multiple files added, project destination is the same. foreach (String file in dlg.FileNames) { // Get the selected file name and display in a TextBox if (result.HasValue == true && result.Value == true) { rawData = File.ReadAllBytes(file); dataList.Add(Tuple.Create(file, rawData)); ext = Path.GetExtension(file); filename = file; } } AnalysisMsgPrompt a = new AnalysisMsgPrompt(new DataGridLoader(), null); if (a.ShowDialog() == true) { dgl.loadSpeakers(a.PID); rowS = dgl.getCollection("S"); foreach (var elem in rowS.ToList()) { ((dynamic)rowS).Add((Speaker)elem); } foreach (var dataItem in dataList) { var comm = new MySqlCommand(); filename = Path.GetFileName(dataItem.Item1); using (DBConnection db = new DBConnection()) { comm.CommandText = "INSERT INTO Analysis (AID, Description, FileData, FileType) VALUES(@AID, @Desc, @FileAsBlob, @FileType)"; comm.Parameters.AddWithValue("@AID", filename); if (a.Desc.Equals("")) { comm.Parameters.AddWithValue("@Desc", "No description"); } else { //Add to analysis table comm.CommandText = "create table if not exists analysis (AID varchar(150) primary key, File mediumblob, Description varchar(500))"; comm.ExecuteNonQuery(); comm.CommandText = "INSERT INTO analysis (AID, File, Description) VALUES(@AID, @FileAsBlob, @Desc)"; comm.Parameters.AddWithValue("@AID", dataItem.Item1); comm.Parameters.AddWithValue("@FileAsBlob", dataItem.Item2); if (a.Desc.Equals("")) { comm.Parameters.AddWithValue("@Desc", "No description"); } else { comm.Parameters.AddWithValue("@Desc", a.Desc); } comm.ExecuteNonQuery(); //Add to the mapping table(to link with speaker) List<Row> startsWithAge = rowS.Where(s => ((Speaker)s).SpeakerName.StartsWith(a.Age)).ToList(); MessageBox.Show(a.Age); foreach (var row in rowS) { //comm.CommandText = "create table if not exists files2analysis (AID varchar(150) primary key, ID varchar(150) primary key)"; //comm.ExecuteNonQuery(); if (((Speaker)row).SpeakerName.StartsWith(a.Age)) { db.insertIntoDB(comm); } comm.CommandText = "INSERT IGNORE INTO files2analysis (ID, AID) VALUES (@ID2, @AID2)"; comm.Parameters.Clear(); comm.Parameters.AddWithValue("@ID2", ((Speaker)row).ID); comm.Parameters.AddWithValue("@AID2", dataItem.Item1); comm.ExecuteNonQuery(); } HashSet<Tuple<String, String>> uniqueAnalysis = new HashSet<Tuple<String, String>>(); HashSet<Tuple<String, String>> uniqueRowName = new HashSet<Tuple<String, String>>(); string previous = ""; foreach (var row in rowS) { if (!((Speaker)row).Name.Equals(previous)) { previous = ((Speaker)row).Name; uniqueAnalysis.Add(Tuple.Create(((Speaker)row).Name, ((Speaker)row).ID)); } } foreach (var uRow in uniqueAnalysis) { if ((uRow.Item1.StartsWith(a.Age))) { comm.CommandText = "INSERT IGNORE INTO File2Analysis (File_FID, Analysis_AID) VALUES (@FileID, @AID)"; comm.Parameters.Clear(); comm.Parameters.AddWithValue("@FileID", uRow.Item2); comm.Parameters.AddWithValue("@AID", filename); db.insertIntoDB(comm); } } } } } } }