Exemple #1
0
        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;
            }));
        }
Exemple #2
0
        private void OnAlgorithmMessageChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (e.Action == NotifyCollectionChangedAction.Add)
            {
                foreach (var item in e.NewItems)
                {
                    AlgorithmMessage message = (AlgorithmMessage)item;

                    if (_logger != null)
                    {
                        if (message.Exception != null)
                        {
                            _logger.LogException(message.Severity, message.Exception, message.Message);
                        }
                        else
                        {
                            _logger.LogMessage(message.Severity, message.Message);
                        }
                    }
                }
            }
            if (e.Action == NotifyCollectionChangedAction.Replace)
            {
                //
            }
            if (e.Action == NotifyCollectionChangedAction.Remove)
            {
                //
            }
            if (e.Action == NotifyCollectionChangedAction.Move)
            {
                //
            }
        }
Exemple #3
0
 public AlgorithmMessage UpdateAlgorithmMessage(AlgorithmMessage message)
 {
     WithStrategyClient(strategyClient =>
     {
         _algorithmMessageResult = strategyClient.UpdateAlgorithmMessage(message);
     });
     return(_algorithmMessageResult);
 }
Exemple #4
0
        public async Task <AlgorithmMessage> UpdateAlgorithmMessageAsync(AlgorithmMessage message)
        {
            await WithStrategyClientAsync(async strategyClient =>
            {
                _algorithmMessageResult = await strategyClient.UpdateAlgorithmMessageAsync(message);
            });

            return(_algorithmMessageResult);
        }
Exemple #5
0
        protected async Task AddAlgorithmMessage(string message, bool saveMesage = true, TraceEventType type = 0, Exception ex = null)
        {
            var newMessage = new AlgorithmMessage()
            {
                AlgorithmInstanceID = _instance.AlgorithmInstanceID,
                Message             = message,
                Severity            = type,
                Exception           = ex
            };

            // limit coll. size due to memory
            if (Messages.Count >= 200)
            {
                Messages.RemoveAt(0);
            }
            Messages.Add(newMessage);

            if (saveMesage)
            {
                StrategyCaller.Instance().UpdateAlgorithmMessageAsync(newMessage);
            }
        }
Exemple #6
0
 public AlgorithmMessage UpdateAlgorithmMessage(AlgorithmMessage message)
 {
     return(Channel.UpdateAlgorithmMessage(message));
 }
Exemple #7
0
 public Task <AlgorithmMessage> UpdateAlgorithmMessageAsync(AlgorithmMessage message)
 {
     return(Channel.UpdateAlgorithmMessageAsync(message));
 }