/// <summary> /// 定义输入参数的描述 /// </summary> /// <param name="name">参数名称</param> /// <param name="type">参数类型描述</param> /// <param name="desc">参数描述</param> /// <param name="defaultvalue">默认值描述</param> /// <param name="position">参数传入的位置</param> /// <param name="isAllowEmpty">是否允许为空</param> public EWRAAddInputAttribute(string name, string type, string desc, string defaultvalue = null, RestInputPosition position = RestInputPosition.PostData, bool isAllowEmpty = true) { Name = name; ValueType = type; Desc = desc; DefaultValue = defaultvalue; IsAllowEmpty = isAllowEmpty; Position = ComFunc.Enum2String <RestInputPosition>(position); }
public dynamic ToJSONObject() { var rtn = FrameDLRObject.CreateInstance(FrameDLRFlags.SensitiveCase); rtn.UserID = UserID; rtn.UserName = UserName; rtn.RoleID = RoleID; rtn.RoleName = RoleName; rtn.GroupID = GroupID; rtn.GroupName = GroupName; rtn.TeamID = TeamID; rtn.TeamName = TeamName; rtn.AgentID = AgentID; rtn.AgentName = AgentName; rtn.Actions = Actions; rtn.LoginTime = LoginTime; rtn.ForceLogoutTimeOut = ForceLogoutTimeOut; rtn.LoginIPAddress = LoginIPAddress; rtn.UserSex = ComFunc.Enum2String <SexType>(UserSex); return(rtn); }
/// <summary> /// Rest接口输出的描述 /// </summary> /// <param name="desc">返回结果的描述</param> /// <param name="format">返回结构集的结构描述,比如:如果为JSON,则填写json的数据格式,如: /// { /// "code":"执行结果状态,success为成功,failed为失败", /// "msg":"执行结果的提示信息", /// "data":[结果集数组] /// } /// </param> /// <param name="type"></param> public EWRAOutputDescAttribute(string desc, string format, RestContentType type = RestContentType.JSON) { Desc = desc; FormatDesc = format; ReturnType = ComFunc.Enum2String <RestContentType>(type); }
/// <summary> /// 转换成串 /// </summary> /// <returns></returns> public override string ToString() { string rtn = ""; rtn = ComFunc.Base64Code(this._id + ";" + this._expired + ";" + this._starttime.ToFileTimeUtc() + ";" + ComFunc.Enum2String <TransStatus>(this._transstatus)) + ";" + _isExpired; return(rtn); }
protected override void OnError(Exception ex, ParameterStd p, DataCollection d) { var ep = (EWRAParameter)p; var ed = (EWRAData)d; ed.StatusCode = Constants.RestStatusCode.INVALID_REQUEST; var isdebug = p[DomainKey.CONFIG, "DebugMode"] == null ? false : (bool)p[DomainKey.CONFIG, "DebugMode"]; string errorCode = "E-" + DateTime.Now.ToString("yyyyMMddHHmmssfff"); string errlog = ""; if (ex is HostJsException) { var jex = (HostJsException)ex; if (ex.InnerException != null) { if (ex.InnerException is HostJsException) { var ijex = (HostJsException)ex.InnerException; errlog = string.Format("错误编号:{0},\n{1}\n{2}\n出错代码行数{3}\n出错代码列数{4}\n出错代码位置{5}\nInnerException:{6}\n{7}\n出错代码行数{8}\n出错代码列数{9}\n出错代码位置{10}", errorCode, ex.Message, ex.StackTrace, jex.Line, jex.Column, jex.SourceCode.Replace("\"", "'"), ex.InnerException.Message, ex.InnerException.StackTrace, ijex.Line, ijex.Column, ijex.SourceCode.Replace("\"", "'")); } else { errlog = string.Format("错误编号:{0},\n{1}\n{2}\n出错代码行数{3}\n出错代码列数{4}\n出错代码位置{5}\nInnerException:{6}\n{7}", errorCode, ex.Message, ex.StackTrace, jex.Line, jex.Column, jex.SourceCode, ex.InnerException.Message, ex.InnerException.StackTrace); } } else { errlog = string.Format("错误编号:{0},\n{1}\n{2}\n出错代码行数{3}\n出错代码列数{4}\n出错代码位置{5}", errorCode, ex.Message, ex.StackTrace, jex.Line, jex.Column, jex.SourceCode.Replace("\"", "'")); } } else { if (ex.InnerException != null) { if (ex.InnerException is HostJsException) { var ijex = (HostJsException)ex.InnerException; errlog = string.Format("错误编号:{0},\n{1}\n{2}\nInnerException:{3}\n{4}\n\n出错代码行数{5}\n出错代码列数{6}\n出错代码位置{7}", errorCode, ex.Message, ex.StackTrace, ex.InnerException.Message, ex.InnerException.StackTrace, ijex.Line, ijex.Column, ijex.SourceCode.Replace("\"", "'")); } else { errlog = string.Format("错误编号:{0},\n{1}\n{2}\nInnerException:{3}\n{4}", errorCode, ex.Message, ex.StackTrace, ex.InnerException.Message, ex.InnerException.StackTrace); } } else { errlog = string.Format("错误编号:{0},\n{1}\n{2}", errorCode, ex.Message, ex.StackTrace); } } GlobalCommon.Logger.WriteLog(LoggerLevel.ERROR, errlog); var contentbody = FrameDLRObject.CreateInstance(FrameDLRFlags.SensitiveCase); var errormsg = ""; if (isdebug) { errormsg = string.Format("出错了,{0}", errlog);; } else { errormsg = string.Format("系统错误!!!(错误编号:{0})", errorCode); } contentbody.error = errormsg; var jsonmsg = ((FrameDLRObject)contentbody).ToJSONString(true); var msgbytelength = Encoding.UTF8.GetByteCount(jsonmsg); SetHeaders(ep, ed); if (page_500 == "") { ep.CurrentHttpContext.Response.StatusCode = (int)ed.StatusCode; ep.CurrentHttpContext.Response.ContentType = ResponseHeader_ContentType.Map(ComFunc.Enum2String <RestContentType>(ed.ContentType).ToLower()) + ";charset=utf-8"; ep.CurrentHttpContext.Response.Headers.Add("Content-Length", msgbytelength + ""); ep.CurrentHttpContext.Response.WriteAsync(jsonmsg); ep.CurrentHttpContext.Response.Body.FlushAsync(); } else { ResponsePageContent(page_500, ep, ed); } }