示例#1
0
        public void TestParseOgg()
        {
            string          path    = Path.GetFullPath(TestDataSample.GetAudioPath("sample.ogg"));
            ParserContext   context = new ParserContext(path);
            IMetadataParser parser  = (IMetadataParser)ParserFactory.CreateMetadata(context);
            ToxyMetadata    x       = parser.Parse();

            Assert.AreEqual(15, x.Count);
        }
示例#2
0
        public void TestParseMp3_Id3v1Only()
        {
            string          path    = Path.GetFullPath(TestDataSample.GetAudioPath("sample_v1_only.mp3"));
            ParserContext   context = new ParserContext(path);
            IMetadataParser parser  = (IMetadataParser)ParserFactory.CreateMetadata(context);
            ToxyMetadata    x       = parser.Parse();

            Assert.AreEqual(11, x.Count);
        }
示例#3
0
        public void TestExcelFile()
        {
            string          path    = Path.GetFullPath(TestDataSample.GetExcelPath("comments.xls"));
            ParserContext   context = new ParserContext(path);
            IMetadataParser parser  = (IMetadataParser)ParserFactory.CreateMetadata(context);
            ToxyMetadata    x       = parser.Parse();

            Assert.AreEqual(8, x.Count);
            Assert.AreEqual("Microsoft Excel", x.Get("ApplicationName").Value);
        }
示例#4
0
        public void TestPowerPoint()
        {
            string          path    = Path.GetFullPath(TestDataSample.GetOLE2Path("Test_Humor-Generation.ppt"));
            ParserContext   context = new ParserContext(path);
            IMetadataParser parser  = (IMetadataParser)ParserFactory.CreateMetadata(context);
            ToxyMetadata    x       = parser.Parse();

            Assert.AreEqual(8, x.Count);
            Assert.AreEqual("Funny Factory", x.Get("Title").Value);
        }
示例#5
0
        public void TestXlsx()
        {
            string          path    = Path.GetFullPath(TestDataSample.GetOOXMLPath("sample.xlsx"));
            ParserContext   context = new ParserContext(path);
            IMetadataParser parser  = (IMetadataParser)ParserFactory.CreateMetadata(context);
            ToxyMetadata    x       = parser.Parse();

            Assert.AreEqual(4, x.Count);
            Assert.AreEqual("Microsoft Excel", x.Get("Application").Value);
            Assert.AreEqual("12.0000", x.Get("AppVersion").Value);
        }
示例#6
0
        public void TestSolidWorksFile()
        {
            string          path    = Path.GetFullPath(TestDataSample.GetOLE2Path("TestSolidWorks.sldprt"));
            ParserContext   context = new ParserContext(path);
            IMetadataParser parser  = (IMetadataParser)ParserFactory.CreateMetadata(context);
            ToxyMetadata    x       = parser.Parse();

            Assert.AreEqual(10, x.Count);
            Assert.AreEqual("{F29F85E0-4FF9-1068-AB91-08002B27B3D9}", x.Get("ClassID").Value);
            Assert.AreEqual("scj", x.Get("LastAuthor").Value);
        }
示例#7
0
        public void TestCorelDrawFile()
        {
            string          path    = Path.GetFullPath(TestDataSample.GetOLE2Path("TestCorel.shw"));
            ParserContext   context = new ParserContext(path);
            IMetadataParser parser  = (IMetadataParser)ParserFactory.CreateMetadata(context);
            ToxyMetadata    x       = parser.Parse();

            Assert.AreEqual(6, x.Count);
            Assert.AreEqual("thorsteb", x.Get("Author").Value);
            Assert.AreEqual("thorsteb", x.Get("LastAuthor").Value);
        }
示例#8
0
        public void TestDocx()
        {
            string          path    = Path.GetFullPath(TestDataSample.GetOOXMLPath("MultipleCoreProperties.docx"));
            ParserContext   context = new ParserContext(path);
            IMetadataParser parser  = (IMetadataParser)ParserFactory.CreateMetadata(context);
            ToxyMetadata    x       = parser.Parse();

            Assert.AreEqual(12, x.Count);
            Assert.AreEqual("Format", x.Get("Title").Value);
            Assert.AreEqual("Microsoft Macintosh Word", x.Get("Application").Value);
        }
示例#9
0
        public void TestPptx()
        {
            string          path    = Path.GetFullPath(TestDataSample.GetOOXMLPath("SampleShow.pptx"));
            ParserContext   context = new ParserContext(path);
            IMetadataParser parser  = (IMetadataParser)ParserFactory.CreateMetadata(context);
            ToxyMetadata    x       = parser.Parse();

            Assert.AreEqual(8, x.Count);
            Assert.AreEqual("SlideShow Sample", x.Get("Title").Value);
            Assert.AreEqual("Microsoft Office PowerPoint", x.Get("Application").Value);
        }
示例#10
0
        public void TestParseGifWithComment()
        {
            string          path    = Path.GetFullPath(TestDataSample.GetImagePath("sample_gimp.gif"));
            ParserContext   context = new ParserContext(path);
            IMetadataParser parser  = (IMetadataParser)ParserFactory.CreateMetadata(context);
            ToxyMetadata    x       = parser.Parse();

            Assert.AreEqual(4, x.Count);
            Assert.AreEqual(37, x.Get("PhotoHeight").Value);
            Assert.AreEqual(12, x.Get("PhotoWidth").Value);
            Assert.AreEqual("Created with GIMP", x.Get("Comment").Value);
            Assert.AreEqual("Created with GIMP", x.Get("GifComment").Value);
        }
