/// <summary> /// 转为前台json数据 /// </summary> /// <param name="r"></param> /// <returns></returns> public static string ToActionResult(this RPC_Result r) { if (r.Success) { return(Newtonsoft.Json.JsonConvert.SerializeObject(new { success = true, message = string.IsNullOrWhiteSpace(r.Message) ? "操作成功!" : r.Message, errorcode = r.ErrorCode, type = "success" })); } else { return(Newtonsoft.Json.JsonConvert.SerializeObject(new { success = false, message = string.IsNullOrWhiteSpace(r.Message) ? "操作失败!" : r.Message, errorcode = r.ErrorCode, type = "error" })); } }
public static string ToActionResultModel <T>(this RPC_Result <T> r) { IsoDateTimeConverter timeFormat = new IsoDateTimeConverter(); timeFormat.DateTimeFormat = "yyyy-MM-dd HH:mm:ss"; if (r.Success) { return(Newtonsoft.Json.JsonConvert.SerializeObject(r.Value, Newtonsoft.Json.Formatting.Indented, timeFormat)); } else { return(Newtonsoft.Json.JsonConvert.SerializeObject(null, Newtonsoft.Json.Formatting.Indented, timeFormat)); } }
/// <summary> /// 转为前台json数据 /// </summary> /// <param name="r"></param> /// <returns></returns> public static string ToActionResult <T>(this RPC_Result <T> r) { IsoDateTimeConverter timeFormat = new IsoDateTimeConverter(); timeFormat.DateTimeFormat = "yyyy-MM-dd HH:mm:ss"; if (r.Success) { return(Newtonsoft.Json.JsonConvert.SerializeObject(new { success = true, message = string.IsNullOrWhiteSpace(r.Message) ? "操作成功!" : r.Message, value = r.Value, errorcode = r.ErrorCode, type = "success" } , Newtonsoft.Json.Formatting.Indented, timeFormat)); } else { return(Newtonsoft.Json.JsonConvert.SerializeObject(new { success = false, message = string.IsNullOrWhiteSpace(r.Message) ? "操作失败!" : r.Message, value = r.Value, errorcode = r.ErrorCode, type = "error" } , Newtonsoft.Json.Formatting.Indented, timeFormat)); } }
public ActionResult GetActionResult(SMS.Model.RPC_Result result) { ISMPModel.RPC_Result r = new ISMPModel.RPC_Result(result.Success, result.Message); return(GetActionResult(r)); }