Skip to content

Commit 9ecd038

Browse files
Including packaged solution and Plugin code
Including the Packaged managed and unmanaged solution. Including the Plugin source code for auto translation and the ribbon action from UI.
0 parents  commit 9ecd038

18 files changed

+1103
-0
lines changed

.gitignore

+236
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,236 @@
1+
## Ignore Visual Studio temporary files, build results, and
2+
## files generated by popular Visual Studio add-ons.
3+
4+
# User-specific files
5+
*.suo
6+
*.user
7+
*.userosscache
8+
*.sln.docstates
9+
10+
# User-specific files (MonoDevelop/Xamarin Studio)
11+
*.userprefs
12+
13+
# Build results
14+
[Dd]ebug/
15+
[Dd]ebugPublic/
16+
[Rr]elease/
17+
[Rr]eleases/
18+
x64/
19+
x86/
20+
bld/
21+
[Bb]in/
22+
[Oo]bj/
23+
24+
# Visual Studio 2015 cache/options directory
25+
.vs/
26+
# Uncomment if you have tasks that create the project's static files in wwwroot
27+
#wwwroot/
28+
29+
# MSTest test Results
30+
[Tt]est[Rr]esult*/
31+
[Bb]uild[Ll]og.*
32+
33+
# NUNIT
34+
*.VisualState.xml
35+
TestResult.xml
36+
37+
# Build Results of an ATL Project
38+
[Dd]ebugPS/
39+
[Rr]eleasePS/
40+
dlldata.c
41+
42+
# DNX
43+
project.lock.json
44+
artifacts/
45+
46+
*_i.c
47+
*_p.c
48+
*_i.h
49+
*.ilk
50+
*.meta
51+
*.obj
52+
*.pch
53+
*.pdb
54+
*.pgc
55+
*.pgd
56+
*.rsp
57+
*.sbr
58+
*.tlb
59+
*.tli
60+
*.tlh
61+
*.tmp
62+
*.tmp_proj
63+
*.log
64+
*.vspscc
65+
*.vssscc
66+
.builds
67+
*.pidb
68+
*.svclog
69+
*.scc
70+
71+
# Chutzpah Test files
72+
_Chutzpah*
73+
74+
# Visual C++ cache files
75+
ipch/
76+
*.aps
77+
*.ncb
78+
*.opendb
79+
*.opensdf
80+
*.sdf
81+
*.cachefile
82+
83+
# Visual Studio profiler
84+
*.psess
85+
*.vsp
86+
*.vspx
87+
*.sap
88+
89+
# TFS 2012 Local Workspace
90+
$tf/
91+
92+
# Guidance Automation Toolkit
93+
*.gpState
94+
95+
# ReSharper is a .NET coding add-in
96+
_ReSharper*/
97+
*.[Rr]e[Ss]harper
98+
*.DotSettings.user
99+
100+
# JustCode is a .NET coding add-in
101+
.JustCode
102+
103+
# TeamCity is a build add-in
104+
_TeamCity*
105+
106+
# DotCover is a Code Coverage Tool
107+
*.dotCover
108+
109+
# NCrunch
110+
_NCrunch_*
111+
.*crunch*.local.xml
112+
nCrunchTemp_*
113+
114+
# MightyMoose
115+
*.mm.*
116+
AutoTest.Net/
117+
118+
# Web workbench (sass)
119+
.sass-cache/
120+
121+
# Installshield output folder
122+
[Ee]xpress/
123+
124+
# DocProject is a documentation generator add-in
125+
DocProject/buildhelp/
126+
DocProject/Help/*.HxT
127+
DocProject/Help/*.HxC
128+
DocProject/Help/*.hhc
129+
DocProject/Help/*.hhk
130+
DocProject/Help/*.hhp
131+
DocProject/Help/Html2
132+
DocProject/Help/html
133+
134+
# Click-Once directory
135+
publish/
136+
137+
# Publish Web Output
138+
*.[Pp]ublish.xml
139+
*.azurePubxml
140+
# TODO: Comment the next line if you want to checkin your web deploy settings
141+
# but database connection strings (with potential passwords) will be unencrypted
142+
*.pubxml
143+
*.publishproj
144+
145+
# NuGet Packages
146+
*.nupkg
147+
# The packages folder can be ignored because of Package Restore
148+
**/packages/*
149+
# except build/, which is used as an MSBuild target.
150+
!**/packages/build/
151+
# Uncomment if necessary however generally it will be regenerated when needed
152+
#!**/packages/repositories.config
153+
# NuGet v3's project.json files produces more ignoreable files
154+
*.nuget.props
155+
*.nuget.targets
156+
157+
# Microsoft Azure Build Output
158+
csx/
159+
*.build.csdef
160+
161+
# Microsoft Azure Emulator
162+
ecf/
163+
rcf/
164+
165+
# Microsoft Azure ApplicationInsights config file
166+
ApplicationInsights.config
167+
168+
# Windows Store app package directory
169+
AppPackages/
170+
BundleArtifacts/
171+
172+
# Visual Studio cache files
173+
# files ending in .cache can be ignored
174+
*.[Cc]ache
175+
# but keep track of directories ending in .cache
176+
!*.[Cc]ache/
177+
178+
# Others
179+
ClientBin/
180+
~$*
181+
*~
182+
*.dbmdl
183+
*.dbproj.schemaview
184+
*.pfx
185+
*.publishsettings
186+
node_modules/
187+
orleans.codegen.cs
188+
189+
# RIA/Silverlight projects
190+
Generated_Code/
191+
192+
# Backup & report files from converting an old project file
193+
# to a newer Visual Studio version. Backup files are not needed,
194+
# because we have git ;-)
195+
_UpgradeReport_Files/
196+
Backup*/
197+
UpgradeLog*.XML
198+
UpgradeLog*.htm
199+
200+
# SQL Server files
201+
*.mdf
202+
*.ldf
203+
204+
# Business Intelligence projects
205+
*.rdl.data
206+
*.bim.layout
207+
*.bim_*.settings
208+
209+
# Microsoft Fakes
210+
FakesAssemblies/
211+
212+
# GhostDoc plugin setting file
213+
*.GhostDoc.xml
214+
215+
# Node.js Tools for Visual Studio
216+
.ntvs_analysis.dat
217+
218+
# Visual Studio 6 build log
219+
*.plg
220+
221+
# Visual Studio 6 workspace options file
222+
*.opt
223+
224+
# Visual Studio LightSwitch build output
225+
**/*.HTMLClient/GeneratedArtifacts
226+
**/*.DesktopClient/GeneratedArtifacts
227+
**/*.DesktopClient/ModelManifest.xml
228+
**/*.Server/GeneratedArtifacts
229+
**/*.Server/ModelManifest.xml
230+
_Pvt_Extensions
231+
232+
# Paket dependency manager
233+
.paket/paket.exe
234+
235+
# FAKE - F# Make
236+
.fake/
Binary file not shown.
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 2013
4+
VisualStudioVersion = 12.0.21005.1
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KnowledgeArticleTranslationSolution", "KnowledgeArticleTranslationSolution\KnowledgeArticleTranslationSolution.csproj", "{EC3D4A76-0127-491A-B9DE-D1CF61E42E22}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{EC3D4A76-0127-491A-B9DE-D1CF61E42E22}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{EC3D4A76-0127-491A-B9DE-D1CF61E42E22}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{EC3D4A76-0127-491A-B9DE-D1CF61E42E22}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{EC3D4A76-0127-491A-B9DE-D1CF61E42E22}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
EndGlobal
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using System.Runtime.Serialization;
2+
3+
namespace KnowledgeArticleTranslationSolution
4+
{
5+
/// <summary>
6+
/// Translator Access Token Class
7+
/// </summary>
8+
[DataContract]
9+
public class AdmAccessToken
10+
{
11+
[DataMember]
12+
public string access_token { get; set; }
13+
[DataMember]
14+
public string token_type { get; set; }
15+
[DataMember]
16+
public string expires_in { get; set; }
17+
[DataMember]
18+
public string scope { get; set; }
19+
}
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
using System.IO;
2+
using System.Net;
3+
using System.Runtime.Serialization.Json;
4+
using System.Text;
5+
6+
namespace KnowledgeArticleTranslationSolution
7+
{
8+
/// <summary>
9+
/// Translator Authentication Class
10+
/// </summary>
11+
public class AdmAuthentication
12+
{
13+
14+
public static readonly string DatamarketAccessUri = "https://datamarket.accesscontrol.windows.net/v2/OAuth2-13";
15+
private string clientId;
16+
private string clientSecret;
17+
private string request;
18+
19+
/// <summary>
20+
/// Authenticate with the Microsoft Translate.
21+
/// </summary>
22+
/// <param name="clientId">Client ID</param>
23+
/// <param name="clientSecret">Client Secret</param>
24+
public AdmAuthentication(string clientId, string clientSecret)
25+
{
26+
this.clientId = clientId;
27+
this.clientSecret = clientSecret;
28+
//If clientid or client secret has special characters, encode before sending request
29+
this.request = string.Format("grant_type=client_credentials&client_id={0}&client_secret={1}&scope=http://api.microsofttranslator.com", System.Net.WebUtility.UrlEncode(clientId), System.Net.WebUtility.UrlEncode(clientSecret));
30+
}
31+
32+
/// <summary>
33+
/// Returns the access token
34+
/// </summary>
35+
/// <returns>AdmAccessToken object</returns>
36+
public AdmAccessToken GetAccessToken()
37+
{
38+
return HttpPost(DatamarketAccessUri, this.request);
39+
}
40+
41+
/// <summary>
42+
/// This mehod used to post the request.
43+
/// </summary>
44+
/// <param name="DatamarketAccessUri">DatamarketAccessUri</param>
45+
/// <param name="requestDetails">requestDetails</param>
46+
/// <returns>AdmAccessToken object</returns>
47+
private AdmAccessToken HttpPost(string DatamarketAccessUri, string requestDetails)
48+
{
49+
//Prepare OAuth request
50+
WebRequest webRequest = WebRequest.Create(DatamarketAccessUri);
51+
webRequest.ContentType = "application/x-www-form-urlencoded";
52+
webRequest.Method = "POST";
53+
byte[] bytes = Encoding.ASCII.GetBytes(requestDetails);
54+
webRequest.ContentLength = bytes.Length;
55+
using (Stream outputStream = webRequest.GetRequestStream())
56+
{
57+
outputStream.Write(bytes, 0, bytes.Length);
58+
}
59+
using (WebResponse webResponse = webRequest.GetResponse())
60+
{
61+
DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(AdmAccessToken));
62+
//Get deserialized object from JSON stream
63+
AdmAccessToken token = (AdmAccessToken)serializer.ReadObject(webResponse.GetResponseStream());
64+
return token;
65+
}
66+
}
67+
}
68+
}

0 commit comments

Comments
 (0)