コード例 #1
0
        public void can_enumerate_multiple_pairs()
        {
            var rvm = new Rv.Message();

            rvm.AddField("custom1", "value1");
            rvm.AddField("custom2", "value2");
            var headers = new ReadOnlyRvMessageHeaders(rvm);

            Assert.AreEqual(new KeyValuePair <string, string>("custom1", "value1"), headers.First());
            Assert.AreEqual(new KeyValuePair <string, string>("custom2", "value2"), headers.ElementAt(1));
            Assert.AreEqual(2, headers.Count());
        }
コード例 #2
0
        public void cannot_access_the_body_via_the_header()
        {
            var rvm = new Rv.Message();

            rvm.AddField("Body", "value");
            var headers  = new ReadOnlyRvMessageHeaders(rvm);
            var ignoreed = headers["Body"];
        }
コード例 #3
0
        public void ContainsKey_returns_true_for_defined_int_property(string name, int value)
        {
            var rvm = new Rv.Message();

            rvm.AddField(name, value);
            var headers = new ReadOnlyRvMessageHeaders(rvm);

            Assert.IsTrue(headers.ContainsKey(name));
        }
コード例 #4
0
        public void enumerating_pairs_ignores_Body()
        {
            var rvm = new Rv.Message();

            rvm.AddField("Body", "value");
            var headers = new ReadOnlyRvMessageHeaders(rvm);

            Assert.AreEqual(0, headers.Count());
        }
コード例 #5
0
        public void can_create_message_with_body()
        {
            var rvm = new Rv.Message();

            rvm.AddField("Body", "hello");
            var msg = new ReadOnlyRvMessage(rvm, null);

            Assert.AreEqual("hello", msg.Body);
        }
コード例 #6
0
        public void can_read_PriorityFromString()
        {
            var rvm = new Rv.Message();

            rvm.AddField("Priority", "1");
            var headers = new ReadOnlyRvMessageHeaders(rvm);

            Assert.AreEqual(1, headers.Priority);
        }
コード例 #7
0
        public void can_read_content_type(string type)
        {
            var rvm = new Rv.Message();

            rvm.AddField("ContentType", type);
            var headers = new ReadOnlyRvMessageHeaders(rvm);

            Assert.AreEqual(type, headers.ContentType);
            Assert.AreEqual(1, headers.Count, "headers.Count");
        }
コード例 #8
0
        public void can_read_custom_header_int_value(string name, int value)
        {
            var rvm = new Rv.Message();

            rvm.AddField(name, value);
            var headers = new ReadOnlyRvMessageHeaders(rvm);

            Assert.AreEqual(value, headers[name]);
            Assert.AreEqual(1, headers.Count, "headers.Count");
        }
コード例 #9
0
        public void can_enumerate_one_pair()
        {
            var rvm = new Rv.Message();

            rvm.AddField("custom", "value");
            var headers = new ReadOnlyRvMessageHeaders(rvm);

            Assert.AreEqual(1, headers.Count());
            Assert.AreEqual(new KeyValuePair <string, string>("custom", "value"), headers.First());
        }
コード例 #10
0
        public void can_read_Priority()
        {
            var rvm = new Rv.Message();

            rvm.AddField("Priority", 1);
            var headers = new ReadOnlyRvMessageHeaders(rvm);

            Assert.AreEqual(1, headers.Priority);
            Assert.AreEqual(1, headers.Count, "headers.Count");
        }
コード例 #11
0
        public void can_enumerate_one_value()
        {
            var rvm = new Rv.Message();

            rvm.AddField("custom", "value");
            var headers = new ReadOnlyRvMessageHeaders(rvm);

            Assert.AreEqual(1, headers.Values.Count());
            Assert.AreEqual("value", headers.Values.First());
        }
コード例 #12
0
        public void can_read_TTL()
        {
            var rvm = new Rv.Message();
            var ttl = TimeSpan.FromMinutes(1);

            rvm.AddField("TimeToLive", ttl.ToString());
            var headers = new ReadOnlyRvMessageHeaders(rvm);

            Assert.AreEqual(ttl, headers.TimeToLive);
            Assert.AreEqual(1, headers.Count, "headers.Count");
        }
