/// <summary> /// The cdata inner-text of the sql-query hbm.xml node. /// </summary> /// <returns></returns> public string ToHbmSql() { var hbmSql = new StringBuilder(); hbmSql.AppendLine(); hbmSql.Append(EXEC); if (ProcName.Contains(".")) { //schema names may have periods within them looking like [my.schema].[MyStoredProc] //so put braces around everything to the left and right of the last period var procNameParts = ProcName.Split('.').Where(x => !string.IsNullOrWhiteSpace(x)).ToList(); if (procNameParts.Count == 1) { hbmSql.AppendFormat("[{0}]", procNameParts[0]); } else if (procNameParts.Count == 2) { hbmSql.AppendFormat("[{0}].[{1}]", procNameParts[0], procNameParts[1]); } else { var leftSide = string.Format("[{0}]", string.Join(".", procNameParts.Take(procNameParts.Count - 1))); var rightSide = string.Format("[{0}]", procNameParts[(procNameParts.Count - 1)]); hbmSql.AppendFormat("{0}.{1}", leftSide, rightSide); } } else { hbmSql.AppendFormat("[{0}]", ProcName); } hbmSql.AppendLine(); if (Parameters != null && Parameters.Count > 0) { hbmSql.AppendLine(string.Join(",\n", Parameters.Select(x => x.ParamName.Replace("@", "\t:")))); } return(hbmSql.ToString()); }
private void ParseRequest(string requestMethod, string thePath, string rawUrl, string soapAction) { string requestPath = thePath.Substring(1); DadSpecifiedInRequest = true; IsFlexibleParams = false; IsPathAlias = false; string[] pathElements = requestPath.Split('/'); if (pathElements.Length >= 2) { ModuleName = pathElements[0]; DadName = pathElements[1]; if (DadName.Length == 0 || !DadConfiguration.IsValidDad(DadName)) { DadSpecifiedInRequest = false; DadName = DadConfiguration.DefaultDad; } // get dad-specific configuration settings DadConfig = new DadConfiguration(DadName); if (pathElements.Length >= 3) { ProcName = pathElements[2]; if (ProcName.Length > 0) { if (ProcName.Substring(0, 1) == "!") { IsFlexibleParams = true; } else if (ProcName == DadConfig.PathAlias) { IsPathAlias = true; PathAliasValue = GetAliasValue(ProcName, thePath); } else if (ProcName == DadConfig.XdbAlias) { IsXdbAlias = true; XdbAliasValue = GetAliasValue(ProcName, thePath); } else if (ProcName == DadConfig.DocumentPath) { IsDocumentPath = true; } } } else { // missing trailing slash in request ProcName = ""; } if (ProcName.Length == 0) { ProcName = DadConfig.DefaultPage; } if (DadConfig.InvocationProtocol == DadConfiguration.INVOCATION_PROTOCOL_SOAP) { IsSoapRequest = true; IsWsdlRequest = requestMethod.ToUpper() == "GET" && rawUrl.ToLower().EndsWith("?wsdl"); } if (IsSoapRequest && !IsWsdlRequest) { // get the procedure name from the SOAPAction header string methodName = soapAction.Replace("\"", ""); methodName = methodName.Substring(methodName.LastIndexOf("/") + 1); ProcName = ProcName + "." + StringUtil.ReversePrettyStr(methodName); } ProcName = SanitizeProcName(ProcName, DadConfig.ExclusionList); } else { ModuleName = ""; DadName = ""; ProcName = ""; } if (DadName.Length > 0 && ProcName.Length > 0) { string[] urlProcElements = ProcName.Split('.'); if (urlProcElements.Length == 3) { // schema, package and procedure specified OraSchema = urlProcElements[0]; OraPackage = urlProcElements[1]; OraProc = urlProcElements[2]; } else if (urlProcElements.Length == 2) { // assume package and procedure specified (although it could also be schema and procedure, but there is no way to be certain) OraSchema = ""; OraPackage = urlProcElements[0]; OraProc = urlProcElements[1]; } else { // just the procedure is specified OraSchema = ""; OraPackage = ""; OraProc = ProcName; } logger.Debug("Parsed module = " + ModuleName + ", dad = " + DadName + ", proc = " + ProcName); } }