|
|
@@ -104,7 +104,7 @@ public static partial class MYOBPosterEngine
|
|
|
return _connectionData;
|
|
|
}
|
|
|
|
|
|
- public static MYOBConnectionData GetConnectionData()
|
|
|
+ public static MYOBConnectionData GetConnectionData(IPosterDispatcher dispatcher)
|
|
|
{
|
|
|
if(_connectionData is MYOBConnectionData data)
|
|
|
{
|
|
|
@@ -114,7 +114,8 @@ public static partial class MYOBPosterEngine
|
|
|
var configuration = new ApiConfiguration(DEV_KEY, SECRET_KEY, REDIRECT_URL);
|
|
|
var authService = new OAuthService(configuration);
|
|
|
|
|
|
- if(!GetAuthorisationCode(configuration, out var code))
|
|
|
+ string? code = null;
|
|
|
+ if(!dispatcher.Execute(() => GetAuthorisationCode(configuration, out code)))
|
|
|
{
|
|
|
throw new PostCancelledException();
|
|
|
}
|
|
|
@@ -167,7 +168,7 @@ public abstract class MYOBPosterEngine<TPostable, TPoster, TSettings> :
|
|
|
|
|
|
protected void LoadConnectionData()
|
|
|
{
|
|
|
- var data = MYOBPosterEngine.GetConnectionData();
|
|
|
+ var data = MYOBPosterEngine.GetConnectionData(Dispatcher);
|
|
|
|
|
|
var globalSettings = GetGlobalSettings();
|
|
|
if(data.CompanyFile is null || data.CompanyFile.Id != globalSettings.CompanyFile.ID)
|
|
|
@@ -175,7 +176,7 @@ public abstract class MYOBPosterEngine<TPostable, TPoster, TSettings> :
|
|
|
CompanyFile? file;
|
|
|
if(globalSettings.CompanyFile.ID == Guid.Empty)
|
|
|
{
|
|
|
- file = MYOBCompanyFileSelectionDialog.SelectCompanyFile();
|
|
|
+ file = MYOBCompanyFileSelectionDialog.SelectCompanyFile(Dispatcher);
|
|
|
if(file is null)
|
|
|
{
|
|
|
throw new PostCancelledException();
|
|
|
@@ -198,7 +199,7 @@ public abstract class MYOBPosterEngine<TPostable, TPoster, TSettings> :
|
|
|
Password = globalSettings.CompanyFilePassword,
|
|
|
NoCredentials = globalSettings.NoCredentials
|
|
|
};
|
|
|
- if (DynamicGridUtils.EditObject(credentials, customiseGrid: grid =>
|
|
|
+ if (Dispatcher.Execute(() => DynamicGridUtils.EditObject(credentials, customiseGrid: grid =>
|
|
|
{
|
|
|
grid.OnValidate += (grid, items, errors) =>
|
|
|
{
|
|
|
@@ -210,7 +211,7 @@ public abstract class MYOBPosterEngine<TPostable, TPoster, TSettings> :
|
|
|
errors.Add("[UserID] cannot be blank");
|
|
|
}
|
|
|
};
|
|
|
- }))
|
|
|
+ })))
|
|
|
{
|
|
|
globalSettings.NoCredentials = credentials.NoCredentials;
|
|
|
globalSettings.CompanyFileUserID = credentials.UserID;
|