Skip to content

Commit

Permalink
LanguageWeaver 2.0.2.1: SDLCOM-6140 - Language Weaver Provider plugin…
Browse files Browse the repository at this point in the history
… throws an error after Studio was closed for several hours: "Authentication failed. Operation is not valid due to the current state of the object."

* Add logging

* Add more details to the exception message shown
  • Loading branch information
ealbu authored Sep 11, 2024
1 parent 767ba9e commit 18f83cf
Show file tree
Hide file tree
Showing 7 changed files with 423 additions and 362 deletions.
5 changes: 3 additions & 2 deletions LanguageWeaverProvider/ApplicationInitializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@ public class ApplicationInitializer : IApplicationInitializer
public static IDictionary<string, ITranslationOptions> TranslationOptions { get; set; }

public void Execute()
{
{
RatedSegments = new List<RatedSegment>();
TranslationOptions = new Dictionary<string, ITranslationOptions>();
CurrentAppVersion = GetAssemblyFileVersion();
}
Log.Setup();
}

public static Window GetBatchTaskWindow()
{
Expand Down
3 changes: 3 additions & 0 deletions LanguageWeaverProvider/LanguageWeaverProvider.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@
<Reference Include="Newtonsoft.Json">
<HintPath>$(TradosFolder)\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="NLog">
<HintPath>$(TradosFolder)\NLog.dll</HintPath>
</Reference>
<Reference Include="Sdl.Core.Globalization">
<HintPath>$(TradosFolder)\Sdl.Core.Globalization.dll</HintPath>
</Reference>
Expand Down
38 changes: 38 additions & 0 deletions LanguageWeaverProvider/Log.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using System;
using System.IO;
using System.Text;
using NLog;
using NLog.Config;
using NLog.Targets;

namespace LanguageWeaverProvider
{
public static class Log
{
public static void Setup()
{
LogManager.Configuration ??= new LoggingConfiguration();

var config = LogManager.Configuration;

var logDirectoryPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Trados AppStore",
"Language Weaver", "Logs");
Directory.CreateDirectory(logDirectoryPath);

var target = new FileTarget
{
Name = "LanguageWeaver",
FileName = Path.Combine(logDirectoryPath, "LanguageWeaverProvider.Logs.txt"),
ArchiveEvery = FileArchivePeriod.Day,
ArchiveNumbering = ArchiveNumberingMode.Date,
Encoding = Encoding.UTF8,
Layout = "${logger}: ${longdate} ${level} ${message} ${exception}"
};

config.AddTarget(target);
config.AddRuleForAllLevels(target, "*LanguageWeaverProvider*");

LogManager.ReconfigExistingLoggers();
}
}
}
25 changes: 15 additions & 10 deletions LanguageWeaverProvider/Model/CloudCredentials.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
namespace LanguageWeaverProvider.Model
{
public class CloudCredentials
public class CloudCredentials
{
public string AccountId { get; set; }
public string AccountId { get; set; }

public string AccountRegion { get; set; }
public string AccountRegion { get; set; }

public string UserName { get; set; }
public string ClientID { get; set; }
public string ClientSecret { get; set; }
public string ConnectionCode { get; set; }
public string UserName { get; set; }

public string UserPassword { get; set; }
public string UserPassword { get; set; }

public string ClientID { get; set; }

public string ClientSecret { get; set; }

public string ConnectionCode { get; set; }
public override string ToString()
{
var password = string.IsNullOrWhiteSpace(UserPassword) ? "NULL" : "PRESENT";
var clientSecret = string.IsNullOrWhiteSpace(ClientSecret) ? "NULL" : "PRESENT";
return $"AccountId: {AccountId}, AccountRegion: {AccountRegion}, UserName: {UserName}, " +
$"ClientID: {ClientID}, Password: {password}, ClientSecret: {clientSecret}, ConnectionCode: {ConnectionCode}";
}
}
}
2 changes: 1 addition & 1 deletion LanguageWeaverProvider/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@
// [assembly: AssemblyVersion("1.0.*")]

[assembly: AssemblyVersion("2.0.0.0")]
[assembly: AssemblyFileVersion("2.0.2.0")]
[assembly: AssemblyFileVersion("2.0.2.1")]
Loading

0 comments on commit 18f83cf

Please sign in to comment.