예제 #1
0
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////
        public DBProvider(DataTable table)
        {
            Debug.Assert(null != table);

            _table = table;

            DataColumnCollection drc = table.Columns;
            foreach (DataColumn dc in drc)
            {
              DataFieldInfo info = new DataFieldInfo(dc.ColumnName, dc.DataType);
              _fieldsInfo.Add(info);
            }
        }
예제 #2
0
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////

        public DBProvider(DataTable table)
        {
            Debug.Assert(null != table);

            _table = table;

            DataColumnCollection drc = table.Columns;

            foreach (DataColumn dc in drc)
            {
                DataFieldInfo info = new DataFieldInfo(dc.ColumnName, dc.DataType);
                _fieldsInfo.Add(info);
            }
        }
예제 #3
0
        /// <summary>
        /// Gets list of object data field.
        /// </summary>
        /// <param name="type">Propery type.</param>
        /// <param name="title">Property title.</param>
        /// <param name="isSourceShape">Flag is source shape file.</param>
        /// <param name="list">Output list object data field.</param>
        static private void _GetFieldInfos(Type type,
                                           string title,
                                           bool isSourceShape,
                                           ref List <ObjectDataFieldInfo> list)
        {
            //
            // NOTE: function use recursion
            //

            if (!_GetAppTypeFieldInfos(type, title, isSourceShape, ref list))
            {   // other types
                Type attributeType = typeof(DomainPropertyAttribute);

                PropertyInfo[] properties = type.GetProperties();
                foreach (PropertyInfo property in properties)
                {
                    if (Attribute.IsDefined(property, attributeType))
                    {
                        if (isSourceShape && ("GeoLocation" == property.Name))
                        {
                            // NOTE: special case
                            continue; // NOTE: ignore for shape files
                        }
                        var importAttribute =
                            Attribute.GetCustomAttribute(property, attributeType)
                            as DomainPropertyAttribute;
                        Debug.Assert(null != importAttribute);

                        Type propertyType = _GetEffectiveType(property.PropertyType);
                        bool isPrefixed   = _IsPrefixed(type, title);

                        string fullTitle = _AssemblyPropertyFullName(importAttribute.Title,
                                                                     isPrefixed, title);
                        if (_IsSystemType(propertyType)) // system type
                        {
                            var info = new DataFieldInfo(fullTitle, propertyType);
                            list.Add(new ObjectDataFieldInfo(info, importAttribute.IsMandatory));
                        }
                        else // application internal declaration type
                        {
                            _GetFieldInfos(propertyType, fullTitle, isSourceShape, ref list);
                        }
                    }
                }
            }
        }
 /// <summary>
 /// Creates data field info.
 /// </summary>
 /// <param name="info">Field info.</param>
 /// <param name="isMandatory">Flag is field mandatory.</param>
 public ObjectDataFieldInfo(DataFieldInfo info, bool isMandatory)
 {
     Info        = info;
     IsMandatory = isMandatory;
 }
        /// <summary>
        /// Gets list of object data field.
        /// </summary>
        /// <param name="type">Propery type.</param>
        /// <param name="title">Property title.</param>
        /// <param name="isSourceShape">Flag is source shape file.</param>
        /// <param name="list">Output list object data field.</param>
        private static void _GetFieldInfos(Type type,
                                           string title,
                                           bool isSourceShape,
                                           ref List<ObjectDataFieldInfo> list)
        {
            //
            // NOTE: function use recursion
            //

            if (!_GetAppTypeFieldInfos(type, title, isSourceShape, ref list))
            {   // other types
                Type attributeType = typeof(DomainPropertyAttribute);

                PropertyInfo[] properties = type.GetProperties();
                foreach (PropertyInfo property in properties)
                {
                    if (Attribute.IsDefined(property, attributeType))
                    {
                        if (isSourceShape && ("GeoLocation" == property.Name))
                            // NOTE: special case
                            continue; // NOTE: ignore for shape files

                        var importAttribute =
                            Attribute.GetCustomAttribute(property, attributeType)
                                as DomainPropertyAttribute;
                        Debug.Assert(null != importAttribute);

                        Type propertyType = _GetEffectiveType(property.PropertyType);
                        bool isPrefixed = _IsPrefixed(type, title);

                        string fullTitle = _AssemblyPropertyFullName(importAttribute.Title,
                                                                     isPrefixed, title);
                        if (_IsSystemType(propertyType)) // system type
                        {
                            var info = new DataFieldInfo(fullTitle, propertyType);
                            list.Add(new ObjectDataFieldInfo(info, importAttribute.IsMandatory));
                        }
                        else // application internal declaration type
                            _GetFieldInfos(propertyType, fullTitle, isSourceShape, ref list);
                    }
                }
            }
        }
        /// <summary>
        /// Gets list of object data field for application types.
        /// </summary>
        /// <param name="type">Propery type.</param>
        /// <param name="title">Property title.</param>
        /// <param name="isSourceShape">Flag is source shape file.</param>
        /// <param name="list">Output list object data field.</param>
        private static bool _GetAppTypeFieldInfos(Type type,
                                                  string title,
                                                  bool isSourceShape,
                                                  ref List<ObjectDataFieldInfo> list)
        {
            bool result = true;

            if (typeof(OrderCustomProperties) == type)
            {   // specials type: related object OrderCustomProperty
                OrderCustomPropertiesInfo infos = App.Current.Project.OrderCustomPropertiesInfo;
                for (int index = 0; index < infos.Count; ++index)
                {
                    Type propType = (infos[index].Type == OrderCustomPropertyType.Text) ?
                                        typeof(string) : typeof(double);
                    var info = new DataFieldInfo(infos[index].Name, propType);
                    list.Add(new ObjectDataFieldInfo(info, false));
                }
            }

            else if (typeof(Capacities) == type)
            {   // specials type: related object Capacities
                CapacitiesInfo infos = App.Current.Project.CapacitiesInfo;
                for (int index = 0; index < infos.Count; ++index)
                {
                    var info = new DataFieldInfo(infos[index].Name, typeof(double));
                    list.Add(new ObjectDataFieldInfo(info, false));
                }
            }

            else if (typeof(Address) == type)
            {   // specials type: related object Address
                AddressField[] fields = App.Current.Geocoder.AddressFields;
                for (int index = 0; index < fields.Length; ++index)
                {
                    var info = new DataFieldInfo(fields[index].Title, typeof(string));
                    list.Add(new ObjectDataFieldInfo(info, false));
                }
            }

            else if ((typeof(IDataObjectCollection<VehicleSpecialty>) == type) ||
                     (typeof(IDataObjectCollection<DriverSpecialty>) == type) ||
                     (typeof(IDataObjectCollection<Location>) == type) ||
                     (typeof(IDataObjectCollection<Zone>) == type) ||
                     (typeof(FuelType) == type) ||
                     (!string.IsNullOrEmpty(title) &&
                        ((typeof(Location) == type) ||
                         (typeof(MobileDevice) == type) ||
                         (typeof(Vehicle) == type) ||
                         (typeof(Driver) == type))))
            {   // specials types: related objects and objects collection
                var info = new DataFieldInfo(title, typeof(string));
                var fieldInfo = new ObjectDataFieldInfo(info, false);
                list.Add(fieldInfo);
            }

            else
            {
                result = false;
            }

            return result;
        }
