Exemple #1
0
 internal override void DeepLoad(TransactionManager transactionManager, Payout entity, bool deep, DeepLoadType deepLoadType, Type[] childTypes, ChildEntityTypesList innerList)
 {
     if (entity != null)
     {
         if (base.CanDeepLoad(entity, "Project", "ProjectCodeSource", deepLoadType, innerList) && (entity.ProjectCodeSource == null))
         {
             object[] pkItems = new object[] { entity.ProjectCode ?? string.Empty };
             Project  project = EntityManager.LocateEntity <Project>(EntityLocator.ConstructKeyFromPkItems(typeof(Project), pkItems), DataRepository.Provider.EnableEntityTracking);
             if (project != null)
             {
                 entity.ProjectCodeSource = project;
             }
             else
             {
                 entity.ProjectCodeSource = DataRepository.ProjectProvider.GetByProjectCode(entity.ProjectCode ?? string.Empty);
             }
             if (deep && (entity.ProjectCodeSource != null))
             {
                 DataRepository.ProjectProvider.DeepLoad(transactionManager, entity.ProjectCodeSource, deep, deepLoadType, childTypes, innerList);
             }
         }
         if (base.CanDeepLoad(entity, "List<PayoutItem>", "PayoutItemCollection", deepLoadType, innerList))
         {
             entity.PayoutItemCollection = DataRepository.PayoutItemProvider.GetByPayoutCode(transactionManager, entity.PayoutCode);
             if (deep && (entity.PayoutItemCollection.Count > 0))
             {
                 DataRepository.PayoutItemProvider.DeepLoad(transactionManager, entity.PayoutItemCollection, deep, deepLoadType, childTypes, innerList);
             }
         }
     }
 }
        public override bool Delete(TransactionManager transactionManager, string payoutItemCode)
        {
            SqlDatabase database = new SqlDatabase(this._connectionString);
            DbCommand   command  = StoredProcedureProvider.GetCommandWrapper(database, "dbo.PayoutItem_Delete", this._useStoredProcedure);

            database.AddInParameter(command, "@PayoutItemCode", DbType.AnsiString, payoutItemCode);
            int num = 0;

            if (transactionManager != null)
            {
                num = Utility.ExecuteNonQuery(transactionManager, command);
            }
            else
            {
                num = Utility.ExecuteNonQuery(database, command);
            }
            if (DataRepository.Provider.EnableEntityTracking)
            {
                EntityManager.StopTracking(EntityLocator.ConstructKeyFromPkItems(typeof(PayoutItem), new object[] { payoutItemCode }));
            }
            if (num == 0)
            {
                return(false);
            }
            return(Convert.ToBoolean(num));
        }
Exemple #3
0
 internal override void DeepLoad(TransactionManager transactionManager, ContractMaterial entity, bool deep, DeepLoadType deepLoadType, Type[] childTypes, ChildEntityTypesList innerList)
 {
     if (entity != null)
     {
         object[] pkItems;
         if (base.CanDeepLoad(entity, "Material", "MaterialCodeSource", deepLoadType, innerList) && (entity.MaterialCodeSource == null))
         {
             pkItems = new object[1];
             int?materialCode = entity.MaterialCode;
             pkItems[0] = materialCode.HasValue ? materialCode.GetValueOrDefault() : 0;
             Material material = EntityManager.LocateEntity <Material>(EntityLocator.ConstructKeyFromPkItems(typeof(Material), pkItems), DataRepository.Provider.EnableEntityTracking);
             if (material != null)
             {
                 entity.MaterialCodeSource = material;
             }
             else
             {
                 materialCode = entity.MaterialCode;
                 entity.MaterialCodeSource = DataRepository.MaterialProvider.GetByMaterialCode(materialCode.HasValue ? materialCode.GetValueOrDefault() : 0);
             }
             if (deep && (entity.MaterialCodeSource != null))
             {
                 DataRepository.MaterialProvider.DeepLoad(transactionManager, entity.MaterialCodeSource, deep, deepLoadType, childTypes, innerList);
             }
         }
         if (base.CanDeepLoad(entity, "Contract", "ContractCodeSource", deepLoadType, innerList) && (entity.ContractCodeSource == null))
         {
             pkItems = new object[] { entity.ContractCode ?? string.Empty };
             Contract contract = EntityManager.LocateEntity <Contract>(EntityLocator.ConstructKeyFromPkItems(typeof(Contract), pkItems), DataRepository.Provider.EnableEntityTracking);
             if (contract != null)
             {
                 entity.ContractCodeSource = contract;
             }
             else
             {
                 entity.ContractCodeSource = DataRepository.ContractProvider.GetByContractCode(entity.ContractCode ?? string.Empty);
             }
             if (deep && (entity.ContractCodeSource != null))
             {
                 DataRepository.ContractProvider.DeepLoad(transactionManager, entity.ContractCodeSource, deep, deepLoadType, childTypes, innerList);
             }
         }
         if (base.CanDeepLoad(entity, "List<ContractMaterialPlan>", "ContractMaterialPlanCollection", deepLoadType, innerList))
         {
             entity.ContractMaterialPlanCollection = DataRepository.ContractMaterialPlanProvider.GetByContractMaterialCode(transactionManager, entity.ContractMaterialCode);
             if (deep && (entity.ContractMaterialPlanCollection.Count > 0))
             {
                 DataRepository.ContractMaterialPlanProvider.DeepLoad(transactionManager, entity.ContractMaterialPlanCollection, deep, deepLoadType, childTypes, innerList);
             }
         }
     }
 }
 internal override void DeepLoad(TransactionManager transactionManager, InspectSituation entity, bool deep, DeepLoadType deepLoadType, Type[] childTypes, ChildEntityTypesList innerList)
 {
     if (entity != null)
     {
         object[] pkItems;
         if (base.CanDeepLoad(entity, "Project", "ProjectCodeSource", deepLoadType, innerList) && (entity.ProjectCodeSource == null))
         {
             pkItems = new object[] { entity.ProjectCode ?? string.Empty };
             Project project = EntityManager.LocateEntity <Project>(EntityLocator.ConstructKeyFromPkItems(typeof(Project), pkItems), DataRepository.Provider.EnableEntityTracking);
             if (project != null)
             {
                 entity.ProjectCodeSource = project;
             }
             else
             {
                 entity.ProjectCodeSource = DataRepository.ProjectProvider.GetByProjectCode(entity.ProjectCode ?? string.Empty);
             }
             if (deep && (entity.ProjectCodeSource != null))
             {
                 DataRepository.ProjectProvider.DeepLoad(transactionManager, entity.ProjectCodeSource, deep, deepLoadType, childTypes, innerList);
             }
         }
         if (base.CanDeepLoad(entity, "SystemUser", "InspectUserSource", deepLoadType, innerList) && (entity.InspectUserSource == null))
         {
             pkItems = new object[] { entity.InspectUser ?? string.Empty };
             SystemUser user = EntityManager.LocateEntity <SystemUser>(EntityLocator.ConstructKeyFromPkItems(typeof(SystemUser), pkItems), DataRepository.Provider.EnableEntityTracking);
             if (user != null)
             {
                 entity.InspectUserSource = user;
             }
             else
             {
                 entity.InspectUserSource = DataRepository.SystemUserProvider.GetByUserCode(entity.InspectUser ?? string.Empty);
             }
             if (deep && (entity.InspectUserSource != null))
             {
                 DataRepository.SystemUserProvider.DeepLoad(transactionManager, entity.InspectUserSource, deep, deepLoadType, childTypes, innerList);
             }
         }
         if (base.CanDeepLoad(entity, "List<Trouble>", "TroubleCollection", deepLoadType, innerList))
         {
             entity.TroubleCollection = DataRepository.TroubleProvider.GetByInspectSituationID(transactionManager, entity.InspectSituationID);
             if (deep && (entity.TroubleCollection.Count > 0))
             {
                 DataRepository.TroubleProvider.DeepLoad(transactionManager, entity.TroubleCollection, deep, deepLoadType, childTypes, innerList);
             }
         }
     }
 }
            // Token: 0x06001EAD RID: 7853 RVA: 0x00084790 File Offset: 0x00082990
            private void DeductStockIfStruckNonPylon()
            {
                GameObject victim = this.grappleController.projectileStickOnImpactController.victim;

                if (victim)
                {
                    GameObject    gameObject = victim;
                    EntityLocator component  = gameObject.GetComponent <EntityLocator>();
                    if (component)
                    {
                        gameObject = component.entity;
                    }
                    gameObject.GetComponent <ProjectileController>();
                }
            }
        /// <summary>
        /// Deep Loads the <see cref="IEntity"/> object with criteria based of the child
        /// property collections only N Levels Deep based on the <see cref="DeepLoadType"/>.
        /// </summary>
        /// <remarks>
        /// Use this method with caution as it is possible to DeepLoad with Recursion and traverse an entire object graph.
        /// </remarks>
        /// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
        /// <param name="entity">The <see cref="PetShop.Business.LineItem"/> object to load.</param>
        /// <param name="deep">Boolean. A flag that indicates whether to recursively save all Property Collection that are descendants of this instance. If True, saves the complete object graph below this object. If False, saves this object only. </param>
        /// <param name="deepLoadType">DeepLoadType Enumeration to Include/Exclude object property collections from Load.</param>
        /// <param name="childTypes">PetShop.Business.LineItem Property Collection Type Array To Include or Exclude from Load</param>
        /// <param name="innerList">A collection of child types for easy access.</param>
        /// <exception cref="ArgumentNullException">entity or childTypes is null.</exception>
        /// <exception cref="ArgumentException">deepLoadType has invalid value.</exception>
        public override void DeepLoad(TransactionManager transactionManager, PetShop.Business.LineItem entity, bool deep, DeepLoadType deepLoadType, System.Type[] childTypes, DeepSession innerList)
        {
            if (entity == null)
            {
                return;
            }

            #region OrderIdSource
            if (CanDeepLoad(entity, "Order|OrderIdSource", deepLoadType, innerList) &&
                entity.OrderIdSource == null)
            {
                object[] pkItems = new object[1];
                pkItems[0] = entity.OrderId;
                Order tmpEntity = EntityManager.LocateEntity <Order>(EntityLocator.ConstructKeyFromPkItems(typeof(Order), pkItems), DataRepository.Provider.EnableEntityTracking);
                if (tmpEntity != null)
                {
                    entity.OrderIdSource = tmpEntity;
                }
                else
                {
                    entity.OrderIdSource = DataRepository.OrderProvider.GetByOrderId(transactionManager, entity.OrderId);
                }

                                #if NETTIERS_DEBUG
                System.Diagnostics.Debug.WriteLine("- property 'OrderIdSource' loaded. key " + entity.EntityTrackingKey);
                                #endif

                if (deep && entity.OrderIdSource != null)
                {
                    innerList.SkipChildren = true;
                    DataRepository.OrderProvider.DeepLoad(transactionManager, entity.OrderIdSource, deep, deepLoadType, childTypes, innerList);
                    innerList.SkipChildren = false;
                }
            }
            #endregion OrderIdSource

            //used to hold DeepLoad method delegates and fire after all the local children have been loaded.
            Dictionary <string, KeyValuePair <Delegate, object> > deepHandles = new Dictionary <string, KeyValuePair <Delegate, object> >();

            //Fire all DeepLoad Items
            foreach (KeyValuePair <Delegate, object> pair in deepHandles.Values)
            {
                pair.Key.DynamicInvoke((object[])pair.Value);
            }
            deepHandles = null;
        }
        private void ModifyBrokenObject()
        {
            SummonMasterBehavior summonMasterBehavior = brokenObject.GetComponent <SummonMasterBehavior>();

            droneMasterRed   = summonMasterBehavior.masterPrefab.InstantiateClone($"{name}RedMaster", true);
            droneMasterGreen = summonMasterBehavior.masterPrefab.InstantiateClone($"{name}GreenMaster", true);
            contentProvider.masterObjects.Add(droneMasterRed);
            contentProvider.masterObjects.Add(droneMasterGreen);
            ModifyDroneMaster();
            CharacterMaster masterRed   = droneMasterRed.GetComponent <CharacterMaster>();
            CharacterMaster masterGreen = droneMasterGreen.GetComponent <CharacterMaster>();

            droneBodyRed   = masterRed.bodyPrefab.InstantiateClone($"{name}RedBody", true);
            droneBodyGreen = masterGreen.bodyPrefab.InstantiateClone($"{name}GreenBody", true);
            contentProvider.bodyObjects.Add(droneBodyRed);
            contentProvider.bodyObjects.Add(droneBodyGreen);
            ModifyDroneBody();
            masterRed.bodyPrefab              = droneBodyRed;
            masterGreen.bodyPrefab            = droneBodyGreen;
            summonMasterBehavior.masterPrefab = droneMasterRed;
            PurchaseInteraction purchaseInteraction = brokenObject.GetComponent <PurchaseInteraction>();

            purchaseInteraction.cost            *= 10;
            purchaseInteraction.Networkcost      = purchaseInteraction.cost;
            purchaseInteraction.contextToken     = "PSI_BIT_CONTEXT";
            purchaseInteraction.displayNameToken = "PSI_BIT_INTERACTABLE_NAME";
            GenericDisplayNameProvider nameProvider = brokenObject.GetComponent <GenericDisplayNameProvider>();

            nameProvider.displayToken = "PSI_BIT_NAME";
            GameObject customBrokenModel = assetBundle.LoadAsset <GameObject>("Assets/Drones/PsiBits/Model/mdlPsiBitsBroken.prefab");

            brokenObject.ReplaceModel(customBrokenModel, DebugCheck());
            Highlight  highlight  = brokenObject.GetComponent <Highlight>();
            GameObject coreObject = customBrokenModel.transform.Find("_mdlPsiBitsBroken").gameObject;

            highlight.targetRenderer = coreObject.GetComponent <MeshRenderer>();
            EntityLocator entityLocator = customBrokenModel.AddComponent <EntityLocator>();

            entityLocator.entity = brokenObject;
            EntityLocator coreEntityLocator = coreObject.AddComponent <EntityLocator>();

            coreEntityLocator.entity = brokenObject;
            AddBrokenEffects(customBrokenModel, (MeshRenderer)highlight.targetRenderer);
        }
