Exemplo n.º 1
0
        public string Save(ESRI.ArcGIS.Geodatabase.IWorkspace Workspace, BaseModel BaseModel, ModelProperty Property)
        {
            object[]      _parametros                 = { (object)Workspace };
            ModelProperty _mpChaveFromField           = BaseModel.ModelProperties.Where(x => x.Attribute is EntityKeyFieldAttribute).First();
            int           chave                       = (int)BaseModel.GetType().GetProperty(_mpChaveFromField.Property.Name).GetValue(BaseModel, null);
            EntityManyToManyFieldAttribute _attribute = (EntityManyToManyFieldAttribute)Property.Attribute;
            BaseModel _mtmField                       = (BaseModel)Activator.CreateInstance(_attribute.TargetModelType, _parametros);

            BaseModel _relateField = (BaseModel)Activator.CreateInstance(_attribute.RelateModelType, _parametros);

            _relateField.Delete(_attribute.FromFieldName + "=" + chave);


            foreach (ModelProperty _mp in BaseModel.ModelProperties.Where(x => x.Attribute.FieldName.Equals(Property.Attribute.FieldName)))
            {
                if (_mp.Property.GetValue(BaseModel, null) != null)
                {
                    IList _list = (IList)_mp.Property.GetValue(BaseModel, null);

                    foreach (var _item in _list)
                    {
                        ModelProperty _mpChaveToField = BaseModel.ModelProperties.Where(x => x.Attribute is EntityKeyFieldAttribute).First();
                        int           _value          = Convert.ToInt32(_item.GetType().GetProperty(_mpChaveToField.Property.Name).GetValue(_item, null).ToString());

                        var _objFinal = Activator.CreateInstance(_attribute.RelateModelType, _parametros);
                        _objFinal.GetType().GetProperty(_attribute.FromFieldName.Split('.')[1]).SetValue(_objFinal, chave, null);
                        _objFinal.GetType().GetProperty(_attribute.ToFieldName.Split('.')[1]).SetValue(_objFinal, _value, null);
                        ((BaseModel)_objFinal).Save();
                    }
                }
            }



            return("");
        }
Exemplo n.º 2
0
 public virtual void Load(IWorkspace Workspace, IRow Row, BaseModel BaseModel, ModelProperty Property, BaseModel.LoadMethod ChooseLoadMethod)
 {
     this.Load(Workspace, Row, BaseModel, Property);
 }
Exemplo n.º 3
0
 public virtual void Load(IWorkspace Workspace, IRow Row, BaseModel BaseModel, ModelProperty Property)
 {
     if (Property.Attribute.FieldType == typeof(bool) || Property.Attribute.FieldType == typeof(bool))
     {
         Property.Property.SetValue(BaseModel, "1".Equals(Row.get_Value(Row.Fields.FindField(Property.Attribute.FieldName)).ToString()), null);
     }
     else
     {
         if (!String.IsNullOrEmpty(Row.get_Value(Row.Fields.FindField(Property.Attribute.FieldName)).ToString()))
         {
             Property.Property.SetValue(BaseModel,
                                        Convert.ChangeType(Row.get_Value(Row.Fields.FindField(Property.Attribute.FieldName)),
                                                           Property.Attribute.FieldType), null);
         }
     }
 }
Exemplo n.º 4
0
 public void Load(IWorkspace Workspace, IFeature Feature, BaseModel BaseModel, ModelProperty Property, BaseModel.LoadMethod ChooseLoadMethod)
 {
     if (ChooseLoadMethod == BaseModel.LoadMethod.Lazy)
     {
         return;
     }
     this.Load(Workspace, Feature, BaseModel, Property);
 }
Exemplo n.º 5
0
        public void Load(IWorkspace Workspace, IFeature Feature, BaseModel BaseModel, ModelProperty Property)
        {
            object[] _parametros = { (object)Workspace };
            EntityOneToManyFieldAttribute _attribute = (EntityOneToManyFieldAttribute)Property.Attribute;
            BaseModel otmField  = (BaseModel)Activator.CreateInstance((_attribute).FieldModelType, _parametros);
            string    _KeyObj   = Feature.get_Value(Feature.Fields.FindField(_attribute.FieldName)).ToString();
            Int32     _keyValue = !String.IsNullOrEmpty(_KeyObj) ? Convert.ToInt32(_KeyObj) : 0;

            if (_keyValue > 0)
            {
                var   _source = otmField.Search(_attribute.FieldName + "=" + _keyValue, BaseModel.LoadMethod.Lazy);
                IList _target = (IList)Activator.CreateInstance(typeof(List <>).MakeGenericType(_attribute.FieldModelType));
                foreach (var _item in _source)
                {
                    _target.Add(_item);
                }

                Property.Property.SetValue(BaseModel, _target, null);
            }
        }
