Exemplo n.º 1
0
        /*
         * 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);
                }
            }
        }