/// <summary>
        /// Fetches the index of the recordset.
        /// </summary>
        /// <param name="part">The part.</param>
        /// <param name="entry">The entry.</param>
        /// <param name="isFramed"></param>
        /// <returns></returns>
        public int FetchRecordsetIndex(IIntellisenseResult part, IBinaryDataListEntry entry, bool isFramed)
        {
            // figure out the index type ;)
            enRecordsetIndexType idxType = DataListUtil.GetRecordsetIndexTypeRaw(part.Option.RecordsetIndex);

            int result = 1;

            if(idxType == enRecordsetIndexType.Numeric)
            {
                // fix index insert ;)
                if(!Int32.TryParse(part.Option.RecordsetIndex, out result))
                {
                    result = -1;
                }
            }
            else if(idxType == enRecordsetIndexType.Blank)
            {
                // append mode
                if(!_recordsetAppendIndexs.TryGetValue(part.Option.Recordset, out result))
                {
                    if(entry != null)
                    {
                        result = entry.FetchAppendRecordsetIndex();
                        _recordsetAppendIndexs[part.Option.Recordset] = result; // stash in cache
                    }
                }

                // Assign behavior ;)
                if(!isFramed)
                {
                    // duplicate match ;)
                    if(nonFramedTokens.Contains(part))
                    {
                        // reset the framing ;)
                        nonFramedTokens.Clear();
                        nonFramedTokens.Add(part);

                        // inc this index ;)
                        _recordsetAppendIndexs[part.Option.Recordset]++;
                        result++;
                    }
                    else
                    {
                        // current append indexes are alright ;)
                        nonFramedTokens.Add(part);
                    }
                }
            }
            else if(idxType == enRecordsetIndexType.Star)
            {
                // overwrite mode from idx 1
                if(!_recordsetOverwriteIndexs.TryGetValue(part.Option.Recordset, out result))
                {
                    result = 1;
                    _recordsetOverwriteIndexs[part.Option.Recordset] = result;
                }
            }

            return result;
        }
        private int FetchNumberOfExecutions(IIntellisenseResult part, IBinaryDataList bdl)
        {
            int result = 1;

            if (!part.Option.IsScalar)
            {
                // process the recordset...
                enRecordsetIndexType type = DataListUtil.GetRecordsetIndexType(part.Option.DisplayValue);
                if (type == enRecordsetIndexType.Star)
                {
                    // Fetch entry and find the last index
                    IBinaryDataListEntry entry;
                    string error;
                    if (bdl.TryGetEntry(part.Option.Recordset, out entry, out error))
                    {
                        result = entry.FetchLastRecordsetIndex();
                    }
                }
                else if (type == enRecordsetIndexType.Numeric)
                {
                    // Fetch index out
                    Int32.TryParse(part.Option.RecordsetIndex, out result);
                }
            }

            return(result);
        }
        /// <summary>
        /// Fetches the index of the recordset.
        /// </summary>
        /// <param name="part">The part.</param>
        /// <param name="entry">The entry.</param>
        /// <param name="isFramed"></param>
        /// <returns></returns>
        public int FetchRecordsetIndex(IIntellisenseResult part, IBinaryDataListEntry entry, bool isFramed)
        {
            // figure out the index type ;)
            enRecordsetIndexType idxType = DataListUtil.GetRecordsetIndexTypeRaw(part.Option.RecordsetIndex);

            int result = 1;

            if (idxType == enRecordsetIndexType.Numeric)
            {
                // fix index insert ;)
                if (!Int32.TryParse(part.Option.RecordsetIndex, out result))
                {
                    result = -1;
                }
            }
            else if (idxType == enRecordsetIndexType.Blank)
            {
                // append mode
                if (!_recordsetAppendIndexs.TryGetValue(part.Option.Recordset, out result))
                {
                    if (entry != null)
                    {
                        result = entry.FetchAppendRecordsetIndex();
                        _recordsetAppendIndexs[part.Option.Recordset] = result; // stash in cache
                    }
                }

                // Assign behavior ;)
                if (!isFramed)
                {
                    // duplicate match ;)
                    if (nonFramedTokens.Contains(part))
                    {
                        // reset the framing ;)
                        nonFramedTokens.Clear();
                        nonFramedTokens.Add(part);

                        // inc this index ;)
                        _recordsetAppendIndexs[part.Option.Recordset]++;
                        result++;
                    }
                    else
                    {
                        // current append indexes are alright ;)
                        nonFramedTokens.Add(part);
                    }
                }
            }
            else if (idxType == enRecordsetIndexType.Star)
            {
                // overwrite mode from idx 1
                if (!_recordsetOverwriteIndexs.TryGetValue(part.Option.Recordset, out result))
                {
                    result = 1;
                    _recordsetOverwriteIndexs[part.Option.Recordset] = result;
                }
            }

            return(result);
        }
        /// <summary>
        /// Adds the bound item.
        /// </summary>
        /// <param name="token">The token.</param>
        /// <param name="binding">The binding.</param>
        public void AddBoundItem(IIntellisenseResult token, IBinaryDataListEntry binding)
        {
            if (binding == null)
            {
                Errors.AddError("Could not evaluate { " + token.Option.DisplayValue + " }");

                return;
            }

            _internalKeyMap[token] = binding;
        }
        public DateTimeIntellisenseProvider()
        {
            Optional = false;
            IntellisenseProviderType = IntellisenseProviderType.NonDefault;
            IDateTimeParser dateTimeParser = DateTimeConverterFactory.CreateParser();

            _intellisenseResults = dateTimeParser.DateTimeFormatParts.Select(p =>
            {
                IIntellisenseResult intellisenseResult = IntellisenseFactory.CreateDateTimeResult(IntellisenseFactory.CreateDateTimePart(p.Value, p.Description));
                return(intellisenseResult);
            }).OrderBy(p => p.Option.DisplayValue).ToList();
        }
