/// <summary>
 /// Creates the appropriate PropertyMapper based on the BusinessObject and propertyName.
 /// </summary>
 /// <param name="businessObject"></param>
 /// <param name="propertyName"></param>
 /// <returns></returns>
 public static IBOPropertyMapper CreateMapper(IBusinessObject businessObject, string propertyName)
 {
     var originalPropertyName = propertyName;
     if (IsReflectiveProp(propertyName))
     {
         IBusinessObject relatedBo = businessObject;
         while (propertyName.Contains(RELATIONSHIP_SEPARATOR))
         {
             //Get the first property name
             string relationshipName = propertyName.Substring(0, propertyName.IndexOf("."));
             propertyName = propertyName.Remove(0, propertyName.IndexOf(".") + 1);
             var newRelatedBo = relatedBo.Relationships.GetRelatedObject(relationshipName);
             if (newRelatedBo == null)
             {
                 var invalidReason = string.Format("The '{0}' relationship of the '{1}' returned null, therefore the '{2}' property could not be accessed.", relationshipName, relatedBo.GetType().Name, propertyName);
                 return new NullBOPropertyMapper(originalPropertyName, invalidReason) { BusinessObject = businessObject };
             }
             relatedBo = newRelatedBo;
         }
         return new ReflectionPropertyMapper(propertyName) { BusinessObject = relatedBo };
     }
     try
     {
         return new BOPropertyMapper(propertyName) { BusinessObject = businessObject };
     }
     catch (InvalidPropertyException)
     {
         //If the BOProp is not found then try a ReflectiveProperty.
         return new ReflectionPropertyMapper(propertyName) { BusinessObject = businessObject };
     }
 }
 /// <summary>
 /// Constructor for <see cref="TransactionalSingleRelationship"/>
 /// </summary>
 /// <param name="relationship"></param>
 /// <param name="relatedBO"></param>
 protected TransactionalSingleRelationship(IRelationship relationship, IBusinessObject relatedBO)
 {
     if (relatedBO == null) throw new ArgumentNullException("relatedBO");
     _transactionID = Guid.NewGuid().ToString();
     _relationship = relationship;
     _relatedBO = relatedBO;
 }
 ///<summary>
 /// Deletes the given business object
 ///</summary>
 ///<param name="businessObject">The business object to delete</param>
 public void DeleteBusinessObject(IBusinessObject businessObject)
 {
     string message;
     if (CustomConfirmationMessageDelegate != null)
     {
         message = CustomConfirmationMessageDelegate(businessObject);
     }
     else
     {
         message = string.Format("Are you certain you want to delete the object '{0}'", businessObject);
     }
     Confirmer.Confirm(message, delegate(bool confirmed)
         {
             if (!confirmed) return;
             var defaultBODeletor = new DefaultBODeletor();
             try
             {
                 defaultBODeletor.DeleteBusinessObject(businessObject);
             }
             catch (Exception ex)
             {
                 GlobalRegistry.UIExceptionNotifier.Notify(ex, "", "Error Deleting");
             }
         });
 }
 /// <summary>
 /// Constructor for a new initialiser
 /// </summary>
 /// <param name="parentObject">The parent for the relationship</param>
 /// <param name="relationship">The relationship object</param>
 /// <param name="correspondingRelationshipName">The corresponding
 /// relationship name</param>
 public RelationshipObjectInitialiser(IBusinessObject parentObject, RelationshipDef relationship,
                                      string correspondingRelationshipName)
 {
     _parentObject = parentObject;
     _relationship = relationship;
     _correspondingRelationshipName = correspondingRelationshipName;
 }
 public void CancelEditsToBusinessObject(IBusinessObject bo)
 {
     bo.CancelEdits();
     if (bo.Status.IsNew)
     {
         bo.MarkForDelete();
     }
 }
 public AutorController(
     IBusinessObject<Autor> bo,
     IMapper<Autor, AutorModel> mapper,
     IMapper<AutorModel, Autor> modelMapper)
 {
     BO = bo;
     Mapper = mapper;
     ModelMapper = modelMapper;
 }
 public GeneroController(
     IBusinessObject<Genero> bo,
     IMapper<Genero, GeneroModel> mapper,
     IMapper<GeneroModel, Genero> modelMapper)
 {
     BO = bo;
     Mapper = mapper;
     ModelMapper = modelMapper;
 }
        /// <summary>
        /// Initialises the given object
        /// </summary>
        /// <param name="objToInitialise">The object to initialise</param>
        public void InitialiseObject(IBusinessObject objToInitialise)
        {
            BusinessObject newBo = (BusinessObject) objToInitialise;
			foreach (RelPropDef propDef in _relationship.RelKeyDef)
			{
                newBo.SetPropertyValue(propDef.OwnerPropertyName,
                                       _parentObject.GetPropertyValue(propDef.RelatedClassPropName));
            }
            newBo.Relationships.SetRelatedObject(_correspondingRelationshipName, _parentObject);
        }
 /// <summary>
 /// Constructs a DTO for a Business Object.
 /// </summary>
 /// <param name="businessObject"></param>
 public BusinessObjectDTO(IBusinessObject businessObject) {
     ClassDefName = businessObject.ClassDef.ClassName;
     ClassName = businessObject.ClassDef.ClassNameExcludingTypeParameter;
     AssemblyName = businessObject.ClassDef.AssemblyName;
     foreach (IBOProp boProp in businessObject.Props)
     {
         Props[boProp.PropertyName.ToUpper()] = boProp.Value;
     }
     ID = businessObject.ID.ToString();
 }
        internal static void TestUpdate(IBusinessObject busObject, object newValue, string columnName)
        {
            ObjectStateEntry stateEntry;
            BsoArchiveEntities.Current.ObjectStateManager.TryGetObjectStateEntry(busObject, out stateEntry);

            var createdProps = stateEntry.CurrentValues.DataRecordInfo.FieldMetadata;

            var prop = createdProps.FirstOrDefault(p => p.FieldType.Name.ToUpper() == columnName.ToUpper());
            stateEntry.CurrentValues.SetValue(prop.Ordinal, newValue);
        }
 /// <summary>
 /// Constructor to initialise the exception with details regarding the
 /// object whose record was deleted
 /// </summary>
 /// <param name="bo">The business object in question</param>
 /// <param name="message">Additional err message</param>
 public BusObjDeleteException(IBusinessObject bo, string message):
     base(String.IsNullOrEmpty(message) ? string.Format(
         "You cannot delete the '{0}', as the IsDeletable is set to false for the object. " +
         "ObjectID: {1}, also identified as {2}",
         bo.ClassDef.ClassName, bo.ID, bo) : message, 
         !String.IsNullOrEmpty(message) ? new Exception(
             string.Format(
                 "You cannot delete the '{0}', as the IsDeletable is set to false for the object. " +
                 "ObjectID: {1}, also identified as {2}",
                 bo.ClassDef.ClassName, bo.ID, bo)) : null)
 {
 }
 ///<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];
     }
 }
 ///<summary>
 /// Deletes the given business object
 ///</summary>
 ///<param name="businessObject">The business object to delete</param>
 public virtual void DeleteBusinessObject(IBusinessObject businessObject)
 {
     try
     {
         businessObject.MarkForDelete();
         var committer = BORegistry.DataAccessor.CreateTransactionCommitter();
         committer.AddBusinessObject(businessObject);
         committer.CommitTransaction();
     }
     catch (Exception)
     {
         businessObject.CancelEdits();
         throw;
     }
 }
        internal static void UpdateObject(IBusinessObject busObject, object newValue, string columnName)
        {
            ObjectStateEntry stateEntry;
            BsoArchiveEntities.Current.ObjectStateManager.TryGetObjectStateEntry(busObject, out stateEntry);

            var createdProps = stateEntry.CurrentValues.DataRecordInfo.FieldMetadata;

            var prop = createdProps.FirstOrDefault(p => p.FieldType.Name.ToUpper() == columnName.ToUpper());

            if (prop.FieldType == null)
                return;

            var value = EFUtility.MapType(newValue, prop.FieldType.TypeUsage.EdmType);

            stateEntry.CurrentValues.SetValue(prop.Ordinal, value);
        }
 ///<summary>
 /// Add an object of type business object to the transaction.
 /// The DBTransactionCommiter wraps this Business Object in the
 /// appropriate Transactional Business Object
 ///</summary>
 ///<param name="businessObject"></param>
 public void AddBusinessObject(IBusinessObject businessObject)
 {
     if (_myDataAccessor == null)
     {
         _myDataAccessor = GetDataAccessorForType(businessObject.GetType());
         _transactionCommitter = _myDataAccessor.CreateTransactionCommitter();
     } else
     {
         IDataAccessor dataAccessorToUseForType = GetDataAccessorForType(businessObject.GetType());
         if (dataAccessorToUseForType != _myDataAccessor)
         {
             throw new HabaneroDeveloperException("A problem occurred while trying to save, please see log for details", string.Format("A BusinessObject of type {0} was added to a TransactionCommitterMultiSource which has been set up with a different source to this type.", businessObject.GetType().FullName));
         }
     }
     _transactionCommitter.AddBusinessObject(businessObject);
 }
        public static void GetBrokenRulesString(IBusinessObject currentObj,
                List<IBusinessObject> checkEntities,
                List<string> errorMessages,
                System.Data.Objects.DataClasses.EntityObject parent)
        {
            if (checkEntities.Contains(currentObj))
                return;

            checkEntities.Add(currentObj);

            if (parent == null)
                errorMessages.Add(currentObj.GetCurrentBrokenRules());
            else
                errorMessages.Add(currentObj.GetCurrentBrokenRules());

            if (IsNew(currentObj))
                return;

            foreach (Adage.EF.Interfaces.RelatedObject eachObj in currentObj.RelatedObjects)
            {
                IRelatedEnd childColl;
                if (eachObj.RelatedType == RelatedEnum.Many)
                {
                    childColl = eachObj.GetRelatedEnd((EntityObject)currentObj);
                    if (childColl == null || childColl.IsLoaded == false)
                    {
                        continue;
                    }
                }
                else
                {
                    if (eachObj.GetReference((EntityObject)currentObj).IsLoaded == false)
                    {
                        continue;
                    }

                    childColl = eachObj.GetRelatedEnd((EntityObject)currentObj);
                }

                foreach (Adage.EF.Interfaces.IBusinessObject eachChild in childColl)
                {
                    eachChild.FindBrokenRules(checkEntities,
                        errorMessages, (EntityObject)currentObj);
                }
            }
        }
 /// <summary>
 /// Constructor to initialise the exception with a set of details
 /// regarding the editing of the object
 /// </summary>
 /// <param name="className">The class name</param>
 /// <param name="userName">The user name editing the record</param>
 /// <param name="machineName">The machine name editing the record</param>
 /// <param name="dateUpdated">The date that the editing took place</param>
 /// <param name="objectID">The object's ID</param>
 /// <param name="obj">The object in question</param>
 public BusObjBeginEditConcurrencyControlException(string className,
     string userName,
     string machineName,
     DateTime dateUpdated,
     string objectID,
     IBusinessObject obj)
     :
         base("You cannot Edit '" + className +
              "', as another user has edited this record. \n" +
              "UserName: "******"[Unknown]") +
              " \nMachineName: " +
              (machineName.Length > 0 ? machineName : "[Unknown]") +
              " \nDateUpdated: " +
              dateUpdated.ToString("dd MMM yyyy HH:mm:ss:fff") +
              " \nObjectID: " + objectID, obj)
 {
 }
        public CloseBOEditorDialogResult ShowDialog(IBusinessObject businessObject)
        {
            if (businessObject == null)
            {
                BOEditorDialogResult = CloseBOEditorDialogResult.CloseWithoutSaving;
                this.Close();
                return BOEditorDialogResult;
            }


            var isInValidState = businessObject.Status.IsValid();
            var isDirty = businessObject.Status.IsDirty;
            SaveAndCloseBtn.Enabled = isInValidState;
            this.BOEditorDialogResult = CloseBOEditorDialogResult.CancelClose;


            if (!isDirty)
            {
                this.BOEditorDialogResult = CloseBOEditorDialogResult.CloseWithoutSaving;
                this.Close();
                return this.BOEditorDialogResult;
            }
            string isValidString;
            if (isInValidState)
            {
                isValidString = " and is in a valid state to be saved";
            }

            else
            {
                string isValidMessage = businessObject.Status.IsValidMessage;

                isValidString = " and is not in a valid state to be saved: " + Environment.NewLine +
                                isValidMessage + Environment.NewLine;
            }
            var fullDisplayName = businessObject.ClassDef.DisplayName
                    + " '" + businessObject.ToString() + "'";
            _label.Text = "The " + fullDisplayName + " is has been edited" + isValidString +
                          ". Please choose the appropriate action";
            this.SaveAndCloseBtn.Enabled = isInValidState;
            ShowForm();
            return this.BOEditorDialogResult;
        }
 /// <summary>
 /// Constructor to initialise the exception with a set of concurrency
 /// details
 /// </summary>
 /// <param name="className">The class name</param>
 /// <param name="userName">The user name that edited the record</param>
 /// <param name="machineName">The machine name that edited the record</param>
 /// <param name="dateUpdated">The date that the record was edited</param>
 /// <param name="objectID">The object ID</param>
 /// <param name="obj">The object whose record was edited</param>
 public BusObjOptimisticConcurrencyControlException(string className,
     string userName,
     string machineName,
     DateTime dateUpdated,
     string objectID,
     IBusinessObject obj) :
         base("You cannot save the changes to '" + className +
              "', as another user has edited this record. \n" +
              "UserName: "******"[Unknown]") +
              " \nMachineName: " +
              (machineName.Length > 0 ? machineName : "[Unknown]") +
              " \nDateUpdated: " +
              dateUpdated.ToString("dd MMM yyyy HH:mm:ss:fff") +
              " \nObjectID: " + objectID, obj)
 {
     _userNameEdited = (userName.Length > 0 ? userName : "******");
     _machineNameEdited = (machineName.Length > 0 ? machineName : "[Unknown]");
     _dateUpdated = dateUpdated;
     _objectID = objectID;
     _obj = obj;
     _className = className;
 }
        public static bool CheckIsValid(IBusinessObject currentObj,
                List<IBusinessObject> checkEntities)
        {
            if (checkEntities.Contains(currentObj))
                return true;

            checkEntities.Add(currentObj);
            foreach (Adage.EF.Interfaces.RelatedObject eachObj in currentObj.RelatedObjects)
            {
                IRelatedEnd childColl;
                if (eachObj.RelatedType == RelatedEnum.Many)
                {
                    childColl = eachObj.GetRelatedEnd((EntityObject)currentObj);
                    if (childColl == null || childColl.IsLoaded == false)
                    {
                        continue;
                    }
                }
                else
                {
                    if (eachObj.GetReference((EntityObject)currentObj).IsLoaded == false)
                    {
                        continue;
                    }

                    childColl = eachObj.GetRelatedEnd((EntityObject)currentObj);
                }

                foreach (IBusinessObject eachChild in childColl)
                {
                    if (eachChild.CheckIsValid(checkEntities) == false)
                        return false;
                }
            }

            return true;
        }
 ///<summary>
 /// Deletes the <paramref name="selectedBo"/> using the
 /// <see cref="IReadOnlyGridControl.BusinessObjectDeletor"/>.
 /// Rolls back the delete and notifies the user if any errors occur
 ///</summary>
 ///<param name="selectedBo"></param>
 public void DeleteBusinessObject(IBusinessObject selectedBo)
 {
     GridControl.SelectedBusinessObject = null;
     try
     {
         GridControl.BusinessObjectDeletor.DeleteBusinessObject(selectedBo);
     }
     catch (Exception ex)
     {
         try
         {
             selectedBo.CancelEdits();
             GridControl.SelectedBusinessObject = selectedBo;
         }
             // ReSharper disable EmptyGeneralCatchClause
         catch
         {
             //Do nothing
         }
         // ReSharper restore EmptyGeneralCatchClause
         GlobalRegistry.UIExceptionNotifier.Notify(ex, "There was a problem deleting",
                                                   "Problem Deleting");
     }
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="BusinessObjectSavingEventArgs"/> class.
 /// </summary>
 /// <param name="businessObject">The business object.</param>
 public BusinessObjectSavingEventArgs(IBusinessObject businessObject) : base(businessObject)
 {
     Cancel = false;
 }
 private static InsertStatementGenerator CreateInsertStatementGenerator(IBusinessObject shape, string databaseVendor)
 {
     var databaseConnection = MyDBConnection.GetDatabaseConfig(databaseVendor).GetDatabaseConnection();
     return new InsertStatementGenerator(shape, databaseConnection);
 }
 ///<summary>
 /// Refreshes the row values for the specified <see cref="IBusinessObject"/>.
 ///</summary>
 ///<param name="businessObject">The <see cref="IBusinessObject"/> for which the row must be refreshed.</param>
 public void RefreshBusinessObjectRow(IBusinessObject businessObject)
 {
     this._manager.RefreshBusinessObjectRow(businessObject);
 }
Exemple #25
0
 public static void AfterChange_Name(IBusinessObject obj)
 {
     obj.Caption  = obj.Name;
     obj.FullName = "BusinessObject." + obj.BusinessObjectName;
 }
Exemple #26
0
 public List <IProperty> Get_DefaultPropertySources(IBusinessObject obj)
 {
     return(obj.AllMembers.OfType <IProperty>().Where(x => !(x.ExtendSetting is IImageProperty)).ToList());
 }
 private void UpdateBusinessObject(IBusinessObject businessObject)
 {
     RefreshBusinessObjectNode(businessObject);
 }
Exemple #28
0
        /// <summary>
        /// Saves the business object.
        /// </summary>
        /// <param name="document"><see cref="CommercialDocument"/> to save.</param>
        /// <returns>Xml containing result of oper</returns>
        public XDocument SaveBusinessObject(CommercialDocument document)
        {
            DictionaryMapper.Instance.CheckForChanges();

            this._CheckTechnologyNameExistence(document);

            //load alternate version
            if (!document.IsNew)
            {
                IBusinessObject alternateBusinessObject = this.mapper.LoadBusinessObject(document.BOType, document.Id.Value);
                document.SetAlternateVersion(alternateBusinessObject);
            }

            this.CheckDateDifference(document);

            //update status
            document.UpdateStatus(true);

            if (document.AlternateVersion != null)
            {
                document.AlternateVersion.UpdateStatus(false);
            }

            this.ExecuteCustomLogic(document);
            this.ExecuteDocumentOptions(document);

            //validate
            document.Validate();

            //update status
            document.UpdateStatus(true);

            if (document.AlternateVersion != null)
            {
                document.AlternateVersion.UpdateStatus(false);
            }

            SqlConnectionManager.Instance.BeginTransaction();

            try
            {
                DictionaryMapper.Instance.CheckForChanges();
                this.mapper.CheckBusinessObjectVersion(document);

                DocumentLogicHelper.AssignNumber(document, this.mapper);

                //Make operations list
                XDocument operations = XDocument.Parse("<root/>");

                document.SaveChanges(operations);

                if (document.AlternateVersion != null)
                {
                    document.AlternateVersion.SaveChanges(operations);
                }

                DocumentCategory category = document.DocumentType.DocumentCategory;

                if (operations.Root.HasElements)
                {
                    this.mapper.ExecuteOperations(operations);
                    this.mapper.UpdateDocumentInfoOnPayments(document);
                    this.mapper.CreateCommunicationXml(document);
                    this.mapper.UpdateDictionaryIndex(document);
                }

                Coordinator.LogSaveBusinessObjectOperation();

                document.SaveRelatedObjects();

                operations = XDocument.Parse("<root/>");

                document.SaveRelations(operations);

                if (document.AlternateVersion != null)
                {
                    ((CommercialDocument)document.AlternateVersion).SaveRelations(operations);
                }

                if (operations.Root.HasElements)
                {
                    this.mapper.ExecuteOperations(operations);
                }

                if (operations.Root.HasElements)
                {
                    this.mapper.CreateCommunicationXmlForDocumentRelations(operations); //generowanie paczek dla relacji dokumentow
                }
                XDocument returnXml = XDocument.Parse(String.Format(CultureInfo.InvariantCulture, "<root><id>{0}</id></root>", document.Id.ToUpperString()));

                //Custom validation
                this.mapper.ExecuteOnCommitValidationCustomProcedure(document);

                if (this.coordinator.CanCommitTransaction)
                {
                    if (!ConfigurationMapper.Instance.ForceRollbackTransaction)
                    {
                        SqlConnectionManager.Instance.CommitTransaction();
                    }
                    else
                    {
                        SqlConnectionManager.Instance.RollbackTransaction();
                    }
                }

                return(returnXml);
            }
            catch (SqlException sqle)
            {
                RoboFramework.Tools.RandomLogHelper.GetLog().Debug("FractusRefactorTraceCatch:84");
                Coordinator.ProcessSqlException(sqle, document.BOType, this.coordinator.CanCommitTransaction);
                throw;
            }
            catch (Exception)
            {
                RoboFramework.Tools.RandomLogHelper.GetLog().Debug("FractusRefactorTraceCatch:85");
                if (this.coordinator.CanCommitTransaction)
                {
                    SqlConnectionManager.Instance.RollbackTransaction();
                }
                throw;
            }
        }
        private void CompareDescendingValues(IComparer <BocListRow> comparer, IBusinessObject left, IBusinessObject right)
        {
            var rowLeft  = new BocListRow(0, left);
            var rowRight = new BocListRow(0, right);

            int compareResultLeftRight = comparer.Compare(rowLeft, rowRight);
            int compareResultRightLeft = comparer.Compare(rowRight, rowLeft);

            Assert.IsTrue(compareResultLeftRight > 0, "Right - Left >= zero.");
            Assert.IsTrue(compareResultRightLeft < 0, "Left - Right <= zero.");
        }
        private void CompareEqualValues(IComparer <BocListRow> comparer, IBusinessObject left, IBusinessObject right)
        {
            var rowLeft  = new BocListRow(0, left);
            var rowRight = new BocListRow(0, right);

            int compareResultLeftRight = comparer.Compare(rowLeft, rowRight);
            int compareResultRightLeft = comparer.Compare(rowRight, rowLeft);

            Assert.IsTrue(compareResultLeftRight == 0, "Left - Right != zero");
            Assert.IsTrue(compareResultRightLeft == 0, "Right - Left != zero");
        }
Exemple #31
0
 public BocCommandClickEventArgs(BocCommand command, IBusinessObject businessObject)
     : base(command)
 {
     _businessObject = businessObject;
 }
Exemple #32
0
 /// <summary>
 /// Populate fields in Control container with BusinessObject
 /// </summary>
 /// <param name="container"></param>
 /// <param name="iBiz"></param>
 protected void PopulateForm(Control container, IBusinessObject iBiz)
 {
     CICHelper.SetFieldValues(container.Controls, iBiz);
 }
Exemple #33
0
 /// <summary>
 /// Populates fields on Page with BusinessObject
 /// </summary>
 /// <param name="iBiz"></param>
 protected void PopulateForm(IBusinessObject iBiz)
 {
     PopulateForm(this, iBiz);
 }
Exemple #34
0
        //TODO: change this to do late instantiation of the relationships (lazy instantiation) so as to improve object instantiation time.

        /// <summary>
        /// Constructor to initialise a new relationship, specifying the
        /// business object that owns the relationships
        /// </summary>
        /// <param name="bo">The business object</param>
        public RelationshipCol(IBusinessObject bo)
        {
            _bo            = bo;
            _relationships = new Dictionary <string, IRelationship>();
        }
Exemple #35
0
        /// <summary>
        /// Contient l'ensemble de processus en fonction des règles défini dans le 'GetProcessRules'
        /// </summary>
        /// <param name="rule">Liste des règles à exécuter</param>
        /// <param name="IBusinessObject">Objet d'affaire d'information</param>
        /// <returns></returns>
        public Process DoBusinessProcess(RuleBusiness rule, ref IBusinessObject businessObject)
        {
            TBusinessObject businessObjectAdd = (TBusinessObject)businessObject;

            return(DoBusinessProcess(rule, businessObjectAdd));
        }
 public void Add(IBusinessObject obj)
 {
     objects.Add(obj);
 }
Exemple #37
0
        public void WithoutSetter()
        {
            IBusinessObject businessObject = Mixin.Get <BindableObjectMixin> (ObjectFactory.Create <SimpleBusinessObjectClass>(ParamList.Empty));

            businessObject.SetProperty("StringWithoutSetter", null);
        }
Exemple #38
0
 private static BOMapper CreateBOMapper(IBusinessObject bo)
 {
     return(new BOMapper(bo));
 }
Exemple #39
0
        private bool IsEqualTo(IBusinessObject businessObject)
        {
            Type t = this.GetType();

            ComparableCache[] cache = BusinessObject.PropertiesComparableCache[t];

            for (int i = 0; i < cache.Length; i++)
            {
                ComparableCache c = cache[i];

                object ourValue   = c.Property.GetValue(this, null);
                object otherValue = c.Property.GetValue(businessObject, null);

                Type type = c.Property.PropertyType;

                if (type == typeof(Boolean))
                {
                    if ((Boolean)ourValue != (Boolean)otherValue)
                    {
                        return(false);
                    }
                }
                else if (type == typeof(String))
                {
                    if (String.Compare((string)ourValue, (string)otherValue, StringComparison.Ordinal) != 0)
                    {
                        return(false);
                    }
                }
                else if (type == typeof(Decimal))
                {
                    if (!((decimal)ourValue).Equals((decimal)otherValue))
                    {
                        return(false);
                    }
                }
                else if (type == typeof(Decimal?))
                {
                    Decimal?ourDecimal   = (Decimal?)ourValue;
                    Decimal?otherDecimal = (Decimal?)otherValue;

                    if (ourDecimal != null && otherDecimal == null ||
                        ourDecimal == null && otherDecimal != null)
                    {
                        return(false);
                    }

                    if (ourDecimal != null && otherDecimal != null &&
                        ourDecimal.Value != otherDecimal.Value)
                    {
                        return(false);
                    }
                }
                else if (type == typeof(Int32))
                {
                    if (!((int)ourValue).Equals((int)otherValue))
                    {
                        return(false);
                    }
                }
                else if (type == typeof(Int32?))
                {
                    Int32?ourInt   = (Int32?)ourValue;
                    Int32?otherInt = (Int32?)otherValue;

                    if (ourInt != null && otherInt == null ||
                        ourInt == null && otherInt != null)
                    {
                        return(false);
                    }

                    if (ourInt != null && otherInt != null &&
                        ourInt.Value != otherInt.Value)
                    {
                        return(false);
                    }
                }
                else if (type == typeof(Guid))
                {
                    if ((Guid)ourValue != (Guid)otherValue)
                    {
                        return(false);
                    }
                }
                else if (type == typeof(Guid?))
                {
                    Guid?ourGuid   = (Guid?)ourValue;
                    Guid?otherGuid = (Guid?)otherValue;

                    if (ourGuid != null && otherGuid == null ||
                        ourGuid == null && otherGuid != null)
                    {
                        return(false);
                    }

                    if (ourGuid != null && otherGuid != null &&
                        ourGuid.Value != otherGuid.Value)
                    {
                        return(false);
                    }
                }
                else if (type == typeof(DateTime))
                {
                    if ((DateTime)ourValue != ((DateTime)otherValue))
                    {
                        return(false);
                    }
                }
                else if (type == typeof(DateTime?))
                {
                    DateTime?ourDateTime   = (DateTime?)ourValue;
                    DateTime?otherDateTime = (DateTime?)otherValue;

                    if (ourDateTime != null && otherDateTime == null ||
                        ourDateTime == null && otherDateTime != null)
                    {
                        return(false);
                    }

                    if (ourDateTime != null && otherDateTime != null &&
                        ourDateTime.Value != otherDateTime.Value)
                    {
                        return(false);
                    }
                }
                else if (type == typeof(XElement))
                {
                    XElement ourXElement   = (XElement)ourValue;
                    XElement otherXElement = (XElement)otherValue;

                    if (ourXElement != null && otherXElement == null ||
                        ourXElement == null && otherXElement != null)
                    {
                        return(false);
                    }

                    if (ourXElement != null && otherXElement != null &&
                        ourXElement.ToString() != otherXElement.ToString())
                    {
                        return(false);
                    }
                }
                else if (typeof(IBusinessObject).IsAssignableFrom(type))
                {
                    IBusinessObject ourObject   = (IBusinessObject)ourValue;
                    IBusinessObject otherObject = (IBusinessObject)otherValue;

                    if (ourObject != null && otherObject == null ||
                        ourObject == null && otherObject != null)
                    {
                        return(false);
                    }

                    if (ourObject != null && otherObject != null &&
                        ourObject.Id.Value != otherObject.Id.Value)
                    {
                        return(false);
                    }
                }
                else if (type.IsEnum)
                {
                    if ((int)ourValue != (int)otherValue)
                    {
                        return(false);
                    }
                }
                else
                {
                    throw new InvalidOperationException("Unknown type to compare");
                }
            }

            return(true);
        }
Exemple #40
0
 public IBusinessObject[] GetAllBase(IBusinessObject bus)
 {
     return(bus.Bases.ToArray().Union(bus.Bases.SelectMany(x => x.GetAllBase())).ToArray());
 }
Exemple #41
0
 public ExitInterviewFactorPresentationEntity(IObserver observer, IPresenter presenter, IBusinessObject businessObject)
     : base(observer, presenter, businessObject)
 {
 }
Exemple #42
0
 public static string Get_BusinessObjectName(IBusinessObject obj)
 {
     return("I" + obj.Name);
 }
Exemple #43
0
 protected override IDatabaseAgent Create(IBusinessObject businessObject)
 {
     return(new CompanyDatabaseAgent(businessObject));
 }
Exemple #44
0
 public List <IPropertyBase> Get_AllMembers(IBusinessObject obj)
 {
     return(obj.Properties.Union(obj.GetAllBase().SelectMany(x => x.Properties)).ToList());
 }
#pragma warning restore 168
        // ReSharper restore EmptyGeneralCatchClause
        /// <summary>
        /// See <see cref="IGridBase.GetBusinessObjectRow"/>
        /// </summary>
        public virtual IDataGridViewRow GetBusinessObjectRow(IBusinessObject businessObject)
        {
            if (businessObject == null) return null;
            Guid boIdGuid = businessObject.ID.ObjectID;
            foreach (IDataGridViewRow row in _gridBase.Rows)
            {
                if (GetRowObjectIDValue(row) == boIdGuid)
                {
                    return row;
                }
            }
            return null;
        }
Exemple #46
0
 public static void AfterConstruction(IBusinessObject obj)
 {
     obj.IsPersistent    = true;
     obj.IsRuntimeDefine = true;
 }
 private IBOProp GetBOProp(IBusinessObject bo)
 {
     return bo.Props[this.GridColumn.PropertyName];
 }
 public void SetSelectedBusinessObject(IBusinessObject bo)
 {
    SelectedBO = bo;
 }
 ///<summary>
 /// Refreshes the row values for the specified <see cref="IBusinessObject"/>.
 ///</summary>
 ///<param name="businessObject">The <see cref="IBusinessObject"/> for which the row must be refreshed.</param>
 public virtual void RefreshBusinessObjectRow(IBusinessObject businessObject)
 {
     if (DataSetProvider == null) return;
     DataSetProvider.UpdateBusinessObjectRowValues(businessObject);
 }
Exemple #50
0
 protected override IDatabaseAgent Create(IBusinessObject businessObject)
 {
     return(new InterviewGradeDatabaseAgent(businessObject));
 }
Exemple #51
0
 /// <summary>
 /// Default Delegate method for Confirming the Deletion of an object.
 /// </summary>
 /// <param name="selectedBo"></param>
 protected virtual void ConfirmDeleteObjectMethod(IBusinessObject selectedBo)
 {
     MessageBox.Show("Are you certain you want to delete the object '" + selectedBo + "'",
                     "Delete Object", MessageBoxButtons.YesNo,
                     (msgBoxSender, e1) => DeleteObjectMethod(((Form)msgBoxSender).DialogResult, selectedBo));
 }
        public void RenderSimpleColumnCellEditModeControl(
            HtmlTextWriter writer,
            BocSimpleColumnDefinition column,
            IBusinessObject businessObject,
            int columnIndex)
        {
            ArgumentUtility.CheckNotNull("writer", writer);
            ArgumentUtility.CheckNotNull("column", column);
            ArgumentUtility.CheckNotNull("businessObject", businessObject);

            if (!HasEditControl(columnIndex))
            {
                return;
            }

            ControlCollection validators = GetValidators(columnIndex);

            IBusinessObjectBoundEditableWebControl editModeControl = _rowEditModeControls[columnIndex];

            bool enforceWidth = column.EnforceWidth &&
                                !column.Width.IsEmpty &&
                                column.Width.Type != UnitType.Percentage;

            if (enforceWidth)
            {
                writer.AddStyleAttribute(HtmlTextWriterStyle.Width, column.Width.ToString(CultureInfo.InvariantCulture));
            }

            writer.AddAttribute(HtmlTextWriterAttribute.Class, "bocListEditableCell");
            writer.RenderBeginTag(HtmlTextWriterTag.Span); // Span Container

            if (_editModeHost.ShowEditModeValidationMarkers)
            {
                bool  isCellValid           = true;
                Image validationErrorMarker = _editModeHost.GetValidationErrorMarker();

                for (int i = 0; i < validators.Count; i++)
                {
                    BaseValidator validator = (BaseValidator)validators[i];
                    isCellValid &= validator.IsValid;
                    if (!validator.IsValid)
                    {
                        if (string.IsNullOrEmpty(validationErrorMarker.ToolTip))
                        {
                            validationErrorMarker.ToolTip = validator.ErrorMessage;
                        }
                        else
                        {
                            validationErrorMarker.ToolTip += "\r\n";
                            validationErrorMarker.ToolTip += validator.ErrorMessage;
                        }
                    }
                }
                if (!isCellValid)
                {
                    validationErrorMarker.RenderControl(writer);
                }
            }

            writer.AddAttribute(HtmlTextWriterAttribute.Class, "control");
            writer.RenderBeginTag(HtmlTextWriterTag.Span); // Span Control

            editModeControl.RenderControl(writer);

            writer.RenderEndTag(); // Span Control

            foreach (BaseValidator validator in validators)
            {
                writer.RenderBeginTag(HtmlTextWriterTag.Div);
                validator.RenderControl(writer);
                writer.RenderEndTag();

                if (!validator.IsValid &&
                    validator.Display == ValidatorDisplay.None &&
                    !_editModeHost.DisableEditModeValidationMessages)
                {
                    if (!string.IsNullOrEmpty(validator.CssClass))
                    {
                        writer.AddAttribute(HtmlTextWriterAttribute.Class, validator.CssClass);
                    }
                    else
                    {
                        writer.AddAttribute(HtmlTextWriterAttribute.Class, CssClassEditModeValidationMessage);
                    }
                    writer.RenderBeginTag(HtmlTextWriterTag.Div);
                    writer.Write(validator.ErrorMessage); // Do not HTML encode.
                    writer.RenderEndTag();
                }
            }

            writer.RenderEndTag(); // Span Container
        }
 private static void AssertPersonsAreEqual(IBusinessObject originalPerson, IBusinessObject deserialisedPerson)
 {
     foreach (IBOProp prop in originalPerson.Props)
     {
         Assert.AreEqual(prop.Value, deserialisedPerson.GetPropertyValue(prop.PropertyName));
     }
 }
Exemple #54
0
 public AlbumBusiness(IBusinessObject <AlbumViewerContext> parentBusiness) : base(parentBusiness)
 {
 }
 /// <summary>
 /// Constructor to initialise the generator
 /// </summary>
 /// <param name="bo">The business object whose properties are to
 /// be inserted</param>
 /// <param name="connection">A database connection</param>
 public InsertStatementGenerator(IBusinessObject bo, IDatabaseConnection connection)
 {
     _bo = (BusinessObject) bo;
     _connection = connection;
 }
 ///<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. The ISecurityController to be used to
 /// retrieve the current user name is also passed in.
 ///</summary>
 ///<param name="businessObject">The BusinessObject to be updated</param>
 ///<param name="securityController">The ISecurityController class</param>
 public BusinessObjectLastUpdatePropertiesLog(IBusinessObject businessObject, ISecurityController securityController)
     : this(businessObject)
 {
     _securityController = securityController;
 }
 ///<summary>
 /// Returns the row for the specified <see cref="IBusinessObject"/>.
 ///</summary>
 ///<param name="businessObject">The <see cref="IBusinessObject"/> to search for.</param>
 ///<returns>Returns the row for the specified <see cref="IBusinessObject"/>, 
 /// or null if the <see cref="IBusinessObject"/> is not found in the grid.</returns>
 public IDataGridViewRow GetBusinessObjectRow(IBusinessObject businessObject)
 {
     return GridBaseManager.GetBusinessObjectRow(businessObject);
 }
 private bool ContainsValue(IBusinessObject value)
 {
     return(value != null && Control.Items.Contains(value));
 }
Exemple #59
0
 public override int CompareTo(IBusinessObject other)
 {
     return(Date.CompareTo((other as Precipitation).Date));
 }
        /// <summary>
        /// Returns the TreeNode associated with a particular business object.
        /// </summary>
        /// <param name="businessObject"></param>
        /// <returns></returns>
        public ITreeNode GetBusinessObjectTreeNode(IBusinessObject businessObject)
        {
            NodeState nodeState = GetBusinessObjectNodeState(businessObject);

            return(nodeState != null ? nodeState.Node : null);
        }