Exemple #1
0
        //Post
        private void BtnPost_Click(object sender, EventArgs e)
        {
            string url = txtUrl.Text + @"/" + txtModelUrl.Text + @"/" + txtOperate.Text
                         + "?Token=" + testToken.getToken();
            string httpResponse = string.Empty;

            byte[] data = System.Text.Encoding.UTF8.GetBytes(txtPostContext.Text);
            bool   flag = HttpHelper.HttpPost(url, data, out httpResponse, 6000);

            txtResponse.Text = httpResponse;
        }
Exemple #2
0
        public void sendData2Db(string urlModel, TokenClazz Token, string jsonText, string id)
        {
            //湖南宏工账套项目号不一致
            if (Token.CompanyName.Equals("湖南宏工"))
            {
                urlModel = urlModel.Replace("ItemClass3003", "ItemClass3002");
            }


            string url          = urlModel + Token.getToken();
            string httpResponse = string.Empty;

            byte[] data = System.Text.Encoding.UTF8.GetBytes(jsonText);
            bool   flag = HttpHelper.HttpPost(url, data, out httpResponse, 6000);


            JObject jo = new JObject();

            try
            {
                jo = (JObject)JsonConvert.DeserializeObject(httpResponse);
            }catch (Exception e)
            {
                return;
            }

            string StatusCode = "";
            string Message    = "";
            string Data       = "";

            StatusCode = null == jo["StatusCode"] ? "" : jo["StatusCode"].ToString();
            Message    = null == jo["Message"] ? "" : jo["Message"].ToString();
            Data       = null == jo["Data"] ? "" :  jo["Data"].ToString();

            //根据id更新推送状态
            string updateSql = string.Format(@"
                    INSERT INTO Synchronize_Log 
                    (DbName,SynID,JsonText_Msg,InsDate,SuccessCode,MsgText,DataText)
                    VALUES ( '{0}', {1} , '{2}',CONVERT(VARCHAR(23),GETDATE(),121), '{3}', '{4}', '{5}' )
                    ", Token.CompanyName, id, jo.ToString(), StatusCode, Message, Data);

            DBCONN.Query(updateSql);
        }