Skip to content

Commit

Permalink
Updating to 2024 R1
Browse files Browse the repository at this point in the history
  • Loading branch information
hb-acumatica committed Jun 12, 2024
1 parent b6fb84c commit 00fff5a
Show file tree
Hide file tree
Showing 12 changed files with 105 additions and 71 deletions.
28 changes: 16 additions & 12 deletions AcumaticaESign/AcumaticaESign.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,49 +15,53 @@
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.Metrics" Version="3.3.4" />
</ItemGroup>
<ItemGroup>
<Reference Include="CsvHelper">
<HintPath>C:\Program Files (x86)\Acumatica ERP\EP2021R100\Bin\CsvHelper.dll</HintPath>
<HintPath>C:\Program Files\Acumatica ERP\EP2024R100\Bin\CsvHelper.dll</HintPath>
</Reference>
<Reference Include="DocuSign">
<HintPath>..\References\DocuSign.dll</HintPath>
<Private>true</Private>
</Reference>
<Reference Include="Microsoft.AspNet.SignalR.Core">
<HintPath>C:\Program Files (x86)\Acumatica ERP\EP2021R100\Bin\Microsoft.AspNet.SignalR.Core.dll</HintPath>
<Reference Include="Microsoft.AspNetCore.SignalR.Core">
<HintPath>C:\Program Files\Acumatica ERP\EP2024R100\Bin\Microsoft.AspNetCore.SignalR.Core.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CSharp" />
<Reference Include="Newtonsoft.Json">
<HintPath>C:\Program Files (x86)\Acumatica ERP\EP2021R100\Bin\Newtonsoft.Json.dll</HintPath>
<HintPath>C:\Program Files\Acumatica ERP\EP2024R100\Bin\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="PX.Common">
<HintPath>C:\Program Files (x86)\Acumatica ERP\EP2021R100\Bin\PX.Common.dll</HintPath>
<HintPath>C:\Program Files\Acumatica ERP\EP2024R100\Bin\PX.Common.dll</HintPath>
</Reference>
<Reference Include="PX.Common.Std">
<HintPath>C:\Program Files (x86)\Acumatica ERP\EP2021R100\Bin\PX.Common.Std.dll</HintPath>
<HintPath>C:\Program Files\Acumatica ERP\EP2024R100\Bin\PX.Common.Std.dll</HintPath>
</Reference>
<Reference Include="PX.Web.UI">
<HintPath>C:\Program Files (x86)\Acumatica ERP\EP2021R100\Bin\PX.Web.UI.dll</HintPath>
<HintPath>C:\Program Files\Acumatica ERP\EP2024R100\Bin\PX.Web.UI.dll</HintPath>
</Reference>
<Reference Include="PX.CS.Contracts">
<HintPath>C:\Program Files (x86)\Acumatica ERP\EP2021R100\Bin\PX.CS.Contracts.dll</HintPath>
<HintPath>C:\Program Files\Acumatica ERP\EP2024R100\Bin\PX.CS.Contracts.dll</HintPath>
</Reference>
<Reference Include="PX.Data">
<HintPath>C:\Program Files (x86)\Acumatica ERP\EP2021R100\Bin\PX.Data.dll</HintPath>
<HintPath>C:\Program Files\Acumatica ERP\EP2024R100\Bin\PX.Data.dll</HintPath>
</Reference>
<Reference Include="PX.OAuthClient">
<HintPath>C:\Program Files (x86)\Acumatica ERP\EP2021R100\Bin\PX.OAuthClient.dll</HintPath>
<HintPath>C:\Program Files\Acumatica ERP\EP2024R100\Bin\PX.OAuthClient.dll</HintPath>
</Reference>
<Reference Include="PX.Objects">
<HintPath>C:\Program Files (x86)\Acumatica ERP\EP2021R100\Bin\PX.Objects.dll</HintPath>
<HintPath>C:\Program Files\Acumatica ERP\EP2024R100\Bin\PX.Objects.dll</HintPath>
</Reference>
<Reference Include="RestSharp">
<HintPath>C:\Program Files (x86)\Acumatica ERP\EP2021R100\Bin\RestSharp.dll</HintPath>
<HintPath>C:\Program Files\Acumatica ERP\EP2024R100\Bin\RestSharp.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Net.Http" />
<Reference Include="System.Web" />
<Reference Include="System.Xml" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion AcumaticaESign/AcumaticaESign/DAC/ESignAccount.cs
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ public static class ProviderTypes
public static class ProviderTypesIconPath
{
public const string DocuSign = "~/Icons/DocuSignIcon.png";
public const string AdobeSign = "~/Icons/AdobeSignIcon.png";
public const string AdobeSign = "~/Icons/AcrobatSignIcon.png";
public const string Empty = "";
}

