Exemple #1
0
 /// <summary>
 /// Constructor.
 /// </summary>
 public Publisher(DesignAutomationClient client, ILogger <Publisher> logger, ResourceProvider resourceProvider, IPostProcessing postProcessing)
 {
     _client           = client;
     _logger           = logger;
     _resourceProvider = resourceProvider;
     _postProcessing   = postProcessing;
 }
Exemple #2
0
 public DesignAutoService(DesignAutomationClient daClient, IWebHostEnvironment env, IConfiguration config)
 {
     this.designAutoClient   = daClient;
     this.localBundlesFolder = Path.Combine(env.WebRootPath, "DesignAuto");
     this.clientId           = config["Forge:ClientId"];
     this.forgeEnv           = config["Forge:Environment"];
 }
        // Constructor, where env and hubContext are specified
        public DesignAutomationController(IWebHostEnvironment env, IHubContext <DesignAutomationHub> hubContext, DesignAutomationClient api)
        {
            DesignAutomationClientBuilder da = new DesignAutomationClientBuilder(OAuthController.FORGE_CLIENT_ID, OAuthController.FORGE_CLIENT_SECRET);

            _designAutomation = da.Client;
            _env        = env;
            _hubContext = hubContext;
        }
 // Constructor, where env and hubContext are specified
 public DesignAutomationController(IWebHostEnvironment env,
                                   IHubContext <DesignAutomationHub> hubContext,
                                   DesignAutomationClient api,
                                   GoodPracticesService gpService
                                   )
 {
     _designAutomation = api;
     _env        = env;
     _hubContext = hubContext;
     _gpService  = gpService;
 }
Exemple #5
0
        // Constructor, where env and hubContext are specified
        public DesignAutomationController(IWebHostEnvironment env, IHubContext <DesignAutomationHub> hubContext, DesignAutomationClient api)
        {
            // DesignAutomation must be created as new instance.
            DesignAutomationClientBuilder da = new DesignAutomationClientBuilder(
                OAuthController.GetAppSetting("FORGE_CLIENT_ID"),
                OAuthController.GetAppSetting("FORGE_CLIENT_SECRET")
                );

            _designAutomation = da.Client;
            _env        = env;
            _hubContext = hubContext;
        }