Exemple #8
0
        protected override bool PerformEquipmentAction(EquipmentSlot slot)
        {
            if (!slot.characterBody)
            {
                return(false);
            }
            if (SceneCatalog.mostRecentSceneDef.baseSceneName == "bazaar")
            {
                return(false);
            }
            var sphpos = slot.characterBody.transform.position;
            var sphrad = radius;

            if (instance.CheckEmbryoProc(slot.characterBody))
            {
                sphrad *= 2;
            }
            Collider[] sphits   = Physics.OverlapSphere(sphpos, sphrad, LayerIndex.defaultLayer.mask, QueryTriggerInteraction.Collide);
            bool       foundAny = false;

            foreach (Collider c in sphits)
            {
                var ent = EntityLocator.GetEntity(c.gameObject);
                if (!ent)
                {
                    continue;
                }
                var cptChest = ent.GetComponent <ChestBehavior>();
                if (!cptChest)
                {
                    continue;
                }
                var cptPurch = ent.GetComponent <PurchaseInteraction>();
                if (cptPurch && cptPurch.available && cptPurch.costType == CostTypeIndex.Money)
                {
                    cptPurch.SetAvailable(false);
                    cptChest.Open();
                    foundAny = true;
                }
            }
            return(foundAny);
        }
 internal override void DeepLoad(TransactionManager transactionManager, ContractBill entity, bool deep, DeepLoadType deepLoadType, Type[] childTypes, ChildEntityTypesList innerList)
 {
     if ((entity != null) && (base.CanDeepLoad(entity, "Contract", "ContractCodeSource", deepLoadType, innerList) && (entity.ContractCodeSource == null)))
     {
         object[] pkItems  = new object[] { entity.ContractCode ?? string.Empty };
         Contract contract = EntityManager.LocateEntity <Contract>(EntityLocator.ConstructKeyFromPkItems(typeof(Contract), pkItems), DataRepository.Provider.EnableEntityTracking);
         if (contract != null)
         {
             entity.ContractCodeSource = contract;
         }
         else
         {
             entity.ContractCodeSource = DataRepository.ContractProvider.GetByContractCode(entity.ContractCode ?? string.Empty);
         }
         if (deep && (entity.ContractCodeSource != null))
         {
             DataRepository.ContractProvider.DeepLoad(transactionManager, entity.ContractCodeSource, deep, deepLoadType, childTypes, innerList);
         }
     }
 }
 internal override void DeepLoad(TransactionManager transactionManager, DictionaryItem entity, bool deep, DeepLoadType deepLoadType, Type[] childTypes, ChildEntityTypesList innerList)
 {
     if ((entity != null) && (base.CanDeepLoad(entity, "DictionaryName", "DictionaryNameCodeSource", deepLoadType, innerList) && (entity.DictionaryNameCodeSource == null)))
     {
         object[]       pkItems = new object[] { entity.DictionaryNameCode ?? string.Empty };
         DictionaryName name    = EntityManager.LocateEntity <DictionaryName>(EntityLocator.ConstructKeyFromPkItems(typeof(DictionaryName), pkItems), DataRepository.Provider.EnableEntityTracking);
         if (name != null)
         {
             entity.DictionaryNameCodeSource = name;
         }
         else
         {
             entity.DictionaryNameCodeSource = DataRepository.DictionaryNameProvider.GetByDictionaryNameCode(entity.DictionaryNameCode ?? string.Empty);
         }
         if (deep && (entity.DictionaryNameCodeSource != null))
         {
             DataRepository.DictionaryNameProvider.DeepLoad(transactionManager, entity.DictionaryNameCodeSource, deep, deepLoadType, childTypes, innerList);
         }
     }
 }
        /// <summary>
        ///     Deletes a row from the DataSource.
        /// </summary>
        /// <param name="_testTimestampId">. Primary Key.</param>
        /// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
        /// <param name="_version">The timestamp field used for concurrency check.</param>
        /// <remarks>Deletes based on primary key(s).</remarks>
        /// <returns>Returns true if operation suceeded.</returns>
        /// <exception cref="System.Exception">The command could not be executed.</exception>
        /// <exception cref="System.Data.DataException">The <paramref name="transactionManager"/> is not open.</exception>
        /// <exception cref="System.Data.Common.DbException">The command could not be executed.</exception>
        /// <exception cref="DBConcurrencyException">The record has been modified by an other user. Please reload the instance before deleting.</exception>
        public override bool Delete(TransactionManager transactionManager, System.Int32 _testTimestampId, byte[] _version)
        {
            SqlDatabase database       = new SqlDatabase(this._connectionString);
            DbCommand   commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "Test.usp_adwTiers_TestTimestamp_Delete", _useStoredProcedure);

            database.AddInParameter(commandWrapper, "@TestTimestampId", DbType.Int32, _testTimestampId);
            database.AddInParameter(commandWrapper, "@Version", DbType.Binary, _version);

            //Provider Data Requesting Command Event
            OnDataRequesting(new CommandEventArgs(commandWrapper, "Delete"));

            int results = 0;

            if (transactionManager != null)
            {
                results = Utility.ExecuteNonQuery(transactionManager, commandWrapper);
            }
            else
            {
                results = Utility.ExecuteNonQuery(database, commandWrapper);
            }

            //Stop Tracking Now that it has been updated and persisted.
            if (DataRepository.Provider.EnableEntityTracking)
            {
                string entityKey = EntityLocator.ConstructKeyFromPkItems(typeof(TestTimestamp)
                                                                         , _testTimestampId);
                EntityManager.StopTracking(entityKey);
            }

            //Provider Data Requested Command Event
            OnDataRequested(new CommandEventArgs(commandWrapper, "Delete"));

            if (results == 0)
            {
                throw new DBConcurrencyException("The record has been modified by an other user. Please reload the instance before deleting.");
            }
            commandWrapper = null;

            return(Convert.ToBoolean(results));
        }        //end Delete
Exemple #12
0
        /// <summary>
        ///     Deletes a row from the DataSource.
        /// </summary>
        /// <param name="iD">. Primary Key.</param>
        /// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
        /// <remarks>Deletes based on primary key(s).</remarks>
        /// <returns>Returns true if operation suceeded.</returns>
        /// <exception cref="System.Exception">The command could not be executed.</exception>
        /// <exception cref="System.Data.DataException">The <paramref name="transactionManager"/> is not open.</exception>
        /// <exception cref="System.Data.Common.DbException">The command could not be executed.</exception>
        public override bool Delete(TransactionManager transactionManager, System.Int32 iD)
        {
            SqlDatabase database       = new SqlDatabase(this._connectionString);
            DbCommand   commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "dbo.Fattura_Delete", _useStoredProcedure);

            database.AddInParameter(commandWrapper, "@ID", DbType.Int32, iD);

            //Provider Data Requesting Command Event
            OnDataRequesting(new CommandEventArgs(commandWrapper, "Delete"));

            int results = 0;

            if (transactionManager != null)
            {
                results = Utility.ExecuteNonQuery(transactionManager, commandWrapper);
            }
            else
            {
                results = Utility.ExecuteNonQuery(database, commandWrapper);
            }

            //Stop Tracking Now that it has been updated and persisted.
            if (DataRepository.Provider.EnableEntityTracking)
            {
                string entityKey = EntityLocator.ConstructKeyFromPkItems(typeof(Fattura)
                                                                         , iD);
                EntityManager.StopTracking(entityKey);
            }

            //Provider Data Requested Command Event
            OnDataRequested(new CommandEventArgs(commandWrapper, "Delete"));

            if (results == 0)
            {
                //throw new DataException("The record has been already deleted.");
                return(false);
            }
            commandWrapper = null;

            return(Convert.ToBoolean(results));
        }        //end Delete
