示例#1
0
        public override async Task <ActionResponse> ExecuteActionAsync(ActionRequest request)
        {
            RestClient rc = ScribeUtility.Initialize(request.DataStore.GetValue("ScribeUsername"), request.DataStore.GetValue("ScribePassword"));

            List <ScribeOrganization> orgs           = JsonConvert.DeserializeObject <List <ScribeOrganization> >(await rc.Get(URL_ORGANIZATIONS));
            List <ScribeOrganization> configuredOrgs = new List <ScribeOrganization>();

            if (orgs != null && orgs.Count > 0)
            {
                foreach (ScribeOrganization org in orgs)
                {
                    await SafeList(rc, org);

                    if (await IsConfigured(rc, org))
                    {
                        await ProvisionCloudAgent(rc, org);

                        configuredOrgs.Add(org);
                    }
                }
            }

            return(configuredOrgs.Count == 0
                ? new ActionResponse(ActionStatus.Failure, JsonUtility.GetEmptyJObject(), null, "Scribe_No_Organizations")
                : new ActionResponse(ActionStatus.Success, JsonUtility.GetJObjectFromStringValue(JsonConvert.SerializeObject(configuredOrgs))));
        }
        public override async Task <ActionResponse> ExecuteActionAsync(ActionRequest request)
        {
            RestClient rc = ScribeUtility.Initialize(request.DataStore.GetValue("ScribeUsername"), request.DataStore.GetValue("ScribePassword"));

            string orgId = request.DataStore.GetLastValue("ScribeOrganizationId");

            List <ScribeSolution> solutions = await GetSolutions(rc, orgId);

            if (solutions != null)
            {
                foreach (ScribeSolution solution in solutions)
                {
                    if (solution.Name.Contains(ScribeUtility.BPST_SOLUTION_NAME))
                    {
                        await DeleteSolution(rc, orgId, solution.Id);
                    }
                }
            }

            List <ScribeConnection> connections = await GetConnections(rc, orgId);

            if (connections != null)
            {
                foreach (ScribeConnection connection in connections)
                {
                    if (connection.Name.Contains(ScribeUtility.BPST_SOURCE_NAME) || connection.Name.Contains(ScribeUtility.BPST_TARGET_NAME))
                    {
                        await DeleteConnection(rc, orgId, connection.Id);
                    }
                }
            }

            return(new ActionResponse(ActionStatus.Success, JsonUtility.GetEmptyJObject()));
        }
