コード例 #1
0
        private void ServerSelectFileButton_Click(object sender, RoutedEventArgs e)
        {
            serverReceiverList = new List <ClientMessageWithTimeStamp>();
            serverSenderList   = new List <ServerMessageWithTimestamp>();
            OpenFileDialog openFileDialog = new OpenFileDialog();

            if (openFileDialog.ShowDialog() == true)
            {
                var tempStringTab = File.ReadAllLines(openFileDialog.FileName);
                foreach (var s in tempStringTab)
                {
                    if (s.Split(' ')[2].Contains("Received"))
                    {
                        try
                        {
                            var temp     = JsonConvert.DeserializeObject <ClientMessage>(s.Split(' ')[5].TrimEnd('@'));
                            var withTime = new ClientMessageWithTimeStamp(temp,
                                                                          DateTime.ParseExact((s.Split(' ')[0] + " " + s.Split(' ')[1]), "yyyy-MM-dd HH:mm:ss,fff",
                                                                                              CultureInfo.InvariantCulture));
                            serverReceiverList.Add(withTime);
                        }
                        catch (Exception exception)
                        {
                            //LogAnError(exception);
                        }
                    }
                    if (s.Split(' ')[2].Contains("Sent"))
                    {
                        try
                        {
                            var temp     = JsonConvert.DeserializeObject <ServerMessage>(s.Split(' ')[5].TrimEnd('@'));
                            var withTime = new ServerMessageWithTimestamp(temp,
                                                                          DateTime.ParseExact((s.Split(' ')[0] + " " + s.Split(' ')[1]), "yyyy-MM-dd HH:mm:ss,fff",
                                                                                              CultureInfo.InvariantCulture));
                            serverSenderList.Add(withTime);
                        }
                        catch (Exception exception)
                        {
                            //LogAnError(exception);
                        }
                    }
                }
                ServerReceiverListBox.ItemsSource = serverReceiverList;
                ServerSenderListBox.ItemsSource   = serverSenderList;
            }
        }
コード例 #2
0
        private void ReceiverSelectFileButton_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            if (openFileDialog.ShowDialog() == true)
            {
                var tempStringTab = File.ReadAllLines(openFileDialog.FileName);
                receiverList = new List <ServerMessageWithTimestamp>();
                foreach (var s in tempStringTab)
                {
                    if (s.Contains("Received from Server"))
                    {
                        var temp     = JsonConvert.DeserializeObject <ServerMessage>(s.Split(' ')[5].TrimEnd('@'));
                        var withTime = new ServerMessageWithTimestamp(temp,
                                                                      DateTime.ParseExact((s.Split(' ')[0] + " " + s.Split(' ')[1]), "yyyy-MM-dd HH:mm:ss,fff",
                                                                                          CultureInfo.InvariantCulture));
                        receiverList.Add(withTime);
                    }
                }
                ReceiverListBox.ItemsSource = receiverList;
            }
        }