Skip to content

Commit e646599

Browse files
committed
v1.0.6
- Set drive "owned by" to uploading account.
1 parent 6cada20 commit e646599

File tree

5 files changed

+31
-24
lines changed

5 files changed

+31
-24
lines changed

CLARiNET.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<PackageIcon>CLARiNET.ico</PackageIcon>
88
<PackageIconUrl />
99
<ApplicationIcon>CLARiNET.ico</ApplicationIcon>
10-
<Version>1.0.5</Version>
10+
<Version>1.0.6</Version>
1111
</PropertyGroup>
1212

1313
<ItemGroup>

DriveApi.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace CLARiNET
99
{
1010
internal class DriveApi
1111
{
12-
public static string BuildSoapRequest(string file, string contents, bool trashed)
12+
public static string BuildSoapRequest(string file, string contents, string uploadedBy, bool trashed)
1313
{
1414
string xmlData = "";
1515
string delimiter = "~";
@@ -47,7 +47,12 @@ public static string BuildSoapRequest(string file, string contents, bool trashed
4747
xmlData = xmlData.Replace("{contents}", contents)
4848
.Replace("{document_wid}", wid)
4949
.Replace("{filename}", filename)
50-
.Replace("{username}", username);
50+
.Replace("{owned_by_username}", username)
51+
.Replace("{uploaded_by_username}", username);
52+
}
53+
else
54+
{
55+
throw new Exception("Could not parse file name or read input line.");
5156
}
5257

5358
return xmlData;

Program.cs

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,7 @@ static void Main(string[] args)
7070
}
7171

7272
// API Call
73-
string result = "";
74-
options.Username = options.Username + "@" + options.Tenant;
73+
string result = "";
7574
restUrl = cloudRepoUrl.Replace("{host}", host) + cloudCollection;
7675
soapUrl = soapUrl.Replace("{tenant}", options.Tenant).Replace("{version}", "v37.0");
7776

@@ -94,26 +93,29 @@ static void Main(string[] args)
9493
case Command.CLAR_UPLOAD:
9594
bytes = File.ReadAllBytes(file);
9695
Console.WriteLine("\n\nDeploying the CLAR and awaiting the result...\n\n");
97-
result = WDWebService.CallRest(options.Tenant, options.Username, options.Password, restUrl, "PUT", bytes);
96+
result = WDWebService.CallRest(options.Tenant, options.Username + "@" + options.Tenant, options.Password, restUrl, "PUT", bytes);
9897
break;
9998
case Command.DRIVE_UPLOAD:
10099
bytes = File.ReadAllBytes(file);
101-
result = DriveUpload(file, bytes, soapUrl);
100+
result = DriveUpload(file, bytes, soapUrl, options.Username);
102101
break;
103102
case Command.DRIVE_TRASH:
104-
result = DriveTrash(file, soapUrl);
103+
result = DriveTrash(file, soapUrl, options.Username);
105104
break;
106105
}
107106

108-
if (result.IndexOf("<?xml") < 0 && result.IndexOf("<SOAP") < 0)
107+
if (result.ToLower().IndexOf("<html") >= 0)
109108
{
110109
Console.WriteLine("No XML response detected. Workday may be unavailable or your parameters are incorrect.");
111110
}
112111
else
113112
{
114-
Console.WriteLine("Result for " + file + "\n");
115-
Console.WriteLine(result);
116-
Console.WriteLine("\n\n");
113+
if (!String.IsNullOrEmpty(result))
114+
{
115+
Console.WriteLine("Result for " + file + "\n");
116+
Console.WriteLine(result);
117+
Console.WriteLine("\n\n");
118+
}
117119
}
118120
}
119121
}
@@ -436,7 +438,7 @@ static string SoapUrlBuild()
436438
return soapUrl;
437439
}
438440

