예제 #1
0
 /// <summary>
 /// 添加幼儿学习情况记录
 /// </summary>
 /// <param name="deviceId"></param>
 /// <param name="studyName"></param>
 private void AddStudy(string deviceId, string studyName)
 {
     if (deviceId != "")
     {
         MessageChild.AddStudyRecord(deviceId, studyName);
     }
 }
예제 #2
0
        public void IndexChild()
        {
            string echoString = HttpContext.Current.Request.QueryString["echoStr"];
            string signature  = HttpContext.Current.Request.QueryString["signature"];
            string timestamp  = HttpContext.Current.Request.QueryString["timestamp"];
            string nonce      = HttpContext.Current.Request.QueryString["nonce"];

            if (string.IsNullOrEmpty(echoString))
            {
                if (WeChildChatHelper.CheckBabySignature(signature, timestamp, nonce))
                {
                    string postString = string.Empty;
                    if (HttpContext.Current.Request.HttpMethod.ToUpper() == "POST")
                    {
                        //读取流消息
                        using (Stream stream = HttpContext.Current.Request.InputStream) {
                            Byte[] postBytes = new Byte[stream.Length];
                            stream.Read(postBytes, 0, (Int32)stream.Length);
                            postString = Encoding.UTF8.GetString(postBytes);
                            MessageChild help = new MessageChild();
                            help.ToKen = GetChildToken();
                            string responseContent = string.Empty;
                            //判断是否加密
                            bool IsAes = HttpContext.Current.Request.QueryString["encrypt_type"] == "aes" ? true : false;
                            if (IsAes)
                            {
                                string        msg_signature = HttpContext.Current.Request.QueryString["msg_signature"];
                                WXBizMsgCrypt wmc           = new WXBizMsgCrypt(WeChatConfig.TokenChild, WeChatConfig.EncodingAESKeyChild, WeChatConfig.AppIdChild);
                                string        decmsg        = string.Empty; //解密后
                                int           decnum        = wmc.DecryptMsg(msg_signature, timestamp, nonce, postString, ref postString);
                                if (decnum == 0)
                                {
                                    wmc.EncryptMsg(help.ReturnMessageChild(postString), timestamp, nonce, ref responseContent);
                                    //wmc.EncryptMsg(postString, timestamp, nonce, ref responseContent);
                                }
                            }
                            else
                            {
                                responseContent = help.ReturnMessageChild(postString);
                                //responseContent = postString;
                            }
                            HttpContext.Current.Response.ContentEncoding = Encoding.UTF8;
                            HttpContext.Current.Response.Write(responseContent);
                        }
                    }
                }
            }
            else
            {
                if (WeChildChatHelper.CheckBabySignature(signature, timestamp, nonce))
                {
                    Write(echoString);
                }
            }
        }
예제 #3
0
        public void Dispatches_Messages_To_Subscribers_Who_Subscribe_To_Ancestor_MessageType()
        {
            // Arrange
            var subscribersHit = new List <string>();
            var message        = new MessageChild("Child Message", subscribersHit);

            // Act
            _broker.SendMessage(message);

            // Assert
            subscribersHit.Count.ShouldEqual(2);
            subscribersHit.ShouldContain("MessageParent");
            subscribersHit.ShouldContain("MessageChild");
        }
예제 #4
0
        public void Test1()
        {
            var name    = "Hello";
            var id      = 9;
            var petId   = 67;
            var petName = "Cat";

            var person = new MessageChild
            {
                Id   = id,
                Name = name,
                Pet  = new Pet
                {
                    PetId   = petId,
                    PetName = petName
                }
            };

            using (var ms = new MemoryStream())
            {
                Serializer.Serialize(ms, person);

                ms.Position = 0;
                var dobj = Serializer.Deserialize <MessageChild>(ms);

                Assert.Equal(id, dobj.Id);
                Assert.Equal(name, dobj.Name);
                Assert.Equal(petId, dobj.Pet.PetId);
                Assert.Equal(petName, dobj.Pet.PetName);

                ms.Position = 0;
                var dobj2 = Serializer.Deserialize <MessageChildB>(ms);
                Assert.Equal(id, dobj2.Base.Id);
                Assert.Equal(name, dobj2.Name);
                Assert.Equal(petId, dobj2.Pet.PetId);
                Assert.Equal(petName, dobj2.Pet.PetName);

                ms.Position = 0;
                Serializer.Serialize(ms, dobj);
                Assert.Equal(id, dobj.Id);
                Assert.Equal(name, dobj.Name);
                Assert.Equal(petId, dobj.Pet.PetId);
                Assert.Equal(petName, dobj.Pet.PetName);
            }
        }