Exemple #13
0
 internal override void DeepLoad(TransactionManager transactionManager, PayoutItem entity, bool deep, DeepLoadType deepLoadType, Type[] childTypes, ChildEntityTypesList innerList)
 {
     if (entity != null)
     {
         object[] pkItems;
         if (base.CanDeepLoad(entity, "Payout", "PayoutCodeSource", deepLoadType, innerList) && (entity.PayoutCodeSource == null))
         {
             pkItems = new object[] { entity.PayoutCode ?? string.Empty };
             Payout payout = EntityManager.LocateEntity <Payout>(EntityLocator.ConstructKeyFromPkItems(typeof(Payout), pkItems), DataRepository.Provider.EnableEntityTracking);
             if (payout != null)
             {
                 entity.PayoutCodeSource = payout;
             }
             else
             {
                 entity.PayoutCodeSource = DataRepository.PayoutProvider.GetByPayoutCode(entity.PayoutCode ?? string.Empty);
             }
             if (deep && (entity.PayoutCodeSource != null))
             {
                 DataRepository.PayoutProvider.DeepLoad(transactionManager, entity.PayoutCodeSource, deep, deepLoadType, childTypes, innerList);
             }
         }
         if (base.CanDeepLoad(entity, "PaymentItem", "PaymentItemCodeSource", deepLoadType, innerList) && (entity.PaymentItemCodeSource == null))
         {
             pkItems = new object[] { entity.PaymentItemCode ?? string.Empty };
             PaymentItem item = EntityManager.LocateEntity <PaymentItem>(EntityLocator.ConstructKeyFromPkItems(typeof(PaymentItem), pkItems), DataRepository.Provider.EnableEntityTracking);
             if (item != null)
             {
                 entity.PaymentItemCodeSource = item;
             }
             else
             {
                 entity.PaymentItemCodeSource = DataRepository.PaymentItemProvider.GetByPaymentItemCode(entity.PaymentItemCode ?? string.Empty);
             }
             if (deep && (entity.PaymentItemCodeSource != null))
             {
                 DataRepository.PaymentItemProvider.DeepLoad(transactionManager, entity.PaymentItemCodeSource, deep, deepLoadType, childTypes, innerList);
             }
         }
     }
 }
        /// <summary>
        ///     Deletes a row from the DataSource.
        /// </summary>
        /// <param name="_employeeId">Employee identification number. Foreign key to Employee.EmployeeID.. Primary Key.</param>
        /// <param name="_startDate">Date the employee started work in the department.. Primary Key.</param>
        /// <param name="_departmentId">Department in which the employee worked including currently. Foreign key to Department.DepartmentID.. Primary Key.</param>
        /// <param name="_shiftId">Identifies which 8-hour shift the employee works. Foreign key to Shift.Shift.ID.. Primary Key.</param>
        /// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
        /// <remarks>Deletes based on primary key(s).</remarks>
        /// <returns>Returns true if operation suceeded.</returns>
        /// <exception cref="System.Exception">The command could not be executed.</exception>
        /// <exception cref="System.Data.DataException">The <paramref name="transactionManager"/> is not open.</exception>
        /// <exception cref="System.Data.Common.DbException">The command could not be executed.</exception>
        public override bool Delete(TransactionManager transactionManager, System.Int32 _employeeId, System.DateTime _startDate, System.Int16 _departmentId, System.Byte _shiftId)
        {
            SqlDatabase database       = new SqlDatabase(this._connectionString);
            DbCommand   commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "HumanResources.usp_adwTiers_EmployeeDepartmentHistory_Delete", _useStoredProcedure);

            database.AddInParameter(commandWrapper, "@EmployeeId", DbType.Int32, _employeeId);
            database.AddInParameter(commandWrapper, "@StartDate", DbType.DateTime, _startDate);
            database.AddInParameter(commandWrapper, "@DepartmentId", DbType.Int16, _departmentId);
            database.AddInParameter(commandWrapper, "@ShiftId", DbType.Byte, _shiftId);

            //Provider Data Requesting Command Event
            OnDataRequesting(new CommandEventArgs(commandWrapper, "Delete"));

            int results = 0;

            if (transactionManager != null)
            {
                results = Utility.ExecuteNonQuery(transactionManager, commandWrapper);
            }
            else
            {
                results = Utility.ExecuteNonQuery(database, commandWrapper);
            }

            //Stop Tracking Now that it has been updated and persisted.
            if (DataRepository.Provider.EnableEntityTracking)
            {
                string entityKey = EntityLocator.ConstructKeyFromPkItems(typeof(EmployeeDepartmentHistory)
                                                                         , _employeeId, _startDate, _departmentId, _shiftId);
                EntityManager.StopTracking(entityKey);
            }

            //Provider Data Requested Command Event
            OnDataRequested(new CommandEventArgs(commandWrapper, "Delete"));

            commandWrapper = null;

            return(Convert.ToBoolean(results));
        }        //end Delete
Exemple #15
0
        /// <summary>
        ///     Deletes a row from the DataSource.
        /// </summary>
        /// <param name="_productModelId">Primary key. Foreign key to ProductModel.ProductModelID.. Primary Key.</param>
        /// <param name="_productDescriptionId">Primary key. Foreign key to ProductDescription.ProductDescriptionID.. Primary Key.</param>
        /// <param name="_cultureId">Culture identification number. Foreign key to Culture.CultureID.. Primary Key.</param>
        /// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
        /// <remarks>Deletes based on primary key(s).</remarks>
        /// <returns>Returns true if operation suceeded.</returns>
        /// <exception cref="System.Exception">The command could not be executed.</exception>
        /// <exception cref="System.Data.DataException">The <paramref name="transactionManager"/> is not open.</exception>
        /// <exception cref="System.Data.Common.DbException">The command could not be executed.</exception>
        public override bool Delete(TransactionManager transactionManager, System.Int32 _productModelId, System.Int32 _productDescriptionId, System.String _cultureId)
        {
            SqlDatabase database       = new SqlDatabase(this._connectionString);
            DbCommand   commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "Production.usp_adwTiers_ProductModelProductDescriptionCulture_Delete", _useStoredProcedure);

            database.AddInParameter(commandWrapper, "@ProductModelId", DbType.Int32, _productModelId);
            database.AddInParameter(commandWrapper, "@ProductDescriptionId", DbType.Int32, _productDescriptionId);
            database.AddInParameter(commandWrapper, "@CultureId", DbType.StringFixedLength, _cultureId);

            //Provider Data Requesting Command Event
            OnDataRequesting(new CommandEventArgs(commandWrapper, "Delete"));

            int results = 0;

            if (transactionManager != null)
            {
                results = Utility.ExecuteNonQuery(transactionManager, commandWrapper);
            }
            else
            {
                results = Utility.ExecuteNonQuery(database, commandWrapper);
            }

            //Stop Tracking Now that it has been updated and persisted.
            if (DataRepository.Provider.EnableEntityTracking)
            {
                string entityKey = EntityLocator.ConstructKeyFromPkItems(typeof(ProductModelProductDescriptionCulture)
                                                                         , _productModelId, _productDescriptionId, _cultureId);
                EntityManager.StopTracking(entityKey);
            }

            //Provider Data Requested Command Event
            OnDataRequested(new CommandEventArgs(commandWrapper, "Delete"));

            commandWrapper = null;

            return(Convert.ToBoolean(results));
        }        //end Delete
Exemple #16
0
        /// <summary>
        ///     Deletes a row from the DataSource.
        /// </summary>
        /// <param name="_orderId">. Primary Key.</param>
        /// <param name="_lineNum">. Primary Key.</param>
        /// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
        /// <remarks>Deletes based on primary key(s).</remarks>
        /// <returns>Returns true if operation suceeded.</returns>
        /// <exception cref="System.Exception">The command could not be executed.</exception>
        /// <exception cref="System.Data.DataException">The <paramref name="transactionManager"/> is not open.</exception>
        /// <exception cref="System.Data.Common.DbException">The command could not be executed.</exception>
        public override bool Delete(TransactionManager transactionManager, int _orderId, int _lineNum)
        {
            SqlDatabase database       = new SqlDatabase(this._connectionString);
            DbCommand   commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "dbo.OrderStatus_Delete", _useStoredProcedure);

            database.AddInParameter(commandWrapper, "@OrderId", DbType.Int32, _orderId);
            database.AddInParameter(commandWrapper, "@LineNum", DbType.Int32, _lineNum);

            //Provider Data Requesting Command Event
            OnDataRequesting(new CommandEventArgs(commandWrapper, "Delete"));

            int results = 0;

            if (transactionManager != null)
            {
                results = Utility.ExecuteNonQuery(transactionManager, commandWrapper);
            }
            else
            {
                results = Utility.ExecuteNonQuery(database, commandWrapper);
            }

            //Stop Tracking Now that it has been updated and persisted.
            if (DataRepository.Provider.EnableEntityTracking)
            {
                string entityKey = EntityLocator.ConstructKeyFromPkItems(typeof(OrderStatus)
                                                                         , _orderId, _lineNum);
                EntityManager.StopTracking(entityKey);
            }

            //Provider Data Requested Command Event
            OnDataRequested(new CommandEventArgs(commandWrapper, "Delete"));

            commandWrapper = null;

            return(Convert.ToBoolean(results));
        }        //end Delete
Exemple #17
0
        /// <summary>
        ///     Deletes a row from the DataSource.
        /// </summary>
        /// <param name="_branch">. Primary Key.</param>
        /// <param name="_accountId">. Primary Key.</param>
        /// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
        /// <remarks>Deletes based on primary key(s).</remarks>
        /// <returns>Returns true if operation suceeded.</returns>
        /// <exception cref="System.Exception">The command could not be executed.</exception>
        /// <exception cref="System.Data.DataException">The <paramref name="transactionManager"/> is not open.</exception>
        /// <exception cref="System.Data.Common.DbException">The command could not be executed.</exception>
        public override bool Delete(TransactionManager transactionManager, System.Decimal _branch, System.String _accountId)
        {
            SqlDatabase database       = new SqlDatabase(this._connectionString);
            DbCommand   commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "dbo.tblAccount_Delete", _useStoredProcedure);

            database.AddInParameter(commandWrapper, "@Branch", DbType.Decimal, _branch);
            database.AddInParameter(commandWrapper, "@AccountId", DbType.AnsiStringFixedLength, _accountId);

            //Provider Data Requesting Command Event
            OnDataRequesting(new CommandEventArgs(commandWrapper, "Delete"));

            int results = 0;

            if (transactionManager != null)
            {
                results = Utility.ExecuteNonQuery(transactionManager, commandWrapper);
            }
            else
            {
                results = Utility.ExecuteNonQuery(database, commandWrapper);
            }

            //Stop Tracking Now that it has been updated and persisted.
            if (DataRepository.Provider.EnableEntityTracking)
            {
                string entityKey = EntityLocator.ConstructKeyFromPkItems(typeof(Account)
                                                                         , _branch, _accountId);
                EntityManager.StopTracking(entityKey);
            }

            //Provider Data Requested Command Event
            OnDataRequested(new CommandEventArgs(commandWrapper, "Delete"));

            commandWrapper = null;

            return(Convert.ToBoolean(results));
        }        //end Delete
