Esempio n. 1
0
        protected string GenSelectClauseForUSC(InternalBookmarkItem ibmItem, ref GenOsqlParamInfo paramInfo)
        {
            //1.Find USC bookmark in the list Conditions to get actual USC.
            //2.Build SQl
            string sqlClause = string.Empty;
            string itemName  = BaseMarkupUtilities.GetOriginalBizName(ibmItem.Key, ibmItem.BizName);

            if (paramInfo.UscItems == null || paramInfo.UscItems.Count <= 0 || ibmItem.Key.EndsWith(BaseProntoMarkup.KeyEndIf))
            {
                return(sqlClause);
            }

            USCItem uscItem = null;

            if (paramInfo.UscItems.Keys.Contains(itemName))
            {
                uscItem = paramInfo.UscItems[itemName];
            }

            //
            Dictionary <string, DSTreeView> lowerFields = new Dictionary <string, DSTreeView>();

            foreach (string key in paramInfo.DomainInfo.Fields.Keys)
            {
                lowerFields.Add(key.ToLower(), paramInfo.DomainInfo.Fields[key]);
            }

            //Validate and Build SQl
            if (uscItem != null)
            {
                List <Token>       lstTokens       = new List <Token>();
                string             error           = string.Empty;
                ExpressionProvider expressProvider = new ExpressionProvider();
                expressProvider.DoTokenize(uscItem.SQLExpression, ref lstTokens, ref error);

                foreach (Token token in lstTokens)
                {
                    string key = string.Empty;
                    if (token.Name.Contains("[") && token.Name.Contains("]"))
                    {
                        key = token.Name.Substring(1, token.Name.Length - 2).ToLower();
                        if (lowerFields.ContainsKey(key))
                        {
                            token.Name = lowerFields[key].TechName;

                            if (paramInfo.DSRelationRow == null)
                            {
                                paramInfo.DSRelationRow = lowerFields[key].Relation.Clone();
                            }
                            else
                            {
                                paramInfo.DSRelationRow.OrRow(lowerFields[key].Relation);
                            }
                        }
                    }
                    sqlClause += token.Name + " ";
                }
            }
            return(sqlClause.Trim());
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        //private void GenFromClause(ref GenOsqlParamInfo paramInfo)
        //{
        //    paramInfo.FormClause = paramInfo.DomainInfo.DSDomainData.GetFromClause(paramInfo.DSRelationRow, AppDbTypes.Oracle);
        //}
        #endregion

        #region gen for xml clause
        private void GenForXmlClause(ref GenOsqlParamInfo paramInfo)
        {
            paramInfo.OsqlXmlItem       = new OsqlXmlItem();
            paramInfo.OsqlXmlItem.Paths = new List <OsqlXmlItemPath>();
            foreach (OsqlStringBuilder item in paramInfo.OsqlStringBuilders)
            {
                OsqlXmlItemPath osqlXmlItemPath = new OsqlXmlItemPath();
                osqlXmlItemPath.Osql = item.Osql.ToString().TrimEnd();
                osqlXmlItemPath.JSql = item.JOsql.ToString().TrimEnd();
                if (!string.IsNullOrWhiteSpace(item.SelectedColumns))
                {
                    if (item.SelectedColumns.StartsWith(","))
                    {
                        osqlXmlItemPath.SelectedColumns = item.SelectedColumns.Remove(0, 1);
                    }
                    else
                    {
                        osqlXmlItemPath.SelectedColumns = item.SelectedColumns;
                    }
                }

                paramInfo.OsqlXmlItem.Paths.Add(osqlXmlItemPath);
            }
            paramInfo.OsqlXmlItem.Index            = paramInfo.IndexOfDomain;
            paramInfo.OsqlXmlItem.DomainName       = paramInfo.DomainInfo.DSDomainData.Name;
            paramInfo.OsqlXmlItem.EncodeDomainName = BaseMarkupUtilities.XmlEncode(paramInfo.DomainInfo.DSDomainData.Name);
        }
Esempio n. 4
0
        private bool ProcessStartForeachTag(string ibmItemKey, string ibmItemBizName,
                                            ref GenOsqlParamInfo paramInfo, ref Dictionary <string, bool> dataTagChecker)
        {
            if (ibmItemKey.Contains(BaseProntoMarkup.KeyStartForeach)) // update for add sort item in for-each
            {
                Dictionary <string, OrderByType> sorteds = BaseMarkupUtilities.GetOldOrderBy(ibmItemBizName, false);
                if (sorteds.Count > 0) // has sort in for-each
                {
                    foreach (string orderBizName in sorteds.Keys)
                    {
                        string sortBizName = paramInfo.DomainInfo.GetUdfSortedBizName(orderBizName);
                        if (sortBizName != orderBizName) // has order by bizname
                        {
                            if (dataTagChecker.ContainsKey(sortBizName))
                            {
                                continue;
                            }

                            InternalBookmarkItem bm = AddUdfFields(sortBizName, ref paramInfo);
                            dataTagChecker.Add(BaseMarkupUtilities.GetOriginalBizName(bm.Key, bm.BizName), true);
                        }
                    }
                }

                return(true);
            }

            return(false);
        }
Esempio n. 5
0
        public void PutRootSelectedTable(string tableAlias)
        {
            if (SelectedTables == null)
            {
                SelectedTables = new List <List <string> >();
            }

            for (int index = 0; index < SelectedTables.Count; index++)
            {
                List <string> path = SelectedTables[index];
                if (path == null)
                {
                    path = new List <string>();
                    path.Add(tableAlias);
                }
                else
                {
                    if (!BaseMarkupUtilities.IsExistOnList(path, tableAlias))
                    {
                        path.Insert(0, tableAlias);
                    }
                }
                SelectedTables[index] = path;
            }
        }
Esempio n. 6
0
        //private void GenFromClause(ref GenOsqlParamInfo paramInfo)
        //{
        //    paramInfo.FormClause = paramInfo.DomainInfo.DSDomainData.GetFromClause(paramInfo.DSRelationRow);
        //}
        #endregion

        #region gen for xml clause
        private void GenForXmlClause(ref GenOsqlParamInfo paramInfo)
        {
            //For XML Auto
            string forXml        = string.Empty;
            string domainEncoded = BaseMarkupUtilities.XmlEncode(paramInfo.IbmDomain.DomainName);

            if (paramInfo.HasField)
            {
                if (!paramInfo.IsNeedInKeyword)
                {
                    forXml = string.Format(Sql08QueryConstants.XmlAuto.ForXMLAuto, domainEncoded);
                }
                else
                {
                    forXml = string.Format(Sql08QueryConstants.XmlAuto.ForXMLAutoIn, domainEncoded);
                }
            }
            else
            {
                string rootTable = paramInfo.SelectedTables[0][0];
                if (!paramInfo.IsNeedInKeyword)
                {
                    forXml = string.Format(Sql08QueryConstants.XmlAuto.ForXMLAutoIn, rootTable, domainEncoded);
                }
                else
                {
                    forXml = string.Format(Sql08QueryConstants.XmlAuto.ForXMLRawIn, rootTable, domainEncoded);
                }
            }

            paramInfo.OsqlXmlItem       = new OsqlXmlItem();
            paramInfo.OsqlXmlItem.Paths = new List <OsqlXmlItemPath>();
            foreach (OsqlStringBuilder item in paramInfo.OsqlStringBuilders)
            {
                item.AppendLine(forXml);

                //Prepare for return
                if (paramInfo.HasImage)
                {
                    item.Append(Sql08QueryConstants.SQLBase64);
                }

                OsqlXmlItemPath osqlXmlItemPath = new OsqlXmlItemPath();
                osqlXmlItemPath.Osql = item.Osql.ToString().TrimEnd();
                osqlXmlItemPath.JSql = item.JOsql.ToString().TrimEnd();

                if (paramInfo.IsNeedInKeyword)
                {
                    osqlXmlItemPath.Osql = string.Format(Sql08QueryConstants.SQLWithIn, osqlXmlItemPath.Osql);
                    osqlXmlItemPath.JSql = string.Format(Sql08QueryConstants.SQLWithIn, osqlXmlItemPath.JSql);
                }
                paramInfo.OsqlXmlItem.Paths.Add(osqlXmlItemPath);
            }
            paramInfo.OsqlXmlItem.Index            = paramInfo.IndexOfDomain;
            paramInfo.OsqlXmlItem.DomainName       = paramInfo.DomainInfo.DSDomainData.Name;
            paramInfo.OsqlXmlItem.EncodeDomainName = BaseMarkupUtilities.XmlEncode(paramInfo.DomainInfo.DSDomainData.Name);
        }
Esempio n. 7
0
        public void PutSelectedTable(string tableAlias, bool createNewPath)
        {
            if (SelectedTables == null)
            {
                SelectedTables = new List <List <string> >();
            }

            if (SelectedTables.Count == 0)
            {
                List <string> path = new List <string>();
                if (!string.IsNullOrWhiteSpace(tableAlias))
                {
                    path.Add(tableAlias);
                }
                SelectedTables.Add(path);
            }
            else
            {
                if (createNewPath)
                {
                    List <string> path = new List <string>();
                    if (!string.IsNullOrWhiteSpace(tableAlias))
                    {
                        path.Add(tableAlias);
                    }
                    SelectedTables.Add(path);
                }
                else
                {
                    int           index = SelectedTables.Count - 1;
                    List <string> path  = SelectedTables[index];
                    if (path == null)
                    {
                        path = new List <string>();
                        if (!string.IsNullOrWhiteSpace(tableAlias))
                        {
                            path.Add(tableAlias);
                        }
                    }
                    else
                    {
                        if (!string.IsNullOrWhiteSpace(tableAlias) && !BaseMarkupUtilities.IsExistOnList(path, tableAlias))
                        {
                            // path.Insert(0, tableAlias);
                            path.Add(tableAlias);
                        }
                    }
                    SelectedTables[index] = path;
                }
            }
        }
Esempio n. 8
0
        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
        }