Exemplo n.º 6
0
 public string Save(IWorkspace Workspace, BaseModel BaseModel, ModelProperty Property)
 {
     //throw new NotImplementedException();
     return("");
 }
Exemplo n.º 7
0
 public void Load(ESRI.ArcGIS.Geodatabase.IWorkspace _workspace, ESRI.ArcGIS.Geodatabase.IRow _row, BaseModel BaseModel, ModelProperty _property, BaseModel.LoadMethod ChooseLoadMethod)
 {
     this.Load(_workspace, _row, BaseModel, _property);
 }
Exemplo n.º 8
0
 public void Save(IWorkspace Workspace, IFeature Feature, BaseModel BaseModel, ModelProperty Property)
 {
     Feature.set_Value(Feature.Fields.FindField(Property.Attribute.FieldName),
                       Convert.ChangeType(Property.Property.GetValue(BaseModel, null),
                                          Property.Attribute.FieldType));
 }
Exemplo n.º 9
0
 public void Load(ESRI.ArcGIS.Geodatabase.IWorkspace Workspace, ESRI.ArcGIS.Geodatabase.IRow Row, BaseModel BaseModel, ModelProperty Property, BaseModel.LoadMethod ChooseLoadMethod)
 {
     if (BaseModel.LoadMethod.Lazy == ChooseLoadMethod)
     {
         return;
     }
     this.Load(Workspace, Row, BaseModel, Property);
 }
Exemplo n.º 10
0
        public void Delete(ESRI.ArcGIS.Geodatabase.IWorkspace Workspace, BaseModel BaseModel, ModelProperty _property)
        {
            ModelProperty _mpChaveFromField = BaseModel.ModelProperties.Where(x => x.Attribute is EntityKeyFieldAttribute).First();
            int           chave             = (int)BaseModel.GetType().GetProperty(_mpChaveFromField.Property.Name).GetValue(BaseModel, null);

            object[] _parametros = { (object)Workspace };

            EntityManyToManyFieldAttribute _attribute = (EntityManyToManyFieldAttribute)_property.Attribute;
            BaseModel _mtmField = (BaseModel)Activator.CreateInstance(_attribute.TargetModelType, _parametros);

            BaseModel _relateField = (BaseModel)Activator.CreateInstance(_attribute.RelateModelType, _parametros);

            _relateField.Delete(_attribute.FromFieldName + "=" + chave);
        }
Exemplo n.º 11
0
 public void Save(ESRI.ArcGIS.Geodatabase.IWorkspace Workspace, ESRI.ArcGIS.Geodatabase.IFeature Feature, BaseModel BaseModel, ModelProperty Property)
 {
     this.Save(Workspace, BaseModel, Property);
 }
        public void Save(IWorkspace Workspace, IFeature Feature, BaseModel BaseModel, ModelProperty Property)
        {
            EntityKeyFieldAttribute _keyField = (EntityKeyFieldAttribute)Property.Attribute;

            if (String.IsNullOrEmpty(_keyField.Sequence))
            {
                Feature.set_Value(Feature.Fields.FindField(Property.Attribute.FieldName), Convert.ChangeType(Property.Property.GetValue(BaseModel, null), Property.Attribute.FieldType));
            }
            else
            {
                ICursor cursor = Helper.GDBCursor.obterCursor((IFeatureWorkspace)Workspace, "SYS.DUAL", _keyField.Sequence + ".NEXTVAL", "");
                IRow    row    = cursor.NextRow();
                Feature.set_Value(Feature.Fields.FindField(Property.Attribute.FieldName), Convert.ChangeType(row.get_Value(0).ToString(), Property.Attribute.FieldType));
            }
        }
Exemplo n.º 13
0
        public void Load(IWorkspace Workspace, IFeature Feature, BaseModel BaseModel, ModelProperty Property)
        {
            object[] _parametros = { (object)Workspace };

            BaseModel otoField  = (BaseModel)Activator.CreateInstance(((EntityOneToOneFieldAttribute)Property.Attribute).FieldModelType, _parametros);
            string    _KeyObj   = Feature.get_Value(Feature.Fields.FindField(Property.Attribute.FieldName)).ToString();
            Int32     _keyValue = !String.IsNullOrEmpty(_KeyObj) ? Convert.ToInt32(_KeyObj) : 0;

            if (_keyValue > 0)
            {
                otoField.Load(_keyValue);
                Property.Property.SetValue(BaseModel, otoField, null);
            }
        }