Exemple #18
0
        /// <summary>
        /// Deep Loads the <see cref="IEntity"/> object with criteria based of the child
        /// property collections only N Levels Deep based on the <see cref="DeepLoadType"/>.
        /// </summary>
        /// <remarks>
        /// Use this method with caution as it is possible to DeepLoad with Recursion and traverse an entire object graph.
        /// </remarks>
        /// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
        /// <param name="entity">The <see cref="Nettiers.AdventureWorks.Entities.WorkOrder"/> object to load.</param>
        /// <param name="deep">Boolean. A flag that indicates whether to recursively save all Property Collection that are descendants of this instance. If True, saves the complete object graph below this object. If False, saves this object only. </param>
        /// <param name="deepLoadType">DeepLoadType Enumeration to Include/Exclude object property collections from Load.</param>
        /// <param name="childTypes">Nettiers.AdventureWorks.Entities.WorkOrder Property Collection Type Array To Include or Exclude from Load</param>
        /// <param name="innerList">A collection of child types for easy access.</param>
        /// <exception cref="ArgumentNullException">entity or childTypes is null.</exception>
        /// <exception cref="ArgumentException">deepLoadType has invalid value.</exception>
        public override void DeepLoad(TransactionManager transactionManager, Nettiers.AdventureWorks.Entities.WorkOrder entity, bool deep, DeepLoadType deepLoadType, System.Type[] childTypes, DeepSession innerList)
        {
            if (entity == null)
            {
                return;
            }

            #region ProductIdSource
            if (CanDeepLoad(entity, "Product|ProductIdSource", deepLoadType, innerList) &&
                entity.ProductIdSource == null)
            {
                object[] pkItems = new object[1];
                pkItems[0] = entity.ProductId;
                Product tmpEntity = EntityManager.LocateEntity <Product>(EntityLocator.ConstructKeyFromPkItems(typeof(Product), pkItems), DataRepository.Provider.EnableEntityTracking);
                if (tmpEntity != null)
                {
                    entity.ProductIdSource = tmpEntity;
                }
                else
                {
                    entity.ProductIdSource = DataRepository.ProductProvider.GetByProductId(transactionManager, entity.ProductId);
                }

                                #if NETTIERS_DEBUG
                System.Diagnostics.Debug.WriteLine("- property 'ProductIdSource' loaded. key " + entity.EntityTrackingKey);
                                #endif

                if (deep && entity.ProductIdSource != null)
                {
                    innerList.SkipChildren = true;
                    DataRepository.ProductProvider.DeepLoad(transactionManager, entity.ProductIdSource, deep, deepLoadType, childTypes, innerList);
                    innerList.SkipChildren = false;
                }
            }
            #endregion ProductIdSource

            #region ScrapReasonIdSource
            if (CanDeepLoad(entity, "ScrapReason|ScrapReasonIdSource", deepLoadType, innerList) &&
                entity.ScrapReasonIdSource == null)
            {
                object[] pkItems = new object[1];
                pkItems[0] = (entity.ScrapReasonId ?? (short)0);
                ScrapReason tmpEntity = EntityManager.LocateEntity <ScrapReason>(EntityLocator.ConstructKeyFromPkItems(typeof(ScrapReason), pkItems), DataRepository.Provider.EnableEntityTracking);
                if (tmpEntity != null)
                {
                    entity.ScrapReasonIdSource = tmpEntity;
                }
                else
                {
                    entity.ScrapReasonIdSource = DataRepository.ScrapReasonProvider.GetByScrapReasonId(transactionManager, (entity.ScrapReasonId ?? (short)0));
                }

                                #if NETTIERS_DEBUG
                System.Diagnostics.Debug.WriteLine("- property 'ScrapReasonIdSource' loaded. key " + entity.EntityTrackingKey);
                                #endif

                if (deep && entity.ScrapReasonIdSource != null)
                {
                    innerList.SkipChildren = true;
                    DataRepository.ScrapReasonProvider.DeepLoad(transactionManager, entity.ScrapReasonIdSource, deep, deepLoadType, childTypes, innerList);
                    innerList.SkipChildren = false;
                }
            }
            #endregion ScrapReasonIdSource

            //used to hold DeepLoad method delegates and fire after all the local children have been loaded.
            Dictionary <string, KeyValuePair <Delegate, object> > deepHandles = new Dictionary <string, KeyValuePair <Delegate, object> >();
            // Deep load child collections  - Call GetByWorkOrderId methods when available

            #region WorkOrderRoutingCollection
            //Relationship Type One : Many
            if (CanDeepLoad(entity, "List<WorkOrderRouting>|WorkOrderRoutingCollection", deepLoadType, innerList))
            {
                                #if NETTIERS_DEBUG
                System.Diagnostics.Debug.WriteLine("- property 'WorkOrderRoutingCollection' loaded. key " + entity.EntityTrackingKey);
                                #endif

                entity.WorkOrderRoutingCollection = DataRepository.WorkOrderRoutingProvider.GetByWorkOrderId(transactionManager, entity.WorkOrderId);

                if (deep && entity.WorkOrderRoutingCollection.Count > 0)
                {
                    deepHandles.Add("WorkOrderRoutingCollection",
                                    new KeyValuePair <Delegate, object>((DeepLoadHandle <WorkOrderRouting>)DataRepository.WorkOrderRoutingProvider.DeepLoad,
                                                                        new object[] { transactionManager, entity.WorkOrderRoutingCollection, deep, deepLoadType, childTypes, innerList }
                                                                        ));
                }
            }
            #endregion


            //Fire all DeepLoad Items
            foreach (KeyValuePair <Delegate, object> pair in deepHandles.Values)
            {
                pair.Key.DynamicInvoke((object[])pair.Value);
            }
            deepHandles = null;
        }
        /// <summary>
        /// Deep Loads the <see cref="IEntity"/> object with criteria based of the child
        /// property collections only N Levels Deep based on the <see cref="DeepLoadType"/>.
        /// </summary>
        /// <remarks>
        /// Use this method with caution as it is possible to DeepLoad with Recursion and traverse an entire object graph.
        /// </remarks>
        /// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
        /// <param name="entity">The <see cref="EmployeeDB.BLL.Address"/> object to load.</param>
        /// <param name="deep">Boolean. A flag that indicates whether to recursively save all Property Collection that are descendants of this instance. If True, saves the complete object graph below this object. If False, saves this object only. </param>
        /// <param name="deepLoadType">DeepLoadType Enumeration to Include/Exclude object property collections from Load.</param>
        /// <param name="childTypes">EmployeeDB.BLL.Address Property Collection Type Array To Include or Exclude from Load</param>
        /// <param name="innerList">A collection of child types for easy access.</param>
        /// <exception cref="ArgumentNullException">entity or childTypes is null.</exception>
        /// <exception cref="ArgumentException">deepLoadType has invalid value.</exception>
        public override void DeepLoad(TransactionManager transactionManager, EmployeeDB.BLL.Address entity, bool deep, DeepLoadType deepLoadType, System.Type[] childTypes, DeepSession innerList)
        {
            if (entity == null)
            {
                return;
            }

            #region CountryCodeSource
            if (CanDeepLoad(entity, "Countries|CountryCodeSource", deepLoadType, innerList) &&
                entity.CountryCodeSource == null)
            {
                object[] pkItems = new object[1];
                pkItems[0] = (entity.CountryCode ?? string.Empty);
                Countries tmpEntity = EntityManager.LocateEntity <Countries>(EntityLocator.ConstructKeyFromPkItems(typeof(Countries), pkItems), DataRepository.Provider.EnableEntityTracking);
                if (tmpEntity != null)
                {
                    entity.CountryCodeSource = tmpEntity;
                }
                else
                {
                    entity.CountryCodeSource = DataRepository.CountriesProvider.GetByCountryCode(transactionManager, (entity.CountryCode ?? string.Empty));
                }

                                #if NETTIERS_DEBUG
                System.Diagnostics.Debug.WriteLine("- property 'CountryCodeSource' loaded. key " + entity.EntityTrackingKey);
                                #endif

                if (deep && entity.CountryCodeSource != null)
                {
                    innerList.SkipChildren = true;
                    DataRepository.CountriesProvider.DeepLoad(transactionManager, entity.CountryCodeSource, deep, deepLoadType, childTypes, innerList);
                    innerList.SkipChildren = false;
                }
            }
            #endregion CountryCodeSource

            #region EmployeeIdSource
            if (CanDeepLoad(entity, "Employee|EmployeeIdSource", deepLoadType, innerList) &&
                entity.EmployeeIdSource == null)
            {
                object[] pkItems = new object[1];
                pkItems[0] = entity.EmployeeId;
                Employee tmpEntity = EntityManager.LocateEntity <Employee>(EntityLocator.ConstructKeyFromPkItems(typeof(Employee), pkItems), DataRepository.Provider.EnableEntityTracking);
                if (tmpEntity != null)
                {
                    entity.EmployeeIdSource = tmpEntity;
                }
                else
                {
                    entity.EmployeeIdSource = DataRepository.EmployeeProvider.GetByEmployeeId(transactionManager, entity.EmployeeId);
                }

                                #if NETTIERS_DEBUG
                System.Diagnostics.Debug.WriteLine("- property 'EmployeeIdSource' loaded. key " + entity.EntityTrackingKey);
                                #endif

                if (deep && entity.EmployeeIdSource != null)
                {
                    innerList.SkipChildren = true;
                    DataRepository.EmployeeProvider.DeepLoad(transactionManager, entity.EmployeeIdSource, deep, deepLoadType, childTypes, innerList);
                    innerList.SkipChildren = false;
                }
            }
            #endregion EmployeeIdSource

            //used to hold DeepLoad method delegates and fire after all the local children have been loaded.
            Dictionary <string, KeyValuePair <Delegate, object> > deepHandles = new Dictionary <string, KeyValuePair <Delegate, object> >();

            //Fire all DeepLoad Items
            foreach (KeyValuePair <Delegate, object> pair in deepHandles.Values)
            {
                pair.Key.DynamicInvoke((object[])pair.Value);
            }
            deepHandles = null;
        }
 internal override void DeepLoad(TransactionManager transactionManager, MaterialPurchasDtl entity, bool deep, DeepLoadType deepLoadType, Type[] childTypes, ChildEntityTypesList innerList)
 {
     if ((entity != null) && (base.CanDeepLoad(entity, "MaterialPurchas", "MaterialPurchasIDSource", deepLoadType, innerList) && (entity.MaterialPurchasIDSource == null)))
     {
         object[] pkItems           = new object[1];
         int?     materialPurchasID = entity.MaterialPurchasID;
         pkItems[0] = materialPurchasID.HasValue ? materialPurchasID.GetValueOrDefault() : 0;
         MaterialPurchas purchas = EntityManager.LocateEntity <MaterialPurchas>(EntityLocator.ConstructKeyFromPkItems(typeof(MaterialPurchas), pkItems), DataRepository.Provider.EnableEntityTracking);
         if (purchas != null)
         {
             entity.MaterialPurchasIDSource = purchas;
         }
         else
         {
             materialPurchasID = entity.MaterialPurchasID;
             entity.MaterialPurchasIDSource = DataRepository.MaterialPurchasProvider.GetByMaterialPurchasID(materialPurchasID.HasValue ? materialPurchasID.GetValueOrDefault() : 0);
         }
         if (deep && (entity.MaterialPurchasIDSource != null))
         {
             DataRepository.MaterialPurchasProvider.DeepLoad(transactionManager, entity.MaterialPurchasIDSource, deep, deepLoadType, childTypes, innerList);
         }
     }
 }
