コード例 #1
0
        public void TestUpdatesProperties_GivenBo_UserNameAndDate_AndSecurityController()
        {
            //-------------Setup Test Pack ------------------

            new Engine(); new Car();
            ContactPerson contactPerson = new ContactPerson();
            IBOProp       dateBoProp    = contactPerson.Props["DateLastUpdated"];
            IBOProp       userBoProp    = contactPerson.Props["UserLastUpdated"];

            contactPerson.CancelEdits();
            ISecurityController securityController    = new MySecurityController();
            BusinessObjectLastUpdatePropertiesLog log = new BusinessObjectLastUpdatePropertiesLog(contactPerson, securityController);
            //-------------Test Pre-conditions --------------
            //-------------Execute test ---------------------
            DateTime beforeUpdate = DateTime.Now;

            log.Update();
            DateTime afterUpdate = DateTime.Now;

            //-------------Test Result ----------------------
            Assert.IsNotNull(userBoProp.Value);
            Assert.AreEqual("MyUserName", userBoProp.Value);
            Assert.IsNotNull(dateBoProp.Value);
            Assert.IsTrue(beforeUpdate <= (DateTime)dateBoProp.Value);
            Assert.IsTrue(afterUpdate >= (DateTime)dateBoProp.Value);
        }
コード例 #2
0
ファイル: DataSetProvider.cs プロジェクト: SaberZA/habanero
 /// <summary>
 /// Adds the Business Object to the DataTable
 /// </summary>
 private void LoadBusinessObject(IBusinessObject businessObject)
 {
     object[] values = GetValues(businessObject);
     try
     {
         DeregisterForTableEvents();
         DataRow row = _table.LoadDataRow(values, true);
         foreach (DataColumn column in _table.Columns)
         {
             string propName = column.ColumnName;
             if (businessObject.Props.Contains(propName))
             {
                 IBOProp prop = businessObject.Props[propName];
                 if (prop != null)
                 {
                     row.SetColumnError(propName, prop.InvalidReason);
                 }
             }
         }
         if (businessObject != null)
         {
             row.RowError = businessObject.Status.IsValidMessage;
         }
     }
     finally
     {
         RegisterForTableEvents();
     }
 }
コード例 #3
0
        public void Test_IfThisThreadLocksAndTimesOutBeforePersistingThenThrowErrorWhenPersisting()
        {
            //---------------Set up test pack-------------------
            ContactPersonPessimisticLockingDB cp = CreateSavedContactPersonPessimisticLocking();

            cp.Surname = Guid.NewGuid().ToString();
            IBOProp propDateTimeLocked = cp.Props["DateTimeLocked"];
            int     lockDuration       = 15;

            //---------------Execute Test ----------------------
            propDateTimeLocked.Value = DateTime.Now.AddMinutes(-1 * lockDuration - 1);
            UpdateDatabaseLockAsExpired(lockDuration);
            try
            {
                cp.Save();
                Assert.Fail();
            }
            //---------------Test Result -----------------------
            catch (BusObjPessimisticConcurrencyControlException ex)
            {
                Assert.IsTrue(
                    ex.Message.Contains(
                        "The lock on the business object ContactPersonPessimisticLockingDB has a duration of 15 minutes and has been exceeded for the object"));
            }
        }
コード例 #4
0
ファイル: TestBoKey.cs プロジェクト: SaberZA/habanero
        public void TestBOKeyEqual()
        {
            //Set values for Key1
            BOKey   lBOKey1 = (BOKey)_keyDef1.CreateBOKey(_boPropCol1);
            IBOProp lProp   = _boPropCol1["PropName"];

            lProp.Value = "Prop Value";

            lProp       = _boPropCol1["PropName1"];
            lProp.Value = "Value 2";

            //Set values for Key2
            BOKey lBOKey2 = (BOKey)_keyDef2.CreateBOKey(_boPropCol2);

            lProp       = _boPropCol2["PropName"];
            lProp.Value = "Prop Value";

            lProp       = _boPropCol2["PropName1"];
            lProp.Value = "Value 2";

            //Assert.AreEqual(lBOKey1, lBOKey2);
            Assert.IsTrue(lBOKey1 == lBOKey2);

            Assert.AreEqual(lBOKey1.GetHashCode(), lBOKey2.GetHashCode());
        }
コード例 #5
0
ファイル: TestBoKey.cs プロジェクト: SaberZA/habanero
        public void TestSortedValues()
        {
            BOKey   lBOKey1 = (BOKey)_keyDef1.CreateBOKey(_boPropCol2);
            IBOProp lProp   = _boPropCol2["PropName"];

            Assert.AreSame(lProp, lBOKey1.SortedValues[0]);
        }
