Esempio n. 1
0
    /// <summary>
    /// 安卓推送线程
    /// </summary>
    internal void AndroidThread()
    {
        string Key          = string.Empty;
        string MasterSecret = string.Empty;

        if (UserType == "0")//推送给经销商
        {
            Key          = ConfigurationManager.AppSettings["DisKey"].ToString();
            MasterSecret = ConfigurationManager.AppSettings["DisMasterSecret"].ToString();
        }
        else//推送给企业
        {
            Key          = ConfigurationManager.AppSettings["CompKey"].ToString();
            MasterSecret = ConfigurationManager.AppSettings["CompMasterSecret"].ToString();
        }
        JPushClient push    = new JPushClient(Key, MasterSecret);
        PushPayload payload = new MsgSend().GetSendUserModel(UserType, OrderID, Type, money_all);

        if (payload != null)
        {
            MessageResult msgResult = push.SendPush(payload);
            //if (msgResult!=null)
            //threadAndroid.Abort();
        }
    }
Esempio n. 2
0
        private void DoSendImsMsg(ImsResponse responseMsg)
        {
            try
            {
                if (ImsNetManager.Instance.IsImsSocketConnect())
                {
                    IMsgInfo msg     = responseMsg;
                    MsgSend  msgSend = new MsgSend();
                    int      res     = msgSend.ConvertFrom(msg);
                    if (0 == res)
                    {
                        byte[] data = msgSend.CloneBytes();
                        ImsNetManager.Instance.NowImsStation.SendBytes(data);

                        //  Logger.LogInfo(null, "向IMS发送响应消息 :【" + BitConverter.ToString(responseMsg.CloneMsgBytes()) + "】");
                    }
                    else
                    {
                        //  Logger.LogError(null, "向IMS发送响应消息 :【" + "消息不合法" + "】");
                    }
                }
            }
            catch (SocketException ex)
            {
                ImsNetManager.Instance.NowImsStation.CloseImsConn();
                // Logger.LogError(null, "IMS发送响应消息时捕获到SOCKET异常:【" + ex.Message+"】");
            }
            catch (Exception ex)
            {
                ImsNetManager.Instance.NowImsStation.CloseImsConn();
                // Logger.LogError(null, "IMS发送响应消息时捕获到未知异常:【" + ex.Message+"】");
            }
        }
Esempio n. 3
0
        public void TestTxSigner()
        {
            List <String> mnemonic = new List <String>(singleVector.Split(" ", StringSplitOptions.RemoveEmptyEntries));
            // Create the network info
            NetworkInfo networkInfo = new NetworkInfo(bech32Hrp: localbech32Hrp, lcdUrl: localTestUrl);

            // Build a transaction
            MsgSend msg = new MsgSend(
                fromAddress: "cosmos1hafptm4zxy5nw8rd2pxyg83c5ls2v62tstzuv2",
                toAddress: "cosmos12lla7fg3hjd2zj6uvf4pqj7atx273klc487c5k",
                amount: new List <StdCoin> {
                new StdCoin(denom: "uatom", amount: "100")
            }
                );
            // Fee
            StdFee fee = new StdFee(
                gas: "200000",
                amount: new List <StdCoin> {
                new StdCoin(denom: "uatom", amount: "250")
            }
                );
            StdTx tx = TxBuilder.buildStdTx(stdMsgs: new List <StdMsg> {
                msg
            }, fee: fee);
            // Create a wallet
            Wallet wallet = Wallet.derive(mnemonic, networkInfo);

            // Verify Wallet
            Assert.AreEqual(wallet.networkInfo.bech32Hrp, networkInfo.bech32Hrp);
            Assert.AreEqual(wallet.networkInfo.lcdUrl, networkInfo.lcdUrl);

            // Build the mockup server
            var _server = new MockHttpServer();
            //  I need this in order to get the correct data out of the mock server
            Dictionary <String, Object> accResponse  = JsonConvert.DeserializeObject <Dictionary <String, Object> >(TestResources.AccountDataResponse);
            Dictionary <String, Object> NodeResponse = JsonConvert.DeserializeObject <Dictionary <String, Object> >(TestResources.NodeInfoResponse);

            // Initialize Server Response
            _server
            .WithService(localTestUrl)
            .Api("auth/accounts/{wallettAddress}", accResponse)
            .Api("node_info", NodeResponse);

            // Link the client to the retrieval classes
            HttpClient client = new HttpClient(_server);

            AccountDataRetrieval.client = client;
            NodeInfoRetrieval.client    = client;

            // Call without await to avoid marking test class as async
            StdTx signedTx = TxSigner.signStdTx(wallet: wallet, stdTx: tx).Result;

            Assert.AreEqual(signedTx.signatures.Count, 1);

            StdSignature signature = (signedTx.signatures.ToArray())[0];

            Assert.AreEqual(signature.publicKey.type, "tendermint/PubKeySecp256k1");
            Assert.AreEqual(signature.publicKey.value, "ArMO2T5FNKkeF2aAZY012p/cpa9+PqKqw2GcQRPhAn3w");
            Assert.AreEqual(signature.value, "m2op4CCBa39fRZD91WiqtBLKbUQI+1OWsc1tJkpDg+8FYB4y51KahGn26MskVMpTJl5gToIC1pX26hLbW1Kxrg==");
        }
