Exemple #1
0
        private static void Jobs(OAuthAuthenticationStrategy auth)
        {
            var jobApiClient = new JobApiClient(auth, projectId);

            foreach (var job in jobApiClient.Get("ApiSample", new List <string>()
            {
                "AWAITING_AUTHORIZATION", "IN_PROGRESS", "IN_PROGRESS"
            }))
            {
                Console.WriteLine(job.jobName);
            }

            var jobRequest = new CreateJob();

            jobRequest.jobName         = "ApiSample_Job_" + Guid.NewGuid();
            jobRequest.description     = "test";
            jobRequest.dueDate         = DateTime.Now.AddMonths(1).ToString("yyyy-MM-ddTHH:mm:ssZ");
            jobRequest.targetLocaleIds = new List <string>()
            {
                "ru-RU"
            };
            jobRequest.callbackUrl     = "https://www.callback.com/smartling/job";
            jobRequest.callbackMethod  = "GET";
            jobRequest.referenceNumber = "test";

            var createdJob = jobApiClient.Create(jobRequest);

            createdJob = jobApiClient.GetById(createdJob.translationJobUid);

            var jobs      = jobApiClient.Get();
            var processes = jobApiClient.GetProcesses(jobs.First().translationJobUid);

            var updateJob = new UpdateJob();

            updateJob.jobName     = jobRequest.jobName;
            updateJob.description = "test2";
            updateJob.dueDate     = DateTime.Now.AddMonths(1).ToString("yyyy-MM-ddTHH:mm:ssZ");
            var updatedJob = jobApiClient.Update(updateJob, jobs.First().translationJobUid);

            jobs = jobApiClient.Get();
            jobApiClient.AddLocale("nl-NL", jobs.First().translationJobUid);

            var batchApiClient = new BatchApiClient(auth, projectId, String.Empty);
            var batch          =
                batchApiClient.Create(new CreateBatch()
            {
                authorize         = true,
                translationJobUid = jobs.First().translationJobUid
            });

            string filePath = "ApiSample_" + Guid.NewGuid();
            string fileUri  = "/master/" + filePath;

            batchApiClient.UploadFile(new BatchUpload.Builder().CreateUpload(@"C:\Sample.xml", fileUri, "xml", new List <string> {
                "ru-RU"
            }, batch.batchUid).WithNameSpace(filePath));
            batchApiClient.Execute(batch.batchUid);

            var batchResult = batchApiClient.Get(batch.batchUid);
        }
Exemple #2
0
        private static void Jobs(OAuthAuthenticationStrategy auth)
        {
            var jobApiClient = new JobApiClient(auth, projectId);

            foreach (var job in jobApiClient.Get("ApiSample").items)
            {
                Console.WriteLine(job.jobName);
            }

            var jobRequest = new CreateJob();

            jobRequest.jobName         = "ApiSample_Job_" + Guid.NewGuid();
            jobRequest.description     = "test";
            jobRequest.dueDate         = "2018-11-21T11:51:17Z";
            jobRequest.targetLocaleIds = new List <string>()
            {
                "ru-RU"
            };
            jobRequest.callbackUrl     = "https://www.callback.com/smartling/job";
            jobRequest.callbackMethod  = "GET";
            jobRequest.referenceNumber = "test";

            jobApiClient.Create(jobRequest);
            var jobs      = jobApiClient.GetAll();
            var processes = jobApiClient.GetProcesses(jobs.items.First().translationJobUid);

            var updateJob = new UpdateJob();

            updateJob.jobName     = jobRequest.jobName;
            updateJob.description = "test2";
            updateJob.dueDate     = "2018-11-21T11:51:17Z";
            jobApiClient.Update(updateJob, jobs.items.First().translationJobUid);
            jobs = jobApiClient.GetAll();
            jobApiClient.AddLocale("nl-NL", jobs.items.First().translationJobUid);

            var batchApiClient = new BatchApiClient(auth, projectId, String.Empty);
            var batch          =
                batchApiClient.Create(new CreateBatch()
            {
                authorize         = true,
                translationJobUid = jobs.items.First().translationJobUid
            });

            string fileUri = "ApiSample_" + Guid.NewGuid();

            batchApiClient.UploadFile(@"C:\Sample.xml", fileUri, "xml", "ru-RU", true, batch.batchUid);
            batchApiClient.Execute(batch.batchUid);

            var batchResult = batchApiClient.Get(batch.batchUid);
        }