コード例 #6
0
 /// <summary>
 /// Removes handlers to events of a current business object property.
 /// It is essential that if the AddCurrentBoPropHandlers is implemented then this
 /// is implemented such that editing a business object that is no longer being shown on the control does not
 /// does not update the value in the control.
 /// </summary>
 /// <param name="mapper">The control mapper that maps the business object property to the control</param>
 /// <param name="boProp">The business object property being mapped to the control</param>
 public void RemoveCurrentBOPropHandlers(ControlMapper mapper, IBOProp boProp)
 {
     if (boProp != null)
     {
         boProp.Updated -= mapper.BOPropValueUpdatedHandler;
     }
 }
コード例 #7
0
 /// <summary>
 /// Removes handlers to events of a current business object property.
 /// It is essential that if the AddCurrentBoPropHandlers is implemented then this 
 /// is implemented such that editing a business object that is no longer being shown on the control does not
 /// does not update the value in the control.
 /// </summary>
 /// <param name="mapper">The control mapper that maps the business object property to the control</param>
 /// <param name="boProp">The business object property being mapped to the control</param>
 public void RemoveCurrentBOPropHandlers(ControlMapper mapper, IBOProp boProp)
 {
     if (boProp != null)
     {
         boProp.Updated -= mapper.BOPropValueUpdatedHandler;
     }
 }
コード例 #8
0
        public void Test_UpdateStateAsCommitted()
        {
            //---------------Set up test pack-------------------
            ContactPersonTestBO contactPersonTestBO = new ContactPersonTestBO();
            OrganisationTestBO  organisationTestBO  = new OrganisationTestBO();

            SingleRelationship <OrganisationTestBO> singleRelationship = contactPersonTestBO.Relationships.GetSingle <OrganisationTestBO>("Organisation");

            singleRelationship.SetRelatedObject(organisationTestBO);

            IRelationship relationship = organisationTestBO.Relationships.GetMultiple <ContactPersonTestBO>("ContactPeople");
            TransactionalSingleRelationship_Added tsr = new TransactionalSingleRelationship_Added(relationship, contactPersonTestBO);
            IBOProp relationshipProp = contactPersonTestBO.Props["OrganisationID"];

            //---------------Assert PreConditions---------------
            Assert.IsTrue(relationshipProp.IsDirty);
            Assert.AreNotEqual(relationshipProp.Value, relationshipProp.PersistedPropertyValue);

            //---------------Execute Test ----------------------
            tsr.UpdateStateAsCommitted();

            //---------------Test Result -----------------------
            Assert.IsFalse(relationshipProp.IsDirty);
            Assert.AreEqual(relationshipProp.Value, relationshipProp.PersistedPropertyValue);
        }
コード例 #9
0
        private bool CheckReadWriteRules()
        {
            IBOProp boProp = CurrentBOProp();
            string  message;

            //Should Add the message to tool tip text
            return(boProp.IsEditable(out message));
        }
コード例 #10
0
 /// <summary>
 /// Adds handlers to events of a current business object property.
 /// </summary>
 /// <param name="mapper">The control mapper that maps the business object property to the control</param>
 /// <param name="boProp">The business object property being mapped to the control</param>
 public void AddCurrentBOPropHandlers(ControlMapper mapper, IBOProp boProp)
 {
     if (boProp != null)
     {
         // Add needed handlers
         boProp.Updated += mapper.BOPropValueUpdatedHandler;
     }
 }
コード例 #11
0
 /// <summary>
 /// Adds handlers to events of a current business object property.
 /// </summary>
 /// <param name="mapper">The control mapper that maps the business object property to the control</param>
 /// <param name="boProp">The business object property being mapped to the control</param>
 public void AddCurrentBOPropHandlers(ControlMapper mapper, IBOProp boProp)
 {
     if (boProp != null)
     {
         // Add needed handlers
         boProp.Updated += mapper.BOPropValueUpdatedHandler;
     }
 }
コード例 #12
0
 public BOPropTester(IBOProp boProp)
 {
     if (boProp == null)
     {
         throw new ArgumentNullException("boProp");
     }
     BOProp = boProp;
 }
コード例 #13
0
 internal UpdateStatementGeneratorLocking(BusinessObject bo, IBOProp boPropLocked, IDatabaseConnection connection)
     : base(bo, connection)
 {
     if (boPropLocked == null)
     {
         throw new ArgumentNullException("boPropLocked");
     }
     _boPropLocked = boPropLocked;
 }