Esempio n. 4
0
 public bool SaveSendMessage(MsgSend send)
 {
     using (var c = new InvoicingContext())
     {
         try
         {
             c.MsgSends.Add(send);
             c.SaveChanges(); return(true);
         }
         catch (Exception ex)
         {
             return(false);
         }
     }
 }
Esempio n. 5
0
    internal void MsgThread()
    {
        string Key          = string.Empty;
        string MasterSecret = string.Empty;

        Key          = ConfigurationManager.AppSettings["DisKey"].ToString();
        MasterSecret = ConfigurationManager.AppSettings["DisMasterSecret"].ToString();

        JPushClient push    = new JPushClient(Key, MasterSecret);
        PushPayload payload = new PushPayload();
        string      type    = MsgType == "" || MsgType == "-1" ? "-1" : MsgType;

        payload = new MsgSend().GetMsgUserModel(MsgID, type);
        if (payload != null)
        {
            MessageResult msgResult = push.SendPush(payload);
            //if (msgResult != null)
            //    threadMsg.Abort();
        }
    }
Esempio n. 6
0
        public ActionResult savemsg(string title, string cate, string forids, string fornames, string remark, string attrname, string attrguid)
        {
            Guid    msg  = Guid.NewGuid();
            MsgSend send = new MsgSend();

            send.createDate = DateTime.Now;
            send.isDelete   = false;
            send.msgcate    = cate;
            send.hadAttr    = false;
            send.msgcontent = remark;
            send.msgId      = msg;
            send.receIds    = forids;
            send.receNames  = fornames;
            send.staffId    = Masterpage.CurrUser.staffid;
            send.title      = title;
            if (attrname != null && attrname != "" && attrguid != null && attrguid != "")
            {
                send.hadAttr = true;
                ServiceDB.Instance.ExecuteSqlCommand("insert into Attachment values(newid(),'" + msg + "','" + attrguid + "','" + attrname + "','',getdate())");
            }

            bool exc       = manageService.SaveSendMessage(send);
            int  rececount = 0;

            if (exc)
            {
                string[] rece = forids.Split(',');
                foreach (var item in rece)
                {
                    if (item != "")
                    {
                        var row = ServiceDB.Instance.ExecuteSqlCommand("insert into MsgRece values('" + msg + "'," + item + ",0,null,0,null)");
                        rececount += row;
                    }
                }
            }
            ReturnValue r = new ReturnValue();

            r.status = rececount > 0;
            return(Json(r, JsonRequestBehavior.AllowGet));
        }
Esempio n. 7
0
    public void AnPush(string userType, string sendType, string orderID)
    {
        MsgSend bll = new MsgSend();

        bll.GetWxService(sendType, orderID, userType);
    }
