public override Entities.EventResult PerformLogin(string username, string password)
        {
            _connectorSettings = JsonConvert.DeserializeObject <ConnectorSettings>(System.Text.Encoding.UTF8.GetString(System.Convert.FromBase64String(password)));

            if (username == "GET")
            {
                Application.DoEvents();
                _currentState            = State.Login;
                ProcessComplete.Finished = false;
                ProcessComplete.Success  = false;
                Url = @"https://www.netflix.com/Login";
                RemoveEvent();
                Browser.PreviewKeyDown += Browser_PreviewKeyDown;
            }
            else
            {
                if (_connectorSettings.showLoadingSpinner)
                {
                    ShowLoading();
                }
                ProcessComplete.Finished = true;
                ProcessComplete.Success  = true;
                _currentState            = State.ReadyToPlay;
            }
            return(EventResult.Complete());
        }
    public async Task <IHttpActionResult> Register(ConnectorSettings settings)
    {
        var    activityText = $"An instance of the ToDo connector (named {settings.ConfigName}) has been set up. We will send you notification whenever new task is added.";
        string cardJson     =
            "{ \"@type\": \"MessageCard\"," +
            "  \"summary\": \"Welcome Message\"," +
            "  \"sections\": [ " +
            "    { " +
            "      \"activityTitle\": \"Welcome Message\"," +
            "      \"text\": \"" + activityText + "\"" +
            "    }" +
            "  ]" +
            "}";

        //prepare the http POST
        HttpClient client = new HttpClient();

        client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
        var content = new StringContent(cardJson, System.Text.Encoding.UTF8, "application/json");

        using (var response = await client.PostAsync(settings.WebHookUrl, content))
        {
            // Check response.IsSuccessStatusCode and take appropriate action if needed.
            var responseText = await response.Content.ReadAsStringAsync();

            var status = response.StatusCode;
        }

        return(Ok());
    }
Exemplo n.º 3
0
        protected bool InitializeClient(AuthenticationType authType, EventHandler<AuthorizationCodeRequiredEventArgs> codeRequiredHandler, Guid clientId = default(Guid), string clientSecret = null)
        {
            var s = GetSettings();

            if (!s.IsConfigured) return false;

            lock (_lck)
            { 
                if (_aaClient == null || _settings == null || _clientSecret != clientSecret || _clientId != clientId || _settings.LastChanged < s.LastChanged )
                {
                    if (authType == AuthenticationType.Code)
                    {
                        clientId = s.UserAppId;
                        if (clientId == default(Guid))
                            clientId = Parameters.CLIENT_ID;
                    }

                    _aaClient = new AAClient(s.TenantId, s.SubscriptionId, s.ResourceGroupName, s.AutomationAccountName, authType, clientId, clientSecret);

                    if (authType == AuthenticationType.Code)
                        _aaClient.AuthorizationCodeRequired += codeRequiredHandler;

                    _clientSecret = clientSecret;
                    _settings = s;
                    _isInitialized = true;
                }
            }
            return true;
        }
Exemplo n.º 4
0
        public void SQLiteDatabaseConnection()
        {
            var db         = new Database();
            var dbSettings = new ConnectorSettings
            {
                ConnectionMode   = ConnectionMode.Database,
                ConnectionString = "Data Source=:memory:",
                DatabaseType     = DatabaseType.SQLite
            };

            var initSuccess = db.Initialize(dbSettings);

            Assert.True(initSuccess);
        }
Exemplo n.º 5
0
        /// <inheritdoc />
        public override Result <Unit, IError> VerifyThis(SCLSettings settings)
        {
            var r = SettingsHelpers.TryGetNuixSettings(
                ConnectorSettings.CreateFromSCLSettings(settings).Select(x => x.Settings)
                )
                    .Bind(NuixConnectionHelper.TryGetConsoleArguments)
                    .MapError(x => x.WithLocation(this));

            if (r.IsFailure)
            {
                return(r.ConvertFailure <Unit>());
            }

            return(base.VerifyThis(settings));
        }
Exemplo n.º 6
0
        public void TestGettingConnectorSettingsFromString()
        {
            var settings = SCLSettings.CreateFromString(ConnectorJson);

            var connectorSettings = ConnectorSettings.CreateFromSCLSettings(settings).ToList();

            connectorSettings.Should().HaveCount(1);

            var nuixSettings = connectorSettings.Single().Settings;

            nuixSettings.Id.Should().Be("Reductech.EDR.Nuix");
            nuixSettings.Version.Should().Be("0.9.0");
            nuixSettings.Enable.Should().Be(true);

            nuixSettings.Settings.TryGetNestedBool("UseDongle").Should().BeTrue();
        }