コード例 #14
0
 /// <summary>
 /// Constructor to initialise a new instance of pessimistic locking with the property details
 /// form implementing the pessimistic locking strategy.
 /// </summary>
 /// <param name="busObj">The business object on which to perform concurrency control</param>
 /// <param name="lockDurationInMinutes">The period of time that the lock will be maintained</param>
 /// <param name="boPropDateTimeLocked">The date that the object was locked</param>
 /// <param name="boPropUserLocked">The user that locked the object</param>
 /// <param name="boPropMachineLocked">The machine name on which the object was last updated</param>
 /// <param name="boPropOperatingSystemUser">The Windows logged on user who locked the object</param>
 /// <param name="boPropLocked">The property that determines whether the object is locked or not</param>
 public PessimisticLockingDB(BusinessObject busObj, int lockDurationInMinutes, IBOProp boPropDateTimeLocked, IBOProp boPropUserLocked, IBOProp boPropMachineLocked, IBOProp boPropOperatingSystemUser, IBOProp boPropLocked)
 {
     _busObj = busObj;
     _lockDurationInMinutes     = lockDurationInMinutes;
     _boPropDateLocked          = OrphanFromBOStatus(boPropDateTimeLocked);
     _boPropUserLocked          = OrphanFromBOStatus(boPropUserLocked);
     _boPropMachineLocked       = OrphanFromBOStatus(boPropMachineLocked);
     _boPropOperatingSystemUser = OrphanFromBOStatus(boPropOperatingSystemUser);
     _boPropLocked = OrphanFromBOStatus(boPropLocked);
 }
コード例 #15
0
ファイル: TestBoPropCol.cs プロジェクト: kevinbosman/habanero
        public void TestSetBOPropValue()
        {
            mProp = mBOPropCol["Prop2"];
            mProp.Value = "Prop Value";
            Assert.AreEqual("Prop Value", mProp.Value);

            mProp = mBOPropCol["PropName"];
            mProp.Value = "Value 2";
            Assert.AreEqual("Value 2", mProp.Value);
        }
コード例 #16
0
 /// <summary>
 /// Constructor as before, but allows the operating system on which
 /// the update was done to be specified
 /// </summary>
 public OptimisticLockingVersionNumberDB(BusinessObject busObj,
                                         IBOProp dateLastUpdated,
                                         IBOProp userLastUpdated,
                                         IBOProp machineLastUpdated,
                                         IBOProp versionNumber,
                                         IBOProp operatingSystemUser)
     : this(busObj, dateLastUpdated, userLastUpdated, machineLastUpdated, versionNumber)
 {
     _operatingSystemUser = operatingSystemUser;
 }
コード例 #17
0
ファイル: TestBoPropCol.cs プロジェクト: SaberZA/habanero
        public void TestSetBOPropValue()
        {
            mProp       = mBOPropCol["Prop2"];
            mProp.Value = "Prop Value";
            Assert.AreEqual("Prop Value", mProp.Value);

            mProp       = mBOPropCol["PropName"];
            mProp.Value = "Value 2";
            Assert.AreEqual("Value 2", mProp.Value);
        }
コード例 #18
0
 /// <summary>
 /// Constructor to initialise a new instance of pessimistic locking with the property details
 /// form implementing the pessimistic locking strategy.
 /// </summary>
 /// <param name="busObj">The business object on which to perform concurrency control</param>
 /// <param name="lockDurationInMinutes">The period of time that the lock will be maintained</param>
 /// <param name="boPropDateTimeLocked">The date that the object was locked</param>
 /// <param name="boPropUserLocked">The user that locked the object</param>
 /// <param name="boPropMachineLocked">The machine name on which the object was last updated</param>
 /// <param name="boPropOperatingSystemUser">The Windows logged on user who locked the object</param>
 /// <param name="boPropLocked">The property that determines whether the object is locked or not</param>
 public PessimisticLockingDB(BusinessObject busObj, int lockDurationInMinutes, IBOProp boPropDateTimeLocked, IBOProp boPropUserLocked, IBOProp boPropMachineLocked, IBOProp boPropOperatingSystemUser, IBOProp boPropLocked)
 {
     _busObj = busObj;
     _lockDurationInMinutes = lockDurationInMinutes;
     _boPropDateLocked = OrphanFromBOStatus(boPropDateTimeLocked);
     _boPropUserLocked = OrphanFromBOStatus(boPropUserLocked);
     _boPropMachineLocked = OrphanFromBOStatus(boPropMachineLocked);
     _boPropOperatingSystemUser = OrphanFromBOStatus(boPropOperatingSystemUser);
     _boPropLocked = OrphanFromBOStatus(boPropLocked);
 }
コード例 #19
0
 public void AddUpdateBoPropOnTextChangedHandler(TextBoxMapper mapper, IBOProp boProp)
 {
     BoProp = boProp;
     _mapper = mapper;
     var tb = mapper.GetControl() as TextBox;
     if (tb != null)
     {
         tb.TextChanged += UpdateBoPropWithTextFromTextBox;
         TextBoxControl = tb;
     }
 }
コード例 #20
0
        /// <summary>
        /// Adds key press event handlers that carry out actions like
        /// limiting the input of certain characters, depending on the type of the
        /// property
        /// </summary>
        /// <param name="mapper">The TextBox mapper</param>
        /// <param name="boProp">The property being mapped</param>
        public void AddKeyPressEventHandler(TextBoxMapper mapper, IBOProp boProp)
        {
            BoProp = boProp;
            var tb = mapper.GetControl() as TextBox;

            if (tb != null)
            {
                tb.KeyPress   += KeyPressEventHandler;
                TextBoxControl = tb;
            }
        }
