public DynamicsController(
            ILogger <DocumentController> logger,
            IOptions <AppOptions> appOptions,
            IDocumentService documentService,
            IOpportunityService opportunityService,
            IGraphClientAppContext graphClientAppContext,
            IOneDriveLinkService oneDriveLinkService,
            IConfiguration configuration,
            IDynamicsLinkService dynamicsLinkService,
            IProposalManagerClientFactory proposalManagerClientFactory) : base(logger, appOptions)
        {
            this.oneDriveLinkService          = oneDriveLinkService;
            this.graphClientAppContext        = graphClientAppContext;
            this.dynamicsLinkService          = dynamicsLinkService;
            this.opportunityService           = opportunityService;
            this.proposalManagerClientFactory = proposalManagerClientFactory;

            oneDriveConfiguration = new OneDriveConfiguration();
            configuration.Bind(OneDriveConfiguration.ConfigurationName, oneDriveConfiguration);

            dynamicsConfiguration = new Dynamics365Configuration();
            configuration.Bind(Dynamics365Configuration.ConfigurationName, dynamicsConfiguration);

            proposalManagerConfiguration = new ProposalManagerConfiguration();
            configuration.Bind(ProposalManagerConfiguration.ConfigurationName, proposalManagerConfiguration);
        }
Esempio n. 2
0
 public GraphSharePointAppService(
     ILogger <GraphSharePointBaseService> logger,
     IOptionsMonitor <AppOptions> appOptions,
     IGraphClientAppContext graphClientContext,
     SharePointListsSchemaHelper sharePointListsSchemaHelper) : base(logger, appOptions, graphClientContext)
 {
 }
Esempio n. 3
0
 public GraphUserAppService(
     ILogger <GraphUserAppService> logger,
     IOptionsMonitor <AppOptions> appOptions,
     IGraphClientAppContext graphClientContext,
     IHostingEnvironment hostingEnvironment) : base(logger, appOptions, graphClientContext, hostingEnvironment)
 {
 }
Esempio n. 4
0
        public OneDriveLinkService(
            IGraphClientAppContext graphClientContext,
            IProposalManagerClientFactory proposalManagerClientFactory,
            IConfiguration configuration,
            IOpportunityRepository opportunityRepository,
            IDeltaLinksStorage deltaLinksStorage)
        {
            this.graphClientContext           = graphClientContext;
            this.proposalManagerClientFactory = proposalManagerClientFactory;

            oneDriveConfiguration = new OneDriveConfiguration();
            configuration.Bind(OneDriveConfiguration.ConfigurationName, oneDriveConfiguration);

            dynamics365Configuration = new Dynamics365Configuration();
            configuration.Bind(Dynamics365Configuration.ConfigurationName, dynamics365Configuration);

            azureAdOptions = new AzureAdOptions();
            configuration.Bind("AzureAd", azureAdOptions);

            appOptions = new AppOptions();
            configuration.Bind("ProposalManagement", appOptions);

            this.opportunityRepository = opportunityRepository;
            this.deltaLinksStorage     = deltaLinksStorage;

            InitializeTemporaryFolderDelta();
        }
Esempio n. 5
0
 public GraphTeamsAppService(
     ILogger <GraphTeamsAppService> logger,
     IOptionsMonitor <AppOptions> appOptions,
     IGraphClientAppContext graphClientContext,
     IUserContext userContext,
     IAzureKeyVaultService azureKeyVaultService) : base(logger, appOptions, graphClientContext, userContext, azureKeyVaultService)
 {
 }
