Пример #1
0
        public static void Delete(IHiveItem item)
        {
            if (item.Id == Guid.Empty && item.GetType() != typeof(JobPermission))
            {
                return;
            }

            if (item is Job)
            {
                HiveServiceLocator.Instance.CallHiveService(s => s.UpdateJobState(item.Id, JobState.StatisticsPending));
            }
            if (item is RefreshableJob)
            {
                RefreshableJob job = (RefreshableJob)item;
                if (job.RefreshAutomatically)
                {
                    job.StopResultPolling();
                }
                HiveServiceLocator.Instance.CallHiveService(s => s.UpdateJobState(item.Id, JobState.StatisticsPending));
            }
            if (item is JobPermission)
            {
                var hep = (JobPermission)item;
                HiveServiceLocator.Instance.CallHiveService(s => s.RevokePermission(hep.JobId, hep.GrantedUserId));
            }
            item.Id = Guid.Empty;
        }
Пример #2
0
 public static void Store(IHiveItem item, CancellationToken cancellationToken)
 {
     if (item.Id == Guid.Empty)
     {
         if (item is SlaveGroup)
         {
             item.Id = HiveServiceLocator.Instance.CallHiveService((s) => s.AddSlaveGroup((SlaveGroup)item));
         }
         if (item is Slave)
         {
             item.Id = HiveServiceLocator.Instance.CallHiveService((s) => s.AddSlave((Slave)item));
         }
         if (item is Downtime)
         {
             item.Id = HiveServiceLocator.Instance.CallHiveService((s) => s.AddDowntime((Downtime)item));
         }
     }
     else
     {
         if (item is SlaveGroup)
         {
             HiveServiceLocator.Instance.CallHiveService((s) => s.UpdateSlaveGroup((SlaveGroup)item));
         }
         if (item is Slave)
         {
             HiveServiceLocator.Instance.CallHiveService((s) => s.UpdateSlave((Slave)item));
         }
         if (item is Downtime)
         {
             HiveServiceLocator.Instance.CallHiveService((s) => s.UpdateDowntime((Downtime)item));
         }
     }
 }
Пример #3
0
 public static void Store(IHiveItem item, CancellationToken cancellationToken)
 {
     if (item.Id == Guid.Empty)
     {
         if (item is RefreshableJob)
         {
             HiveClient.Instance.UploadJob((RefreshableJob)item, cancellationToken);
         }
         if (item is JobPermission)
         {
             var hep = (JobPermission)item;
             hep.GrantedUserId = HiveServiceLocator.Instance.CallHiveService((s) => s.GetUserIdByUsername(hep.GrantedUserName));
             if (hep.GrantedUserId == Guid.Empty)
             {
                 throw new ArgumentException(string.Format("The user {0} was not found.", hep.GrantedUserName));
             }
             HiveServiceLocator.Instance.CallHiveService((s) => s.GrantPermission(hep.JobId, hep.GrantedUserId, hep.Permission));
         }
     }
     else
     {
         if (item is Job)
         {
             HiveServiceLocator.Instance.CallHiveService(s => s.UpdateJob((Job)item));
         }
     }
 }
Пример #4
0
 public static void Delete(IHiveItem item)
 {
     if (item is SlaveGroup)
     {
         HiveServiceLocator.Instance.CallHiveService((s) => s.DeleteSlaveGroup(item.Id));
     }
     else if (item is Slave)
     {
         HiveServiceLocator.Instance.CallHiveService((s) => s.DeleteSlave(item.Id));
     }
     else if (item is Downtime)
     {
         HiveServiceLocator.Instance.CallHiveService((s) => s.DeleteDowntime(item.Id));
     }
 }
Пример #5
0
        public static void StoreAsync(Action <Exception> exceptionCallback, IHiveItem item, CancellationToken cancellationToken)
        {
            var call = new Func <Exception>(delegate() {
                try {
                    Store(item, cancellationToken);
                } catch (Exception ex) {
                    return(ex);
                }
                return(null);
            });

            call.BeginInvoke(delegate(IAsyncResult result) {
                Exception ex = call.EndInvoke(result);
                if (ex != null)
                {
                    exceptionCallback(ex);
                }
            }, null);
        }