コード例 #21
0
        /// <summary>
        /// Adds key press event handlers that carry out actions like
        /// limiting the input of certain characters, depending on the type of the
        /// property
        /// </summary>
        /// <param name="mapper">The TextBox mapper</param>
        /// <param name="boProp">The property being mapped</param>
        public void AddKeyPressEventHandler(TextBoxMapper mapper, IBOProp boProp)
        {
            BoProp = boProp;
            var tb = mapper.GetControl() as TextBox;

            if (tb != null)
            {
                tb.KeyPress += KeyPressEventHandler;
                TextBoxControl = tb;
            }
        }
コード例 #22
0
        public void AddUpdateBoPropOnTextChangedHandler(TextBoxMapper mapper, IBOProp boProp)
        {
            BoProp  = boProp;
            _mapper = mapper;
            var tb = mapper.GetControl() as TextBox;

            if (tb != null)
            {
                tb.TextChanged += UpdateBoPropWithTextFromTextBox;
                TextBoxControl  = tb;
            }
        }
コード例 #23
0
ファイル: BOKey.cs プロジェクト: SaberZA/habanero
 /// <summary>
 /// Adds a <see cref="IBOProp"/> to the key
 /// </summary>
 /// <param name="boProp">The BOProp to add</param>
 public virtual void Add(IBOProp boProp)
 {
     ArgumentValidationHelper.CheckArgumentNotNull(boProp, "boProp");
     if (_props.ContainsKey(boProp.PropertyName))
     {
         throw new InvalidPropertyException(String.Format(
                                                "The property with the name '{0}' that is being added already " +
                                                "exists in the key collection.", boProp.PropertyName));
     }
     _props.Add(boProp.PropertyName, boProp);
     boProp.Updated += BOPropUpdated_Handler;
 }
コード例 #24
0
ファイル: PropertyLink.cs プロジェクト: SaberZA/habanero
 /// <summary>
 /// Constructor for building the link between two properties.
 /// </summary>
 /// <param name="owningBO">The object that owns the properties being linked</param>
 /// <param name="sourcePropName">The name of the source property.  This property will be watched for updates, triggering the updating of the destination property</param>
 /// <param name="destPropName">The name of the destination property.  This will be set to the value of the source (after transformation)</param>
 /// <param name="transform">The transform to apply. For no transform (ie a straight copy of the source property's value) simply return the input value</param>
 public PropertyLink(IBusinessObject owningBO, string sourcePropName, string destPropName,
                     Converter <TInput, TOutput> transform)
 {
     _owningBO            = owningBO;
     _sourcePropName      = sourcePropName;
     _sourceProp          = _owningBO.Props[_sourcePropName];
     _destPropName        = destPropName;
     _destinationProp     = _owningBO.Props[_destPropName];
     _transform           = transform;
     _previousSourceValue = GetSourcePropValue();
     Enable();
 }
コード例 #25
0
 /// <summary>
 /// Constructor to initialise a new instance with details of the last
 /// update of the object in the database
 /// </summary>
 /// <param name="busObj">The business object on which to perform concurrency control</param>
 /// <param name="dateLastUpdated">The date that the object was
 /// last updated</param>
 /// <param name="userLastUpdated">The user that last updated the
 /// object</param>
 /// <param name="machineLastUpdated">The machine name on which the
 /// object was last updated</param>
 /// <param name="versionNumber">The version number</param>
 public OptimisticLockingVersionNumberDB(BusinessObject busObj,
                                         IBOProp dateLastUpdated,
                                         IBOProp userLastUpdated,
                                         IBOProp machineLastUpdated,
                                         IBOProp versionNumber)
 {
     _busObj              = busObj;
     _dateLastUpdated     = dateLastUpdated;
     _userLastUpdated     = userLastUpdated;
     _machineLastUpdated  = machineLastUpdated;
     _versionNumber       = versionNumber;
     _operatingSystemUser = null;
 }
コード例 #26
0
 /// <summary>
 /// Constructor to initialise a new instance with details of the last
 /// update of the object in the database
 /// </summary>
 /// <param name="busObj">The business object on which to perform concurrency control</param>
 /// <param name="dateLastUpdated">The date that the object was
 /// last updated</param>
 /// <param name="userLastUpdated">The user that last updated the
 /// object</param>
 /// <param name="machineLastUpdated">The machine name on which the
 /// object was last updated</param>
 /// <param name="versionNumber">The version number</param>
 public OptimisticLockingVersionNumberDB(BusinessObject busObj,
                                         IBOProp dateLastUpdated,
                                         IBOProp userLastUpdated,
                                         IBOProp machineLastUpdated,
                                         IBOProp versionNumber)
 {
     _busObj = busObj;
     _dateLastUpdated = dateLastUpdated;
     _userLastUpdated = userLastUpdated;
     _machineLastUpdated = machineLastUpdated;
     _versionNumber = versionNumber;
     _operatingSystemUser = null;
 }
