This commit is contained in:
@@ -250,6 +250,7 @@ namespace Sockeye.Biz
|
||||
.AddText(obj.Region)
|
||||
.AddText(obj.Country)
|
||||
.AddText(obj.AddressPostal)
|
||||
.AddText(obj.DbId)
|
||||
.AddCustomFields(obj.CustomFields);
|
||||
}
|
||||
|
||||
|
||||
@@ -201,11 +201,70 @@ namespace Sockeye.Biz
|
||||
*/
|
||||
res = await client.GetAsync($"{URL_ROCKFISH}api/customer/list");
|
||||
responseText = await res.Content.ReadAsStringAsync();
|
||||
var d = JArray.Parse(responseText);
|
||||
//
|
||||
var jaCustomerList = JArray.Parse(responseText);
|
||||
foreach (JObject jCustomerListItem in jaCustomerList)
|
||||
{
|
||||
res = await client.GetAsync($"{URL_ROCKFISH}api/customer/{jCustomerListItem["id"].Value<long>()}");
|
||||
|
||||
var jCustomer = JObject.Parse(await res.Content.ReadAsStringAsync());
|
||||
|
||||
//SITES
|
||||
res = await client.GetAsync($"{URL_ROCKFISH}api/customer/{jCustomerListItem["id"].Value<long>()}/sites");
|
||||
var jaSiteList = JArray.Parse(await res.Content.ReadAsStringAsync());
|
||||
|
||||
bool multiSite = jaSiteList.Count() > 1;
|
||||
|
||||
foreach (JObject jSite in jaSiteList)
|
||||
{
|
||||
var CustomerName = jCustomer["name"].Value<string>();
|
||||
if (multiSite)
|
||||
CustomerName += " - " + jSite["name"].Value<string>();
|
||||
|
||||
//Create customer if we don't have one already
|
||||
if (await ct.Customer.AnyAsync(z => z.Name == CustomerName))
|
||||
continue;//already have this one so no need to process it again
|
||||
{
|
||||
//CREATE CUSTOMER
|
||||
Customer c = new Customer();
|
||||
c.Name = CustomerName;
|
||||
c.Country = jSite["country"].Value<string>();
|
||||
c.Region = jSite["stateProvince"].Value<string>();
|
||||
c.DoNotContact = jCustomer["doNotContact"].Value<bool>();
|
||||
c.Notes = jCustomer["notes"].Value<string>();
|
||||
c.DbId = jSite["dbId"].Value<string>();
|
||||
if (c.DbId == "v7_no_dbid"){
|
||||
c.DbId=null;
|
||||
c.Tags.Add("v7");
|
||||
}
|
||||
else
|
||||
c.Tags.Add("raven");
|
||||
|
||||
if (jSite["hosted"].Value<bool>() == true)
|
||||
c.Tags.Add("hosted");
|
||||
|
||||
var adminEmail = jCustomer["adminEmail"].Value<string>();
|
||||
if (!string.IsNullOrWhiteSpace(adminEmail))
|
||||
c.Notes += "\nAdmin Email: " + adminEmail;
|
||||
c.EmailAddress = jCustomer["adminEmail"].Value<string>();
|
||||
CustomerBiz biz = CustomerBiz.GetBiz(ct);
|
||||
var NewObject = await biz.CreateAsync(c);
|
||||
|
||||
//Add all customer related shit here
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}//end of all customers iteration
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -214,6 +273,7 @@ namespace Sockeye.Biz
|
||||
}
|
||||
|
||||
|
||||
log.LogInformation("FINISHED IMPORTING");
|
||||
//in the correct order retrieve every object and if it's not already present in sockeye, import it
|
||||
//this should be callable any time and it will just update so it can be test live in sync / parallel until ready to switch over
|
||||
//await Task.CompletedTask;
|
||||
|
||||
Reference in New Issue
Block a user