Skip to content

Commit 78243d6

Browse files
oerodgervlabramov
andauthored
Merge pull request #31 from intento/release/2.2.24
CONTMS-117 Telemetry: 5XX on large project in Trados CONTMS-120 Trados: fix bug with < > in Deepl CONTMS-119 Add utm labels to the console link in the Trados app Co-authored-by: Vladimir Abramov <[email protected]>
2 parents 061c8a4 + 0d4c138 commit 78243d6

File tree

10 files changed

+91
-126
lines changed

10 files changed

+91
-126
lines changed

Intento.MT.Plugin.PropertiesForm.Test/Intento.MT.Plugin.PropertiesForm.Test.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="IntentoSDK" Version="1.5.3" />
10+
<PackageReference Include="IntentoSDK" Version="1.5.4" />
1111
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
1212
<PackageReference Include="NUnit" Version="3.12.0" />
1313
<PackageReference Include="NUnit3TestAdapter" Version="3.16.1" />

Intento.MT.Plugin.PropertiesForm/Intento.MT.Plugin.PropertiesForm.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@
3939
<AssemblyOriginatorKeyFile>intento_sn.snk</AssemblyOriginatorKeyFile>
4040
</PropertyGroup>
4141
<ItemGroup>
42-
<Reference Include="IntentoSDK, Version=1.5.3.0, Culture=neutral, PublicKeyToken=7fbf26cf2c5f5508, processorArchitecture=MSIL">
43-
<HintPath>..\..\packages\IntentoSDK.1.5.3\lib\net45\IntentoSDK.dll</HintPath>
42+
<Reference Include="IntentoSDK, Version=1.5.4.0, Culture=neutral, PublicKeyToken=7fbf26cf2c5f5508, processorArchitecture=MSIL">
43+
<HintPath>..\..\packages\IntentoSDK.1.5.4\lib\net45\IntentoSDK.dll</HintPath>
4444
</Reference>
4545
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
4646
<HintPath>..\..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>

Intento.MT.Plugin.PropertiesForm/Logs.cs

Lines changed: 67 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,44 @@
1-
using Intento.MT.Plugin.PropertiesForm;
2-
using Newtonsoft.Json.Linq;
1+
using Newtonsoft.Json.Linq;
32
using System;
3+
using System.Collections.Concurrent;
44
using System.Collections.Generic;
55
using System.IO;
6-
using System.Linq;
6+
using System.Net;
77
using System.Net.Http;
88
using System.Text;
9-
using System.Threading.Tasks;
9+
using System.Timers;
1010

1111
namespace Intento.MT.Plugin.PropertiesForm
1212
{
1313

1414
public static class Logs
1515
{
16+
/// <summary>
17+
/// Limiting the request rate, ms
18+
/// </summary>
19+
const int sleepTime = 5000;
20+
/// <summary>
21+
/// Limit of entries from the queue in one request
22+
/// </summary>
23+
const int maxEntries = 300;
24+
1625
static string _consumer_id;
1726
static string _session_id;
1827
public static string ApiKey { get; set; }
1928
public static string PluginName { get; set; }
2029

30+
/// <summary>
31+
/// A stream instance that checks the data queue and sends it to the cloud
32+
/// </summary>
33+
static Timer sender;
34+
35+
/// <summary>
36+
/// Data queue
37+
/// </summary>
38+
static ConcurrentQueue<KeyValuePair<char, string>> queue = new ConcurrentQueue<KeyValuePair<char, string>>();
39+
40+
const string url = "https://api.inten.to/telemetry/upload_json";
41+
2142
public static string ConsumerId
2243
{
2344
get
@@ -119,7 +140,7 @@ public static IEnumerable<string> LoggingEx(char identificator, Exception ex)
119140
return items;
120141
}
121142

122-
private static async void WriteRemoteLog(char identificator, string text)
143+
private static void WriteRemoteLog(char identificator, string text)
123144
{
124145
if (!IsLogging())
125146
return;
@@ -130,22 +151,51 @@ private static async void WriteRemoteLog(char identificator, string text)
130151
if (string.IsNullOrWhiteSpace(ApiKey))
131152
return;
132153

133-
dynamic jsonResult;
134-
string url = "https://api.inten.to/telemetry/upload_json";
135-
JObject data = new JObject();
136-
data["plugin_name"] = string.Format("{0}-{1}", PluginName, identificator);
137-
data["session_id"] = SessionId;
138-
data["logs"] = text;
139-
var content = new StringContent(data.ToString(), Encoding.UTF8, "application/json");
140-
// Call to Intento API
141-
using (var conn = new HttpClient())
154+
queue.Enqueue(new KeyValuePair<char, string>(identificator, text));
155+
if (sender == null)
142156
{
143-
conn.DefaultRequestHeaders.Add("apikey", ApiKey);
144-
conn.DefaultRequestHeaders.Add("x-consumer-id", ConsumerId);
145-
jsonResult = await conn.PostAsync(url, content);
157+
sender = new Timer();
158+
sender.Interval = sleepTime;
159+
sender.Elapsed += OnTimedEvent;
160+
sender.Start();
146161
}
147162
}
163+
private static async void OnTimedEvent(Object source, ElapsedEventArgs e)
164+
{
165+
try
166+
{
167+
Dictionary<char, string> inprogress = new Dictionary<char, string>();
168+
KeyValuePair<char, string> item;
169+
JObject data = new JObject();
170+
data["session_id"] = SessionId;
171+
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
172+
dynamic jsonResult;
173+
int entries = 0;
174+
while (queue.TryDequeue(out item) && entries < maxEntries)
175+
{
176+
if (inprogress.ContainsKey(item.Key))
177+
inprogress[item.Key] += "\n" + item.Value;
178+
else
179+
inprogress.Add(item.Key, item.Value);
180+
entries++;
181+
}
148182

183+
foreach (KeyValuePair<char, string> kp in inprogress)
184+
{
185+
data["plugin_name"] = string.Format("{0}-{1}", PluginName, kp.Key);
186+
data["logs"] = kp.Value;
187+
var content = new StringContent(data.ToString(), Encoding.UTF8, "application/json");
188+
// Call to Intento API
189+
using (var conn = new HttpClient())
190+
{
191+
conn.DefaultRequestHeaders.Add("apikey", ApiKey);
192+
conn.DefaultRequestHeaders.Add("x-consumer-id", ConsumerId);
193+
jsonResult = await conn.PostAsync(url, content);
194+
}
195+
}
196+
}
197+
catch { }
198+
}
149199
}
150200

151201
}

