Esempio n. 1
0
        public static void CopyDrawings(XmlDocument xmlResult, string url)
        {
            //Copy XML and order to GR_Cfg_DocumentQueue and send process-command through message queue to remote Windows service
            try
            {
                DatabaseFactory.InsertDocumentRecord(xmlResult, Triggers.pubOrderNumber, Triggers.dbEnvironment, StagingUtilities.dbSite, C1WebService.SPOrderNumber);
            }
            catch (System.Exception dbf1)
            {
                Triggers.logEvent = "ERROR QR: " + dbf1.Message;
                System.Diagnostics.EventLog.WriteEntry(Triggers.logSource, Triggers.logEvent, System.Diagnostics.EventLogEntryType.Information, 234);
            }

            Triggers.logEvent = "Signal Message Queue to begin document processing for: " + Triggers.pubOrderNumber + " -> " + C1WebService.SPOrderNumber;
            System.Diagnostics.EventLog.WriteEntry(Triggers.logSource, Triggers.logEvent, System.Diagnostics.EventLogEntryType.Information, 234);

            //Send command to ZMQ listener to process newly created record from queue
            //setup
            using (ZMQ.Context context = new ZMQ.Context())
            {
                using (ZMQ.Socket requester = context.Socket(ZMQ.SocketType.REQ))
                {
                    //connect to remote endpoint, <server>
                    if (Triggers.dbEnvironment == "PROD")
                    {
                        requester.Connect("tcp://192.168.23.19:5555");  //grc000dmzbus
                    }
                    else
                    {
                        requester.Connect("tcp://172.16.1.60:5555");    //grctslsql0 (dev)
                    }

                    //send on the REQ pattern
                    string requestText = "PROCESS:" + Triggers.pubOrderNumber;
                    requester.Send(Encoding.ASCII.GetBytes(requestText.ToCharArray()));

                    //receive Response on the REP pattern
                    string ackMsg = requester.Recv(Encoding.ASCII);
                    Triggers.logEvent = "Message received from ZMQ: " + ackMsg;
                    System.Diagnostics.EventLog.WriteEntry(Triggers.logSource, Triggers.logEvent, System.Diagnostics.EventLogEntryType.Information, 234);
                }
            }

            //If site was not NOVB, disable the C1Order trigger for the order-site and then move the queue record to the appropriate site queue table
            switch (StagingUtilities.dbSite)
            {
            case "NOVB":
                //do nothing
                break;

            default:
                DatabaseFactory.MoveQueueRecord(Triggers.pubOrderNumber, StagingUtilities.dbSite);
                break;
            }
        }
Esempio n. 2
0
        public AnnaHttpServer(string busControllerUrl, string rpcHostUrl, string httpUrl)
        {
            if (string.IsNullOrEmpty(busControllerUrl))
            {
                throw new ArgumentNullException("busControllerUrl");
            }

            if (string.IsNullOrEmpty(rpcHostUrl))
            {
                throw new ArgumentNullException("rpcHostUrl");
            }

            if (string.IsNullOrEmpty(httpUrl))
            {
                throw new ArgumentNullException("httpUrl");
            }

            LoggerProvider.EnvironmentLogger.Info("Starting HTTP Server...");

            broadcastSocket.Connect(busControllerUrl);
            broadcastSocket.Subscribe("STOP-HTTPD", Encoding.UTF8);

            if (!httpUrl.EndsWith("/"))
            {
                httpUrl += '/';
            }

            this.httpHostUrl = httpUrl;
            LoggerProvider.EnvironmentLogger.Info(String.Format("HTTP Listen: [{0}]", httpUrl));

            this.rpcReqUrl = rpcHostUrl;
            LoggerProvider.EnvironmentLogger.Info("Connecting to MQ: [" + this.rpcReqUrl + "]");
        }
Esempio n. 3
0
        public Client(string address, int port = 4949)
        {
            ctx = new Context(4);
            sock = ctx.Socket(SocketType.REQ);

            // TODO: set me
            bmp = new Bitmap(640, 480, PixelFormat.Format16bppRgb555);

            sock.Connect("tcp://"+address+":"+port.ToString());

            buf = new byte[640*480*3]; // w*h*BYTES PER PIXEL!

            dcmp = new LZ4Decompressor64(); // returns appropriate sized decompressor

            decompressed = new byte[640 * 480 * 3];
        }
Esempio n. 4
0
        public static void ProcessingLoop()
        {
            if (!SlipstreamEnvironment.Initialized)
            {
                throw new InvalidOperationException(
                          "Unable to start PRC-Handler thread, please initialize the environment first.");
            }

            var broadcastUrl  = SlipstreamEnvironment.Settings.BroadcastUrl;
            var rpcHandlerUrl = SlipstreamEnvironment.Settings.RpcHandlerUrl;
            var id            = Guid.NewGuid();

            LoggerProvider.EnvironmentLogger.Debug(
                () => string.Format("Starting RpcHandler thread[{0}] URL=[{1}] ...", id, rpcHandlerUrl));

            using (var broadcastSocket = new ZMQ.Socket(ZMQ.SocketType.SUB))
                using (var receiver = new ZMQ.Socket(ZMQ.SocketType.REP))
                {
                    broadcastSocket.Connect(broadcastUrl);
                    broadcastSocket.Subscribe("STOP-RPC", Encoding.UTF8);
                    LoggerProvider.EnvironmentLogger.Debug(
                        () => string.Format("RpcHandler thread[{0}] is connected to the Commander URL[{1}]", id, broadcastUrl));

                    receiver.Connect(rpcHandlerUrl);

                    var items = new PollItem[2];
                    items[0] = broadcastSocket.CreatePollItem(IOMultiPlex.POLLIN);
                    items[0].PollInHandler += new PollHandler(BusControllerPollInHandler);

                    items[1] = receiver.CreatePollItem(IOMultiPlex.POLLIN);
                    items[1].PollInHandler += new PollHandler(ReceiverPollInHandler);

                    lock (s_lockObj)
                    {
                        s_running = true;
                    }

                    //  Process messages from both sockets
                    while (s_running)
                    {
                        Context.Poller(items, -1);
                    }

                    LoggerProvider.EnvironmentLogger.Debug(
                        () => string.Format("The RpcHandler thread[{0}] is stopped", id));
                }
        }
Esempio n. 5
0
        /// <summary>
        /// Fancy way to connect to socket insuring that connection accepted.
        /// Seems to make sence only for in-proc transport.
        /// </summary>
        public void Connect(String address, CancellationToken token)
        {
            while (!token.IsCancellationRequested)
            {
                try
                {
                    _zmqSocket.Connect(address);
                    return;
                }
                catch (ZMQ.Exception ex)
                {
                    // Connection refused
                    if (ex.Errno == 107)
                    {
                        SpinWait.SpinUntil(() => token.IsCancellationRequested, 200);
                        Thread.Sleep(20);
                        continue;
                    }

                    throw;
                }
            }
        }
Esempio n. 6
0
 public override void Start(long period, TimeUnit unit)
 {
     socket_.Connect(endpoint_);
     base.Start(period, unit);
 }