Esempio n. 1
0
 public LayoutInvestigationViewModel(InvestigationFacade investigationFacade, HangfireFacade hangfireFacade, CaptureFacade captureFacade, ExportFacade exportFacade)
 {
     this.InvestigationFacade = investigationFacade;
     this.HangfireFacade      = hangfireFacade;
     this.CaptureFacade       = captureFacade;
     this.ExportFacade        = exportFacade;
 }
Esempio n. 2
0
            //ExEnd:SourceMp3FilePath + SourceMp3DirectoryPath


            /// <summary>
            ///  Export metadata of Mp3 format to Excel.
            ///  Each new metadata type will be presented in separate sheet
            /// </summary>
            public static void ExportMetadataToExcel()
            {
                // path to the out dir
                string outputDir = directoryPath;

                // get mp3 files only
                string[] files = Directory.GetFiles(directoryPath, "*.mp3");

                foreach (string path in files)
                {
                    // get excel file as byte array
                    byte[] bytes = ExportFacade.ExportToExcel(path);

                    // prepare excel file name
                    string resultFileName = string.Format("{0}\\{1}.xlsx", outputDir, Path.GetFileNameWithoutExtension(path));

                    // remove output file if exist
                    if (File.Exists(resultFileName))
                    {
                        File.Delete(resultFileName);
                    }

                    // write file to the file system
                    File.WriteAllBytes(resultFileName, bytes);
                }
            }
 public ExportOverviewWebmailsViewModel(
     InvestigationFacade investigationFacade,
     HangfireFacade hangfireFacade,
     CaptureFacade captureFacade,
     ExportFacade exportFacade,
     SnooperWebmailsWeb snooperInfo) : base(investigationFacade, hangfireFacade, captureFacade, exportFacade)
 {
     this.SnooperInfo = snooperInfo;
 }
 public ExportDNSViewModel(
     InvestigationFacade investigationFacade,
     HangfireFacade hangfireFacade,
     CaptureFacade captureFacade,
     ExportFacade exportFacade,
     SnooperDNSWeb snooperInfo,
     ExportDNSFacade exportFTPFacade) : base(investigationFacade, hangfireFacade, captureFacade, exportFacade)
 {
     this.SnooperInfo     = snooperInfo;
     this.ExportDNSFacade = exportFTPFacade;
 }
        public HttpResponseMessage Get(bool isExcel, string file)
        {
            try
            {
                FileStream original   = File.Open(Utils._storagePath + "\\" + file, FileMode.OpenOrCreate);
                string     outputPath = Utils._storagePath + "\\Metadata_" + Path.GetFileNameWithoutExtension(file) + (isExcel ? ".xlsx" : ".csv");

                if (isExcel)
                {
                    byte[] content = ExportFacade.ExportToExcel(original);
                    // write data to the file
                    File.WriteAllBytes(outputPath, content);
                }
                else
                {
                    byte[] content = ExportFacade.ExportToCsv(original);
                    // write data to the file
                    File.WriteAllBytes(outputPath, content);
                }

                using (var ms = new MemoryStream())
                {
                    original = File.OpenRead(outputPath);
                    original.CopyTo(ms);
                    var result = new HttpResponseMessage(HttpStatusCode.OK)
                    {
                        Content = new ByteArrayContent(ms.ToArray())
                    };
                    result.Content.Headers.ContentDisposition =
                        new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment")
                    {
                        FileName = "Metadata_" + Path.GetFileNameWithoutExtension(file) + (isExcel ? ".xlsx" : ".csv")
                    };
                    result.Content.Headers.ContentType =
                        new MediaTypeHeaderValue("application/octet-stream");

                    original.Close();
                    File.Delete(outputPath);
                    return(result);
                }
            }
            catch (Exception exc)
            {
                throw exc;
            }
        }
            /// <summary>
            /// Exports AVI metadata to Csv,Xls file
            /// </summary>
            public static void ExportMetadata()
            {
                try
                {
                    //ExStart:ExportMetadataAvi
                    // export to excel
                    byte[] content = ExportFacade.ExportToExcel(Common.MapSourceFilePath(filePath));

                    // write data to the file
                    File.WriteAllBytes(Common.MapDestinationFilePath(OutputDataFilePathAvi), content);
                    //ExEnd:ExportMetadataAvi
                    Console.WriteLine("Metadata has been export successfully");
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
 public CaptureViewModel(InvestigationFacade investigationFacade, HangfireFacade hangfireFacade, CaptureFacade captureFacade, ExportFacade exportFacade) : base(investigationFacade, hangfireFacade, captureFacade, exportFacade)
 {
 }
        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                tabMetadataTypes.TabPages.Clear();

                DataSet ds;

                using (StreamReader streamReader = new StreamReader(openFileDialog.FileName))
                {
                    try
                    {
                        ds = ExportFacade.ExportToDataSet(streamReader.BaseStream);
                    }
                    catch (GroupDocs.Metadata.Exceptions.InvalidFormatException)
                    {
                        MessageBox.Show(@"This format is not supported");
                        return;
                    }
                    catch (GroupDocs.Metadata.Exceptions.GroupDocsException ex)
                    {
                        MessageBox.Show(string.Format("Error: {0}", ex.Message));
                        return;
                    }
                }

                propertiesEditor      = null;
                saveMetadata.FileName = openFileDialog.FileName;

                if (ds.Tables.Count == 0)
                {
                    MessageBox.Show(@"Metadata not found");
                }
                else
                {
                    for (int i = 0; i < ds.Tables.Count; i++)
                    {
                        DataTable table = ds.Tables[i];

                        Control child;
                        string  tabName;

                        switch (table.TableName.ToLower())
                        {
                        case "xmp":
                            tabName = "XMP metadata";
                            XmpPacketWrapper xmpPacket = MetadataUtility.ExtractXmpPackage(openFileDialog.FileName);
                            ucXmpTree        xmpTree   = new ucXmpTree();
                            xmpTree.LoadControl(xmpPacket);
                            ResizeControl(xmpTree);
                            child = xmpTree;
                            break;

                        case "pdf":
                        case "doc":
                        case "xls":
                        case "ppt":
                            tabName = "Document properties";
                            MetadataPropertyCollection properties = MetadataUtility.ExtractDocumentProperties(openFileDialog.FileName);
                            propertiesEditor = new ucPropertiesEditor();
                            ResizeControl(propertiesEditor);
                            propertiesEditor.LoadControl(properties);
                            child = propertiesEditor;
                            break;

                        default:
                            tabName = string.Format("{0} metadata", table.TableName);
                            DataGridView gridView = new DataGridView();
                            ResizeControl(gridView);
                            gridView.DataSource = table;
                            child = gridView;
                            break;
                        }

                        tabMetadataTypes.TabPages.Add(tabName);
                        TabPage addedTab = tabMetadataTypes.TabPages[i];

                        //addedTab.Anchor = AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Right | AnchorStyles.Top;
                        addedTab.Controls.Add(child);
                    }

                    tabMetadataTypes.Visible = true;
                }
            }
        }
        /// <summary>
        /// Exports metadata of specified file into specified type
        /// </summary>
        public static void ExportMetadata(string filePath, int exportType)
        {
            try
            {
                //ExStart:ExportMetadataAPI
                filePath = Common.MapSourceFilePath(filePath);

                if (exportType == ExportTypes.ToExcel)
                {
                    //ExStart:ExportMetadataToExcel
                    // path to the output file
                    string outputPath = Common.MapDestinationFilePath("metadata.xlsx");

                    // export to excel
                    byte[] content = ExportFacade.ExportToExcel(filePath);

                    // write data to the file
                    File.WriteAllBytes(outputPath, content);
                    //ExEnd:ExportMetadataToExcel
                }
                else if (exportType == ExportTypes.ToCSV)
                {
                    //ExStart:ExportMetadataToCVS
                    // path to the output file
                    string outputPath = Common.MapDestinationFilePath("metadata.csv");

                    // export to csv
                    byte[] content = ExportFacade.ExportToCsv(filePath);

                    // write data to the file
                    File.WriteAllBytes(outputPath, content);
                    //ExEnd:ExportMetadataToCVS
                }
                else
                {
                    //ExStart:ExportMetadataToDataSet
                    // export to DataSet
                    DataSet ds = ExportFacade.ExportToDataSet(filePath);
                    // get first table
                    DataTable products = ds.Tables[0];

                    // need to System.Data.DataSetExtension reference
                    IEnumerable <DataRow> query =
                        from product in products.AsEnumerable()
                        select product;

                    Console.WriteLine("Properties:");
                    foreach (DataRow p in query)
                    {
                        Console.Write(p.Field <string>("Metadata property"));
                        Console.Write(": ");
                        Console.WriteLine(p.Field <string>("Value"));
                    }
                    //ExEnd:ExportMetadataToDataSet
                }
                //ExEnd:ExportMetadataAPI
            }
            catch (Exception exp)
            {
                Console.WriteLine("Exception occurred: " + exp.Message);
            }
        }
