Exemple #1
0
        protected override bool Visit(IErrorMessage error)
        {
            Log.LogError("{0}: {1}", error.ExceptionType, Escape(error.Message));
            Log.LogError(error.StackTrace);

            return base.Visit(error);
        }
Exemple #2
0
        protected override bool Visit(IErrorMessage error)
        {
            Console.Error.WriteLine("{0}: {1}", error.ExceptionType, Escape(error.Message));
            Console.Error.WriteLine(error.StackTrace);

            return base.Visit(error);
        }
Exemple #3
0
        protected override bool Visit(IErrorMessage error)
        {
            Log.LogError("{0}: {1}", error.ExceptionType, Escape(error.Message));
            Log.LogError(error.StackTrace);

            return(base.Visit(error));
        }
Exemple #4
0
        protected override bool Visit(IErrorMessage error)
        {
            Log.LogError("{0}", Escape(ExceptionUtility.CombineMessages(error)));
            Log.LogError("{0}", ExceptionUtility.CombineStackTraces(error));

            return(base.Visit(error));
        }
        protected override bool Visit(IErrorMessage error)
        {
            Log.LogError("{0}", Escape(ExceptionUtility.CombineMessages(error)));
            Log.LogError("{0}", ExceptionUtility.CombineStackTraces(error));

            return base.Visit(error);
        }
Exemple #6
0
        protected override bool Visit(IErrorMessage error)
        {
            Console.Error.WriteLine("{0}: {1}", error.ExceptionType, Escape(error.Message));
            Console.Error.WriteLine(error.StackTrace);

            return(base.Visit(error));
        }
Exemple #7
0
        public void DisplayMessage(int n)
        {
            lock (this)
            {
                int errorCount = ServiceManager.ErrorHandler.ErrorList.Count;
                Debug.Assert(n >= 0 && n < Services.ServiceManager.ErrorHandler.ErrorList.Count, "Bad ErrorList index!");

                currentMessage = Services.ServiceManager.ErrorHandler.ErrorList[n] as IErrorMessage;

                if (currentMessage != null)
                {
                    //textBox1.Text = (currentMessage.FullDescription != null) ?
                    //    currentMessage.FullDescription : currentMessage.Text;

                    // let \n be the new line character instead of \r\n
                    string message = (currentMessage.FullDescription != null) ?
                                     currentMessage.FullDescription : currentMessage.Text;
                    textBox1.Lines = message.Split('\n');

                    currentErrorIsFirstError = (n == 0) ? true : false;

                    ShowButtons();

                    SendMessage("Errors Pending");
                    this.Show();
                }
            }
        }
        protected override bool Visit(IErrorMessage error)
        {
            Console.Error.WriteLine("{0}: {1}", error.ExceptionTypes[0], Escape(ExceptionUtility.CombineMessages(error)));
            Console.Error.WriteLine(ExceptionUtility.CombineStackTraces(error));

            return base.Visit(error);
        }
