Exemple #1
0
        public static void Warn(string messageFormat, params object[] arg)
        {
            var message = string.Format(messageFormat, arg);

            ErrorMessageHandler.Warn(message);
            LastErrorMessageType = "Warn";
            LastErrorMessage     = string.Format(message, arg);
        }
Exemple #2
0
        public static void Error(string messageFormat, params object[] arg)
        {
            var message = string.Format(messageFormat, arg);

            ErrorMessageHandler.Error(message);
            LastErrorMessageType = "Error";
            LastErrorMessage     = message;
        }
Exemple #3
0
        public static void Notice(string messageFormat, params object[] arg)
        {
            var message = string.Format(messageFormat, arg);

            ErrorMessageHandler.Notice(message);
            LastErrorMessageType = "Notice";
            LastErrorMessage     = string.Format(message, arg);
        }
 public void testADKRetryPublish()
 {
     IElementDef objType = StudentDTD.STUDENTCONTACT;
      ErrorMessageHandler handler =
      new ErrorMessageHandler(ErrorMessageHandler.HandlerBehavior.ThrowADKRetryException);
      fZone.SetPublisher(handler, objType, null);
      fZone.Connect(ProvisioningFlags.Register);
      AssertRetryHandling(handler, createSIF_Request(objType), fZone);
 }
Exemple #5
0
        /// <summary>
        /// Main loop for listener task.
        /// </summary>
        private void NotificationLoop()
        {
            while (IsListening())
            {
                List <NotificationMessage> messages = new List <NotificationMessage>();
                try
                {
                    messages = SqlProcedures.ReceiveSubscription(AppName);
                }
                catch (Exception ex)
                {
                    try
                    {
                        ErrorMessageHandler.Invoke(new NotificationMessage(ex.Message));
                    }
                    catch (Exception)
                    { }
                }
                foreach (NotificationMessage message in messages)
                {
                    try
                    {
                        switch (message.MessageType)
                        {
                        case NotificationMessageType.Error:
                            ErrorMessageHandler.Invoke(message);
                            break;

                        case NotificationMessageType.NotImplementedType:
                            ErrorMessageHandler.Invoke(message);
                            break;

                        case NotificationMessageType.Unsubscribed:
                            UnsubscribedMessageHandler.Invoke(message);
                            break;

                        case NotificationMessageType.Empty:
                            break;

                        default:
                            MessageHandler.Invoke(message);
                            break;
                        }
                    }
                    catch (Exception ex)
                    {
                        try
                        {
                            message.AddError(ex);
                            ErrorMessageHandler.Invoke(message);
                        }
                        catch (Exception)
                        { }
                    }
                }
            }
        }
Exemple #6
0
        private static void OnAutoStartComplete()
        {
            if (_Started != null)
            {
                _Started(null, null);
            }

            // Clear everything out
            _DisplayError    = null;
            s_AutoStartStack = null;
        }
 public HistoricalFacade(
     HistoricalRequestFormatter historicalRequestFormatter,
     LookupDispatcher lookupDispatcher,
     ErrorMessageHandler errorMessageHandler,
     HistoricalMessageHandler historicalMessageHandler,
     HistoricalRawFacade historicalRawFacade,
     int timeoutMs) : base(lookupDispatcher, errorMessageHandler, timeoutMs)
 {
     _historicalMessageHandler   = historicalMessageHandler;
     _historicalRequestFormatter = historicalRequestFormatter;
     Raw = historicalRawFacade;
 }
        public void testADKRetryEvent()
        {
            IElementDef objType = StudentDTD.STUDENTCONTACT;
             ErrorMessageHandler handler = new ErrorMessageHandler(ErrorMessageHandler.HandlerBehavior.ThrowADKRetryException);

             // SifContext ctxt = SifContext.Create("SIF_SUBSCRIBE");
             // SubscriptionOptions options = new SubscriptionOptions(ctxt);

             fZone.SetSubscriber(handler, objType, null);
             SIF_Event evnt = createSIF_Event(objType);

             fZone.Connect(ProvisioningFlags.Register);
             AssertRetryHandling(handler, evnt, fZone);
        }