Esempio n. 9
0
        /// <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);
            }
        }
Esempio n. 10
0
        private int GetTableIndexForUSC(InternalBookmarkItem ibmItem, ref GenOsqlParamInfo paramInfo)
        {
            if (paramInfo.UscItems == null || paramInfo.UscItems.Count <= 0)
            {
                return(-1);
            }
            string  itemName = BaseMarkupUtilities.GetOriginalBizName(ibmItem.Key, ibmItem.BizName);
            USCItem item     = paramInfo.UscItems[itemName];
            int     maxIndex = -1;

            if (item.Fields.Count > 0)
            {
                foreach (USCItem subField in item.Fields)
                {
                    if (paramInfo.DomainInfo.Fields.Keys.Contains(subField.BusinessName))
                    {
                        if (maxIndex < paramInfo.DomainInfo.Fields[subField.BusinessName].TableIndex)
                        {
                            maxIndex         = paramInfo.DomainInfo.Fields[subField.BusinessName].TableIndex;
                            item.BaseOnField = string.IsNullOrWhiteSpace(paramInfo.DomainInfo.Fields[subField.BusinessName].OrginalField) ?
                                               paramInfo.DomainInfo.Fields[subField.BusinessName].Text : paramInfo.DomainInfo.Fields[subField.BusinessName].OrginalField;
                        }
                    }
                }
            }
            ibmItem.TableIndex = maxIndex;
            item.TableIndex    = maxIndex;

            //Update to Relation
            DSOnClause table     = paramInfo.DomainInfo.DSDomainData.OnClauses.Items[maxIndex];
            string     tableName = table.Alias;

            if (!paramInfo.DomainInfo.Relations.MapInfos.ContainsKey(itemName))
            {
                paramInfo.DomainInfo.Relations.MapInfos.Add(itemName, new Mapping(itemName, tableName, itemName));
            }
            else
            {
                paramInfo.DomainInfo.Relations.MapInfos[itemName].TableName = tableName;
            }

            return(maxIndex);
        }