Exemple #9
0
        protected override bool Visit(IErrorMessage error)
        {
            Console.Error.WriteLine("{0}: {1}", error.ExceptionTypes[0], Escape(ExceptionUtility.CombineMessages(error)));
            Console.Error.WriteLine(ExceptionUtility.CombineStackTraces(error));

            return(base.Visit(error));
        }
 public OnMessage_ErrorMessage()
 {
     errorMessage = Substitute.For<IErrorMessage>();
     errorMessage.ExceptionType.Returns("ExceptionType");
     errorMessage.Message.Returns("This is my message \t\r\n");
     errorMessage.StackTrace.Returns("Line 1\r\nLine 2\r\nLine 3");
 }
        protected override bool Visit(IErrorMessage error)
        {
            ExecutionSummary.Errors++;

            logger.LogError("Catastrophic failure: {0}", ExceptionUtility.CombineMessages(error));

            return(!cancelledThunk());
        }
 _ErrorMessage AdaptErrorMessage(IErrorMessage message) =>
 new _ErrorMessage
 {
     ExceptionParentIndices = message.ExceptionParentIndices,
     ExceptionTypes         = message.ExceptionTypes,
     Messages    = message.Messages,
     StackTraces = message.StackTraces
 };
        protected override bool Visit(IErrorMessage error)
        {
            var stackFrameInfo = GetStackFrameInfo(error);

            Log.LogError(null, null, null, stackFrameInfo.Item1, stackFrameInfo.Item2, 0, 0, 0, "{0}", Escape(ExceptionUtility.CombineMessages(error)));
            Log.LogError(null, null, null, stackFrameInfo.Item1, stackFrameInfo.Item2, 0, 0, 0, "{0}", ExceptionUtility.CombineStackTraces(error));

            return base.Visit(error);
        }
        protected override bool Visit(IErrorMessage error)
        {
            var stackFrameInfo = GetStackFrameInfo(error);

            Log.LogError(null, null, null, stackFrameInfo.Item1, stackFrameInfo.Item2, 0, 0, 0, "{0}", Escape(ExceptionUtility.CombineMessages(error)));
            Log.LogError(null, null, null, stackFrameInfo.Item1, stackFrameInfo.Item2, 0, 0, 0, "{0}", ExceptionUtility.CombineStackTraces(error));

            return(base.Visit(error));
        }
        // Called for xunit1:
        // 1. Catastrophic error, i.e. the test runner throws. The only expected exception
        //    is for ambiguous method names. Test run is aborted
        // 2. class failure, i.e. fixture's ctor or dispose throws. Test methods are not run
        //    if the fixture's ctor throws. Not called for exceptions in class ctor/dispose
        //    (these are reported as failing test methods, as the class is created for each
        //     test method)
        // Not called for xunit2
        protected override bool Visit(IErrorMessage errorMessage)
        {
            // TODO: Verify what error.TestCases is in both scenarios above
            var classNames = string.Join(", ",
                                         errorMessage.TestCases.Select(tc => tc.TestMethod.TestClass.Class.Name).Distinct().ToArray());
            var methodMessage = string.Format("Class failed in {0}", classNames);

            HandleFailure(errorMessage, errorMessage.TestCases, methodMessage);
            return(context.ShouldContinue);
        }
        public ErrorFormPresenter(IErrorForm form, IErrorMessage errorMessage)
        {
            this.form         = form;
            this.errorMessage = errorMessage;

            form.ErrorMessage = errorMessage.GetControl();
            form.Title        = errorMessage.ErrorType;

            errorMessage.OkButtonClicked += ProcessOkClick;
        }
Exemple #17
0
        protected override bool Visit(IErrorMessage error)
        {
            lock (consoleLock)
            {
                Console.WriteLine("   {0} [FATAL]", Escape(error.ExceptionTypes[0]));
                Console.WriteLine("      {0}", Escape(ExceptionUtility.CombineMessages(error)));

                WriteStackTrace(ExceptionUtility.CombineStackTraces(error));
            }

            return(base.Visit(error));
        }
        void PaintLeafPortal_Out_ReportError(IErrorMessage errorMessage)
        {
            string innerExceptionText = "";
            if (errorMessage.Exception.InnerException != null)
            {
                innerExceptionText = "\n\n" + errorMessage.Exception.InnerException;
            }

            MessageBox.Show(this, errorMessage.Exception.Message + innerExceptionText,
                "Es ist ein Fehler aufgetreten",
                MessageBoxButtons.OK, MessageBoxIcon.Error);
        }
        protected override bool Visit(IErrorMessage error)
        {
            lock (consoleLock)
            {
                Console.Error.WriteLine("   {0} [FATAL]", Escape(error.ExceptionTypes[0]));
                Console.Error.WriteLine("      {0}", Escape(ExceptionUtility.CombineMessages(error)));

                WriteStackTrace(ExceptionUtility.CombineStackTraces(error));
            }

            return base.Visit(error);
        }
