예제 #1
0
        /// <summary>
        /// Build Current values for Runtime cursor.
        /// </summary>
        /// <param name="runtimeCursor"></param>
        /// <param name="record"></param>
        private void BuildCurrentValues(RuntimeCursor runtimeCursor, RecordForDataViewToDataSource record)
        {
            for (int j = 0; j < destinationDataSourceDefinition.Fields.Count; j++)
            {
                DBField dbfield    = destinationDataSourceDefinition.Fields[j];
                bool    fieldExist = false;

                //Check if current Dbfield exist in the selected column list.
                foreach (DBField destinationDbField in destinationColumnList)
                {
                    if (dbfield.Name == destinationDbField.Name)
                    {
                        fieldExist = true;
                        break;
                    }
                }

                //If field is selected then set the value of that field in the runtime cursor.
                if (fieldExist)
                {
                    runtimeCursor.CursorDefinition.IsFieldUpdated[j] = true;

                    //Convert values of fields of record.
                    int recordFieldIndex;
                    destinationToSourceFieldIndexMapping.TryGetValue(dbfield.Name, out recordFieldIndex);

                    runtimeCursor.RuntimeCursorData.CurrentValues[j].IsNull = record.IsNull(recordFieldIndex);

                    if (record.IsNull(recordFieldIndex))
                    {
                        if (!dbfield.AllowNull)
                        {
                            runtimeCursor.RuntimeCursorData.CurrentValues[j].Value  = dbfield.DefaultValue;
                            runtimeCursor.RuntimeCursorData.CurrentValues[j].IsNull = false;
                        }
                    }
                    else
                    {
                        runtimeCursor.RuntimeCursorData.CurrentValues[j].Value = record.GetFieldValue(recordFieldIndex);
                    }
                }
                else
                {
                    runtimeCursor.CursorDefinition.IsFieldUpdated[j]        = false;
                    runtimeCursor.RuntimeCursorData.CurrentValues[j].IsNull = true;
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Build the ranges using the unique key segments.
        /// </summary>
        /// <param name="record"></param>
        /// <param name="runtimeCursor"></param>
        /// <returns></returns>
        private void BuildRanges(RecordForDataViewToDataSource record, RuntimeCursor runtimeCursor)
        {
            int recordFieldIndex = 0;

            if (uniqueKey != null)
            {
                runtimeCursor.RuntimeCursorData.Ranges = new List <RangeData>();

                foreach (DBSegment segment in uniqueKey.Segments)
                {
                    for (int fldIndex = 0; fldIndex < destinationColumnList.Count; fldIndex++)
                    {
                        DBField dbField = destinationColumnList[fldIndex];

                        if (dbField.Equals(segment.Field))
                        {
                            RangeData rngData = new RangeData();
                            rngData.FieldIndex = dbField.IndexInRecord;

                            rngData.Max.Type    = RangeType.RangeParam;
                            rngData.Max.Discard = false;

                            rngData.Min.Type    = RangeType.RangeParam;
                            rngData.Min.Discard = false;

                            FieldValue fieldValue = new FieldValue();
                            destinationToSourceFieldIndexMapping.TryGetValue(dbField.Name, out recordFieldIndex);
                            fieldValue.Value = record.GetFieldValue(recordFieldIndex);

                            rngData.Max.Value = fieldValue;
                            rngData.Min.Value = fieldValue;

                            runtimeCursor.RuntimeCursorData.Ranges.Add(rngData);
                            break;
                        }
                    }
                }
            }
        }