Пример #1
0
        public virtual void Construct(GORoleDataObject gORole, bool includeDirtyObjectsOnly)
        {
            if (gORole == null)
            {
                return;
            }

            this.PrimaryKey = gORole.PrimaryKey;

            if (gORole.ObjectsDataSet == null)
            {
                var dataset = ApplicationSettings.Container.Resolve <IObjectsDataSet>();
                dataset.AddObject(gORole);
            }

            if (gORole.ObjectsDataSet == null)
            {
                _logEngine.LogError("Unable to set a dataset to the Entity GORole", "Unable to set a dataset to the entity. Container may not be initialized", "GORoleDataObject", null);
                throw new PulpException("Unexpected Error : Unable to set a dataset to the entity : GORole");
            }

            if (gORole.InternalObjectId == null)
            {
                _logEngine.LogError("Unable to construct an object without InternalObjectId in GORoleDataObject", "The Object you are trying to construct doesn't have an InternalObjectId", "GORoleDataObject", null);
                throw new PulpException("Unexpected Error : Unable to construct an object without InternalObjectId in GORoleDataObject");
            }
            this.InternalObjectId = (int)gORole.InternalObjectId;
            this.ObjectsDataSet   = includeDirtyObjectsOnly ? gORole.ObjectsDataSet.CloneDirtyObjects() : gORole.ObjectsDataSet;
        }
Пример #2
0
        /// <summary>
        /// Copy Constructor
        /// </summary>
        public GORoleDataObject(GORoleDataObject template, bool deepCopy)
        {
            this.SetDescriptionValue(template.Description, false, false);
            this.SetDisplayNameValue(template.DisplayName, false, false);
            this.SetNameValue(template.Name, false, false);
            this.SetPasswordExpiryValue(template.PasswordExpiry, false, false);
            this.SetPasswordPolicySummaryValue(template.PasswordPolicySummary, false, false);
            this.SetPasswordRegExValue(template.PasswordRegEx, false, false);



            this.SetIsNewValue(template.IsNew, false, false);

            if (deepCopy)
            {
                this.ObjectsDataSet = template.ObjectsDataSet.Clone();
                // Remove the template object from the dataset
                this.ObjectsDataSet.RemoveObject(template);
                // And Replace by the one we're currently constructing
                this.ObjectsDataSet.AddObject(this);
            }

            this.SetIsDirtyValue(template.IsDirty, false, false);
            this.SetIsMarkedForDeletionValue(template.IsMarkedForDeletion, false, false);
        }
        public IEnumerable <GOGroupRoleDataObject> GetGroupRoleItemsForRole(GORoleDataObject roleInstance)
        {
            if (roleInstance.IsNew)
            {
                return(GOGroupRoleObjects.Where(o => o.Value._role_NewObjectId != null && o.Value._role_NewObjectId == roleInstance.InternalObjectId).Select(o => o.Value));
            }

            if (Role_FKIndex.ContainsKey(roleInstance.Name))
            {
                return(Role_FKIndex[roleInstance.Name].Where(e => GOGroupRoleObjects.ContainsKey(e)).Select(e => GOGroupRoleObjects[e]));
            }

            return(new DataObjectCollection <GOGroupRoleDataObject>());
        }
        public virtual void SetRoleValue(GORoleDataObject valueToSet, bool notifyChanges, bool dirtyHandlerOn)
        {
            GORoleDataObject existing_role = null;

            if (!(this.GORoleName == null || ObjectsDataSet == null))
            {
                var key = this._role_NewObjectId == null ? new GORoleDataObject(this.GORoleName)
                {
                    IsNew = false
                } : new GORoleDataObject()
                {
                    IsNew = true, InternalObjectId = this._role_NewObjectId
                };
                existing_role = (GORoleDataObject)ObjectsDataSet.GetObject(key);
            }

            if (ReferenceEquals(existing_role, valueToSet))
            {
                return;
            }
            // Give opportunity to change value before set
            OnBeforeSetRelationField("Role", valueToSet);

            // Setting the navigator desync the FK. The FK should be resync
            if (!ReferenceEquals(null, valueToSet))
            {
                if (ObjectsDataSet == null)
                {
                    _logEngine.LogError("Unable to set Relation Field", "Unable to set Relation Field, your entity doesn't have a DataSet.", "GOGroupRoleDataObject", null);
                    throw new PulpException("Unable to set Relation fields, your entity doesn't have a DataSet");
                }

                ObjectsDataSet.AddObjectIfDoesNotExist(valueToSet);

                if (valueToSet.IsNew)
                {
                    if (_role_NewObjectId != valueToSet.InternalObjectId)
                    {
                        _role_NewObjectId = valueToSet.InternalObjectId;
                        _gORoleName       = valueToSet.Name;
                        OnPropertyChanged("GORoleName", notifyChanges, dirtyHandlerOn);
                    }
                }
                else
                {
                    if (_gORoleName != valueToSet.Name)
                    {
                        _role_NewObjectId = null;

                        _gORoleName = valueToSet.Name;
                        OnPropertyChanged("GORoleName", notifyChanges, dirtyHandlerOn);
                    }
                }
            }
            else
            {
                _gORoleName = null;
                OnPropertyChanged("GORoleName", notifyChanges, dirtyHandlerOn);
            }
            if (!ReferenceEquals(existing_role, valueToSet))
            {
                OnPropertyChanged("Role", notifyChanges, dirtyHandlerOn);
            }
        }
 public virtual void SetRoleValue(GORoleDataObject valueToSet)
 {
     SetRoleValue(valueToSet, true, true);
 }
Пример #6
0
 public GORoleContainer(GORoleDataObject gORole, bool includeDirtyObjectsOnly)
 {
     Construct(gORole, includeDirtyObjectsOnly);
 }
Пример #7
0
 public GORoleContainer(GORoleDataObject gORole)
 {
     Construct(gORole, false);
 }