Exemple #21
0
        /// <summary>
        /// Deep Loads the <see cref="IEntity"/> object with criteria based of the child
        /// property collections only N Levels Deep based on the <see cref="DeepLoadType"/>.
        /// </summary>
        /// <remarks>
        /// Use this method with caution as it is possible to DeepLoad with Recursion and traverse an entire object graph.
        /// </remarks>
        /// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
        /// <param name="entity">The <see cref="Nettiers.AdventureWorks.Entities.CurrencyRate"/> object to load.</param>
        /// <param name="deep">Boolean. A flag that indicates whether to recursively save all Property Collection that are descendants of this instance. If True, saves the complete object graph below this object. If False, saves this object only. </param>
        /// <param name="deepLoadType">DeepLoadType Enumeration to Include/Exclude object property collections from Load.</param>
        /// <param name="childTypes">Nettiers.AdventureWorks.Entities.CurrencyRate Property Collection Type Array To Include or Exclude from Load</param>
        /// <param name="innerList">A collection of child types for easy access.</param>
        /// <exception cref="ArgumentNullException">entity or childTypes is null.</exception>
        /// <exception cref="ArgumentException">deepLoadType has invalid value.</exception>
        public override void DeepLoad(TransactionManager transactionManager, Nettiers.AdventureWorks.Entities.CurrencyRate entity, bool deep, DeepLoadType deepLoadType, System.Type[] childTypes, DeepSession innerList)
        {
            if (entity == null)
            {
                return;
            }

            #region FromCurrencyCodeSource
            if (CanDeepLoad(entity, "Currency|FromCurrencyCodeSource", deepLoadType, innerList) &&
                entity.FromCurrencyCodeSource == null)
            {
                object[] pkItems = new object[1];
                pkItems[0] = entity.FromCurrencyCode;
                Currency tmpEntity = EntityManager.LocateEntity <Currency>(EntityLocator.ConstructKeyFromPkItems(typeof(Currency), pkItems), DataRepository.Provider.EnableEntityTracking);
                if (tmpEntity != null)
                {
                    entity.FromCurrencyCodeSource = tmpEntity;
                }
                else
                {
                    entity.FromCurrencyCodeSource = DataRepository.CurrencyProvider.GetByCurrencyCode(transactionManager, entity.FromCurrencyCode);
                }

                                #if NETTIERS_DEBUG
                System.Diagnostics.Debug.WriteLine("- property 'FromCurrencyCodeSource' loaded. key " + entity.EntityTrackingKey);
                                #endif

                if (deep && entity.FromCurrencyCodeSource != null)
                {
                    innerList.SkipChildren = true;
                    DataRepository.CurrencyProvider.DeepLoad(transactionManager, entity.FromCurrencyCodeSource, deep, deepLoadType, childTypes, innerList);
                    innerList.SkipChildren = false;
                }
            }
            #endregion FromCurrencyCodeSource

            #region ToCurrencyCodeSource
            if (CanDeepLoad(entity, "Currency|ToCurrencyCodeSource", deepLoadType, innerList) &&
                entity.ToCurrencyCodeSource == null)
            {
                object[] pkItems = new object[1];
                pkItems[0] = entity.ToCurrencyCode;
                Currency tmpEntity = EntityManager.LocateEntity <Currency>(EntityLocator.ConstructKeyFromPkItems(typeof(Currency), pkItems), DataRepository.Provider.EnableEntityTracking);
                if (tmpEntity != null)
                {
                    entity.ToCurrencyCodeSource = tmpEntity;
                }
                else
                {
                    entity.ToCurrencyCodeSource = DataRepository.CurrencyProvider.GetByCurrencyCode(transactionManager, entity.ToCurrencyCode);
                }

                                #if NETTIERS_DEBUG
                System.Diagnostics.Debug.WriteLine("- property 'ToCurrencyCodeSource' loaded. key " + entity.EntityTrackingKey);
                                #endif

                if (deep && entity.ToCurrencyCodeSource != null)
                {
                    innerList.SkipChildren = true;
                    DataRepository.CurrencyProvider.DeepLoad(transactionManager, entity.ToCurrencyCodeSource, deep, deepLoadType, childTypes, innerList);
                    innerList.SkipChildren = false;
                }
            }
            #endregion ToCurrencyCodeSource

            //used to hold DeepLoad method delegates and fire after all the local children have been loaded.
            Dictionary <string, KeyValuePair <Delegate, object> > deepHandles = new Dictionary <string, KeyValuePair <Delegate, object> >();
            // Deep load child collections  - Call GetByCurrencyRateId methods when available

            #region SalesOrderHeaderCollection
            //Relationship Type One : Many
            if (CanDeepLoad(entity, "List<SalesOrderHeader>|SalesOrderHeaderCollection", deepLoadType, innerList))
            {
                                #if NETTIERS_DEBUG
                System.Diagnostics.Debug.WriteLine("- property 'SalesOrderHeaderCollection' loaded. key " + entity.EntityTrackingKey);
                                #endif

                entity.SalesOrderHeaderCollection = DataRepository.SalesOrderHeaderProvider.GetByCurrencyRateId(transactionManager, entity.CurrencyRateId);

                if (deep && entity.SalesOrderHeaderCollection.Count > 0)
                {
                    deepHandles.Add("SalesOrderHeaderCollection",
                                    new KeyValuePair <Delegate, object>((DeepLoadHandle <SalesOrderHeader>)DataRepository.SalesOrderHeaderProvider.DeepLoad,
                                                                        new object[] { transactionManager, entity.SalesOrderHeaderCollection, deep, deepLoadType, childTypes, innerList }
                                                                        ));
                }
            }
            #endregion


            //Fire all DeepLoad Items
            foreach (KeyValuePair <Delegate, object> pair in deepHandles.Values)
            {
                pair.Key.DynamicInvoke((object[])pair.Value);
            }
            deepHandles = null;
        }
