コード例 #1
0
ファイル: BasicAnonymizer.cs プロジェクト: Symbyo360/GDCM-New
    public static int Main(string[] args)
    {
        gdcm.Global global = gdcm.Global.GetInstance();
        if (!global.LoadResourcesFiles())
        {
            System.Console.WriteLine("Could not LoadResourcesFiles");
            return(1);
        }

        string file1  = args[0];
        string file2  = args[1];
        Reader reader = new Reader();

        reader.SetFileName(file1);
        bool ret = reader.Read();

        if (!ret)
        {
            return(1);
        }

        string certpath = gdcm.Filename.Join(gdcm.Testing.GetSourceDirectory(), "/Testing/Source/Data/certificate.pem");

        gdcm.CryptoFactory fact             = gdcm.CryptoFactory.GetFactoryInstance();
        gdcm.CryptographicMessageSyntax cms = fact.CreateCMSProvider();
        if (!cms.ParseCertificateFile(certpath))
        {
            return(1);
        }

        //Anonymizer ano = new Anonymizer();
        SmartPtrAno sano = Anonymizer.New();
        Anonymizer  ano  = sano.__ref__();

        //SimpleSubjectWatcher watcher = new SimpleSubjectWatcher(ano, "Anonymizer");
        MyWatcher watcher = new MyWatcher(ano);

        ano.SetFile(reader.GetFile());
        ano.SetCryptographicMessageSyntax(cms);
        if (!ano.BasicApplicationLevelConfidentialityProfile())
        {
            return(1);
        }

        Writer writer = new Writer();

        writer.SetFileName(file2);
        writer.SetFile(ano.GetFile());
        ret = writer.Write();
        if (!ret)
        {
            return(1);
        }

        return(0);
    }
コード例 #2
0
ファイル: BasicAnonymizer.cs プロジェクト: hsorby/gdcm
    public static int Main(string[] args)
    {
        gdcm.Global global = gdcm.Global.GetInstance();
        if( !global.LoadResourcesFiles() )
          {
          System.Console.WriteLine( "Could not LoadResourcesFiles" );
          return 1;
          }

        string file1 = args[0];
        string file2 = args[1];
        Reader reader = new Reader();
        reader.SetFileName( file1 );
        bool ret = reader.Read();
        if( !ret )
          {
          return 1;
          }

        string certpath = gdcm.Filename.Join(gdcm.Testing.GetSourceDirectory(), "/Testing/Source/Data/certificate.pem" );
        gdcm.CryptographicMessageSyntax cms = new gdcm.CryptographicMessageSyntax();
        if( !cms.ParseCertificateFile( certpath ) )
          {
          return 1;
          }

        //Anonymizer ano = new Anonymizer();
        SmartPtrAno sano = Anonymizer.New();
        Anonymizer ano = sano.__ref__();

        //SimpleSubjectWatcher watcher = new SimpleSubjectWatcher(ano, "Anonymizer");
        MyWatcher watcher = new MyWatcher(ano);

        ano.SetFile( reader.GetFile() );
        ano.SetCryptographicMessageSyntax( cms );
        if( !ano.BasicApplicationLevelConfidentialityProfile() )
          {
          return 1;
          }

        Writer writer = new Writer();
        writer.SetFileName( file2 );
        writer.SetFile( ano.GetFile() );
        ret = writer.Write();
        if( !ret )
          {
          return 1;
          }

        return 0;
    }