Esempio n. 11
0
        private string ImportPdeChart(Word.Document wDoc, string chartName, string chartContent)
        {
            string chartPath = AssetManager.FileAdapter.GenRandomFilePath(ChartExtension);
            string bmValue   = MarkupUtilities.GenTextXslTag(chartName, XsltType.Select, true);
            string bmName    = BaseMarkupUtilities.XmlEncode(chartName);

            // create temporary image
            bmName = string.Format("{0}{1}{2}", MarkupConstant.MarkupPdeTag, bmName, MarkupConstant.MarkupPdeChart);
            ProntoDoc.Framework.Utils.FileHelper.FileFromBase64(chartContent, chartPath);

            // delete old bm
            Word.Bookmark oldBm = null;
            foreach (Word.Bookmark bookmark in wDoc.Bookmarks)
            {
                if (string.Equals(bmName, bookmark.Name, StringComparison.OrdinalIgnoreCase))
                {
                    oldBm = bookmark;
                    break;
                }
            }
            if (oldBm != null)
            {
                oldBm.Delete();
            }

            // add image into word
            wDoc.Application.Selection.TypeText(" ");
            Word.InlineShape inlineShape = wDoc.Application.Selection.InlineShapes.AddPicture(chartPath, false, true);
            inlineShape.AlternativeText = MarkupUtilities.CreateAlternativeText(bmName, bmValue);

            // add bookmark
            wDoc.Application.Selection.MoveLeft(Word.WdUnits.wdCharacter, 1);
            wDoc.Application.Selection.MoveRight(Word.WdUnits.wdCharacter, 1, Word.WdMovementType.wdExtend);
            wDoc.Bookmarks.Add(bmName, wDoc.Application.Selection.Range);
            wDoc.Application.Selection.MoveRight(Word.WdUnits.wdCharacter);

            // delete temporary file
            System.IO.File.Delete(chartPath);

            return(bmName);
        }
