Exemplo n.º 1
0
        void ClientPost(object Msg)
        {
            CounterSendMsg initMsgNow    = (CounterSendMsg)Msg;
            string         strEncCode    = CryptoModule.encrypt(initMsgNow.strSendMsg.ToString().Trim());
            string         strReturnData = string.Empty;

            lock (lockerPost)
            {
                try
                {
                    initMsgNow.strSendMsg = initMsgNow.bMultiFlag ? initMsgNow.strSendMsg : "";
                    strReturnData         = Post(VarGlobal.ServerUrl.ToString().Trim(), strEncCode.ToString().Trim(), initMsgNow.strSendMsg.ToString().Trim());
                    LogHelper.WriteLog("SendResult " + strReturnData.Replace("\r\n", "-"));
                }
                catch (OutOfMemoryException ex)
                {
                    LogHelper.WriteLog("OutOfMemoryException   post " + initMsgNow.strSendMsg + ex.ToString());
                }
                catch (Exception ex)
                {
                    AppLog.Fatal("ClientPost  " + ex.ToString());
                    LogHelper.WriteLog("Exception ClientPost " + ex.ToString());
                }
            }
        }
Exemplo n.º 2
0
        void ClientPost(object Msg)
        {
            CounterSendMsg initMsgNow    = (CounterSendMsg)Msg;
            string         strEncCode    = CryptoModule.encrypt(initMsgNow.strSendMsg.ToString().Trim());
            string         strReturnData = string.Empty;

            lock (lockerPost)
            {
                try
                {
                    initMsgNow.strSendMsg = initMsgNow.bMultiFlag ? initMsgNow.strSendMsg : "";
                    strReturnData         = Post(VarGlobal.ServerUrl.ToString().Trim(), strEncCode.ToString().Trim(), initMsgNow.strSendMsg.ToString().Trim());
                    LogHelper.WriteLog("SendResult " + strReturnData.Replace("\r\n", "-"));
                }
                catch (Exception ex)
                {
                    //string bufret1 = (ex.Message.ToString()
                    //                        + strReturnData + "/r/n"
                    //                        + strEncCode + "/r/n"
                    //                        + m_VtmUrl.ToString().Trim());
                    //string bufret = (ex.Message.ToString() + "/r/n"
                    //                        + strReturnData + "/r/n"
                    //                        + strEncCode + "/r/n"
                    //                        + m_VtmUrl.ToString().Trim());
                    //showApiData(bufret, richApiLog);
                }
            }
        }
Exemplo n.º 3
0
        string Post(string url, string postStr, string inteStr = "", Encoding encode = null)
        {
            string result;
            string timeStamp = string.Empty;
            string nonce     = string.Empty;

            try
            {
                var webClient = new WebClient {
                    Encoding = Encoding.UTF8
                };
                webClient.Proxy = null;
                if (encode != null)
                {
                    webClient.Encoding = encode;
                }
                if (!string.IsNullOrWhiteSpace(VarGlobal.TokenKey))
                {
                    webClient.Headers.Add("Authorization", VarGlobal.TokenKey);
                }
                ServicePointManager.ServerCertificateValidationCallback +=
                    delegate(
                        object sender,
                        X509Certificate certificate,
                        X509Chain chain,
                        SslPolicyErrors sslPolicyErrors)
                {
                    return(true);
                };
                NameValueCollection markStatus = new NameValueCollection();
                string[]            values     = null;
                if (string.IsNullOrWhiteSpace(inteStr))
                {
                    markStatus.Add("q", postStr);
                }
                else
                {
                    string[] arryStrParam = inteStr.Split('#');
                    foreach (string istring in arryStrParam)
                    {
                        string strEn = CryptoModule.encrypt(istring.ToString().Trim());
                        markStatus.Add("q", strEn);
                    }
                }
                ServicePointManager.SecurityProtocol = (SecurityProtocolType)192 | (SecurityProtocolType)768 | (SecurityProtocolType)3072;
                var readData = webClient.UploadValues(url, "POST", markStatus);
                result = Encoding.UTF8.GetString(readData);
            }
            catch (Exception ee)
            {
                string buf = ee.Message;
                throw new Exception(buf.ToString());
            }
            return(result);
        }