Exemple #22
0
        /// <summary>
        /// Deep Loads the <see cref="IEntity"/> object with criteria based of the child
        /// property collections only N Levels Deep based on the <see cref="DeepLoadType"/>.
        /// </summary>
        /// <remarks>
        /// Use this method with caution as it is possible to DeepLoad with Recursion and traverse an entire object graph.
        /// </remarks>
        /// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
        /// <param name="entity">The <see cref="Nettiers.AdventureWorks.Entities.PurchaseOrderHeader"/> object to load.</param>
        /// <param name="deep">Boolean. A flag that indicates whether to recursively save all Property Collection that are descendants of this instance. If True, saves the complete object graph below this object. If False, saves this object only. </param>
        /// <param name="deepLoadType">DeepLoadType Enumeration to Include/Exclude object property collections from Load.</param>
        /// <param name="childTypes">Nettiers.AdventureWorks.Entities.PurchaseOrderHeader Property Collection Type Array To Include or Exclude from Load</param>
        /// <param name="innerList">A collection of child types for easy access.</param>
        /// <exception cref="ArgumentNullException">entity or childTypes is null.</exception>
        /// <exception cref="ArgumentException">deepLoadType has invalid value.</exception>
        public override void DeepLoad(TransactionManager transactionManager, Nettiers.AdventureWorks.Entities.PurchaseOrderHeader entity, bool deep, DeepLoadType deepLoadType, System.Type[] childTypes, DeepSession innerList)
        {
            if (entity == null)
            {
                return;
            }

            #region EmployeeIdSource
            if (CanDeepLoad(entity, "Employee|EmployeeIdSource", deepLoadType, innerList) &&
                entity.EmployeeIdSource == null)
            {
                object[] pkItems = new object[1];
                pkItems[0] = entity.EmployeeId;
                Employee tmpEntity = EntityManager.LocateEntity <Employee>(EntityLocator.ConstructKeyFromPkItems(typeof(Employee), pkItems), DataRepository.Provider.EnableEntityTracking);
                if (tmpEntity != null)
                {
                    entity.EmployeeIdSource = tmpEntity;
                }
                else
                {
                    entity.EmployeeIdSource = DataRepository.EmployeeProvider.GetByEmployeeId(transactionManager, entity.EmployeeId);
                }

                                #if NETTIERS_DEBUG
                System.Diagnostics.Debug.WriteLine("- property 'EmployeeIdSource' loaded. key " + entity.EntityTrackingKey);
                                #endif

                if (deep && entity.EmployeeIdSource != null)
                {
                    innerList.SkipChildren = true;
                    DataRepository.EmployeeProvider.DeepLoad(transactionManager, entity.EmployeeIdSource, deep, deepLoadType, childTypes, innerList);
                    innerList.SkipChildren = false;
                }
            }
            #endregion EmployeeIdSource

            #region ShipMethodIdSource
            if (CanDeepLoad(entity, "ShipMethod|ShipMethodIdSource", deepLoadType, innerList) &&
                entity.ShipMethodIdSource == null)
            {
                object[] pkItems = new object[1];
                pkItems[0] = entity.ShipMethodId;
                ShipMethod tmpEntity = EntityManager.LocateEntity <ShipMethod>(EntityLocator.ConstructKeyFromPkItems(typeof(ShipMethod), pkItems), DataRepository.Provider.EnableEntityTracking);
                if (tmpEntity != null)
                {
                    entity.ShipMethodIdSource = tmpEntity;
                }
                else
                {
                    entity.ShipMethodIdSource = DataRepository.ShipMethodProvider.GetByShipMethodId(transactionManager, entity.ShipMethodId);
                }

                                #if NETTIERS_DEBUG
                System.Diagnostics.Debug.WriteLine("- property 'ShipMethodIdSource' loaded. key " + entity.EntityTrackingKey);
                                #endif

                if (deep && entity.ShipMethodIdSource != null)
                {
                    innerList.SkipChildren = true;
                    DataRepository.ShipMethodProvider.DeepLoad(transactionManager, entity.ShipMethodIdSource, deep, deepLoadType, childTypes, innerList);
                    innerList.SkipChildren = false;
                }
            }
            #endregion ShipMethodIdSource

            #region VendorIdSource
            if (CanDeepLoad(entity, "Vendor|VendorIdSource", deepLoadType, innerList) &&
                entity.VendorIdSource == null)
            {
                object[] pkItems = new object[1];
                pkItems[0] = entity.VendorId;
                Vendor tmpEntity = EntityManager.LocateEntity <Vendor>(EntityLocator.ConstructKeyFromPkItems(typeof(Vendor), pkItems), DataRepository.Provider.EnableEntityTracking);
                if (tmpEntity != null)
                {
                    entity.VendorIdSource = tmpEntity;
                }
                else
                {
                    entity.VendorIdSource = DataRepository.VendorProvider.GetByVendorId(transactionManager, entity.VendorId);
                }

                                #if NETTIERS_DEBUG
                System.Diagnostics.Debug.WriteLine("- property 'VendorIdSource' loaded. key " + entity.EntityTrackingKey);
                                #endif

                if (deep && entity.VendorIdSource != null)
                {
                    innerList.SkipChildren = true;
                    DataRepository.VendorProvider.DeepLoad(transactionManager, entity.VendorIdSource, deep, deepLoadType, childTypes, innerList);
                    innerList.SkipChildren = false;
                }
            }
            #endregion VendorIdSource

            //used to hold DeepLoad method delegates and fire after all the local children have been loaded.
            Dictionary <string, KeyValuePair <Delegate, object> > deepHandles = new Dictionary <string, KeyValuePair <Delegate, object> >();
            // Deep load child collections  - Call GetByPurchaseOrderId methods when available

            #region PurchaseOrderDetailCollection
            //Relationship Type One : Many
            if (CanDeepLoad(entity, "List<PurchaseOrderDetail>|PurchaseOrderDetailCollection", deepLoadType, innerList))
            {
                                #if NETTIERS_DEBUG
                System.Diagnostics.Debug.WriteLine("- property 'PurchaseOrderDetailCollection' loaded. key " + entity.EntityTrackingKey);
                                #endif

                entity.PurchaseOrderDetailCollection = DataRepository.PurchaseOrderDetailProvider.GetByPurchaseOrderId(transactionManager, entity.PurchaseOrderId);

                if (deep && entity.PurchaseOrderDetailCollection.Count > 0)
                {
                    deepHandles.Add("PurchaseOrderDetailCollection",
                                    new KeyValuePair <Delegate, object>((DeepLoadHandle <PurchaseOrderDetail>)DataRepository.PurchaseOrderDetailProvider.DeepLoad,
                                                                        new object[] { transactionManager, entity.PurchaseOrderDetailCollection, deep, deepLoadType, childTypes, innerList }
                                                                        ));
                }
            }
            #endregion


            //Fire all DeepLoad Items
            foreach (KeyValuePair <Delegate, object> pair in deepHandles.Values)
            {
                pair.Key.DynamicInvoke((object[])pair.Value);
            }
            deepHandles = null;
        }
        /// <summary>
        /// Deep Loads the <see cref="IEntity"/> object with criteria based of the child
        /// property collections only N Levels Deep based on the <see cref="DeepLoadType"/>.
        /// </summary>
        /// <remarks>
        /// Use this method with caution as it is possible to DeepLoad with Recursion and traverse an entire object graph.
        /// </remarks>
        /// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
        /// <param name="entity">The <see cref="Nettiers.AdventureWorks.Entities.ProductVendor"/> object to load.</param>
        /// <param name="deep">Boolean. A flag that indicates whether to recursively save all Property Collection that are descendants of this instance. If True, saves the complete object graph below this object. If False, saves this object only. </param>
        /// <param name="deepLoadType">DeepLoadType Enumeration to Include/Exclude object property collections from Load.</param>
        /// <param name="childTypes">Nettiers.AdventureWorks.Entities.ProductVendor Property Collection Type Array To Include or Exclude from Load</param>
        /// <param name="innerList">A collection of child types for easy access.</param>
        /// <exception cref="ArgumentNullException">entity or childTypes is null.</exception>
        /// <exception cref="ArgumentException">deepLoadType has invalid value.</exception>
        public override void DeepLoad(TransactionManager transactionManager, Nettiers.AdventureWorks.Entities.ProductVendor entity, bool deep, DeepLoadType deepLoadType, System.Type[] childTypes, DeepSession innerList)
        {
            if (entity == null)
            {
                return;
            }

            #region ProductIdSource
            if (CanDeepLoad(entity, "Product|ProductIdSource", deepLoadType, innerList) &&
                entity.ProductIdSource == null)
            {
                object[] pkItems = new object[1];
                pkItems[0] = entity.ProductId;
                Product tmpEntity = EntityManager.LocateEntity <Product>(EntityLocator.ConstructKeyFromPkItems(typeof(Product), pkItems), DataRepository.Provider.EnableEntityTracking);
                if (tmpEntity != null)
                {
                    entity.ProductIdSource = tmpEntity;
                }
                else
                {
                    entity.ProductIdSource = DataRepository.ProductProvider.GetByProductId(transactionManager, entity.ProductId);
                }

                                #if NETTIERS_DEBUG
                System.Diagnostics.Debug.WriteLine("- property 'ProductIdSource' loaded. key " + entity.EntityTrackingKey);
                                #endif

                if (deep && entity.ProductIdSource != null)
                {
                    innerList.SkipChildren = true;
                    DataRepository.ProductProvider.DeepLoad(transactionManager, entity.ProductIdSource, deep, deepLoadType, childTypes, innerList);
                    innerList.SkipChildren = false;
                }
            }
            #endregion ProductIdSource

            #region UnitMeasureCodeSource
            if (CanDeepLoad(entity, "UnitMeasure|UnitMeasureCodeSource", deepLoadType, innerList) &&
                entity.UnitMeasureCodeSource == null)
            {
                object[] pkItems = new object[1];
                pkItems[0] = entity.UnitMeasureCode;
                UnitMeasure tmpEntity = EntityManager.LocateEntity <UnitMeasure>(EntityLocator.ConstructKeyFromPkItems(typeof(UnitMeasure), pkItems), DataRepository.Provider.EnableEntityTracking);
                if (tmpEntity != null)
                {
                    entity.UnitMeasureCodeSource = tmpEntity;
                }
                else
                {
                    entity.UnitMeasureCodeSource = DataRepository.UnitMeasureProvider.GetByUnitMeasureCode(transactionManager, entity.UnitMeasureCode);
                }

                                #if NETTIERS_DEBUG
                System.Diagnostics.Debug.WriteLine("- property 'UnitMeasureCodeSource' loaded. key " + entity.EntityTrackingKey);
                                #endif

                if (deep && entity.UnitMeasureCodeSource != null)
                {
                    innerList.SkipChildren = true;
                    DataRepository.UnitMeasureProvider.DeepLoad(transactionManager, entity.UnitMeasureCodeSource, deep, deepLoadType, childTypes, innerList);
                    innerList.SkipChildren = false;
                }
            }
            #endregion UnitMeasureCodeSource

            #region VendorIdSource
            if (CanDeepLoad(entity, "Vendor|VendorIdSource", deepLoadType, innerList) &&
                entity.VendorIdSource == null)
            {
                object[] pkItems = new object[1];
                pkItems[0] = entity.VendorId;
                Vendor tmpEntity = EntityManager.LocateEntity <Vendor>(EntityLocator.ConstructKeyFromPkItems(typeof(Vendor), pkItems), DataRepository.Provider.EnableEntityTracking);
                if (tmpEntity != null)
                {
                    entity.VendorIdSource = tmpEntity;
                }
                else
                {
                    entity.VendorIdSource = DataRepository.VendorProvider.GetByVendorId(transactionManager, entity.VendorId);
                }

                                #if NETTIERS_DEBUG
                System.Diagnostics.Debug.WriteLine("- property 'VendorIdSource' loaded. key " + entity.EntityTrackingKey);
                                #endif

                if (deep && entity.VendorIdSource != null)
                {
                    innerList.SkipChildren = true;
                    DataRepository.VendorProvider.DeepLoad(transactionManager, entity.VendorIdSource, deep, deepLoadType, childTypes, innerList);
                    innerList.SkipChildren = false;
                }
            }
            #endregion VendorIdSource

            //used to hold DeepLoad method delegates and fire after all the local children have been loaded.
            Dictionary <string, KeyValuePair <Delegate, object> > deepHandles = new Dictionary <string, KeyValuePair <Delegate, object> >();

            //Fire all DeepLoad Items
            foreach (KeyValuePair <Delegate, object> pair in deepHandles.Values)
            {
                pair.Key.DynamicInvoke((object[])pair.Value);
            }
            deepHandles = null;
        }