Exemplo n.º 14
0
        public void Save(IWorkspace Workspace, IFeature Feature, BaseModel BaseModel, ModelProperty Property)
        {
            BaseModel _bm = (BaseModel)Property.Property.GetValue(BaseModel, null);

            if (_bm != null)
            {
                ModelProperty _keyProperty = _bm.ModelProperties.Where(x => x.Attribute is EntityKeyFieldAttribute).First <ModelProperty>();
                Int32         _keyValue    = (Int32)_keyProperty.Property.GetValue(_bm, null);

                Feature.set_Value(Feature.Fields.FindField(Property.Attribute.FieldName), _keyValue);
            }
        }
Exemplo n.º 15
0
 public void Load(IWorkspace Workspace, IFeature Feature, BaseModel BaseModel, ModelProperty Property)
 {
     if (!String.IsNullOrEmpty(Feature.get_Value(Feature.Fields.FindField(Property.Attribute.FieldName)).ToString()))
     {
         Property.Property.SetValue(BaseModel,
                                    Convert.ChangeType(Feature.get_Value(Feature.Fields.FindField(Property.Attribute.FieldName)),
                                                       Property.Attribute.FieldType),
                                    null);
     }
 }
Exemplo n.º 16
0
        public void Load(ESRI.ArcGIS.Geodatabase.IWorkspace Workspace, ESRI.ArcGIS.Geodatabase.IFeature Feature, BaseModel BaseModel, ModelProperty Property)
        {
            object[] _parametros = { (object)Workspace };
            EntityManyToManyFieldAttribute _attribute = (EntityManyToManyFieldAttribute)Property.Attribute;
            BaseModel _mtmField = (BaseModel)Activator.CreateInstance(_attribute.RelateModelType, _parametros);

            string _KeyObj   = Feature.get_Value(Feature.Fields.FindField(BaseModel.KeyField)).ToString();
            Int32  _keyValue = !String.IsNullOrEmpty(_KeyObj) ? Convert.ToInt32(_KeyObj) : 0;

            if (_keyValue > 0)
            {
                var _source = _mtmField.Search(_attribute.FromFieldName + "=" + _keyValue, BaseModel.LoadMethod.Lazy);

                IList _target = (IList)Activator.CreateInstance(typeof(List <>).MakeGenericType(_attribute.TargetModelType));
                foreach (BaseModel _item in _source)
                {
                    BaseModel    _itemTarget   = (BaseModel)Activator.CreateInstance(_attribute.TargetModelType, _parametros);
                    PropertyInfo _entityTarget = _item.ModelProperties.Where(x =>
                    {
                        return(_attribute.ToFieldName.Split('.')[1].Equals(((System.Reflection.MemberInfo)x.Property).Name));
                    }).Single().Property;
                    _itemTarget.Load((int)_entityTarget.GetValue(_item, null));
                    _target.Add(_itemTarget);
                }

                Property.Property.SetValue(BaseModel, _target, null);
            }
        }
Exemplo n.º 17
0
 public void Load(IWorkspace Workspace, IFeature Feature, BaseModel BaseModel, ModelProperty Property, BaseModel.LoadMethod ChooseLoadMethod)
 {
     this.Load(Workspace, Feature, BaseModel, Property);
 }
Exemplo n.º 18
0
 public void Save(IWorkspace Workspace, IFeature Row, BaseModel BaseModel, ModelProperty Property)
 {
     //throw new NotImplementedException();
 }
Exemplo n.º 19
0
 public string Save(IWorkspace Workspace, BaseModel BaseModel, ModelProperty Property)
 {
     return(FieldFormatHelper.FormatField(Property.Property.GetValue(BaseModel, null), Property.Attribute.FieldType));
 }
Exemplo n.º 20
0
 public void Load(ESRI.ArcGIS.Geodatabase.IWorkspace Workspace, ESRI.ArcGIS.Geodatabase.IRow Row, BaseModel AEOModel, ModelProperty Property)
 {
     if (!String.IsNullOrEmpty(Row.get_Value(Row.Fields.FindField(Property.Attribute.FieldName)).ToString()))
     {
         Property.Property.SetValue(AEOModel,
                                    Convert.ChangeType(Row.get_Value(Row.Fields.FindField(Property.Attribute.FieldName)),
                                                       Property.Attribute.FieldType), null);
     }
 }