This commit is contained in:
@@ -169,10 +169,8 @@ namespace AyaNova.PlugIn.V8
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
TODO:
|
TODO:
|
||||||
* EMPTY DB ROUTE
|
* Userskill, user cert as tags?
|
||||||
* custom fields processor for: User, Client, Contract, HeadOffice, LoanItem, part, project, purchaseorder, unit, unitmodel, vendor, workorderitem
|
* custom fields processor for: User, Client, Contract, HeadOffice, LoanItem, part, project, purchaseorder, unit, unitmodel, vendor, workorderitem
|
||||||
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@@ -332,8 +330,6 @@ namespace AyaNova.PlugIn.V8
|
|||||||
#region users
|
#region users
|
||||||
private async System.Threading.Tasks.Task ExportUsers(ProgressForm progress)
|
private async System.Threading.Tasks.Task ExportUsers(ProgressForm progress)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
UserPickList pl = UserPickList.GetList(false);
|
UserPickList pl = UserPickList.GetList(false);
|
||||||
progress.Append("Dumping " + pl.Count.ToString() + " Users");
|
progress.Append("Dumping " + pl.Count.ToString() + " Users");
|
||||||
foreach (UserPickList.UserPickListInfo i in pl)
|
foreach (UserPickList.UserPickListInfo i in pl)
|
||||||
@@ -367,7 +363,6 @@ namespace AyaNova.PlugIn.V8
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
d.active = false;//all imported users are inactive to start
|
d.active = false;//all imported users are inactive to start
|
||||||
d.roles = 0;//todo: try to determine role from v7 member of group? or is that even possible?
|
d.roles = 0;//todo: try to determine role from v7 member of group? or is that even possible?
|
||||||
d.login = util.RandomString();
|
d.login = util.RandomString();
|
||||||
@@ -379,15 +374,28 @@ namespace AyaNova.PlugIn.V8
|
|||||||
Tagit(c.DispatchZoneID, tags);
|
Tagit(c.DispatchZoneID, tags);
|
||||||
SetTags(d, tags);
|
SetTags(d, tags);
|
||||||
|
|
||||||
await util.PostAsync("User", d.ToString());
|
var a=await util.PostAsync("User", d.ToString());
|
||||||
|
long RavenId = util.IdFromResponse(a);
|
||||||
|
Map.Add(c.ID, RavenId);
|
||||||
|
|
||||||
|
//USER OPTIONS
|
||||||
|
a=await util.GetAsync("UserOptions/"+RavenId.ToString());
|
||||||
|
d=a.ObjectResponse["data"];
|
||||||
|
d.uiColor = System.Drawing.ColorTranslator.ToHtml(System.Drawing.Color.FromArgb(c.ScheduleBackColor));
|
||||||
|
d.emailAddress = c.EmailAddress;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//JObject xtra = new JObject();
|
//JObject xtra = new JObject();
|
||||||
//xtra.Add("hexaScheduleBackColor", System.Drawing.ColorTranslator.ToHtml(System.Drawing.Color.FromArgb(c.ScheduleBackColor)));
|
//xtra.Add("hexaScheduleBackColor", );
|
||||||
|
|
||||||
//DumpObjectToFolder(tempArchiveFolder, c, "user." + c.ID.ToString(), objectExcludeProperties, new TypeAndID(RootObjectTypes.User, c.ID), null, xtra);
|
//DumpObjectToFolder(tempArchiveFolder, c, "user." + c.ID.ToString(), objectExcludeProperties, new TypeAndID(RootObjectTypes.User, c.ID), null, xtra);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
//todo fixup post import
|
||||||
|
progress.Append("TODO: User, fixup translationID, headofficeid, clientid vendorid");
|
||||||
}
|
}
|
||||||
#endregion clients
|
#endregion clients
|
||||||
|
|
||||||
|
|||||||
@@ -122,19 +122,18 @@ namespace AyaNova.PlugIn.V8
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
public async static Task<ApiResponse> GetAsync(string route, string authToken = null, string bodyJsonData = null)
|
public async static Task<ApiResponse> GetAsync(string route)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
var requestMessage = new HttpRequestMessage(HttpMethod.Get, route);
|
var requestMessage = new HttpRequestMessage(HttpMethod.Get, route);
|
||||||
if (!string.IsNullOrWhiteSpace(JWT))
|
if (!string.IsNullOrWhiteSpace(JWT))
|
||||||
requestMessage.Headers.Authorization = new AuthenticationHeaderValue("Bearer", JWT);
|
requestMessage.Headers.Authorization = new AuthenticationHeaderValue("Bearer", JWT);
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(bodyJsonData))
|
|
||||||
requestMessage.Content = new StringContent(bodyJsonData, System.Text.Encoding.UTF8, "application/json");
|
|
||||||
|
|
||||||
HttpResponseMessage response = await client.SendAsync(requestMessage);
|
HttpResponseMessage response = await client.SendAsync(requestMessage);
|
||||||
var responseAsString = await response.Content.ReadAsStringAsync();
|
var responseAsString = await response.Content.ReadAsStringAsync();
|
||||||
|
if (!response.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
throw new Exception("GET error, route: " + route + "\n" + responseAsString + "\n" + response.ReasonPhrase);
|
||||||
|
}
|
||||||
|
|
||||||
return new ApiResponse() { HttpResponse = response, ObjectResponse = Parse(responseAsString) };
|
return new ApiResponse() { HttpResponse = response, ObjectResponse = Parse(responseAsString) };
|
||||||
}
|
}
|
||||||
@@ -159,6 +158,27 @@ namespace AyaNova.PlugIn.V8
|
|||||||
return new ApiResponse() { HttpResponse = response, ObjectResponse = Parse(responseAsString) };
|
return new ApiResponse() { HttpResponse = response, ObjectResponse = Parse(responseAsString) };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async static Task<ApiResponse> PutAsync(string route, string putJson = null)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
var requestMessage = new HttpRequestMessage(HttpMethod.Put, route);
|
||||||
|
if (!string.IsNullOrWhiteSpace(JWT))
|
||||||
|
requestMessage.Headers.Authorization = new AuthenticationHeaderValue("Bearer", JWT);
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(putJson))
|
||||||
|
requestMessage.Content = new StringContent(putJson, System.Text.Encoding.UTF8, "application/json");
|
||||||
|
|
||||||
|
HttpResponseMessage response = await client.SendAsync(requestMessage);
|
||||||
|
var responseAsString = await response.Content.ReadAsStringAsync();
|
||||||
|
if (!response.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
throw new Exception("PUT error, route: " + route + "\n" + responseAsString + "\n" + response.ReasonPhrase);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new ApiResponse() { HttpResponse = response, ObjectResponse = Parse(responseAsString) };
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//eoc
|
//eoc
|
||||||
public class ApiResponse
|
public class ApiResponse
|
||||||
@@ -186,6 +206,17 @@ namespace AyaNova.PlugIn.V8
|
|||||||
}
|
}
|
||||||
return JObject.Parse(jsonString);
|
return JObject.Parse(jsonString);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static long IdFromResponse(ApiResponse a)
|
||||||
|
{
|
||||||
|
return a.ObjectResponse["data"]["id"].Value<long>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static uint CTokenFromResponse(ApiResponse a)
|
||||||
|
{
|
||||||
|
return a.ObjectResponse["data"]["concurrencyToken"].Value<uint>();
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Misc utils
|
#region Misc utils
|
||||||
@@ -228,7 +259,7 @@ namespace AyaNova.PlugIn.V8
|
|||||||
if (s.Length > maxLength)
|
if (s.Length > maxLength)
|
||||||
s = s.Substring(0, maxLength);
|
s = s.Substring(0, maxLength);
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user