예제 #1
0
        public void Refresh()
        {
            if (!IsReplaying)
            {
                FilesForReplay.Clear();
                if (Parent.SettingContainer.Settings.GeneralSettings.FileLocations != null && Parent.SettingContainer.Settings.GeneralSettings.FileLocations.Count > 0)
                {
                    foreach (FileLocation loc in Parent.SettingContainer.Settings.GeneralSettings.FileLocations)
                    {
                        Tuple <FileLocation, List <ReplayFile> > tuple = new Tuple <FileLocation, List <ReplayFile> >(loc, new List <ReplayFile>());
                        FilesForReplay.Add(tuple);
                        if (!string.IsNullOrEmpty(loc.Path))
                        {
                            try
                            {
                                string fullPath = Path.GetFullPath(Environment.ExpandEnvironmentVariables(loc.Path));
                                if (Directory.Exists(fullPath))
                                {
                                    foreach (string file in Directory.GetFiles(fullPath, "*.ffc"))
                                    {
                                        ReplayFile replayFile = new ReplayFile()
                                        {
                                            Name = Path.GetFileNameWithoutExtension(file), FullPath = file
                                        };
                                        tuple.Item2.Add(replayFile);
                                        Task.Run(() =>
                                        {
                                            string notes = RawDataReader.ReadNotes(file);
                                            Parent.SyncContext.Post(c =>
                                            {
                                                replayFile.Notes = notes;
                                            }, null);
                                        });
                                    }
                                }
                            }
                            catch (Exception) { }
                        }
                    }
                }
                if (Parent.ConnectivityState == LinkUp.Raw.LinkUpConnectivityState.Connected)
                {
                    RemoteDataStore remoteDataStore = new RemoteDataStore(Parent.SettingContainer.Settings.ConnectionSettings.SelectedConnection.IpAddress, Parent.SettingContainer.Settings.ConnectionSettings.SelectedConnection.Username, Parent.SettingContainer.Settings.ConnectionSettings.SelectedConnection.Password);

                    List <string> files = remoteDataStore.GetAllFileNames("/home/up/data");
                    if (files.Count > 0)
                    {
                        Tuple <FileLocation, List <ReplayFile> > tuple = new Tuple <FileLocation, List <ReplayFile> >(new FileLocation()
                        {
                            Name = "Remote", Path = "/home/up/data", IsRemote = true
                        }, new List <ReplayFile>());
                        FilesForReplay.Add(tuple);

                        foreach (string filename in files)
                        {
                            if (Path.GetExtension(filename) == ".csv")
                            {
                                tuple.Item2.Add(new ReplayFile()
                                {
                                    Name = filename, IsRemote = true, FullPath = string.Format("{0}/{1}", tuple.Item1.Path, filename)
                                });
                            }
                        }
                    }
                }
            }
        }