Intento.MT.Plugin.PropertiesForm/PluginHelper.cs

Lines changed: 1 addition & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -8,92 +8,7 @@ namespace Intento.MT.Plugin.PropertiesForm
88
{
99
public static class PluginHelper
1010
{
11-
private static IReadOnlyDictionary<string, string> specialCodesIn
12-
= new Dictionary<string, string>
13-
{
14-
{ "&amp;gt;" , "<tph1/>" },
15-
{ "&amp;lt;" , "<tph2/>" },
16-
{ "&lt;" , "<tph3/>" },
17-
{ "&gt;" , "<tph4/>" }
18-
};
19-
20-
private static IReadOnlyDictionary<string, string> specialCodesOut
21-
= new Dictionary<string, string>
22-
{
23-
{ "<tph1>" , "&amp;gt;" },
24-
{ "<tph2>" , "&amp;lt;" },
25-
{ "<tph3>" , "&lt;" },
26-
{ "<tph4>" , "&gt;" },
27-
{ "<tph1/>", "&amp;gt;" },
28-
{ "<tph2/>", "&amp;lt;" },
29-
{ "<tph3/>", "&lt;" },
30-
{ "<tph4/>", "&gt;" },
31-
{ "<tph1 />", "&amp;gt;" },
32-
{ "<tph2 />", "&amp;lt;" },
33-
{ "<tph3 />", "&lt;" },
34-
{ "<tph4 />", "&gt;" },
35-
{ "</tph1>", "" },
36-
{ "</tph2>", "" },
37-
{ "</tph3>", "" },
38-
{ "</tph4>", "" }
39-
};
40-
41-
public static string PrepareText(string format, string data)
42-
{
43-
// Remove parasite character for memoq
44-
data = new string(data.Where(c => (int)c != 9727).ToArray());
45-
46-
// Replacing some HTML codes with special tags
47-
foreach (KeyValuePair<string, string> pair in specialCodesIn)
48-
{
49-
data = data.Replace(pair.Key, pair.Value);
50-
}
51-
if (format == "xml")
52-
return string.Format("<root>{0}</root>", data);
53-
return data;
54-
}
55-
56-
public static string PrepareResult(string format, string text)
57-
{
58-
// Return HTML codes instead of special tags
59-
foreach (KeyValuePair<string, string> pair in specialCodesOut)
60-
{
61-
text = text.Replace(pair.Key, pair.Value);
62-
}
63-
if (format == "xml")
64-
{
65-
// Remove <? > tag
66-
int n1 = text.IndexOf("<?");
67-
string text2 = text;
68-
if (n1 != -1)
69-
{
70-
int n2 = text.IndexOf(">");
71-
text2 = text.Substring(n2 + 1);
72-
}
73-
74-
// Remove <root> and </root> tags
75-
string text3 = text2.Replace("<root>", "").Replace("</root>", "");
76-
return text3;
77-
}
78-
79-
if (format == "html")
80-
{
81-
// Remove <meta> and </meta> tags
82-
int n1 = text.IndexOf("<meta");
83-
string text2 = text;
84-
if (n1 != -1)
85-
{
86-
int n2 = text.IndexOf(">");
87-
text2 = text.Substring(n2 + 1);
88-
}
89-
90-
return text2;
91-
}
92-
93-
return text;
94-
}
95-
96-
public class ErrorInfo
11+
public class ErrorInfo
9712
{
9813
public bool isError;
9914
public string visibleErrorText;

Intento.MT.Plugin.PropertiesForm/Properties/Intento.MT.Plugin.PropertiesForm.nuspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
<package>
33
<metadata>
44
<id>Intento.MT.Plugin.PropertiesForm</id>
5-
<version>2.2.23.0</version>
5+
<version>2.2.24.0</version>
66
<authors>Intento</authors>
77
<owners>Intento</owners>
88
<requireLicenseAcceptance>false</requireLicenseAcceptance>
99
<description>A library with a settings form used in Intento momoQ plugin and Intento Trados plugin.</description>
1010
<copyright>Copyright © Intento 2018-2021</copyright>
1111
<dependencies>
12-
<dependency id="IntentoSDK" version="1.5.3.0" />
12+
<dependency id="IntentoSDK" version="1.5.4.0" />
1313
</dependencies>
1414
</metadata>
1515
<files>

Intento.MT.Plugin.PropertiesForm/WinForms/IntentoFormOptonsMain.Designer.cs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
<?xml version="1.0" encoding="utf-8"?>
2-
<packages>
3-
<package id="AWSSDK.Core" version="3.3.107.14" targetFramework="net45" />
4-
<package id="AWSSDK.S3" version="3.3.111.14" targetFramework="net45" />
5-
<package id="IntentoSDK" version="1.5.3" targetFramework="net45" />
6-
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net45" />
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<packages>
3+
<package id="IntentoSDK" version="1.5.4" targetFramework="net45" />
4+
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net45" />
75
</packages>

TestForm/App.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
88
<dependentAssembly>
99
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
10-
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
10+
<bindingRedirect oldVersion="0.0.0.0-4.5.0.0" newVersion="4.5.0.0" />
1111
</dependentAssembly>
1212
</assemblyBinding>
1313
</runtime>

TestForm/TestForm.csproj

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,11 @@
3232
<WarningLevel>4</WarningLevel>
3333
</PropertyGroup>
3434
<ItemGroup>
35-
<Reference Include="IntentoSDK">
36-
<HintPath>..\bin\IntentoSDK.dll</HintPath>
35+
<Reference Include="IntentoSDK, Version=1.5.4.0, Culture=neutral, PublicKeyToken=7fbf26cf2c5f5508, processorArchitecture=MSIL">
36+
<HintPath>..\..\packages\IntentoSDK.1.5.4\lib\net45\IntentoSDK.dll</HintPath>
3737
</Reference>
38-
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
39-
<SpecificVersion>False</SpecificVersion>
40-
<HintPath>..\bin\Newtonsoft.Json.dll</HintPath>
38+
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
39+
<HintPath>..\..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
4140
</Reference>
4241
<Reference Include="System" />
4342
<Reference Include="System.Core" />
@@ -97,7 +96,10 @@
9796
<None Include="App.config" />
9897
</ItemGroup>
9998
<ItemGroup>
100-
<Analyzer Include="..\..\Plugins\packages\AWSSDK.S3.3.5.0-beta\analyzers\dotnet\cs\AWSSDK.S3.CodeAnalysis.dll" />
99+
<ProjectReference Include="..\Intento.MT.Plugin.PropertiesForm\Intento.MT.Plugin.PropertiesForm.csproj">
100+
<Project>{a4374128-dd01-4ce3-b62c-4cc3460620c0}</Project>
101+
<Name>Intento.MT.Plugin.PropertiesForm</Name>
102+
</ProjectReference>
101103
</ItemGroup>
102104
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
103105
</Project>

TestForm/packages.config

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
<?xml version="1.0" encoding="utf-8"?>
2-
<packages>
3-
<package id="AWSSDK.Core" version="3.5.0-beta" targetFramework="net47" />
4-
<package id="AWSSDK.S3" version="3.5.0-beta" targetFramework="net47" />
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<packages>
3+
<package id="IntentoSDK" version="1.5.4" targetFramework="net47" />
4+
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net47" />
55
</packages>

0 commit comments

Comments
 (0)