Exemple #20
0
        /// <summary>
        /// Сохраниь ошибку для сообщения
        /// </summary>
        /// <param name="error">Ошибка</param>
        public void SetError(IErrorMessage error)
        {
            var message = Db.Messages.FirstOrDefault(i => i.MessageId == error.MessageId);

            if (message == null)
            {
                return;
            }

            message.Status          = (Status)error.Status;
            message.ErrorException  = error.ErrorMessage;
            Db.Entry(message).State = EntityState.Modified;
            Db.SaveChanges();
        }
        protected override bool Visit(IErrorMessage error)
        {
            lock (consoleLock)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.Error.WriteLine("   {0} [FATAL]", Escape(error.ExceptionType));
                Console.ForegroundColor = ConsoleColor.Gray;
                Console.Error.WriteLine("      {0}", Escape(error.Message));

                WriteStackTrace(error.StackTrace);
            }

            return(base.Visit(error));
        }
        protected override bool Visit(IErrorMessage error)
        {
            lock (consoleLock)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.Error.WriteLine("   {0} [FATAL]", Escape(error.ExceptionType));
                Console.ForegroundColor = ConsoleColor.Gray;
                Console.Error.WriteLine("      {0}", Escape(error.Message));

                WriteStackTrace(error.StackTrace);
            }

            return base.Visit(error);
        }
        protected override bool Visit(IErrorMessage error)
        {
            lock (consoleLock)
            {
#if ASPNET50
                Console.ForegroundColor = ConsoleColor.Red;
#endif
                Console.Error.WriteLine("   {0} [FATAL]", Escape(error.ExceptionTypes[0]));
#if ASPNET50
                Console.ForegroundColor = ConsoleColor.Gray;
#endif
                Console.Error.WriteLine("      {0}", Escape(ExceptionUtility.CombineMessages(error)));

                WriteStackTrace(ExceptionUtility.CombineStackTraces(error));
            }

            return(base.Visit(error));
        }
        private byte[] Compose(IErrorMessage message)
        {
            byte[] packet = PreparePacketWithHeader(_info.MinPacketLength + 1, message.SlaveDeviceAddress);

            if (message is ProtocolSpecifiedErrorMessage mgError)
            {
                packet[_info.DataOffset] = (byte)mgError.ErrorCode;
            }
            else
            {
                packet[_info.DataOffset] = ConvertCommonErrorMessageCode(message);
            }


            packet[packet.Length - 1] =
                CheckSum.Crc8(packet.Take(packet.Length - _info.PacketCheckSumSize).ToArray());

            return(packet);
        }
Exemple #25
0
        public DefaultErrorPanel(IErrorMessage message)
        {
            // This call is required by the Windows.Forms Form Designer.
            InitializeComponent();

            // TODO: Add any initialization after the InitializeComponent call
            this.message = message;

            textBox1.Text = (message.FullDescription != null) ? message.FullDescription : message.Text;
            // left button text
            if (message.BtnList.Left == ErrorButton.NoButton)
            {
                btnLeft.Hide();
            }
            else
            {
                btnLeft.Text = message.BtnList.Left.ToString();
            }
            // middle button text
            if (message.BtnList.Middle == ErrorButton.NoButton)
            {
                btnMiddle.Hide();
            }
            else
            {
                btnMiddle.Text = message.BtnList.Middle.ToString();
            }
            // right button text
            if (message.BtnList.Right == ErrorButton.NoButton)
            {
                btnRight.Hide();
            }
            else
            {
                btnRight.Text = message.BtnList.Right.ToString();
            }
        }
        public void UnRegisterMessage(IErrorMessage message)
        {
            lock (this)
            {
                if (errorList.Contains(message))
                {
                    LogMessage("Un-Register error: " + message.Text + " From: " + message.Source);
                    if (logFileEnabled)
                    {
                        string s = "-" + DateTime.Now.ToString("h:mm:ss.ff") + " Error=" + message.Text + " Source=" + message.Source;
                        WriteToLogFile(s);
                    }
                    // find the error stats in the hashtable
                    if (errorTable.ContainsKey(message.UniqueID))
                    {
                        MessageRecord rec = errorTable[message.UniqueID] as MessageRecord;
                        if (rec != null)
                        {
                            rec.Stop();
                        }
                    }
                    errorList.Remove(message);

                    if (errorList.Count == 0)
                    {
                        lastHandledMessage = null;
                    }

                    updateRequired = true;
                    //					myUI.RemoveMessage(message);		// UI timer will remove the message itseld

                    SaveErrorTable();
                    SaveErrorTableTxt();
                }
            }
        }
