/// <summary> /// 校验类,实始状态码为10000 /// </summary> /// <param name="msg"></param> /// <param name="state"></param> /// <returns></returns> public static VExcept Verify(string msg, int state) { VExcept we = new VExcept(msg, state); we.State = 1000 + state; return(we); }
/// <summary> /// 执行,返回结构封装到DataResult对象中 /// </summary> /// <param name="letter">客户端递交的参数信息</param> /// <returns></returns> public static DataResult ExecToResult(Letter letter) { DateTime time = DateTime.Now; try { if (!"weishakeji".Equals(letter.HTTP_Mark)) { throw VExcept.System("请求标识不正确", 100); } //执行方法 object res = Exec(letter); //计算耗时 double span = ((TimeSpan)(DateTime.Now - time)).TotalMilliseconds; // //如果是分页数据 if (res is ListResult) { ListResult list = (ListResult)res; list.ExecSpan = span; return(list); } return(new Song.ViewData.DataResult(res, span)); //普通数据 } catch (Exception ex) { //如果是自定义异常 if (ex.InnerException is VExcept) { VExcept except = (VExcept)ex.InnerException; return(new Song.ViewData.DataResult(except, time)); } return(new Song.ViewData.DataResult(ex, time)); } }