Exemplo n.º 7
0
        public void LoadData(ConnectorSettings settings)
        {
            _settings = settings;

            if (_settings.LocalAccount)
            {
                var settingsManager = new ConnectorSettingsManager();
                settingsManager.LoadLocalUserSettings(_settings);
            }

            InitializeStatusColorMapping();

            var mantisConnector =
                new org.mantisbt.www.MantisConnect(settings.RepositoryUri.ToString() + _settings.WebServicePath);

            mantisConnector.mc_filter_getCompleted += (s, e) =>
            {
                var filters    = e.Result;
                var filterData = new org.mantisbt.www.FilterData()
                {
                    name = "[No filter]", id = "-1"
                };
                Array.Reverse(filters);
                Array.Resize(ref filters, filters.Length + 1);
                Array.Reverse(filters);
                filters[0] = filterData;
                tscbFilter.ComboBox.DataSource    = filters;
                tscbFilter.ComboBox.DisplayMember = "name";

                mantisConnector.Dispose();
            };

            lbCurrentAction.Text = "Getting filters...";

            mantisConnector.mc_filter_getAsync(settings.UserName, settings.Password, settings.ProjectId.ToString());
        }
        public ConfigurationPage()
        {
            InitializeComponent();

            Settings = new ConnectorSettings();
        }
Exemplo n.º 9
0
        protected void SaveSettings(ConnectorSettings s)
        {
            var emo = _emg.EntityObjects.GetObject<EnterpriseManagementObject>(ConnectorSettingsClass.Id, ObjectQueryOptions.Default);
            emo.SetProperty(ConnectorSettingsClass, "TenantId", s.TenantId);
            emo.SetProperty(ConnectorSettingsClass, "SubscriptionId", s.SubscriptionId);
            emo.SetProperty(ConnectorSettingsClass, "ResourceGroup", s.ResourceGroupName);
            emo.SetProperty(ConnectorSettingsClass, "AutomationAccountName", s.AutomationAccountName);
            emo.SetProperty(ConnectorSettingsClass, "UserAppId", s.UserAppId);
            emo.SetProperty(ConnectorSettingsClass, "CredentialExpirationDate", s.CredentialExpirationDate);
            emo.SetProperty(ConnectorSettingsClass, "DefaultRunOn", s.DefaultRunOn);

            emo.SetProperty(ConnectorSettingsClass, "LastChanged", DateTime.UtcNow);

            emo.Overwrite();
        }
Exemplo n.º 10
0
        protected ConnectorSettings GetSettings(bool getSecData = false)
        {
            var emo = _emg.EntityObjects.GetObject<EnterpriseManagementObject>(ConnectorSettingsClass.Id, ObjectQueryOptions.Default);
            var s = new ConnectorSettings();
            s.TenantId = emo.GetPropertyOrDefault<Guid>(ConnectorSettingsClass, "TenantId");
            s.SubscriptionId = emo.GetPropertyOrDefault<Guid>(ConnectorSettingsClass, "SubscriptionId");
            s.ResourceGroupName = emo.GetPropertyOrDefault<string>(ConnectorSettingsClass, "ResourceGroup");
            s.AutomationAccountName = emo.GetPropertyOrDefault<string>(ConnectorSettingsClass, "AutomationAccountName");
            s.UserAppId = emo.GetPropertyOrDefault<Guid>(ConnectorSettingsClass, "UserAppId");
            s.LastChanged = emo.GetPropertyOrDefault<DateTime>(ConnectorSettingsClass, "LastChanged");
            s.CredentialExpirationDate = emo.GetPropertyOrDefault<DateTime>(ConnectorSettingsClass, "CredentialExpirationDate");
            s.DefaultRunOn = emo.GetPropertyOrDefault<string>(ConnectorSettingsClass, "DefaultRunOn");

            if (getSecData)
            {
                var secData = (Microsoft.EnterpriseManagement.Security.BasicCredentialSecureData)_emg.Security.GetSecureData(new SecureDataCriteria($"Name = '{Parameters.SECURE_REFERENCE_NAME}'")).FirstOrDefault();
                if (secData != null)
                    s.WorkflowAppId = new Guid(secData.UserName);
            }
            return s;
        }
Exemplo n.º 11
0
        public async Task TestConnector()
        {
            var logger = new TestOutputLogger("Step Logger", TestOutputHelper);

            var absolutePath = PluginLoadContext.GetAbsolutePath(RelativePath);

            var assembly = PluginLoadContext.LoadPlugin(
                absolutePath,
                logger
                );

            assembly.ShouldBeSuccessful();

            var stepTypes = assembly.Value.GetTypes()
                            .Where(x => typeof(IStep).IsAssignableFrom(x))
                            .ToList();

            foreach (var type in stepTypes)
            {
                TestOutputHelper.WriteLine(type.Name);
            }

            var stepFactoryStore = StepFactoryStore.Create(
                new ConnectorData(ConnectorSettings.DefaultForAssembly(assembly.Value), assembly.Value)
                );

            var injectedContextsResult = stepFactoryStore.TryGetInjectedContexts(
                new SCLSettings(
                    Entity.Create(
                        new List <(EntityPropertyKey key, object?value)>()
            {
                (new EntityPropertyKey(new[] { "connectors", "example", "colorSource" }),
                 "Red")
            }
                        )
                    )
                );

            injectedContextsResult.ShouldBeSuccessful();

            var externalContext = ExternalContext.Default with
            {
                InjectedContexts = injectedContextsResult.Value
            };

            var runner = new SCLRunner(
                SCLSettings.EmptySettings,
                logger,
                stepFactoryStore,
                externalContext
                );

            var r = await
                    runner.RunSequenceFromTextAsync(
                "Log (GetTestString)",
                new Dictionary <string, object>(),
                CancellationToken.None
                );

            r.ShouldBeSuccessful();
        }
    }