Exemple #27
0
        protected override bool Visit(IErrorMessage error)
        {
            WriteError("FATAL", error);

            return(base.Visit(error));
        }
Exemple #28
0
        protected override bool Visit(IErrorMessage error)
        {
            WriteError("FATAL", error);

            return base.Visit(error);
        }
Exemple #29
0
        protected override bool Visit(IErrorMessage error)
        {
            recorder.SendMessage(TestMessageLevel.Error, String.Format("Catastrophic failure: {0}", ExceptionUtility.CombineMessages(error)));

            return(!cancelledThunk());
        }
Exemple #30
0
 public void ReportError(IErrorMessage error) {
   throw new NotImplementedException();
 }
 void IMetadataHost.ReportError(IErrorMessage error)
 {
     throw new NotImplementedException();
 }
Exemple #32
0
        public static string ToJson(this IErrorMessage errorMessage)
        {
            var json = initObject("fatalError", errorMessage, typeof(IErrorMessage));

            return(ToJson(json));
        }
Exemple #33
0
 /// <summary>
 /// Called when an instance of <see cref="IErrorMessage"/> is sent to the message sink.
 /// </summary>
 /// <param name="error">The message.</param>
 /// <returns>Return <c>true</c> to continue executing tests; <c>false</c> otherwise.</returns>
 protected virtual bool Visit(IErrorMessage error)
 {
     return(true);
 }
Exemple #34
0
 private ErrorDetail ConvertMessage(IErrorMessage arg)
 {
     return new ErrorDetail(arg.Message, arg.Location);
 }
Exemple #35
0
        protected override bool Visit(IErrorMessage error)
        {
            AddError("fatal", null, error);

            return(base.Visit(error));
        }
        /// <inheritdoc/>
        protected override bool Visit(IErrorMessage error)
        {
            LogError("FATAL ERROR", error);

            return(base.Visit(error));
        }
        public void RegisterMessage(IErrorMessage message)
        {
            Debug.Assert(message != null, "ErrorHandler.RegisterMessage() received a message that does not implement IErrorMessage interface");
            Debug.Assert(message.Text != null, "ErrorHandler.RegsisterMessage() received a message that has no text assigned!");

            // need to verify that message is not already in queue
            foreach (IErrorMessage msg in errorList)
            {
                if (msg.UniqueID == message.UniqueID)
                {
                    string s = String.Format("The error \"{0}\" is already enqueued!", message.Text);
                    ServiceManager.Tracing.Trace(s);
                    return;
                }
            }
            lock (this)
            {
                LogMessage("Register error: " + message.Text + " From: " + message.Source);
                message.TimeIn = DateTime.Now;
                if (logFileEnabled)
                {
                    string s = "+" + DateTime.Now.ToString("h:mm:ss.ff") + " Error=" + message.Text + " Source=" + message.Source;
                    WriteToLogFile(s);
                }
                int i;
                for (i = 0; i < errorList.Count; i++)
                {
                    if (message.Priority > ((ErrorMessage)errorList[i]).Priority)
                    {
                        break;
                    }
                }

                if ((lastHandledMessage != null) && (lastHandledMessage.Source == message.Source))
                {
                    i = 0;
                }

                errorList.Insert(i, message);

                // Check time and dat file existing,
                // If file not existed, imply that start new shift
                //      Clear errortable and start new file, note
                // If file existed, no action needed

                // Check time and dat file existing,
                DateTime tmpDate = new DateTime();
                tmpDate = DateTime.Now.AddHours(-6);

                string newErrorTableFileName = string.Format(errorTableFileNameFormat, tmpDate.ToString("yyyyMMddtt"));
                if (!File.Exists(errorTableFilePath + errorTableFilePrefix + newErrorTableFileName))
                {
                    errorTable.Clear();
                    errorTableStartDateTime = tmpDate.AddHours(6);
                    errorTableFileName      = newErrorTableFileName;
                }


                // find the error stats in the hashtable
                if (errorTable.ContainsKey(message.UniqueID))
                {
                    MessageRecord rec = errorTable[message.UniqueID] as MessageRecord;
                    if (rec != null)
                    {
                        rec.Start();
                    }
                }
                else                                                    // new error, need to
                {
                    MessageRecord rec = new MessageRecord(message);
                    errorTable.Add(message.UniqueID, rec);
                    rec.Start();
                }
                updateRequired = true;
                myUI.EnableTimer();

                SaveErrorTable();
                SaveErrorTableTxt();
            }
        }