Пример #6
0
 public static void Delete(IHiveItem item) {
   if (item is SlaveGroup) {
     HiveServiceLocator.Instance.CallHiveService((s) => s.DeleteSlaveGroup(item.Id));
   } else if (item is Slave) {
     HiveServiceLocator.Instance.CallHiveService((s) => s.DeleteSlave(item.Id));
   } else if (item is Downtime) {
     HiveServiceLocator.Instance.CallHiveService((s) => s.DeleteDowntime(item.Id));
   }
 }
Пример #7
0
 public static void Store(IHiveItem item, CancellationToken cancellationToken) {
   if (item.Id == Guid.Empty) {
     if (item is SlaveGroup) {
       item.Id = HiveServiceLocator.Instance.CallHiveService((s) => s.AddSlaveGroup((SlaveGroup)item));
     }
     if (item is Slave) {
       item.Id = HiveServiceLocator.Instance.CallHiveService((s) => s.AddSlave((Slave)item));
     }
     if (item is Downtime) {
       item.Id = HiveServiceLocator.Instance.CallHiveService((s) => s.AddDowntime((Downtime)item));
     }
   } else {
     if (item is SlaveGroup) {
       HiveServiceLocator.Instance.CallHiveService((s) => s.UpdateSlaveGroup((SlaveGroup)item));
     }
     if (item is Slave) {
       HiveServiceLocator.Instance.CallHiveService((s) => s.UpdateSlave((Slave)item));
     }
     if (item is Downtime) {
       HiveServiceLocator.Instance.CallHiveService((s) => s.UpdateDowntime((Downtime)item));
     }
   }
 }
Пример #8
0
    public static void Delete(IHiveItem item) {
      if (item.Id == Guid.Empty && item.GetType() != typeof(JobPermission))
        return;

      if (item is Job)
        HiveServiceLocator.Instance.CallHiveService(s => s.DeleteJob(item.Id));
      if (item is RefreshableJob) {
        RefreshableJob job = (RefreshableJob)item;
        if (job.RefreshAutomatically) {
          job.StopResultPolling();
        }
        HiveServiceLocator.Instance.CallHiveService(s => s.DeleteJob(item.Id));
      }
      if (item is JobPermission) {
        var hep = (JobPermission)item;
        HiveServiceLocator.Instance.CallHiveService(s => s.RevokePermission(hep.JobId, hep.GrantedUserId));
      }
      item.Id = Guid.Empty;
    }
Пример #9
0
 public static void StoreAsync(Action<Exception> exceptionCallback, IHiveItem item, CancellationToken cancellationToken) {
   var call = new Func<Exception>(delegate() {
     try {
       Store(item, cancellationToken);
     }
     catch (Exception ex) {
       return ex;
     }
     return null;
   });
   call.BeginInvoke(delegate(IAsyncResult result) {
     Exception ex = call.EndInvoke(result);
     if (ex != null) exceptionCallback(ex);
   }, null);
 }
Пример #10
0
 public static void Store(IHiveItem item, CancellationToken cancellationToken) {
   if (item.Id == Guid.Empty) {
     if (item is RefreshableJob) {
       HiveClient.Instance.UploadJob((RefreshableJob)item, cancellationToken);
     }
     if (item is JobPermission) {
       var hep = (JobPermission)item;
       hep.GrantedUserId = HiveServiceLocator.Instance.CallHiveService((s) => s.GetUserIdByUsername(hep.GrantedUserName));
       if (hep.GrantedUserId == Guid.Empty) {
         throw new ArgumentException(string.Format("The user {0} was not found.", hep.GrantedUserName));
       }
       HiveServiceLocator.Instance.CallHiveService((s) => s.GrantPermission(hep.JobId, hep.GrantedUserId, hep.Permission));
     }
   } else {
     if (item is Job)
       HiveServiceLocator.Instance.CallHiveService(s => s.UpdateJob((Job)item));
   }
 }