Esempio n. 12
0
        private List <string> GetPdeSelectedTables(string key, bool includeKey = true)
        {
            List <string>  paths      = new List <string>();
            PdeDataTagInfo pdeTagInfo = _ibm.GetPdeDataTagInfo(key);

            // root node
            paths.Add(ProntoDoc.Framework.CoreObject.FrameworkConstants.PdeExportedRootName);

            // stn node
            paths.Add(pdeTagInfo.STN);

            // kind of data
            switch (pdeTagInfo.MapType)
            {
            case MapType.Table:
                paths.Add(MarkupConstant.PdeExportTable);
                paths.Add(pdeTagInfo.ParentName);
                break;

            case MapType.SingleCell:
                paths.Add(MarkupConstant.PdeExportField);
                break;

            case MapType.Chart:
                paths.Add(MarkupConstant.PdeExportChart);
                break;

            default:
                break;
            }

            // its path
            if (includeKey)
            {
                paths.Add(pdeTagInfo.MapType == MapType.Chart ? BaseMarkupUtilities.XmlEncode(pdeTagInfo.ExcelName) : pdeTagInfo.ExcelName);
            }

            return(paths);
        }
Esempio n. 13
0
        /// <summary>
        /// gen key of Icon
        /// </summary>
        /// <param name="dbid"></param>
        /// <param name="customerIconID"></param>
        /// <returns></returns>
        public static string GenKey(string dbid, string customerIconID)
        {
            string key = string.Format("img{0}{1}{2}", dbid, (char)27, customerIconID);

            return(BaseMarkupUtilities.XmlEncode(key));
        }