Exemple #9
0
        // Loads all the services found in the servers directory
        public static void LoadServices(ErrorMessageHandler onError)
        {
            s_Services          = new Dictionary <string, Service>();
            s_ImmutableServices = new ImmutableDictionary <string, Service>(s_Services);

            // Just to ensure an empty environment is available at least
            if (s_Environment == null)
            {
                s_Environment  = new Dictionary <string, string>();
                s_ImmutableEnv = new ImmutableDictionary <string, string>(s_Environment);
            }

            try
            {
                // Get a list of all the services in the environment and try to load them
                foreach (string dir in Directory.EnumerateDirectories("servers"))
                {
                    string serviceName = Path.GetFileName(dir);
                    try
                    {
                        // Skip directories starting with "." or "!" (because windows explorer won't allow you to create a directory starting with '.')
                        if ((serviceName.StartsWith(".") == false) && (serviceName.StartsWith("!") == false))
                        {
                            ServiceDetails.Service service = new ServiceDetails.Service(serviceName);
                            s_Services.Add(service.Name, service);
                        }
                    }
                    catch (ServiceDetails.IgnoreServiceException)
                    {
                        // This service has been flagged as to be ignored
                    }
                    catch (ServiceDetails.ParserError x)
                    {
                        if (onError != null)
                        {
                            onError(serviceName, x.Message);
                        }
                    }
                }
            }
            catch (DirectoryNotFoundException)
            {
                onError("Servie", "Servers directory not found.");
            }
        }
Exemple #10
0
 public SymbolFacade(
     SymbolRequestFormatter symbolRequestFormatter,
     LookupDispatcher lookupDispatcher,
     ErrorMessageHandler errorMessageHandler,
     SymbolMessageHandler symbolMessageHandler,
     MarketSymbolDownloader marketSymbolDownloader,
     MarketSymbolReader marketSymbolReader,
     ExpiredOptionDownloader expiredOptionDownloader,
     ExpiredOptionReader expiredOptionReader,
     int timeoutMs) : base(lookupDispatcher, errorMessageHandler, timeoutMs)
 {
     _symbolRequestFormatter  = symbolRequestFormatter;
     _symbolMessageHandler    = symbolMessageHandler;
     _expiredOptionReader     = expiredOptionReader;
     _expiredOptionDownloader = expiredOptionDownloader;
     _marketSymbolReader      = marketSymbolReader;
     _marketSymbolDownloader  = marketSymbolDownloader;
 }
        public static LookupClient CreateNew(string host   = IQFeedDefault.Hostname, int port = IQFeedDefault.LookupPort,
                                             int timeoutMs = LookupDefault.TimeoutMs, int numberOfClients = 1, int bufferSize = LookupDefault.BufferSize)
        {
            // Common
            var requestFormatter    = new RequestFormatter();
            var lookupDispatcher    = new LookupDispatcher(host, port, bufferSize, IQFeedDefault.ProtocolVersion, numberOfClients, requestFormatter);
            var errorMessageHandler = new ErrorMessageHandler();
            var rawMessageHandler   = new RawMessageHandler(lookupDispatcher, errorMessageHandler, timeoutMs);

            // Historical
            var historicalDataRequestFormatter = new HistoricalRequestFormatter();
            var historicalRawFace = new HistoricalRawFacade(historicalDataRequestFormatter, rawMessageHandler);
            var historicalFacade  = new HistoricalFacade(
                historicalDataRequestFormatter,
                lookupDispatcher,
                errorMessageHandler,
                new HistoricalMessageHandler(),
                historicalRawFace,
                timeoutMs
                );

            // News
            var newsFacade = new NewsFacade();

            // Symbol
            var symbolFacade = new SymbolFacade(
                new SymbolRequestFormatter(),
                lookupDispatcher,
                errorMessageHandler,
                new SymbolMessageHandler(),
                new MarketSymbolDownloader(),
                new MarketSymbolReader(),
                new ExpiredOptionDownloader(),
                new ExpiredOptionReader(),
                timeoutMs);

            // Chains
            var chainsFacade = new ChainsFacade(new ChainsRequestFormatter(), new ChainsMessageHandler(), lookupDispatcher, errorMessageHandler, timeoutMs);

            return(new LookupClient(lookupDispatcher, historicalFacade, newsFacade, symbolFacade, chainsFacade));
        }
