protected override void Execute(NativeActivityContext context)
        {
            string serviceAccountEmail = ServiceAccountEmail.Get(context);
            string keyPath             = KeyPath.Get(context);
            string password            = Password.Get(context);

            var certificate = new X509Certificate2(@keyPath, password, X509KeyStorageFlags.Exportable);

            ServiceAccountCredential credential = new ServiceAccountCredential(
                new ServiceAccountCredential.Initializer(serviceAccountEmail)
            {
                Scopes = new[] { SheetsService.Scope.Spreadsheets }
            }.FromCertificate(certificate));

            // Create the service.
            var sheetService = new SheetsService(new BaseClientService.Initializer()
            {
                HttpClientInitializer = credential,
                ApplicationName       = "UiPath Robot",
            });

            var googleSheetProperty = new GoogleSheetProperty()
            {
                SheetsService = sheetService,
                SpreadsheetId = SpreadsheetId.Get(context)
            };

            if (Body != null)
            {
                context.ScheduleAction <GoogleSheetProperty>(Body, googleSheetProperty, OnCompleted, OnFaulted);
            }
        }
Example #2
0
        protected override void Execute(CodeActivityContext context)
        {
            string hive = null;

            switch (Hive.Get(context))
            {
            case Microsoft.Win32.RegistryHive.ClassesRoot:
                hive = "HKEY_CLASSES_ROOT";
                break;

            case Microsoft.Win32.RegistryHive.CurrentConfig:
                hive = "HKEY_CURRENT_CONFIG";
                break;

            case Microsoft.Win32.RegistryHive.CurrentUser:
                hive = "HKEY_CURRENT_USER";
                break;

            case Microsoft.Win32.RegistryHive.DynData:
                hive = "HKEY_DYN_DATA";
                break;

            case Microsoft.Win32.RegistryHive.LocalMachine:
                hive = "HKEY_LOCAL_MACHINE";
                break;

            case Microsoft.Win32.RegistryHive.PerformanceData:
                hive = "HKEY_PERFORMANCE_DATA";
                break;

            case Microsoft.Win32.RegistryHive.Users:
                hive = "HKEY_USERS";
                break;
            }

            string keyName = string.Format("{0}\\{1}", hive, KeyPath.Get(context).TrimEnd('\\'));

            object returnValue = Microsoft.Win32.Registry.GetValue(keyName, ValueName.Get(context), DefaultValue.Get(context));

            OutputValue.Set(context, returnValue);
        }
Example #3
0
        protected override void Execute(NativeActivityContext context)
        {
            string spreadsheetId = SpreadsheetId.Get(context);
            GoogleSheetProperty googleSheetProperty;

            switch (AuthenticationType)
            {
            case GoogleAuthenticationType.ApiKey:
                string apiKey = ApiKey.Get(context);
                googleSheetProperty = GoogleSheetProperty.Create(apiKey, spreadsheetId);
                break;

            case GoogleAuthenticationType.OAuth2User:
                string credentialID     = CredentialID.Get(context);
                string credentialSecret = CredentialSecret.Get(context);
                googleSheetProperty = Task.Run(async() =>
                {
                    return(await GoogleSheetProperty.Create(credentialID, credentialSecret, spreadsheetId));
                }).Result;
                break;

            case GoogleAuthenticationType.OAuth2ServiceAccount:
                string serviceAccountEmail = ServiceAccountEmail.Get(context);
                string keyPath             = KeyPath.Get(context);
                string password            = Password.Get(context);
                googleSheetProperty = GoogleSheetProperty.Create(keyPath, password, serviceAccountEmail, spreadsheetId);
                break;

            default:
                googleSheetProperty = GoogleSheetProperty.Create("wrongkey", spreadsheetId);
                break;
            }

            if (Body != null)
            {
                context.ScheduleAction <GoogleSheetProperty>(Body, googleSheetProperty, OnCompleted, OnFaulted);
            }
        }