示例#1
0
        private void CheckForLimits(string message)
        {
            foreach (string msg in limits)
            {
                if (message.Contains(msg))
                {
                    // there is a limit message

                    #region system status
                    Maple.ApplicationStatus.SetStatus(statusSystemName, "Error", "Bloomberg limit has been reached - " + msg + ".", 1);
                    #endregion

                    #region email
                    if (!sentLimitEmail)
                    {
                        Maple.Email email = new Maple.Email();
                        string      html  = string.Format("<HTML><BODY><P>{0}</P><P>This automated email sent from {1} : </BR> {2} </P></BODY><HTML>",
                                                          "Please check, get the limit reset by Bloomberg ASAP, and if necessary run the app on a backup machine.</BR></BR>" + message,
                                                          Environment.MachineName,
                                                          Environment.GetCommandLineArgs()[0]);
                        email.SendEmail(emailErrorsTo,
                                        "Bloomberg limit has been reached on machine " + Environment.MachineName,
                                        html,
                                        true);
                    }
                    #endregion

                    sentLimitEmail = true;
                    break;
                }
            }
        }
示例#2
0
        /// <summary>
        /// Processes misc Bloomberg events.
        /// </summary>
        /// <param name="eventObj">The event obj.</param>
        /// <param name="session">The session.</param>
        private void processMiscEvents(BB.Event eventObj, BB.Session session)
        {
            foreach (BB.Message msg in eventObj.GetMessages())
            {
                UpdateStatus(msg.MessageType.ToString());

                switch (msg.MessageType.ToString())
                {
                case "SessionStarted":
                    break;

                case "SessionTerminated":
                case "SessionStopped":
                    break;

                case "ServiceOpened":
                    break;

                case "RequestFailure":
                    UpdateStatus("*** REQUEST FAILURE ***");

                    BB.Element reason     = msg.GetElement(REASON);
                    string     reasonText = string.Format("Error: Source-[{0}], Code-[{1}], Category-[{2}], Desc-[{3}]",
                                                          reason.GetElementAsString(SOURCE),
                                                          reason.GetElementAsString(ERROR_CODE),
                                                          reason.GetElementAsString(CATEGORY),
                                                          reason.GetElementAsString(DESCRIPTION));
                    UpdateStatus(reasonText);
                    UpdateStatus("Error message body : " + msg.ToString());

                    bool hasGUID          = false;
                    bool hasResponseError = false;
                    try {
                        Guid reqGUID = (Guid)msg.CorrelationID.Object;
                        hasGUID          = true;
                        hasResponseError = msg.HasElement("responseError");
                    } catch {
                        hasGUID          = false;
                        hasResponseError = false;
                    }

                    if (hasGUID & hasResponseError)
                    {
                        UpdateStatus("GUID and responseError found - handling normally");

                        // has both a GUID and a response error so can be handled normally
                        processSubscriptionDataEvent(eventObj, session);
                    }
                    else if (hasGUID)
                    {
                        UpdateStatus("GUID found - updating GUID list.");

                        Guid reqGUID = (Guid)msg.CorrelationID.Object;
                        // only has a GUID so add to the list of returned GUIDs
                        if (!guids.Contains(reqGUID))
                        {
                            guids.Add(reqGUID);
                        }
                    }
                    else
                    {
                        // ok, email out that a timeout has occurred
                        Maple.Email email = new Maple.Email();
                        email.SendEmail(emailErrorsTo,
                                        "Bloomberg Request Failure",
                                        "A RequestFailure response has been returned from Bloomberg." + Environment.NewLine + reasonText + Environment.NewLine + msg.ToString(),
                                        false);
                    }
                    break;

                default:
                    UpdateStatus("*** Unhandled Misc Event ***");
                    break;
                }
            }
        }