-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 8debb82
Showing
16 changed files
with
1,106 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
using Newtonsoft.Json.Linq; | ||
using RestSharp; | ||
using System; | ||
using Newtonsoft.Json; | ||
|
||
|
||
namespace TestConsoleApp | ||
{ | ||
class Program | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
|
||
var token = Authenticate(); | ||
|
||
String worker = "5637145201"; | ||
String date = "2019-09-05"; | ||
String hours = "4"; | ||
String project = "00000101"; | ||
String activity = "W00002480"; | ||
String dataAreaId = "ussi"; | ||
|
||
var entryId = WriteEntry(token, worker, date); | ||
WriteDetails(token, worker, date, entryId, project, activity, hours, dataAreaId); | ||
|
||
date = "2019-09-06"; | ||
hours = "5"; | ||
activity = "W00002388"; | ||
|
||
entryId = WriteEntry(token, worker, date); | ||
WriteDetails(token, worker, date, entryId, project, activity, hours, dataAreaId); | ||
} | ||
|
||
private static string Authenticate() | ||
{ | ||
String id = "abcd3f06-f260-48f7-adad-6ae62a81374f"; | ||
String secret = "SOqbCvR5skVbS23fips5iwd14aANiM8uPQbJZGWIqAA="; | ||
String resource = "00000015-0000-0000-c000-000000000000"; | ||
|
||
|
||
// authenticate | ||
|
||
var client = new RestClient("https://login.windows.net/adacta-group.com/oauth2/token"); | ||
var request = new RestRequest(Method.POST); | ||
request.AddHeader("cache-control", "no-cache"); | ||
request.AddHeader("content-type", "application/x-www-form-urlencoded"); | ||
request.AddParameter("application/x-www-form-urlencoded", "grant_type=client_credentials&scope=all&client_id=" + id + "&client_secret=" + secret + "&resource=" + resource, ParameterType.RequestBody); | ||
IRestResponse response = client.Execute(request); | ||
|
||
dynamic resp = JObject.Parse(response.Content); | ||
String token = resp.access_token; | ||
|
||
return token; | ||
} | ||
|
||
private static long WriteEntry(String token, String worker, string date) | ||
{ | ||
|
||
var client = new RestClient("https://ad-ctp-10-38eb6867baef10230aos.cloudax.dynamics.com/api/services/TSTimesheetServices/TSTimesheetSubmissionService/findOrCreateTimesheet"); | ||
var request = new RestRequest(Method.POST); | ||
request.AddHeader("authorization", "Bearer " + token); | ||
request.AddHeader("Content-Type", "application/json"); | ||
|
||
request.RequestFormat = DataFormat.Json; | ||
request.AddBody(new { _resource = worker, _timesheetDate = date }); | ||
|
||
|
||
var response = client.Execute(request); | ||
dynamic resp = JObject.Parse(response.Content); | ||
|
||
var headerId = (long)resp.parmHeaderRecId; | ||
|
||
return headerId; | ||
} | ||
|
||
private static void WriteDetails(String token, String worker, string date, long headerId, String project, String activity, string hours, String dataAreaId) | ||
{ | ||
var entry = new JObject | ||
{ | ||
{ "parmResource", worker }, | ||
{ "parmTimesheetNumber", headerId }, | ||
{ "parmProjectDataAreaId", dataAreaId }, | ||
{ "parmProjId", project }, | ||
{ "parmProjActivityNumber", activity }, | ||
{ "parmEntryDate", date }, | ||
{ "parmHrsPerDay", 4 }, | ||
{ "customFields", new JArray() }, | ||
}; | ||
var eList = new JArray(); | ||
eList.Add(entry); | ||
|
||
var entryList = new JObject | ||
{ | ||
{"entryList", eList } | ||
}; | ||
|
||
|
||
var tsEntryList = new JObject | ||
{ | ||
{ "_tsTimesheetEntryList", entryList } | ||
}; | ||
|
||
var client = new RestClient("https://ad-ctp-10-38eb6867baef10230aos.cloudax.dynamics.com/api/services/TSTimesheetServices/TSTimesheetSubmissionService/createOrUpdateTimesheetLine"); | ||
var request = new RestRequest(Method.POST); | ||
request.AddHeader("authorization", "Bearer " + token); | ||
request.AddHeader("Content-Type", "application/json"); | ||
|
||
request.RequestFormat = DataFormat.Json; | ||
request.AddBody(tsEntryList); | ||
|
||
dynamic response = client.Execute(request); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>netcoreapp2.1</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" /> | ||
<PackageReference Include="RestSharp" Version="106.6.10" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 16 | ||
VisualStudioVersion = 16.0.29306.81 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestConsoleApp", "TestConsoleApp.csproj", "{F93A5C29-D545-4492-94CC-3848D197349E}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{F93A5C29-D545-4492-94CC-3848D197349E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{F93A5C29-D545-4492-94CC-3848D197349E}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{F93A5C29-D545-4492-94CC-3848D197349E}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{F93A5C29-D545-4492-94CC-3848D197349E}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {0D622C51-D919-42D0-BD2B-5E05E2D2DAC2} | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
//------------------------------------------------------------------------------ | ||
// <auto-generated> | ||
// This code was generated by a tool. | ||
// Runtime Version:4.0.30319.42000 | ||
// | ||
// Changes to this file may cause incorrect behavior and will be lost if | ||
// the code is regenerated. | ||
// </auto-generated> | ||
//------------------------------------------------------------------------------ | ||
|
||
using System; | ||
using System.Reflection; | ||
|
||
[assembly: System.Reflection.AssemblyCompanyAttribute("TestConsoleApp")] | ||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] | ||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] | ||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")] | ||
[assembly: System.Reflection.AssemblyProductAttribute("TestConsoleApp")] | ||
[assembly: System.Reflection.AssemblyTitleAttribute("TestConsoleApp")] | ||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] | ||
|
||
// Generated by the MSBuild WriteCodeFragment class. | ||
|
1 change: 1 addition & 0 deletions
1
obj/Debug/netcoreapp2.1/TestConsoleApp.AssemblyInfoInputs.cache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
a676e243b1295936b605dbe10d65fe3d8fc23819 |
Binary file not shown.
1 change: 1 addition & 0 deletions
1
obj/Debug/netcoreapp2.1/TestConsoleApp.csproj.CoreCompileInputs.cache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
070833df26c6a310da80858c371f698a297abf90 |
11 changes: 11 additions & 0 deletions
11
obj/Debug/netcoreapp2.1/TestConsoleApp.csproj.FileListAbsolute.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
C:\Users\grt\source\repos\TestConsoleApp\obj\Debug\netcoreapp2.1\TestConsoleApp.csprojAssemblyReference.cache | ||
C:\Users\grt\source\repos\TestConsoleApp\obj\Debug\netcoreapp2.1\TestConsoleApp.csproj.CoreCompileInputs.cache | ||
C:\Users\grt\source\repos\TestConsoleApp\obj\Debug\netcoreapp2.1\TestConsoleApp.AssemblyInfoInputs.cache | ||
C:\Users\grt\source\repos\TestConsoleApp\obj\Debug\netcoreapp2.1\TestConsoleApp.AssemblyInfo.cs | ||
C:\Users\grt\source\repos\TestConsoleApp\bin\Debug\netcoreapp2.1\TestConsoleApp.deps.json | ||
C:\Users\grt\source\repos\TestConsoleApp\bin\Debug\netcoreapp2.1\TestConsoleApp.runtimeconfig.json | ||
C:\Users\grt\source\repos\TestConsoleApp\bin\Debug\netcoreapp2.1\TestConsoleApp.runtimeconfig.dev.json | ||
C:\Users\grt\source\repos\TestConsoleApp\bin\Debug\netcoreapp2.1\TestConsoleApp.dll | ||
C:\Users\grt\source\repos\TestConsoleApp\bin\Debug\netcoreapp2.1\TestConsoleApp.pdb | ||
C:\Users\grt\source\repos\TestConsoleApp\obj\Debug\netcoreapp2.1\TestConsoleApp.dll | ||
C:\Users\grt\source\repos\TestConsoleApp\obj\Debug\netcoreapp2.1\TestConsoleApp.pdb |
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"version": 1, | ||
"dgSpecHash": "8QPiUGsIKVy2nmJdFS1jx/OAyo4M6lmE9r8Rq+J7vPtHaC1AOTJwTTg249MPeYpd1xHbIgAUCoVNFKHjPFqVbA==", | ||
"success": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
{ | ||
"format": 1, | ||
"restore": { | ||
"C:\\Users\\grt\\source\\repos\\TestConsoleApp\\TestConsoleApp.csproj": {} | ||
}, | ||
"projects": { | ||
"C:\\Users\\grt\\source\\repos\\TestConsoleApp\\TestConsoleApp.csproj": { | ||
"version": "1.0.0", | ||
"restore": { | ||
"projectUniqueName": "C:\\Users\\grt\\source\\repos\\TestConsoleApp\\TestConsoleApp.csproj", | ||
"projectName": "TestConsoleApp", | ||
"projectPath": "C:\\Users\\grt\\source\\repos\\TestConsoleApp\\TestConsoleApp.csproj", | ||
"packagesPath": "C:\\Users\\grt\\.nuget\\packages\\", | ||
"outputPath": "C:\\Users\\grt\\source\\repos\\TestConsoleApp\\obj\\", | ||
"projectStyle": "PackageReference", | ||
"fallbackFolders": [ | ||
"C:\\Program Files\\dotnet\\sdk\\NuGetFallbackFolder" | ||
], | ||
"configFilePaths": [ | ||
"C:\\Users\\grt\\AppData\\Roaming\\NuGet\\NuGet.Config", | ||
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config" | ||
], | ||
"originalTargetFrameworks": [ | ||
"netcoreapp2.1" | ||
], | ||
"sources": { | ||
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {}, | ||
"https://api.nuget.org/v3/index.json": {} | ||
}, | ||
"frameworks": { | ||
"netcoreapp2.1": { | ||
"projectReferences": {} | ||
} | ||
}, | ||
"warningProperties": { | ||
"warnAsError": [ | ||
"NU1605" | ||
] | ||
} | ||
}, | ||
"frameworks": { | ||
"netcoreapp2.1": { | ||
"dependencies": { | ||
"Microsoft.NETCore.App": { | ||
"target": "Package", | ||
"version": "[2.1.0, )", | ||
"autoReferenced": true | ||
}, | ||
"Newtonsoft.Json": { | ||
"target": "Package", | ||
"version": "[12.0.2, )" | ||
}, | ||
"RestSharp": { | ||
"target": "Package", | ||
"version": "[106.6.10, )" | ||
} | ||
}, | ||
"imports": [ | ||
"net461" | ||
], | ||
"assetTargetFallback": true, | ||
"warn": true | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0" encoding="utf-8" standalone="no"?> | ||
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' "> | ||
<RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess> | ||
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool> | ||
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile> | ||
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">$(UserProfile)\.nuget\packages\</NuGetPackageRoot> | ||
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">C:\Users\grt\.nuget\packages\;C:\Program Files\dotnet\sdk\NuGetFallbackFolder</NuGetPackageFolders> | ||
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle> | ||
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">5.2.0</NuGetToolVersion> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects> | ||
</PropertyGroup> | ||
<ImportGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' "> | ||
<Import Project="C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app\2.1.0\build\netcoreapp2.1\Microsoft.NETCore.App.props" Condition="Exists('C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app\2.1.0\build\netcoreapp2.1\Microsoft.NETCore.App.props')" /> | ||
</ImportGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0" encoding="utf-8" standalone="no"?> | ||
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects> | ||
</PropertyGroup> | ||
<ImportGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' "> | ||
<Import Project="C:\Program Files\dotnet\sdk\NuGetFallbackFolder\netstandard.library\2.0.3\build\netstandard2.0\NETStandard.Library.targets" Condition="Exists('C:\Program Files\dotnet\sdk\NuGetFallbackFolder\netstandard.library\2.0.3\build\netstandard2.0\NETStandard.Library.targets')" /> | ||
<Import Project="C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app\2.1.0\build\netcoreapp2.1\Microsoft.NETCore.App.targets" Condition="Exists('C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.netcore.app\2.1.0\build\netcoreapp2.1\Microsoft.NETCore.App.targets')" /> | ||
</ImportGroup> | ||
</Project> |
Oops, something went wrong.