Exemple #38
0
        protected override QState StateError(IQEvent qEvent)
        {
            LogStateInfo(_processName, System.Reflection.MethodBase.GetCurrentMethod().Name, qEvent);

            if (qEvent.IsSignal(QSignals.Entry))
            {
                _isErrorstate = true;
                string str = this.ToString();
                str = str.Substring(str.LastIndexOf(".") + 1);
                str = str.Remove(str.LastIndexOf("-"));
                str = str + ": " + this.currentException.Source;
                _workcell.DisplayTitleMessage("Error Occurred (" + str + ")");
            }
            if (qEvent.IsSignal(QSignals.Exit))
            {
                _isErrorstate = false;
                string str = this.ToString();
                str = str.Substring(str.LastIndexOf(".") + 1);
                str = str.Remove(str.LastIndexOf("-"));
                str = str + ": " + this.currentException.Source;
                _workcell.DisplayTitleMessage("Error Cleared (" + str + ")");

                // Log alarm cleared.
                string errMsg = this.GetErrorLogFormatString();
                Log.Error(this, "{0} Message:{1}", LoggerCategory.AlarmCleared, errMsg);
            }
            if (qEvent.IsSignal(base.SigStateJob))
            {
                // Format to CLU error format.
                this.errorMessageHST.Format();

                this.DefaultErrorHandler();

                // Change state UDT.
                _workcell.ARAMSState.ChangeState(ARAMSStateHST.ARAMSSubstateCodes.UDT_UnscheduledDownTime);

                // Log alarm occured
                string errMsg = this.GetErrorLogFormatString();
                Log.Error(this, "{0} Message:{1}", LoggerCategory.AlarmOccured, errMsg);

                string [] maintenance_msg = this.GetMaintenanceLogFormatString();
                Log.Maintenance(this, "{0}, {1}", maintenance_msg[0], maintenance_msg[1]);
                return(null);
            }
            if (!qEvent.IsSignal(Active.SigResume))
            {
                return(this.statePaused);
            }
            System.Threading.Thread.Sleep(500);
            _workcell.OffAlarm = false;
            switch (base.errorMessage.ButtonSelected)
            {
            case ErrorButton.Abort:
                this._workcell.MainProcess.Abort();
                break;

            case ErrorButton.Retry:
            {
                base.targetState = base.stateHistory;
                base.TransitionToWithoutJob(base.targetState);
                QEvent event2 = new QEvent(base.SigStateJob);
                event2.EventObject = base.errorMessage.ButtonSelected;
                this.errorMessage  = null;
                base.PostFIFO(event2);
                break;
            }

            case ErrorButton.Stop:
                this._workcell.MainProcess.Stop();

                for (int i = 0; i < ServiceManager.ErrorHandler.ErrorList.Count; i++)
                {
                    IErrorMessage currentMessage = ServiceManager.ErrorHandler.ErrorList[i] as IErrorMessage;
                    ServiceManager.ErrorHandler.UnRegisterMessage(currentMessage);
                }
                break;

            case ErrorButton.NoButton:
                //TY: Treat NoButton as Retry
                Console.Beep();
                base.targetState = base.stateHistory;
                base.TransitionToWithoutJob(base.targetState);
                QEvent event4 = new QEvent(base.SigStateJob);
                event4.EventObject = base.errorMessage.ButtonSelected;
                this.errorMessage  = null;
                base.PostFIFO(event4);
                break;

            default:
            {
                base.targetState = base.stateHistory;
                base.TransitionToWithoutJob(base.targetState);
                QEvent event3 = new QEvent(base.SigRecover);
                event3.EventObject = base.errorMessage.ButtonSelected;
                base.PostFIFO(event3);
                break;
            }
            }
            return(null);
        }
