反射(前台到后台,后台到前台)

简介: 后台: using System;using System.Collections.Generic;using System.Linq;using System.Reflection;using System.

后台:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Web;
using System.Web.Script.Serialization;
using HotelCheckIn_PlatformSystem.DataService.BLL;
using HotelCheckIn_PlatformSystem.DataService.Bll;
using HotelCheckIn_PlatformSystem.DataService.Dal;
using HotelCheckIn_PlatformSystem.DataService.Model;
using HotelCheckIn_PlatformSystem.DataService.Model.Parameter;
using log4net;

namespace HotelCheckIn_PlatformSystem.DataService.WebService.Material
{
  /// <summary>
  /// Summary description for MaterialService
  /// </summary>
  public class MaterialService : IHttpHandler
  {
    protected ILog Log = LogManager.GetLogger("PriceAdjustmentService");
    readonly JavaScriptSerializer _jss = new JavaScriptSerializer();
    public void ProcessRequest(HttpContext context)
    {
      context.Response.ContentType = "text/plain";
      var action = context.Request.Params["action"];
      Type curType = GetType();
      MethodInfo method = curType.GetMethod(action, BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
      if (method != null)
      {
        method.Invoke(this, new object[] { HttpContext.Current });
      }
      else
      {
        context.Response.Write("没有这个方法!");
      }
  }

  /// <summary>
  /// 页面初始化素材表数据
  /// </summary>
  /// <param name="context"></param>
  private void InitMaterialGrid(HttpContext context)
  {
    string strjson = null;
    var json = new ZwJson<InitMaterialGrid>();
    var materialdal = new MaterialDal();
    var page = context.Request.Params["page"];
    var rows = context.Request.Params["rows"];
    var mypage = 0;
    var mysize = 0;
    var count = 0;
    if (!string.IsNullOrEmpty(page))
      mypage = int.Parse(page);
    if (!string.IsNullOrEmpty(rows))
      mysize = int.Parse(rows);
    try
    {

      var dt = materialdal.QueryByPage(new Model.Material(), mypage, mysize, ref count);
      var list = ConvertHelper<InitMaterialGrid>.ConvertToList(dt);
      json.Rows = list;
      json.Total = count;
      strjson = _jss.Serialize(json);
      strjson = strjson.Replace("Total", "total");
      strjson = strjson.Replace("Rows", "rows");
    }
    catch (Exception e)
    {
      Log.Error(e);
    }
    if (strjson != null) context.Response.Write(strjson);
  }

  public bool IsReusable
  {
    get
    {
      return false;
    }
  }
  }
}

 

 

前台:

var myurl;
var mydata;
var postype = "POST";
var getype = "GET";
var jsontype = "json";
var htmltype = "html";
var contentype = "application/json; charset=utf-8";

//---------------------------- 初始化 ---------------------------------
$(function () {
initGrid(); //初始化datagrid
});
/**
* *设置datagrid对象
**/
var dgObj = {
url: '../../DataService/WebService/Material/MaterialService.ashx',
queryParams: { action: 'InitMaterialGrid' },
fit: true,
pagination: true,
pageSize: 20,
singleSelect: true,
border: false,
striped: true,
toolbar: "#tb"
};

//---------------------------- 页面方法 ---------------------------------

/**
* *初始化datagrid
**/
function initGrid() {
dgObj.columns = [[
{ field: 'Id', hidden: true },
{ field: 'Name', title: '素材名称', align: 'center', width: 100 },
{ field: 'Url', title: '主路径', align: 'center', width: 316 },
{ field: 'DateTimePara', title: '日期', align: 'center', width: 120 },
{ field: 'Operator', title: '操作人', align: 'center', width: 80 },
{ field: 'Note', title: '备注', align: 'center', width: 183 },
{ field: 'UpdateDtPara', title: '更新日期', align: 'center', width: 120 },
{ field: 'UpdatePerson', title: '更新人', align: 'center', width: 80 }
]];
$('#dg').datagrid(dgObj);
}
//---------------------------- 页面事件 ---------------------------------

/**
* *添加
**/
function add_click() {

}
/**
* *修改
**/
function edit_click() {

}

/**
* *删除
**/
function del_click() {

}

/**
* *上传文件
**/
function upload_click() {

}


/**
* *关闭告警处理界面
**/
function close_click() {
$('#dlg').dialog('close');
}

//---------------------------- ajax方法 ---------------------------------

/**
* *ajax增删改查方法
**/
function ajaxData() {
$.ajax({
url: myurl,
type: postype,
async: false,
data: mydata,
dataType: jsontype,
success: serviceSuccess,
error: serviceError
});
}

/**
* *ajax成功时返回resultObject是json数据
**/
function serviceSuccess(resultObject) {
if (resultObject == null) {
return true;
}
if (resultObject.IsSuccess) {
eval(resultObject.JsExecuteMethod + "(resultObject)");
} else {
parent.messager("提示", resultObject.Msg);
}
return true;
}

/**
* *ajax失败时返回
**/
function serviceError(result) {
return false;
}

目录
相关文章
|
机器学习/深度学习 算法 数据可视化
数据报告分享|WEKA贝叶斯网络挖掘学校在校人数影响因素数据分类模型
数据报告分享|WEKA贝叶斯网络挖掘学校在校人数影响因素数据分类模型
|
5天前
|
云安全 人工智能 安全
AI被攻击怎么办?
阿里云提供 AI 全栈安全能力,其中对网络攻击的主动识别、智能阻断与快速响应构成其核心防线,依托原生安全防护为客户筑牢免疫屏障。
|
15天前
|
域名解析 人工智能
【实操攻略】手把手教学,免费领取.CN域名
即日起至2025年12月31日,购买万小智AI建站或云·企业官网,每单可免费领1个.CN域名首年!跟我了解领取攻略吧~
|
9天前
|
安全 Java Android开发
深度解析 Android 崩溃捕获原理及从崩溃到归因的闭环实践
崩溃堆栈全是 a.b.c?Native 错误查不到行号?本文详解 Android 崩溃采集全链路原理,教你如何把“天书”变“说明书”。RUM SDK 已支持一键接入。
604 214
|
存储 人工智能 监控
从代码生成到自主决策:打造一个Coding驱动的“自我编程”Agent
本文介绍了一种基于LLM的“自我编程”Agent系统,通过代码驱动实现复杂逻辑。该Agent以Python为执行引擎,结合Py4j实现Java与Python交互,支持多工具调用、记忆分层与上下文工程,具备感知、认知、表达、自我评估等能力模块,目标是打造可进化的“1.5线”智能助手。
842 61
|
7天前
|
人工智能 移动开发 自然语言处理
2025最新HTML静态网页制作工具推荐:10款免费在线生成器小白也能5分钟上手
晓猛团队精选2025年10款真正免费、无需编程的在线HTML建站工具,涵盖AI生成、拖拽编辑、设计稿转代码等多种类型,均支持浏览器直接使用、快速出图与文件导出,特别适合零基础用户快速搭建个人网站、落地页或企业官网。
1243 157
|
4天前
|
编解码 Linux 数据安全/隐私保护
教程分享免费视频压缩软件,免费视频压缩,视频压缩免费,附压缩方法及学习教程
教程分享免费视频压缩软件,免费视频压缩,视频压缩免费,附压缩方法及学习教程
239 138
|
7天前
|
存储 安全 固态存储
四款WIN PE工具,都可以实现U盘安装教程
Windows PE是基于NT内核的轻量系统,用于系统安装、分区管理及故障修复。本文推荐多款PE制作工具,支持U盘启动,兼容UEFI/Legacy模式,具备备份还原、驱动识别等功能,操作简便,适合新旧电脑维护使用。
520 109