示例#11
0
        public void TestParseTiff()
        {
            string          path    = Path.GetFullPath(TestDataSample.GetImagePath("sample_gimp.tiff"));
            ParserContext   context = new ParserContext(path);
            IMetadataParser parser  = (IMetadataParser)ParserFactory.CreateMetadata(context);
            ToxyMetadata    x       = parser.Parse();

            Assert.AreEqual(97, x.Count);
            Assert.AreEqual(10, x.Get("PhotoHeight").Value);
            Assert.AreEqual(10, x.Get("PhotoWidth").Value);
            Assert.AreEqual("Test", x.Get("Comment").Value);
            Assert.AreEqual("28/10", x.Get("FNumber").Value);
            Assert.AreEqual("0", x.Get("Rating").Value);
            Assert.AreEqual("+150", x.Get("Tint").Value);
            Assert.AreEqual("5", x.Get("Shadows").Value);
        }
示例#12
0
        public void TestWord()
        {
            string          path    = Path.GetFullPath(TestDataSample.GetOLE2Path("TestEditTime.doc"));
            ParserContext   context = new ParserContext(path);
            IMetadataParser parser  = (IMetadataParser)ParserFactory.CreateMetadata(context);
            ToxyMetadata    x       = parser.Parse();

            Assert.AreEqual(18, x.Count);

            path    = Path.GetFullPath(TestDataSample.GetOLE2Path("TestChineseProperties.doc"));
            context = new ParserContext(path);
            parser  = (IMetadataParser)ParserFactory.CreateMetadata(context);
            x       = parser.Parse();
            Assert.AreEqual(18, x.Count);
            Assert.AreEqual("雅虎網站分類", x.Get("Comments").Value);
            Assert.AreEqual("參考資料", x.Get("Title").Value);
        }
示例#13
0
        public void TestParseJpegWithXmp()
        {
            string          path    = Path.GetFullPath(TestDataSample.GetImagePath("sample_nikon1.jpg"));
            ParserContext   context = new ParserContext(path);
            IMetadataParser parser  = (IMetadataParser)ParserFactory.CreateMetadata(context);
            ToxyMetadata    x       = parser.Parse();

            Assert.AreEqual(17, x.Count);
            Assert.AreEqual(3008, x.Get("PhotoHeight").Value);
            Assert.AreEqual(96, x.Get("PhotoQuality").Value);
            Assert.AreEqual(2000, x.Get("PhotoWidth").Value);
            Assert.AreEqual("NIKON D70", x.Get("Model").Value);
            Assert.AreEqual("Kirche Sulzbach", x.Get("Keywords").Value);
            Assert.AreEqual("1", x.Get("Rating").Value);
            Assert.AreEqual("2009-08-04T20:42:36Z", x.Get("DateAcquired").Value);
            Assert.AreEqual("Microsoft Windows Photo Gallery 6.0.6001.18000", x.Get("Software").Value);
            Assert.AreEqual("Microsoft Windows Photo Gallery 6.0.6001.18000", x.Get("creatortool").Value);
        }
示例#14
0
        public void TestParseJpeg()
        {
            string          path    = Path.GetFullPath(TestDataSample.GetImagePath("sample_sony1.jpg"));
            ParserContext   context = new ParserContext(path);
            IMetadataParser parser  = (IMetadataParser)ParserFactory.CreateMetadata(context);
            ToxyMetadata    x       = parser.Parse();

            Assert.AreEqual(12, x.Count);
            Assert.AreEqual(2592, x.Get("PhotoHeight").Value);
            Assert.AreEqual(95, x.Get("PhotoQuality").Value);
            Assert.AreEqual(3872, x.Get("PhotoWidth").Value);
            Assert.AreEqual("DSLR-A200", x.Get("Model").Value);
            Assert.AreEqual((uint)400, x.Get("ISOSpeedRatings").Value);
            Assert.AreEqual(5.6, x.Get("FNumber").Value);
            Assert.AreEqual((double)35, x.Get("FocalLength").Value);
            Assert.AreEqual((uint)52, x.Get("FocalLengthIn35mmFilm").Value);
            Assert.AreEqual(new DateTime(2009, 11, 21, 12, 39, 39), x.Get("DateTime").Value);
        }
示例#15
0
        public ToxyMetadata Parse()
        {
            if (!System.IO.File.Exists(Context.Path))
            {
                throw new System.IO.FileNotFoundException("File " + Context.Path + " is not found");
            }

            ToxyMetadata metadata = new ToxyMetadata();
            OPCPackage   pack     = null;

            try
            {
                pack = OPCPackage.Open(Context.Path, PackageAccess.READ);
                POIXMLProperties props = new POIXMLProperties(pack);
                if (props.CoreProperties != null)
                {
                    if (props.CoreProperties.Title != null)
                    {
                        metadata.Add("Title", props.CoreProperties.Title);
                    }
                    else if (props.CoreProperties.Identifier != null)
                    {
                        metadata.Add("Identifier", props.CoreProperties.Identifier);
                    }
                    else if (props.CoreProperties.Keywords != null)
                    {
                        metadata.Add("Keywords", props.CoreProperties.Keywords);
                    }
                    else if (props.CoreProperties.Revision != null)
                    {
                        metadata.Add("Revision", props.CoreProperties.Revision);
                    }
                    else if (props.CoreProperties.Subject != null)
                    {
                        metadata.Add("Subject", props.CoreProperties.Subject);
                    }
                    else if (props.CoreProperties.Modified != null)
                    {
                        metadata.Add("Modified", props.CoreProperties.Modified);
                    }
                    else if (props.CoreProperties.LastPrinted != null)
                    {
                        metadata.Add("LastPrinted", props.CoreProperties.LastPrinted);
                    }
                    else if (props.CoreProperties.Created != null)
                    {
                        metadata.Add("Created", props.CoreProperties.Created);
                    }
                    else if (props.CoreProperties.Creator != null)
                    {
                        metadata.Add("Creator", props.CoreProperties.Creator);
                    }
                    else if (props.CoreProperties.Description != null)
                    {
                        metadata.Add("Description", props.CoreProperties.Description);
                    }
                }
                if (props.ExtendedProperties != null && props.ExtendedProperties.props != null)
                {
                    var extProps = props.ExtendedProperties.props.GetProperties();
                    if (extProps.Application != null)
                    {
                        metadata.Add("Application", extProps.Application);
                    }
                    if (extProps.AppVersion != null)
                    {
                        metadata.Add("AppVersion", extProps.AppVersion);
                    }
                    if (extProps.Characters > 0)
                    {
                        metadata.Add("Characters", extProps.Characters);
                    }
                    if (extProps.CharactersWithSpaces > 0)
                    {
                        metadata.Add("CharactersWithSpaces", extProps.CharactersWithSpaces);
                    }
                    if (extProps.Company != null)
                    {
                        metadata.Add("Company", extProps.Company);
                    }
                    if (extProps.Lines > 0)
                    {
                        metadata.Add("Lines", extProps.Lines);
                    }
                    if (extProps.Manager != null)
                    {
                        metadata.Add("Manager", extProps.Manager);
                    }
                    if (extProps.Notes > 0)
                    {
                        metadata.Add("Notes", extProps.Notes);
                    }
                    if (extProps.Pages > 0)
                    {
                        metadata.Add("Pages", extProps.Pages);
                    }
                    if (extProps.Paragraphs > 0)
                    {
                        metadata.Add("Paragraphs", extProps.Paragraphs);
                    }
                    if (extProps.Words > 0)
                    {
                        metadata.Add("Words", extProps.Words);
                    }
                    if (extProps.TotalTime > 0)
                    {
                        metadata.Add("TotalTime", extProps.TotalTime);
                    }
                }
            }
            finally
            {
                if (pack != null)
                {
                    pack.Close();
                }
            }

            return(metadata);
        }
示例#16
0
        public ToxyMetadata Parse()
        {
            if (!System.IO.File.Exists(Context.Path))
                throw new System.IO.FileNotFoundException("File " + Context.Path + " is not found");
            ToxyMetadata metadatas = new ToxyMetadata();
            TagLib.File file = TagLib.Audible.File.Create(Context.Path);
            if (file.Properties.AudioSampleRate != 0)
                metadatas.Add("AudioSampleRate", file.Properties.AudioSampleRate);
            if (file.Properties.AudioChannels != 0)
                metadatas.Add("AudioChannels", file.Properties.AudioChannels);
            if (file.Properties.AudioBitrate != 0)
                metadatas.Add("AudioBitrate", file.Properties.AudioBitrate);
            if (file.Properties.BitsPerSample != 0)
                metadatas.Add("BitsPerSample", file.Properties.BitsPerSample);
            if (file.Properties.Description != null)
                metadatas.Add("Description", file.Properties.Description);
            if (file.Length>0)
                metadatas.Add("FileLength", file.Length);


            TagLib.Tag tag1 = file.Tag;
            if (tag1 != null)
            {
                if (tag1.Album != null)
                    metadatas.Add("Album", tag1.Album);
                if (tag1.AlbumArtists.Length > 0)
                    metadatas.Add("AlbumArtists", tag1.JoinedAlbumArtists);
                if (tag1.BeatsPerMinute != 0)
                    metadatas.Add("BeatsPerMinute", tag1.BeatsPerMinute);
                if (tag1.Composers.Length > 0)
                    metadatas.Add("Composers", tag1.JoinedComposers);
                if (tag1.Genres.Length > 0)
                    metadatas.Add("Genres", tag1.JoinedGenres);
                if (tag1.Performers.Length > 0)
                    metadatas.Add("Performers", tag1.JoinedPerformers);
                if (tag1.Comment != null)
                    metadatas.Add("Comment", tag1.Comment);
                if (tag1.Conductor != null)
                    metadatas.Add("Conductor", tag1.Conductor);
                if (tag1.Copyright != null)
                    metadatas.Add("Copyright", tag1.Copyright);
                if (tag1.Disc != 0)
                    metadatas.Add("Disc", tag1.Disc);
                if (tag1.DiscCount != 0)
                    metadatas.Add("DiscCount", tag1.DiscCount);
                if (tag1.Lyrics != null)
                    metadatas.Add("Lyrics", tag1.Lyrics);
                if (tag1.Title != null)
                    metadatas.Add("Title", tag1.Title);
                if (tag1.Track != 0)
                    metadatas.Add("Track", tag1.Track);
                if (tag1.TrackCount != 0)
                    metadatas.Add("TrackCount", tag1.TrackCount);
                if (tag1.Year != 0)
                    metadatas.Add("Year", tag1.Year);
                if (tag1.AmazonId != null)
                    metadatas.Add("AmazonId", tag1.AmazonId);
                if (tag1.MusicIpId != null)
                    metadatas.Add("MusicIpId", tag1.MusicIpId);
            }
            
            return metadatas;
        }