Exemple #12
0
        // Start a single service
        public static void StartService(Service service, ErrorMessageHandler displayError)
        {
            if (s_AutoStartStack != null)
            {
                throw new Exception("Services are already being started.");
            }
            _DisplayError = displayError;

            s_AutoStartStack = new Stack <Service>();

            // Push the service onto the stack
            if (!service.IsRunning)
            {
                s_AutoStartStack.Push(service);
            }

            if (_StartRequested != null)
            {
                _StartRequested(null, null);
            }
            StartFirstServiceOnStack();
        }
        public void testEventThrowsNullPointerException()
        {
            IElementDef objType = StudentDTD.STUDENTCONTACT;
             ErrorMessageHandler handler =
             new ErrorMessageHandler(ErrorMessageHandler.HandlerBehavior.ThrowNullPointerException);

             SubscriptionOptions options = new SubscriptionOptions();

             fZone.SetSubscriber(handler, objType, options);
             fZone.Connect(ProvisioningFlags.Register);
             //

             //fZone.SetSubscriber(handler, objType, null);
             SIF_Event evnt = createSIF_Event(objType);
             AssertExceptionHandling(handler, evnt, fZone, typeof(NullReferenceException));
        }
Exemple #14
0
 public ChainsFacade(ChainsRequestFormatter chainsRequestFormatter, ChainsMessageHandler chainsMessageHandler, LookupDispatcher lookupDispatcher, ErrorMessageHandler errorMessageHandler, int timeoutMs) : base(lookupDispatcher, errorMessageHandler, timeoutMs)
 {
     _chainsMessageHandler   = chainsMessageHandler;
     _chainsRequestFormatter = chainsRequestFormatter;
 }
 private void AssertRetryHandling(ErrorMessageHandler handler, SifMessagePayload payload, ZoneImpl zone)
 {
     try
      {
     assertNormalHandling(handler, payload, zone);
      }
      catch (SifException ex)
      {
     Assert.IsTrue(handler.wasCalled(), "Handler was not called");
     Assert.AreEqual(SifErrorCategoryCode.Transport, ex.ErrorCategory,
                     "SIF Error category should be 10: " + ex.Message);
      }
      Assert.IsTrue(handler.wasCalled(), "Handler was not called");
      AssertThreadIsOK();
 }
 private void assertNormalHandling(ErrorMessageHandler handler, SifMessagePayload payload, ZoneImpl zone)
 {
     MessageDispatcher testDispatcher = new MessageDispatcher(zone);
      int result = testDispatcher.dispatch(payload);
      Assert.IsTrue(handler.wasCalled(), "Handler was not called");
      Assert.AreEqual(1, result, "Result code should always be 1 because this version does not support SMB");
 }
        private void AssertExceptionHandling(ErrorMessageHandler handler, SifMessagePayload payload, ZoneImpl zone,
                                             Type expectedExceptionType)
        {
            Exception exc = null;
             try
             {
            assertNormalHandling(handler, payload, zone);
             }
             catch (Exception ex)
             {
            exc = ex;
            Assert.IsTrue(handler.wasCalled(), "Handler was not called");

            AdkMessagingException adkme = ex as AdkMessagingException;
            Assert.IsNotNull(adkme,
                             "Expected an ADKMessagingException, but was " + ex.GetType().Name + ":" + ex.ToString());

             Exception source = adkme;
             Exception innerEx = null;
             while( source.InnerException != null )
             {
                 innerEx = source.InnerException;
                 source = innerEx;
             }
            Assert.IsNotNull(innerEx, "AdkMessaginException was thrown but inner exception was not set");

            if (innerEx.GetType() != expectedExceptionType)
            {
               Assert.Fail("Exception thrown was not a " + expectedExceptionType.Name + ", but was " +
                           innerEx.GetType().Name + ":" + innerEx.ToString());
            }
             }

             Assert.IsNotNull(exc, "An exception was not thrown by the handler");
             AssertThreadIsOK();
        }
 public void testUndeliverableRetryEvent()
 {
     IElementDef objType = StudentDTD.STUDENTCONTACT;
      ErrorMessageHandler handler =
      new ErrorMessageHandler(ErrorMessageHandler.HandlerBehavior.ThrowSIFRetryException);
      fAgent.ErrorHandler = handler;
      SIF_Event evnt = createSIF_Event(objType);
      fZone.Connect(ProvisioningFlags.Register);
      AssertRetryHandling(handler, evnt, fZone);
 }
        public void testSIFRetryQueryResultsNoCache()
        {
            IElementDef objType = StudentDTD.STUDENTCONTACT;
             ErrorMessageHandler handler =
             new ErrorMessageHandler(ErrorMessageHandler.HandlerBehavior.ThrowSIFRetryException);

             fZone.SetQueryResults(handler, objType, null );
             fZone.Connect(ProvisioningFlags.Register);
             SIF_Response r = createSIF_Response(objType, false, null);
             AssertRetryHandling(handler, r, fZone);

             // Now, dispatch a second time. This time the dispatching should work correctly, including
             // custom state
             handler.Behavior = ErrorMessageHandler.HandlerBehavior.Normal;
             assertNormalHandling(handler, r, fZone);
             assertRequestCacheCleared(r);
        }
        public void testSIFRetryEvent()
        {
            IElementDef objType = StudentDTD.STUDENTCONTACT;
             ErrorMessageHandler handler = new ErrorMessageHandler(ErrorMessageHandler.HandlerBehavior.ThrowADKRetryException);

             fZone.SetSubscriber(handler, objType, null);
             SIF_Event evnt = createSIF_Event(objType);
             fZone.Connect(ProvisioningFlags.Register);
             AssertRetryHandling(handler, evnt, fZone);
        }
        public void testQueryResultsNoCache()
        {
            IElementDef objType = StudentDTD.STUDENTCONTACT;
             ErrorMessageHandler handler = new ErrorMessageHandler(ErrorMessageHandler.HandlerBehavior.Normal);

             fZone.SetQueryResults(handler, objType, null );
             fZone.Connect(ProvisioningFlags.Register);
             SIF_Response r = createSIF_Response(objType, false, null);
             assertNormalHandling(handler, r, fZone);
             assertRequestCacheCleared(r);
        }
 protected BaseLookupFacade(LookupDispatcher lookupDispatcher, ErrorMessageHandler errorMessageHandler, int timeoutMs)
 {
     _lookupDispatcher    = lookupDispatcher;
     _errorMessageHandler = errorMessageHandler;
     _timeoutMs           = timeoutMs;
 }
