private static int HandleOU(OrgUnitRegistrationExtended ou, OrgUnitService service, OrgUnitDao dao) { try { OrganisationRegistryProperties.SetCurrentMunicipality(ou.Cvr); if (ou.Operation.Equals(OperationType.DELETE)) { service.Delete(ou.Uuid, ou.Timestamp); } else { service.Update(ou); } dao.OnSuccess(ou.Id); dao.Delete(ou.Id); return(0); } catch (TemporaryFailureException ex) { log.Warn("Could not handle ou '" + ou.Uuid + "' at the moment, will try later", ex); return(-1); } catch (Exception ex) { log.Error("Could not handle ou '" + ou.Uuid + "'", ex); dao.OnFailure(ou.Id, ex.Message); dao.Delete(ou.Id); return(-2); } }
/* * public static long HandleItSystems() * { * ItSystemService service = new ItSystemService(); * ItSystemDao dao = new ItSystemDao(); * long count = 0; * * ItSystemRegistrationExtended itSystem = null; * while ((itSystem = dao.GetOldestEntry()) != null) * { * try * { * if (itSystem.Operation.Equals(OperationType.DELETE)) * { * service.Delete(itSystem.Uuid, itSystem.Timestamp); * } * else * { * service.Update(itSystem); * } * * count++; * * dao.Delete(itSystem.Uuid); * } * catch (TemporaryFailureException ex) * { * log.Error("Could not handle ItSystem '" + itSystem.Uuid + "' at the moment, will try later", ex); * break; * } * catch (Exception ex) * { * log.Error("Could not handle ItSystem '" + itSystem.Uuid + "'", ex); * dao.Delete(itSystem.Uuid); * } * } * * return count; * } */ public static void HandleOUs(out long count) { OrgUnitService service = new OrgUnitService(); OrgUnitDao dao = new OrgUnitDao(); count = 0; OrgUnitRegistrationExtended ou = null; while ((ou = dao.GetOldestEntry()) != null) { try { if (ou.Operation.Equals(OperationType.DELETE)) { service.Delete(ou.Uuid, ou.Timestamp); } else { service.Update(ou); } count++; dao.Delete(ou.Id); errorCount = 0; } catch (TemporaryFailureException ex) { log.Error("Could not handle ou '" + ou.Uuid + "' at the moment, will try later"); throw ex; } catch (Exception ex) { log.Error("Could not handle ou '" + ou.Uuid + "'", ex); dao.Delete(ou.Id); } } }