public override FileMetadata AnalyzeFile() { try { this.foundMetadata = new FileMetadata(); using (StreamReader sr = new StreamReader(this.fileStream)) { string line = string.Empty; while ((line = sr.ReadLine()) != null) { string[] separatedValues = line.Split(new char[] { '=' }); if (separatedValues.Length < 2) { continue; } string key = separatedValues[0].ToLower(); string value = line.Remove(0, key.Length + 1); if (String.IsNullOrWhiteSpace(value)) { continue; } if (key.StartsWith("address") || key.StartsWith("httpbrowseraddress") || key.StartsWith("tcpbrowseraddress") || key.StartsWith("sslproxyhost")) { string ipOrHost = value.Split(new char[] { ':' })[0]; if (ipOrHost != "*") { this.foundMetadata.Add(new Server(ipOrHost, "ICA file Analysis")); } } else if (key.StartsWith("username")) { this.foundMetadata.Add(new User(value, true)); } else if (key.StartsWith("clearpassword") || key.StartsWith("password")) { this.foundMetadata.Add(new Password(value, "ICA Clear password")); } else if (key.StartsWith("persistentcachepath") || key.StartsWith("workdirectory") || key.StartsWith("initialprogram") || key.StartsWith("iconpath")) { this.foundMetadata.Add(new Diagrams.Path(value, true)); string user = PathAnalysis.ExtractUserFromPath(value); if (user != string.Empty) { this.foundMetadata.Add(new User(user, true)); } string softName = ApplicationAnalysis.GetApplicationsFromString(value); if (!string.IsNullOrEmpty(value)) { this.foundMetadata.Add(new Application(softName)); } else { this.foundMetadata.Add(new Application(value)); } } } } } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e.ToString()); } return(this.foundMetadata); }
/// <summary> /// Extrae los metadatos del documento /// </summary> public override FileMetadata AnalyzeFile() { try { this.foundMetadata = new FileMetadata(); using (PdfDocument doc = PdfReader.Open(this.fileStream, PdfDocumentOpenMode.InformationOnly)) { int imageNumber = 0; //Read embedded images foreach (PdfDictionary item in doc.Internals.GetAllObjects().Where(p => p is PdfDictionary d && d.Stream != null && "/Image".Equals(d.Elements["/Subtype"]?.ToString()))) { try { using (MemoryStream msJPG = new MemoryStream(item.Stream.Value)) { using (EXIFDocument eDoc = new EXIFDocument(msJPG)) { FileMetadata exifMetadata = eDoc.AnalyzeFile(); //Ignore images which only contain 'Adobe JPEG' makernotes if (exifMetadata != null && exifMetadata.HasMetadata() && !exifMetadata.Makernotes.All(p => p.Key == "Adobe JPEG")) { foundMetadata.EmbeddedImages.Add(imageNumber.ToString(), exifMetadata); imageNumber++; this.foundMetadata.AddRange(exifMetadata.Users.ToArray()); this.foundMetadata.AddRange(exifMetadata.Applications.ToArray()); } } } } catch (Exception) { } } ReadXMPMetadata(doc); if (doc.Info.Title != string.Empty) { this.foundMetadata.Title = Functions.ToPlainText(doc.Info.Title); if (Uri.IsWellFormedUriString(doc.Info.Title, UriKind.Absolute)) { this.foundMetadata.Add(new Diagrams.Path(PathAnalysis.CleanPath(doc.Info.Title), true)); } } if (doc.Info.Subject != string.Empty) { this.foundMetadata.Subject = Functions.ToPlainText(doc.Info.Subject); } if (doc.Info.Author != string.Empty) { this.foundMetadata.Add(new User(Functions.ToPlainText(doc.Info.Author), true)); } if (doc.Info.Keywords != string.Empty) { this.foundMetadata.Keywords = Functions.ToPlainText(doc.Info.Keywords); } if (doc.Info.Creator != string.Empty) { string strSoftware = ApplicationAnalysis.GetApplicationsFromString(Functions.ToPlainText(doc.Info.Creator)); if (strSoftware.Trim() != string.Empty) { this.foundMetadata.Add(new Application(strSoftware)); } //No se ha localizado ninguna aplicación conocida, aun así mostrar la aplicación encontrada else if (!String.IsNullOrWhiteSpace(Functions.ToPlainText(doc.Info.Creator))) { this.foundMetadata.Add(new Application(Functions.ToPlainText(doc.Info.Creator).Trim())); } } if (!String.IsNullOrWhiteSpace(doc.Info.Producer)) { string strSoftware = ApplicationAnalysis.GetApplicationsFromString(Functions.ToPlainText(doc.Info.Producer)); if (!String.IsNullOrWhiteSpace(strSoftware)) { this.foundMetadata.Add(new Application(strSoftware)); } //No se ha localizado ninguna aplicación conocida, aun así mostrar la aplicación encontrada else if (!String.IsNullOrWhiteSpace(Functions.ToPlainText(doc.Info.Producer))) { this.foundMetadata.Add(new Application(Functions.ToPlainText(doc.Info.Producer).Trim())); } } try { if (doc.Info.CreationDate != DateTime.MinValue) { this.foundMetadata.Dates.CreationDate = doc.Info.CreationDate; } } catch (InvalidCastException) { } try { if (doc.Info.ModificationDate != DateTime.MinValue) { this.foundMetadata.Dates.ModificationDate = doc.Info.ModificationDate; } } catch (InvalidCastException) { } } SearchPathsLinksAndEmails(this.fileStream); //Find users in paths foreach (Diagrams.Path path in this.foundMetadata.Paths) { string strUser = PathAnalysis.ExtractUserFromPath(path.Value); this.foundMetadata.Add(new User(strUser, path.IsComputerFolder)); } //Also search software in the title (only pdf). It is added only if the software is known. if (!String.IsNullOrEmpty(foundMetadata.Title)) { string strSoftware = ApplicationAnalysis.GetApplicationsFromString(foundMetadata.Title); if (!String.IsNullOrWhiteSpace(strSoftware)) { this.foundMetadata.Add(new Application(strSoftware)); } } } catch (PdfReaderException) { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); } finally { if (foundMetadata == null) { this.foundMetadata = new FileMetadata(); } if (fileStream != null) { this.fileStream.Dispose(); } } return(this.foundMetadata); }
private void AnalizeFileApp(Stream stm) { try { XmlDocument doc = new XmlDocument(); doc.XmlResolver = null; doc.Load(stm); XmlNodeList xnl = doc.GetElementsByTagName("Application"); if (xnl.Count != 0) { if (xnl[0].HasChildNodes) { string app = xnl[0].FirstChild.Value; xnl = doc.GetElementsByTagName("AppVersion"); if (xnl.Count != 0) { if (xnl[0].HasChildNodes) { string strSoftware = ApplicationAnalysis.GetApplicationsFromString(app + " - " + xnl[0].FirstChild.Value); this.foundMetadata.Add(new Application(strSoftware)); } } } } xnl = doc.GetElementsByTagName("Company"); if (xnl.Count != 0) { if (xnl[0].HasChildNodes) { this.foundMetadata.Company = xnl[0].FirstChild.Value; } } xnl = doc.GetElementsByTagName("Manager"); if (xnl.Count != 0) { if (xnl[0].HasChildNodes) { this.foundMetadata.Add(new User(xnl[0].FirstChild.Value, false, "Manager")); } } xnl = doc.GetElementsByTagName("TotalTime"); if (xnl.Count != 0) { if (xnl[0].HasChildNodes) { Double d; if (Double.TryParse(xnl[0].FirstChild.Value, out d)) { this.foundMetadata.EditTime = (decimal)d; } } } StringBuilder statisticBuilder = new StringBuilder(); xnl = doc.GetElementsByTagName("Pages"); if (xnl.Count != 0) { if (xnl[0].HasChildNodes) { statisticBuilder.Append("Pages: " + xnl[0].FirstChild.Value); } } xnl = doc.GetElementsByTagName("Words"); if (xnl.Count != 0) { if (xnl[0].HasChildNodes) { statisticBuilder.Append("\tWords: " + xnl[0].FirstChild.Value); } } xnl = doc.GetElementsByTagName("Characters"); if (xnl.Count != 0) { if (xnl[0].HasChildNodes) { statisticBuilder.Append("\tCharacters: " + xnl[0].FirstChild.Value); } } xnl = doc.GetElementsByTagName("Lines"); if (xnl.Count != 0) { if (xnl[0].HasChildNodes) { statisticBuilder.Append("\tLines: " + xnl[0].FirstChild.Value); } } xnl = doc.GetElementsByTagName("Paragraphs"); if (xnl.Count != 0) { if (xnl[0].HasChildNodes) { statisticBuilder.Append("\tParagraphs: " + xnl[0].FirstChild.Value); } } this.foundMetadata.Statistic = statisticBuilder.ToString().Trim(); } catch (Exception e) { System.Diagnostics.Debug.WriteLine(String.Format("Error reading file app.xml ({0}).", e.ToString())); } }
/// <summary> /// Extrae los metadatos del documento /// </summary> public override FileMetadata AnalyzeFile() { try { this.foundMetadata = new FileMetadata(); using (PdfDocument doc = PdfReader.Open(this.fileStream, PdfDocumentOpenMode.InformationOnly)) { ReadXMPMetadata(doc); if (doc.Info.Title != string.Empty) { this.foundMetadata.Title = Functions.ToPlainText(doc.Info.Title); if (Uri.IsWellFormedUriString(doc.Info.Title, UriKind.Absolute)) { this.foundMetadata.Add(new Diagrams.Path(PathAnalysis.CleanPath(doc.Info.Title), true)); } } if (doc.Info.Subject != string.Empty) { this.foundMetadata.Subject = Functions.ToPlainText(doc.Info.Subject); } if (doc.Info.Author != string.Empty) { this.foundMetadata.Add(new User(Functions.ToPlainText(doc.Info.Author), true)); } if (doc.Info.Keywords != string.Empty) { this.foundMetadata.Keywords = Functions.ToPlainText(doc.Info.Keywords); } if (doc.Info.Creator != string.Empty) { string strSoftware = ApplicationAnalysis.GetApplicationsFromString(Functions.ToPlainText(doc.Info.Creator)); if (strSoftware.Trim() != string.Empty) { this.foundMetadata.Add(new Application(strSoftware)); } //No se ha localizado ninguna aplicación conocida, aun así mostrar la aplicación encontrada else if (!String.IsNullOrWhiteSpace(Functions.ToPlainText(doc.Info.Creator))) { this.foundMetadata.Add(new Application(Functions.ToPlainText(doc.Info.Creator).Trim())); } } if (!String.IsNullOrWhiteSpace(doc.Info.Producer)) { string strSoftware = ApplicationAnalysis.GetApplicationsFromString(Functions.ToPlainText(doc.Info.Producer)); if (!String.IsNullOrWhiteSpace(strSoftware)) { this.foundMetadata.Add(new Application(strSoftware)); } //No se ha localizado ninguna aplicación conocida, aun así mostrar la aplicación encontrada else if (!String.IsNullOrWhiteSpace(Functions.ToPlainText(doc.Info.Producer))) { this.foundMetadata.Add(new Application(Functions.ToPlainText(doc.Info.Producer).Trim())); } } try { if (doc.Info.CreationDate != DateTime.MinValue) { this.foundMetadata.Dates.CreationDate = doc.Info.CreationDate; } } catch (InvalidCastException) { } try { if (doc.Info.ModificationDate != DateTime.MinValue) { this.foundMetadata.Dates.ModificationDate = doc.Info.ModificationDate; } } catch (InvalidCastException) { } } //Busca path y links binariamente this.foundMetadata.AddRange(BinarySearchPaths(this.fileStream).ToArray()); this.foundMetadata.AddRange(BinarySearchLinks(this.fileStream).ToArray()); foreach (Diagrams.Path ri in this.foundMetadata.Paths) { //Busca usuarios dentro de la ruta string strUser = PathAnalysis.ExtractUserFromPath(ri.Value); this.foundMetadata.Add(new User(strUser, ri.IsComputerFolder)); } //También busca el software en el título solo en los pdf, solo lo añade si es software conocido if (!String.IsNullOrEmpty(foundMetadata.Title)) { string strSoftware = ApplicationAnalysis.GetApplicationsFromString(foundMetadata.Title); if (!String.IsNullOrWhiteSpace(strSoftware)) { this.foundMetadata.Add(new Application(strSoftware)); } } } catch (PdfReaderException) { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); } finally { if (foundMetadata == null) { this.foundMetadata = new FileMetadata(); } } return(this.foundMetadata); }
/// <summary> /// Extrae los metadatos del documento /// </summary> public override FileMetadata AnalyzeFile() { try { this.foundMetadata = new FileMetadata(); using (PdfDocument doc = PdfReader.Open(this.fileStream, PdfDocumentOpenMode.InformationOnly)) { ReadXMPMetadata(doc); if (doc.Info.Title != string.Empty) { this.foundMetadata.Title = Functions.ToPlainText(doc.Info.Title); if (Uri.IsWellFormedUriString(doc.Info.Title, UriKind.Absolute)) { this.foundMetadata.Add(new Diagrams.Path(PathAnalysis.CleanPath(doc.Info.Title), true)); } } if (doc.Info.Subject != string.Empty) { this.foundMetadata.Subject = Functions.ToPlainText(doc.Info.Subject); } if (doc.Info.Author != string.Empty) { this.foundMetadata.Add(new User(Functions.ToPlainText(doc.Info.Author), true)); } if (doc.Info.Keywords != string.Empty) { this.foundMetadata.Keywords = Functions.ToPlainText(doc.Info.Keywords); } if (doc.Info.Creator != string.Empty) { string strSoftware = ApplicationAnalysis.GetApplicationsFromString(Functions.ToPlainText(doc.Info.Creator)); if (strSoftware.Trim() != string.Empty) { this.foundMetadata.Add(new Application(strSoftware)); } //No se ha localizado ninguna aplicación conocida, aun así mostrar la aplicación encontrada else if (!String.IsNullOrWhiteSpace(Functions.ToPlainText(doc.Info.Creator))) { this.foundMetadata.Add(new Application(Functions.ToPlainText(doc.Info.Creator).Trim())); } } if (!String.IsNullOrWhiteSpace(doc.Info.Producer)) { string strSoftware = ApplicationAnalysis.GetApplicationsFromString(Functions.ToPlainText(doc.Info.Producer)); if (!String.IsNullOrWhiteSpace(strSoftware)) { this.foundMetadata.Add(new Application(strSoftware)); } //No se ha localizado ninguna aplicación conocida, aun así mostrar la aplicación encontrada else if (!String.IsNullOrWhiteSpace(Functions.ToPlainText(doc.Info.Producer))) { this.foundMetadata.Add(new Application(Functions.ToPlainText(doc.Info.Producer).Trim())); } } try { if (doc.Info.CreationDate != DateTime.MinValue) { this.foundMetadata.Dates.CreationDate = doc.Info.CreationDate; } } catch (InvalidCastException) { } try { if (doc.Info.ModificationDate != DateTime.MinValue) { this.foundMetadata.Dates.ModificationDate = doc.Info.ModificationDate; } } catch (InvalidCastException) { } } SearchPathsLinksAndEmails(this.fileStream); //Find users in paths foreach (Diagrams.Path path in this.foundMetadata.Paths) { string strUser = PathAnalysis.ExtractUserFromPath(path.Value); this.foundMetadata.Add(new User(strUser, path.IsComputerFolder)); } //Also search software in the title (only pdf). It is added only if the software is known. if (!String.IsNullOrEmpty(foundMetadata.Title)) { string strSoftware = ApplicationAnalysis.GetApplicationsFromString(foundMetadata.Title); if (!String.IsNullOrWhiteSpace(strSoftware)) { this.foundMetadata.Add(new Application(strSoftware)); } } } catch (PdfReaderException ex) { } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.ToString()); } finally { if (foundMetadata == null) { this.foundMetadata = new FileMetadata(); } if (fileStream != null) { this.fileStream.Dispose(); } } return(this.foundMetadata); }
protected void ExtractFromXMP(XmlDocument xDoc) { #region Metadatos como atributos XmlNodeList xnl = xDoc.GetElementsByTagName("rdf:Description"); foreach (XmlNode xn in xnl) { XmlAttribute xa = xn.Attributes["pdf:Creator"]; if (xa != null && !string.IsNullOrEmpty(xa.Value)) { string strValue = Analysis.ApplicationAnalysis.GetApplicationsFromString(xa.Value); if (!String.IsNullOrWhiteSpace(strValue)) { this.foundMetadata.Add(new Application(strValue.Trim())); } //No se ha localizado ninguna aplicación conocida, aun así mostrar la aplicación encontrada else if (!String.IsNullOrWhiteSpace(xa.Value)) { this.foundMetadata.Add(new Application(xa.Value.Trim())); } } xa = xn.Attributes["pdf:CreationDate"]; if (xa != null && !string.IsNullOrEmpty(xa.Value)) { string strValue = xa.Value; DateTime d; if (DateTime.TryParse(strValue.Replace('T', ' ').Replace('Z', ' '), out d)) { //Si existe una fecha de creación anterior, sobreescribir if (!foundMetadata.Dates.CreationDate.HasValue || this.foundMetadata.Dates.CreationDate > d) { this.foundMetadata.Dates.CreationDate = d; } } } xa = xn.Attributes["pdf:Title"]; if (xa != null && !string.IsNullOrEmpty(xa.Value)) { string strValue = xa.Value; if (string.IsNullOrWhiteSpace(foundMetadata.Title) || this.foundMetadata.Title.Length < strValue.Length) { this.foundMetadata.Title = strValue; } } xa = xn.Attributes["pdf:Author"]; if (xa != null && !string.IsNullOrEmpty(xa.Value)) { this.foundMetadata.Add(new User(xa.Value, true)); } xa = xn.Attributes["pdf:Producer"]; if (xa != null && !string.IsNullOrEmpty(xa.Value)) { string strValue = ApplicationAnalysis.GetApplicationsFromString(xa.Value); if (!String.IsNullOrWhiteSpace(strValue)) { this.foundMetadata.Add(new Application(strValue.Trim())); } //No se ha localizado ninguna aplicación conocida, aun así mostrar la aplicación encontrada else if (!String.IsNullOrWhiteSpace(xa.Value)) { this.foundMetadata.Add(new Application(xa.Value.Trim())); } } xa = xn.Attributes["pdf:ModDate"]; if (xa != null && !string.IsNullOrEmpty(xa.Value)) { string strValue = xa.Value; DateTime d; if (DateTime.TryParse(strValue.Replace('T', ' ').Replace('Z', ' '), out d)) { this.foundMetadata.Dates.ModificationDate = d; } } xa = xn.Attributes["xap:CreateDate"]; if (xa != null && !string.IsNullOrEmpty(xa.Value)) { string strValue = xa.Value; DateTime d; if (DateTime.TryParse(strValue.Replace('T', ' ').Replace('Z', ' '), out d)) { //Si existe una fecha de creación anterior, sobreescribir if (!foundMetadata.Dates.CreationDate.HasValue || this.foundMetadata.Dates.CreationDate > d) { //Si existe una fecha de modificación posterior, sobreescribir if (!foundMetadata.Dates.ModificationDate.HasValue || this.foundMetadata.Dates.ModificationDate < d) { this.foundMetadata.Dates.CreationDate = d; } } } } xa = xn.Attributes["xap:Title"]; if (xa != null && !string.IsNullOrEmpty(xa.Value)) { string strValue = xa.Value; //Si ya existe un título y es mas pequeño, sobreescribirle. if (String.IsNullOrWhiteSpace(foundMetadata.Title) || this.foundMetadata.Title.Length < strValue.Length) { this.foundMetadata.Title = strValue; } } xa = xn.Attributes["xap:Author"]; if (xa != null && !string.IsNullOrEmpty(xa.Value)) { this.foundMetadata.Add(new User(xa.Value, true)); } xa = xn.Attributes["xap:ModifyDate"]; if (xa != null && !string.IsNullOrEmpty(xa.Value)) { string strValue = xa.Value; DateTime d; if (DateTime.TryParse(strValue.Replace('T', ' ').Replace('Z', ' '), out d)) { //Si existe una fecha de modificación posterior, sobreescribir if (!foundMetadata.Dates.ModificationDate.HasValue || this.foundMetadata.Dates.ModificationDate < d) { this.foundMetadata.Dates.ModificationDate = d; } } } xa = xn.Attributes["xap:CreatorTool"]; if (xa != null && !string.IsNullOrEmpty(xa.Value)) { string strValue = Analysis.ApplicationAnalysis.GetApplicationsFromString(xa.Value); if (!String.IsNullOrWhiteSpace(strValue)) { this.foundMetadata.Add(new Application(strValue.Trim())); } //No se ha localizado ninguna aplicación conocida, aun así mostrar la aplicación encontrada else if (!String.IsNullOrWhiteSpace(xa.Value)) { this.foundMetadata.Add(new Application(xa.Value.Trim())); } } //xap:MetadataDate, fecha en la que se añadieron los metadatos xa = xn.Attributes["dc:title"]; if (xa != null && !string.IsNullOrEmpty(xa.Value)) { string strValue = xa.Value; //Si ya existe un título y es mas pequeño, sobreescribirle. if (string.IsNullOrEmpty(foundMetadata.Title) || this.foundMetadata.Title.Length < strValue.Length) { this.foundMetadata.Title = strValue; } } xa = xn.Attributes["dc:creator"]; if (xa != null && !string.IsNullOrEmpty(xa.Value)) { string strValue = xa.Value; if (!string.IsNullOrEmpty(strValue)) { this.foundMetadata.Add(new User(strValue, true)); } } } #endregion #region Metadatos como nodos independientes xnl = xDoc.GetElementsByTagName("pdf:Creator"); if (xnl != null && xnl.Count != 0 && xnl[0].HasChildNodes && !string.IsNullOrEmpty(xnl[0].FirstChild.Value)) { string strValue = ApplicationAnalysis.GetApplicationsFromString(xnl[0].FirstChild.Value); if (!String.IsNullOrWhiteSpace(strValue)) { this.foundMetadata.Add(new Application(strValue.Trim())); } //No se ha localizado ninguna aplicación conocida, aun así mostrar la aplicación encontrada else if (!String.IsNullOrWhiteSpace(xnl[0].FirstChild.Value)) { this.foundMetadata.Add(new Application(xnl[0].FirstChild.Value.Trim())); } } xnl = xDoc.GetElementsByTagName("pdf:CreationDate"); if (xnl != null && xnl.Count != 0 && xnl[0].HasChildNodes && !string.IsNullOrEmpty(xnl[0].FirstChild.Value)) { string strValue = xnl[0].FirstChild.Value; DateTime d; if (DateTime.TryParse(strValue.Replace('T', ' ').Replace('Z', ' '), out d)) { //Si existe una fecha de creación anterior, sobreescribir if (!foundMetadata.Dates.CreationDate.HasValue || this.foundMetadata.Dates.CreationDate > d) { this.foundMetadata.Dates.CreationDate = d; } } } xnl = xDoc.GetElementsByTagName("pdf:Title"); if (xnl != null && xnl.Count != 0 && xnl[0].HasChildNodes && !string.IsNullOrEmpty(xnl[0].FirstChild.Value)) { string strValue = xnl[0].FirstChild.Value; if ((string.IsNullOrEmpty(foundMetadata.Title) || this.foundMetadata.Title.Length < strValue.Length)) { this.foundMetadata.Title = strValue; } } xnl = xDoc.GetElementsByTagName("pdf:Author"); if (xnl != null && xnl.Count != 0 && xnl[0].HasChildNodes && !string.IsNullOrEmpty(xnl[0].FirstChild.Value)) { this.foundMetadata.Add(new User(xnl[0].FirstChild.Value, true)); } xnl = xDoc.GetElementsByTagName("pdf:Producer"); if (xnl != null && xnl.Count != 0 && xnl[0].HasChildNodes && !string.IsNullOrEmpty(xnl[0].FirstChild.Value)) { string strValue = ApplicationAnalysis.GetApplicationsFromString(xnl[0].FirstChild.Value); if (!String.IsNullOrWhiteSpace(strValue)) { this.foundMetadata.Add(new Application(strValue.Trim())); } //No se ha localizado ninguna aplicación conocida, aun así mostrar la aplicación encontrada else if (!String.IsNullOrWhiteSpace(xnl[0].FirstChild.Value)) { this.foundMetadata.Add(new Application(xnl[0].FirstChild.Value.Trim())); } } xnl = xDoc.GetElementsByTagName("pdf:ModDate"); if (xnl != null && xnl.Count != 0 && xnl[0].HasChildNodes && !string.IsNullOrEmpty(xnl[0].FirstChild.Value)) { string strValue = xnl[0].FirstChild.Value; DateTime d; if (DateTime.TryParse(strValue.Replace('T', ' ').Replace('Z', ' '), out d)) { this.foundMetadata.Dates.ModificationDate = d; } } xnl = xDoc.GetElementsByTagName("xap:CreateDate"); if (xnl != null && xnl.Count != 0 && xnl[0].HasChildNodes && !string.IsNullOrEmpty(xnl[0].FirstChild.Value)) { string strValue = xnl[0].FirstChild.Value; DateTime d; if (DateTime.TryParse(strValue.Replace('T', ' ').Replace('Z', ' '), out d)) { //Si existe una fecha de creación anterior, sobreescribir if (!foundMetadata.Dates.CreationDate.HasValue || this.foundMetadata.Dates.CreationDate > d) { //Si existe una fecha de modificación posterior, sobreescribir if (!foundMetadata.Dates.ModificationDate.HasValue || this.foundMetadata.Dates.ModificationDate < d) { this.foundMetadata.Dates.CreationDate = d; } } } } xnl = xDoc.GetElementsByTagName("xap:Title"); if (xnl != null && xnl.Count != 0 && xnl[0].HasChildNodes) { XmlNode xn = xnl[0].FirstChild; //Busca el primer subnodo con valor while (xn.Value == null && xn.HasChildNodes) { xn = xn.FirstChild; } if (!string.IsNullOrEmpty(xn.Value)) { string strValue = xn.Value; //Si ya existe un título y es mas pequeño, sobreescribirle. if (String.IsNullOrWhiteSpace(foundMetadata.Title) || this.foundMetadata.Title.Length < strValue.Length) { this.foundMetadata.Title = strValue; } } } xnl = xDoc.GetElementsByTagName("xap:Author"); if (xnl != null && xnl.Count != 0 && xnl[0].HasChildNodes && !string.IsNullOrEmpty(xnl[0].FirstChild.Value)) { this.foundMetadata.Add(new User(xnl[0].FirstChild.Value, true)); } xnl = xDoc.GetElementsByTagName("xap:ModifyDate"); if (xnl != null && xnl.Count != 0 && xnl[0].HasChildNodes && !string.IsNullOrEmpty(xnl[0].FirstChild.Value)) { string strValue = xnl[0].FirstChild.Value; DateTime d; if (DateTime.TryParse(strValue.Replace('T', ' ').Replace('Z', ' '), out d)) { //Si existe una fecha de modificación posterior, sobreescribir if (!foundMetadata.Dates.ModificationDate.HasValue || this.foundMetadata.Dates.ModificationDate < d) { this.foundMetadata.Dates.ModificationDate = d; } } } xnl = xDoc.GetElementsByTagName("xap:CreatorTool"); if (xnl != null && xnl.Count != 0 && xnl[0].HasChildNodes && !string.IsNullOrEmpty(xnl[0].FirstChild.Value)) { string strValue = Analysis.ApplicationAnalysis.GetApplicationsFromString(xnl[0].FirstChild.Value); if (!String.IsNullOrWhiteSpace(strValue)) { this.foundMetadata.Add(new Application(strValue.Trim())); } //No se ha localizado ninguna aplicación conocida, aun así mostrar la aplicación encontrada else if (!String.IsNullOrWhiteSpace(xnl[0].FirstChild.Value)) { this.foundMetadata.Add(new Application(Functions.ToPlainText(xnl[0].FirstChild.Value.Trim()))); } } xnl = xDoc.GetElementsByTagName("dc:creator"); if (xnl != null && xnl.Count != 0 && xnl[0].HasChildNodes) { XmlNode xn = xnl[0].FirstChild; //Busca el primer subnodo con valor while (xn.Value == null && xn.HasChildNodes) { xn = xn.FirstChild; } if (!string.IsNullOrEmpty(xn.Value)) { string strValue = xn.Value; this.foundMetadata.Add(new User(Functions.ToPlainText(strValue), true)); } } //xap:MetadataDate, fecha en la que se añadieron los metadatos xnl = xDoc.GetElementsByTagName("dc:title"); if (xnl != null && xnl.Count != 0 && xnl[0].HasChildNodes) { XmlNode xn = xnl[0].FirstChild; //Busca el primer subnodo con valor while (xn.Value == null && xn.HasChildNodes) { xn = xn.FirstChild; } if (!string.IsNullOrEmpty(xn.Value)) { string strValue = xn.Value; //Si ya existe un título y es mas pequeño, sobreescribirle. if ((string.IsNullOrEmpty(foundMetadata.Title) || this.foundMetadata.Title.Length < strValue.Length)) { this.foundMetadata.Title = strValue; } } } xnl = xDoc.GetElementsByTagName("stRef:lastURL"); if (xnl != null && xnl.Count != 0 && xnl[0].HasChildNodes && !string.IsNullOrEmpty(xnl[0].FirstChild.Value)) { this.foundMetadata.Add(new Diagrams.Path(PathAnalysis.CleanPath(xnl[0].FirstChild.Value), true)); } #endregion }