public void Dispose() { Message = null; UserToken = null; Socket = null; ManualResetEvent confirmationEvent = ConfirmationEvent; ConfirmationEvent = null; if (confirmationEvent != null) { try { confirmationEvent.Close(); } catch (Exception ex) { #if Matrix_Diagnostics SystemMonitor.Error("Failed to close event", ex); #endif } } MemoryStream stream = Stream; if (stream != null) { stream.Dispose(); } Stream = null; }
/// <summary> /// Helper. /// </summary> void TryCompleteOrderOperation(string token, bool printWarning, OrderInfo?orderInfo) { PlaceOrderOperation operation; lock (this) { // Operations stored in stub by order token / Id. operation = (PlaceOrderOperation)_operationStub.GetOperationById(token); } if (operation == null) { if (printWarning) { SystemMonitor.Error("Operation with this ID [" + token + "] not found."); } return; } if (orderInfo.HasValue == false) { if (printWarning) { SystemMonitor.Warning("Failed to convert order for order [" + token + "]."); } operation.Complete("Failed to convert order type. Operation failed.", null); return; } operation.Complete(string.Empty, orderInfo.Value); }
/// <summary> /// /// </summary> /// <param name="parameter0"></param> void _timeOutMonitor_EntityTimedOutEvent(TimeOutable parameter0) { SystemMonitor.Error("_timeOutMonitor_EntityTimedOutEvent"); ExecutionEntity entity = (ExecutionEntity)parameter0; entity.Conversation.EntityTimedOut(entity); }
/// <summary> /// Apply an update of the subscription structute on current event, based on request data. /// </summary> public void SubscriptionUpdate(EventSubscriptionRequest request) { if (request.SenderId == null) { #if Matrix_Diagnostics SystemMonitor.OperationError("Proxy call or proxy call sender not found in a super pool subscription update."); #endif return; } if (request == null) { #if Matrix_Diagnostics SystemMonitor.Error(string.Format("Subscription request not available, subscription failed, delegate method [{0}].", request.DelegateInstanceMethodInfo.ToString())); #endif return; } ReadOnlyCollection <ClientId> sources = request.EventsSources; if (sources != null && sources.Count > 0) { foreach (ClientId id in sources) { DoUpdateSubscription(request.SenderId, request.DelegateInstanceMethodInfo, id, request.IsAdd, request.SpecificCountOptional); } } else {// Single subscribe to all. DoUpdateSubscription(request.SenderId, request.DelegateInstanceMethodInfo, SubscribeToAllId, request.IsAdd, request.SpecificCountOptional); } }
/// <summary> /// /// </summary> /// <param name="entity"></param> public void AddExecutionEntity(ExecutionEntity entity) { TracerHelper.TraceEntry(); lock (this) { if (_pendingEntities.Count > _maxPendingExecutionItems) { TracerHelper.TraceError("Too many pending entities in system. Some older entities are being dropped."); if ((DateTime.Now - _maxPendingItemsWarningShownTime) > _warningsTimeSpan) { _maxPendingItemsWarningShownTime = DateTime.Now; SystemMonitor.Error("Too many pending entities in system. Some older entities are being dropped."); } // Loose the oldest entity in line. _timeOutMonitor.RemoveEntity(_pendingEntities[0]); _pendingEntities.RemoveAt(0); } _timeOutMonitor.AddEntity(entity); _pendingEntities.Add(entity); } // Continue execution chain. UpdatePendingExecution(); }
/// <summary> /// Make sure not to sleep on the UI thread, since the receival event from the web service needs it. /// </summary> public double?GetRate(string symbol1, string symbol2, TimeSpan timeOut, bool obtainForFutureReference) { if (Application.OpenForms.Count > 0) { if (Application.OpenForms[0].InvokeRequired == false && timeOut > TimeSpan.Zero) { SystemMonitor.Error("When calling from main UI thread time out must be zero, as otherwise it locks the expected web service update event."); return(null); } } if (string.IsNullOrEmpty(symbol1) || string.IsNullOrEmpty(symbol2)) { SystemMonitor.Warning("Invalid symbol name."); return(null); } symbol1 = symbol1.ToUpper(); symbol2 = symbol2.ToUpper(); if (symbol1 == symbol2) { return(1); } lock (this) { double?value = GetEntryUpdatedValue(symbol1, symbol2, timeOut); if (value.HasValue) { return(value); } value = GetEntryUpdatedValue(symbol2, symbol1, timeOut); if (value.HasValue) { if (double.IsInfinity(value.Value) || double.IsNaN(value.Value)) { SystemMonitor.Warning("Invalid entry value."); return(null); } if (value.Value == 0) { return(0); } return(1 / value.Value); } } if (obtainForFutureReference) { CreateEntry(symbol1, symbol2, null); return(GetEntryUpdatedValue(symbol1, symbol2, timeOut)); } return(null); }
///// <summary> ///// Append the result piece to the named result set. ///// </summary> //public bool AppendSetValues(string name, double[] inputResultPiece) //{ // return AddSetValues(name, this[name].Count, inputResultPiece.Length, true, inputResultPiece); //} /// <summary> /// /// </summary> //public bool UpdateSetLatestValues(string name, double[] inputResultPiece) //{ // return AddSetValues(name, Math.Max(0, this.SetLength - inputResultPiece.Length), inputResultPiece.Length, true, inputResultPiece); //} ///<summary> /// This used to handle results. /// inputResultPiece stores results, where 0 corresponds to startingIndex; the length of inputResultPiece may be larger than count. ///</summary> public bool AddSetValues(string name, int startingIndex, int count, bool overrideExistingValues, double[] inputResultPiece) { lock (this) { if (_resultSets.ContainsKey(name) == false) { SystemMonitor.Error("SetResultSetValues result set [" + name + "] not found."); return(false); } List <double> resultSet = _resultSets[name]; for (int i = resultSet.Count; i < startingIndex; i++) {// Only if there are some empty spaces before the start, fill them with no value. resultSet.Add(double.NaN); } // Get the dataDelivery from the result it is provided to us. for (int i = startingIndex; i < startingIndex + count; i++) { if (resultSet.Count <= i) { resultSet.Add(inputResultPiece[i - startingIndex]); } else { if (overrideExistingValues) { resultSet[i] = inputResultPiece[i - startingIndex]; } } } } return(true); }
public void tdSink_ITradeDeskEvents_Event_OnRowChanged(object tableDisp, string rowID) { if (_manager.LoggedIn) { try { FXCore.ITableAut t = (FXCore.ITableAut)tableDisp; if ("offers".Equals(t.Type)) { DataTick dataTick = new DataTick(); TableAut offersTable = (TableAut)_manager.Desk.FindMainTable("offers"); RowAut instrumentRow = (RowAut)offersTable.FindRow("OfferID", rowID, 0); dataTick.Ask = (decimal)((double)instrumentRow.CellValue("Ask")); dataTick.Bid = (decimal)((double)instrumentRow.CellValue("Bid")); dataTick.DateTime = (DateTime)instrumentRow.CellValue("Time"); PostQuoteUpdate((string)instrumentRow.CellValue("Instrument"), dataTick); // TODO: this may be way too often, since it will update on each tick of any symbol... // Also update the accounts informations. foreach (AccountInfo accountInfo in _manager.Orders.GetAvailableAccounts()) { _orderExecutionStub.UpdateAccountInfo(accountInfo); } } } catch (System.Exception ex) { SystemMonitor.Error(ex.ToString()); } } }
protected virtual DataSubscriptionResponseMessage Receive(DataSubscriptionRequestMessage message) { if (message.TransportInfo.OriginalSenderId.HasValue == false) { SystemMonitor.Error("Received a message with no original sender. Dropped."); return(null); } if (message.SessionInfo.IsEmtpy) {// General (un)subscription requestMessage, not specific to a sessionInformation. if (message.Subscribe) { SystemMonitor.OperationError("Unexpected combination of empty session and subscribe request, ignored."); } else {// Unsubscribe to each that has a orderInfo for this original sender. lock (this) { foreach (CombinedDataSubscriptionInformation combined in _dataSessions.Values) { if (combined.FullUnsubscribe(message.TransportInfo.OriginalSenderId.Value) == false) { SystemMonitor.OperationError("Failed to unsubscribe [" + message.TransportInfo.OriginalSenderId.Value.Id.Name + "]."); } } } } } else { lock (this) { if (_dataSessions.ContainsKey(message.SessionInfo.Symbol) == false || _dataSessions[message.SessionInfo.Symbol].SessionInformation.Info.Equals(message.SessionInfo) == false) { SystemMonitor.Warning("Subsribe request for non existing session."); return(new DataSubscriptionResponseMessage(message.SessionInfo, false)); } CombinedDataSubscriptionInformation combined = _dataSessions[message.SessionInfo.Symbol]; if (combined != null) { TracerHelper.Trace("Subscribing... " + message.TransportInfo.OriginalSenderId.Value.Id.Name); combined.HandleRequest(message.TransportInfo, message.Subscribe, message.Information); } else { SystemMonitor.OperationError("Combined subscription info not found."); } } } // Finalizing / responding section. if (message.RequestResponse) { return(new DataSubscriptionResponseMessage(message.SessionInfo, true)); } return(null); }
/// <summary> /// Gather all operations of this type and provide them here. /// </summary> /// <typeparam name="RequiredType"></typeparam> /// <returns></returns> protected List <OperationInformation> GetPendingMessagesOperations <RequiredType>(bool gatherStarted) where RequiredType : RequestMessage { List <OperationInformation> result = new List <OperationInformation>(); try { lock (this) { foreach (OperationInformation info in _stub.PendingOperationsArray) { if (info.Request is RequiredType && (gatherStarted || info.IsStarted == false)) { result.Add(info); } } } } catch (Exception ex) {// Make sure we handle any possible unexpected exceptions, as otherwise they bring the // entire package (MT4 included) down with a bad error. SystemMonitor.Error(ex.Message); } return(result); }
public bool RemoveAssembly(Assembly assembly) { lock (this) { if (_expertContainingAssembliesAndPaths.ContainsKey(assembly) == false) { SystemMonitor.Error("Failed to remove assembly [" + assembly.FullName + "]"); return(false); } SystemMonitor.CheckError(_expertContainingAssembliesAndPaths.Remove(assembly)); foreach (ExpertInformation container in GeneralHelper.EnumerableToArray <ExpertInformation>(_expertInfos)) { if (container.ContainingAssembly == assembly) { RemoveExpert(container); } } } if (ExpertAssemblyRemovedEvent != null) { ExpertAssemblyRemovedEvent(assembly); } return(true); }
/// <summary> /// OperationId is not mandatory - but is should be there when the update was requested by a special recepient. /// </summary> public void TradingValuesUpdate(string symbol, int operationId, double time, int period, int availableBarsCount, Int64[] times, decimal[] opens, decimal[] closes, decimal[] highs, decimal[] lows, decimal[] volumes) { TracerHelper.TraceEntry(); CombinedDataSubscriptionInformation session = GetDataSession(symbol); if (session == null) { SystemMonitor.Error("Failed to find symbol session [" + symbol + "], quotes not sent."); return; } try { // History update. TimeSpan periodValue = TimeSpan.FromMinutes(period); DataHistoryUpdate update = new DataHistoryUpdate(periodValue, GenerateDataBars(periodValue, times, opens, closes, highs, lows, volumes)); update.AvailableHistorySize = availableBarsCount; DataHistoryUpdateMessage message = new DataHistoryUpdateMessage(session.SessionInformation.Info, update, true); SendToDataSubscribers(session, null, message); } catch (Exception ex) {// Make sure we handle any possible unexpected exceptions, as otherwise they bring the // entire package (MT4 included) down with a bad error. SystemMonitor.Error(ex.Message); } TracerHelper.TraceExit(); }
/// <summary> /// Will start a shoutcast mode conversation, the sender sending to all. /// </summary> /// <param name="sender"></param> /// <param name="requestMessage"></param> /// <param name="timeout"></param> /// <returns></returns> public ConversationMultiPoint CreateConversation(ArbiterClientId senderID, Message message, TimeSpan timeout) { if (message is TransportMessage) { SystemMonitor.CheckError(((TransportMessage)message).TransportInfo.CurrentTransportInfo != null); TracerHelper.Trace("sender[" + senderID.Id.Name + "], message [" + message.GetType().Name + "] [" + ((TransportMessage)message).TransportInfo.TransportInfoCount + "]"); } else { TracerHelper.Trace("sender[" + senderID.Id.Name + "], message [" + message.GetType().Name + "]"); } if (GetClientByID(senderID, false) == null) { SystemMonitor.Error("Creating conversation by not present sender/owner."); return(null); } ConversationMultiPoint conversation = new ConversationMultiPoint(_executionManager, message, senderID, GatherMessageClients(message, senderID), timeout); if (_isDisposed) {// Possible to get disposed while operating here. return(null); } lock (_timeOutMonitor) { _timeOutMonitor.AddEntity(conversation); } return(conversation); }
/// <summary> /// Since the MT4 uses its slippage in points, we need to convert. /// </summary> /// <param name="normalValue"></param> /// <returns></returns> protected int ConvertSlippage(Symbol symbol, decimal?normalValue) { RuntimeDataSessionInformation session = null; //string convertedSymbol = ConvertSymbol(symbol); lock (this) { if (_dataSessions.ContainsKey(symbol)) { session = _dataSessions[symbol].SessionInformation; } } if (normalValue.HasValue == false) {// -1 encoded for full value. return(-1); } if (session == null) { SystemMonitor.Error("Session for symbol [" + symbol + "] not created yet. Slippage conversion failed."); return(-1); } return((int)((double)normalValue * Math.Pow(10, session.Info.DecimalPlaces))); }
/// <summary> /// /// </summary> public void HandleRequest(TransportInfo transportInfo, bool subscribe, DataSubscriptionInfo?info) { if (transportInfo.OriginalSenderId.HasValue == false) { SystemMonitor.Error("Original sender not available in transport info."); return; } lock (this) { if (info.HasValue == false) { _subscriptions.Remove(transportInfo.OriginalSenderId.Value); } else { if (_subscriptions.ContainsKey(transportInfo.OriginalSenderId.Value)) { _subscriptions[transportInfo.OriginalSenderId.Value] = new KeyValuePair <TransportInfo, DataSubscriptionInfo>(transportInfo, DataSubscriptionInfo.Combine(_subscriptions[transportInfo.OriginalSenderId.Value].Value, subscribe, info.Value)); } else { _subscriptions[transportInfo.OriginalSenderId.Value] = new KeyValuePair <TransportInfo, DataSubscriptionInfo>(transportInfo, info.Value); } } } }
/// <summary> /// Save expert source code to local file. /// </summary> public bool SaveLocal() { if (IsExternal) { SystemMonitor.Error("This expert is external, can not save locally."); return(false); } try { using (FileStream fs = File.Create(_filePath)) { using (StreamWriter sw = new StreamWriter(fs)) { if (string.IsNullOrEmpty(_sourceCode) == false) { sw.Write(_sourceCode); } } } } catch (Exception ex) { SystemMonitor.OperationError(ex.Message); _isSavedLocally = false; return(false); } _isSavedLocally = true; return(true); }
/// <summary> /// Prepare the object for operation. Access to this allows externals to use the 2 /// step component registration process. /// Called to bring up a component for operation. Does not add the component /// permanently to the platform. /// </summary> public bool InitializeComponent(PlatformComponent component) { TracerHelper.Trace(component.Name); try { if (component.IsInitialized == false) { Arbiter.AddClient(component); // This allows the component to persist while initializing. component.PersistenceDataUpdatedEvent += new GeneralHelper.GenericDelegate <IDBPersistent>(HandleComponentPersistenceDataUpdatedEvent); } if (component.IsInitialized || component.Initialize(this)) { return(true); } } catch (Exception ex) { SystemMonitor.Error(string.Format("Exception occured during initializing component [{0}, {1}]", component.Name, ex.Message)); } // Failed to initialize component. component.PersistenceDataUpdatedEvent -= new GeneralHelper.GenericDelegate <IDBPersistent>(HandleComponentPersistenceDataUpdatedEvent); Arbiter.RemoveClient(component); return(false); }
// for the double (and int) values, 0 means do not change, -1 means set to "not assigned" // << Result format : int& orderTicket, int& operationID, double& stopLoss, double& takeProfit, double& targetOpenPrice, int& expiration public string RequestModifyOrder() { try { int operationId; ModifyOrderMessage message = base.GetPendingMessage <ModifyOrderMessage>(true, out operationId); if (message == null) { return(string.Empty); } string result = message.Symbol.Name.ToString() + SeparatorSymbol + message.OrderId.ToString() + SeparatorSymbol + operationId.ToString() + SeparatorSymbol + TranslateModificationValue(message.StopLoss).ToString(GeneralHelper.UniversalNumberFormatInfo) + SeparatorSymbol + TranslateModificationValue(message.TakeProfit).ToString(GeneralHelper.UniversalNumberFormatInfo) + SeparatorSymbol + TranslateModificationValue(message.TargetOpenPrice).ToString(GeneralHelper.UniversalNumberFormatInfo) + SeparatorSymbol + TranslateModificationValue(message.Expiration).ToString(); TracerHelper.Trace(result); return(result); } catch (Exception ex) {// Make sure we handle any possible unexpected exceptions, as otherwise they bring the // entire package (MT4 included) down with a bad error. SystemMonitor.Error(ex.Message); } return(string.Empty); }
// >> public void OrderModified(string symbol, int operationID, int orderTicket, int orderNewTicket, bool operationResult, string operationResultMessage) { TracerHelper.Trace(symbol); try { OperationInformation operation = base.GetOperationById(operationID); if (operation != null) { ModifyOrderResponseMessage message; lock (this) { message = new ModifyOrderResponseMessage(_accountInfo, orderTicket.ToString(), orderNewTicket.ToString(), operationResult); message.OperationResultMessage = operationResultMessage; } base.CompleteOperation(operationID, message); } lock (this) { _pendingOrdersInformations.Add(orderTicket.ToString()); } } catch (Exception ex) {// Make sure we handle any possible unexpected exceptions, as otherwise they bring the // entire package (MT4 included) down with a bad error. SystemMonitor.Error(ex.Message); } }
/// <summary> /// /// </summary> public bool AddPosition(Position position) { if (position.Symbol.IsEmpty || string.IsNullOrEmpty(position.Symbol.Name)) { SystemMonitor.Warning("Added a position with empty symbol."); return(false); } lock (this) { if (_positions.ContainsKey(position.Symbol)) { SystemMonitor.Warning("Added a position, but symbol already has a position."); return(false); } _positions.Add(position.Symbol, position); } position.UpdateEvent += new UpdateDelegate(position_UpdateEvent); if (PositionsAddedEvent != null) { if (_provider == null || _provider.DefaultAccount == null) { SystemMonitor.Error("Provider or account not yet assigned, position add event not launched."); } else { PositionsAddedEvent(this, _provider.DefaultAccount.Info, new Position[] { position }); } } return(true); }
private void listViewSessions_RetrieveVirtualItem(object sender, RetrieveVirtualItemEventArgs e) { //if (_manager != null) //{ // int totalCount = 0; // lock (_manager) // {// Since we do a lenghtly iteration make sure full lock is applied. // foreach (string group in _manager.Groups) // { // List<DataSessionInfo> sessions = new List<DataSessionInfo>(_manager.GetGroupSessions(group)); // int currentCount = sessions.Count; // if (e.ItemIndex >= totalCount && e.ItemIndex < totalCount + currentCount) // { // DataSessionInfo orderInfo = sessions[e.ItemIndex - totalCount]; // e.Item = new ListViewItem(new string[] { orderInfo.Name, orderInfo.BaseCurrency.Name, "-", "-" }); // e.Item.Tag = orderInfo; // return; // } // totalCount += sessions.Count; // } // } //} e.Item = new ListViewItem("Item not found."); SystemMonitor.Error("Item not found."); }
/// <summary> /// /// </summary> /// <returns></returns> public virtual bool Initialize(DataSessionInfo?sessionInfo) { if (sessionInfo.HasValue == false) { sessionInfo = _sessionInfo; } if (IsInitOrOperational(_sessionDataProvider.OperationalState) == false) { if (_sessionDataProvider.Initialize(sessionInfo) == false) { SystemMonitor.Error("Data provider for expert session can not be initialized."); ChangeOperationalState(OperationalStateEnum.NotOperational); return(false); } } ChangeOperationalState(OperationalStateEnum.Initializing); _sessionDataProvider.OperationalStateChangedEvent += new OperationalStateChangedDelegate(_subItem_OperationalStatusChangedEvent); if (_orderExecutionProvider != null) { SystemMonitor.CheckReport(_orderExecutionProvider.OperationalState == OperationalStateEnum.Operational, "Order execution provider not ready on session init."); _orderExecutionProvider.OperationalStateChangedEvent += new OperationalStateChangedDelegate(_subItem_OperationalStatusChangedEvent); } _subItem_OperationalStatusChangedEvent(null, OperationalStateEnum.Unknown); return(true); }
public bool AddSymbol(ComponentId dataSourceId, Symbol symbol, out string operationResultMessage) { if (_dataSourceId.HasValue && _dataSourceId.Value != dataSourceId) { operationResultMessage = "One source per watch component currently supported."; SystemMonitor.Error(operationResultMessage); return(false); } _dataSourceId = dataSourceId; if (_delivery == null) { _delivery = base.ObtainDataDelivery(_dataSourceId.Value); } RuntimeDataSessionInformation info = _delivery.GetSymbolRuntimeSessionInformation(symbol); if (info == null) { operationResultMessage = "Failed to obtain symbol runtime session information."; return(false); } _delivery.SubscribeToData(info.Info, true, new DataSubscriptionInfo(true, false, null)); _delivery.QuoteUpdateEvent += new QuoteUpdateDelegate(delivery_QuoteUpdateEvent); operationResultMessage = string.Empty; return(true); }
/// <summary> /// Load expert source code from local file. /// </summary> /// <param name="checkLoadOnly">Only perform check if source and file are the same and update SaveLocally variable.</param> public bool LoadLocal(bool checkLoadOnly) { if (IsExternal) { SystemMonitor.Error("This expert is external, can not save locally."); return(false); } string sourceCode; try { using (FileStream fs = File.OpenRead(_filePath)) { using (StreamReader sr = new StreamReader(fs)) { sourceCode = sr.ReadToEnd(); } } } catch (Exception ex) { SystemMonitor.Error("Failed to load local expert file [" + _filePath + "] [" + ex.Message + " ]"); return(false); } if (checkLoadOnly == false) { _sourceCode = sourceCode; } _isSavedLocally = _sourceCode.CompareTo(sourceCode) == 0; return(true); }
/// <summary> /// /// </summary> public void Quotes(string symbol, int operationId, double ask, double bid, double open, double close, double low, double high, double volume, double time) { TracerHelper.TraceEntry(); CombinedDataSubscriptionInformation session = GetDataSession(symbol); if (session == null) { SystemMonitor.Error("Failed to find symbol session [" + symbol + "], quotes not sent."); return; } try { QuoteUpdateMessage message = new QuoteUpdateMessage(session.SessionInformation.Info, new Quote((decimal)ask, (decimal)bid, (decimal)open, (decimal)close, (decimal)high, (decimal)low, (decimal)volume, GeneralHelper.GenerateDateTimeSecondsFrom1970((long)time)), true); SendToDataSubscribers(session, message, null); } catch (Exception ex) {// Make sure we handle any possible unexpected exceptions, as otherwise they bring the // entire package (MT4 included) down with a bad error. SystemMonitor.Error(ex.Message); } }
/// <summary> /// Managed thread entrance only. /// </summary> void Managed_tdSink_ITradeDeskEvents_Event_OnRowChanged(object tableDisp, string rowID) { if (LoggedIn) { TradeDeskAut desk = _desk; if (desk == null) { return; } try { FXCore.ITableAut t = (FXCore.ITableAut)tableDisp; if ("offers".Equals(t.Type)) { TableAut offersTable = (TableAut)desk.FindMainTable("offers"); RowAut instrumentRow = (RowAut)offersTable.FindRow("OfferID", rowID, 0); DataTick dataTick = new DataTick(); dataTick.Ask = (decimal)((double)instrumentRow.CellValue("Ask")); dataTick.Bid = (decimal)((double)instrumentRow.CellValue("Bid")); dataTick.DateTime = (DateTime)instrumentRow.CellValue("Time"); QuoteUpdateDelegate delegateInstance = QuoteUpdatedEvent; if (delegateInstance != null) { GeneralHelper.FireAndForget(delegateInstance, this, (string)instrumentRow.CellValue("Instrument"), dataTick); } } else if ("orders".Equals(t.Type)) { // Orders table empty? //TableAut offersTable = (TableAut)desk.FindMainTable("orders"); //RowAut instrumentRow = (RowAut)offersTable.FindRow("OrderID", rowID, 0); //string accountId; //OrderInfo? info = Managed_ExtractOrderInfo(instrumentRow, out accountId); //OrderUpdateDelegate delegateInstance = OrderUpdatedEvent; //if (info.HasValue && delegateInstance != null) //{ // GeneralHelper.FireAndForget(delegateInstance, this, accountId, info.Value); //} } else if ("accounts".Equals(t.Type)) { ItemUpdateDelegate delegateInstance = AccountUpdatedEvent; if (delegateInstance != null) { GeneralHelper.FireAndForget(delegateInstance, this, rowID); } } } catch (System.Exception ex) { SystemMonitor.Error("Failed to handle OnRow event", ex); } } }
public override void OnException(ExceptionContext filterContext) { SystemMonitor.Error(filterContext.Exception, "Error executing request."); if (filterContext.ExceptionHandled || !filterContext.HttpContext.IsCustomErrorEnabled) { return; } if (new HttpException(null, filterContext.Exception).GetHttpCode() != 500) { return; } if (!ExceptionType.IsInstanceOfType(filterContext.Exception)) { return; } // if the request is AJAX return JSON else view. if (filterContext.HttpContext.Request.Headers["X-Requested-With"] == "XMLHttpRequest") { filterContext.Result = new JsonResult { JsonRequestBehavior = JsonRequestBehavior.AllowGet, Data = new { error = true, message = filterContext.Exception.Message } }; } else { var controllerName = (string)filterContext.RouteData.Values["controller"]; var actionName = (string)filterContext.RouteData.Values["action"]; var model = new HandleErrorInfo(filterContext.Exception, controllerName, actionName); filterContext.Result = new ViewResult { ViewName = View, MasterName = Master, ViewData = new ViewDataDictionary <HandleErrorInfo>(model), TempData = filterContext.Controller.TempData }; } // log the error using log4net. SystemMonitor.Error(filterContext.Exception, filterContext.Exception.Message); filterContext.ExceptionHandled = true; filterContext.HttpContext.Response.Clear(); filterContext.HttpContext.Response.StatusCode = 500; filterContext.HttpContext.Response.TrySkipIisCustomErrors = true; }
public override void EntityExecutionFailed(ExecutionEntity entity, Exception exception) { SystemMonitor.Error("Execution of entity failed [" + exception.ToString() + "]."); lock (_executingEntities) { SystemMonitor.CheckError(_executingEntities.Contains(entity), "Removing entity not present in conversation."); _executingEntities.Remove(entity); } }
public bool RemovePersistedComponentById(long componentId) { if (PersistenceHelper.Delete <PlatformComponent>(new MatchExpression("Id", componentId)) != 1) { SystemMonitor.Error("Failed to remove persisted component [" + componentId + "]."); return(false); } return(true); }
static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e) { //string message = e.Exception.Message; //if (e.Exception.InnerException != null && string.IsNullOrEmpty(e.Exception.InnerException.Message)) //{ // message += ", inner [" + e.Exception.InnerException.Message + "]"; //} SystemMonitor.Error("Application exception ", e.Exception); }