Пример #1
0
 public void UpdateInstances(List <ServiceInstance> requestInfo)
 {
     lock (Requests)
     {
         List <RequestView> childs = new List <RequestView>();
         foreach (var request in requestInfo)
         {
             if (_requestsRef.ContainsKey(request.InstanceID))
             {
                 _requestsRef[request.InstanceID].schedulingRequestInfo = request;
             }
             else
             {
                 RequestView rv = new RequestView()
                 {
                     schedulingRequestInfo = request
                 };
                 _requestsRef[request.InstanceID] = rv;
                 if (rv.ParentID == Guid.Empty)
                 {
                     Requests.Add(rv);
                 }
                 else
                 {
                     childs.Add(rv);
                 }
             }
         }
         foreach (var child in childs)
         {
             if (_requestsRef.ContainsKey(child.ParentID))
             {
                 _requestsRef[child.ParentID].ChildsSteps.Add(child);
             }
         }
         //TODO: ADD REMOVE ENDED
     }
 }
Пример #2
0
 internal void ClearEnded()
 {
     lock (Requests)
     {
         List <int> toRemove = new List <int>();
         for (int i = 0; i < Requests.Count; i++)
         {
             RequestView instance = Requests[i];
             if (instance.State == Core.Services.ServiceState.Ended && DateTime.Parse(instance.ActualEndTime).AddMinutes(5) < DateTime.Now)
             {
                 foreach (var child in instance.ChildsSteps)
                 {
                     _requestsRef.Remove(child.ID);
                 }
                 _requestsRef.Remove(instance.ID);
                 toRemove.Add(i);
             }
         }
         foreach (var index in toRemove)
         {
             Requests.RemoveAt(index);
         }
     }
 }