예제 #7
0
        /// <summary>
        /// Gets list of object data field for application types.
        /// </summary>
        /// <param name="type">Propery type.</param>
        /// <param name="title">Property title.</param>
        /// <param name="isSourceShape">Flag is source shape file.</param>
        /// <param name="list">Output list object data field.</param>
        static private bool _GetAppTypeFieldInfos(Type type,
                                                  string title,
                                                  bool isSourceShape,
                                                  ref List <ObjectDataFieldInfo> list)
        {
            bool result = true;

            if (typeof(OrderCustomProperties) == type)
            {   // specials type: related object OrderCustomProperty
                OrderCustomPropertiesInfo infos = App.Current.Project.OrderCustomPropertiesInfo;
                for (int index = 0; index < infos.Count; ++index)
                {
                    Type propType = (infos[index].Type == OrderCustomPropertyType.Text) ?
                                    typeof(string) : typeof(double);
                    var info = new DataFieldInfo(infos[index].Name, propType);
                    list.Add(new ObjectDataFieldInfo(info, false));
                }
            }

            else if (typeof(Capacities) == type)
            {   // specials type: related object Capacities
                CapacitiesInfo infos = App.Current.Project.CapacitiesInfo;
                for (int index = 0; index < infos.Count; ++index)
                {
                    var info = new DataFieldInfo(infos[index].Name, typeof(double));
                    list.Add(new ObjectDataFieldInfo(info, false));
                }
            }

            else if (typeof(Address) == type)
            {   // specials type: related object Address
                AddressField[] fields = App.Current.Geocoder.AddressFields;
                for (int index = 0; index < fields.Length; ++index)
                {
                    var info = new DataFieldInfo(fields[index].Title, typeof(string));
                    list.Add(new ObjectDataFieldInfo(info, false));
                }
            }

            else if ((typeof(IDataObjectCollection <VehicleSpecialty>) == type) ||
                     (typeof(IDataObjectCollection <DriverSpecialty>) == type) ||
                     (typeof(IDataObjectCollection <Location>) == type) ||
                     (typeof(IDataObjectCollection <Zone>) == type) ||
                     (typeof(FuelType) == type) ||
                     (!string.IsNullOrEmpty(title) &&
                      ((typeof(Location) == type) ||
                       (typeof(MobileDevice) == type) ||
                       (typeof(Vehicle) == type) ||
                       (typeof(Driver) == type))))
            {   // specials types: related objects and objects collection
                var info      = new DataFieldInfo(title, typeof(string));
                var fieldInfo = new ObjectDataFieldInfo(info, false);
                list.Add(fieldInfo);
            }

            else
            {
                result = false;
            }

            return(result);
        }
 /// <summary>
 /// Creates data field info.
 /// </summary>
 /// <param name="info">Field info.</param>
 /// <param name="isMandatory">Flag is field mandatory.</param>
 public ObjectDataFieldInfo(DataFieldInfo info, bool isMandatory)
 {
     Info = info;
     IsMandatory = isMandatory;
 }