Exemple #39
0
        protected override bool Visit(IErrorMessage errorMessage)
        {
            ReportError("Fatal Error", errorMessage);

            return(true);
        }
 public void ReportError(IErrorMessage error) {
 }
 public void Handle(IErrorMessage message)
 {
     _outputTextColour = DarkRed;
     _outputText       = string.Format("Error : Code {0} ", message.ErrorCode);
 }
Exemple #42
0
 protected override bool Visit(IErrorMessage error)
 {
     Calls.Add("IErrorMessage");
     return base.Visit(error);
 }
Exemple #43
0
 /// <summary>
 /// Raises the CompilationErrors event with the given error wrapped up in an error event arguments object.
 /// The event is raised on a separate thread.
 /// </summary>
 /// <param name="error">The error to report.</param>
 public void ReportError(IErrorMessage error) {
   if (this.Errors != null) {
     List<IErrorMessage> errors = new List<IErrorMessage>(1);
     errors.Add(error);
     Microsoft.Cci.ErrorEventArgs errorEventArguments = new Microsoft.Cci.ErrorEventArgs(error.ErrorReporter, error.Location, errors.AsReadOnly());
     this.ReportErrors(errorEventArguments);
   }
 }
Exemple #44
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TransformedResult&lt;T&gt;"/> class.
 /// </summary>
 /// <param name="errorMessage">The error message.</param>
 /// <param name="result">The result object.</param>
 public TransformedResult(IErrorMessage errorMessage, T result)
 {
     this.errorMessage = errorMessage;
     this.resultData   = result;
 }