コード例 #3
0
    public static int Main(string[] args)
    {
        gdcm.FileMetaInformation.SetSourceApplicationEntityTitle("My ClinicalTrial App");

        // http://www.oid-info.com/get/1.3.6.1.4.17434
        string THERALYS_ORG_ROOT = "1.3.6.1.4.17434";

        gdcm.UIDGenerator.SetRoot(THERALYS_ORG_ROOT);
        System.Console.WriteLine("Root dir is now: " + gdcm.UIDGenerator.GetRoot());

        gdcm.Global global = gdcm.Global.GetInstance();
        if (!global.LoadResourcesFiles())
        {
            System.Console.WriteLine("Could not LoadResourcesFiles");
            return(1);
        }

        if (args.Length != 2)
        {
            System.Console.WriteLine("Usage:");
            System.Console.WriteLine("ClinicalTrialIdentificationWorkflow input_dir output_dir");
            return(1);
        }
        string dir1 = args[0];
        string dir2 = args[1];

        // Check input is valid:
        if (!gdcm.PosixEmulation.FileIsDirectory(dir1))
        {
            System.Console.WriteLine("Input directory: " + dir1 + " does not exist. Sorry");
            return(1);
        }
        if (!gdcm.PosixEmulation.FileIsDirectory(dir2))
        {
            System.Console.WriteLine("Output directory: " + dir2 + " does not exist. Sorry");
            return(1);
        }

        // Recursively search all file within this toplevel directory:
        Directory d      = new Directory();
        uint      nfiles = d.Load(dir1, true);

        if (nfiles == 0)
        {
            return(1);
        }

        // Let's use the pre-shipped certificate of GDCM.
        string certpath = gdcm.Filename.Join(gdcm.Testing.GetSourceDirectory(), "/Testing/Source/Data/certificate.pem");

        gdcm.CryptographicMessageSyntax cms = new gdcm.CryptographicMessageSyntax();
        if (!cms.ParseCertificateFile(certpath))
        {
            System.Console.WriteLine("PEM Certificate : " + certpath + " could not be read. Sorry");
            return(1);
        }

        //Anonymizer ano = new Anonymizer();
        // A reference to an actual C++ instance is required here:
        SmartPtrAno sano = Anonymizer.New();
        Anonymizer  ano  = sano.__ref__();

        //SimpleSubjectWatcher watcher = new SimpleSubjectWatcher(ano, "Anonymizer");
        MyWatcher watcher = new MyWatcher(ano);

        // Explicitely specify the Cryptographic Message Syntax to use:
        ano.SetCryptographicMessageSyntax(cms);

        // Process all filenames:
        FilenamesType filenames = d.GetFilenames();

        for (uint i = 0; i < nfiles; ++i)
        {
            string filename    = filenames[(int)i];
            string outfilename = filename.Replace(dir1, dir2);
            System.Console.WriteLine("Filename: " + filename);
            System.Console.WriteLine("Out Filename: " + outfilename);
            if (!ProcessOneFile(ano, filename, outfilename))
            {
                System.Console.WriteLine("Could not process filename: " + filename);
                return(1);
            }
        }

        return(0);
    }
コード例 #4
0
    public static int Main(string[] args)
    {
        gdcm.FileMetaInformation.SetSourceApplicationEntityTitle( "My ClinicalTrial App" );

        // http://www.oid-info.com/get/1.3.6.1.4.17434
        string THERALYS_ORG_ROOT = "1.3.6.1.4.17434";
        gdcm.UIDGenerator.SetRoot( THERALYS_ORG_ROOT );
        System.Console.WriteLine( "Root dir is now: " + gdcm.UIDGenerator.GetRoot() );

        gdcm.Global global = gdcm.Global.GetInstance();
        if( !global.LoadResourcesFiles() )
          {
          System.Console.WriteLine( "Could not LoadResourcesFiles" );
          return 1;
          }

        string dir1 = args[0];
        string dir2 = args[1];

        // Check input is valid:
        if( !gdcm.PosixEmulation.FileIsDirectory(dir1) )
          {
          System.Console.WriteLine( "Input directory: " + dir1 + " does not exist. Sorry" );
          return 1;
          }
        if( !gdcm.PosixEmulation.FileIsDirectory(dir2) )
          {
          System.Console.WriteLine( "Output directory: " + dir2 + " does not exist. Sorry" );
          return 1;
          }

        Directory d = new Directory();
        uint nfiles = d.Load( dir1, true );
        if(nfiles == 0) return 1;

        string certpath = gdcm.Filename.Join(gdcm.Testing.GetSourceDirectory(), "/Testing/Source/Data/certificate.pem" );
        gdcm.CryptographicMessageSyntax cms = new gdcm.CryptographicMessageSyntax();
        if( !cms.ParseCertificateFile( certpath ) )
          {
          return 1;
          }

        //Anonymizer ano = new Anonymizer();
        SmartPtrAno sano = Anonymizer.New();
        Anonymizer ano = sano.__ref__();

        //SimpleSubjectWatcher watcher = new SimpleSubjectWatcher(ano, "Anonymizer");
        MyWatcher watcher = new MyWatcher(ano);

        ano.SetCryptographicMessageSyntax( cms );

        // Process all filenames:
        FilenamesType filenames = d.GetFilenames();
        for( uint i = 0; i < nfiles; ++i )
          {
          string filename = filenames[ (int)i ];
          string outfilename = filename.Replace( dir1, dir2 );
          System.Console.WriteLine( "Filename: " + filename );
          System.Console.WriteLine( "Out Filename: " + outfilename );
          if( !ProcessOneFile( ano , filename, outfilename ) )
        {
        System.Console.WriteLine( "Could not process filename: " + filename );
        return 1;
        }
          }

        return 0;
    }
