This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { HttpClient, IHttpClientOptions, HttpClientResponse } from '@microsoft/sp-http'; | |
private makeRequest(value1: string, value2: string, value3: string): Promise<HttpClientResponse> { | |
const postURL = "https://REST-API-URL"; | |
const body: string = JSON.stringify({ | |
'name1': value1, | |
'name2': value2, | |
'name3': value3, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private sendEmailViaOffice365Outlook(emailaddress: string, emailSubject: string, emailBody: string): Promise<HttpClientResponse> { | |
const postURL = this.properties.flowURL; | |
const body: string = JSON.stringify({ | |
'emailaddress': emailaddress, | |
'emailSubject': emailSubject, | |
'emailBody': emailBody, | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private sendEmail() { | |
if (!this.properties.flowURL) { | |
this.context.statusRenderer.renderError(this.domElement, "Flow URL is missing. Open the property pane and specify a Flow URL."); | |
return; | |
} | |
if (!this.validateEmail(this.properties.emailAddress)) { | |
this.context.statusRenderer.renderError(this.domElement, "Email address is not valid. Open the property pane and specify a valid email address."); | |
return; | |
} | |
else { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private async Task<ActiveDirectoryClient> GetActiveDirectoryClient() | |
{ | |
Uri baseServiceUri = new Uri(AADAppSettings.AADGraphResourceId); | |
var tenantId = ClaimsPrincipal.Current.FindFirst("http://schemas.microsoft.com/identity/claims/tenantid").Value; | |
ActiveDirectoryClient activeDirectoryClient = | |
new ActiveDirectoryClient(new Uri(baseServiceUri, tenantId), | |
async () => await AcquireTokenAsync()); | |
return activeDirectoryClient; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public async Task CreateADUsersAndGroups() | |
{ | |
XmlDocument sampleData = new XmlDocument(); | |
var sampleDataUrl = HttpContext.Current.Request.Url.Scheme + "://" + HttpContext.Current.Request.Url.Authority + "/Content/SampleData.xml"; | |
sampleData.Load(sampleDataUrl); | |
this.client = await this.GetActiveDirectoryClient(); | |
//VerifiedDomain defaultDomain = await this.GetTenantDefualtDomain(); | |
String defaultDomainValue = System.Configuration.ConfigurationManager.AppSettings["DemoSiteCollectionOwner"].Split('@')[1]; | |
await ParaseXmlAndCreateADGroups(sampleData); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[HttpPost] | |
public async Task<ActionResult> CreateDemoData(SuiteLevelWebApp.Models.ProvisionDemoData model) | |
{ | |
string token = await O365Util.GetAccessToken(ServiceResources.Dashboard); | |
using (var clientContext = TokenHelper.GetClientContextWithAccessToken(DemoSiteCollectionUrl, token)) | |
{ | |
AuthenticationHelper adHelp =new AuthenticationHelper(); | |
await adHelp.CreateADUsersAndGroups(); | |
SiteProvisioning siteProvisioning = new SiteProvisioning(clientContext); | |
siteProvisioning.AddSiteContents(); |