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); } } }
private static void testReadOU(RestClient client, string uuid) { OrgUnitRegistration ou = new OrgUnitRegistration(); ou.Uuid = uuid; ou.Name = "testOU"; ou.ParentOrgUnitUuid = GetFreshUuid(); ou.Email.Value = "*****@*****.**"; // store directly, then use service to read OrgUnitService orgUnitService = new OrgUnitService(); orgUnitService.Update(ou); var request = new RestRequest("/api/v1_1/orgunit?uuid=" + uuid); request.Method = Method.GET; var response = client.Execute <OrgUnitRegistration>(request); OrgUnitRegistration responseRegistration = response.Data; if (!ou.Email.Value.Equals(responseRegistration.Email.Value)) { throw new Exception("Email mismatch"); } if (!ou.Name.Equals(responseRegistration.Name)) { throw new Exception("Name mismatch"); } if (!ou.ParentOrgUnitUuid.Equals(responseRegistration.ParentOrgUnitUuid)) { throw new Exception("Parent.UUID mismatch"); } }
static void Main(string[] args) { InitEnvironment(); OrgUnitRegistration registration = OUReg(); registration.Name = "Testenhed til Opgaver"; registration.ParentOrgUnitUuid = Uuid(); registration.Tasks = new List <string>(); registration.Tasks.Add("407a84c9-5347-4871-9842-fa7a5f8fe607"); registration.Tasks.Add("dbb1b318-3c85-11e3-9b13-0050c2490048"); registration.Tasks.Add("1b72daba-5e77-4512-a92e-5e4ca9950a35"); orgUnitService.Update(registration); var ou = inspectorService.ReadOUObject(registration.Uuid); registration.Name = "Navneændring"; orgUnitService.Update(registration); ou = inspectorService.ReadOUObject(registration.Uuid); /* ordinary tests * TestListAndReadOUs(); * TestListAndReadUsers(); * TestCreateAndUpdateFullUser(); * TestCreateDeleteUpdateUser(); * TestCreateDeleteUpdateOU(); * TestCreateAndUpdateFullOU(); * TestUpdateWithoutChanges(); * TestPayoutUnits(); * TestPositions(); * // TestContactPlaces(); * TestUpdateAndSearch(); * TestMultipleAddresses(); */ System.Environment.Exit(0); }