コード例 #27
0
        public ContactPersonPessimisticLockingDB()
        {
            IBOProp propDateLocked                = _boPropCol["DateTimeLocked"];
            IBOProp propUserLocked                = _boPropCol["UserLocked"];
            IBOProp propMachineLocked             = _boPropCol["MachineLocked"];
            IBOProp propOperatingSystemUserLocked = _boPropCol["OperatingSystemUserLocked"];

            _boPropLocked = _boPropCol["Locked"];

            SetConcurrencyControl(new PessimisticLockingDB(this, 15, propDateLocked,
                                                           propUserLocked, propMachineLocked,
                                                           propOperatingSystemUserLocked, _boPropLocked));
        }
コード例 #28
0
 ///<summary>
 /// This constructor initialises this update log with the BusinessObject to be updated.
 /// This businessobject is then searched for the default UserLastUpdated and DateLastUpdated properties 
 /// that are to be updated when the BusinessObject is updated.
 ///</summary>
 ///<param name="businessObject">The BusinessObject to be updated</param>
 public BusinessObjectLastUpdatePropertiesLog(IBusinessObject businessObject)
 {
     IBOPropCol boPropCol = businessObject.Props;
     string propName = "UserLastUpdated";
     if (boPropCol.Contains(propName))
     {
         _userLastUpdatedBoProp = boPropCol[propName];
     }
     propName = "DateLastUpdated";
     if (boPropCol.Contains(propName))
     {
         _dateLastUpdatedBoProp = boPropCol[propName];
     }
 }
コード例 #29
0
ファイル: TestBoKey.cs プロジェクト: SaberZA/habanero
 public void TestIndexerPropertyNotFound()
 {
     try
     {
         IBOKey  boKey = _keyDef1.CreateBOKey(_boPropCol1);
         IBOProp prop  = boKey["invalidpropname"];
         Assert.Fail("Expected to throw an InvalidPropertyNameException");
     }
     //---------------Test Result -----------------------
     catch (InvalidPropertyNameException ex)
     {
         StringAssert.Contains("invalidpropname", ex.Message);
     }
 }
コード例 #30
0
 /// <summary>
 /// Sets the value of the <see cref="IBOProp"/> to a valid value.
 /// This is primarily used internally.
 /// </summary>
 /// <param name="boProp"></param>
 public virtual void SetPropValueToValidValue(IBOProp boProp)
 {
     if (boProp == null)
     {
         return;
     }
     if (boProp.Value != null &&
         !_defaultValueRegistry.IsRegistered(boProp.PropertyName) &&
         !_validValueGenRegistry.IsRegistered(boProp.PropDef))
     {
         return;
     }
     boProp.Value = this.GetValidPropValue(boProp);
 }
コード例 #31
0
        /// <summary>
        /// Returns a valid prop value for <paramref name="boProp"/>
        /// using any <see cref="IPropRule"/>s for the Prop.
        /// Note_ this value does take into consideration any
        /// <see cref="InterPropRule"/>s </summary>
        /// <param name="boProp"></param>
        /// <returns></returns>
        public virtual object GetValidPropValue(IBOProp boProp)
        {
            if (boProp == null)
            {
                return(null);
            }
            var propDef = boProp.PropDef;

            if (boProp.BusinessObject == null)
            {
                return(this.GetValidPropValue(propDef));
            }
            return(this.GetValidPropValue(boProp.BusinessObject, propDef.PropertyName));
        }
コード例 #32
0
ファイル: BOObjectID.cs プロジェクト: SaberZA/habanero
        /// <summary>
        /// Adds a property to the key
        /// </summary>
        /// <param name="boProp">The property to add</param>
        public override void Add(IBOProp boProp)
        {
            if (Count > 0)
            {
                throw new InvalidObjectIdException("A BOObjectID cannot have " +
                                                   "more than one property.");
            }
            if (boProp.PropertyType != typeof(Guid))
            {
                throw new InvalidObjectIdException("A BOObjectID cannot have " +
                                                   "a property of type other than Guid.");
            }

            base.Add(boProp);
        }
コード例 #33
0
ファイル: TestBOObjectID.cs プロジェクト: SaberZA/habanero
        public void Test_ObjectID_EqualsIdPropValue()
        {
            //--------------- Set up test pack ------------------
            BOObjectID primaryKey = CreateBOObjectID();
            Guid       id         = Guid.NewGuid();
            IBOProp    keyProp    = primaryKey[0];

            //--------------- Test Preconditions ----------------
            Assert.AreEqual(Guid.Empty, primaryKey.ObjectID);
            //--------------- Execute Test ----------------------
            keyProp.Value = id;
            //--------------- Test Result -----------------------
            Assert.AreEqual(id, keyProp.Value);
            Assert.AreEqual(id, primaryKey.ObjectID);
        }
