C# 一般处理程序操作类
1、IWsService类
using ProjectCommon;
using SysFrameWeb.AppCode;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
namespace SysFrameWeb.API
{
public interface IWsService
{
void ProcessRequest(HttpContext context, ref Msg_Result msg, string strParamData,string strUserName);
}
}
2、ServiceContainer类
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Practices.Unity;
namespace SysFrameWeb.API
{
public class ServiceContainer
{
public static IUnityContainer Current()
{
IUnityContainer container = new UnityContainer();
#region 系统设置
container.RegisterType<IWsService, CommonManage>("LOGIN".ToUpper()); //获取用户登录
container.RegisterType<IWsService, xxx>("LOGINX".ToUpper()); //获取用户登录
container.RegisterType<IWsService, CommonManage>("USERINFO".ToUpper()); //获取用户登录
container.RegisterType<IWsService, CommonManage>("GETUSERBYBRANCH".ToUpper()); //获取部门用户表
container.RegisterType<IWsService, CommonManage>("GETUSERSCOREPAGE".ToUpper()); //获取考试记录页
container.RegisterType<IWsService, CommonManage>("GETUSERTITLEPAGE".ToUpper()); //获取某次考试详细记录页
container.RegisterType<IWsService, CommonManage>("ADDEXAM".ToUpper()); //获取某次考试详细记录页
#endregion
container.RegisterType<IWsService, INManage>("GETLQFBTREE".ToUpper()); //获取楼群分布表的Tree方法
container.RegisterType<IWsService, INManage>("GETLQINFOPAGE".ToUpper()); //获取楼群详情表的方法
container.RegisterType<IWsService, INManage>("GETLQLISTPAGE".ToUpper()); //获取楼群列表的方法
#region 医生管理
container.RegisterType<IWsService, INManage>("GETBMSORTTREE".ToUpper()); //获取部门表的Tree方法
container.RegisterType<IWsService, INManage>("DELLQLIST".ToUpper()); //获取删除院楼信息
container.RegisterType<IWsService, INManage>("DELLQKSDETIAL".ToUpper()); //获取删除楼群科室详情信息
container.RegisterType<IWsService, INManage>("GETDOCLISTPAGE".ToUpper()); //获取医生列表的方法
container.RegisterType<IWsService, INManage>("DELDOCLIST".ToUpper()); //获取删除医生表信息
container.RegisterType<IWsService, INManage>("DELDOCID".ToUpper()); //获取删除医生表信息
container.RegisterType<IWsService, INManage>("DELCASEHEALTHEXAM".ToUpper());//获取删除医生简介信息
//线上预约
container.RegisterType<IWsService, INManage>("GETYYINFOTPAGE".ToUpper()); //获取预约列表的方法
container.RegisterType<IWsService, INManage>("DELDOCLIST".ToUpper()); //获取删除医生表信息
container.RegisterType<IWsService, INManage>("DELCASEHEALTHEXAM".ToUpper());//获取删除医生简介信息
//科室信息
container.RegisterType<IWsService, INManage>("GETYYKSPAGE".ToUpper()); //获取科室列表信息的方法
container.RegisterType<IWsService, INManage>("DELKSLIST".ToUpper()); //获取删除科室表信息
container.RegisterType<IWsService, INManage>("GETDEPLIST".ToUpper()); //获取导入His科室表信息
container.RegisterType<IWsService, INManage>("GETYYLIST".ToUpper()); //获取导入His科室医生表信息
#endregion
#region 分院信息
container.RegisterType<IWsService, INManage>("DELFYXX".ToUpper()); //删除分院信息
#endregion
#region 手机页面数据获取和处理
container.RegisterType<IWsService, INManage>("GETHOSINFO".ToUpper()); //获取导入His科室医生表信息
container.RegisterType<IWsService, INManage>("GETDEPINFO".ToUpper()); //获取导入His科室表信息
container.RegisterType<IWsService, INManage>("GETDEPJJINFO".ToUpper()); //获取科室简介信息
container.RegisterType<IWsService, INManage>("GETDEPYSINFO".ToUpper()); //获取科室名称和医生信息
container.RegisterType<IWsService, INManage>("GETYSJJINFO".ToUpper()); //获取医生简介信息
#endregion
return container;
}
}
}
3、CommonManage类
using ProjectCommon;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Web;
using FastReflectionLib;
using System.Data;
namespace SysFrameWeb.API
{
public class CommonManage : IWsService
{
public void ProcessRequest(HttpContext context, ref Msg_Result msg, string strParamData, string strUserName)
{
MethodInfo methodInfo = typeof(CommonManage).GetMethod(msg.Action.ToUpper());
CommonManage model = new CommonManage();
methodInfo.FastInvoke(model, new object[] { context, msg, strParamData, strUserName });
}
#region 系统
//获取登录信息
public void LOGIN(HttpContext context, Msg_Result msg, string strParamData, string strUserName)
{
User u = new User();
u.uid = "111";
u.uName = "admin";
msg.Result = "1";
msg.Result1 = JsonHelper.ToJson(u);
msg.Result5 = "0";
}
public class User
{
public string uid { get; set; }
public string uName { get; set; }
}
//获取考试记录
public void USERINFO(HttpContext context, Msg_Result msg, string strParamData, string strUserName)
{
User u = new User();
u.uid = "111";
u.uName = "admin";
msg.Result = u;
}
//获取某次考试详细记录
public void GETUSERTITLEPAGE(HttpContext context, Msg_Result msg, string strParamData, string strUserName)
{
//string xuanxiang = context.Request["xuanxiang"] ?? "";
//string baseSearch = context.Request["baseName"] ?? "";
//string pageIndex = context.Request["pageIndex"] ?? "0";
//string pageCount = context.Request["pageCount"] ?? "0";
//string ksid = context.Request["ksid"] ?? "0";
//int pageTotal = 0;
//msg.Result = new AQ_UserTitleB().GetUserTitleByPage(ref pageTotal, ksid, strParamData, baseSearch, xuanxiang, int.Parse(pageIndex), int.Parse(pageCount));
//msg.Result1 = pageTotal;
}
//根据部门获取用户列表
public void GETUSERBYBRANCH(HttpContext context, Msg_Result msg, string strParamData, string strUserName)
{
//string baseName = context.Request["SearchText"] ?? "";
//string HOID = context.Request["HID"] ?? "";
//string pageIndex = context.Request["pageIndex"] ?? "1";
//string pageCount = context.Request["pageCount"] ?? "10";
//int pageTotal = 0;
//msg.Result = new JH_Auth_UserB().GetUserByBranch(strParamData, baseName,int.Parse(HOID), int.Parse(pageIndex), int.Parse(pageCount), ref pageTotal);
//msg.Result1 = pageTotal;
}
#endregion
}
}
4、一般处理程序操作页面
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Microsoft.Practices.Unity;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json;
using System.Web.SessionState;
using ProjectCommon;
namespace SysFrameWeb.API
{
/// <summary>
/// FTAPI 的摘要说明
/// </summary>
public class FTAPI : IHttpHandler, IRequiresSessionState
{
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
context.Response.AddHeader("pragma", "no-cache");
context.Response.AddHeader("cache-control", "");
context.Response.CacheControl = "no-cache";
context.Response.ContentType = "text/plain";
string strAction = context.Request["Action"] ?? "";
string strUserName = context.Request["UserName"] ?? "";
if (strUserName == "" && HttpContext.Current.Session["UserName"] != null)
{
strUserName = HttpContext.Current.Session["UserName"].ToString();
}
string strParamData = context.Request["ParamData"] ?? "";
Msg_Result Model = new Msg_Result() { Action = strAction.ToUpper(), ErrorMsg = "" };
if (!string.IsNullOrEmpty(strAction))
{
try
{
var container = ServiceContainer.Current().Resolve<IWsService>(strAction.ToUpper());
container.ProcessRequest(context, ref Model, strParamData, strUserName);
}
catch (Exception ex)
{
Model.ErrorMsg = "操作异常,请重试!" + ex.Message;
Model.Result = ex.Message;
}
IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
//string Result = JsonConvert.SerializeObject(Model, Formatting.Indented, timeConverter).Replace("null", "\"\"");
string Result = JsonConvert.SerializeObject(Model, Formatting.Indented, timeConverter);
context.Response.Write(Result);
}
}
public bool IsReusable
{
get
{
return false;
}
}
}
}
操作说明
一般处理程序调用后, 通过判断参数,执行不同的类文件中的方法。