Esempio n. 6
0
        public SharePointLocationRepository(
            IConfiguration configuration,
            IDynamicsClientFactory dynamicsClientFactory,
            ISharePointLocationsCache sharePointLocationsCache,
            IGraphClientAppContext graphClientContext)
        {
            dynamicsConfiguration = new Dynamics365Configuration();
            appOptions            = new AppOptions();
            configuration.Bind(Dynamics365Configuration.ConfigurationName, dynamicsConfiguration);
            configuration.Bind("ProposalManagement", appOptions);
            this.sharePointLocationsCache = sharePointLocationsCache;
            graphClient = graphClientContext.GraphClient;
            this.dynamicsClientFactory = dynamicsClientFactory;
            if (!Guid.TryParse(sharePointLocationsCache.ProposalManagerSiteId, out Guid existingSiteId))
            {
                var     result          = dynamicsClientFactory.GetDynamicsAuthorizedWebClientAsync().Result.GetAsync($"/api/data/v9.0/sharepointsites?$filter=absoluteurl eq 'https://{appOptions.SharePointHostName}'").Result;
                JObject responseJObject = result.Content.ReadAsAsync <JObject>().Result;

                if (responseJObject == null || responseJObject["value"] == null)
                {
                    throw new Exception("DYNAMICS INTEGRATION ENGINE: Invalid or null response from Dynamics when querying for Tenant Site.");
                }

                var site = responseJObject["value"].AsJEnumerable().SingleOrDefault();

                if (site == null)
                {
                    throw new Exception("DYNAMICS INTEGRATION ENGINE: Tenant Site is not registered in Dynamics.");
                }

                sharePointLocationsCache.ProposalManagerSiteId = site["sharepointsiteid"].ToString();

                if (!Guid.TryParse(sharePointLocationsCache.ProposalManagerSiteId, out existingSiteId))
                {
                    throw new Exception("DYNAMICS INTEGRATION ENGINE: Malformed GUID for Tenant Site.");
                }
            }
            if (!Guid.TryParse(sharePointLocationsCache.ProposalManagerBaseSiteId, out Guid existingBaseSiteId))
            {
                var     result          = dynamicsClientFactory.GetDynamicsAuthorizedWebClientAsync().Result.GetAsync($"/api/data/v9.0/sharepointsites?$filter=parentsite/sharepointsiteid eq '{sharePointLocationsCache.ProposalManagerSiteId}' and relativeurl eq 'sites/{appOptions.SharePointSiteRelativeName}'").Result;
                JObject responseJObject = result.Content.ReadAsAsync <JObject>().Result;

                if (responseJObject == null || responseJObject["value"] == null)
                {
                    throw new Exception("DYNAMICS INTEGRATION ENGINE: Invalid or null response from Dynamics when querying for Proposal Manager Site.");
                }

                var sites = responseJObject["value"].AsJEnumerable().SingleOrDefault();

                if (sites == null)
                {
                    throw new Exception("DYNAMICS INTEGRATION ENGINE: Proposal Manager Site is not registered in Dynamics.");
                }

                sharePointLocationsCache.ProposalManagerBaseSiteId = sites["sharepointsiteid"].ToString();

                if (!Guid.TryParse(sharePointLocationsCache.ProposalManagerBaseSiteId, out existingSiteId))
                {
                    throw new Exception("DYNAMICS INTEGRATION ENGINE: Malformed GUID for Proposal Manager Site.");
                }
            }
            if (!Guid.TryParse(sharePointLocationsCache.RootDriveLocationId, out Guid existingDriveId))
            {
                var     result          = dynamicsClientFactory.GetDynamicsAuthorizedWebClientAsync().Result.GetAsync($"/api/data/v9.0/sharepointdocumentlocations?$filter=parentsiteorlocation_sharepointsite/sharepointsiteid eq '{sharePointLocationsCache.ProposalManagerBaseSiteId}' and relativeurl eq '{dynamicsConfiguration.RootDrive}'").Result;
                JObject responseJObject = result.Content.ReadAsAsync <JObject>().Result;

                if (responseJObject == null || responseJObject["value"] == null)
                {
                    throw new Exception("DYNAMICS INTEGRATION ENGINE: Invalid or null response from Dynamics when querying for Proposal Manger Site Drive.");
                }

                var location = responseJObject["value"].AsJEnumerable().SingleOrDefault();

                if (location == null)
                {
                    throw new Exception("DYNAMICS INTEGRATION ENGINE: Proposal Manager Site Drive is not registered in Dynamics.");
                }

                sharePointLocationsCache.RootDriveLocationId = location["sharepointdocumentlocationid"].ToString();

                if (!Guid.TryParse(sharePointLocationsCache.RootDriveLocationId, out existingSiteId))
                {
                    throw new Exception("DYNAMICS INTEGRATION ENGINE: Malformed GUID for Proposal Manager Site Drive.");
                }
            }
            if (!Guid.TryParse(sharePointLocationsCache.TempFolderLocationId, out Guid existingTempFolderId))
            {
                var     result          = dynamicsClientFactory.GetDynamicsAuthorizedWebClientAsync().Result.GetAsync($"/api/data/v9.0/sharepointdocumentlocations?$filter=parentsiteorlocation_sharepointdocumentlocation/sharepointdocumentlocationid eq '{sharePointLocationsCache.RootDriveLocationId}' and relativeurl eq '{TempFolderName}'").Result;
                JObject responseJObject = result.Content.ReadAsAsync <JObject>().Result;

                if (responseJObject == null || responseJObject["value"] == null)
                {
                    throw new Exception("DYNAMICS INTEGRATION ENGINE: Invalid or null response from Dynamics when querying for Proposal Manager Temporary Folder.");
                }

                var location = responseJObject["value"].AsJEnumerable().SingleOrDefault();

                if (location == null)
                {
                    throw new Exception("DYNAMICS INTEGRATION ENGINE: Proposal Manager Temporary Folder is not registered in Dynamics.");
                }

                sharePointLocationsCache.TempFolderLocationId = location["sharepointdocumentlocationid"].ToString();

                if (!Guid.TryParse(sharePointLocationsCache.TempFolderLocationId, out existingSiteId))
                {
                    throw new Exception("DYNAMICS INTEGRATION ENGINE: Malformed GUID for Proposal Manager Temporary Folder.");
                }
            }
        }
