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
using Microsoft.Identity.Client; | |
using System; | |
using System.Net.Http; | |
using System.Threading.Tasks; | |
public static async Task<string> GetAccessTokenAsync(string clientId, string tenantId) | |
{ | |
var app = PublicClientApplicationBuilder.Create(clientId) | |
.WithAuthority($"https://login.microsoftonline.com/{tenantId}") | |
.Build(); |
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
const msalConfig = { | |
auth: { | |
clientId: 'your-client-id', | |
authority: 'https://login.microsoftonline.com/common', | |
redirectUri: 'http://localhost:3000', | |
}, | |
cache: { | |
cacheLocation: 'localStorage', | |
storeAuthStateInCookie: true, | |
} |
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
string[] scopes = { "user.read" }; | |
string clientId = "your-client-id"; | |
string redirectUri = "http://localhost/myapp"; | |
IPublicClientApplication app = PublicClientApplicationBuilder | |
.Create(clientId) | |
.WithRedirectUri(redirectUri) | |
.Build(); | |
AuthenticationResult result = await app.AcquireTokenInteractive(scopes) | |
.ExecuteAsync(); |
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
DateTime startTime = DateTime.Now; | |
//Code here | |
TimeSpan diff = DateTime.Now - startTime; | |
//Use methods in [diff] to get required data. | |
// e.g. the below is to get time in seconds. | |
Console.WriteLine(diff.TotalSeconds); |
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
<configuration> | |
<system.web> | |
<compilation> | |
<assemblies> | |
<add assembly="netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51"/> | |
</assemblies> | |
</compilation> | |
</system.web> | |
</configuration> |
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
catch (Exception ex) | |
{ | |
if (ex is System.Reflection.ReflectionTypeLoadException) | |
{ | |
var typeEx = ex as ReflectionTypeLoadException; | |
var loadEx = typeEx.LoaderExceptions; | |
//Do something with loadEx | |
} | |
} |
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 List<System.IO.MemoryStream> getInfoPathAttachments(System.Xml.XmlDocument InfoPathDocument, string nodePath) | |
{ | |
/// <summary> | |
/// Grab multiple attachments from an InfoPath form and | |
/// return them in a list of memory streams. | |
/// </summary> | |
List<System.IO.MemoryStream> files = new List<MemoryStream>(); | |
System.Xml.XmlNamespaceManager nm = new System.Xml.XmlNamespaceManager(InfoPathDocument.NameTable); | |
nm.AddNamespace("my", "http://schemas.microsoft.com/office/infopath/2003/myXSD/2014-07-12T15:29:09"); |
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
//Create an XmlNamespaceManager | |
XmlNamespaceManager ns = this.NamespaceManager; | |
//Create an XPathNavigator object for the Main data source | |
XPathNavigator xnMain = this.MainDataSource.CreateNavigator(); | |
//Create an XPathNavigator object for the attachment node | |
XPathNavigator xnAttNode = xnMain.SelectSingleNode("/my:myFields/my:theAttachmentField", ns); | |
//Obtain the text of the node. |
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
using System; | |
using System.IO; | |
using System.Text; | |
namespace InfoPathAttachmentEncoding | |
{ | |
/// <summary> | |
/// Decodes a file attachment and saves it to a specified path. | |
/// </summary> | |
public class InfoPathAttachmentDecoder |
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
using System; | |
using System.IO; | |
using System.Text; | |
using System.Security.Cryptography; | |
using InfoPathAttachmentEncoding; | |
namespace InfoPathAttachmentEncoding | |
{ | |
/// <summary> | |
/// InfoPathAttachment encodes file data into the format expected by InfoPath for use in file attachment nodes. |
NewerOlder