示例#17
0
        public ToxyMetadata Parse()
        {
            if (!System.IO.File.Exists(Context.Path))
            {
                throw new System.IO.FileNotFoundException("File " + Context.Path + " is not found");
            }
            ToxyMetadata metadatas = new ToxyMetadata();

            TagLib.File file = TagLib.Audible.File.Create(Context.Path);
            if (file.Properties.AudioSampleRate != 0)
            {
                metadatas.Add("AudioSampleRate", file.Properties.AudioSampleRate);
            }
            if (file.Properties.AudioChannels != 0)
            {
                metadatas.Add("AudioChannels", file.Properties.AudioChannels);
            }
            if (file.Properties.AudioBitrate != 0)
            {
                metadatas.Add("AudioBitrate", file.Properties.AudioBitrate);
            }
            if (file.Properties.BitsPerSample != 0)
            {
                metadatas.Add("BitsPerSample", file.Properties.BitsPerSample);
            }
            if (file.Properties.Description != null)
            {
                metadatas.Add("Description", file.Properties.Description);
            }
            if (file.Length > 0)
            {
                metadatas.Add("FileLength", file.Length);
            }


            TagLib.Tag tag1 = file.Tag;
            if (tag1 != null)
            {
                if (tag1.Album != null)
                {
                    metadatas.Add("Album", tag1.Album);
                }
                if (tag1.AlbumArtists.Length > 0)
                {
                    metadatas.Add("AlbumArtists", tag1.JoinedAlbumArtists);
                }
                if (tag1.BeatsPerMinute != 0)
                {
                    metadatas.Add("BeatsPerMinute", tag1.BeatsPerMinute);
                }
                if (tag1.Composers.Length > 0)
                {
                    metadatas.Add("Composers", tag1.JoinedComposers);
                }
                if (tag1.Genres.Length > 0)
                {
                    metadatas.Add("Genres", tag1.JoinedGenres);
                }
                if (tag1.Performers.Length > 0)
                {
                    metadatas.Add("Performers", tag1.JoinedPerformers);
                }
                if (tag1.Comment != null)
                {
                    metadatas.Add("Comment", tag1.Comment);
                }
                if (tag1.Conductor != null)
                {
                    metadatas.Add("Conductor", tag1.Conductor);
                }
                if (tag1.Copyright != null)
                {
                    metadatas.Add("Copyright", tag1.Copyright);
                }
                if (tag1.Disc != 0)
                {
                    metadatas.Add("Disc", tag1.Disc);
                }
                if (tag1.DiscCount != 0)
                {
                    metadatas.Add("DiscCount", tag1.DiscCount);
                }
                if (tag1.Lyrics != null)
                {
                    metadatas.Add("Lyrics", tag1.Lyrics);
                }
                if (tag1.Title != null)
                {
                    metadatas.Add("Title", tag1.Title);
                }
                if (tag1.Track != 0)
                {
                    metadatas.Add("Track", tag1.Track);
                }
                if (tag1.TrackCount != 0)
                {
                    metadatas.Add("TrackCount", tag1.TrackCount);
                }
                if (tag1.Year != 0)
                {
                    metadatas.Add("Year", tag1.Year);
                }
                if (tag1.AmazonId != null)
                {
                    metadatas.Add("AmazonId", tag1.AmazonId);
                }
                if (tag1.MusicIpId != null)
                {
                    metadatas.Add("MusicIpId", tag1.MusicIpId);
                }
            }

            return(metadatas);
        }
示例#18
0
        public ToxyMetadata Parse()
        {
            if (!System.IO.File.Exists(Context.Path))
                throw new System.IO.FileNotFoundException("File " + Context.Path + " is not found");

            ToxyMetadata metadatas = new ToxyMetadata();
            TagLib.File file = TagLib.Image.File.Create(Context.Path);
            if (file.Properties.PhotoHeight != 0)
                metadatas.Add("PhotoHeight", file.Properties.PhotoHeight);
            if (file.Properties.PhotoQuality != 0)
                metadatas.Add("PhotoQuality", file.Properties.PhotoQuality);
            if (file.Properties.PhotoWidth != 0)
                metadatas.Add("PhotoWidth", file.Properties.PhotoWidth);

            CombinedImageTag tags = file.Tag as CombinedImageTag;
            if (tags.Altitude != null)
                metadatas.Add("Altitude", (double)tags.Altitude);
            if(tags.Latitude!=null)
                metadatas.Add("Latitude", (double)tags.Latitude);
            if(tags.Model!=null)
                metadatas.Add("Model", tags.Model);
            if (tags.Make != null)
                metadatas.Add("Make", tags.Make);
            if (tags.Orientation != ImageOrientation.None)
                metadatas.Add("Make", tags.Orientation);
            if(tags.Longitude!=null)
                metadatas.Add("Longitude", (double)tags.Longitude);
            if(tags.Keywords.Length>0)
                metadatas.Add("Keywords", string.Join(",", tags.Keywords));
            if(tags.ISOSpeedRatings!=null)
                metadatas.Add("ISOSpeedRatings", (uint)tags.ISOSpeedRatings);
            if (tags.Creator != null)
                metadatas.Add("Creator", tags.Creator);
            if (!string.IsNullOrEmpty(tags.Comment))
                metadatas.Add("Comment", tags.Comment);
            if (tags.Rating != null)
                metadatas.Add("Rating", (uint)tags.Rating);
            if (tags.Software != null)
                metadatas.Add("Software", tags.Software);
            if (tags.FNumber != null)
                metadatas.Add("FNumber", (double)tags.FNumber);
            if (tags.ExposureTime != null)
                metadatas.Add("ExposureTime", (double)tags.ExposureTime);
            if (tags.FocalLength != null)
                metadatas.Add("FocalLength", (double)tags.FocalLength);
            if (tags.FocalLengthIn35mmFilm != null)
                metadatas.Add("FocalLengthIn35mmFilm", (uint)tags.FocalLengthIn35mmFilm);
            if (tags.DateTime != null)
                metadatas.Add("DateTime", (DateTime)tags.DateTime);

            if ((file.TagTypes & TagLib.TagTypes.XMP) == TagLib.TagTypes.XMP)
            {
                TagLib.Xmp.XmpTag tagXmp = file.GetTag(TagLib.TagTypes.XMP) as TagLib.Xmp.XmpTag;
                foreach (TagLib.Xmp.XmpNode node in tagXmp.NodeTree.Children)
                {
                    if(!string.IsNullOrEmpty(node.Value))
                    metadatas.Add(node.Name, node.Value);
                }
            }
            if ((file.TagTypes & TagLib.TagTypes.GifComment) == TagLib.TagTypes.GifComment)
            {
                TagLib.Gif.GifCommentTag tagGif = file.GetTag(TagLib.TagTypes.GifComment) as TagLib.Gif.GifCommentTag;
                metadatas.Add("GifComment", tagGif.Comment);
            }

            return metadatas;
        }
