Skip to content

Commit

Permalink
fixes #6: Switch to old web service only during login
Browse files Browse the repository at this point in the history
  • Loading branch information
rstefko committed Feb 3, 2020
1 parent 7cc90f2 commit c5201b2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
11 changes: 6 additions & 5 deletions eWayCRM.API/Connection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ public class Connection
private readonly string clientMachineIdentifier;
private readonly bool useDefaultCredentials;
private readonly NetworkCredential networkCredential;
private const string uploadMethodName = "SaveBinaryAttachment";
private const string _uploadMethodName = "SaveBinaryAttachment";
private const string _loginMethodName = "LogIn";
private static readonly MD5 _md5Hash = MD5.Create();

private Guid? sessionId;
Expand Down Expand Up @@ -230,7 +231,7 @@ public void EnsureLogin()

private void LogIn()
{
JObject response = this.Call("LogIn", JObject.FromObject(new
JObject response = this.Call(_loginMethodName, JObject.FromObject(new
{
userName = this.username,
passwordHash = this.passwordHash,
Expand Down Expand Up @@ -290,7 +291,7 @@ private JObject Call(string methodName, JObject data)
}
catch (WebException ex)
{
if (!oldServiceUriUsed && ((HttpWebResponse)ex.Response).StatusCode == HttpStatusCode.NotFound)
if (!oldServiceUriUsed && ((HttpWebResponse)ex.Response).StatusCode == HttpStatusCode.NotFound && methodName == _loginMethodName && this.passwordHash != null)
{
this.serviceUri = this.GetApiServiceUrl(this.baseServiceUri, true);
this.oldServiceUriUsed = true;
Expand Down Expand Up @@ -466,7 +467,7 @@ private JObject UploadFile(Guid itemGuid, Stream stream, string fileName, bool r
return this.UploadFile(itemGuid, stream, fileName, false);
}
if (response.GetValue("ReturnCode").ToString() != "rcSuccess")
throw new ResponseException(uploadMethodName, response.GetValue("ReturnCode").ToString(), response.GetValue("Description").ToString());
throw new ResponseException(_uploadMethodName, response.GetValue("ReturnCode").ToString(), response.GetValue("Description").ToString());
return response;
}

Expand Down Expand Up @@ -518,7 +519,7 @@ private string GetMethodUri(string methodName)

private string GetFileUploadUri(Guid itemGuid, string FileName)
{
return ($"{this.serviceUri}/{uploadMethodName}?sessionId={this.sessionId}&itemGuid={itemGuid}&fileName={FileName}");
return ($"{this.serviceUri}/{_uploadMethodName}?sessionId={this.sessionId}&itemGuid={itemGuid}&fileName={FileName}");
}

private static string GetClientIdentification(string uriString)
Expand Down
4 changes: 2 additions & 2 deletions eWayCRM.API/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.3.4")]
[assembly: AssemblyFileVersion("1.3.4")]
[assembly: AssemblyVersion("1.3.5")]
[assembly: AssemblyFileVersion("1.3.5")]

0 comments on commit c5201b2

Please sign in to comment.