コード例 #34
0
ファイル: TestBoKey.cs プロジェクト: SaberZA/habanero
        public void TestIndexerIntegerOutOfRange()
        {
            try
            {
                IBOKey  boKey = _keyDef1.CreateBOKey(_boPropCol1);
                IBOProp prop  = boKey[2];

                Assert.Fail("Expected to throw an IndexOutOfRangeException");
            }
            //---------------Test Result -----------------------
            catch (IndexOutOfRangeException ex)
            {
                StringAssert.Contains("the collection does not contain that many items", ex.Message);
            }
        }
コード例 #35
0
        /// <summary>
        /// This property returns the
        /// Returns a string containing the database field name and the
        /// persisted value, in the format of:<br/>
        /// "[fieldname] = '[value]'" (eg. "children = '2'")<br/>
        /// If a sql statement is provided, then the arguments are added
        /// in parameterised form.
        /// </summary>
        /// <param name="prop"></param>
        /// <param name="sql">A sql statement used to generate and track parameters</param>
        /// <returns>Returns a string</returns>
        private static string PersistedDatabaseNameFieldNameValuePair(IBOProp prop, SqlStatement sql)
        {
            if (prop.PersistedPropertyValue == null)
            {
                return(sql.Connection.SqlFormatter.DelimitField(prop.DatabaseFieldName + " is NULL "));
            }
            if (sql == null)
            {
                return(prop.DatabaseFieldName + " = '" + prop.PersistedPropertyValueString + "'");
            }
            string paramName = sql.ParameterNameGenerator.GetNextParameterName();

            sql.AddParameter(paramName, prop.PersistedPropertyValue, prop.PropertyType);
            return(sql.Connection.SqlFormatter.DelimitField(prop.DatabaseFieldName) + " = " + paramName);
        }
コード例 #36
0
        ///<summary>
        /// This constructor initialises this update log with the BusinessObject to be updated.
        /// This businessobject is then searched for the default UserLastUpdated and DateLastUpdated properties
        /// that are to be updated when the BusinessObject is updated.
        ///</summary>
        ///<param name="businessObject">The BusinessObject to be updated</param>
        public BusinessObjectLastUpdatePropertiesLog(IBusinessObject businessObject)
        {
            IBOPropCol boPropCol = businessObject.Props;
            string     propName  = "UserLastUpdated";

            if (boPropCol.Contains(propName))
            {
                _userLastUpdatedBoProp = boPropCol[propName];
            }
            propName = "DateLastUpdated";
            if (boPropCol.Contains(propName))
            {
                _dateLastUpdatedBoProp = boPropCol[propName];
            }
        }
コード例 #37
0
ファイル: TestBoPropCol.cs プロジェクト: kevinbosman/habanero
 public void TestPropDefColIsValid()
 {
     mProp = mBOPropCol["Prop2"];
     try
     {
         mProp.Value = "Prop Value fdfdfdf ff";
     }
     catch (InvalidPropertyValueException)
     {
     }
     mProp = mBOPropCol["PropName"];
     string reason;
     Assert.IsFalse(mBOPropCol.IsValid(out reason));
     Assert.IsTrue(reason.Length > 0);
 }
コード例 #38
0
ファイル: TestBoPropCol.cs プロジェクト: SaberZA/habanero
        public void TestPropDefColIsValid()
        {
            mProp = mBOPropCol["Prop2"];
            try
            {
                mProp.Value = "Prop Value fdfdfdf ff";
            }
            catch (InvalidPropertyValueException)
            {
            }
            mProp = mBOPropCol["PropName"];
            string reason;

            Assert.IsFalse(mBOPropCol.IsValid(out reason));
            Assert.IsTrue(reason.Length > 0);
        }
コード例 #39
0
ファイル: BOObjectID.cs プロジェクト: kevinbosman/habanero
        /// <summary>
        /// Adds a property to the key
        /// </summary>
        /// <param name="boProp">The property to add</param>
        public override void Add(IBOProp boProp)
        {
            
            if (Count > 0)
            {
                throw new InvalidObjectIdException("A BOObjectID cannot have " +
                    "more than one property.");
            }
            if (boProp.PropertyType != typeof(Guid))
            {
                throw new InvalidObjectIdException("A BOObjectID cannot have " +
                    "a property of type other than Guid.");
            }

            base.Add(boProp);
        }
コード例 #40
0
        public void TestBoProp_ChangesWhen_TextBoxTextChanges()
        {
            //---------------Set up test pack-------------------
            _mapper.BusinessObject = _shape;
            TextBoxMapperStrategyWin strategy =
                (TextBoxMapperStrategyWin)GetControlFactory().CreateTextBoxMapperStrategy();
            IBOProp boProp = _shape.Props["ShapeName"];

            strategy.AddKeyPressEventHandler(_mapper, boProp);
            strategy.AddUpdateBoPropOnTextChangedHandler(_mapper, boProp);
            _mapper.Control.Text = "TestString";
            //---------------Execute Test ----------------------

            //---------------Test Result -----------------------
            Assert.AreEqual("TestString", boProp.Value);
            //---------------Tear down -------------------------
        }
