예제 #1
0
        public bool Start()
        {
            try
            {
                //获取当前所有设备信息
                HttpResult <string> result = WebLogic.GetHttpResult <string>(CreateHttpItem(@"vetsync/v1/devices"));
                if (result.Success)
                {
                    string      ncResultXML = result.Result;
                    XmlDocument xml         = new XmlDocument();
                    xml.LoadXml(ncResultXML);
                    XmlNode DataDictionaryUpdateInfo = xml.SelectSingleNode("Devices");
                    foreach (XmlNode node in DataDictionaryUpdateInfo.ChildNodes)
                    {
                        if (node["Type"] != null && node["Type"].InnerText == abaxisDevice.FuseCode)
                        {
                            abaxisDevice.FuseID           = node["Id"].InnerText;
                            abaxisDevice.CommandsChanged += Vs2_CommandsChanged;
                            timer.Start();
                            return(true);
                        }
                    }
                }
            }
            catch (Exception)
            {
                return(false);
            }

            return(false);
        }
예제 #2
0
        /// <summary>
        /// 取消请求
        /// </summary>
        /// <param name="cmd"></param>
        private void CancelCommand(Command cmd)
        {
            //----------http://192.168.0.104:8080/vetsync/v1/orders/7777 ????  7777是表示查检号吗?
            //按practiceref字段搜索

            HttpItem httpItem = CreateHttpItem(@"vetsync/v1/orders/" + cmd.Code);

            httpItem.Method = HttpMethod.Delete;
            HttpResult <string> result = WebLogic.GetHttpResult <string>(httpItem);

            if (result.Success)
            {
                //result.Result   //----------此字段为返回的数据! 返回什么表示成功????
            }
        }
예제 #3
0
        /// <summary>
        /// 查询查一个检查是否完成
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        private bool GetStatus(Command cmd)
        {
            //HttpItem httpItem = CreateHttpItem(@"vetsync/v1/orders/UNREQ-1708/status?rel=status");

            HttpItem            httpItem = CreateHttpItem(string.Format(@"vetsync/v1/orders/{0}/status?rel=status", cmd.Code));
            HttpResult <string> result   = WebLogic.GetHttpResult <string>(httpItem);

            if (result.Success)
            {
                XmlDocument xml = new XmlDocument();
                xml.LoadXml(result.Result);
                XmlNode node = xml.SelectSingleNode("order");
                if (node["status"] != null && node["status"].InnerText == "Done")
                {
                    return(true);
                }
            }
            return(false);
        }
예제 #4
0
        /// <summary>
        /// 读取结果
        /// </summary>
        /// <param name="cmd"></param>
        private void ReadResult(Command cmd)
        {
            //HttpWebRequest request = (HttpWebRequest)WebRequest.Create(commonURLs + "orders/6666/results");  ----------666是什么意思

            HttpItem            httpItem = CreateHttpItem(string.Format("vetsync/v1/orders/{0}/results", cmd.Code));
            HttpResult <string> result   = WebLogic.GetHttpResult <string>(httpItem);

            if (result.Success)
            {
                Devices.Result cmdResult = new Result();
                cmdResult.CMD     = cmd;
                cmdResult.Devices = abaxisDevice;
                cmdResult.Date    = DateTime.Now;
                cmdResult.Source  = result.Result;


                XmlDocument xml = new XmlDocument();
                xml.LoadXml(result.Result);
                XmlNode DataDictionaryUpdateInfo = xml.SelectSingleNode("LabReport");

                XmlNode nodelist = xml.SelectSingleNode("LabReport/LabResults/LabResult/LabResultItems");
                if (nodelist == null)
                {
                    return;
                }
                cmdResult.ResultDatas = new List <ResultItem>();
                foreach (XmlNode node in nodelist.ChildNodes)
                {
                    ResultItem item = new ResultItem();
                    item.Code  = node["AnalyteCode"].InnerText;
                    item.Value = node["Result"].InnerText;
                    item.Unit  = node["Units"].InnerText;
                    item.Min   = node["LowRange"]?.InnerText;  // --------------此字段有可能为空吗?
                    item.Max   = node["HighRange"]?.InnerText; //--------------此字段有可能为空吗?
                    cmdResult.ResultDatas.Add(item);
                }
                abaxisDevice.ResultComplete(cmdResult);
            }
        }
예제 #5
0
        /// <summary>
        /// 发送请求
        /// </summary>
        /// <param name="cmd"></param>
        private void SendCommand(Command cmd)
        {
            //------------------
            LabRequest request = new LabRequest();

            request.DeviceID = abaxisDevice.FuseID;
            request.TestCode = abaxisDevice.RequestCode;// "HEM"; //----------这是什么?
            LabRequests labRequests = new LabRequests();

            labRequests.LabRequest = new List <LabRequest>();
            labRequests.LabRequest.Add(request);
            //宠物信息
            AnimalDetails deatails = new AnimalDetails();

            deatails.AnimalID   = cmd.PetId;
            deatails.AnimalName = cmd.PetName;
            deatails.Breed      = cmd.KindOf.ToString(); //----------品种 这里是可以随意填还是有固定值?
            deatails.Gender     = cmd.Gender.ToString(); // "female";//性别
            deatails.Species    = cmd.KindOf.ToString(); // "DOG";//----------种类 这里是可以随意填还是有固定值?
            int age = Convert.ToInt32(cmd.Age);

            deatails.Age                = string.Format("{0}Y{1}M0D", age / 12, age % 12);  // "1Y3M25D";
            deatails.DateOfBirth        = DateTime.Now.AddMonths(-age).ToString("yyyy-MM"); // "2018-08-11";
            deatails.AbbreviatedHistory = "";
            //主人信息
            Identification identifiObj = new Identification();

            identifiObj.ReportType   = "Request";
            identifiObj.PracticeID   = cmd.Id;   // ----------这两个字段是做什么的?
            identifiObj.PracticeRef  = cmd.Code; // ----------这两个字段是做什么的?
            identifiObj.LaboratoryID = cmd.Id;
            identifiObj.PIMSName     = "";       //----------这个是什么
            identifiObj.OwnerID      = cmd.CustomerId;
            identifiObj.OwnerName    = cmd.Customer;
            identifiObj.VetID        = cmd.DoctorId; // "8888";//医生ID
            identifiObj.VetName      = cmd.Doctor;   // //医生姓名

            LabReport report = new LabReport();

            report.LabRequests    = labRequests;
            report.AnimalDetails  = deatails;
            report.Identification = identifiObj;
            string xmlStr     = string.Empty;
            string xmlmessage = string.Empty;

            using (StringWriter sw = new StringWriter())
            {
                MemoryStream            ms         = new MemoryStream();
                XmlTextWriter           textwriter = new XmlTextWriter(ms, Encoding.GetEncoding("UTF-8"));
                XmlSerializer           xz         = new XmlSerializer(typeof(LabReport));
                XmlSerializerNamespaces ns         = new XmlSerializerNamespaces();
                ns.Add("", "");
                xz.Serialize(textwriter, report, ns);
                xmlmessage = Encoding.UTF8.GetString(ms.GetBuffer());
                //xz.Serialize(sw, report, ns);
                xmlStr = xmlmessage;
            }

            HttpItem httpItem = CreateHttpItem(@"vetsync/v1/orders");

            httpItem.Method  = HttpMethod.Post;
            httpItem.Content = Encoding.UTF8.GetBytes(xmlStr);


            HttpResult <string> result = WebLogic.GetHttpResult <string>(httpItem);

            if (result.Success)
            {
                //result.Result   //----------此字段为返回的数据! 返回什么表示成功????
            }
        }