Ejemplo n.º 1
0
        private void Import_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog
            {
                InitialDirectory = Directory.GetCurrentDirectory(),
                Filter           = "CSV File (*.csv)|*.csv",
                ReadOnlyChecked  = true
            };

            if (openFileDialog.ShowDialog() != true)
            {
                return;
            }
            var file = openFileDialog.FileName;
            List <IShellItem> csvShelltems = CsvIO.ImportCSVFile(file);

            if (csvShelltems.Count == 0)
            {
                LogAggregator.Instance.ShowIfNotEmpty();
                return;
            }

            if (App.ShellItems != null)
            {
                App.ShellItems.Clear();
            }
            if (App.nodeCollection.nodeList != null)
            {
                App.nodeCollection.nodeList.Clear();
            }

            App.ShellItems = csvShelltems;
            List <IEvent> events = EventParser.GetEvents(App.ShellItems);

            App.nodeCollection.ClearAllFilters();
            App.nodeCollection.nodeList.AddRange(NodeParser.GetNodes(events));

            if (Home.timelinePage == null)
            {
                Home.timelinePage = new TimelinePage();
                App.NavigationService.Navigate(Home.timelinePage);
            }
            else
            {
                Home.timelinePage.RebuildTimeline();
                string timelinePageKey = "timelinepage";
                if (App.pages.ContainsKey(timelinePageKey))
                {
                    App.NavigationService.Navigate(App.pages[timelinePageKey]);
                }
                else
                {
                    App.NavigationService.Navigate(Home.timelinePage);
                }
            }
            LogAggregator.Instance.ShowIfNotEmpty();
        }
Ejemplo n.º 2
0
        public void ExportAndImportCSVWithSpecialCharactersTest()
        {
            // Export
            List <IShellItem>           shellItems          = new List <IShellItem>();
            Dictionary <string, string> shellItemProperties = new Dictionary <string, string>();

            shellItemProperties.Add("Size", "0");
            shellItemProperties.Add("Type", "31");
            shellItemProperties.Add("TypeName", "Some Type Name");
            shellItemProperties.Add("Name", "Some Name, \n \"Name\"");
            shellItemProperties.Add("ModifiedDate", "1/1/0001 12:00:00 AM");
            shellItemProperties.Add("AccessedDate", "1/1/0001 12:00:00 AM");
            shellItemProperties.Add("CreationDate", "1/1/0001 12:00:00 AM");
            CsvParsedShellItem ShellItem = new CsvParsedShellItem(shellItemProperties);

            shellItems.Add(ShellItem);

            if (File.Exists("raw.csv"))
            {
                File.Delete("raw.csv");
            }
            CsvIO.OutputCSVFile(shellItems, "raw.csv");
            Assert.IsTrue(File.Exists("raw.csv"));

            // Import
            List <IShellItem>            importedShellItems = CsvIO.ImportCSVFile("raw.csv");
            IDictionary <string, string> allProperties      = importedShellItems[0].GetAllProperties();

            Assert.IsTrue(allProperties["Size"].Equals("0"));
            Assert.IsTrue(allProperties["Type"].Equals("31"));
            Assert.IsTrue(allProperties["TypeName"].Equals("Some Type Name"));
            Assert.IsTrue(allProperties["Name"].Equals("Some Name, \n \"Name\""));
            Assert.IsTrue(allProperties["ModifiedDate"].Equals("1/1/0001 12:00:00 AM"));
            Assert.IsTrue(allProperties["AccessedDate"].Equals("1/1/0001 12:00:00 AM"));
            Assert.IsTrue(allProperties["CreationDate"].Equals("1/1/0001 12:00:00 AM"));
        }
Ejemplo n.º 3
0
        public void ImportCSVFileTest()
        {
            List <IShellItem> shellItems = CsvIO.ImportCSVFile(Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName + @"\TestResource\raw.csv");

            Assert.AreNotEqual(shellItems.Count, 0);
        }