public AlgorithmMessage UpdateAlgorithmMessage(AlgorithmMessage message) { return(ExecuteFaultHandledOperation(() => { IAlgorithmInstanceRepository algorithmInstanceRepository = _DataRepositoryFactory.GetDataRepository <IAlgorithmInstanceRepository>(); AlgorithmInstance instance = algorithmInstanceRepository.Get(message.AlgorithmInstanceID); if (instance == null) { NotFoundFault fault = new NotFoundFault(string.Format("No algorithm instance found for instanceId '{0}'.", message.AlgorithmInstanceID)); throw new FaultException <NotFoundFault>(fault, fault.Message); } IAlgorithmMessageRepository messageRepository = _DataRepositoryFactory.GetDataRepository <IAlgorithmMessageRepository>(); AlgorithmMessage updatedEntity = null; if (message.AlgorithmMessageID == 0) { updatedEntity = messageRepository.Add(message); } else { updatedEntity = messageRepository.Update(message); } return updatedEntity; })); }
public AlgorithmInstance[] GetAlgorithmInstances() { return(ExecuteFaultHandledOperation(() => { IAlgorithmInstanceRepository instanceRepository = _DataRepositoryFactory.GetDataRepository <IAlgorithmInstanceRepository>(); IEnumerable <AlgorithmInstance> instances = instanceRepository.Get(); return instances.ToArray(); })); }
public bool IsStrategyAlgorithmRunning(int strategyId) { bool running = false; IAlgorithmInstanceRepository algoInstanceRepository = _DataRepositoryFactory.GetDataRepository <IAlgorithmInstanceRepository>(); var instances = algoInstanceRepository.GetAlgorithmInstancesByStrategy(strategyId); var runningInstance = instances.Where(i => i.Status != (short)AlgorithmStatus.NotRunning).FirstOrDefault(); running = runningInstance != null; return(running); }
public AlgorithmInstance UpdateAlgorithmInstance(AlgorithmInstance instance) { return(ExecuteFaultHandledOperation(() => { AlgorithmInstance updatedEntity = null; Strategy strategy = GetStrategy(instance.StrategyID); if (strategy != null) { IAlgorithmInstanceRepository algorithmInstanceRepository = _DataRepositoryFactory.GetDataRepository <IAlgorithmInstanceRepository>(); if (instance.AlgorithmInstanceID == 0) { updatedEntity = algorithmInstanceRepository.Add(instance); } else { updatedEntity = algorithmInstanceRepository.Update(instance); } } return updatedEntity; })); }