Exemplo n.º 1
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");

            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));
        }