Esempio n. 1
0
 public void RealStart()
 {
     ClientInstancesManager.GetInstance().GetComputer(ClientId).Status = "Running";
     Variables["ClientName"] = ClientInstancesManager.GetInstance().GetComputer(ClientId).Name;
     Variables["ClientId"]   = ClientId;
     Status = "Running";
     _workflowApplication.Run();
 }
Esempio n. 2
0
 public void Stop()
 {
     if (_workflowApplication != null)
     {
         ClientInstancesManager.GetInstance().GetComputer(ClientId).Status = "Ready";
         _workflowApplication.Cancel();
     }
 }
Esempio n. 3
0
 public void SetCommand(XElement steps)
 {
     Log.Debug("Set Command:\n" + steps);
     steps.SetAttributeValue(Constants.INSTANCE_ID, InstanceId);
     if (!string.IsNullOrEmpty(ClientId))
     {
         ClientInstancesManager.GetInstance().GetComputer(ClientId).SetCommand(steps.ToString());
     }
     lock (this)
     {
         _command = steps;
     }
 }
Esempio n. 4
0
        public WorkflowApplication GetWorkflowApplication(AutomationActivity activity)
        {
            var workflowApplication = new WorkflowApplication(activity)
            {
                Completed = delegate(WorkflowApplicationCompletedEventArgs e)
                {
                    switch (e.CompletionState)
                    {
                    case ActivityInstanceState.Faulted:
                        Log.Error("workflow [" + activity.Id + "] " + activity.DisplayName +
                                  " stopped! Error Message:\n" + e.TerminationException.GetType().FullName + "\n" +
                                  e.TerminationException.Message + "\n" + e.TerminationException.StackTrace);
                        Status = "Terminated";
                        ClientInstancesManager.GetInstance().GetComputer(ClientId).Status = "Ready";
                        break;

                    case ActivityInstanceState.Canceled:
                        Log.Error("workflow [" + activity.Id + "] " + activity.DisplayName + " Cancel.");
                        Status = "Canceled";
                        ClientInstancesManager.GetInstance().GetComputer(ClientId).Status = "Ready";
                        break;

                    default:
                        Log.Info("workflow [" + activity.Id + "] " + activity.DisplayName + " Completed.");
                        Status = "Completed";
                        ClientInstancesManager.GetInstance().GetComputer(ClientId).Status = "Ready";
                        break;
                    }
                },
                Aborted = delegate(WorkflowApplicationAbortedEventArgs e)
                {
                    Log.Error(" aborted! Error Message:\n" + e.Reason.GetType().FullName + "\n" + e.Reason.Message);
                    Status = "Aborted";
                    ClientInstancesManager.GetInstance().GetComputer(ClientId).Status = "Ready";
                }
            };

            return(workflowApplication);
        }
Esempio n. 5
0
 private InstanceManager()
 {
     _task = new Task(() =>
     {
         while (true)
         {
             lock (_waitingList){
                 int toRemove = -1;
                 foreach (var instance in _waitingList)
                 {
                     if (string.IsNullOrEmpty(instance.ClientId))
                     {
                         var clientId = ClientInstancesManager.GetInstance().GetAReadyClientInstance();
                         if (string.IsNullOrEmpty(clientId))
                         {
                             continue;
                         }
                         instance.ClientId = clientId;
                     }
                     var clientStatus = ClientInstancesManager.GetInstance().GetComputer(instance.ClientId).Status;
                     if (clientStatus.Equals("Running"))
                     {
                         continue;
                     }
                     toRemove = _waitingList.IndexOf(instance);
                     break;
                 }
                 if (toRemove > -1)
                 {
                     _waitingList[toRemove].RealStart();
                     _waitingList.RemoveAt(toRemove);
                 }
             }
             Thread.Sleep(500);
         }
     });
     _task.Start();
 }
Esempio n. 6
0
 public static ClientInstancesManager GetInstance()
 {
     return(_instance ?? (_instance = new ClientInstancesManager()));
 }
Esempio n. 7
0
 public static ClientInstancesManager GetInstance()
 {
     return _instance ?? (_instance = new ClientInstancesManager());
 }