コード例 #41
0
ファイル: ContactPerson.cs プロジェクト: kevinbosman/habanero
        protected override void ConstructFromClassDef(bool newObject)
        {
            base.ConstructFromClassDef(newObject);

            mPropDateLastUpdated = _boPropCol["DateLastUpdated"];
            mPropUserLastUpdated = _boPropCol["UserLastUpdated"];
            mPropMachineLastUpdated = _boPropCol["MachineLastUpdated"];
            mPropVersionNumber = _boPropCol["VersionNumber"];

            //SetConcurrencyControl(new OptimisticLockingVersionNumberDB(this,mPropDateLastUpdated,
            //                                                         mPropUserLastUpdated, mPropMachineLastUpdated,
            //                                                         mPropVersionNumber));
            //SetTransactionLog(new TransactionLogTable("TransactionLog",
            //                                          "DateTimeUpdated",
            //                                          "WindowsUser",
            //                                          "LogonUser",
            //                                          "MachineName",
            //                                          "BusinessObjectTypeName",
            //                                          "CRUDAction",
            //                                          "DirtyXML"));
        }
コード例 #42
0
 internal UpdateStatementGeneratorLocking(BusinessObject bo, IBOProp boPropLocked, IDatabaseConnection connection)
     : base(bo, connection)
 {
     if (boPropLocked == null) throw new ArgumentNullException("boPropLocked");
     _boPropLocked = boPropLocked;
 }
コード例 #43
0
 private static IBOProp OrphanFromBOStatus(IBOProp prop)
 {
     ((BOProp)prop).UpdatesBusinessObjectStatus = false;
     return prop;
 }
コード例 #44
0
ファイル: RelProp.cs プロジェクト: kevinbosman/habanero
 /// <summary>
 /// Constructor to initialise a new property
 /// </summary>
 /// <param name="mRelPropDef">The relationship property definition</param>
 /// <param name="lBoProp">The property</param>
 internal RelProp(RelPropDef mRelPropDef, IBOProp lBoProp)
 {
     this._relPropDef = mRelPropDef;
     _boProp = lBoProp;
     lBoProp.Updated += (sender, e) => FirePropValueUpdatedEvent();
 }
コード例 #45
0
ファイル: TestBoPropCol.cs プロジェクト: kevinbosman/habanero
        public void TestDirtyXml()
        {
            mProp = mBOPropCol["Prop2"];
            mProp.InitialiseProp("Prop2-Orig");
            mProp.Value = "Prop2-New";
            Assert.IsTrue(mProp.IsDirty);

            mProp = mBOPropCol["PropName"];
            mProp.InitialiseProp("Propn-Orig");
            mProp.Value = "PropName-new";
            Assert.IsTrue(mProp.IsDirty);

            mPropDef = new PropDef("Prop3", typeof(string), PropReadWriteRule.ReadOnly, null);
            mPropDef.AddPropRule( new PropRuleString(mPropDef.PropertyName, "Test", 1, 40, null));
            mBOPropCol.Add(mPropDef.CreateBOProp(false));
            mProp = mBOPropCol["Prop3"];
            mProp.InitialiseProp("Prop3-new");
            Assert.IsFalse(mProp.IsDirty);
            const string dirtyXml = "<Properties><Prop2><PreviousValue>Prop2-Orig</PreviousValue><NewValue>Prop2-New</NewValue></Prop2><PropName><PreviousValue>Propn-Orig</PreviousValue><NewValue>PropName-new</NewValue></PropName></Properties>";
            Assert.AreEqual(dirtyXml, mBOPropCol.DirtyXml);
        }
コード例 #46
0
 /// <summary>
 /// Constructor to initialise a new event argument
 /// with the affected BOProp
 /// </summary>
 /// <param name="prop">The affected BOProp</param>
 public BOPropEventArgs(IBOProp prop)
 {
     _prop = prop;
 }
コード例 #47
0
 /// <summary>
 /// Sets the value of the <see cref="IBOProp"/> to a valid value.
 /// This is primarily used internally.
 /// </summary>
 /// <param name="boProp"></param>
 public virtual void SetPropValueToValidValue(IBOProp boProp)
 {
     if (boProp == null) return;
     if (boProp.Value != null
         && !_defaultValueRegistry.IsRegistered(boProp.PropertyName)
         && !_validValueGenRegistry.IsRegistered(boProp.PropDef)) return;
     boProp.Value = this.GetValidPropValue(boProp);
 }
コード例 #48
0
 public bool IsAuthorised(IBOProp prop, BOPropActions actionToPerform)
 {
     return (actionsAllowed.Contains(actionToPerform));
 }
コード例 #49
0
 /// <summary>
 /// Returns a valid prop value for <paramref name="boProp"/>
 /// using any <see cref="IPropRule"/>s for the Prop.
 /// Note_ this value does take into consideration any 
 /// <see cref="InterPropRule"/>s </summary>
 /// <param name="boProp"></param>
 /// <returns></returns>
 public virtual object GetValidPropValue(IBOProp boProp)
 {
     if (boProp == null) return null;
     var propDef = boProp.PropDef;
     if (boProp.BusinessObject == null) return this.GetValidPropValue(propDef);
     return this.GetValidPropValue(boProp.BusinessObject, propDef.PropertyName);
 }
