示例#1
0
 public Processor()
 {
     try
     {
         settings = new CurrentSettings();
         settings.Load();
     }
     catch (Exception ex)
     {
         ex.Write();
     }
 }
示例#2
0
 public GoogleAccess()
 {
     try
     {
         settings = new CurrentSettings();
         settings.Load();
     }
     catch (Exception ex)
     {
         ex.Write();
     }
 }
示例#3
0
        public DriveService PreviewGetDriveAccessForUser(CurrentSettings _settings, string userEmail)
        {
            //check the file exists
            if (!System.IO.File.Exists(_settings.keyFilePath))
            {
                Console.WriteLine("An Error occurred - Key file does not exist");
                return(null);
            }

            string[] scopes = new string[] { DriveService.Scope.Drive }; //View Drive

            var certificate = new X509Certificate2(_settings.keyFilePath, "notasecret", X509KeyStorageFlags.Exportable);

            try
            {
                ServiceAccountCredential credential = new ServiceAccountCredential(
                    new ServiceAccountCredential.Initializer(_settings.serviceAccount)
                {
                    Scopes = scopes,
                    User   = userEmail
                }.FromCertificate(certificate));

                //Create the service
                DriveService service = new DriveService(new BaseClientService.Initializer()
                {
                    HttpClientInitializer = credential,
                    ApplicationName       = _settings.applicationName
                });

                return(service);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return(null);
            }
        }
示例#4
0
        public bool Load()
        {
            if (System.IO.File.Exists(@"settings.xml") == false)
            {
                return(false);
            }

            bool         retval = false;
            StreamReader sr     = new StreamReader(@"settings.xml");

            try
            {
                XmlSerializer   xs = new XmlSerializer(typeof(CurrentSettings));
                CurrentSettings cs = (CurrentSettings)xs.Deserialize(sr);
                serviceAccount  = cs.serviceAccount;
                keyFilePath     = cs.keyFilePath;
                applicationName = cs.applicationName;
                maxParallel     = cs.maxParallel;
                clearOutput     = cs.clearOutput;
                filter          = cs.filter;

                inputType              = cs.inputType;
                MySQL_input_server     = cs.MySQL_input_server;
                MySQL_input_database   = cs.MySQL_input_database;
                MySQL_input_username   = cs.MySQL_input_username;
                MySQL_input_password   = cs.MySQL_input_password;
                MySQL_input_query      = cs.MySQL_input_query;
                MySQL_input_mail       = cs.MySQL_input_mail;
                MySQL_input_identifier = cs.MySQL_input_identifier;

                SQL_input_server             = cs.SQL_input_server;
                SQL_input_database           = cs.SQL_input_database;
                SQL_input_username           = cs.SQL_input_username;
                SQL_input_password           = cs.MySQL_input_password;
                SQL_input_authenticationType = cs.SQL_input_authenticationType;
                SQL_input_query      = cs.SQL_input_query;
                SQL_input_mail       = cs.SQL_input_mail;
                SQL_input_identifier = cs.SQL_input_identifier;

                MongoDB_input_server     = cs.MongoDB_input_server;
                MongoDB_input_database   = cs.MongoDB_input_database;
                MongoDB_input_username   = cs.MongoDB_input_username;
                MongoDB_input_password   = cs.MongoDB_input_password;
                MongoDB_input_collection = cs.MongoDB_input_collection;
                MongoDB_input_mail       = cs.MongoDB_input_mail;
                MongoDB_input_identifier = cs.MongoDB_input_identifier;

                FlatFile_input_path      = cs.FlatFile_input_path;
                FlatFile_input_mail      = cs.FlatFile_input_mail;
                FlatFile_input_identifer = cs.FlatFile_input_identifer;

                outputType            = cs.outputType;
                MySQL_output_server   = cs.MySQL_output_server;
                MySQL_output_database = cs.MySQL_output_database;
                MySQL_output_username = cs.MySQL_output_username;
                MySQL_output_password = cs.MySQL_output_password;

                SQL_output_server             = cs.SQL_output_server;
                SQL_output_database           = cs.SQL_output_database;
                SQL_output_username           = cs.SQL_output_username;
                SQL_output_password           = cs.SQL_output_password;
                SQL_output_authenticationType = cs.SQL_output_authenticationType;

                MongoDB_output_server   = cs.MongoDB_output_server;
                MongoDB_output_database = cs.MongoDB_output_database;
                MongoDB_output_username = cs.MongoDB_output_username;
                MongoDB_output_password = cs.MongoDB_output_password;

                FlatFile_ouput_path = cs.FlatFile_ouput_path;
            }
            catch (Exception ex)
            {
                ex.Write();
            }
            finally
            {
                sr.Close();
                sr.Dispose();
            }
            return(retval);
        }