Exemple #23
0
        /// <summary>Reads the TOC, processes it, returns the track list and last sector</summary>
        /// <param name="dev">Device</param>
        /// <param name="dumpLog">Dump log</param>
        /// <param name="force">Force dump enabled</param>
        /// <param name="lastSector">Last sector number</param>
        /// <param name="leadOutStarts">Lead-out starts</param>
        /// <param name="mediaTags">Media tags</param>
        /// <param name="stoppingErrorMessage">Stopping error message handler</param>
        /// <param name="toc">Full CD TOC</param>
        /// <param name="trackFlags">Track flags</param>
        /// <param name="updateStatus">Update status handler</param>
        /// <returns>List of tracks</returns>
        public static Track[] GetCdTracks(Device dev, DumpLog dumpLog, bool force, out long lastSector,
                                          Dictionary <int, long> leadOutStarts,
                                          Dictionary <MediaTagType, byte[]> mediaTags,
                                          ErrorMessageHandler stoppingErrorMessage, out FullTOC.CDFullTOC?toc,
                                          Dictionary <byte, byte> trackFlags, UpdateStatusHandler updateStatus)
        {
            byte[]       cmdBuf;                         // Data buffer
            const uint   sectorSize = 2352;              // Full sector size
            bool         sense;                          // Sense indicator
            List <Track> trackList = new List <Track>(); // Tracks in disc

            byte[] tmpBuf;                               // Temporary buffer
            toc        = null;
            lastSector = 0;
            TrackType leadoutTrackType = TrackType.Audio;

            // We discarded all discs that falsify a TOC before requesting a real TOC
            // No TOC, no CD (or an empty one)
            dumpLog?.WriteLine("Reading full TOC");
            updateStatus?.Invoke("Reading full TOC");
            sense = dev.ReadRawToc(out cmdBuf, out _, 0, dev.Timeout, out _);

            if (!sense)
            {
                toc = FullTOC.Decode(cmdBuf);

                if (toc.HasValue)
                {
                    tmpBuf = new byte[cmdBuf.Length - 2];
                    Array.Copy(cmdBuf, 2, tmpBuf, 0, cmdBuf.Length - 2);
                    mediaTags?.Add(MediaTagType.CD_FullTOC, tmpBuf);
                }
            }

            updateStatus?.Invoke("Building track map...");
            dumpLog?.WriteLine("Building track map...");

            if (toc.HasValue)
            {
                FullTOC.TrackDataDescriptor[] sortedTracks =
                    toc.Value.TrackDescriptors.OrderBy(track => track.POINT).ToArray();

                foreach (FullTOC.TrackDataDescriptor trk in sortedTracks.Where(trk => trk.ADR == 1 || trk.ADR == 4))
                {
                    if (trk.POINT >= 0x01 &&
                        trk.POINT <= 0x63)
                    {
                        trackList.Add(new Track
                        {
                            TrackSequence = trk.POINT,
                            TrackSession  = trk.SessionNumber,
                            TrackType     = (TocControl)(trk.CONTROL & 0x0D) == TocControl.DataTrack ||
                                            (TocControl)(trk.CONTROL & 0x0D) == TocControl.DataTrackIncremental
                                            ? TrackType.Data : TrackType.Audio,
                            TrackStartSector =
                                (ulong)((trk.PHOUR * 3600 * 75) + (trk.PMIN * 60 * 75) + (trk.PSEC * 75) + trk.PFRAME -
                                        150),
                            TrackBytesPerSector    = (int)sectorSize,
                            TrackRawBytesPerSector = (int)sectorSize
                        });

                        trackFlags?.Add(trk.POINT, trk.CONTROL);
                    }
                    else if (trk.POINT == 0xA2)
                    {
                        int phour, pmin, psec, pframe;

                        if (trk.PFRAME == 0)
                        {
                            pframe = 74;

                            if (trk.PSEC == 0)
                            {
                                psec = 59;

                                if (trk.PMIN == 0)
                                {
                                    pmin  = 59;
                                    phour = trk.PHOUR - 1;
                                }
                                else
                                {
                                    pmin  = trk.PMIN - 1;
                                    phour = trk.PHOUR;
                                }
                            }
                            else
                            {
                                psec  = trk.PSEC - 1;
                                pmin  = trk.PMIN;
                                phour = trk.PHOUR;
                            }
                        }
                        else
                        {
                            pframe = trk.PFRAME - 1;
                            psec   = trk.PSEC;
                            pmin   = trk.PMIN;
                            phour  = trk.PHOUR;
                        }

                        lastSector = (phour * 3600 * 75) + (pmin * 60 * 75) + (psec * 75) + pframe - 150;
                        leadOutStarts?.Add(trk.SessionNumber, lastSector + 1);
                    }
                    else if (trk.POINT == 0xA0 &&
                             trk.ADR == 1)
                    {
                        leadoutTrackType =
                            (TocControl)(trk.CONTROL & 0x0D) == TocControl.DataTrack ||
                            (TocControl)(trk.CONTROL & 0x0D) == TocControl.DataTrackIncremental ? TrackType.Data
                                : TrackType.Audio;
                    }
                }
            }
            else
            {
                updateStatus?.Invoke("Cannot read RAW TOC, requesting processed one...");
                dumpLog?.WriteLine("Cannot read RAW TOC, requesting processed one...");
                sense = dev.ReadToc(out cmdBuf, out _, false, 0, dev.Timeout, out _);

                TOC.CDTOC?oldToc = TOC.Decode(cmdBuf);

                if ((sense || !oldToc.HasValue) &&
                    !force)
                {
                    dumpLog?.WriteLine("Could not read TOC, if you want to continue, use force, and will try from LBA 0 to 360000...");

                    stoppingErrorMessage?.
                    Invoke("Could not read TOC, if you want to continue, use force, and will try from LBA 0 to 360000...");

                    return(null);
                }

                if (oldToc.HasValue)
                {
                    foreach (TOC.CDTOCTrackDataDescriptor trk in oldToc.Value.TrackDescriptors.
                             OrderBy(t => t.TrackNumber).
                             Where(trk => trk.ADR == 1 || trk.ADR == 4))
                    {
                        if (trk.TrackNumber >= 0x01 &&
                            trk.TrackNumber <= 0x63)
                        {
                            trackList.Add(new Track
                            {
                                TrackSequence = trk.TrackNumber,
                                TrackSession  = 1,
                                TrackType     = (TocControl)(trk.CONTROL & 0x0D) == TocControl.DataTrack ||
                                                (TocControl)(trk.CONTROL & 0x0D) == TocControl.DataTrackIncremental
                                                ? TrackType.Data : TrackType.Audio,
                                TrackStartSector       = trk.TrackStartAddress,
                                TrackBytesPerSector    = (int)sectorSize,
                                TrackRawBytesPerSector = (int)sectorSize
                            });

                            trackFlags?.Add(trk.TrackNumber, trk.CONTROL);
                        }
                        else if (trk.TrackNumber == 0xAA)
                        {
                            leadoutTrackType =
                                (TocControl)(trk.CONTROL & 0x0D) == TocControl.DataTrack ||
                                (TocControl)(trk.CONTROL & 0x0D) == TocControl.DataTrackIncremental ? TrackType.Data
                                    : TrackType.Audio;

                            lastSector = trk.TrackStartAddress - 1;
                        }
                    }
                }
            }

            if (trackList.Count == 0)
            {
                updateStatus?.Invoke("No tracks found, adding a single track from 0 to Lead-Out");
                dumpLog?.WriteLine("No tracks found, adding a single track from 0 to Lead-Out");

                trackList.Add(new Track
                {
                    TrackSequence          = 1,
                    TrackSession           = 1,
                    TrackType              = leadoutTrackType,
                    TrackStartSector       = 0,
                    TrackBytesPerSector    = (int)sectorSize,
                    TrackRawBytesPerSector = (int)sectorSize
                });

                trackFlags?.Add(1, (byte)(leadoutTrackType == TrackType.Audio ? 0 : 4));
            }

            if (lastSector != 0)
            {
                return(trackList.ToArray());
            }

            sense = dev.ReadCapacity16(out cmdBuf, out _, dev.Timeout, out _);

            if (!sense)
            {
                byte[] temp = new byte[8];

                Array.Copy(cmdBuf, 0, temp, 0, 8);
                Array.Reverse(temp);
                lastSector = (long)BitConverter.ToUInt64(temp, 0);
            }
            else
            {
                sense = dev.ReadCapacity(out cmdBuf, out _, dev.Timeout, out _);

                if (!sense)
                {
                    lastSector = (cmdBuf[0] << 24) + (cmdBuf[1] << 16) + (cmdBuf[2] << 8) + cmdBuf[3];
                }
            }

            if (lastSector > 0)
            {
                return(trackList.ToArray());
            }

            if (!force)
            {
                stoppingErrorMessage?.
                Invoke("Could not find Lead-Out, if you want to continue use force option and will continue until 360000 sectors...");

                dumpLog?.WriteLine("Could not find Lead-Out, if you want to continue use force option and will continue until 360000 sectors...");

                return(null);
            }

            updateStatus?.
            Invoke("WARNING: Could not find Lead-Out start, will try to read up to 360000 sectors, probably will fail before...");

            dumpLog?.WriteLine("WARNING: Could not find Lead-Out start, will try to read up to 360000 sectors, probably will fail before...");
            lastSector = 360000;

            return(trackList.ToArray());
        }
