Skip to content

Commit

Permalink
- Enable user to override the default system paths for MyDocument & A…
Browse files Browse the repository at this point in the history
…pplicationData from a configuration file.

- Removed 'Sdl.Community.' from the assembly output names.
- Bumped release version to 5.1.6.0

Details:
Starting with this latest release, a new configuration file 'Qualitivity.config' is now unpacked in plugins folder (e.g. ...\Trados\Trados Studio\17\Plugins\Unpacked\Qualitivity\Qualitivity.config).  You will find two new properties MyDocumentsPath & ApplicationDataPath that enable the user to override these default paths from the system.
Note: It is possible to specify the same folder for both.  If the folder/s specified are empty or not valid, then the default system path/s will be used.

Example: (Qualitivity.dll.config)
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
 <appSettings>
  <add key="MyDocumentsPath" value="C:\Temp\" />
  <add key="ApplicationDataPath" value="C:\Temp\" />
 </appSettings>
</configuration>
  • Loading branch information
Impertatore committed Dec 28, 2022
1 parent e423408 commit bec81ee
Show file tree
Hide file tree
Showing 15 changed files with 170 additions and 113 deletions.
4 changes: 2 additions & 2 deletions Qualitivity/Build/SolutionInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@

[assembly: AssemblyProductAttribute("Qualitivity")]
[assembly: AssemblyVersionAttribute("5.0.0.0")]
[assembly: AssemblyFileVersionAttribute("5.1.5.1")]
[assembly: AssemblyFileVersionAttribute("5.1.6.0")]
[assembly: ComVisibleAttribute(false)]
namespace System
{
internal static class AssemblyVersionInformation
{
internal const System.String AssemblyProduct = "Qualitivity";
internal const System.String AssemblyVersion = "5.0.0.0";
internal const System.String AssemblyFileVersion = "5.1.5.1";
internal const System.String AssemblyFileVersion = "5.1.6.0";
internal const System.Boolean ComVisible = false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Sdl.Community.Comparison</RootNamespace>
<AssemblyName>Sdl.Community.Qualitivity.Comparison</AssemblyName>
<AssemblyName>Qualitivity.Comparison</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
Expand Down Expand Up @@ -68,4 +68,4 @@
</None>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Sdl.Community.Hooks</RootNamespace>
<AssemblyName>Sdl.Community.Qualitivity.Hooks</AssemblyName>
<AssemblyName>Qualitivity.Hooks</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,74 +1,115 @@
using System;
using System.Configuration;
using System.IO;
using System.Linq;
using System.Reflection;

namespace Sdl.Community.Structures.Configuration
{
[Serializable]
public class ApplicationPaths : ICloneable
{
public string ApplicationSettingsPath { get; set; }

public string ApplicationTrackChangesPath { get; set; }
public string ApplicationTrackChangesReportPath { get; set; }

public string ApplicationMyDocumentsPath { get; set; }
public string ApplicationMyDocumentsDatabasePath { get; set; }
public string ApplicationMyDocumentsDatabaseSettingsPath { get; set; }
public string ApplicationMyDocumentsDatabaseProjectsPath { get; set; }

public string ApplicationBackupDatabasePath { get; set; }

public ApplicationPaths()
{
ApplicationSettingsPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Qualitivity");
if (!Directory.Exists(ApplicationSettingsPath))
Directory.CreateDirectory(ApplicationSettingsPath);


ApplicationTrackChangesPath = Path.Combine(ApplicationSettingsPath, "Track.Changes");
if (!Directory.Exists(ApplicationTrackChangesPath))
Directory.CreateDirectory(ApplicationTrackChangesPath);

ApplicationTrackChangesReportPath = Path.Combine(ApplicationTrackChangesPath, "Reports");
if (!Directory.Exists(ApplicationTrackChangesReportPath))
Directory.CreateDirectory(ApplicationTrackChangesReportPath);


ApplicationMyDocumentsPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Qualitivity");
if (!Directory.Exists(ApplicationMyDocumentsPath))
Directory.CreateDirectory(ApplicationMyDocumentsPath);
ApplicationMyDocumentsDatabasePath = Path.Combine(ApplicationMyDocumentsPath, "Database");
if (!Directory.Exists(ApplicationMyDocumentsDatabasePath))
Directory.CreateDirectory(ApplicationMyDocumentsDatabasePath);
ApplicationMyDocumentsDatabaseSettingsPath = Path.Combine(ApplicationMyDocumentsDatabasePath, "Settings.sqlite");
ApplicationMyDocumentsDatabaseProjectsPath = Path.Combine(ApplicationMyDocumentsDatabasePath, "Projects.sqlite");




ApplicationBackupDatabasePath = Path.Combine(ApplicationMyDocumentsDatabasePath, "Backups");
if (!Directory.Exists(ApplicationBackupDatabasePath))
Directory.CreateDirectory(ApplicationBackupDatabasePath);
}

public object Clone()
{
var applicationPaths = new ApplicationPaths
{
ApplicationSettingsPath = ApplicationSettingsPath,
ApplicationTrackChangesPath = ApplicationTrackChangesPath,
ApplicationTrackChangesReportPath = ApplicationTrackChangesReportPath,
ApplicationMyDocumentsPath = ApplicationMyDocumentsPath,
ApplicationMyDocumentsDatabasePath = ApplicationMyDocumentsDatabasePath,
ApplicationBackupDatabasePath = ApplicationBackupDatabasePath
};






return applicationPaths;
}
}
[Serializable]
public class ApplicationPaths : ICloneable
{
public string ApplicationSettingsPath { get; set; }

public string ApplicationTrackChangesPath { get; set; }
public string ApplicationTrackChangesReportPath { get; set; }

public string ApplicationMyDocumentsPath { get; set; }
public string ApplicationMyDocumentsDatabasePath { get; set; }
public string ApplicationMyDocumentsDatabaseSettingsPath { get; set; }
public string ApplicationMyDocumentsDatabaseProjectsPath { get; set; }

public string ApplicationBackupDatabasePath { get; set; }

const string MyDocumentsPath = "MyDocumentsPath";
const string ApplicationDataPath = "ApplicationDataPath";

public ApplicationPaths()
{
var location = Assembly.GetExecutingAssembly().Location;
var unpackedFolder = location.Substring(0, location.LastIndexOf("\\", StringComparison.Ordinal));

var assembly = Path.Combine(unpackedFolder, "Qualitivity.dll");
var config = ConfigurationManager.OpenExeConfiguration(assembly);

var myDocumentsPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
var applicationDataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);

if (config.AppSettings?.Settings != null)
{
var myDocumentsPathCustom = GetConfigValue(config, MyDocumentsPath);
if (myDocumentsPathCustom != null)
{
myDocumentsPath = myDocumentsPathCustom;
}

var applicationDataPathCustom = GetConfigValue(config, ApplicationDataPath);
if (applicationDataPathCustom != null)
{
applicationDataPath = applicationDataPathCustom;
}
}

ApplicationMyDocumentsPath = Path.Combine(myDocumentsPath, "Qualitivity");
if (!Directory.Exists(ApplicationMyDocumentsPath))
Directory.CreateDirectory(ApplicationMyDocumentsPath);

ApplicationMyDocumentsDatabasePath = Path.Combine(ApplicationMyDocumentsPath, "Database");
if (!Directory.Exists(ApplicationMyDocumentsDatabasePath))
Directory.CreateDirectory(ApplicationMyDocumentsDatabasePath);

ApplicationMyDocumentsDatabaseSettingsPath = Path.Combine(ApplicationMyDocumentsDatabasePath, "Settings.sqlite");
ApplicationMyDocumentsDatabaseProjectsPath = Path.Combine(ApplicationMyDocumentsDatabasePath, "Projects.sqlite");

ApplicationBackupDatabasePath = Path.Combine(ApplicationMyDocumentsDatabasePath, "Backups");
if (!Directory.Exists(ApplicationBackupDatabasePath))
Directory.CreateDirectory(ApplicationBackupDatabasePath);

ApplicationSettingsPath = Path.Combine(applicationDataPath, "Qualitivity");
if (!Directory.Exists(ApplicationSettingsPath))
Directory.CreateDirectory(ApplicationSettingsPath);

ApplicationTrackChangesPath = Path.Combine(ApplicationSettingsPath, "Track.Changes");
if (!Directory.Exists(ApplicationTrackChangesPath))
Directory.CreateDirectory(ApplicationTrackChangesPath);

ApplicationTrackChangesReportPath = Path.Combine(ApplicationTrackChangesPath, "Reports");
if (!Directory.Exists(ApplicationTrackChangesReportPath))
Directory.CreateDirectory(ApplicationTrackChangesReportPath);
}

private static string GetConfigValue(System.Configuration.Configuration config, string propertyName)
{
if (config.AppSettings.Settings.AllKeys.Any(a => a == propertyName))
{
var value = config.AppSettings.Settings[propertyName].Value;
if (value != null && Directory.Exists(value))
{
return value;
}
}

return null;
}

public object Clone()
{
var applicationPaths = new ApplicationPaths
{
ApplicationSettingsPath = ApplicationSettingsPath,
ApplicationTrackChangesPath = ApplicationTrackChangesPath,
ApplicationTrackChangesReportPath = ApplicationTrackChangesReportPath,
ApplicationMyDocumentsPath = ApplicationMyDocumentsPath,
ApplicationMyDocumentsDatabasePath = ApplicationMyDocumentsDatabasePath,
ApplicationBackupDatabasePath = ApplicationBackupDatabasePath
};






return applicationPaths;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Sdl.Community.Structures</RootNamespace>
<AssemblyName>Sdl.Community.Qualitivity.Models</AssemblyName>
<AssemblyName>Qualitivity.Models</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
Expand Down Expand Up @@ -44,6 +44,7 @@
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Design" />
<Reference Include="System.Drawing" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Sdl.Community.Parser</RootNamespace>
<AssemblyName>Sdl.Community.Qualitivity.Parser</AssemblyName>
<AssemblyName>Qualitivity.Parser</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
Expand All @@ -8,7 +8,7 @@
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Sdl.Community.Report</RootNamespace>
<AssemblyName>Sdl.Community.Qualitivity.Report</AssemblyName>
<AssemblyName>Qualitivity.Report</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
Expand All @@ -8,7 +8,7 @@
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Sdl.Community.TM</RootNamespace>
<AssemblyName>Sdl.Community.Qualitivity.TM</AssemblyName>
<AssemblyName>Qualitivity.TM</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Sdl.Community.WPFListView</RootNamespace>
<AssemblyName>Sdl.Community.Qualitivity.WPFListView</AssemblyName>
<AssemblyName>Qualitivity.WPFListView</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
Expand Down
7 changes: 7 additions & 0 deletions Qualitivity/Sdl.Community.Qualitivity/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="MyDocumentsPath" value="C:\Temp\MyDocumentsPath" />
<add key="ApplicationDataPath" value="C:\Temp\ApplicationDataPath" />
</appSettings>
</configuration>
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Sdl.Community.Qualitivity</RootNamespace>
<AssemblyName>Sdl.Community.Qualitivity</AssemblyName>
<AssemblyName>Qualitivity</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileUpgradeFlags>
</FileUpgradeFlags>
Expand Down Expand Up @@ -111,6 +111,7 @@
<HintPath>$(MSBuildProgramFiles32)\Trados\Trados Studio\Studio17\Sdl.TranslationStudioAutomation.IntegrationApi.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Data" />
<Reference Include="System.Data.SQLite">
Expand Down Expand Up @@ -191,12 +192,6 @@
<DependentUpon>QualityMetricWeightsAppend.cs</DependentUpon>
</Compile>
<Compile Include="EditDistance.cs" />
<Compile Include="Dialogs\About.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Dialogs\About.Designer.cs">
<DependentUpon>About.cs</DependentUpon>
</Compile>
<Compile Include="Dialogs\AddressDetails.cs">
<SubType>Form</SubType>
</Compile>
Expand Down Expand Up @@ -389,10 +384,6 @@
<Content Include="Resources\Timer.ico" />
<Content Include="Resources\Timetable.ico" />
<Content Include="Resources\Users-simple.ico" />
<EmbeddedResource Include="Dialogs\About.resx">
<DependentUpon>About.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Dialogs\ActivityReportWizard.resx">
<DependentUpon>ActivityReportWizard.cs</DependentUpon>
<SubType>Designer</SubType>
Expand Down Expand Up @@ -544,6 +535,7 @@
<None Include="..\..\SdlCommunity.snk">
<Link>SdlCommunity.snk</Link>
</None>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<WCFMetadata Include="Service References\" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace Sdl.Community.Qualitivity.Tracking
{
public class TrackedController
{

private static string _productName = "Studio 2022";

private static ContentGenerator _contentProcessor;

Expand Down Expand Up @@ -107,6 +107,7 @@ public static void TrackNewDocumentEntry(IStudioDocument doc)
{
Id = file.Id.ToString(),
Name = file.Name,
ProductName = _productName,
SourceLanguage = project.SourceLanguage,
TargetLanguage = doc.ActiveFile.Language.CultureInfo.Name
};
Expand Down Expand Up @@ -507,8 +508,9 @@ public static List<StateCountItem> InitializeDocumentStatisticalState(IStudioDoc
var sourceLanguage = doc.ActiveFileProperties.FileConversionProperties.SourceLanguage.CultureInfo;
var targetLanguage = doc.ActiveFileProperties.FileConversionProperties.TargetLanguage.CultureInfo;

var pathInfo = new Trados.Community.Toolkit.LanguagePlatform.Models.PathInfo(_productName);
var segmentPairProcessor = new SegmentPairProcessor(
new Trados.Community.Toolkit.LanguagePlatform.Models.Settings(sourceLanguage, targetLanguage), new Trados.Community.Toolkit.LanguagePlatform.Models.PathInfo());
new Trados.Community.Toolkit.LanguagePlatform.Models.Settings(sourceLanguage, targetLanguage), pathInfo);

var parser = new ContentGenerator();

Expand Down
Loading

0 comments on commit bec81ee

Please sign in to comment.