private bool ProcessUSCTag(InternalBookmarkItem ibmItem, DSIconType dataTagType, string itemName, ref GenOsqlParamInfo paramInfo, ref Dictionary <string, bool> dataTagChecker) { if (dataTagType == DSIconType.USC) { GetTableIndexForUSC(ibmItem, ref paramInfo); USCItem usc = paramInfo.UscItems[itemName]; string orderFieldName = usc.BaseOnField; if (!string.IsNullOrWhiteSpace(orderFieldName) && !dataTagChecker.ContainsKey(orderFieldName)) { InternalBookmarkItem exist = (from c in paramInfo.IbmDomain.InternalBookmarkItems where (c.TableIndex == usc.TableIndex) && (string.Equals(c.ItemType, DSIconType.Field.ToString())) select c).FirstOrDefault(); //If existed one data field in selected tag, shouldnot include data field in udf if (exist == null || string.IsNullOrEmpty(exist.BizName)) { InternalBookmarkItem bm = AddUdfFields(orderFieldName, ref paramInfo); dataTagChecker.Add(BaseMarkupUtilities.GetOriginalBizName(bm.Key, bm.BizName), true); } else { dataTagChecker.Add(itemName, true); paramInfo.AddDataTags(ibmItem, true); } } return(true); } return(false); }
/// <summary> /// This is used for Markup /// </summary> /// <param name="businessName"></param> /// <param name="dataType"></param> /// <param name="type"></param> public USCItem(string businessName, string sqlExpression, SQLDBType dataType, DSIconType type) { BusinessName = businessName; SQLExpression = sqlExpression; DataType = dataType; Type = type; IsValid = true; }
private void GenSelectClauseForField(InternalBookmarkItem bmItem, ref GenOsqlParamInfo paramInfo) { string itemName = BaseMarkupUtilities.GetOriginalBizName(bmItem.Key, bmItem.BizName); DSTreeView item = paramInfo.DomainInfo.GetField(itemName); DSIconType type = (DSIconType)Enum.Parse(typeof(DSIconType), bmItem.ItemType); double i = Math.Log((double)bmItem.TableIndex, (double)2); DSOnClause table = paramInfo.DomainInfo.DSDomainData.OnClauses.Items[bmItem.TableIndex]; string tableName = table.Alias; paramInfo.PutSelectedTable(tableName, false); paramInfo.SelectedTableIndexes.Add(item.TableIndex); UpdateSelectedColumns(ref paramInfo, tableName, itemName); InternalBookmarkItem existedItem = paramInfo.DataTagFields.FirstOrDefault(a => a.TableIndex == item.TableIndex && a.DSIconType == DSIconType.Field); bool isImageTrunc = bmItem.IsTruncImage(); if (isImageTrunc && existedItem != null && existedItem.BizName == bmItem.BizName && !paramInfo.TablesHasField.Contains(item.TableIndex)) { // this table has only image that is chunked then we need to add one default column GenSelectClauseItem(DSIconType.Field, item.TechName, string.Empty, Guid.NewGuid().ToString(), false, true, ref paramInfo); paramInfo.TablesHasField.Add(item.TableIndex); paramInfo.HasImage = true; } GenSelectClauseItem(type, bmItem.TechName, item.JavaClause, itemName, bmItem.IsTruncImage(), true, ref paramInfo); if (!string.IsNullOrEmpty(item.RenderXYOrder)) { List <string> renderParam = item.RenderXYOrder.Split(';').ToList <string>(); for (int j = 0; j < renderParam.Count; j++) { AddItemToListJParameters((renderParam[j] == "1") ? FrameworkConstants.RenderArgumentX : FrameworkConstants.RenderArgumentY, ref paramInfo, OracleQueryConstants.DicSelectClauseParamName); } } #region Build Extra field if (existedItem == null && !string.IsNullOrEmpty(item.OrginalField) && !paramInfo.TablesHasField.Contains(item.TableIndex)) { GenSelectClauseItem(DSIconType.Field, item.OrginalField, string.Empty, Guid.NewGuid().ToString(), false, true, ref paramInfo); paramInfo.TablesHasField.Add(item.TableIndex); return; } #endregion }
private bool ProcessSelectTag(InternalBookmarkItem ibmItem, DSIconType dataTagType, string itemName, ref GenOsqlParamInfo paramInfo, ref Dictionary <string, bool> dataTagChecker) { if ((ibmItem.TableIndex >= 0 && dataTagType != DSIconType.USC) || (dataTagType == DSIconType.SystemInfo) || (dataTagType == DSIconType.Condition) || (dataTagType == DSIconType.RenderXY)) { if (dataTagType == DSIconType.SystemInfo || (dataTagType == DSIconType.Condition) || (dataTagType == DSIconType.RenderXY)) { ibmItem.TableIndex = Math.Max(0, ibmItem.TableIndex); } dataTagChecker.Add(itemName, true); bool isUdf = dataTagType == DSIconType.UDF || dataTagType == DSIconType.Condition; paramInfo.AddDataTags(ibmItem, isUdf); return(true); } return(false); }
/// <summary> /// get list of data tag fields, data tag others and renderxy /// </summary> /// <param name="paramInfo"></param> protected void AnalyzeDataTag(ref GenOsqlParamInfo paramInfo) { paramInfo.RenderXY = 0; paramInfo.UpdateUSCItemsDictionary(); int itemIndex = 0; Dictionary <string, bool> dataTagChecker = new Dictionary <string, bool>(); while (itemIndex < paramInfo.IbmDomain.InternalBookmarkItems.Count) { InternalBookmarkItem ibmItem = paramInfo.IbmDomain.InternalBookmarkItems[itemIndex]; DSIconType type = ibmItem.DSIconType; string itemName = BaseMarkupUtilities.GetOriginalBizName(ibmItem.Key, ibmItem.BizName); DSTreeView dsObject = paramInfo.DomainInfo.GetField(itemName); if (dsObject != null) { paramInfo.RenderXY = paramInfo.RenderXY | CheckRenderXY(dsObject.RenderXYOrder); } else { paramInfo.RenderXY = paramInfo.RenderXY | CheckRenderXY("0"); } itemIndex++; if (ProcessEndForeachIfTag(ref paramInfo, ibmItem.Key, itemName, dataTagChecker)) { continue; } if (ProcessStartForeachTag(ibmItem.Key, ibmItem.BizName, ref paramInfo, ref dataTagChecker)) { continue; } if (ProcessUSCTag(ibmItem, type, itemName, ref paramInfo, ref dataTagChecker)) { continue; } ProcessSelectTag(ibmItem, type, itemName, ref paramInfo, ref dataTagChecker); } }
private void GenSelectClauseForFields(ref GenOsqlParamInfo paramInfo) { paramInfo.HasImage = false; paramInfo.HasField = false; if (paramInfo.DataTagFields != null && paramInfo.DataTagFields.Count > 0) { paramInfo.OrderDataTagFieldsByTableIndex(); List <List <InternalBookmarkItem> > paths = GetPaths(ref paramInfo, paramInfo.DataTagFields, paramInfo.DomainInfo.DSDomainData); foreach (List <InternalBookmarkItem> path in paths) { if (path.Count <= 0) { continue; } paramInfo.OsqlStringBuilder = new OsqlStringBuilder(); paramInfo.OsqlStringBuilder.AppendLine(OracleQueryConstants.SelectClause); paramInfo.DSRelationRow = null; // add paramater for watermark at start of query for osql & jsql paramInfo.OsqlStringBuilder.Osql.AppendLine(string.Format(OracleQueryConstants.SQLSystemInfo, ProntoDoc.Framework.CoreObject.FrameworkConstants.PdwWatermark, ProntoDoc.Framework.CoreObject.FrameworkConstants.PdwWatermark) + OracleQueryConstants.SQLComma); paramInfo.OsqlStringBuilder.JOsql.AppendLine(string.Format(OracleQueryConstants.JSQLSystemInfo, ProntoDoc.Framework.CoreObject.FrameworkConstants.PdwWatermark) + OracleQueryConstants.SQLComma); paramInfo.OsqlStringBuilder.SelectedColumns = string.Empty; paramInfo.CurrentTableName = string.Empty; paramInfo.PutSelectedTable(string.Empty, true); paramInfo.SelectedTableIndexes = new List <int>(); foreach (InternalBookmarkItem item in path) { DSIconType type = item.DSIconType; if (type == DSIconType.Field) { paramInfo.HasField = true; } if (type == DSIconType.USC) { string sqlUSC = GenSelectClauseForUSC(item, ref paramInfo); string itemBizName = BaseMarkupUtilities.GetOriginalBizName(item.Key, item.BizName); GenSelectClauseItem(type, sqlUSC, string.Empty, itemBizName, false, true, ref paramInfo); string tableName = paramInfo.SelectedTables[0][0]; UpdateSelectedColumns(ref paramInfo, tableName, itemBizName); } else { if (item.Relation != null) { if (paramInfo.DSRelationRow == null) { paramInfo.DSRelationRow = item.Relation.Clone(); } else { paramInfo.DSRelationRow.OrRow(item.Relation); } } GenSelectClauseForField(item, ref paramInfo); } if (item != null && item.DataType != null && (item.DataType.Name == SQLTypeName.BINARY || item.DataType.Name == SQLTypeName.VARBINARY)) { paramInfo.HasImage = true; } } UpdateOsqlXmlItem(ref paramInfo); } } }
private void GenSelectClauseItem(DSIconType type, string techName, string javaName, string name, bool isImage, bool isField, ref GenOsqlParamInfo paramInfo) { name = NormalizeBizName(name); switch (type) { case DSIconType.UDF: { paramInfo.OsqlStringBuilder.Osql.AppendLine(string.Format(OracleQueryConstants.SQLUDFFormat, techName, name) + OracleQueryConstants.SQLComma); paramInfo.OsqlStringBuilder.JOsql.AppendLine(string.Format(OracleQueryConstants.SQLUDFFormat, javaName, name) + OracleQueryConstants.SQLComma); } break; case DSIconType.Field: { string select = string.Format(OracleQueryConstants.SQLFieldFormat, isImage ? string.Format(OracleQueryConstants.UdfTruncImage, techName) : techName, name) + OracleQueryConstants.SQLComma; paramInfo.OsqlStringBuilder.Osql.AppendLine(select); select = string.Format(OracleQueryConstants.SQLFieldFormat, isImage ? string.Format(OracleQueryConstants.UdfTruncImage, javaName) : javaName, name) + OracleQueryConstants.SQLComma; paramInfo.OsqlStringBuilder.JOsql.AppendLine(select); } break; case DSIconType.Condition: case DSIconType.USC: if (!string.IsNullOrEmpty(techName)) { string select = string.Format(OracleQueryConstants.SQLConditionFormat, techName, name) + OracleQueryConstants.SQLComma; paramInfo.OsqlStringBuilder.AppendLine(select); } break; case DSIconType.SystemInfo: case DSIconType.RenderXY: if (string.Compare(techName, ProntoDoc.Framework.CoreObject.FrameworkConstants.PluginSystemInfo.GeneratedTime) == 0) { string select = string.Format(OracleQueryConstants.SQLGeneratedTime, name) + OracleQueryConstants.SQLComma; paramInfo.OsqlStringBuilder.AppendLine(select); } else { AddItemToListJParameters(techName, ref paramInfo, OracleQueryConstants.DicSelectClauseParamName); string norTechName = techName.Replace(" ", ""); string select; string jSelect; if (!paramInfo.IsNeedInKeyword) { select = string.Format(OracleQueryConstants.SQLSystemInfo, norTechName, name) + OracleQueryConstants.SQLComma; jSelect = string.Format(OracleQueryConstants.JSQLSystemInfo, name) + OracleQueryConstants.SQLComma; } else { select = string.Format(OracleQueryConstants.SQLSystemInfoWithIn, norTechName, name) + OracleQueryConstants.SQLComma; jSelect = string.Format(OracleQueryConstants.JSQLSystemInfoWithIn, name) + OracleQueryConstants.SQLComma; } paramInfo.OsqlStringBuilder.Osql.AppendLine(select); paramInfo.OsqlStringBuilder.JOsql.AppendLine(jSelect); } AddItemToSystemParams(techName, ref paramInfo); break; } }