Esempio n. 14
0
        /// <summary>
        /// separate osql to multi paths
        /// </summary>
        /// <param name="fullItems"></param>
        /// <param name="dsDomain"></param>
        /// <returns></returns>
        protected List <List <InternalBookmarkItem> > GetPaths(ref GenOsqlParamInfo paramInfo,
                                                               List <InternalBookmarkItem> fullItems, DSDomain dsDomain)
        {
            List <List <InternalBookmarkItem> > paths = new List <List <InternalBookmarkItem> >();

            #region calculate used table indexes
            Dictionary <int, List <InternalBookmarkItem> > usedTableIndexes = new Dictionary <int, List <InternalBookmarkItem> >();
            List <int> sortedTableIndexes = new List <int>();
            foreach (InternalBookmarkItem ibmItem in fullItems)
            {
                if (!usedTableIndexes.ContainsKey(ibmItem.TableIndex))
                {
                    usedTableIndexes.Add(ibmItem.TableIndex, new List <InternalBookmarkItem>());
                    sortedTableIndexes.Add(ibmItem.TableIndex);
                }

                usedTableIndexes[ibmItem.TableIndex].Add(ibmItem);
            }
            if (!usedTableIndexes.ContainsKey(0))
            {
                usedTableIndexes.Add(0, new List <InternalBookmarkItem>());
                sortedTableIndexes.Add(0);
            }
            sortedTableIndexes = sortedTableIndexes.OrderBy(c => c).ToList();
            #endregion

            #region get paths
            string whereClauseName                    = "WhereClause";
            Dictionary <int, bool> checker            = new Dictionary <int, bool>();
            List <DSRelationRow>   dsRelationRows     = dsDomain.TableRelations.Rows.Items;
            DSRelationRow          dsWhereRelationRow = dsRelationRows.FirstOrDefault(
                c => whereClauseName.Equals(c.Name, StringComparison.OrdinalIgnoreCase));
            string whereRelations = BitHelper.ToBinaryFormat(dsWhereRelationRow.Data, true);
            whereRelations = BaseMarkupUtilities.ReverseString(whereRelations);
            foreach (DSRelationRow dsRelationRow in dsRelationRows)
            {
                if (whereClauseName.Equals(dsRelationRow.Name, StringComparison.OrdinalIgnoreCase))
                {
                    paramInfo.DSWhereClauseRelationRow = dsRelationRow;
                    continue;
                }

                List <InternalBookmarkItem> path = new List <InternalBookmarkItem>();
                string relations = BitHelper.ToBinaryFormat(dsRelationRow.Data, true);
                relations = BaseMarkupUtilities.ReverseString(relations);
                bool hasTable = false;
                foreach (int tableIndex in sortedTableIndexes)
                {
                    int index = tableIndex;
                    if (relations.Length > index && relations[index] == '1')
                    {
                        path.AddRange(usedTableIndexes[tableIndex]);
                        if (!checker.ContainsKey(tableIndex))
                        {
                            hasTable = true;
                            checker.Add(tableIndex, true);
                        }
                    }
                }

                if (hasTable)
                {
                    int parentTableIndex = GetParentTableInexInJoinClause(dsWhereRelationRow, dsRelationRow);
                    if (!usedTableIndexes.ContainsKey(parentTableIndex))
                    {
                        usedTableIndexes.Add(parentTableIndex, new List <InternalBookmarkItem>());
                    }
                    InternalBookmarkItem ibmItem = usedTableIndexes[parentTableIndex].FirstOrDefault(
                        c => c.TableIndex == parentTableIndex && c.DSIconType == DSIconType.Field);
                    if (ibmItem == null)
                    {
                        DSTreeView firstField = paramInfo.DomainInfo.Fields.Values.FirstOrDefault(
                            c => c.TableIndex == parentTableIndex && c.Type == DSIconType.Field);
                        if (firstField != null)
                        {
                            ibmItem = new InternalBookmarkItem()
                            {
                                BizName    = firstField.Text,
                                ItemType   = "Field",
                                JavaName   = firstField.JavaClause,
                                Key        = Guid.NewGuid().ToString(),
                                OrderNo    = 1,
                                TableIndex = parentTableIndex,
                                TechName   = firstField.TechName,
                                Type       = XsltType.Select
                            };

                            usedTableIndexes[parentTableIndex].Insert(0, ibmItem);
                            path.Insert(0, ibmItem);
                        }
                    }

                    paths.Add(path);
                }
            }
            #endregion

            return(paths);
        }