示例#19
0
        public ToxyMetadata Parse()
        {
            if (!System.IO.File.Exists(Context.Path))
            {
                throw new System.IO.FileNotFoundException("File " + Context.Path + " is not found");
            }

            ToxyMetadata metadata = new ToxyMetadata();

            using (Stream stream = File.OpenRead(Context.Path))
            {
                POIFSFileSystem poifs = new NPOI.POIFS.FileSystem.POIFSFileSystem(stream);
                DirectoryNode   root  = poifs.Root;

                SummaryInformation         si  = null;
                DocumentSummaryInformation dsi = null;
                if (root.HasEntry(SummaryInformation.DEFAULT_STREAM_NAME))
                {
                    PropertySet ps = GetPropertySet(root, SummaryInformation.DEFAULT_STREAM_NAME);
                    if (ps is SummaryInformation)
                    {
                        si = ps as SummaryInformation;

                        if (si.Author != null)
                        {
                            metadata.Add("Author", si.Author);
                        }
                        if (si.ApplicationName != null)
                        {
                            metadata.Add("ApplicationName", si.ApplicationName);
                        }
                        if (si.ClassID != null)
                        {
                            metadata.Add("ClassID", si.ClassID.ToString());
                        }
                        if (si.CharCount != 0)
                        {
                            metadata.Add("CharCount", si.CharCount);
                        }
                        if (si.ByteOrder != 0)
                        {
                            metadata.Add("ByteOrder", si.ByteOrder);
                        }
                        if (si.CreateDateTime != null)
                        {
                            metadata.Add("CreateDateTime", si.CreateDateTime);
                        }
                        if (si.LastAuthor != null)
                        {
                            metadata.Add("LastAuthor", si.LastAuthor);
                        }
                        if (si.Keywords != null)
                        {
                            metadata.Add("Keywords", si.Keywords);
                        }
                        if (si.LastPrinted != null)
                        {
                            metadata.Add("LastPrinted", si.LastPrinted);
                        }
                        if (si.LastSaveDateTime != null)
                        {
                            metadata.Add("LastSaveDateTime", si.LastSaveDateTime);
                        }
                        if (si.PageCount != 0)
                        {
                            metadata.Add("PageCount", si.PageCount);
                        }
                        if (si.WordCount != 0)
                        {
                            metadata.Add("WordCount", si.WordCount);
                        }
                        if (si.Comments != null)
                        {
                            metadata.Add("Comments", si.Comments);
                        }
                        if (si.EditTime != 0)
                        {
                            metadata.Add("EditTime", si.EditTime);
                        }
                        if (si.RevNumber != null)
                        {
                            metadata.Add("RevNumber", si.RevNumber);
                        }
                        if (si.Security != 0)
                        {
                            metadata.Add("Security", si.Security);
                        }
                        if (si.Subject != null)
                        {
                            metadata.Add("Subject", si.Subject);
                        }
                        if (si.Title != null)
                        {
                            metadata.Add("Title", si.Title);
                        }
                        if (si.Template != null)
                        {
                            metadata.Add("Template", si.Template);
                        }
                    }
                }

                if (root.HasEntry(DocumentSummaryInformation.DEFAULT_STREAM_NAME))
                {
                    PropertySet ps = GetPropertySet(root, DocumentSummaryInformation.DEFAULT_STREAM_NAME);
                    if (ps is DocumentSummaryInformation)
                    {
                        dsi = ps as DocumentSummaryInformation;
                        if (dsi.ByteCount > 0)
                        {
                            metadata.Add("ByteCount", dsi.ByteCount);
                        }
                        else if (dsi.Company != null)
                        {
                            metadata.Add("Company", dsi.Company);
                        }
                        else if (dsi.Format > 0)
                        {
                            metadata.Add("Format", dsi.Format);
                        }
                        else if (dsi.LineCount > 0)
                        {
                            metadata.Add("LineCount", dsi.LineCount);
                        }
                        else if (dsi.LinksDirty)
                        {
                            metadata.Add("LinksDirty", true);
                        }
                        else if (dsi.Manager != null)
                        {
                            metadata.Add("Manager", dsi.Manager);
                        }
                        else if (dsi.NoteCount > 0)
                        {
                            metadata.Add("NoteCount", dsi.NoteCount);
                        }
                        else if (dsi.Scale)
                        {
                            metadata.Add("Scale", dsi.Scale);
                        }
                        else if (dsi.HiddenCount > 0)
                        {
                            metadata.Add("HiddenCount", dsi.Company);
                        }
                        else if (dsi.MMClipCount > 0)
                        {
                            metadata.Add("MMClipCount", dsi.MMClipCount);
                        }
                        else if (dsi.ParCount > 0)
                        {
                            metadata.Add("ParCount", dsi.ParCount);
                        }
                    }
                }
            }
            return(metadata);
        }