Exemple #24
0
        private void ModifyClayMan()
        {
            AISkillDriver clayPrimary = clayMaster.GetComponent <AISkillDriver>();

            clayPrimary.maxDistance = 16f;
            clayMaster.GetComponent <CharacterMaster>().bodyPrefab = clayObject;

            LanguageAPI.Add("CLAY_BODY_NAME", "Clay Man");

            LanguageAPI.Add("CLAY_BODY_LORE", "Quick with his sword and quicker with his feet; the agility of these clay 'people' is unexpected with a form so roughly shaped.\n\nWhen faced with one of the few creatures here which I feel some humanity in, my aloneness closes in. Why do they have clay pots on their heads? Could it be protection from this cruel reality, or maybe just to hide the scars from this brutal planet.");
            clayObject.AddComponent <Interactor>().maxInteractionDistance = 3f;
            clayObject.AddComponent <InteractionDriver>();

            ModelLocator clayModelLocator = clayObject.GetComponent <ModelLocator>();

            clayModelLocator.modelTransform.gameObject.layer = LayerIndex.entityPrecise.intVal;
            clayModelLocator.modelTransform.localScale      *= 1.2f;
            clayModelLocator.noCorpse = true;

            CharacterDeathBehavior clayCDB = clayObject.GetComponent <CharacterDeathBehavior>();

            clayCDB.deathState = Resources.Load <GameObject>("prefabs/characterbodies/WispBody").GetComponent <CharacterDeathBehavior>().deathState;

            CharacterBody clayCB = clayObject.GetComponent <CharacterBody>();

            clayCB.baseNameToken  = "CLAY_BODY_NAME";
            clayCB.baseJumpPower  = 22f;
            clayCB.baseMaxHealth  = 140f;
            clayCB.levelMaxHealth = clayCB.baseMaxHealth * 0.3f;
            clayCB.baseArmor      = 0f;
            clayCB.baseDamage     = 11f;
            clayCB.levelDamage    = clayCB.baseDamage * 0.2f;
            clayCB.baseMoveSpeed  = 9f;
            clayCB.baseRegen      = 0f;
            clayCB.levelRegen     = 0f;
            clayCB.bodyFlags      = CharacterBody.BodyFlags.ImmuneToGoo;

            //Debug.Log(clayCB.GetComponent<DeathRewards>().logUnlockableName);

            /*UnlockableDef clayLog = ScriptableObject.CreateInstance<UnlockableDef>();
             * clayCB.GetComponent<DeathRewards>().logUnlockableDef = clayLog;*/

            SetStateOnHurt claySSoH = clayObject.AddComponent <SetStateOnHurt>();

            claySSoH.canBeFrozen     = true;
            claySSoH.canBeStunned    = true;
            claySSoH.canBeHitStunned = false;
            claySSoH.hitThreshold    = 0.15f;

            SfxLocator claySFX = clayObject.GetComponent <SfxLocator>();

            claySFX.deathSound = "Play_clayboss_M1_explo";
            claySFX.barkSound  = "";

            //Ice Fix Credits: SushiDev
            int i = 0;

            EntityStateMachine[] esmr = new EntityStateMachine[2];
            foreach (EntityStateMachine esm in clayObject.GetComponentsInChildren <EntityStateMachine>())
            {
                switch (esm.customName)
                {
                case "Body":
                    claySSoH.targetStateMachine = esm;
                    break;

                default:
                    if (i < 2)
                    {
                        esmr[i] = esm;
                    }
                    i++;
                    break;
                }
            }

            #region hitbox
            Component[] clayComponents           = clayObject.GetComponentsInChildren <Transform>();
            Transform   clayTransform            = null;
            Transform   clayHeadTransform        = null;
            Transform   claySwordHitboxTransform = null;
            foreach (Transform t in clayComponents)
            {
                if (t.name == "chest")
                {
                    clayTransform = t;
                }
                else if (t.name == "head")
                {
                    clayHeadTransform = t;
                }
                else if (t.name == "Hitbox")
                {
                    claySwordHitboxTransform = t;
                }
                if (clayTransform != null && clayHeadTransform != null && claySwordHitboxTransform != null)
                {
                    break;
                }
            }

            ItemDisplays.headTransform = clayHeadTransform;

            HurtBoxGroup clayHurtBoxGroup = clayModelLocator.modelTransform.gameObject.AddComponent <HurtBoxGroup>();
            claySwordHitboxTransform.localScale *= 2.4f; //2.8 -> 2.4

            #region chest
            clayTransform.gameObject.layer = LayerIndex.entityPrecise.intVal;
            CapsuleCollider clayCollider = clayTransform.gameObject.AddComponent <CapsuleCollider>();
            clayCollider.center -= new Vector3(0, 0.6f, 0);
            clayCollider.height *= 0.25f;
            clayCollider.radius *= 1.16f;
            HurtBox clayHurtBox = clayTransform.gameObject.AddComponent <HurtBox>();
            clayHurtBox.isBullseye      = true;
            clayHurtBox.healthComponent = clayObject.GetComponent <HealthComponent>();
            clayHurtBox.damageModifier  = HurtBox.DamageModifier.Normal;
            clayHurtBox.hurtBoxGroup    = clayHurtBoxGroup;
            clayHurtBox.indexInGroup    = 0;
            //clayHurtBox.name = "ChestHurtbox";
            #endregion

            #region head


            clayHeadTransform.gameObject.layer = LayerIndex.entityPrecise.intVal;
            CapsuleCollider clayHeadCollider = clayHeadTransform.gameObject.AddComponent <CapsuleCollider>();
            clayHeadCollider.height *= 0.4f;
            clayHeadCollider.radius *= 0.3f;
            clayHeadCollider.center += new Vector3(0, 0.2f, 0);
            HurtBox clayHeadHurtBox = clayHeadTransform.gameObject.AddComponent <HurtBox>();
            clayHeadHurtBox.isBullseye      = false;
            clayHeadHurtBox.healthComponent = clayObject.GetComponent <HealthComponent>();
            clayHeadHurtBox.damageModifier  = HurtBox.DamageModifier.SniperTarget;
            clayHeadHurtBox.hurtBoxGroup    = clayHurtBoxGroup;
            clayHeadHurtBox.indexInGroup    = 1;
            //clayHeadHurtBox.name = "HeadHurtbox";

            #endregion

            HurtBox[] clayHurtBoxArray = new HurtBox[]
            {
                clayHurtBox, clayHeadHurtBox
            };

            clayHurtBoxGroup.bullseyeCount = 1;
            clayHurtBoxGroup.hurtBoxes     = clayHurtBoxArray;
            clayHurtBoxGroup.mainHurtBox   = clayHurtBox;

            #endregion

            EntityLocator clayLocator = clayObject.AddComponent <EntityLocator>();
            clayLocator.entity = clayObject;
        }
 internal override void DeepLoad(TransactionManager transactionManager, Trouble entity, bool deep, DeepLoadType deepLoadType, Type[] childTypes, ChildEntityTypesList innerList)
 {
     if ((entity != null) && (base.CanDeepLoad(entity, "InspectSituation", "InspectSituationIDSource", deepLoadType, innerList) && (entity.InspectSituationIDSource == null)))
     {
         object[]         pkItems   = new object[] { entity.InspectSituationID };
         InspectSituation situation = EntityManager.LocateEntity <InspectSituation>(EntityLocator.ConstructKeyFromPkItems(typeof(InspectSituation), pkItems), DataRepository.Provider.EnableEntityTracking);
         if (situation != null)
         {
             entity.InspectSituationIDSource = situation;
         }
         else
         {
             entity.InspectSituationIDSource = DataRepository.InspectSituationProvider.GetByInspectSituationID(entity.InspectSituationID);
         }
         if (deep && (entity.InspectSituationIDSource != null))
         {
             DataRepository.InspectSituationProvider.DeepLoad(transactionManager, entity.InspectSituationIDSource, deep, deepLoadType, childTypes, innerList);
         }
     }
 }
Exemple #26
0
        /// <summary>
        /// Deep Loads the <see cref="IEntity"/> object with criteria based of the child
        /// property collections only N Levels Deep based on the <see cref="DeepLoadType"/>.
        /// </summary>
        /// <remarks>
        /// Use this method with caution as it is possible to DeepLoad with Recursion and traverse an entire object graph.
        /// </remarks>
        /// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
        /// <param name="entity">The <see cref="GenTest.Entities.Macchina"/> object to load.</param>
        /// <param name="deep">Boolean. A flag that indicates whether to recursively save all Property Collection that are descendants of this instance. If True, saves the complete object graph below this object. If False, saves this object only. </param>
        /// <param name="deepLoadType">DeepLoadType Enumeration to Include/Exclude object property collections from Load.</param>
        /// <param name="childTypes">GenTest.Entities.Macchina Property Collection Type Array To Include or Exclude from Load</param>
        /// <param name="innerList">A collection of child types for easy access.</param>
        /// <exception cref="ArgumentNullException">entity or childTypes is null.</exception>
        /// <exception cref="ArgumentException">deepLoadType has invalid value.</exception>
        public override void DeepLoad(TransactionManager transactionManager, GenTest.Entities.Macchina entity, bool deep, DeepLoadType deepLoadType, System.Type[] childTypes, DeepSession innerList)
        {
            if (entity == null)
            {
                return;
            }

            #region CropAggregationMacchinaIDSource
            if (CanDeepLoad(entity, "Macchina|CropAggregationMacchinaIDSource", deepLoadType, innerList) &&
                entity.CropAggregationMacchinaIDSource == null)
            {
                object[] pkItems = new object[1];
                pkItems[0] = (entity.CropAggregationMacchinaID ?? (int)0);
                Macchina tmpEntity = EntityManager.LocateEntity <Macchina>(EntityLocator.ConstructKeyFromPkItems(typeof(Macchina), pkItems), DataRepository.Provider.EnableEntityTracking);
                if (tmpEntity != null)
                {
                    entity.CropAggregationMacchinaIDSource = tmpEntity;
                }
                else
                {
                    entity.CropAggregationMacchinaIDSource = DataRepository.MacchinaProvider.GetByID(transactionManager, (entity.CropAggregationMacchinaID ?? (int)0));
                }

                                #if NETTIERS_DEBUG
                System.Diagnostics.Debug.WriteLine("- property 'CropAggregationMacchinaIDSource' loaded. key " + entity.EntityTrackingKey);
                                #endif

                if (deep && entity.CropAggregationMacchinaIDSource != null)
                {
                    innerList.SkipChildren = true;
                    DataRepository.MacchinaProvider.DeepLoad(transactionManager, entity.CropAggregationMacchinaIDSource, deep, deepLoadType, childTypes, innerList);
                    innerList.SkipChildren = false;
                }
            }
            #endregion CropAggregationMacchinaIDSource

            #region AssociationMotoreIDSource
            if (CanDeepLoad(entity, "Motore|AssociationMotoreIDSource", deepLoadType, innerList) &&
                entity.AssociationMotoreIDSource == null)
            {
                object[] pkItems = new object[1];
                pkItems[0] = (entity.AssociationMotoreID ?? (int)0);
                Motore tmpEntity = EntityManager.LocateEntity <Motore>(EntityLocator.ConstructKeyFromPkItems(typeof(Motore), pkItems), DataRepository.Provider.EnableEntityTracking);
                if (tmpEntity != null)
                {
                    entity.AssociationMotoreIDSource = tmpEntity;
                }
                else
                {
                    entity.AssociationMotoreIDSource = DataRepository.MotoreProvider.GetByID(transactionManager, (entity.AssociationMotoreID ?? (int)0));
                }

                                #if NETTIERS_DEBUG
                System.Diagnostics.Debug.WriteLine("- property 'AssociationMotoreIDSource' loaded. key " + entity.EntityTrackingKey);
                                #endif

                if (deep && entity.AssociationMotoreIDSource != null)
                {
                    innerList.SkipChildren = true;
                    DataRepository.MotoreProvider.DeepLoad(transactionManager, entity.AssociationMotoreIDSource, deep, deepLoadType, childTypes, innerList);
                    innerList.SkipChildren = false;
                }
            }
            #endregion AssociationMotoreIDSource

            //used to hold DeepLoad method delegates and fire after all the local children have been loaded.
            Dictionary <string, KeyValuePair <Delegate, object> > deepHandles = new Dictionary <string, KeyValuePair <Delegate, object> >();
            // Deep load child collections  - Call GetByID methods when available

            #region SpecchiettoCollection
            //Relationship Type One : Many
            if (CanDeepLoad(entity, "List<Specchietto>|SpecchiettoCollection", deepLoadType, innerList))
            {
                                #if NETTIERS_DEBUG
                System.Diagnostics.Debug.WriteLine("- property 'SpecchiettoCollection' loaded. key " + entity.EntityTrackingKey);
                                #endif

                entity.SpecchiettoCollection = DataRepository.SpecchiettoProvider.GetByAggregationMacchinaID(transactionManager, entity.ID);

                if (deep && entity.SpecchiettoCollection.Count > 0)
                {
                    deepHandles.Add("SpecchiettoCollection",
                                    new KeyValuePair <Delegate, object>((DeepLoadHandle <Specchietto>)DataRepository.SpecchiettoProvider.DeepLoad,
                                                                        new object[] { transactionManager, entity.SpecchiettoCollection, deep, deepLoadType, childTypes, innerList }
                                                                        ));
                }
            }
            #endregion


            #region MacchinaCollection
            //Relationship Type One : Many
            if (CanDeepLoad(entity, "List<Macchina>|MacchinaCollection", deepLoadType, innerList))
            {
                                #if NETTIERS_DEBUG
                System.Diagnostics.Debug.WriteLine("- property 'MacchinaCollection' loaded. key " + entity.EntityTrackingKey);
                                #endif

                entity.MacchinaCollection = DataRepository.MacchinaProvider.GetByCropAggregationMacchinaID(transactionManager, entity.ID);

                if (deep && entity.MacchinaCollection.Count > 0)
                {
                    deepHandles.Add("MacchinaCollection",
                                    new KeyValuePair <Delegate, object>((DeepLoadHandle <Macchina>)DataRepository.MacchinaProvider.DeepLoad,
                                                                        new object[] { transactionManager, entity.MacchinaCollection, deep, deepLoadType, childTypes, innerList }
                                                                        ));
                }
            }
            #endregion


            //Fire all DeepLoad Items
            foreach (KeyValuePair <Delegate, object> pair in deepHandles.Values)
            {
                pair.Key.DynamicInvoke((object[])pair.Value);
            }
            deepHandles = null;
        }