コード例 #5
0
    public static int Main(string[] args)
    {
        gdcm.FileMetaInformation.SetSourceApplicationEntityTitle( "My ClinicalTrial App" );

        // http://www.oid-info.com/get/1.3.6.1.4.17434
        string THERALYS_ORG_ROOT = "1.3.6.1.4.17434";
        gdcm.UIDGenerator.SetRoot( THERALYS_ORG_ROOT );
        System.Console.WriteLine( "Root dir is now: " + gdcm.UIDGenerator.GetRoot() );

        gdcm.Global global = gdcm.Global.GetInstance();
        if( !global.LoadResourcesFiles() )
          {
          System.Console.WriteLine( "Could not LoadResourcesFiles" );
          return 1;
          }

        if( args.Length != 2 )
          {
          System.Console.WriteLine( "Usage:" );
          System.Console.WriteLine( "ClinicalTrialIdentificationWorkflow input_dir output_dir" );
          return 1;
          }
        string dir1 = args[0];
        string dir2 = args[1];

        // Check input is valid:
        if( !gdcm.PosixEmulation.FileIsDirectory(dir1) )
          {
          System.Console.WriteLine( "Input directory: " + dir1 + " does not exist. Sorry" );
          return 1;
          }
        if( !gdcm.PosixEmulation.FileIsDirectory(dir2) )
          {
          System.Console.WriteLine( "Output directory: " + dir2 + " does not exist. Sorry" );
          return 1;
          }

        // Recursively search all file within this toplevel directory:
        Directory d = new Directory();
        uint nfiles = d.Load( dir1, true );
        if(nfiles == 0) return 1;

        // Let's use the pre-shipped certificate of GDCM.
        string certpath = gdcm.Filename.Join(gdcm.Testing.GetSourceDirectory(), "/Testing/Source/Data/certificate.pem" );
        gdcm.CryptographicMessageSyntax cms = new gdcm.CryptographicMessageSyntax();
        if( !cms.ParseCertificateFile( certpath ) )
          {
          System.Console.WriteLine( "PEM Certificate : " + certpath + " could not be read. Sorry" );
          return 1;
          }

        //Anonymizer ano = new Anonymizer();
        // A reference to an actual C++ instance is required here:
        SmartPtrAno sano = Anonymizer.New();
        Anonymizer ano = sano.__ref__();

        //SimpleSubjectWatcher watcher = new SimpleSubjectWatcher(ano, "Anonymizer");
        MyWatcher watcher = new MyWatcher(ano);

        // Explicitely specify the Cryptographic Message Syntax to use:
        ano.SetCryptographicMessageSyntax( cms );

        // Process all filenames:
        FilenamesType filenames = d.GetFilenames();
        for( uint i = 0; i < nfiles; ++i )
          {
          string filename = filenames[ (int)i ];
          string outfilename = filename.Replace( dir1, dir2 );
          System.Console.WriteLine( "Filename: " + filename );
          System.Console.WriteLine( "Out Filename: " + outfilename );
          if( !ProcessOneFile( ano , filename, outfilename ) )
        {
        System.Console.WriteLine( "Could not process filename: " + filename );
        return 1;
        }
          }

        return 0;
    }