/// <summary>
        /// Update VMRequest status
        /// </summary>
        /// <param name="id">VMRequest id</param>
        /// <param name="newStatus">New status to associate to the VMRequest</param>
        /// <param name="additionalLogInfo">Additional log info</param>
        public void UpdateStatus(
            long id,
            VMFactory.Api.Business.Entity.RequestStatus newStatus,
            string additionalLogInfo)
        {
            VirtualMachineRequest vmRequest = new VirtualMachineRequest(id);

            vmRequest.Status = newStatus;
            vmRequest.ProcessLog = additionalLogInfo;

            /*
            if (!string.IsNullOrEmpty(additionalLogInfo))
            {
                if (string.IsNullOrEmpty(vmRequest.ProcessLog))
                    vmRequest.ProcessLog = additionalLogInfo;
                else
                    vmRequest.ProcessLog += string.Format("\n{0}", additionalLogInfo);
            }
            */

            bool result = vmRequest.Save();

            if (result == false)
                throw new Exception("Unable to update information!");
        }
Пример #2
0
 public void Execute()
 {
     while (Result.CurrentStatus == ProcessStatus.Running) { if (IsReadyForExecution()) { Console.WriteLine("Get next virtual machine request"); VMRequest = VirtualMachine.GetNextVirtualMachineRequest();  if (VMRequest == null) { Console.WriteLine("No request to process!"); System.Threading.Thread.Sleep(10000); this.Result.CurrentStatus = ProcessStatus.Finished; } else { if (VMRequest.Status == RequestStatus.None) { this._ProcessLog.Append(String.Format("Loaded request: ID [{0}], Requester [{1}], Requested on [{2}], Current Time [{3}]", VMRequest.Id, VMRequest.RequestedBy, VMRequest.RequestedOn, DateTime.UtcNow)); }  if (VMRequest.IsValid) { this._ProcessLog.Append("Request is valid."); ProcessRequest();  this._ProcessLog.Append("Request processing is complete.");  } else { this._ProcessLog.Append("Request is invalid."); }                     }                 } else { AbortExecution();  }             }
 }
Пример #3
0
 /// <summary>
 /// Gets the next virtual machine request.
 /// </summary>
 /// <returns></returns>
 public static VirtualMachineRequest GetNextVirtualMachineRequest()
 {
     VirtualMachineRequest result = null;  try { using (var db = new VMFSupportContext()) { var x = db.VMRequests;  var dbRequests = from r in db.VMRequests where r.RequestStatus == (int)RequestStatus.None orderby r.CreatedOn select r;  result = new VirtualMachineRequest(dbRequests.First <VMRequest>()); } } catch (Exception e) {  }  return(result);
 }
 /// <summary>
 /// Gets the status.
 /// </summary>
 /// <param name="vmRequest">The vm request.</param>
 /// <returns></returns>
 public VirtualMachineRequest GetStatus(VirtualMachineRequest vmRequest)
 {
     return vmRequest;
 }
 /// <summary>
 /// Gets the status.
 /// </summary>
 /// <param name="vmRequestId">The vm request id.</param>
 /// <returns></returns>
 public VirtualMachineRequest GetStatus(string vmRequestId)
 {
     var vmRequest = new VirtualMachineRequest() { CorrelationId = new Guid(vmRequestId) }; return GetStatus(vmRequest);
 }
 /// <summary>
 /// Update VMRequest status
 /// </summary>
 /// <param name="id">VMRequest id</param>
 /// <param name="newStatus">New status to associate to the VMRequest</param>
 public void UpdateStatus( long id, VMFactory.Api.Business.Entity.RequestStatus newStatus)
 {
     VirtualMachineRequest vmRequest = new VirtualMachineRequest(id);  vmRequest.Status = newStatus;  vmRequest.Save();
 }
Пример #7
0
 /// <summary>
 /// Gets the next virtual machine request.
 /// </summary>
 /// <returns></returns>
 public static VirtualMachineRequest GetNextVirtualMachineRequest()
 {
     VirtualMachineRequest result = null;  try { using (var db = new VMFSupportContext()) { var x = db.VMRequests;  var dbRequests = from r in db.VMRequests where r.RequestStatus == (int)RequestStatus.None orderby r.CreatedOn select r;  result = new VirtualMachineRequest(dbRequests.First<VMRequest>());  } } catch (Exception e) {  }  return result;
 }