コード例 #13
0
 static void AddReplyTo(Uri source, Rv.Message rvm, Uri replyTo)
 {
     if (source.Scheme.IsRvScheme() && source.Host == replyTo.Host && source.Port == replyTo.Port)
     {
         rvm.ReplySubject = ToRvSubject(replyTo.AbsolutePath);
     }
     else
     {
         rvm.AddField(Fields.ReplyTo, replyTo.ToString());
     }
 }
コード例 #14
0
        public void TryGetValue_returns_true_for_defined_int_property(string name, int value)
        {
            var rvm = new Rv.Message();

            rvm.AddField(name, value);
            var    headers = new ReadOnlyRvMessageHeaders(rvm);
            object valueOut;

            Assert.IsTrue(headers.TryGetValue(name, out valueOut));
            Assert.AreEqual(value, valueOut, "valueOut");
        }
コード例 #15
0
        /// <summary>
        /// Test 용 Message Send Function
        /// </summary>
        /// <param name="sendMessage"></param>
        /// <param name="sendMSG"></param>
        public void SendMessage4Test(TIBCO.Rendezvous.Message sendMessage, string sendMSG)
        {
            try
            {
                sendMessage.SendSubject = REMOTE_SUBJECT;
                sendMessage.AddField(FIELD_NAME, sendMSG);
                tibTrans.Send(sendMessage);

                //CHECK NEED  SystemLogger.Log(Level.Verbose, GetMessageLog(sendMSG, true), ToString(), this.Name);
            }
            catch (Exception ex)
            {
                //CHECK NEED  SystemLogger.Log(ex);
            }
        }
コード例 #16
0
ファイル: TIBInterface.cs プロジェクト: aliceshin/origine
        public void Send(string data, EESMessage msgbuilder)
        {
            Transport transport = null;

            try
            {
                TIBCO.Rendezvous.Environment.Open();
            }
            catch (RendezvousException exception)
            {
                LogHandler.ExceptionLogWrite(Definition.APPLICATION_NAME + ":TIBCO Initialize", exception);
            }

            try
            {
                // Real/Local 시
                transport = new TIBCO.Rendezvous.NetTransport(_sService, _sNetwork, _sDaemon);

                //transport = new NetTransport(service, network, daemon);
            }
            catch (RendezvousException exception)
            {
                LogHandler.ExceptionLogWrite(Definition.APPLICATION_NAME + ":NetTransport Initialize", exception);
            }



            // Create the message
            //TIBCO.Rendezvous.Message
            TIBCO.Rendezvous.Message message = new TIBCO.Rendezvous.Message();

            // Set send subject into the message
            try
            {
                //#if (DEBUG)
                //                // Test 시
                //                message.SendSubject = "OYCP.HT.EES.TEST_DB";
                //#else
                //                // Real 시
                message.SendSubject = _sSubjectName;
                //#endif
            }
            catch (RendezvousException exception)
            {
                LogHandler.ExceptionLogWrite(Definition.APPLICATION_NAME + ":message Initialize", exception);
            }

            try
            {
                if (_sDataTypeCD.Equals("BIN"))
                {
                    //#BINARY
                    Opaque opaque = new Opaque();
                    opaque.Value = Encoding.GetEncoding(51949).GetBytes(data);
                    message.AddField("DATA", opaque);
                }
                else
                {
                    //#TEXT
                    message.AddField("DATA", data);
                }

                transport.Send(message);
            }
            catch (RendezvousException exception)
            {
                LogHandler.ExceptionLogWrite(Definition.APPLICATION_NAME + ":Send ", exception);
            }
            catch (Exception err)
            {
                LogHandler.ExceptionLogWrite(Definition.APPLICATION_NAME, err);
            }


            // Close Environment, it will cleanup all underlying memory, destroy
            // transport and guarantee delivery.
            try
            {
                transport.Destroy();

                TIBCO.Rendezvous.Environment.Close();
            }
            catch (RendezvousException exception)
            {
                LogHandler.ExceptionLogWrite(Definition.APPLICATION_NAME, exception);
            }
        }