439-
static string DriveUpload(string file, byte[] bytes, string soapUrl)
441+
static string DriveUpload(string file, byte[] bytes, string soapUrl, string uploadedBy)
440442
{
441443
string result = "";
442444
try
@@ -445,8 +447,8 @@ static string DriveUpload(string file, byte[] bytes, string soapUrl)
445447
{
446448
Console.WriteLine("\n\nUploading " + file + " to Drive and awaiting the result...\n\n");
447449
string fileContents = Convert.ToBase64String(bytes);
448-
string xmlData = DriveApi.BuildSoapRequest(file, fileContents, false);
449-
result = WDWebService.CallAPI(options.Username, options.Password, soapUrl, xmlData);
450+
string xmlData = DriveApi.BuildSoapRequest(file, fileContents, uploadedBy, false);
451+
result = WDWebService.CallAPI(options.Username + "@" + options.Tenant, options.Password, soapUrl, xmlData);
450452
if (result.IndexOf("<?xml") == 0)
451453
{
452454
string processedFile = Path.Combine(processedDir, Path.GetFileName(file));
@@ -469,16 +471,16 @@ static string DriveUpload(string file, byte[] bytes, string soapUrl)
469471
return result;
470472
}
471473

472-
static string DriveTrash(string file, string soapUrl)
474+
static string DriveTrash(string file, string soapUrl, string uploadedBy)
473475
{
474476
string result = "";
475477
try
476478
{
477479
if (file.Trim().Length > 0)
478480
{
479481
Console.WriteLine("\n\nTrashing " + file + " in Drive and awaiting the result...\n\n");
480-
string xmlData = DriveApi.BuildSoapRequest(file, "", true);
481-
result = WDWebService.CallAPI(options.Username, options.Password, soapUrl, xmlData);
482+
string xmlData = DriveApi.BuildSoapRequest(file, "", uploadedBy, true);
483+
result = WDWebService.CallAPI(options.Username + "@" + options.Tenant, options.Password, soapUrl, xmlData);
482484
}
483485
}
484486
catch (Exception ex)

Resources.Designer.cs

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Resources.resx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,12 @@
126126
&lt;bsvc:Workdrive_Item_Generic_Data&gt;
127127
&lt;bsvc:Drive_Item_Name&gt;{filename}&lt;/bsvc:Drive_Item_Name&gt;
128128
&lt;bsvc:Owned_By_Reference&gt;
129-
&lt;bsvc:ID bsvc:type="WorkdayUserName"&gt;{username}&lt;/bsvc:ID&gt;
129+
&lt;bsvc:ID bsvc:type="WorkdayUserName"&gt;{owned_by_username}&lt;/bsvc:ID&gt;
130130
&lt;/bsvc:Owned_By_Reference&gt;
131131
&lt;/bsvc:Workdrive_Item_Generic_Data&gt;
132132
&lt;bsvc:File&gt;{contents}&lt;/bsvc:File&gt;
133133
&lt;bsvc:Drive_File_Uploaded_By_Reference&gt;
134-
&lt;bsvc:ID bsvc:type="WorkdayUserName"&gt;{username}&lt;/bsvc:ID&gt;
134+
&lt;bsvc:ID bsvc:type="WorkdayUserName"&gt;{uploaded_by_username}&lt;/bsvc:ID&gt;
135135
&lt;/bsvc:Drive_File_Uploaded_By_Reference&gt;
136136
&lt;/bsvc:Drive_Document_Content_Data&gt;
137137
&lt;/bsvc:Put_Drive_Document_Content_Request&gt;</value>
@@ -148,11 +148,11 @@
148148
&lt;bsvc:Drive_Item_Name&gt;{filename}&lt;/bsvc:Drive_Item_Name&gt;
149149
&lt;bsvc:Trashed&gt;true&lt;/bsvc:Trashed&gt;
150150
&lt;bsvc:Owned_By_Reference&gt;
151-
&lt;bsvc:ID bsvc:type="WorkdayUserName"&gt;{username}&lt;/bsvc:ID&gt;
151+
&lt;bsvc:ID bsvc:type="WorkdayUserName"&gt;{owned_by_username}&lt;/bsvc:ID&gt;
152152
&lt;/bsvc:Owned_By_Reference&gt;
153153
&lt;/bsvc:Workdrive_Item_Generic_Data&gt;
154154
&lt;bsvc:Drive_File_Uploaded_By_Reference&gt;
155-
&lt;bsvc:ID bsvc:type="WorkdayUserName"&gt;{username}&lt;/bsvc:ID&gt;
155+
&lt;bsvc:ID bsvc:type="WorkdayUserName"&gt;{uploaded_by_username}&lt;/bsvc:ID&gt;
156156
&lt;/bsvc:Drive_File_Uploaded_By_Reference&gt;
157157
&lt;/bsvc:Drive_Document_Content_Data&gt;
158158
&lt;/bsvc:Put_Drive_Document_Content_Request&gt;</value>

0 commit comments

Comments
 (0)