Skip to content
Snippets Groups Projects
Commit 7e555ce7 authored by Sebastian Pongratz's avatar Sebastian Pongratz :ping_pong:
Browse files

Merge branch 'cm_dt_1077287_updateAllAdressLocations-stopsAtInvalidData' into '2021.0'

Cm dt 1077287 update all adress locations stops at invalid data

See merge request xrm/basic!885
parents 0da84f75 2fd3ccd0
No related branches found
No related tags found
No related merge requests found
import("system.logging");
import("Util_lib");
import("system.db");
import("Sql_lib");
import("Address_lib");
import("Location_lib");
var locationSearch = new LocationFinder();
var malformedAddressData = [];
if (locationSearch.isEnabled())
{
......@@ -18,14 +21,31 @@ if (locationSearch.isEnabled())
addresses.forEach(function ([addressId, address, buildingno, zip, city, country, state])
{
var addressData = new AddressObject(address, buildingno, zip, city, country, state);
var location = locationSearch.getGeoLocation(addressData);
if (location)
try
{
locationUpdates.push(["ADDRESS", ["LAT", "LON"], null, [location.lat, location.lon],
newWhere("ADDRESS.ADDRESSID", addressId).buildCondition()]);
var location = locationSearch.getGeoLocation(addressData);
if (location)
{
locationUpdates.push(["ADDRESS", ["LAT", "LON"], null, [location.lat, location.lon],
newWhere("ADDRESS.ADDRESSID", addressId).buildCondition()]);
}
}
catch (pException)
{
malformedAddressData.push(addressId);
}
});
if (locationUpdates.length > 0)
db.updates(locationUpdates);
});
if (Utils.isNotNullOrEmptyString(malformedAddressData))
{
errMsg = "updateAllAddressLocations_serverProcess: Something went wrong, during updating address locations, with the following uids: ";
malformedAddressData.forEach(function(pMalformedData)
{
errMsg += pMalformedData + "\n";
});
logging.log(errMsg);
}
}
\ No newline at end of file
import("system.db");
import("system.logging");
import("Sql_lib");
import("Address_lib");
import("Location_lib");
import("Util_lib");
var locationSearch = new LocationFinder();
var malformedAddressData = [];
if (locationSearch.isEnabled())
{
......@@ -16,14 +19,31 @@ if (locationSearch.isEnabled())
addresses.forEach(function ([addressId, address, buildingno, zip, city, country, state])
{
var addressData = new AddressObject(address, buildingno, zip, city, country, state);
var location = locationSearch.getGeoLocation(addressData);
if (location)
try
{
locationUpdates.push(["ADDRESS", ["LAT", "LON"], null, [location.lat, location.lon],
newWhere("ADDRESS.ADDRESSID", addressId).buildCondition()]);
var location = locationSearch.getGeoLocation(addressData);
if (location)
{
locationUpdates.push(["ADDRESS", ["LAT", "LON"], null, [location.lat, location.lon],
newWhere("ADDRESS.ADDRESSID", addressId).buildCondition()]);
}
}
catch (pException)
{
malformedAddressData.push(addressId);
}
});
if (locationUpdates.length > 0)
db.updates(locationUpdates);
});
if (Utils.isNotNullOrEmptyString(malformedAddressData))
{
errMsg = "updateAllAddressLocations_serverProcess: Something went wrong, during updating address locations, with the following uids: ";
malformedAddressData.forEach(function(pMalformedData)
{
errMsg += pMalformedData + "\n";
});
logging.log(errMsg);
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment