/// <summary> /// 获取指定的SQL 字符窜。 /// </summary> /// <param name="xmlFileName"></param> /// <param name="sqlName"></param> /// <returns></returns> public MB.Orm.DbSql.SqlString[] GetSqlString(string xmlFileName, string sqlName) { // string xmlFileFullName = XML_FILE_PATH + xmlFileName + ".xml"; //统一在方法 getSqlNode 进行判断 //if (!System.IO.File.Exists(xmlFileFullName)) // throw new MB.Util.APPException(string.Format("XML配置文件{0},不存在!", xmlFileFullName), MB.Util.APPMessageType.SysErrInfo); System.Xml.XmlNode sqlNode = getSqlNode(xmlFileName, sqlName); if (sqlNode == null || sqlNode.ChildNodes.Count == 0) { TraceEx.Write("在XML 文件:" + xmlFileName + " 中获取相应SQL 语句:" + sqlName + "出错,请检查资源文件或者对应SQL 语句是否存在!"); return(null); } List <MB.Orm.DbSql.SqlString> sqlStrings = new List <SqlString>(); foreach (System.Xml.XmlNode sqlStringNode in sqlNode.ChildNodes) { if (sqlStringNode.NodeType != System.Xml.XmlNodeType.Element) { continue; } if (string.Compare(sqlStringNode.Name, XML_SQL_STRING_NAME, true) != 0) { continue; } string str = string.Empty; foreach (System.Xml.XmlNode node in sqlStringNode.ChildNodes) { if (node.NodeType != System.Xml.XmlNodeType.Element) { continue; } if (string.Compare(node.Name, XML_SQL_STRING_TEXT_NAME, true) != 0) { continue; } TraceEx.Write("成功发现SQL 语句:" + sqlName); str = formatSqlString(node.InnerText.Trim()); break; } List <SqlParamInfo> pars = getSqlParams(sqlStringNode); MB.Orm.DbSql.SqlString sqlStr = new MB.Orm.DbSql.SqlString(str, pars); sqlStrings.Add(sqlStr); } return(sqlStrings.ToArray()); }
/// <summary> /// 根据指定的 XML 和 SQL 名称获取参数的Mapping 配置信息。 /// </summary> /// <param name="xmlFileName"></param> /// <param name="sqlName"></param> /// <returns></returns> public MB.Orm.Mapping.QueryParameterMappings GetSqlQueryParamMappings(string xmlFileName, string sqlName) { System.Xml.XmlNode sqlNode = getSqlNode(xmlFileName, sqlName); if (sqlNode == null || sqlNode.ChildNodes.Count == 0) { TraceEx.Write("在XML 文件:" + xmlFileName + " 中获取相应SQL 语句:" + sqlName + "出错,请检查资源文件或者对应SQL 语句是否存在!"); return(null); } MB.Orm.Mapping.QueryParameterMappings mappings = null; foreach (System.Xml.XmlNode paramMappingNode in sqlNode.ChildNodes) { if (paramMappingNode.NodeType != System.Xml.XmlNodeType.Element) { continue; } if (string.Compare(paramMappingNode.Name, XML_PARAM_MAPPINGS, true) != 0) { continue; } mappings = new QueryParameterMappings(); if (paramMappingNode.Attributes["DefaultTableAlias"] != null) { mappings.DefaultTableAlias = paramMappingNode.Attributes["DefaultTableAlias"].Value; } foreach (System.Xml.XmlNode node in paramMappingNode.ChildNodes) { if (node.NodeType != System.Xml.XmlNodeType.Element) { continue; } if (string.Compare(node.Name, "Mapping", true) != 0) { continue; } if (node.Attributes["Name"] == null || node.Attributes["DbFieldName"] == null) { throw new MB.Util.APPException(string.Format("XML配置文件{0},配置QueryParamMappings 是可能没有配置 Name 或者 DbFieldName!", xmlFileName)); } mappings.Add(new QueryParameterMappingInfo(node.Attributes["Name"].Value, node.Attributes["DbFieldName"].Value)); } break; } return(mappings); }
public BaseAndroidController() : base() { //获取访问语言 Language = GetLanguage(); HttpRequest httpRequest = HttpContext.Current.Request; string path = httpRequest.Path; string RawUrl = httpRequest.RawUrl; TraceEx.Write(SysMessageLevel.SysReceiveInfo, string.Format("访问路径:{0}", RawUrl)); if (!NoTokenUrl.Contains(path.ToLower())) { tokenModel = CheckAndGetToken(); HttpContext.Current.Request.Headers.Add("TokenStatus", tokenModel.CheckResult.ToString()); } else { HttpContext.Current.Request.Headers.Add("TokenStatus", CheckToken_Success.ToString()); } }
/// <summary> /// 终止系统产生的异常,并以消息的形式提示给用户。 /// </summary> /// <param name="ex">异常</param> /// <param name="expectMsgOnError">出错时期待提示的消息。</param> public void ExceptionTerminate(Exception ex, string expectMsgOnError) { MB.Util.APPException appEx = getAppException(ex);// as MB.Util.APPException; string reason = string.Empty; if (appEx == null) { appEx = ex.InnerException as MB.Util.APPException; } if (appEx != null) { if (appEx.MsgLever == MB.Util.APPMessageType.DisplayToUser) { MessageBoxEx.Show(appEx.Message); return; } else { expectMsgOnError = MB.Util.TraceEx.GetErrorMessageByType(appEx.MsgLever) + " " + appEx.Message; } } else { System.ServiceModel.FaultException <MB.Util.Model.WcfFaultMessage> fex = ex as System.ServiceModel.FaultException <MB.Util.Model.WcfFaultMessage>; if (fex != null) { if (fex.Detail != null) { if (fex.Detail.MessageType == MB.Util.APPMessageType.DisplayToUser) { MessageBoxEx.Show(fex.Detail.Message); return; } else { reason = fex.Detail.Message + " " + MB.Util.TraceEx.GetErrorMessageByType(fex.Detail.MessageType); } } else { reason = fex.Message; } } string msg = string.Empty; if (string.IsNullOrEmpty(reason)) { getErrMessage(ex, ref msg); } TraceEx.Write(msg, APPMessageType.SysErrInfo); if (!string.IsNullOrEmpty(ex.StackTrace)) { TraceEx.Write(ex.StackTrace, APPMessageType.SysErrInfo); } } if (string.IsNullOrEmpty(expectMsgOnError)) { if (string.IsNullOrEmpty(reason)) { reason = "系统出现未知的异常,请重试!"; } MessageBoxEx.Show(reason); } else { MessageBoxEx.Show("系统错误:" + expectMsgOnError); } }