コード例 #50
0
 ///<summary>
 /// This constructor initialises this update log with the UserLastUpdated and DateLastUpdated properties 
 /// that are to be updated when the BusinessObject is updated.
 ///</summary>
 ///<param name="userLastUpdatedBoProp">The UserLastUpdated property</param>
 ///<param name="dateLastUpdatedBoProp">The DateLastUpdated property</param>
 public BusinessObjectLastUpdatePropertiesLog(IBOProp userLastUpdatedBoProp, IBOProp dateLastUpdatedBoProp)
 {
     _userLastUpdatedBoProp = userLastUpdatedBoProp;
     _dateLastUpdatedBoProp = dateLastUpdatedBoProp;
 }
コード例 #51
0
 ///<summary>
 /// This constructor initialises this update log with the UserLastUpdated and DateLastUpdated properties 
 /// that are to be updated when the BusinessObject is updated, and the ISecurityController to be used to 
 /// retrieve the current user name.
 ///</summary>
 ///<param name="userLastUpdatedBoProp">The UserLastUpdated property</param>
 ///<param name="dateLastUpdatedBoProp">The DateLastUpdated property</param>
 ///<param name="securityController">The ISecurityController class</param>
 public BusinessObjectLastUpdatePropertiesLog(IBOProp userLastUpdatedBoProp, IBOProp dateLastUpdatedBoProp, ISecurityController securityController)
     : this(userLastUpdatedBoProp, dateLastUpdatedBoProp)
 {
     _securityController = securityController;
 }
コード例 #52
0
 public BOPropTester(IBOProp boProp)
 {
     if (boProp == null) throw new ArgumentNullException("boProp");
     BOProp = boProp;
 }
コード例 #53
0
ファイル: TestBoProp.cs プロジェクト: kevinbosman/habanero
 public void init()
 {
     _propDef = new PropDef("PropName", typeof(string), PropReadWriteRule.ReadWrite, null);
     _prop = _propDef.CreateBOProp(false);
 }
		public ContactPersonPessimisticLockingDB()
		{
			IBOProp propDateLocked = _boPropCol["DateTimeLocked"];
			IBOProp propUserLocked = _boPropCol["UserLocked"];
			IBOProp propMachineLocked = _boPropCol["MachineLocked"];
			IBOProp propOperatingSystemUserLocked = _boPropCol["OperatingSystemUserLocked"];
			_boPropLocked = _boPropCol["Locked"];

			SetConcurrencyControl(new PessimisticLockingDB(this, 15, propDateLocked,
														   propUserLocked, propMachineLocked,
														   propOperatingSystemUserLocked, _boPropLocked));
		}
コード例 #55
0
ファイル: TestBoProp.cs プロジェクト: kevinbosman/habanero
 private static void WriteTestValues(IBOProp boProp)
 {
     boProp.Value = "TestValue";
     Assert.AreEqual("TestValue", boProp.Value, "BOProp value should now have the given value.");
     boProp.Value = "TestValue2";
     Assert.AreEqual("TestValue2", boProp.Value, "BOProp value should now have the given value.");
     boProp.Value = "TestValue3";
     Assert.AreEqual("TestValue3", boProp.Value, "BOProp value should now have the given value.");
     boProp.Value = "TestValue4";
     Assert.AreEqual("TestValue4", boProp.Value, "BOProp value should now have the given value.");
 }
コード例 #56
0
 /// <summary>
 /// Constructor to initialise a new event argument
 /// with the updated <see cref="IBOProp"/> and the <see cref="IBusinessObject"/> to which the prop belongs.
 /// </summary>
 /// <param name="businessObject">The <see cref="IBusinessObject"/> to which the updated <see cref="IBOProp"/> belongs.</param>
 /// <param name="prop">The updated <see cref="IBOProp"/>.</param>
 public BOPropUpdatedEventArgs(IBusinessObject businessObject, IBOProp prop)
 {
     _businessObject = businessObject;
     _prop = prop;
 }
コード例 #57
0
 public void SetBOProp(IBOProp prop)
 {
     _property = prop;
 }
コード例 #58
0
 /// <summary>
 /// Constructor as before, but allows the operating system on which
 /// the update was done to be specified
 /// </summary>
 public OptimisticLockingVersionNumberDB(BusinessObject busObj,
                                         IBOProp dateLastUpdated,
                                         IBOProp userLastUpdated,
                                         IBOProp machineLastUpdated,
                                         IBOProp versionNumber,
                                         IBOProp operatingSystemUser)
     : this(busObj, dateLastUpdated, userLastUpdated, machineLastUpdated, versionNumber)
 {
     _operatingSystemUser = operatingSystemUser;
 }