Esempio n. 10
0
        public void TestFramework_Messages()
        {
            this.Configuration.RouteTable.Add("Investigations_overview", "Investigations/overview", "overview.dothtml", null);
            var context = new TestDotvvmRequestContext()
            {
                Configuration       = this.Configuration,
                ApplicationHostPath = "../Netfox.Web.App/",
                Parameters          = new Dictionary <string, object>()
            };

            this.AddUser();
            this.AddInvestigation();

            Investigation investigation;

            // var exportService = Container.Resolve<ExportService>(new { investigationId = investigation.Id });
            using (var uow = this.UnitOfWorkProvider.Create())
            {
                var ctx = EntityFrameworkUnitOfWork.TryGetDbContext <NetfoxWebDbContext>(this.UnitOfWorkProvider);
                investigation = ctx.Investigations.First();
            }

            var NetfoxAPIFacadeFactory = this.Container.Resolve <Func <IWindsorContainer, Guid, string, NetfoxAPIFacade> >();
            var netfoxAPI = NetfoxAPIFacadeFactory(this.ContainerAPI, investigation.Id, Directory.GetCurrentDirectory());
            var snooper   = Container.Resolve <SnooperYMSG.SnooperYMSG>();

            Assert.NotNull(netfoxAPI);

            netfoxAPI.ProcessCapture(NetfoxWebTest.Default.MessagePcap);

            var capturelList = CaptureFacade.GetCaptureList(investigation.Id).ToList();

            Assert.AreEqual(capturelList.Count, 1);

            var l3    = new GridViewDataSet <L3ConversationDTO>();
            var l4    = new GridViewDataSet <L4ConversationDTO>();
            var l7    = new GridViewDataSet <L7ConversationDTO>();
            var frame = new GridViewDataSet <PmFrameBaseDTO>();

            l3.PagingOptions.PageSize        = 15;
            l3.SortingOptions.SortDescending = false;
            l3.SortingOptions.SortExpression = nameof(L3ConversationDTO.Id);

            l4.PagingOptions.PageSize        = 15;
            l4.SortingOptions.SortDescending = false;
            l4.SortingOptions.SortExpression = nameof(L4ConversationDTO.Id);

            l7.PagingOptions.PageSize        = 15;
            l7.SortingOptions.SortDescending = false;
            l7.SortingOptions.SortExpression = nameof(L7ConversationDTO.Id);

            frame.PagingOptions.PageSize        = 15;
            frame.SortingOptions.SortDescending = false;
            frame.SortingOptions.SortExpression = nameof(PmFrameBaseDTO.Id);

            this.CaptureFacade.FillL3ConversationDataSet(l3, capturelList.First().Id, investigation.Id, new ConversationFilterDTO());
            Assert.AreEqual(l3.PagingOptions.TotalItemsCount, 9);
            this.CaptureFacade.FillL4ConversationDataSet(l4, capturelList.First().Id, investigation.Id, new ConversationFilterDTO());
            Assert.AreEqual(l4.PagingOptions.TotalItemsCount, 9);
            this.CaptureFacade.FillL7ConversationDataSet(l7, capturelList.First().Id, investigation.Id, new ConversationFilterDTO());
            Assert.AreEqual(l7.PagingOptions.TotalItemsCount, 9);
            this.CaptureFacade.FillPmFrameDataSet(frame, capturelList.First().Id, investigation.Id, new FrameFilterDTO());
            Assert.AreEqual(frame.PagingOptions.TotalItemsCount, 158);

            var listSnooper = new List <string>();

            listSnooper.Add(snooper.GetType().FullName);

            netfoxAPI.ExportData(listSnooper);
            var exports = new GridViewDataSet <ExportChatMessageDTO>();

            exports.PagingOptions.PageSize        = 15;
            exports.SortingOptions.SortDescending = false;
            exports.SortingOptions.SortExpression = nameof(ExportChatMessageDTO.Id);

            ExportFacade.FillChatMessageDataSet(exports, investigation.Id, new ExportFilterDTO());

            Assert.AreEqual(exports.PagingOptions.TotalItemsCount, 4);
        }
Esempio n. 11
0
 public CallDetailViewModel(ExportFacade exportFacade)
 {
     this.ExportFacade = exportFacade;
 }