Beispiel #6
0
        public void ProcessResults(IList <IIntellisenseResult> realResults, IIntellisenseResult intellisenseResult)
        {
            var addToFinal = true;

            realResults
            .ToList()
            .ForEach(rr =>
            {
                if (rr.Option.DisplayValue == intellisenseResult.Option.DisplayValue)
                {
                    addToFinal = false;
                }
            });

            if (addToFinal)
            {
                realResults.Add(intellisenseResult);
            }
        }
Beispiel #7
0
 static void ProcessResults(IList <IIntellisenseResult> realResults, IIntellisenseResult r) => _parserHelper.ProcessResults(realResults, r);
        // 2 seconds for 10k entries with 75 columns ;)
        public void FlushIterations(PayloadIterationFrame <string> scopedFrame, bool isFramed, bool isTerminalFlush)
        {
            string error;

            Dev2TokenConverter tc = new Dev2TokenConverter();

            bool amendedData = false;

            // We do not care about data language in these cases, skip all the junk and get it done son ;)

            while (scopedFrame.HasData())
            {
                DataListPayloadFrameTO <string> tmp = scopedFrame.FetchNextFrameItem();
                string exp = tmp.Expression; //.Replace("(*)", "()"); // force conversion ;)
                string val = tmp.Value;

                // correction, we now need to support recursive evaluation ;(
                if (!DataListUtil.IsRootVariable(exp))
                {
                    ErrorResultTO errors;
                    var           tmpToken = _c.Evaluate(_bdl.UID, enActionType.User, exp, true, out errors);
                    if (errors.HasErrors())
                    {
                        throw new Exception(errors.MakeDisplayReady());
                    }
                    var scalar = tmpToken.FetchScalar();
                    if (scalar == null)
                    {
                        // ReSharper disable RedundantAssignment
                        exp = null;
                        // ReSharper restore RedundantAssignment
                    }
                    exp = tmpToken.FetchScalar().TheValue;
                }

                IIntellisenseResult token = tc.ParseTokenForMatch(exp, _bdl.FetchIntellisenseParts());

                if (token != null)
                {
                    // Get rs and field
                    string rs    = token.Option.Recordset;
                    string field = token.Option.Field;
                    string idx   = token.Option.RecordsetIndex;

                    if (rs != _lastRs && !string.IsNullOrEmpty(rs))
                    {
                        // Flush any existing row data for a different recordset ;)
                        if (_rowData != null)
                        {
                            if (!token.Option.IsScalar)
                            {
                                DumpColAtATime();
                            }

                            amendedData = false;
                        }

                        _bdl.TryGetEntry(rs, out _entry, out error);
                        if (error != string.Empty || _entry == null)
                        {
                            throw new Exception("Upsert Exception : " + error);
                        }

                        // stash last rs
                        _lastRs = rs;

                        // build new row data
                        int cnt = _entry.Columns.Count;
                        _rowData = new List <IBinaryDataListItem>(cnt);
                        InitRowBuffer(cnt);
                    }


                    if (!token.Option.IsScalar)
                    {
                        // set commit flag ;)
                        amendedData = true;

                        int colIdx = _entry.InternalFetchColumnIndex(field);

                        IBinaryDataListItem itm = _rowData[colIdx];

                        enRecordsetIndexType idxType = DataListUtil.GetRecordsetIndexTypeRaw(idx);

                        int tmpIdx = _dris.FetchRecordsetIndex(token, _entry, isFramed);

                        if (tmpIdx != _upsertIdx)
                        {
                            // silly users making algorithms slow ;(
                            // we need to dump data at this point... 1 fliping column at a time
                            DumpColAtATime();
                        }

                        _upsertIdx = tmpIdx;

                        if (_upsertIdx == 0)
                        {
                            throw new Exception("Invalid recordset index of 0");
                        }

                        // if numeric fetch the index
                        if (idxType == enRecordsetIndexType.Numeric)
                        {
                            Int32.TryParse(idx, out _upsertIdx);
                        }


                        itm.UpdateIndex(_upsertIdx);
                        itm.UpdateField(field);
                        itm.UpdateValue(val);

                        if (_rowData == null)
                        {
                            throw new Exception("Invalid Bulk Load Data");
                        }

                        _rowData[colIdx] = itm;
                    }
                    else
                    {
                        IBinaryDataListItem itm = DataListConstants.baseItem.Clone();

                        // else scalar and we need to get the entry ;(
                        IBinaryDataListEntry scalarEntry;
                        _bdl.TryGetEntry(field, out scalarEntry, out error);
                        itm.UpdateField(field);
                        itm.UpdateValue(val);

                        scalarEntry.TryPutScalar(itm, out error);

                        if (error != string.Empty)
                        {
                            throw new Exception(error);
                        }
                    }
                }
                else
                {
                    throw new Exception("Null token for [ " + exp + " ]");
                }
            }

            // flush the rowData out ;)
            if (_entry != null && _entry.IsRecordset && amendedData)
            {
                _entry.TryPutRecordRowAt(_rowData, _upsertIdx, out error);
                if (error != string.Empty)
                {
                    throw new Exception(error);
                }

                _dris.MoveIndexesToNextPosition();
            }

            if (isTerminalFlush)
            {
                ErrorResultTO errors;
                _c.PushBinaryDataListInServerScope(_liveFlushingLocation, _bdl, out errors);
            }

            // clear out the buffer
            ClearRowBuffer();
        }
        /// <summary>
        /// Adds the bound item.
        /// </summary>
        /// <param name="token">The token.</param>
        /// <param name="binding">The binding.</param>
        public void AddBoundItem(IIntellisenseResult token, IBinaryDataListEntry binding)
        {
            if(binding == null)
            {
                Errors.AddError("Could not evaluate { " + token.Option.DisplayValue + " }");

                return;
            }

            _internalKeyMap[token] = binding;
        }