庹庹

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
  22 随笔 :: 1 文章 :: 0 评论 :: 26847 阅读

1.in wcf sever side,you create this interface

复制代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using NurseWcfLib.NurseWorkServiceReference;
using System.ServiceModel.Web;

namespace NurseWcfLib
{
// 注意: 使用“重构”菜单上的“重命名”命令,可以同时更改代码和配置文件中的接口名“IService1”。
[ServiceContract]
public interface INurseWorkSvc
{
[OperationContract]
[WebGet(UriTemplate
= "GetHISAccout/{appid}/{phoneNo}",
ResponseFormat
= WebMessageFormat.Json,
BodyStyle
= WebMessageBodyStyle.Wrapped)]
string GetHISAccout(string appid, string phoneNo);

[OperationContract]
[WebGet(UriTemplate
= "GetNightingale/{appid}/{phoneNo}/{pwd}",
ResponseFormat
= WebMessageFormat.Json,
BodyStyle
= WebMessageBodyStyle.Wrapped)]
Nightingale GetNightingale(
string appid, string phoneNo,string pwd);

[OperationContract]
[WebGet(UriTemplate
= "GetPatientInfo/{department}",
ResponseFormat
= WebMessageFormat.Json,
BodyStyle
= WebMessageBodyStyle.Wrapped)]
IList
<PatientInfo> GetPatientInfo(string department);

[OperationContract]
[WebGet(UriTemplate
= "GetPatientAdvice/{patientNo}/{admissTimes}/{flag}",
ResponseFormat
= WebMessageFormat.Json,
BodyStyle
= WebMessageBodyStyle.Wrapped)]
IList
<PatientAdvice> GetPatientAdvice(string patientNo, string admissTimes, string flag);

[OperationContract]
[WebInvoke(
UriTemplate
= "ConfirmAdvice",
Method
= "POST",
ResponseFormat
= WebMessageFormat.Json,
RequestFormat
= WebMessageFormat.Json,
BodyStyle
= WebMessageBodyStyle.Wrapped)]
int ConfirmAdvice(string his_account, string patientNo, string times);

[OperationContract]
[WebInvoke(
UriTemplate
= "SubmitRecord",
Method
= "POST",
ResponseFormat
= WebMessageFormat.Json,
RequestFormat
= WebMessageFormat.Json,
BodyStyle
= WebMessageBodyStyle.Wrapped)]
int SubmitRecord(NursingRecord record);
}


}
复制代码

2.the data contract.

复制代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;

namespace com.guc.android.wcf.datacontract.Nurse
{
[DataContract]
public class NursingRecord
{
//HISAccouns--HIS帐号
//timebh--时间编号
//patientNo--住院号
//admissTimes--住院次数
//position--体温部位
//temperature--体温
//piesis_x--血压x
//piesis_y--血压y
//respiration--呼吸
//pulse --脉搏
//liquidinput--液体入量
//urea--尿液
//bowels--大便次数
//otheroutput--其它排出量

[DataMember]
public string patientNo { set; get; }
[DataMember]
public string admissTimes { set; get; }
[DataMember]
public string timebh { set; get; }
[DataMember]
public string his_account { set; get; }
[DataMember]
public string position { set; get; }
[DataMember]
public string temperature { set; get; }
[DataMember]
public string pulse { set; get; }
[DataMember]
public string respiration { set; get; }
[DataMember]
public string piesis_x { set; get; }
[DataMember]
public string piesis_y { set; get; }

[DataMember]
public string liquidinput { set; get; }
[DataMember]
public string urea { set; get; }
[DataMember]
public string bowels { set; get; }
[DataMember]
public string otheroutput { set; get; }

}
}
复制代码

 

3.using jquery and send json string parameter to server,the json parameter name must same as the server method parameter.and you can using JSON.stringify(javascriptObject) method to convert an object to jsonstring. for example:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>this is integrated daily report page</title>
<script type="text/javascript" src="../js/jquery-1.4.1.min.js"></script>
<script type="text/javascript" src="../js/guc_widget.js"></script>
<script type="text/javascript" src="../js/guc_ui.js"></script>
<script>
    $(function() {
        calendarWidget();
        $("#submit").bind("click",function(){
            alert("click submit...");
            submitRecord();
            });
    });
 
    function submitRecord() {
        $("#jsonstring").html(getRecord());
        $.ajax({
            type : "POST",
            dataType:"json",
            contentType : "application/json",
            url : "http://192.168.0.110:8082/Nurse/SubmitRecord",
            data:getRecord(),
            success : function(result) {
            alert("server result:"+result.SubmitRecordResult);
                hideProgress();
            },
            beforeSend : function() {
                showProgress();
            },
            error : function(xhr) {
                $("#response").html(xhr.responseText)
                hideProgress();
            }
        });
    }
     
    function getRecord(){
        var data={
                record:{
                    his_account:"00000",
                    timebh:"1",
                    patientNo:"*001201",
                    admissTimes:"1",
                    position:"1",
                    piesis_x:"1",
                    piesis_y:"1",
                    respiration:"1",
                    temperature:"36.5",
                    pulse:"1",
                    liquidinput:"1",
                    urea:"1",
                    bowels:"1",
                    otheroutput:"1"
                    }
                }
        return JSON.stringify(data);
         
    }
</script>
</head>
<body>
    <div id="calendarWidget"></div>
    <div id="" style="clear: both"></div>
    <h3>一般护理记录单</h3>
    <div id="jsonstring"></div>
    <div id="response"></div>
    <input type="button" value="submit" id="submit"/>
</body>
</html>

 

posted on   庹林  阅读(394)  评论(0编辑  收藏  举报
编辑推荐:
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
阅读排行:
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· 分享 3 个 .NET 开源的文件压缩处理库,助力快速实现文件压缩解压功能!
· Ollama——大语言模型本地部署的极速利器
· [AI/GPT/综述] AI Agent的设计模式综述
点击右上角即可分享
微信分享提示