Exemple #6
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public Publisher(DesignAutomationClient client, ILogger <Publisher> logger, IResourceProvider resourceProvider,
                         IPostProcessing postProcessing, IOptions <PublisherConfiguration> publisherConfiguration,
                         IWorkItemsApi workItemsApi, IGuidGenerator guidGenerator, ITaskUtil taskUtil)
        {
            _client           = client;
            _logger           = logger;
            _resourceProvider = resourceProvider;
            _postProcessing   = postProcessing;

            _callbackUrlBase = publisherConfiguration.Value.CallbackUrlBase;
            CompletionCheck  = publisherConfiguration.Value.CompletionCheck;

            _workItemsApi  = workItemsApi;
            _guidGenerator = guidGenerator;

            _taskUtil = taskUtil;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="DesignAutomationController"/> class.
 /// </summary>
 /// <param name="clientApi">The clientApi<see cref="DesignAutomationClient"/>.</param>
 /// <param name="env">The env<see cref="IWebHostEnvironment"/>.</param>
 /// <param name="hub">The hub<see cref="IHubContext{DesignAutomationHub}"/>.</param>
 /// <param name="config">The config<see cref="IConfiguration"/>.</param>
 public DesignAutomationController(DesignAutomationClient clientApi,
                                   IWebHostEnvironment env,
                                   IHubContext <DesignAutomationHub> hub,
                                   IOptions <ForgeConfiguration> config)
 {
     hubContext      = hub;
     configuration   = config.Value;
     FORGE_CLIENT_ID =
         Environment.GetEnvironmentVariable("FORGE_CLIENT_ID")
         ?? configuration.ClientId;
     FORGE_CLIENT_SECRET =
         Environment.GetEnvironmentVariable("FORGE_CLIENT_SECRET")
         ?? configuration.ClientSecret;
     FORGE_WEBHOOK_URL = Environment.GetEnvironmentVariable("FORGE_WEBHOOK_URL");
     _env = env;
     api  = clientApi;
 }
Exemple #8
0
        public DesignAutomation4Revit()
        {
            // need to initialize manually as this class runs in background
            ForgeService service =
                new ForgeService(
                    new HttpClient(
                        new ForgeHandler(Microsoft.Extensions.Options.Options.Create(new ForgeConfiguration()
            {
                ClientId     = Credentials.GetAppSetting("FORGE_CLIENT_ID"),
                ClientSecret = Credentials.GetAppSetting("FORGE_CLIENT_SECRET")
            }))
            {
                InnerHandler = new HttpClientHandler()
            })
                    );

            _designAutomation = new DesignAutomationClient(service);
        }
Exemple #9
0
        protected DesignAutomation4Civil3D()
        {
            // need to initialize manually as this class runs in background
            ForgeService service =
                new ForgeService(
                    new HttpClient(
                        new ForgeHandler(Microsoft.Extensions.Options.Options.Create(new ForgeConfiguration()
            {
                ClientId     = Credentials.GetAppSetting("FORGE_CLIENT_ID"),
                ClientSecret = Credentials.GetAppSetting("FORGE_CLIENT_SECRET")
            }))
            {
                InnerHandler = new HttpClientHandler()
            })
                    );

            _designAutomation = new DesignAutomationClient(service);
            //_designAutomation.Configuration.BaseAddress = new Uri("https://developer.api.autodesk.com/preview.da/us-east/");
        }
Exemple #10
0
        public Fixture()
        {
            var configuration = new ConfigurationBuilder()
                                .AddJsonFile("appsettings.json")
                                .AddJsonFile($"appsettings.user.json", optional: true)
                                .AddEnvironmentVariables()
                                .Build();

            DataFolder       = Path.Combine(Environment.CurrentDirectory, "..\\..\\..\\data\\");
            this.testHandler = new TestHandler(Path.Combine(Environment.CurrentDirectory, "..\\..\\..\\recordings\\"));
            var serviceCollection = new ServiceCollection();

            serviceCollection.AddDesignAutomation(configuration).ConfigurePrimaryHttpMessageHandler(() =>
            {
                return(this.testHandler);
            });

            var serviceProvider = serviceCollection.BuildServiceProvider();

            this.DesignAutomationClient = serviceProvider.GetRequiredService <DesignAutomationClient>();
        }
Exemple #11
0
        public InitializerTestBase(DefaultProjectsConfiguration defaultProjectsConfiguration)
        {
            var configuration = new ConfigurationBuilder()
                                .SetBasePath(Directory.GetCurrentDirectory())
                                .AddJsonFile("appsettings.json", false)
                                .AddJsonFile("appsettings.Local.json", optional: true, reloadOnChange: true)
                                .AddEnvironmentVariables()
                                .AddForgeAlternativeEnvironmentVariables()
                                .Build();

            IServiceCollection services = new ServiceCollection();

            services.AddHttpClient();
            var serviceProvider = services.BuildServiceProvider();

            ForgeConfiguration            forgeConfiguration = configuration.GetSection("Forge").Get <ForgeConfiguration>();
            IOptions <ForgeConfiguration> forgeConfigOptions = Options.Create(forgeConfiguration);

            var httpClientFactory = serviceProvider.GetRequiredService <IHttpClientFactory>();

            forgeOSS = new ForgeOSS(httpClientFactory, forgeConfigOptions, new NullLogger <ForgeOSS>());

            var httpMessageHandler = new ForgeHandler(Options.Create(forgeConfiguration))
            {
                InnerHandler = new HttpClientHandler()
            };
            var forgeService           = new ForgeService(new HttpClient(httpMessageHandler));
            var designAutomationClient = new DesignAutomationClient(forgeService);

            projectsBucketKey = Guid.NewGuid().ToString();

            localCache = new LocalCache();
            var bucketPrefixProvider = new BucketPrefixProvider(forgeConfigOptions, configuration);
            var resourceProvider     = new ResourceProvider(forgeConfigOptions, designAutomationClient, configuration, bucketPrefixProvider, projectsBucketKey);
            var postProcessing       = new PostProcessing(httpClientFactory, new NullLogger <PostProcessing>(), localCache, Options.Create(new ProcessingOptions()));
            var publisher            = new Publisher(designAutomationClient, new NullLogger <Publisher>(), resourceProvider,
                                                     postProcessing, Options.Create(new PublisherConfiguration()),
                                                     new WorkItemsApi(forgeService), null, new TaskUtil());

            var appBundleZipPathsConfiguration = new AppBundleZipPaths
            {
                EmptyExe          = "../../../../WebApplication/AppBundles/EmptyExePlugin.bundle.zip",
                DataChecker       = "../../../../WebApplication/AppBundles/DataCheckerPlugin.bundle.zip",
                CreateSVF         = "../../../../WebApplication/AppBundles/CreateSVFPlugin.bundle.zip",
                CreateThumbnail   = "../../../../WebApplication/AppBundles/CreateThumbnailPlugin.bundle.zip",
                ExtractParameters = "../../../../WebApplication/AppBundles/ExtractParametersPlugin.bundle.zip",
                UpdateParameters  = "../../../../WebApplication/AppBundles/UpdateParametersPlugin.bundle.zip",
                CreateRFA         = "../../../../WebApplication/AppBundles/RFAExportRCEPlugin.bundle.zip",
                CreateBOM         = "../../../../WebApplication/AppBundles/ExportBOMPlugin.bundle.zip",
                ExportDrawing     = "../../../../WebApplication/AppBundles/ExportDrawingAsPdfPlugin.bundle.zip",
                UpdateDrawings    = "../../../../WebApplication/AppBundles/UpdateDrawingsPlugin.bundle.zip"
            };
            IOptions <AppBundleZipPaths> appBundleZipPathsOptions = Options.Create(appBundleZipPathsConfiguration);

            var fdaClient = new FdaClient(publisher, appBundleZipPathsOptions);
            IOptions <DefaultProjectsConfiguration> defaultProjectsOptions = Options.Create(defaultProjectsConfiguration);
            var profileProvider   = new ProfileProvider(forgeOSS);
            var bucketKeyProvider = new LoggedInUserBucketKeyProvider(profileProvider, resourceProvider);
            var userResolver      = new UserResolver(forgeOSS, bucketKeyProvider, localCache, NullLogger <UserResolver> .Instance, profileProvider);
            var arranger          = new Arranger(httpClientFactory, userResolver);

            // TODO: linkGenerator should be mocked
            var dtoGenerator = new DtoGenerator(linkGenerator: null, localCache);
            var projectWork  = new ProjectWork(new NullLogger <ProjectWork>(), arranger, fdaClient, dtoGenerator, userResolver);

            var projectService = new ProjectService(new NullLogger <ProjectService>(), userResolver, projectWork, dtoGenerator);

            initializer = new Initializer(new NullLogger <Initializer>(), fdaClient,
                                          defaultProjectsOptions, projectWork, userResolver, localCache,
                                          projectService, bucketPrefixProvider);

            testFileDirectory = Directory.CreateDirectory(Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()));
            httpClient        = new HttpClient();
        }
 public DesignAutomationController(IWebHostEnvironment env, IHubContext <DesignAutomationHub> hubContext, DesignAutomationClient api)
 {
     _designAutomation = api;
     _env        = env;
     _hubContext = hubContext;
 }