Esempio n. 7
0
 public SharePointLocationRepository(
     IConfiguration configuration,
     IDynamicsClientFactory dynamicsClientFactory,
     ISharePointLocationsCache sharePointLocationsCache,
     IGraphClientAppContext graphClientContext)
 {
     dynamicsConfiguration = new Dynamics365Configuration();
     appOptions            = new AppOptions();
     configuration.Bind(Dynamics365Configuration.ConfigurationName, dynamicsConfiguration);
     configuration.Bind("ProposalManagement", appOptions);
     this.sharePointLocationsCache = sharePointLocationsCache;
     graphClient = graphClientContext.GraphClient;
     this.dynamicsClientFactory = dynamicsClientFactory;
     if (!Guid.TryParse(sharePointLocationsCache.ProposalManagerSiteId, out Guid existingSiteId))
     {
         var result = dynamicsClientFactory.GetDynamicsAuthorizedWebClientAsync().Result.GetAsync($"/api/data/v9.0/sharepointsites?$filter=absoluteurl eq 'https://{appOptions.SharePointHostName}'").Result;
         if (!Guid.TryParse(
                 sharePointLocationsCache.ProposalManagerSiteId =
                     JsonConvert.DeserializeObject <JObject>(result.Content.ReadAsStringAsync().Result)["value"].AsJEnumerable()
                     .Single()["sharepointsiteid"].ToString()
                 , out existingSiteId))
         {
             throw new Exception("DYNAMICS INTEGRATION ENGINE: Tenant Site is not registered in Dynamics.");
         }
     }
     if (!Guid.TryParse(sharePointLocationsCache.ProposalManagerBaseSiteId, out Guid existingBaseSiteId))
     {
         var result = dynamicsClientFactory.GetDynamicsAuthorizedWebClientAsync().Result.GetAsync($"/api/data/v9.0/sharepointsites?$filter=parentsite/sharepointsiteid eq '{sharePointLocationsCache.ProposalManagerSiteId}' and relativeurl eq 'sites/{appOptions.SharePointSiteRelativeName}'").Result;
         if (!Guid.TryParse(
                 sharePointLocationsCache.ProposalManagerBaseSiteId =
                     JsonConvert.DeserializeObject <JObject>(result.Content.ReadAsStringAsync().Result)["value"].AsJEnumerable()
                     .Single()["sharepointsiteid"].ToString()
                 , out existingSiteId))
         {
             throw new Exception("DYNAMICS INTEGRATION ENGINE: Proposal Manager Site is not registered in Dynamics.");
         }
     }
     if (!Guid.TryParse(sharePointLocationsCache.RootDriveLocationId, out Guid existingDriveId))
     {
         var result = dynamicsClientFactory.GetDynamicsAuthorizedWebClientAsync().Result.GetAsync($"/api/data/v9.0/sharepointdocumentlocations?$filter=parentsiteorlocation_sharepointsite/sharepointsiteid eq '{sharePointLocationsCache.ProposalManagerBaseSiteId}' and relativeurl eq '{dynamicsConfiguration.RootDrive}'").Result;
         if (!Guid.TryParse(
                 sharePointLocationsCache.RootDriveLocationId =
                     JsonConvert.DeserializeObject <JObject>(result.Content.ReadAsStringAsync().Result)["value"].AsJEnumerable()
                     .Single()["sharepointdocumentlocationid"].ToString()
                 , out existingSiteId))
         {
             throw new Exception("DYNAMICS INTEGRATION ENGINE: Proposal Manager Site Drive is not registered in Dynamics.");
         }
     }
     if (!Guid.TryParse(sharePointLocationsCache.TempFolderLocationId, out Guid existingTempFolderId))
     {
         var result = dynamicsClientFactory.GetDynamicsAuthorizedWebClientAsync().Result.GetAsync($"/api/data/v9.0/sharepointdocumentlocations?$filter=parentsiteorlocation_sharepointdocumentlocation/sharepointdocumentlocationid eq '{sharePointLocationsCache.RootDriveLocationId}' and relativeurl eq '{TempFolderName}'").Result;
         if (!Guid.TryParse(
                 sharePointLocationsCache.TempFolderLocationId =
                     JsonConvert.DeserializeObject <JObject>(result.Content.ReadAsStringAsync().Result)["value"].AsJEnumerable()
                     .Single()["sharepointdocumentlocationid"].ToString()
                 , out existingSiteId))
         {
             throw new Exception("DYNAMICS INTEGRATION ENGINE: Proposal Manager Temporary Folder is not registered in Dynamics.");
         }
     }
 }
 public GraphSharePointAppService(
     ILogger <GraphSharePointBaseService> logger,
     IOptions <AppOptions> appOptions,
     IGraphClientAppContext graphClientContext) : base(logger, appOptions, graphClientContext)
 {
 }