public HttpResponseMessage UpdateModule(Mode mode)
{
var response = Process.Instance.ExecuteString(() =>
{ var count = DbHelper.ExecuteNonQuery(CommandType.Text, strSql.ToString(), parms); if (count < )
{
resultMsg.ResultMsg = "更新失败";
return resultMsg.ToJson();
} resultMsg.Result = ;
resultMsg.total = ;
resultMsg.ResultMsg = "更新成功"; return resultMsg.ToJson(); }); return HttpHelper.ResponseMessagetoJson(response);
}

public class Process
{
private static volatile Process _process = null;
private readonly string returnMsg = "{\"RowsCount\":0,\"Result\":-1,\"ResultMsg\":\" api 500 error\",\"Rows\":null}"; protected Process()
{ } /// <summary> Gets the instance
/// </summary>
public static Process Instance
{
get
{
if (_process == null)
{
lock (typeof(Process))
{
if (_process == null)
{
_process = new Process();
}
}
}
return _process;
}
} public string ExecuteString(Func<string> action)
{
try
{
return action.Invoke();
}
catch (Exception ex)
{
Logger.Error(ex);
return returnMsg;
}
} public dynamic ExecuteStringExtend(Func<dynamic> action)
{
try
{
return action.Invoke();
}
catch (Exception ex)
{
Logger.Error(ex);
return returnMsg;
}
} public string ExecuteStringtran(Func<string> action,ITransactionManager tran)
{
try
{
return action.Invoke();
}
catch (Exception ex)
{
Logger.Error(ex);
if (tran != null) tran.Rollback();
return returnMsg;
}
}
}
public static class HttpHelper
{
public static HttpResponseMessage ResponseMessagetoJsonExtnd(string str)
{
var response = new HttpResponseMessage(HttpStatusCode.OK);
HttpContent content = response.Content;
response.Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "text/html");
return response;
} public static HttpResponseMessage ResponseMessagetoJson(object obj)
{
string str;
if ((obj is string) || (obj is char))
{
str = obj.ToString();
}
else
{
str = obj.ToJson();
}
var response = new HttpResponseMessage(HttpStatusCode.OK)
{
Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "text/html")
};
return response;
}
public static HttpResponseMessage ResponseMessagetoJsonExtend(string str)
{
var response = new HttpResponseMessage(HttpStatusCode.OK)
{
Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "text/html")
};
return response;
}
}

  