Exemple #24
0
        protected void Application_Error(object sender, EventArgs e)
        {
            var app = sender as HttpApplication;

            if (app == null)
            {
                return;
            }

            HttpErrorResponse httpError = null;

            try
            {
                var exception = app.Server.GetLastError();
                //Logger.ErrorFormat("Caught unhandled exception in http module: {0}.", exception);
                httpError = ErrorMessageHandler.CreateResponseFromException(exception);
            }
            catch (Exception ex)
            {
                //Logger.ErrorFormat("Error occurred when handling exception: {0}", ex);
                httpError = new HttpErrorResponse
                {
                    HttpStatusCode = HttpStatusCode.InternalServerError,
                    ErrorOutput    = new ErrorResponse(new Error
                    {
                        Code    = ErrorCode.InternalServerError,
                        Message = ErrorMessage.InternalServerError
                    })
                };
            }

            var response = app.Context.Response;

            response.TrySkipIisCustomErrors = true;

            // Ensure ASP.NET not to show 'Yellow Screen of Death'.
            app.Server.ClearError();

            #region 创建返回类

            // Ensure that any content written to the response stream is erased.
            response.Clear();
            response.ClearContent();

            response.StatusCode  = (int)httpError.HttpStatusCode;
            response.ContentType = "application/json; charset=utf-8";

            if (httpError.Headers != null)
            {
                foreach (var key in httpError.Headers.AllKeys)
                {
                    response.AddHeader(key, httpError.Headers.Get(key));
                }
            }
            #endregion

            string responseString = httpError.ErrorOutput.ToJsonDefault();
            response.Output.Write(responseString);

            response.Flush();

            app.Context.ApplicationInstance.CompleteRequest();
        }
        public void testNormalEvent()
        {
            IElementDef objType = StudentDTD.STUDENTCONTACT;
             ErrorMessageHandler handler = new ErrorMessageHandler(ErrorMessageHandler.HandlerBehavior.Normal);

             SubscriptionOptions options = new SubscriptionOptions();

             fZone.SetSubscriber(handler, objType, options);
             fZone.Connect(ProvisioningFlags.Register);
             //fZone.SetSubscriber(handler, objType, null);
             SIF_Event evnt = createSIF_Event(objType);
             assertNormalHandling(handler, evnt, fZone);
        }