Expand Down
2 changes: 1 addition & 1 deletion AcumaticaESign/AcumaticaESign/DAC/ESignEnvelopeInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -927,7 +927,7 @@ public static class ProviderTypes
public static class ProviderTypesIconPath
{
public const string DocuSign = "~/Icons/DocuSignIcon.png";
public const string AdobeSign = "~/Icons/AdobeSignIcon.png";
public const string AdobeSign = "~/Icons/AcrobatSignIcon.png";
public const string Empty = "";
}

Expand Down
8 changes: 5 additions & 3 deletions AcumaticaESign/AcumaticaESign/Descriptor/Messages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public static class ESignIntegrationStatus
public static class ESignProviderType
{
public const string DocuSign = "DocuSign";
public const string AdobeSign = "AdobeSign";
public const string AdobeSign = "AcrobatSign";
}

public static class ESignAccountType
Expand Down Expand Up @@ -224,6 +224,8 @@ public static class ESignEnvelopeStatus

#region Validation messages

public const string ConnectionSuccess = "The connection to the eSign provider was successful.";

public const string EnvelopeStatusChanged =
"This document was already sent previously. Please refresh your screen to see latest status information.";

Expand All @@ -250,10 +252,10 @@ public static class ESignEnvelopeStatus

public const string DocumentWasDeletedMessage = "Document was deleted from web version.";
public const string EnvelopeWithoutRecipientMessage = "You cannot send a document without recipient.";
public const string MessagePattern = "Unsupported values ({0}) have been sent to Adobe Sign.";
public const string MessagePattern = "Unsupported values ({0}) have been sent to Acrobat Sign.";
public const string AccessIsNotAllowedMessage = "Access is not allowed.";
public const string InvalidFileTypeMessage = "Invalid file type chosen for E Sign.";
public const string NotFoundMessage = "Adobe Sign entity has not been found.";
public const string NotFoundMessage = "Acrobat Sign entity has not been found.";
public const string SentToYourselfMessage = "You cannot send a document only to yourself to complete.";

#endregion
Expand Down
18 changes: 8 additions & 10 deletions AcumaticaESign/AcumaticaESign/ESignAccountEntry.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Microsoft.AspNet.SignalR.Infrastructure;
using Microsoft.AspNetCore.SignalR;
using PX.Data;
using PX.Data.DependencyInjection;
using PX.OAuthClient.Hubs;
Expand All @@ -9,7 +9,7 @@ namespace AcumaticaESign
public class ESignAccountEntry : PXGraph<ESignAccountEntry, ESignAccount>, IGraphWithInitialization
{
[InjectDependency]
private IConnectionManager _signalRConnectionManager { get; set; }
private IHubContext<RefreshHub> _signalRConnectionManager { get; set; }

public void Initialize()
{
Expand Down Expand Up @@ -51,6 +51,7 @@ public virtual void connect()
}
}


public PXAction<ESignAccount> Disconnect;
[PXButton]
[PXUIField(DisplayName = Messages.Actions.Disconnect, MapEnableRights = PXCacheRights.Update,
Expand Down Expand Up @@ -287,8 +288,7 @@ protected virtual void _(Events.FieldUpdated<ESignAccount.ownerID> args)

private void SendRefreshCall()
{
var hubContext = _signalRConnectionManager.GetHubContext<RefreshHub>();
hubContext.Clients.All.RefreshPage();
_signalRConnectionManager?.Clients?.All?.SendCoreAsync("refreshScreen", null);
}

private static bool IsDisconnected(ESignAccount account)
Expand All @@ -300,12 +300,10 @@ private void AuthenticateAdobeSignAccount(ESignAccount account)
{
var companyId = PXAccess.GetCompanyName();
var client = AdobeSignClientBuilder.BuildUnauthorized(account, companyId);
PXLongOperation.StartOperation(this, () =>
{
var loginUrl = client.Authentication.GetLoginPageUrl();
throw new PXRedirectToUrlException(loginUrl, PXBaseRedirectException.WindowMode.InlineWindow,
string.Empty, false);
});

var loginUrl = client.Authentication.GetLoginPageUrl();
throw new PXRedirectToUrlException(loginUrl, PXBaseRedirectException.WindowMode.InlineWindow,
string.Empty, false);
}

private void AuthenticateDocuSignAccount(ESignAccount account)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Text.RegularExpressions;
using System.Web;

namespace AcumaticaESign
Expand All @@ -13,11 +14,15 @@ public static AdobeSignClient Build(ESignAccount account, string companyId = nul

public static AdobeSignClient BuildUnauthorized(ESignAccount account, string companyId = null)
{
string leftPart = IsSecureConnection() && HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority).StartsWith("http:", StringComparison.OrdinalIgnoreCase) ?
Regex.Replace(HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority), "http:", "https:", RegexOptions.IgnoreCase) :
HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority);

var credentials = CreateCredentials(account, companyId);
if (HttpContext.Current != null)
{
var url = string.Concat(
HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority),
leftPart,
HttpContext.Current.Request.ApplicationPath != null && HttpContext.Current.Request.ApplicationPath.EndsWith("/")
? string.Concat(HttpContext.Current.Request.ApplicationPath, "Pages/ES/ESign.aspx")
: string.Concat(HttpContext.Current.Request.ApplicationPath, "/", "Pages/ES/ESign.aspx"));
Expand All @@ -40,5 +45,14 @@ private static Credentials CreateCredentials(ESignAccount setup, string companyI
CompanyId = companyId
};
}

