Exemple #1
0
 public void UpdateInstances(ServiceInstanceInfo[] instancesInfo)
 {
     lock (Instances)
     {
         List <InstanceView> childs = new List <InstanceView>();
         foreach (var instance in instancesInfo)
         {
             if (_InstancesRef.ContainsKey(instance.LegacyInstanceGuid))
             {
                 _InstancesRef[instance.LegacyInstanceGuid].ServiceInstanceInfo = instance;
             }
             else
             {
                 InstanceView iv = new InstanceView()
                 {
                     ServiceInstanceInfo = instance
                 };
                 _InstancesRef[instance.LegacyInstanceGuid] = iv;
                 if (iv.ParentID == Guid.Empty)
                 {
                     Instances.Add(iv);
                 }
                 else
                 {
                     childs.Add(iv);
                 }
             }
         }
         foreach (var child in childs)
         {
             if (_InstancesRef.ContainsKey(child.ParentID))
             {
                 _InstancesRef[child.ParentID].ChildsSteps.Add(child);
             }
         }
         //TODO: ADD REMOVE ENDED
     }
 }
Exemple #2
0
 internal void ClearEnded()
 {
     lock (Instances)
     {
         List <int> toRemove = new List <int>();
         for (int i = 0; i < Instances.Count; i++)
         {
             InstanceView instance = Instances[i];
             if (instance.State == Core.Services.ServiceState.Ended && DateTime.Parse(instance.ActualEndTime).AddMinutes(5) < DateTime.Now)
             {
                 foreach (var child in instance.ChildsSteps)
                 {
                     _InstancesRef.Remove(child.ID);
                 }
                 _InstancesRef.Remove(instance.ID);
                 toRemove.Add(i);
             }
         }
         foreach (var index in toRemove)
         {
             Instances.RemoveAt(index);
         }
     }
 }