Ejemplo n.º 1
0
    /// <summary>
    /// 
    /// </summary>
    /// <returns></returns>
    public static List< XmlDocsInformations > LoadFilesPath( )
    {
      List< XmlDocsInformations >    files = new List<XmlDocsInformations>( );
      string []                      filesTarget = System.IO.Directory.GetFiles( Path.Combine( Environment.CurrentDirectory, "008622415_14_Sittel") );
      string                         fileTarget  = string.Empty;
      XmlDocsInformations            xmlDocInfo;

      foreach ( string fileSource in System.IO.Directory.GetFiles( Path.Combine( Environment.CurrentDirectory, "000699816_1_Sittel" ) ) )
      {
        xmlDocInfo = new XmlDocsInformations();

        fileTarget = filesTarget.FirstOrDefault( x => x.GetUniqueName( '_' ).Equals( fileSource.GetUniqueName( '_' ) ) );

        if ( fileTarget == null ) continue;

        xmlDocInfo.FileNameSource  = fileSource.GetUniqueName( '_' );
        xmlDocInfo.FileNameTarget = fileTarget.GetUniqueName( '_' );
        xmlDocInfo.FullPathSource = fileSource;
        xmlDocInfo.FullPathTarget = fileTarget;
        xmlDocInfo.StreamSource = GetStream( fileSource );
        xmlDocInfo.StreamTarget = GetStream( fileTarget );
        xmlDocInfo.MergedFileName = fileSource.GetUniqueName( '_' );

        files.Add( xmlDocInfo );
      }

      return files;
    }
Ejemplo n.º 2
0
    /// <summary>
    /// 
    /// </summary>
    /// <param name="docSource"></param>
    /// <param name="docTarget"></param>
    /// <returns></returns>
    private void MergeXmlDocs( XmlDocsInformations docInfo )
    {
      XDocument docSource           = XDocument.Load( docInfo.StreamSource );
      XDocument docTarget           = XDocument.Load( docInfo.StreamTarget );

      foreach ( XElement nodeSource in docSource.Root.Nodes() )
      {
        docTarget.Root.FirstNode.AddAfterSelf( nodeSource );
      }

      DeleteMergedDoc ( Path.Combine( Environment.CurrentDirectory, "MergedDoc", docInfo.MergedFileName ) );

      Console.WriteLine ( "Generating the merged file {0} ...", docInfo.MergedFileName );

      docTarget.Save  ( Path.Combine( Environment.CurrentDirectory, "MergedDoc", docInfo.MergedFileName ) );
    }