示例#3
0
        public override async Task <ActionResponse> ExecuteActionAsync(ActionRequest request)
        {
            RestClient rc = ScribeUtility.Initialize(request.DataStore.GetValue("ScribeUsername"), request.DataStore.GetValue("ScribePassword"));

            string orgId = request.DataStore.GetValue("ScribeOrganizationId");

            ScribeSolution solution = new ScribeSolution
            {
                Name                  = ScribeUtility.BPST_SOLUTION_NAME,
                Description           = string.Empty,
                SolutionType          = "Replication",
                ReplicationSettings   = new ScribeReplicationSettings(request.DataStore.GetValue("Entities").Split(new[] { ',', ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries)),
                ConnectionIdForSource = await GetConnectionId(rc, orgId, ScribeUtility.BPST_SOURCE_NAME),
                ConnectionIdForTarget = await GetConnectionId(rc, orgId, ScribeUtility.BPST_TARGET_NAME),
                AgentId               = await GetAgentId(rc, orgId, request.DataStore.GetValue("ScribeAgentName"))
            };

            string response = await rc.Post(string.Format(CultureInfo.InvariantCulture, URL_SOLUTIONS, orgId), JsonConvert.SerializeObject(solution));

            ScribeSolution result = JsonConvert.DeserializeObject <ScribeSolution>(response);

            ScribeSolutionSchedule schedule = new ScribeSolutionSchedule("Daily");
            await rc.Put(string.Format(CultureInfo.InvariantCulture, URL_SOLUTION_SCHEDULE, orgId, result.Id), JsonConvert.SerializeObject(schedule));

            return(new ActionResponse(ActionStatus.Success, JsonUtility.GetEmptyJObject()));
        }
        public override async Task <ActionResponse> ExecuteActionAsync(ActionRequest request)
        {
            RestClient rc = ScribeUtility.Initialize(request.DataStore.GetValue("ScribeUsername"), request.DataStore.GetValue("ScribePassword"));

            string orgId = request.DataStore.GetValue("ScribeOrganizationId");

            Thread.Sleep(SOLUTION_STATUS_WAIT);

            string response = await rc.Get(string.Format(CultureInfo.InvariantCulture, URL_SOLUTION, orgId, await GetSolutionId(rc, orgId, ScribeUtility.BPST_SOLUTION_NAME)));

            var result = JsonConvert.DeserializeObject <ScribeSolution>(response);

            string status = result.status ?? string.Empty;

            if (status.Equals("IdleLastRunFailed", StringComparison.OrdinalIgnoreCase) || status.Equals("OnDemandLastRunFailed", StringComparison.OrdinalIgnoreCase))
            {
                return(new ActionResponse(ActionStatus.Failure, JsonUtility.GetEmptyJObject()));
            }
            else if (status.Equals("Idle", StringComparison.OrdinalIgnoreCase) || status.Equals("OnDemand", StringComparison.OrdinalIgnoreCase))
            {
                return(new ActionResponse(ActionStatus.Success, JsonUtility.GetEmptyJObject()));
            }
            else
            {
                return(new ActionResponse(ActionStatus.BatchNoState, JsonUtility.GetEmptyJObject()));
            }
        }
        public override async Task <ActionResponse> ExecuteActionAsync(ActionRequest request)
        {
            RestClient rc       = ScribeUtility.Initialize(request.DataStore.GetValue("ScribeUsername"), request.DataStore.GetValue("ScribePassword"));
            string     response = await rc.Post(string.Format(CultureInfo.InvariantCulture, URL_PROVISION_ONPREMISE_AGENT, request.DataStore.GetValue("ScribeOrganizationId")), string.Empty);

            return(new ActionResponse(ActionStatus.Success, JsonUtility.GetJObjectFromStringValue(JsonConvert.SerializeObject(response))));
        }
        public override async Task <ActionResponse> ExecuteActionAsync(ActionRequest request)
        {
            RestClient rc = ScribeUtility.Initialize(request.DataStore.GetValue("ScribeUsername"), request.DataStore.GetValue("ScribePassword"));

            string orgId = request.DataStore.GetValue("ScribeOrganizationId");

            List <string> entities = JsonUtility.DeserializeEntities(request.DataStore.GetValue("Entities"), request.DataStore.GetValue("AdditionalObjects"));

            ScribeSolution solution = new ScribeSolution
            {
                Name                  = ScribeUtility.BPST_SOLUTION_NAME,
                Description           = string.Empty,
                SolutionType          = "Replication",
                ReplicationSettings   = new ScribeReplicationSettings(entities.ToArray()),
                ConnectionIdForSource = await GetConnectionId(rc, orgId, ScribeUtility.BPST_SOURCE_NAME),
                ConnectionIdForTarget = await GetConnectionId(rc, orgId, ScribeUtility.BPST_TARGET_NAME),
                AgentId               = await GetAgentId(rc, orgId, request.DataStore.GetValue("ScribeAgentName"))
            };

            ScribeSolution result = JsonUtility.Deserialize <ScribeSolution>(await rc.Post(string.Format(ScribeUtility.URL_SOLUTIONS, orgId), JsonUtility.Serialize(solution)));

            ScribeSolutionSchedule schedule = new ScribeSolutionSchedule(request.DataStore.GetValue("RefreshSchedule"));
            await rc.Put(string.Format(ScribeUtility.URL_SOLUTION_SCHEDULE, orgId, result.Id), JsonUtility.Serialize(schedule));

            return(new ActionResponse(ActionStatus.Success));
        }
        public override async Task <ActionResponse> ExecuteActionAsync(ActionRequest request)
        {
            RestClient rc = ScribeUtility.Initialize(request.DataStore.GetValue("ScribeUsername"), request.DataStore.GetValue("ScribePassword"));

            string orgId = request.DataStore.GetValue("ScribeOrganizationId");

            Thread.Sleep(SOLUTION_STATUS_WAIT);

            string solutionId = await ScribeUtility.GetSolutionId(rc, orgId, ScribeUtility.BPST_SOLUTION_NAME);

            ScribeSolution solution = JsonUtility.Deserialize <ScribeSolution>(await rc.Get(string.Format(ScribeUtility.URL_SOLUTION, orgId, solutionId)));

            string status = solution.status ?? string.Empty;

            if (status.EqualsIgnoreCase(SOLUTION_STATUS_IDLE_LAST_RUN_FAILED) || status.EqualsIgnoreCase(SOLUTION_STATUS_ON_DEMAND_LAST_RUN_FAILED))
            {
                return(new ActionResponse(ActionStatus.Failure, new ActionResponseExceptionDetail(string.Empty, await GetHistory(rc, orgId, solutionId))));
            }
            else if (status.EqualsIgnoreCase(SOLUTION_STATUS_IDLE) || status.EqualsIgnoreCase(SOLUTION_STATUS_ON_DEMAND))
            {
                return(new ActionResponse(ActionStatus.Success));
            }
            else
            {
                return(new ActionResponse(ActionStatus.InProgress));
            }
        }
        public override async Task <ActionResponse> ExecuteActionAsync(ActionRequest request)
        {
            RestClient rc = ScribeUtility.Initialize(request.DataStore.GetValue("ScribeUsername"), request.DataStore.GetValue("ScribePassword"));

            List <ScribeOrganization> orgs           = JsonUtility.Deserialize <List <ScribeOrganization> >(await rc.Get(ScribeUtility.URL_ORGANIZATIONS));
            List <ScribeOrganization> configuredOrgs = new List <ScribeOrganization>();

            if (!orgs.IsNullOrEmpty())
            {
                foreach (ScribeOrganization org in orgs)
                {
                    await SafeList(rc, org);

                    if (await IsConfigured(rc, org))
                    {
                        await ProvisionCloudAgent(rc, org);

                        configuredOrgs.Add(org);
                    }
                }
            }

            return(configuredOrgs.Count == 0
                ? new ActionResponse(ActionStatus.Failure, new ActionResponseExceptionDetail("Scribe_No_Organizations"))
                : new ActionResponse(ActionStatus.Success, JsonUtility.Serialize(configuredOrgs)));
        }
示例#9
0
        public override async Task <ActionResponse> ExecuteActionAsync(ActionRequest request)
        {
            RestClient rc = ScribeUtility.Initialize(request.DataStore.GetValue("ScribeUsername"), request.DataStore.GetValue("ScribePassword"));

            string apiToken = request.DataStore.GetValue("ScribeApiToken");
            string orgId    = request.DataStore.GetValue("ScribeOrganizationId");

            await ScribeUtility.InstallConnector(rc, orgId, CONNECTOR_ID);

            ScribeConnection connection = new ScribeConnection
            {
                ConnectorId = CONNECTOR_ID,
                Color       = "#FFEA69A6",
                Name        = ScribeUtility.BPST_SOURCE_NAME,
                Properties  = new List <ScribeKeyValue>()
            };

            string username = request.DataStore.GetValue("D365Username");

            // Set authentication
            ScribeKeyValue kvp = new ScribeKeyValue {
                Key = "DeploymentType", Value = ScribeUtility.AesEncrypt(apiToken, "Online")
            };                                                                                                                        // OnPremise

            connection.Properties.Add(kvp);
            kvp = new ScribeKeyValue {
                Key = "Url", Value = ScribeUtility.AesEncrypt(apiToken, request.DataStore.GetValue("ConnectorUrl"))
            };
            connection.Properties.Add(kvp);
            // Set CRM user name
            kvp = new ScribeKeyValue {
                Key = "UserId", Value = ScribeUtility.AesEncrypt(apiToken, username.Split('\\').Last())
            };
            connection.Properties.Add(kvp);
            kvp = new ScribeKeyValue {
                Key = "Domain", Value = ScribeUtility.AesEncrypt(apiToken, username.Split('\\').First())
            };
            connection.Properties.Add(kvp);
            // Set CRM user password
            kvp = new ScribeKeyValue {
                Key = "Password", Value = ScribeUtility.AesEncrypt(apiToken, request.DataStore.GetValue("D365Password"))
            };
            connection.Properties.Add(kvp);
            // Set CRM pick list
            kvp = new ScribeKeyValue {
                Key = "DisplayPickListNames", Value = ScribeUtility.AesEncrypt(apiToken, "true")
            };
            connection.Properties.Add(kvp);
            // Set organization name
            kvp = new ScribeKeyValue {
                Key = "Organization", Value = ScribeUtility.AesEncrypt(apiToken, request.DataStore.GetValue("OrganizationName"))
            };
            connection.Properties.Add(kvp);

            await rc.Post(string.Format(CultureInfo.InvariantCulture, URL_CONNECTIONS, orgId), JsonConvert.SerializeObject(connection, Formatting.Indented));

            return(new ActionResponse(ActionStatus.Success, JsonUtility.GetEmptyJObject()));
        }
        public override async Task <ActionResponse> ExecuteActionAsync(ActionRequest request)
        {
            RestClient rc = ScribeUtility.Initialize(request.DataStore.GetValue("ScribeUsername"), request.DataStore.GetValue("ScribePassword"));

            string response = await rc.Get(string.Format(CultureInfo.InvariantCulture, URL_AGENTS, request.DataStore.GetValue("ScribeOrganizationId")));

            List <ScribeAgent> agents = JsonConvert.DeserializeObject <List <ScribeAgent> >(response);

            return(new ActionResponse(ActionStatus.Success, JsonUtility.GetJObjectFromStringValue(JsonConvert.SerializeObject(agents))));
        }
        public override async Task <ActionResponse> ExecuteActionAsync(ActionRequest request)
        {
            RestClient rc = ScribeUtility.Initialize(request.DataStore.GetValue("ScribeUsername"), request.DataStore.GetValue("ScribePassword"));

            string apiToken = request.DataStore.GetValue("ScribeApiToken");
            string orgId    = request.DataStore.GetValue("ScribeOrganizationId");

            await ScribeUtility.InstallConnector(rc, orgId, CONNECTOR_ID);

            ScribeConnection connection = new ScribeConnection
            {
                ConnectorId = CONNECTOR_ID,
                Color       = "#FFEA69A6",
                Name        = ScribeUtility.BPST_SOURCE_NAME,
                Properties  = new List <ScribeKeyValue>()
            };

            // Set discovery URL
            ScribeKeyValue kvp = new ScribeKeyValue {
                Key = "Url", Value = ScribeUtility.AesEncrypt(apiToken, $"https://{request.DataStore.GetValue("SalesforceUrl")}/services/Soap/u/33.0")
            };

            connection.Properties.Add(kvp);
            // Set CRM user name
            kvp = new ScribeKeyValue {
                Key = "UserId", Value = ScribeUtility.AesEncrypt(apiToken, request.DataStore.GetValue("SalesforceUser"))
            };
            connection.Properties.Add(kvp);
            // Set CRM user password
            kvp = new ScribeKeyValue {
                Key = "Password", Value = ScribeUtility.AesEncrypt(apiToken, request.DataStore.GetValue("SalesforcePassword"))
            };
            connection.Properties.Add(kvp);
            // Set bulk APIs
            kvp = new ScribeKeyValue {
                Key = "UseBulkApiRS", Value = ScribeUtility.AesEncrypt(apiToken, "true")
            };
            connection.Properties.Add(kvp);
            // Set metadata refresh
            kvp = new ScribeKeyValue {
                Key = "RefeshMetaDataUponReconnect", Value = ScribeUtility.AesEncrypt(apiToken, "true")
            };
            connection.Properties.Add(kvp);
            // Set organization name
            kvp = new ScribeKeyValue {
                Key = "SecurityToken", Value = ScribeUtility.AesEncrypt(apiToken, request.DataStore.GetValue("SalesforceToken"))
            };
            connection.Properties.Add(kvp);

            await rc.Post(string.Format(ScribeUtility.URL_CONNECTIONS, orgId), JsonUtility.Serialize(connection));

            return(new ActionResponse(ActionStatus.Success));
        }
        public override async Task <ActionResponse> ExecuteActionAsync(ActionRequest request)
        {
            RestClient rc = ScribeUtility.Initialize(request.DataStore.GetValue("ScribeUsername"), request.DataStore.GetValue("ScribePassword"));

            string apiToken = request.DataStore.GetValue("ScribeApiToken");
            string orgId    = request.DataStore.GetValue("ScribeOrganizationId");

            await ScribeUtility.InstallConnector(rc, orgId, CONNECTOR_ID);

            ScribeConnection connection = new ScribeConnection
            {
                ConnectorId = CONNECTOR_ID,
                Color       = "#FFEA69A6",
                Name        = ScribeUtility.BPST_TARGET_NAME,
                Properties  = new List <ScribeKeyValue>()
            };

            // Set authentication
            ScribeKeyValue kvp = new ScribeKeyValue
            {
                Key   = "WindowsAuthentication",
                Value = request.DataStore.GetJson("SqlCredentials", "AuthType").EqualsIgnoreCase("Windows") ? ScribeUtility.AesEncrypt(apiToken, "true") : ScribeUtility.AesEncrypt(apiToken, "false")
            };

            connection.Properties.Add(kvp);
            // Set server name
            kvp = new ScribeKeyValue {
                Key = "Server", Value = ScribeUtility.AesEncrypt(apiToken, request.DataStore.GetValue("Server"))
            };
            connection.Properties.Add(kvp);
            // Set database
            kvp = new ScribeKeyValue {
                Key = "Database", Value = ScribeUtility.AesEncrypt(apiToken, request.DataStore.GetValue("Database"))
            };
            connection.Properties.Add(kvp);
            // Set user name
            kvp = new ScribeKeyValue {
                Key = "UserName", Value = ScribeUtility.AesEncrypt(apiToken, request.DataStore.GetValue("Username"))
            };
            connection.Properties.Add(kvp);
            // Set password
            kvp = new ScribeKeyValue {
                Key = "Password", Value = ScribeUtility.AesEncrypt(apiToken, request.DataStore.GetValue("Password"))
            };
            connection.Properties.Add(kvp);

            await rc.Post(string.Format(ScribeUtility.URL_CONNECTIONS, orgId), JsonUtility.Serialize(connection), null);

            return(new ActionResponse(ActionStatus.Success));
        }
示例#13
0
        public override async Task <ActionResponse> ExecuteActionAsync(ActionRequest request)
        {
            Thread.Sleep(SOLUTION_STATUS_WAIT);

            RestClient rc = ScribeUtility.Initialize(request.DataStore.GetValue("ScribeUsername"), request.DataStore.GetValue("ScribePassword"));

            string orgId = request.DataStore.GetValue("ScribeOrganizationId");

            string solutionId = await GetSolutionId(rc, orgId, ScribeUtility.BPST_SOLUTION_NAME);

            for (int i = 0; i < SOLUTION_STATUS_ATTEMPTS && !(await IsSolutionReady(rc, orgId, solutionId)); i++)
            {
                Thread.Sleep(SOLUTION_STATUS_WAIT);
            }

            await rc.Post(string.Format(CultureInfo.InvariantCulture, URL_SOLUTION_PROCESS, orgId, solutionId), string.Empty);

            return(new ActionResponse(ActionStatus.Success, JsonUtility.GetEmptyJObject()));
        }
        public override async Task <ActionResponse> ExecuteActionAsync(ActionRequest request)
        {
            RestClient rc = ScribeUtility.Initialize(request.DataStore.GetValue("ScribeUsername"), request.DataStore.GetValue("ScribePassword"));

            return(new ActionResponse(ActionStatus.Success, await rc.Get(string.Format(ScribeUtility.URL_AGENTS, request.DataStore.GetValue("ScribeOrganizationId")))));
        }