Esempio n. 8
0
        public void TestSendMsg()
        {
            Dictionary <String, Object> wk, toJson;
            Object outValue;

            MsgSend message = new MsgSend(fromAddress: "cosmos1huydeevpz37sd9snkgul6070mstupukw00xkw9",
                                          toAddress: "cosmos12lla7fg3hjd2zj6uvf4pqj7atx273klc487c5k",
                                          amount: new List <StdCoin> {
                new StdCoin(denom: "uatom", amount: "100")
            });

            // Assert of various properties
            Assert.AreEqual(message.type, "cosmos-sdk/MsgSend");

            wk = message.value;
            if (wk.TryGetValue("from_address", out outValue))
            {
                String outString = outValue as String;
                Assert.AreEqual(outString, "cosmos1huydeevpz37sd9snkgul6070mstupukw00xkw9");
            }
            if (wk.TryGetValue("to_address", out outValue))
            {
                String outString = outValue as String;
                Assert.AreEqual(outString, "cosmos12lla7fg3hjd2zj6uvf4pqj7atx273klc487c5k");
            }
            if (wk.TryGetValue("amount", out outValue))
            {
                List <Dictionary <String, Object> > stdCoins = outValue as List <Dictionary <String, Object> >;
                foreach (var item in stdCoins)
                {
                    if (item.TryGetValue("amount", out outValue))
                    {
                        String outString = outValue as String;
                        Assert.AreEqual(outString, "100");
                    }
                }
            }

            toJson = message.toJson();
            if (toJson.TryGetValue("type", out outValue))
            {
                String outString = outValue as String;
                Assert.AreEqual(outString, "cosmos-sdk/MsgSend");
            }
            if (toJson.TryGetValue("value", out outValue))
            {
                Dictionary <String, Object> value = outValue as Dictionary <String, Object>;
                if (value.TryGetValue("from_address", out outValue))
                {
                    String outString = outValue as String;
                    Assert.AreEqual(outString, "cosmos1huydeevpz37sd9snkgul6070mstupukw00xkw9");
                }
                if (value.TryGetValue("to_address", out outValue))
                {
                    String outString = outValue as String;
                    Assert.AreEqual(outString, "cosmos12lla7fg3hjd2zj6uvf4pqj7atx273klc487c5k");
                }
                if (value.TryGetValue("amount", out outValue))
                {
                    List <Dictionary <String, Object> > stdCoins = outValue as List <Dictionary <String, Object> >;
                    foreach (var item in stdCoins)
                    {
                        if (item.TryGetValue("amount", out outValue))
                        {
                            String outString = outValue as String;
                            Assert.AreEqual(outString, "100");
                        }
                    }
                }
            }
        }
Esempio n. 9
0
 public void Register(MsgSend m)
 {
     msgSend += m;
     m("Registered");
 }
Esempio n. 10
0
 public void Unregister(MsgSend m)
 {
     msgSend -= m;     // <--- Change += to -=
     m("Unregistered");
 }
Esempio n. 11
0
    public void AnPush(string userType, string sendType, string orderID, decimal money = 0)
    {
        MsgSend bll = new MsgSend();

        bll.GetWxService(sendType, orderID, userType, money: money);
    }
Esempio n. 12
0
 public bool SaveSendMessage(MsgSend send)
 {
     return(_manageRepository.SaveSendMessage(send));
 }
    protected void BtnSend_Click(object sender, EventArgs e)
    {
        RM rm = new RM(ResourceFile.Msg);
        if (Fn.ToLength(this.TxtTitle.Text) == 0)
        {
            Alert(rm["PleaseInputTitle"]);
            return;
        }
        else if (Fn.ToLength(this.TxtContent.Text) == 0)
        {
            Alert(rm["PleaseInputContent"]);
            return;
        }

        string errorMsg = string.Empty;
        MsgSend msgSend = new MsgSend();

        //保存消息
        if (msgSend.SaveAndSendMessage(this.HidReceiveUserId.Value,this.TxtReceiveUserName.Text, this.TxtTitle.Text, this.TxtContent.Text, 0))
        {
          
            //获取未读消息
            MsgReceive msgReceive = new MsgReceive();
            DataSet ds = msgReceive.GetUnReadMessageCount(this.HidReceiveUserId.Value);
            //刷新消息提醒机制
            MessageNotifyTicker.Instance.NotifyClients(ds.Tables[0]);

            Alert(rm["SendSuccess"]);
            this.ClearForm();
        }
        else
        {
            Alert(msgSend.ErrorMessage);
        }      
    }
    /// <summary>
    /// 保存按钮事件
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void BtnSave_Click(object sender, EventArgs e)
    {
        RM rm = new RM(ResourceFile.Msg);
        if (Fn.ToLength(this.TxtTitle.Text) == 0)
        {
            Alert(rm["PleaseInputTitle"]);
            return;
        }
        else if (Fn.ToLength(this.TxtContent.Text) == 0)
        {
            Alert(rm["PleaseInputContent"]);
            return;
        }

        string errorMsg = string.Empty;

        MsgSend msgSend = new MsgSend();
        //保存消息
        if (msgSend.SaveMessage(this.HidReceiveUserId.Value,this.TxtReceiveUserName.Text, this.TxtTitle.Text, this.TxtContent.Text, 0))
        {
            Alert(rm["SaveSuccess"]);
            this.ClearForm();
        }
        else
        {
            Alert(msgSend.ErrorMessage);
        }
    }