C#标准响应数据的更多相关文章

  1. jQuery-1.9.1源码分析系列(十六)ajax——响应数据处理和api整理

    ajax在得到请求响应后主要会做两个处理:获取响应数据和使用类型转化器转化数据 a.获取响应数据 获取响应数据是调用ajaxHandleResponses函数来处理. ajaxHandleRespon ...

  2. rest-assured之验证响应数据(Verifying Response Data)

    前面的文章中已经介绍过了如果获得响应数据,接下来我们来介绍一下应该如何来验证这些获得的响应数据,比如验证状态码.状态行.cookies.header.content-type以及body体. 1.验证 ...

  3. 使用HttpServletRequestWrapper修改请求参数 和 使用HttpServletResponseWrapper截获响应数据

    Servlet规范中的Filter引入了一个功能强大的拦截模式.Filter能在request到达servlet的服务方法之前拦截request对象,而在服务方法转移控制后又能拦截response对象 ...

  4. Jmeter运行后,查看结果树中的响应数据出现中文乱码。

    参考:https://blog.csdn.net/qq_15228737/article/details/82597482 https://baike.baidu.com/item/UTF-8/481 ...

  5. Java框架之SpringMVC 03-RequestMapping-请求数据-响应数据

    SpringMVC SpringMVC是一种轻量级的.基于MVC的Web层应用框架. 通过一套 MVC 注解,让 POJO 成为处理请求的控制器,而无须实现任何接口. 采用了松散耦合可插拔组件结构,比 ...

  6. 用 jQuery.ajaxSetup 实现对请求和响应数据的过滤

    不知道同学们在做项目的过程中有没有相同的经历呢?在使用 ajax 的时候,需要对请求参数和响应数据进行过滤处理,比如你们觉得就让请求参数和响应信息就这么赤裸裸的在互联网里来回的穿梭,比如这样: 要知道 ...

  7. ASP.NET Core 中文文档 第四章 MVC(2.3)格式化响应数据

    原文:Formatting Response Data 作者:Steve Smith 翻译:刘怡(AlexLEWIS) 校对:许登洋(Seay) ASP.NET Core MVC 内建支持对相应数据( ...

  8. Jmeter—5 关联 响应数据传递-正则表达式提取器

    在测试过程中,遇到一个问题:用户登录成功后服务器会返回一个登录凭证,之后所有的操作都需要带上此凭证.我们怎么获取登录凭证并传递给后续的操作? Jmeter提供了正则表达式提取器,用变量提取参数,后续通 ...

  9. Jmeter—4 添加断言 判断响应数据是否符合预期

    发出请求之后,通过添加断言可以判断响应数据是否是我们的预期结果. 1 在Jmeter中发送一个登录的http请求(参数故意输入错误).结果肯定是登陆失败啦. 但结果树中http请求的图标显示‘绿色’表 ...

随机推荐

  1. (译)如何优化cocos2d程序的内存使用和程序大小:第二部分(完)

    前言:从上周发布教程的微博反应情况来看,cocos2der们对于游戏的内存问题还是非常关心的.本文是上一篇博文的续,旨在教大家如何减少cocos2d程序的大小. 全文如下: 减少你的程序的大小 把纹理 ...

  2. opengl的mipmap

    压缩纹理是不能调用glGenerateMipmap生成mipmap的. DDS和PVR都不行. 强行调用会产生GL_INVALID_OPERATION的错误. PNG格式试验了glGenerateMi ...

  3. Asp.Net Web API 2第二课——CRUD操作

    详情请查看http://aehyok.com/Blog/Detail/69.html 个人网站地址:aehyok.com QQ 技术群号:206058845,验证码为:aehyok 本文文章链接:ht ...

  4. Wix 安装部署教程(三)自定义安装界面和行为

    接上一篇自定义安装界面,这篇继续探索,首先介绍下,Wix为我们定义了五种风格,每种风格的UI都是有一定顺序的.我们可以改变安装顺序,也可以完全自定义一个Dialog插入其中.比如Wix_Mondo 风 ...

  5. android selector(如对TextView点击样式改变)

    selector 1.selector 从单词的意思来说:选择者,选择器,就是对你的目标的控制. 从API来说: A controller for the selection of Selectabl ...

  6. [JS8] 显示从(0,0)到(0,0)的坐标

    <html> <head> <title>JS Unleashed</title> </head> <body> <SCR ...

  7. 深入浅出OOP(一): 多态和继承(早期绑定/编译时多态)

    在本系列中,我们以CodeProject上比较火的OOP系列博客为主,进行OOP深入浅出展现. 无论作为软件设计的高手.或者菜鸟,对于架构设计而言,均需要多次重构.取舍,以有利于整个软件项目的健康构建 ...

  8. piap.excel 微软 时间戳转换mssql sql server文件时间戳转换unix 导入mysql

    piap.excel 微软 时间戳转换mssql sql server文件时间戳转换unix 导入mysql 需要不个mssql的sql文件导入mysql.他们的时间戳格式不同..ms用的是自定义的时 ...

  9. iOS开发-图片高斯模糊效果

    iOS开发的时候有的时候需要将图片设置模糊,或者通过点击下拉方法,去除模糊,一切都是为了应用更受用户欢迎,iOS7之后半透明模糊效果得到大范围使用的比较大,现在也可以看到很多应用局部用到了图片模糊效果 ...

  10. JQ中mouseover和mouseenter的区别

    我最近也在学习JQuery,所以最近对JQ中的一些小问题进行总结,方便学习. 在对于刚开始学习JQ的初学者来说,mouseover事件和mouseenter事件总是傻傻分不清楚,毕竟刚开始学习的时候, ...