示例#20
0
        public ToxyMetadata Parse()
        {
            if (!System.IO.File.Exists(Context.Path))
                throw new System.IO.FileNotFoundException("File " + Context.Path + " is not found");

            ToxyMetadata metadata=new ToxyMetadata();
            using (Stream stream = File.OpenRead(Context.Path))
            {
                POIFSFileSystem poifs = new NPOI.POIFS.FileSystem.POIFSFileSystem(stream);
                DirectoryNode root=poifs.Root;

                SummaryInformation si = null;
                DocumentSummaryInformation dsi = null;
                if(root.HasEntry(SummaryInformation.DEFAULT_STREAM_NAME))
                {
                    PropertySet ps = GetPropertySet(root, SummaryInformation.DEFAULT_STREAM_NAME);
                    if (ps is SummaryInformation)
                    {
                        si = ps as SummaryInformation;
                    
                    if (si.Author != null)
                        metadata.Add("Author", si.Author);
                    if (si.ApplicationName != null)
                        metadata.Add("ApplicationName", si.ApplicationName);
                    if (si.ClassID != null)
                        metadata.Add("ClassID", si.ClassID.ToString());
                    if(si.CharCount!=0)
                        metadata.Add("CharCount", si.CharCount);
                    if (si.ByteOrder != 0)
                        metadata.Add("ByteOrder", si.ByteOrder);
                    if(si.CreateDateTime!=null)
                        metadata.Add("CreateDateTime", si.CreateDateTime);
                    if (si.LastAuthor != null)
                        metadata.Add("LastAuthor", si.LastAuthor);
                    if (si.Keywords != null)
                        metadata.Add("Keywords", si.Keywords);
                    if (si.LastPrinted != null)
                        metadata.Add("LastPrinted", si.LastPrinted);
                    if (si.LastSaveDateTime != null)
                        metadata.Add("LastSaveDateTime", si.LastSaveDateTime);
                    if (si.PageCount != 0)
                        metadata.Add("PageCount", si.PageCount);
                    if (si.WordCount != 0)
                        metadata.Add("WordCount", si.WordCount);
                    if (si.Comments != null)
                        metadata.Add("Comments", si.Comments);
                    if (si.EditTime != 0)
                        metadata.Add("EditTime", si.EditTime);
                    if (si.RevNumber != null)
                        metadata.Add("RevNumber", si.RevNumber);
                    if (si.Security != 0)
                        metadata.Add("Security", si.Security);
                    if (si.Subject != null)
                        metadata.Add("Subject", si.Subject);
                    if (si.Title != null)
                        metadata.Add("Title", si.Title);
                    if (si.Template != null)
                        metadata.Add("Template", si.Template);
                    }
                }

                if (root.HasEntry(DocumentSummaryInformation.DEFAULT_STREAM_NAME))
                {
                    PropertySet ps = GetPropertySet(root, DocumentSummaryInformation.DEFAULT_STREAM_NAME);
                    if (ps is DocumentSummaryInformation)
                    {
                        dsi = ps as DocumentSummaryInformation;
                        if (dsi.ByteCount > 0)
                        {
                            metadata.Add("ByteCount", dsi.ByteCount);
                        }
                        else if (dsi.Company != null)
                        {
                            metadata.Add("Company", dsi.Company);
                        }
                        else if (dsi.Format > 0)
                        {
                            metadata.Add("Format", dsi.Format);
                        }
                        else if (dsi.LineCount > 0)
                        {
                            metadata.Add("LineCount", dsi.LineCount);
                        }
                        else if (dsi.LinksDirty)
                        {
                            metadata.Add("LinksDirty", true);
                        }
                        else if (dsi.Manager != null)
                        {
                            metadata.Add("Manager", dsi.Manager);
                        }
                        else if (dsi.NoteCount > 0)
                        {
                            metadata.Add("NoteCount", dsi.NoteCount);
                        }
                        else if (dsi.Scale)
                        {
                            metadata.Add("Scale", dsi.Scale);
                        }
                        else if (dsi.HiddenCount > 0)
                        {
                            metadata.Add("HiddenCount", dsi.Company);
                        }
                        else if (dsi.MMClipCount > 0)
                        {
                            metadata.Add("MMClipCount", dsi.MMClipCount);
                        }
                        else if (dsi.ParCount > 0)
                        {
                            metadata.Add("ParCount", dsi.ParCount);
                        }
                    }
                }
            }
            return metadata;
        }