Exemple #45
0
        public override ITransformedResult <ExecutionFX> GetTransformed()
        {
            ExecutionFX   returnObject = new ExecutionFX();
            IErrorMessage errorMessage = null;

            try
            {
                if (string.IsNullOrEmpty(this.SiamNumber))
                {
                    string message = string.Format(MESSAGE_FORMAT, "Missing field in file : \"SIAM #\""
                                                   , string.Empty
                                                   , string.IsNullOrEmpty(this.FxCode) ? string.Empty : this.FxCode
                                                   , string.IsNullOrEmpty(this.Amount) ? string.Empty : this.Amount);

                    errorMessage = new ErrorMessage(ErrorMessageType.BusinessMessage, message);
                    // l'objet est setté à Null pour qu'il ne soit pas retourné dans le résultat
                    returnObject = null;
                }
                if (returnObject.IsNotNull() && string.IsNullOrEmpty(this.PurchaseSale))
                {
                    string message = string.Format(MESSAGE_FORMAT, "Missing field in file : \"Type\""
                                                   , string.IsNullOrEmpty(this.SiamNumber) ? string.Empty : this.SiamNumber
                                                   , string.IsNullOrEmpty(this.FxCode) ? string.Empty : this.FxCode
                                                   , string.IsNullOrEmpty(this.Amount) ? string.Empty : this.Amount);

                    errorMessage = new ErrorMessage(ErrorMessageType.BusinessMessage, message);
                    // l'objet est setté à Null pour qu'il ne soit pas retourné dans le résultat
                    returnObject = null;
                }
                if (returnObject.IsNotNull() && string.IsNullOrEmpty(this.Amount))
                {
                    string message = string.Format(MESSAGE_FORMAT, "Missing field in file : \"Amount\""
                                                   , string.IsNullOrEmpty(this.SiamNumber) ? string.Empty : this.SiamNumber
                                                   , string.IsNullOrEmpty(this.FxCode) ? string.Empty : this.FxCode
                                                   , string.Empty);

                    errorMessage = new ErrorMessage(ErrorMessageType.BusinessMessage, message);
                    // l'objet est setté à Null pour qu'il ne soit pas retourné dans le résultat
                    returnObject = null;
                }
                if (returnObject.IsNotNull() && string.IsNullOrEmpty(this.Currency))
                {
                    string message = string.Format(MESSAGE_FORMAT, "Missing field in file : \"Currency\""
                                                   , string.IsNullOrEmpty(this.SiamNumber) ? string.Empty : this.SiamNumber
                                                   , string.IsNullOrEmpty(this.FxCode) ? string.Empty : this.FxCode
                                                   , string.IsNullOrEmpty(this.Amount) ? string.Empty : this.Amount);

                    errorMessage = new ErrorMessage(ErrorMessageType.BusinessMessage, message);
                    // l'objet est setté à Null pour qu'il ne soit pas retourné dans le résultat
                    returnObject = null;
                }
                if (returnObject.IsNotNull() && string.IsNullOrEmpty(this.SpotRate))
                {
                    string message = string.Format(MESSAGE_FORMAT, "Missing field in file : \"Spot rate\""
                                                   , string.IsNullOrEmpty(this.SiamNumber) ? string.Empty : this.SiamNumber
                                                   , string.IsNullOrEmpty(this.FxCode) ? string.Empty : this.FxCode
                                                   , string.IsNullOrEmpty(this.Amount) ? string.Empty : this.Amount);

                    errorMessage = new ErrorMessage(ErrorMessageType.BusinessMessage, message);
                    // l'objet est setté à Null pour qu'il ne soit pas retourné dans le résultat
                    returnObject = null;
                }
                if (returnObject.IsNotNull() && string.IsNullOrEmpty(this.Maturity))
                {
                    string message = string.Format(MESSAGE_FORMAT, "Missing field in file : \"Maturity\""
                                                   , string.IsNullOrEmpty(this.SiamNumber) ? string.Empty : this.SiamNumber
                                                   , string.IsNullOrEmpty(this.FxCode) ? string.Empty : this.FxCode
                                                   , string.IsNullOrEmpty(this.Amount) ? string.Empty : this.Amount);

                    errorMessage = new ErrorMessage(ErrorMessageType.BusinessMessage, message);
                    // l'objet est setté à Null pour qu'il ne soit pas retourné dans le résultat
                    returnObject = null;
                }

                if (returnObject.IsNotNull())
                {
                    returnObject.AllIn  = string.IsNullOrEmpty(this.AllIn) ? decimal.Zero : Convert.ToDecimal(this.AllIn);
                    returnObject.Amount = string.IsNullOrEmpty(this.Amount) ? decimal.Zero : Convert.ToDecimal(this.Amount);

                    int confirmationNumber;

                    if (int.TryParse(this.ConfirmationNumber, out confirmationNumber))
                    {
                        returnObject.ConfirmationNumber = confirmationNumber;
                    }

                    if (String.Equals(this.Currency, "EUR"))
                    {
                        returnObject.AmountCurrencyId = (int)eCurrency.EUR;
                    }
                    else if (String.Equals(this.Currency, "USD"))
                    {
                        returnObject.AmountCurrencyId = (int)eCurrency.USD;
                    }
                    else if (String.Equals(this.Currency, "GBP"))
                    {
                        returnObject.AmountCurrencyId = (int)eCurrency.GBP;
                    }

                    if (String.Equals(this.ExchCurrency, "EUR") || String.Equals(this.ExchCurrency, "EU"))
                    {
                        returnObject.ExchCurrencyId = (int)eCurrency.EUR;
                    }
                    else if (String.Equals(this.ExchCurrency, "USD") || String.Equals(this.ExchCurrency, "US"))
                    {
                        returnObject.ExchCurrencyId = (int)eCurrency.USD;
                    }
                    else if (String.Equals(this.ExchCurrency, "GBP") || String.Equals(this.ExchCurrency, "GB"))
                    {
                        returnObject.ExchCurrencyId = (int)eCurrency.GBP;
                    }

                    if (string.IsNullOrEmpty(this.FwdPoint))
                    {
                        if (string.IsNullOrEmpty(this.AllIn))
                        {
                            returnObject.FwdPoint = decimal.Zero;
                        }
                        else
                        {
                            returnObject.FwdPoint = Convert.ToDecimal(this.AllIn) - Convert.ToDecimal(this.SpotRate);
                        }
                    }
                    if (string.IsNullOrEmpty(this.AllIn))
                    {
                        returnObject.AllIn = Convert.ToDecimal(this.SpotRate) + Convert.ToDecimal(returnObject.FwdPoint);
                    }

                    returnObject.ExchValue = string.IsNullOrEmpty(this.ExchValue) ? decimal.Zero : Convert.ToDecimal(this.ExchValue);
                    returnObject.FXHedge   = new FXHedge {
                        Code = this.FxCode
                    };
                    returnObject.Maturity = Convert.ToDateTime(this.Maturity);
                    returnObject.Nature   = this.Nature;
                    if (String.Equals(this.PurchaseSale, "A"))
                    {
                        returnObject.PurchaseSaleId = (int)ePurchaseSale.ACHAT;
                    }
                    if (String.Equals(this.PurchaseSale, "V"))
                    {
                        returnObject.PurchaseSaleId = (int)ePurchaseSale.VENTE;
                    }

                    returnObject.FwdPoint      = string.IsNullOrEmpty(this.FwdPoint) ? decimal.Zero : Convert.ToDecimal(this.FwdPoint);
                    returnObject.ExecutionCode = this.SiamNumber;
                    returnObject.SpotRate      = string.IsNullOrEmpty(this.SpotRate) ? decimal.Zero : Convert.ToDecimal(this.SpotRate);

                    if (returnObject.ExchCurrencyId != (int)eCurrency.EUR)
                    {
                        string message = string.Format(MESSAGE_FORMAT, "\"Exch value currency\" in file is not EUR"
                                                       , string.IsNullOrEmpty(this.SiamNumber) ? string.Empty : this.SiamNumber
                                                       , string.IsNullOrEmpty(this.FxCode) ? string.Empty : this.FxCode
                                                       , string.IsNullOrEmpty(this.Amount) ? string.Empty : this.Amount);

                        errorMessage = new ErrorMessage(ErrorMessageType.BusinessMessage, message);
                        // l'objet est setté à Null pour qu'il ne soit pas retourné dans le résultat
                        returnObject = null;
                    }

                    if (returnObject.IsNotNull() && !string.IsNullOrEmpty(this.AllIn) &&
                        Convert.ToDecimal(this.SpotRate) + Convert.ToDecimal(returnObject.FwdPoint) != Convert.ToDecimal(this.AllIn))
                    {
                        string message = string.Format(MESSAGE_FORMAT, "The result of difference between \"All in\" and \"Fwd pts\" in file is not equal to \"Spot rate\""
                                                       , string.IsNullOrEmpty(this.SiamNumber) ? string.Empty : this.SiamNumber
                                                       , string.IsNullOrEmpty(this.FxCode) ? string.Empty : this.FxCode
                                                       , string.IsNullOrEmpty(this.Amount) ? string.Empty : this.Amount);

                        errorMessage = new ErrorMessage(ErrorMessageType.BusinessMessage, message);
                        // l'objet est setté à Null pour qu'il ne soit pas retourné dans le résultat
                        returnObject = null;
                    }
                }
            }
            catch (Exception ex)
            {
                string message = ex.InnerException.IsNotNull() ? ex.InnerException.Message : ex.Message;
                errorMessage = new ErrorMessage(ErrorMessageType.TechnicalMessage, message);
            }

            return(new TransformedResult <ExecutionFX>(errorMessage, returnObject));
        }
Exemple #46
0
 public static void ThrowErrorMessage(this IHookable hookable, IErrorMessage message)
 {
     hookable.hook.ThrowErrorMessage(message);
 }
        protected override bool Visit(IErrorMessage error)
        {
            logger.LogImportantMessage(error.ToJson());

            return base.Visit(error);
        }
        protected override bool Visit(IErrorMessage error)
        {
            LogError("FATAL ERROR", error);

            return base.Visit(error);
        }