コード例 #17
0
        /// <summary>
        /// 실제로 Message를 전송
        /// </summary>
        /// <param name="sendMessage"></param>
        /// <param name="sendMSG"></param>
        private void SendTibMessage(CTibRVMessageBase oTibMessage)
        {
            lock (_MessageSend)
            {
                try
                {
                    oTibMessage.SEND_TIME      = DateTime.Now;
                    oTibMessage.StartTickCount = System.Environment.TickCount;

                    TIBCO.Rendezvous.Message sendMessage = new TIBCO.Rendezvous.Message();

                    string sendMSG = oTibMessage.ToString();
                    sendMessage.SendSubject = REMOTE_SUBJECT;
                    sendMessage.AddField(FIELD_NAME, sendMSG);

                    tibTrans.Send(sendMessage);

                    //CELSC oELSC = oTibMessage as CELSC;
                    //if (oELSC != null)
                    //{
                    //    if (oELSC.IsOnlineChangeMessage)
                    //    {
                    //        if (RemoteControlStateChangeComplete != null)
                    //            RemoteControlStateChangeComplete(this, enumHostControl.Online);
                    //    }
                    //}

                    CEMCR oEMCR = oTibMessage as CEMCR;
                    if (oEMCR != null)
                    {
                        if (oEMCR.IsOnlineChangeMessage)
                        {
                            if (oEMCR.RCS == "F")
                            {
                                if (RemoteControlStateChangeComplete != null)
                                {
                                    RemoteControlStateChangeComplete(this, enumHostControl.Offline);
                                }
                            }
                            else
                            {
                                if (RemoteControlStateChangeComplete != null)
                                {
                                    RemoteControlStateChangeComplete(this, enumHostControl.Online);
                                }
                            }
                        }
                    }

                    // 보낸 Message String 에 System Byte 추가함.
                    sendMSG += string.Format(" SYSTEM_BYTE={0}", oTibMessage.SystemBytes.ToString());

                    CLogManager.Instance.Log(new CTIBRVFormat(Catagory.Info, oTibMessage.EQP, sendMSG));

                    //CHECK NEED  SystemLogger.Log(Level.Verbose, GetMessageLog(sendMSG, true), ToString(), this.Name);
                }
                catch (Exception ex)
                {
                    CLogManager.Instance.Log(new CExceptionLogFormat(Catagory.Error, "EMP", ex));
                    CLogManager.Instance.Log(new CStatusLogFormat(Catagory.Error, "OGS", "TIB", "SendTibMessage \r\n" + ex.ToString()));
                }
            }
        }
コード例 #18
0
 static void AddPriority(IReadOnlyMessage msg, Rv.Message rvm)
 {
     rvm.AddField(nameof(msg.Headers.Priority), msg.Headers.Priority.Value);
 }
コード例 #19
0
 static void AddRvField(Rv.Message rv, string name, object value)
 {
     if (value is string)
     {
         rv.AddField(name, (string)value);
     }
     else if (value is int)
     {
         rv.AddField(name, (int)value);
     }
     else if (value is long)
     {
         rv.AddField(name, (long)value);
     }
     else if (value is DateTime)
     {
         rv.AddField(name, (DateTime)value);
     }
     else if (value is XmlDocument)
     {
         rv.AddField(name, (XmlDocument)value);
     }
     else if (value is byte[])
     {
         rv.AddField(name, (byte[])value);
     }
     else if (value is short)
     {
         rv.AddField(name, (short)value);
     }
     else if (value is byte)
     {
         rv.AddField(name, (byte)value);
     }
     else if (value is double)
     {
         rv.AddField(name, (double)value);
     }
     else if (value is float)
     {
         rv.AddField(name, (float)value);
     }
     else
     {
         rv.AddField(name, value.ToString());
     }
 }