示例#21
0
        private void ShowDocument(string filepath, string encoding, string extension)
        {
            ParserContext context = new ParserContext(filepath);

            context.Encoding = Encoding.GetEncoding(encoding);

            if (Mode == ViewMode.Text)
            {
                AppendRichTextBox();
                var tparser = ParserFactory.CreateText(context);
                rtbPanel.Text     = tparser.Parse();
                tbParserType.Text = tparser.GetType().Name;
            }
            else if (Mode == ViewMode.Structured)
            {
                switch (extension)
                {
                case ".csv":
                    AppendSpreadsheetGrid();
                    context.Properties.Add("HasHeader", "1");
                    ISpreadsheetParser csvparser = ParserFactory.CreateSpreadsheet(context);
                    ss = csvparser.Parse();
                    tbParserType.Text = csvparser.GetType().Name;
                    var table1 = ss.Tables[0];
                    ShowToGrid(table1);
                    cbSheets.Items.Clear();
                    foreach (var table in ss.Tables)
                    {
                        cbSheets.Items.Add(table.Name);
                    }
                    cbSheets.SelectedIndex = 0;
                    panel1.Visible         = true;
                    break;

                case ".xlsx":
                case ".xls":
                    AppendSpreadsheetGrid();
                    ISpreadsheetParser ssparser = ParserFactory.CreateSpreadsheet(context);
                    ss = ssparser.Parse();
                    tbParserType.Text = ssparser.GetType().Name;
                    var table0 = ss.Tables[0];
                    ShowToGrid(table0);
                    cbSheets.Items.Clear();
                    foreach (var table in ss.Tables)
                    {
                        cbSheets.Items.Add(table.Name);
                    }
                    cbSheets.SelectedIndex = 0;
                    panel1.Visible         = true;
                    break;

                case ".vcf":
                    AppendDataGridView();
                    var vparser = ParserFactory.CreateVCard(context);
                    ToxyBusinessCards vcards = vparser.Parse();
                    tbParserType.Text             = vparser.GetType().Name;
                    gridPanel.GridView.DataSource = vcards.ToDataTable().DefaultView;
                    break;

                case ".pptx":
                    //TODO: show slides
                    break;

                case ".xml":
                case ".htm":
                case ".html":
                    AppendTreePanel();
                    var      domparser = ParserFactory.CreateDom(context);
                    ToxyDom  htmlDom   = domparser.Parse();
                    TreeNode rootNode  = treePanel.Tree.Nodes.Add(htmlDom.Root.NodeString);
                    treePanel.Tree.BeginUpdate();
                    AppendTree(rootNode, htmlDom.Root);
                    treePanel.Tree.EndUpdate();
                    //rootNode.ExpandAll();
                    break;
                }
            }
            else
            {
                AppendPropertyListPanel();
                var          tparser   = ParserFactory.CreateMetadata(context);
                ToxyMetadata metadatas = tparser.Parse();
                plPanel.Clear();
                foreach (var data in metadatas)
                {
                    plPanel.AddItem(data.Name, data.Value.ToString());
                }
                tbParserType.Text = tparser.GetType().Name;
            }
        }
示例#22
0
        public ToxyMetadata Parse()
        {
            if (!System.IO.File.Exists(Context.Path))
            {
                throw new System.IO.FileNotFoundException("File " + Context.Path + " is not found");
            }

            ToxyMetadata metadatas = new ToxyMetadata();

            TagLib.File file = TagLib.Image.File.Create(Context.Path);
            if (file.Properties.PhotoHeight != 0)
            {
                metadatas.Add("PhotoHeight", file.Properties.PhotoHeight);
            }
            if (file.Properties.PhotoQuality != 0)
            {
                metadatas.Add("PhotoQuality", file.Properties.PhotoQuality);
            }
            if (file.Properties.PhotoWidth != 0)
            {
                metadatas.Add("PhotoWidth", file.Properties.PhotoWidth);
            }

            CombinedImageTag tags = file.Tag as CombinedImageTag;

            if (tags.Altitude != null)
            {
                metadatas.Add("Altitude", (double)tags.Altitude);
            }
            if (tags.Latitude != null)
            {
                metadatas.Add("Latitude", (double)tags.Latitude);
            }
            if (tags.Model != null)
            {
                metadatas.Add("Model", tags.Model);
            }
            if (tags.Make != null)
            {
                metadatas.Add("Make", tags.Make);
            }
            if (tags.Orientation != ImageOrientation.None)
            {
                metadatas.Add("Make", tags.Orientation);
            }
            if (tags.Longitude != null)
            {
                metadatas.Add("Longitude", (double)tags.Longitude);
            }
            if (tags.Keywords.Length > 0)
            {
                metadatas.Add("Keywords", string.Join(",", tags.Keywords));
            }
            if (tags.ISOSpeedRatings != null)
            {
                metadatas.Add("ISOSpeedRatings", (uint)tags.ISOSpeedRatings);
            }
            if (tags.Creator != null)
            {
                metadatas.Add("Creator", tags.Creator);
            }
            if (!string.IsNullOrEmpty(tags.Comment))
            {
                metadatas.Add("Comment", tags.Comment);
            }
            if (!string.IsNullOrEmpty(tags.Description))
            {
                metadatas.Add("Comment", tags.Description); // TODO: sort this out
            }
            if (tags.Rating != null)
            {
                metadatas.Add("Rating", (uint)tags.Rating);
            }
            if (tags.Software != null)
            {
                metadatas.Add("Software", tags.Software);
            }
            if (tags.FNumber != null)
            {
                metadatas.Add("FNumber", (double)tags.FNumber);
            }
            if (tags.ExposureTime != null)
            {
                metadatas.Add("ExposureTime", (double)tags.ExposureTime);
            }
            if (tags.FocalLength != null)
            {
                metadatas.Add("FocalLength", (double)tags.FocalLength);
            }
            if (tags.FocalLengthIn35mmFilm != null)
            {
                metadatas.Add("FocalLengthIn35mmFilm", (uint)tags.FocalLengthIn35mmFilm);
            }
            if (tags.DateTime != null)
            {
                metadatas.Add("DateTime", (DateTime)tags.DateTime);
            }

            if ((file.TagTypes & TagLib.TagTypes.XMP) == TagLib.TagTypes.XMP)
            {
                TagLib.Xmp.XmpTag tagXmp = file.GetTag(TagLib.TagTypes.XMP) as TagLib.Xmp.XmpTag;
                foreach (TagLib.Xmp.XmpNode node in tagXmp.NodeTree.Children)
                {
                    if (!string.IsNullOrEmpty(node.Value))
                    {
                        metadatas.Add(node.Name, node.Value);
                    }
                }
            }
            if ((file.TagTypes & TagLib.TagTypes.GifComment) == TagLib.TagTypes.GifComment)
            {
                TagLib.Gif.GifCommentTag tagGif = file.GetTag(TagLib.TagTypes.GifComment) as TagLib.Gif.GifCommentTag;
                metadatas.Add("GifComment", tagGif.Comment);
            }

            return(metadatas);
        }
