/// <summary> /// //案件加载完成时发生; /// </summary> /// <param name="cs"></param> private void OnCaseLoaded(ICase cs) { if (cs == null) { return; } //设定标题; ServiceProvider.Current.GetInstance <IShellService>()?.SetTitle(cs.CaseName); var nodeService = MainTreeService.Current; if (nodeService == null) { return; } //加入案件节点; var csUnit = TreeUnitFactory.CreateNew(Contracts.Casing.Constants.TreeUnitType_Case); csUnit.Label = cs.CaseName; csUnit.SetInstance(cs, Contracts.Casing.Constants.TreeUnitTag_Case); nodeService.AddUnit(null, csUnit); }
public TestPartitionsBrowser() { InitializeComponent(); this.Loaded += delegate { RegionHelper.RequestNavigate( SingularityForensic.Contracts.MainPage.Constants.MainPageDocumentRegion, SingularityForensic.Contracts.Document.Constants.DocumentTabsView ); SingularityForensic.Contracts.Casing.CaseService.Current.LoadCase("E:\\Cases\\001\\001\\001.sfproj"); //"J://Z0176-809.dd" //"E://anli/FAT32.img" //var cs = SingularityForensic.Contracts.Casing.CaseService.Current.CreateNewCase(); //foreach (var evi in SingularityForensic.Contracts.Casing.CaseService.Current.CurrentCase.CaseEvidences.ToList()) { // SingularityForensic.Contracts.Casing.CaseService.Current.CurrentCase.RemoveCaseEvidence(evi); //} //SingularityForensic.Contracts.Imaging.ImgService.Current.AddImg("E://anli/FAT32.img"); var file = FileSystemService.Current.MountedUnits.First().File; //var file = FileSystemService.Current.MountStream(System.IO.File.OpenRead(), "mmp", null, null); var unit = TreeUnitFactory.CreateNew(SingularityForensic.Contracts.FileExplorer.Constants.TreeUnitType_FileSystem); unit.SetInstance(file, SingularityForensic.Contracts.FileExplorer.Constants.TreeUnitTag_FileSystem_File); CommonEventHelper.GetEvent <TreeUnitSelectedChangedEvent>().Publish((unit, MainTreeService.Current)); CommonEventHelper.PublishEventToHandlers((unit, MainTreeService.Current), GenericServiceStaticInstances <ITreeUnitSelectedChangedEventHandler> .Currents); CommonEventHelper.GetEvent <TreeUnitSelectedChangedEvent>().Publish((unit, MainTreeService.Current)); CommonEventHelper.GetEvent <TreeUnitSelectedChangedEvent>().Publish((unit, MainTreeService.Current)); }; }
public void TestOnTreeUnitAdded() { var csUnit = TreeUnitFactory.CreateNew(SingularityForensic.Contracts.Casing.Constants.TreeUnitType_CaseEvidence); var csEvidence = CaseService.Current.CreateNewCaseEvidence(new string[] { }, string.Empty, string.Empty); var file = _fsService.MountStream(File.OpenRead(AppMockers.OpenFileName), csEvidence.Name, csEvidence.EvidenceGUID, null); csUnit.SetInstance(csEvidence, SingularityForensic.Contracts.Casing.Constants.TreeUnitTag_CaseEvidence); CommonEventHelper.GetEvent <TreeUnitAddedEvent>().Publish((csUnit, MainTreeService.Current)); Assert.AreEqual(csUnit.Children.Count, 1); }
private void TestNameCategory_Loaded(object sender, RoutedEventArgs e) { RegionHelper.RequestNavigate( SingularityForensic.Contracts.MainPage.Constants.MainPageDocumentRegion, SingularityForensic.Contracts.Document.Constants.DocumentTabsView ); var file = FileSystemService.Current.MountStream(System.IO.File.OpenRead("E://anli/FAT32.img"), "mmp", null, null); var unit = TreeUnitFactory.CreateNew(SingularityForensic.Contracts.FileExplorer.Constants.TreeUnitType_FileSystem); unit.SetInstance(file, SingularityForensic.Contracts.FileExplorer.Constants.TreeUnitTag_FileSystem_File); CommonEventHelper.PublishEventToHandlers((unit, MainTreeService.Current), GenericServiceStaticInstances <ITreeUnitSelectedChangedEventHandler> .Currents); CommonEventHelper.GetEvent <TreeUnitSelectedChangedEvent>().Publish((unit, MainTreeService.Current)); }
public void TestAddUnit() { var unit = TreeUnitFactory.CreateNew(string.Empty); var addedCatched = false; var addStoken = CommonEventHelper.GetEvent <TreeUnitAddedEvent>().Subscribe(tuple => { addedCatched = true; Assert.AreEqual(unit, tuple.unit); }); _treeService.AddUnit(null, unit); Assert.IsTrue(addedCatched); CommonEventHelper.GetEvent <TreeUnitAddedEvent>().Unsubscribe(addStoken); }
/// <summary> /// 在节点中加入证据项节点; /// </summary> /// <param name="evidence"></param> private void LoadEvidenceUnitToTree(ICaseEvidence evidence) { var treeService = MainTreeService.Current; if (treeService == null) { LoggerService.WriteCallerLine($"{nameof(treeService)} can't be null."); return; } var unit = TreeUnitFactory.CreateNew(Contracts.Casing.Constants.TreeUnitType_CaseEvidence); unit.Label = evidence.Name; unit.SetInstance(evidence, Contracts.Casing.Constants.TreeUnitTag_CaseEvidence); treeService.AddUnit(treeService.CurrentUnits.FirstOrDefault(), unit); }
/// <summary> /// 根据ComObject获得Units; /// </summary> private IEnumerable <ITreeUnit> GetUnitsFromObject() { List <ITreeUnit> units = new List <ITreeUnit>(); //各种检查为空; if (_comObject == null) { LoggerService.Current?.WriteCallerLine($"{nameof(_comObject)} can't be null."); return(Enumerable.Empty <ITreeUnit>()); } if (_comObject.LocalHdds == null) { LoggerService.Current?.WriteCallerLine($"{nameof(_comObject.LocalHdds)} can't be null."); return(Enumerable.Empty <ITreeUnit>()); } //遍历添加子节点; foreach (var hdd in _comObject.LocalHdds) { var hddUnit = TreeUnitFactory.CreateNew(Constants.DriveType_LocalHDD); hddUnit.Label = hdd.SerialNumber; hddUnit.SetInstance(hdd, Constants.TreeUnitTag_LocalHDD); if (hdd.Volumes == null) { LoggerService.Current?.WriteCallerLine($"{nameof(hdd.Volumes)} can't be null."); continue; } foreach (var volume in hdd.Volumes) { var volUnit = TreeUnitFactory.CreateNew(Constants.DriveType_LocalVolume); volUnit.Label = $"{volume.Sign}:"; volUnit.SetInstance(volume, Constants.TreeUnitTag_LocalVolume); hddUnit.Children.Add(volUnit); } units.Add(hddUnit); } return(units); }
public void HandleTest() { var device = FileSystemService.Current.MountStream(System.IO.File.OpenRead("E://anli/Fat32_Test.img"), "mmp", null, null) as IDevice; Assert.IsNotNull(device); var unit = TreeUnitFactory.CreateNew(SingularityForensic.Contracts.FileExplorer.Constants.TreeUnitType_InnerFile); unit.SetInstance <IFile>(device.Children.First(), SingularityForensic.Contracts.FileExplorer.Constants.TreeUnitTag_InnerFile); _handler.Handle(); var mainDocService = SingularityForensic.Contracts.Document.DocumentService.MainDocumentService; var docs = mainDocService.CurrentDocuments; Assert.AreEqual(docs.Count(), 1); var fbDoc = docs.First().GetInstance <IFolderBrowserDataContext>(SingularityForensic.Contracts.FileExplorer.Constants.DocumentTag_FolderBrowserDataContext); Assert.IsNotNull(fbDoc); Assert.AreEqual(fbDoc.FolderBrowserViewModel.FileRows.Count(), device.GetInnerFiles().Count()); }
public void TestAddChildToUnit() { TestAddUnit(); var unit = _treeService.CurrentUnits.ElementAt(0); var newUnit = TreeUnitFactory.CreateNew(string.Empty); var addedCatched = false; var areEqual = false; CommonEventHelper.GetEvent <TreeUnitAddedEvent>().Subscribe(tuple => { addedCatched = true; areEqual = newUnit == tuple.unit; }); _treeService.AddUnit(unit, newUnit); Assert.AreEqual(unit.Children.Count, 1); Assert.IsTrue(areEqual); Assert.IsTrue(addedCatched); }
private void LoadUnits() { if (!File.Exists(DbPath)) { return; } var tablesUnit = TreeUnitFactory.CreateNew(Constants.DBUnitType_Content); tablesUnit.Label = LanguageService.FindResourceString(Constants.UnitLabel_SqliteTable); var tableCount = 0; try { CheckOpen(); var comm = Conn.CreateCommand(); comm.CommandText = "select * from sqlite_master where type = 'table'"; comm.CommandType = CommandType.Text; var reader = comm.ExecuteReader(); while (reader.Read()) { try { var name = reader["name"].ToString(); var tableUnit = TreeUnitFactory.CreateNew(Constants.DBUnitType_Table); tableUnit.Label = name; tablesUnit.Children.Add(tableUnit); tableCount++; } catch { } } reader.Close(); } catch (Exception ex) { LoggerService.WriteCallerLine($"{nameof(SqlitePreviewerViewModel)}->{nameof(LoadUnits)}:{ex.Message}"); } finally { tablesUnit.Label += $"({tableCount})"; DBUnits.Add(tablesUnit); } }
//测试点击设备节点后响应; static void TestDeviceNodeClick() { var devStoken = new DeviceStoken { BaseStream = System.IO.File.OpenRead("D://youdaonote_unsilent38.exe"), Name = "mmp" }; //for (int i = 0; i < 24; i++) { // var partEnStoken = new PartitionEntryStoken { // StartLBA = i * 16, // Size = 16 // }; // devStoken.PartitionEntries.Add( // PartitionEntryFactory.CreatePartitionEntry(string.Empty) // ); //} //var dev = new IDevice(string.Empty, devStoken); //var rand = new Random(); //for (int i = 0; i < 24; i++) { // var part = new IPartition(string.Empty, new PartitionStoken { // Name = "Dada", // Size = rand.Next(25535), // BaseStream = MulPeriodsStream.CreateFromStream(devStoken.BaseStream, // new(long StartIndex, long Size)[] { // (25535 * i,1024) // }) // }); // dev.Children.Add(part); // dev.SetStartLBA(part, i * 200); //} var unit = TreeUnitFactory.CreateNew(SingularityForensic.Contracts.FileExplorer.Constants.TreeUnitType_FileSystem); MainTreeService.Current?.AddUnit(null, unit); CommonEventHelper.GetEvent <TreeUnitSelectedChangedEvent>().Publish((unit, MainTreeService.Current)); CommonEventHelper.GetEvent <TreeUnitSelectedChangedEvent>().Publish((unit, MainTreeService.Current)); CommonEventHelper.GetEvent <TreeUnitSelectedChangedEvent>().Publish((unit, MainTreeService.Current)); CommonEventHelper.GetEvent <TreeUnitSelectedChangedEvent>().Publish((unit, MainTreeService.Current)); }