Exemple #13
0
 public DaService(DesignAutomationClient daClient)
 {
     this.daClient = daClient;
 }
Exemple #14
0
        public ResourceProvider(IOptions <ForgeConfiguration> forgeConfigOptionsAccessor, DesignAutomationClient client, IConfiguration configuration, BucketPrefixProvider bucketPrefixProvider, string bucketKey = null)
        {
            _forgeConfiguration   = forgeConfigOptionsAccessor.Value.Validate();
            _configuration        = configuration;
            _bucketPrefixProvider = bucketPrefixProvider;

            BucketKey = bucketKey ?? AnonymousBucketKey();

            _nickname = new Lazy <Task <string> >(async() => await client.GetNicknameAsync("me"));
        }
 public AutoDeskDesignAutomationRepository(DesignAutomationClient designAutomation)
 {
     this._designAutomation = designAutomation;
 }
 // Constructor, where env and hubContext are specified
 public DesignAutomationController(IHostingEnvironment env, IHubContext <ForgeCommunicationHub> hubContext, DesignAutomationClient api)
 {
     _designAutomation = api;
     _env        = env;
     _hubContext = hubContext;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="App"/> class.
 /// </summary>
 /// <param name="api">The api<see cref="DesignAutomationClient"/>.</param>
 /// <param name="config">The config<see cref="IOptions{ForgeConfiguration}"/>.</param>
 public App(DesignAutomationClient api, IOptions <ForgeConfiguration> config)
 {
     this.api    = api;
     this.config = config.Value;
 }
Exemple #18
0
        public ResourceProvider(IOptions <ForgeConfiguration> forgeConfigOptionsAccessor, DesignAutomationClient client, IConfiguration configuration, string bucketKey = null)
        {
            var    forgeConfiguration = forgeConfigOptionsAccessor.Value.Validate();
            string suffix             = configuration != null?configuration.GetValue <string>("BucketKeySuffix") : "";

            BucketKey = bucketKey ?? $"projects-{forgeConfiguration.ClientId.Substring(0, 3)}-{forgeConfiguration.HashString()}{suffix}".ToLowerInvariant();

            _nickname = new Lazy <Task <string> >(async() => await client.GetNicknameAsync("me"));
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="App"/> class.
 /// </summary>
 /// <param name="api">The api<see cref="DesignAutomationClient"/>.</param>
 /// <param name="config">The config<see cref="IOptions{ForgeConfiguration}"/>.</param>
 /// <param name="storageConfig">The storageConfig<see cref="IOptions{AzureStorageConfig}"/>.</param>
 public App(DesignAutomationClient api, IOptions <ForgeConfiguration> config, IOptions <AzureStorageConfig> storageConfig)
 {
     this.api           = api;
     this.config        = config.Value;
     this.storageConfig = storageConfig.Value;
 }
Exemple #20
0
 public DesignAutomationClientBuilder(string forgeClientId, string forgeClientSecret)
 {
     Client = CreateDesignAutomationClient(forgeClientId, forgeClientSecret);
 }