Esempio n. 1
0
        private async static Task <bool> Translate2Stl(string urn, string guid, JobObjOutputPayloadAdvanced.UnitEnum unit = JobObjOutputPayloadAdvanced.UnitEnum.Meter, JobPayloadDestination.RegionEnum targetRegion = JobPayloadDestination.RegionEnum.US)
        {
            try {
                Console.WriteLine("**** Requesting STL translation for: " + urn);
                JobPayloadInput  jobInput  = new JobPayloadInput(urn);
                JobPayloadOutput jobOutput = new JobPayloadOutput(
                    new List <JobPayloadItem> (
                        new JobPayloadItem [] {
                    new JobPayloadItem(
                        JobPayloadItem.TypeEnum.Stl,
                        null,
                        new JobStlOutputPayloadAdvanced(JobStlOutputPayloadAdvanced.FormatEnum.Ascii, true, JobStlOutputPayloadAdvanced.ExportFileStructureEnum.Single)
                        )
                }
                        ),
                    new JobPayloadDestination(targetRegion)
                    );
                JobPayload            job      = new JobPayload(jobInput, jobOutput);
                bool                  bForce   = true;
                ApiResponse <dynamic> response = await DerivativesAPI.TranslateAsyncWithHttpInfo(job, bForce);

                httpErrorHandler(response, "Failed to register file for STL translation");
                return(true);
            } catch (Exception) {
                Console.WriteLine("**** Failed to register file for STL translation");
                return(false);
            }
        }
Esempio n. 2
0
        private async static Task <bool> Translate2Obj(string urn, string guid, JobObjOutputPayloadAdvanced.UnitEnum unit = JobObjOutputPayloadAdvanced.UnitEnum.Meter, JobPayloadDestination.RegionEnum targetRegion = JobPayloadDestination.RegionEnum.US)
        {
            try {
                Console.WriteLine("**** Requesting OBJ translation for: " + urn);
                JobPayloadInput  jobInput  = new JobPayloadInput(urn);
                JobPayloadOutput jobOutput = new JobPayloadOutput(
                    new List <JobPayloadItem> (
                        new JobPayloadItem [] {
                    new JobPayloadItem(
                        JobPayloadItem.TypeEnum.Obj,
                        null,
                        //new JobObjOutputPayloadAdvanced (null, guid, new List<int> () { -1 }, unit) // all
                        new JobObjOutputPayloadAdvanced(null, guid, new List <int> ()
                    {
                        1526, 1527
                    }, unit)
                        )
                }
                        ),
                    new JobPayloadDestination(targetRegion)
                    );
                JobPayload            job      = new JobPayload(jobInput, jobOutput);
                bool                  bForce   = true;
                ApiResponse <dynamic> response = await DerivativesAPI.TranslateAsyncWithHttpInfo(job, bForce);

                httpErrorHandler(response, "Failed to register file for OBJ translation");
                return(true);
            } catch (Exception) {
                Console.WriteLine("**** Failed to register file for OBJ translation");
                return(false);
            }
        }
Esempio n. 3
0
        /**
         * Example of how to send a translate to SVF job request.
         * Uses the oauth2TwoLegged and twoLeggedCredentials objects that you retrieved previously.
         * @param urn - the urn of the file to translate
         */
        private static dynamic translateToSVF(string urn)
        {
            Console.WriteLine("***** Sending Derivative API translate request");
            JobPayloadInput jobInput = new JobPayloadInput(
                System.Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(urn))
                );
            JobPayloadOutput jobOutput = new JobPayloadOutput(
                new List <JobPayloadItem> (
                    new JobPayloadItem [] {
                new JobPayloadItem(
                    JobPayloadItem.TypeEnum.Svf,
                    new List <JobPayloadItem.ViewsEnum> (
                        new JobPayloadItem.ViewsEnum [] { JobPayloadItem.ViewsEnum._3d }
                        ),
                    null
                    )
            }
                    )
                );
            JobPayload job      = new JobPayload(jobInput, jobOutput);
            dynamic    response = derivativesApi.Translate(job, true);

            Console.WriteLine("***** Response for Translating File to SVF: " + response.ToString());
            return(response);
        }
Esempio n. 4
0
        private async static Task <bool> Translate2Svf2(string urn, JobPayloadDestination.RegionEnum targetRegion = JobPayloadDestination.RegionEnum.US)
        {
            try {
                Console.WriteLine("**** Requesting SVF2 translation for: " + urn);
                JobPayloadInput  jobInput  = new JobPayloadInput(urn);
                JobPayloadOutput jobOutput = new JobPayloadOutput(
                    new List <JobPayloadItem> (
                        new JobPayloadItem [] {
                    new JobPayloadItem(
                        JobPayloadItem.TypeEnum.Svf2,
                        new List <JobPayloadItem.ViewsEnum> (
                            new JobPayloadItem.ViewsEnum [] {
                        JobPayloadItem.ViewsEnum._2d, JobPayloadItem.ViewsEnum._3d
                    }
                            ),
                        null
                        )
                }
                        ),
                    new JobPayloadDestination(targetRegion)
                    );
                JobPayload            job      = new JobPayload(jobInput, jobOutput);
                bool                  bForce   = true;
                ApiResponse <dynamic> response = await DerivativesAPI.TranslateAsyncWithHttpInfo(job, bForce);

                httpErrorHandler(response, "Failed to register file for SVF2 translation");
                return(true);
            } catch (Exception) {
                Console.WriteLine("**** Failed to register file for SVF2 translation");
                return(false);
            }
        }
Esempio n. 5
0
        private async Task <bool> TranslateObject(ObservableCollection <ForgeObjectInfo> items, ForgeObjectInfo item)
        {
            try {
                string          urn      = URN((string)BucketsInRegion.SelectedItem, item, false);
                JobPayloadInput jobInput = new JobPayloadInput(
                    urn,
                    System.IO.Path.GetExtension(item.Name).ToLower() == ".zip",
                    item.Name
                    );
                JobPayloadOutput jobOutput = new JobPayloadOutput(
                    new List <JobPayloadItem> (
                        new JobPayloadItem [] {
                    new JobPayloadItem(
                        JobPayloadItem.TypeEnum.Svf,
                        new List <JobPayloadItem.ViewsEnum> (
                            new JobPayloadItem.ViewsEnum [] {
                        JobPayloadItem.ViewsEnum._2d, JobPayloadItem.ViewsEnum._3d
                    }
                            ),
                        null
                        )
                }
                        )
                    );
                JobPayload     job    = new JobPayload(jobInput, jobOutput);
                bool           bForce = true;
                DerivativesApi md     = new DerivativesApi();
                md.Configuration.AccessToken = accessToken;
                ApiResponse <dynamic> response = await md.TranslateAsyncWithHttpInfo(job, bForce);

                httpErrorHandler(response, "Failed to register file for translation");
                item.TranslationRequested = StateEnum.Busy;
                item.Manifest             = response.Data;

                JobProgress jobWnd = new JobProgress(item, accessToken);
                jobWnd._callback = new JobCompletedDelegate(this.TranslationCompleted);
                jobWnd.Owner     = this;
                jobWnd.Show();
            } catch (Exception /*ex*/) {
                item.TranslationRequested = StateEnum.Idle;
                return(false);
            }
            return(true);
        }