コード例 #1
0
        public KRResponse PostExamResult(ExamResultMetadata <T> result)
        {
            try
            {
                switch (this._type)
                {
                case ProductType.BMD:
                    var bmdTcpService = _proxy as IBMDTcpService;
                    var jsonStr       = CommunicationHelper.SerializeObjToJsonStr(result);
                    if (bmdTcpService != null)
                    {
                        return(bmdTcpService.PostExamResult(jsonStr));
                    }
                    break;

                case ProductType.KRTCD:
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }
            catch (Exception ex)
            {
                ClientHelper.TraceException("TCPClientManager.PostExamResult", "上传检查结果", ex.Message);
            }
            return(new KRResponse()
            {
                Status = "FAIL", Msg = ""
            });
        }
コード例 #2
0
 private void BuildHttpItem(ExamResultMetadata <T> checkResult, HttpItem pitem, string postResultUrl, string parameterName)
 {
     pitem.URL = postResultUrl;
     if (string.IsNullOrEmpty(parameterName))
     {
         pitem.Postdata    = CommunicationHelper.SerializeObjToJsonStr(checkResult);
         pitem.ContentType = "application/json";
     }
     else
     {
         pitem.Postdata = AddToken(string.Format("{0}={1}", parameterName,
                                                 CommunicationHelper.SerializeObjToJsonStr(checkResult)));
         pitem.ContentType  = "application/x-www-form-urlencoded";
         pitem.PostEncoding = Encoding.UTF8;
     }
 }
コード例 #3
0
        public override KRResponse PostExamResult(ExamResultMetadata <T> result)
        {
            try
            {
                var      resultStr = CommunicationHelper.SerializeObjToJsonStr(result);
                string[] param     = { ClientConstants.KR_POST_RESULT, resultStr };
                var      proxy     = new WebServiceProxy(Config.HttpConfigModel.PostCheckResultUrl, Config.HttpConfigModel.WebServiceName);
                Trace.WriteLine(string.Format("开始发送检查结果,地址为{0}", Config.HttpConfigModel.PostCheckResultUrl));
                var response = (string)proxy.ExecuteQuery(Config.HttpConfigModel.WebServiceName, param);
                Trace.WriteLine(string.Format("开始发送检查结果结束,返回结果{0}", resultStr));

                return(CommunicationHelper.DeserializeJsonToObj <KRResponse>(response));
            }
            catch (KRException ex)
            {
                throw new Exception("上传检查结果失败 " + ex.Msg);
            }
        }
コード例 #4
0
        static void Main(string[] args)
        {
            //ClientProxy<BMDCheckResult> proxy = new ClientProxy<BMDCheckResult>();
            //proxy.ConfigClient(ProductType.BMD, Protocol.WebService);

            ////Use CallUnknowWebService
            //var webSvcClient = proxy.ClientObj as WebServiceClient<BMDCheckResult>;
            //string[] param = { "20160101" };
            //var result = webSvcClient.CallUnknowWebService("http://localhost:51374/WebService1.asmx", "GetPatient", param);
            //var patient = CommunicationHelper.DeserializeJsonToObj<Patient_DTO>(result);

            //Use config
            //[NET_CONFIG]
            //BassAddress=localhost
            //Port = 51374
            //[BUSINESS]
            //GetPatientUrl=WebService1.asmx
            //PostCheckResultUrl = WebService1.asmx
            //var patient1 = proxy.GetPatient("20160101");

            //ExamResultMetadata<BMDCheckResult> bmdCheckResult = new ExamResultMetadata<BMDCheckResult>()
            //{
            //    Diagnosis = "everything is good",
            //    BrithDay = "19870808",
            //    Age = 30,
            //    CardID = "131002198702274615",
            //    CardType = CardType.IDCard,
            //    Name = "zhangshiwei",
            //    Result = new BMDCheckResult()
            //    {
            //        Position = "zuo",
            //        EOA = 22,
            //        Fracturerisk = 55,
            //        HP = 90,
            //        LimbSide = "123",
            //        PAB = 33,
            //        TValue = 33,
            //        ZValue = 89,
            //        RRF = 98,
            //        Percentage = 76,
            //        Physical = "444",
            //        SOS = 4233,
            //        STI = 34
            //    }

            //};
            ClientProxy <APIPWVCheckResult> proxy = new ClientProxy <APIPWVCheckResult>();
            //proxy.ConfigClient(Protocol.Http);
            ExamResultMetadata <APIPWVCheckResult> ABIPWV = new ExamResultMetadata <APIPWVCheckResult>()
            {
                Diagnosis = "everything is good",
                BrithDay  = "19870808",
                Age       = 30,
                CardID    = "131002198702274615",
                CardType  = CardType.IDCard,
                Name      = "zhangshiwei",
                Result    = new APIPWVCheckResult()
                {
                    ABIL  = "3212",
                    ABIR  = "343",
                    BAIL  = "454",
                    BAIR  = "53",
                    DBPLA = 123,
                    DBPLB = 5656,
                    DBPRA = 44,
                    DBPRB = 454,
                    MBPLA = 123,
                    MBPLB = 123,
                    MBPRA = 645,
                    MBPRB = 654,
                    PPLA  = 64,
                    PPLB  = 345,
                    PPRA  = 435,
                    PPRB  = 456,
                    PWVL  = 123,
                    PWVR  = 234,
                    SBPLA = 345,
                    SBPLB = 345,
                    SBPRA = 567,
                    SBPRB = 77
                }
            };

            string json     = CommunicationHelper.SerializeObjToJsonStr(ABIPWV);
            var    response = proxy.SendExamResult(ABIPWV);
            //string result1 = PostWebRequest("http://121.42.41.188:8080/PostCheckExam", "checkresult=" + json, Encoding.UTF8);

            var response1 = CreateGetHttpResponse(string.Format("{0}{1}", "http://121.42.41.188:8080/AAS/PostCheckExam?checkresult=",
                                                                json));

            Console.Read();
            //ExamResultMetadata<KRSGCheckResult> krsgCheckresult = new ExamResultMetadata<KRSGCheckResult>()
            //{
            //    Diagnosis = "everything is good",
            //    BrithDay = "19870808",
            //    Age = 30,
            //    CardID = "131002198702274615",
            //    CardType = CardType.IDCard,
            //    Name = "zhangshiwei",
            //    Result = new KRSGCheckResult()
            //    {
            //        BMI = 24.1f,
            //        Brithday = "1987/01/01",
            //        CurrentCount = 3,
            //        DeviceID = "2015354878512",
            //        Gender = 1,
            //        Height = 198,
            //        MeasureDateTime = "2016/05/09",
            //        Order = 4,
            //        PatientID = "201650548",
            //        PatientName = "小明",
            //        ScanCode = "65584",
            //        Status = 2,
            //        Temperature = 39.5f,
            //        TotalCount = 44,
            //        TransferIndex = 234,
            //        TransferTotalCount = 2,
            //        Weight = 59.5f

            //    }
            //};

            //string json = CommunicationHelper.SerializeObjToJsonStr(krsgCheckresult);
            //ExamResultMetadata<TCDDopplerCheckResult> dopplerCheckresult = new ExamResultMetadata<TCDDopplerCheckResult>()
            //{
            //    Diagnosis = "everything is good",
            //    BrithDay = "19870808",
            //    Age = 30,
            //    CardID = "131002198702274615",
            //    CardType = CardType.IDCard,
            //    Name = "zhangshiwei",
            //    Result = new TCDDopplerCheckResult()
            //    {
            //        Age = 20,
            //        BaseLine = 33,
            //        Depth = 4,
            //        Filter = 6,
            //        Gain = 6,
            //        Gender = 1,
            //        GraphUse = false,
            //        HR = 4,
            //        ImageFilePath = "",
            //        ListUse = false,
            //        Number = 5,
            //        PI = 55,
            //        PRF = 55,
            //        ProbeHz = 33,
            //        ProberDirection = 3,
            //        ProbeType = 3,
            //        RI = 5,
            //        SBI = 55,
            //        Scale = 5,
            //        SD = 3,
            //        StudyUID = "",
            //        UID = "",
            //        UseIndex = 3,
            //        Vs = 43,
            //        Vd = 34,
            //        Vm = 1


            //    }
            //};

            //string json = CommunicationHelper.SerializeObjToJsonStr(dopplerCheckresult);

            //var response = proxy.SendExamResult(bmdCheckResult);


            Console.Read();
        }
コード例 #5
0
        public string HttpPostData(string url, object paramter, HttpItem pitem = null)
        {
            try
            {
                if (paramter == null)
                {
                    CommunicationHelper.TraceException("HttppostData", "null parameter", "parameter obj is null");
                }

                string contentType = "application/json";

                if (paramter is string || paramter.GetType().IsValueType)
                {
                    contentType = "application/x-www-form-urlencoded";
                }

                var postStr = CommunicationHelper.SerializeObjToJsonStr(paramter);
                if (pitem == null)
                {
                    pitem = new HttpItem()
                    {
                        Method      = "Post",
                        Postdata    = postStr,
                        ContentType = "application/x-www-form-urlencoded",
                        Encoding    = Encoding.UTF8,
                        URL         = url
                    };
                }
                else
                {
                    pitem.Method   = "Post";
                    pitem.Postdata = postStr;
                    //pitem.ContentType = contentType;
                    pitem.URL = url;
                }

                var result = _engine.GetHtml(pitem);
                CommunicationHelper.RecordTrace("HttpPostData", "返回结果:" + result.Html);
                return(result.Html);

                //var client = new KRWebClient { Timeout = Timeout };
                //NameValueCollection param = new NameValueCollection();
                ////client.Headers.Add("Content-Type", "application/json");
                //param.Add("type", type);
                //param.Add("content", jsonStr);
                //var content = client.UploadValues(url, param);
                //var strContent = Encoding.UTF8.GetString(content);
                //return strContent;
                //HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
                //request.Method = "Post";
                //request.ContentType = "application/json";
                //request.ContentLength = _encoding.GetByteCount(jsonStr);
                //Stream myRequestStream = request.GetRequestStream();
                //StreamWriter myStreamWriter = new StreamWriter(myRequestStream);
                //myStreamWriter.Write(jsonStr);
                //myStreamWriter.Close();

                //HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                //Stream myResponseStream = response.GetResponseStream();
                //StreamReader myStreamReader = new StreamReader(myResponseStream);
                //retString = myStreamReader.ReadToEnd();
                //myStreamReader.Close();
                //myResponseStream.Close();
            }
            catch (Exception ex)
            {
                ClientHelper.TraceException("HttpPostData:Post", "Post数据失败", ex.Message);
                return(string.Empty);
            }

            //return HttpUtility.UrlDecode(retString);
        }