Exemple #27
0
        /// <summary>
        /// Deep Loads the <see cref="IEntity"/> object with criteria based of the child
        /// property collections only N Levels Deep based on the <see cref="DeepLoadType"/>.
        /// </summary>
        /// <remarks>
        /// Use this method with caution as it is possible to DeepLoad with Recursion and traverse an entire object graph.
        /// </remarks>
        /// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
        /// <param name="entity">The <see cref="GenTest.Entities.RigaFattura"/> object to load.</param>
        /// <param name="deep">Boolean. A flag that indicates whether to recursively save all Property Collection that are descendants of this instance. If True, saves the complete object graph below this object. If False, saves this object only. </param>
        /// <param name="deepLoadType">DeepLoadType Enumeration to Include/Exclude object property collections from Load.</param>
        /// <param name="childTypes">GenTest.Entities.RigaFattura Property Collection Type Array To Include or Exclude from Load</param>
        /// <param name="innerList">A collection of child types for easy access.</param>
        /// <exception cref="ArgumentNullException">entity or childTypes is null.</exception>
        /// <exception cref="ArgumentException">deepLoadType has invalid value.</exception>
        internal override void DeepLoad(TransactionManager transactionManager, GenTest.Entities.RigaFattura entity, bool deep, DeepLoadType deepLoadType, System.Type[] childTypes, DeepSession innerList)
        {
            if (entity == null)
            {
                return;
            }

            #region ComposedFatturaIDSource
            if (CanDeepLoad(entity, "Fattura|ComposedFatturaIDSource", deepLoadType, innerList) &&
                entity.ComposedFatturaIDSource == null)
            {
                object[] pkItems = new object[1];
                pkItems[0] = (entity.ComposedFatturaID ?? (int)0);
                Fattura tmpEntity = EntityManager.LocateEntity <Fattura>(EntityLocator.ConstructKeyFromPkItems(typeof(Fattura), pkItems), DataRepository.Provider.EnableEntityTracking);
                if (tmpEntity != null)
                {
                    entity.ComposedFatturaIDSource = tmpEntity;
                }
                else
                {
                    entity.ComposedFatturaIDSource = DataRepository.FatturaProvider.GetByID(transactionManager, (entity.ComposedFatturaID ?? (int)0));
                }

                                #if NETTIERS_DEBUG
                System.Diagnostics.Debug.WriteLine("- property 'ComposedFatturaIDSource' loaded. key " + entity.EntityTrackingKey);
                                #endif

                if (deep && entity.ComposedFatturaIDSource != null)
                {
                    innerList.SkipChildren = true;
                    DataRepository.FatturaProvider.DeepLoad(transactionManager, entity.ComposedFatturaIDSource, deep, deepLoadType, childTypes, innerList);
                    innerList.SkipChildren = false;
                }
            }
            #endregion ComposedFatturaIDSource

            #region AggregatedFatturaIDSource
            if (CanDeepLoad(entity, "Fattura|AggregatedFatturaIDSource", deepLoadType, innerList) &&
                entity.AggregatedFatturaIDSource == null)
            {
                object[] pkItems = new object[1];
                pkItems[0] = (entity.AggregatedFatturaID ?? (int)0);
                Fattura tmpEntity = EntityManager.LocateEntity <Fattura>(EntityLocator.ConstructKeyFromPkItems(typeof(Fattura), pkItems), DataRepository.Provider.EnableEntityTracking);
                if (tmpEntity != null)
                {
                    entity.AggregatedFatturaIDSource = tmpEntity;
                }
                else
                {
                    entity.AggregatedFatturaIDSource = DataRepository.FatturaProvider.GetByID(transactionManager, (entity.AggregatedFatturaID ?? (int)0));
                }

                                #if NETTIERS_DEBUG
                System.Diagnostics.Debug.WriteLine("- property 'AggregatedFatturaIDSource' loaded. key " + entity.EntityTrackingKey);
                                #endif

                if (deep && entity.AggregatedFatturaIDSource != null)
                {
                    innerList.SkipChildren = true;
                    DataRepository.FatturaProvider.DeepLoad(transactionManager, entity.AggregatedFatturaIDSource, deep, deepLoadType, childTypes, innerList);
                    innerList.SkipChildren = false;
                }
            }
            #endregion AggregatedFatturaIDSource

            #region AssociatedFatturaIDSource
            if (CanDeepLoad(entity, "Fattura|AssociatedFatturaIDSource", deepLoadType, innerList) &&
                entity.AssociatedFatturaIDSource == null)
            {
                object[] pkItems = new object[1];
                pkItems[0] = (entity.AssociatedFatturaID ?? (int)0);
                Fattura tmpEntity = EntityManager.LocateEntity <Fattura>(EntityLocator.ConstructKeyFromPkItems(typeof(Fattura), pkItems), DataRepository.Provider.EnableEntityTracking);
                if (tmpEntity != null)
                {
                    entity.AssociatedFatturaIDSource = tmpEntity;
                }
                else
                {
                    entity.AssociatedFatturaIDSource = DataRepository.FatturaProvider.GetByID(transactionManager, (entity.AssociatedFatturaID ?? (int)0));
                }

                                #if NETTIERS_DEBUG
                System.Diagnostics.Debug.WriteLine("- property 'AssociatedFatturaIDSource' loaded. key " + entity.EntityTrackingKey);
                                #endif

                if (deep && entity.AssociatedFatturaIDSource != null)
                {
                    innerList.SkipChildren = true;
                    DataRepository.FatturaProvider.DeepLoad(transactionManager, entity.AssociatedFatturaIDSource, deep, deepLoadType, childTypes, innerList);
                    innerList.SkipChildren = false;
                }
            }
            #endregion AssociatedFatturaIDSource

            //used to hold DeepLoad method delegates and fire after all the local children have been loaded.
            Dictionary <string, KeyValuePair <Delegate, object> > deepHandles = new Dictionary <string, KeyValuePair <Delegate, object> >();
            // Deep load child collections  - Call GetByID methods when available

            #region FatturaCollectionGetByAggregatedRigaFatturaID
            //Relationship Type One : Many
            if (CanDeepLoad(entity, "List<Fattura>|FatturaCollectionGetByAggregatedRigaFatturaID", deepLoadType, innerList))
            {
                                #if NETTIERS_DEBUG
                System.Diagnostics.Debug.WriteLine("- property 'FatturaCollectionGetByAggregatedRigaFatturaID' loaded. key " + entity.EntityTrackingKey);
                                #endif

                entity.FatturaCollectionGetByAggregatedRigaFatturaID = DataRepository.FatturaProvider.GetByAggregatedRigaFatturaID(transactionManager, entity.ID);

                if (deep && entity.FatturaCollectionGetByAggregatedRigaFatturaID.Count > 0)
                {
                    deepHandles.Add("FatturaCollectionGetByAggregatedRigaFatturaID",
                                    new KeyValuePair <Delegate, object>((DeepLoadHandle <Fattura>)DataRepository.FatturaProvider.DeepLoad,
                                                                        new object[] { transactionManager, entity.FatturaCollectionGetByAggregatedRigaFatturaID, deep, deepLoadType, childTypes, innerList }
                                                                        ));
                }
            }
            #endregion


            #region Fattura
            // RelationshipType.OneToOne
            if (CanDeepLoad(entity, "Fattura|Fattura", deepLoadType, innerList))
            {
                entity.Fattura = DataRepository.FatturaProvider.GetByAssociatedRigaFatturaID(transactionManager, entity.ID);
                                #if NETTIERS_DEBUG
                System.Diagnostics.Debug.WriteLine("- property 'Fattura' loaded. key " + entity.EntityTrackingKey);
                                #endif

                if (deep && entity.Fattura != null)
                {
                    deepHandles.Add("Fattura",
                                    new KeyValuePair <Delegate, object>((DeepLoadSingleHandle <Fattura>)DataRepository.FatturaProvider.DeepLoad,
                                                                        new object[] { transactionManager, entity.Fattura, deep, deepLoadType, childTypes, innerList }
                                                                        ));
                }
            }
            #endregion



            #region FatturaCollectionGetByComposedRigaFatturaID
            //Relationship Type One : Many
            if (CanDeepLoad(entity, "List<Fattura>|FatturaCollectionGetByComposedRigaFatturaID", deepLoadType, innerList))
            {
                                #if NETTIERS_DEBUG
                System.Diagnostics.Debug.WriteLine("- property 'FatturaCollectionGetByComposedRigaFatturaID' loaded. key " + entity.EntityTrackingKey);
                                #endif

                entity.FatturaCollectionGetByComposedRigaFatturaID = DataRepository.FatturaProvider.GetByComposedRigaFatturaID(transactionManager, entity.ID);

                if (deep && entity.FatturaCollectionGetByComposedRigaFatturaID.Count > 0)
                {
                    deepHandles.Add("FatturaCollectionGetByComposedRigaFatturaID",
                                    new KeyValuePair <Delegate, object>((DeepLoadHandle <Fattura>)DataRepository.FatturaProvider.DeepLoad,
                                                                        new object[] { transactionManager, entity.FatturaCollectionGetByComposedRigaFatturaID, deep, deepLoadType, childTypes, innerList }
                                                                        ));
                }
            }
            #endregion


            //Fire all DeepLoad Items
            foreach (KeyValuePair <Delegate, object> pair in deepHandles.Values)
            {
                pair.Key.DynamicInvoke((object[])pair.Value);
            }
            deepHandles = null;
        }