Пример #1
0
        public static void SignRequest(SignRequest request)
        {
            if (request == null)
            {
                throw new ArgumentNullException("SignRequest data can not be null.");
            }
            string requestString = JsonConvert.SerializeObject(request);

            if (!TcpClient.IsConnected)
            {
                if (string.IsNullOrWhiteSpace(Const.Locator.ParameterSetting.SdcUrl))
                {
                    MessageBoxEx.Show("E-SDC URL can not be null.", MessageBoxButton.OK);
                    return ;
                }
                string[] sdc = Const.Locator.ParameterSetting.SdcUrl.Split(':');
                if (sdc != null && sdc.Count() != 2)
                {
                    MessageBoxEx.Show("E-SDC URL is not in the right format.", MessageBoxButton.OK);
                    return ;
                }
                TcpClient.Connect(IPAddress.Parse(sdc[0]), int.Parse(sdc[1]));
            }
            TcpClient.Send(0x02, requestString);

            //MessageModel messageModel = TcpClient.Recive();
            TcpClient.Recive();

            //request.Hash = CaclBase64Md5Hash(requestString);
            //requestString = JsonConvert.SerializeObject(request);

            //HttpHelper httpHelper = new HttpHelper();
            //HttpItem httpItem = new HttpItem();
            //httpItem.Method = "POST";
            //httpItem.URL = Const.SignUri;
            //httpItem.Postdata = Convert.ToString(requestString);

            //httpItem.ResultType = ResultType.String;
            //HttpResult html = httpHelper.GetHtml(httpItem);
            //if (html.StatusCode != HttpStatusCode.OK)
            //{
            //    throw new Exception(string.IsNullOrEmpty(html.Html) ? (string.IsNullOrEmpty(html.StatusDescription) ? "Post Data Error!" : html.StatusDescription) : html.Html);
            //}

            //return JsonConvert.DeserializeObject<SignResponse>(messageModel.Message);
        }