示例#23
0
        public ToxyMetadata Parse()
        {
            if (!System.IO.File.Exists(Context.Path))
                throw new System.IO.FileNotFoundException("File " + Context.Path + " is not found");

            ToxyMetadata metadata=new ToxyMetadata();
            OPCPackage pack=null;
            try
            {
                pack = OPCPackage.Open(Context.Path, PackageAccess.READ);
                POIXMLProperties props = new POIXMLProperties(pack);
                if (props.CoreProperties != null)
                {
                    if (props.CoreProperties.Title != null)
                    {
                        metadata.Add("Title", props.CoreProperties.Title);
                    }
                    else if (props.CoreProperties.Identifier != null)
                    {
                        metadata.Add("Identifier", props.CoreProperties.Identifier);
                    }
                    else if (props.CoreProperties.Keywords != null)
                    {
                        metadata.Add("Keywords", props.CoreProperties.Keywords);
                    }
                    else if (props.CoreProperties.Revision != null)
                    {
                        metadata.Add("Revision", props.CoreProperties.Revision);
                    }
                    else if (props.CoreProperties.Subject != null)
                    {
                        metadata.Add("Subject", props.CoreProperties.Subject);
                    }
                    else if (props.CoreProperties.Modified != null)
                    {
                        metadata.Add("Modified", props.CoreProperties.Modified);
                    }
                    else if (props.CoreProperties.LastPrinted != null)
                    {
                        metadata.Add("LastPrinted", props.CoreProperties.LastPrinted);
                    }
                    else if (props.CoreProperties.Created != null)
                    {
                        metadata.Add("Created", props.CoreProperties.Created);
                    }
                    else if (props.CoreProperties.Creator != null)
                    {
                        metadata.Add("Creator", props.CoreProperties.Creator);
                    }
                    else if (props.CoreProperties.Description != null)
                    {
                        metadata.Add("Description", props.CoreProperties.Description);
                    }
                }
                if (props.ExtendedProperties != null && props.ExtendedProperties.props != null)
                {
                    var extProps = props.ExtendedProperties.props.GetProperties();
                    if (extProps.Application != null)
                    {
                        metadata.Add("Application", extProps.Application);
                    }
                    if (extProps.AppVersion != null)
                    {
                        metadata.Add("AppVersion", extProps.AppVersion);
                    }
                    if (extProps.Characters > 0)
                    {
                        metadata.Add("Characters", extProps.Characters);
                    }
                    if (extProps.CharactersWithSpaces > 0)
                    {
                        metadata.Add("CharactersWithSpaces", extProps.CharactersWithSpaces);
                    }
                    if (extProps.Company != null)
                    {
                        metadata.Add("Company", extProps.Company);
                    }
                    if (extProps.Lines > 0)
                    {
                        metadata.Add("Lines", extProps.Lines);
                    }
                    if (extProps.Manager != null)
                    {
                        metadata.Add("Manager", extProps.Manager);
                    }
                    if (extProps.Notes > 0)
                    {
                        metadata.Add("Notes", extProps.Notes);
                    }
                    if (extProps.Pages > 0)
                    {
                        metadata.Add("Pages", extProps.Pages);
                    }
                    if (extProps.Paragraphs > 0)
                    {
                        metadata.Add("Paragraphs", extProps.Paragraphs);
                    }
                    if (extProps.Words > 0)
                    {
                        metadata.Add("Words", extProps.Words);
                    }
                    if (extProps.TotalTime > 0)
                    {
                        metadata.Add("TotalTime", extProps.TotalTime);
                    }
                }
            }
            finally
            {
                if(pack!=null)
                    pack.Close();
            }

            return metadata;
        }