Esempio n. 15
0
        protected void GenWhereClause(ref GenOsqlParamInfo paramInfo)
        {
            if (paramInfo.WhereClauses == null)
            {
                paramInfo.WhereClauses = new List <string>();
            }
            if (paramInfo.JWhereClauses == null)
            {
                paramInfo.JWhereClauses = new List <string>();
            }
            if (paramInfo.DomainInfo.DSDomainData.WhereClause.DSJoins == null ||
                paramInfo.DomainInfo.DSDomainData.WhereClause.DSJoins.Count == 0)
            {
                paramInfo.WhereClauses.Add(paramInfo.DomainInfo.DSDomainData.WhereClause.Clause);
                paramInfo.JWhereClauses.Add(paramInfo.DomainInfo.DSDomainData.WhereClause.JavaClause);
            }
            else
            {
                paramInfo.DSWhereClauseRelationRow = null;
                string whereClause  = string.Empty;
                string jWhereClause = string.Empty;
                string logicType    = string.Empty;
                bool   hasRootJoin  = false;
                foreach (DSJoin dsJoin in paramInfo.DomainInfo.DSDomainData.WhereClause.DSJoins)
                {
                    string usedTables = BitHelper.ToBinaryFormat(dsJoin.Tables.Data, true);
                    usedTables = BaseMarkupUtilities.ReverseString(usedTables);
                    bool isUseDSJoin = true;

                    #region check use or no
                    for (int index = 0; index < usedTables.Length; index++)
                    {
                        if (usedTables[index] == '1')
                        {
                            if (!paramInfo.SelectedTableIndexes.Contains(index))
                            {
                                isUseDSJoin = false;
                                break;
                            }
                        }
                    }
                    if (!isUseDSJoin)
                    {
                        continue;
                    }
                    #endregion

                    #region build where clause
                    if ("and".Equals(dsJoin.LogicType, StringComparison.OrdinalIgnoreCase) ||
                        "or".Equals(dsJoin.LogicType, StringComparison.OrdinalIgnoreCase))
                    {
                        if (!hasRootJoin)
                        {
                            whereClause  = dsJoin.LogicType + " " + dsJoin.Condition + " " + whereClause;
                            jWhereClause = dsJoin.LogicType + " " + dsJoin.JavaCondition + " " + jWhereClause;
                        }
                        else
                        {
                            whereClause  = whereClause + " " + dsJoin.LogicType + " " + dsJoin.Condition;
                            jWhereClause = jWhereClause + " " + dsJoin.LogicType + " " + dsJoin.JavaCondition;
                        }
                        logicType = dsJoin.LogicType;
                    }
                    else
                    {
                        whereClause  = dsJoin.Condition + " " + whereClause;
                        jWhereClause = dsJoin.JavaCondition + " " + jWhereClause;
                        hasRootJoin  = true;
                    }
                    #endregion

                    #region mark used for gen from clause
                    if (paramInfo.DSWhereClauseRelationRow == null)
                    {
                        paramInfo.DSWhereClauseRelationRow = dsJoin.Tables.Clone();
                    }
                    else
                    {
                        paramInfo.DSWhereClauseRelationRow.OrRow(dsJoin.Tables);
                    }
                    #endregion
                }

                if (!hasRootJoin && !string.IsNullOrWhiteSpace(logicType))
                {
                    whereClause  = whereClause.Substring(logicType.Length);
                    jWhereClause = jWhereClause.Substring(logicType.Length);
                }
                paramInfo.WhereClauses.Add(whereClause);
                paramInfo.JWhereClauses.Add(jWhereClause);
                if (paramInfo.DSWhereClauseRelationRow == null)
                {
                    DSRelationRow templateRow = paramInfo.DomainInfo.DSDomainData.WhereClause.DSJoins[0].Tables;
                    paramInfo.DSWhereClauseRelationRow = templateRow.Clone();
                    for (int index = 0; index < paramInfo.DSWhereClauseRelationRow.Data.Count; index++)
                    {
                        paramInfo.DSWhereClauseRelationRow.Data[index] = paramInfo.DSWhereClauseRelationRow.Data[index] & 0;
                    }
                    foreach (int tableIndex in paramInfo.SelectedTableIndexes)
                    {
                        int index = (tableIndex / 64) + (tableIndex % 64 != 0 ? 1 : 0);
                        index--;
                        if (index >= 0 && index < paramInfo.DSWhereClauseRelationRow.Data.Count)
                        {
                            int position = tableIndex % 64;
                            paramInfo.DSWhereClauseRelationRow.Data[index] =
                                paramInfo.DSWhereClauseRelationRow.TurnOnBit(paramInfo.DSWhereClauseRelationRow.Data[index], position);
                        }
                    }
                }
            }
        }
Esempio n. 16
0
        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);
                }
            }
        }