private static bool IsSecureConnection()
{
return
HttpContext.Current.Request.IsSecureConnection
|| string.Equals(HttpContext.Current.Request.Headers["X-Forwarded-Proto"],
"https",
StringComparison.InvariantCultureIgnoreCase);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ public class Request
public Dictionary<string, byte[]> FileParameters { get; } = new Dictionary<string, byte[]>();
public Dictionary<string, object> UrlParameters { get; set; } = new Dictionary<string, object>();

public IRestResponse Execute()
public RestResponse Execute()
{
var request = BuildRestRequest();
return Dependencies.RestClient.Execute(request);
}

public IRestResponse<T> Execute<T>()
public RestResponse<T> Execute<T>()
where T : new()
{
var request = BuildRestRequest();
Expand All @@ -49,55 +49,55 @@ public RestRequest BuildRestRequest()
return request;
}

private void AddUseFormContentTypeHeader(IRestRequest request)
private void AddUseFormContentTypeHeader(RestRequest request)
{
if (UseFormContentTypeHeader)
{
request.AddHeader("Content-Type", "application/x-www-form-urlencoded");
}
}

private void AddAuthorizationHeader(IRestRequest request)
private void AddAuthorizationHeader(RestRequest request)
{
if (UseAuthorizationHeader)
{
request.AddHeader("Access-Token", Dependencies.Credentials.AccessToken);
}
}

private void AddDownloadParameter(IRestRequest request)
private void AddDownloadParameter(RestRequest request)
{
if (IsDownload)
{
request.AddHeader("Accept", "*/*");
}
}

private void AddQueryParameters(IRestRequest request)
private void AddQueryParameters(RestRequest request)
{
foreach (var pair in QueryParameters)
{
request.AddParameter(pair.Key, pair.Value);
request.AddParameter(pair.Key, pair.Value.ToString());
}
}

private void AddUrlSegment(IRestRequest request)
private void AddUrlSegment(RestRequest request)
{
foreach (var pair in UrlParameters)
{
request.AddUrlSegment(pair.Key, (string) pair.Value);
}
}

private void AddFileParameters(IRestRequest request)
private void AddFileParameters(RestRequest request)
{
foreach (var pair in FileParameters)
{
request.AddFileBytes("File", pair.Value, pair.Key);
request.AddFile("File", pair.Value, pair.Key);
}
}

private void AddBodyParameters(IRestRequest request)
private void AddBodyParameters(RestRequest request)
{
if (BodyParameters.Count > 0)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,13 @@ public T Execute<T>(bool checkStatusCode = true)
return HandleResponse(() => Request.Execute<T>(), checkStatusCode).Data;
}

public IRestResponse Execute(bool checkStatusCode = true)
public RestResponse Execute(bool checkStatusCode = true)
{
return HandleResponse(() => Request.Execute(), checkStatusCode);
}

private T HandleResponse<T>(Func<T> getResponse, bool checkStatusCode)
where T : IRestResponse
where T : RestResponse
{
var response = getResponse();

Expand All @@ -113,7 +113,7 @@ private T HandleResponse<T>(Func<T> getResponse, bool checkStatusCode)
return response;
}

private void HandleStatusCode(IRestResponse response, bool required)
private void HandleStatusCode(RestResponse response, bool required)
{
if (required && !expectedStatuses.Contains(response.StatusCode))
{
Expand All @@ -134,7 +134,7 @@ private void HandleStatusCode(IRestResponse response, bool required)
}
}

private void HandleValidationErrors(IRestResponse response)
private void HandleValidationErrors(RestResponse response)
{
dynamic errors = null;
string message = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public string GetLoginPageUrl()

public AccessTokenEntity CreateAccessToken(string authorizationCode)
{
return new RequestBuilder(Dependencies, Method.POST, "oauth/v2/token")
return new RequestBuilder(Dependencies, Method.Post, "oauth/v2/token")
.AddFormContentTypeHeader()
.AddQueryParameter("code", authorizationCode)
.AddQueryParameter("client_id", Dependencies.Credentials.ClientId)
Expand All @@ -32,7 +32,7 @@ public AccessTokenEntity CreateAccessToken(string authorizationCode)

public AccessTokenEntity RefreshAccessToken()
{
return new RequestBuilder(Dependencies, Method.POST, "/oauth/v2/refresh")
return new RequestBuilder(Dependencies, Method.Post, "/oauth/v2/refresh")
.AddFormContentTypeHeader()
.AddQueryParameter("grant_type", "refresh_token")
.AddQueryParameter("client_id", Dependencies.Credentials.ClientId)
Expand Down
Loading

0 comments on commit 00fff5a

Please sign in to comment.