コード例 #1
0
 public RelationMemberTests()
 {
     Mock<IEntityCollection<IOsmGeometry>> _nodesCollectionM = new Mock<IEntityCollection<IOsmGeometry>>();
     _nodesCollectionM.SetupGet(c => c[1, EntityType.Node]).Returns(new Node(1, 1.1, 2.2));
     _nodesCollectionM.Setup(c => c.Contains(1, EntityType.Node)).Returns(true);
     _nodesEntityCollection = _nodesCollectionM.Object;
 }
コード例 #2
0
ファイル: BindableGrid.cs プロジェクト: lordfist/FistCore.Lib
 public BindableGrid(string id, IEntityCollection dataCollection)
 {
     this.ID = id;
     this.Value = null;
     this.Collection = dataCollection;
     if (this.Collection != null && this.Collection.IDbTable.PrimaryKey.Count > 0)
         this.ColumnName = this.Collection.IDbTable.PrimaryKey[0].ColumnName;
 }
コード例 #3
0
ファイル: WayTests.cs プロジェクト: najira/spatiallite-net
 public WayTests()
 {
     Mock<IEntityCollection<IOsmGeometry>> _nodesCollectionM = new Mock<IEntityCollection<IOsmGeometry>>();
     _nodesCollectionM.SetupGet(c => c[1, EntityType.Node]).Returns(_nodes[0]);
     _nodesCollectionM.SetupGet(c => c[2, EntityType.Node]).Returns(_nodes[1]);
     _nodesCollectionM.SetupGet(c => c[3, EntityType.Node]).Returns(_nodes[2]);
     _nodesEntityCollection = _nodesCollectionM.Object;
 }
コード例 #4
0
        public void BulkInsert(IConnectionProvider conn, IEntityCollection newEntities, IEntityDaoFactory daoFactory)
        {
            if (newEntities.Count == 0)
                return;

            DataTable newRecords = newEntities.ToDataTable();
            var bulkCopy = BuildSqlBulkCopy(conn, newEntities.IDbTable.TableName, newRecords);
            bulkCopy.WriteToServer(newRecords);
        }
コード例 #5
0
ファイル: AuditActionDAO.cs プロジェクト: priaonehaha/HnD
 /// <summary>Retrieves in the calling AuditActionCollection object all AuditActionEntity objects which are related via a relation of type 'm:n' with the passed in RoleEntity.</summary>
 /// <param name="containingTransaction">A containing transaction, if caller is added to a transaction, or null if not.</param>
 /// <param name="collectionToFill">Collection to fill with the entity objects retrieved</param>
 /// <param name="maxNumberOfItemsToReturn"> The maximum number of items to return with this retrieval query. When set to 0, no limitations are specified.</param>
 /// <param name="sortClauses">The order by specifications for the sorting of the resultset. When not specified, no sorting is applied.</param>
 /// <param name="entityFactoryToUse">The EntityFactory to use when creating entity objects during a GetMulti() call.</param>
 /// <param name="roleInstance">RoleEntity object to be used as a filter in the m:n relation</param>
 /// <param name="prefetchPathToUse">the PrefetchPath which defines the graph of objects to fetch.</param>
 /// <param name="pageNumber">The page number to retrieve.</param>
 /// <param name="pageSize">The page size of the page to retrieve.</param>
 /// <returns>true if succeeded, false otherwise</returns>
 public bool GetMultiUsingRolesWithAuditAction(ITransaction containingTransaction, IEntityCollection collectionToFill, long maxNumberOfItemsToReturn, ISortExpression sortClauses, IEntityFactory entityFactoryToUse, IEntity roleInstance, IPrefetchPath prefetchPathToUse, int pageNumber, int pageSize)
 {
     RelationCollection relations = new RelationCollection();
     relations.Add(AuditActionEntity.Relations.RoleAuditActionEntityUsingAuditActionID, "RoleAuditAction_");
     relations.Add(RoleAuditActionEntity.Relations.RoleEntityUsingRoleID, "RoleAuditAction_", string.Empty, JoinHint.None);
     IPredicateExpression selectFilter = new PredicateExpression();
     selectFilter.Add(new FieldCompareValuePredicate(roleInstance.Fields[(int)RoleFieldIndex.RoleID], ComparisonOperator.Equal));
     return this.GetMulti(containingTransaction, collectionToFill, maxNumberOfItemsToReturn, sortClauses, entityFactoryToUse, selectFilter, relations, prefetchPathToUse, pageNumber, pageSize);
 }
コード例 #6
0
ファイル: ProductCollection.cs プロジェクト: jlarc/Merchello
        /// <summary>
        /// Initializes a new instance of the <see cref="ProductCollection"/> class.
        /// </summary>
        /// <param name="entityCollection">
        /// The <see cref="IEntityCollection"/>.
        /// </param>
        /// <exception cref="Exception">
        /// Throws an exception if the <see cref="IEntityCollection"/> is not a product collection
        /// </exception>
        internal ProductCollection(IEntityCollection entityCollection)
        {
            Mandate.ParameterNotNull(entityCollection, "entityCollection");
            if (entityCollection.EntityTfKey != Core.Constants.TypeFieldKeys.Entity.ProductKey)
            {
                throw new Exception("Must be a product collection");
            }

            this._entityCollection = entityCollection;
        }
コード例 #7
0
 /// <summary>Retrieves in the calling MembershipCollection object all MembershipEntity objects which have data in common with the specified related Entities. If one is omitted, that entity is not used as a filter. </summary>
 /// <param name="containingTransaction">A containing transaction, if caller is added to a transaction, or null if not.</param>
 /// <param name="collectionToFill">Collection to fill with the entity objects retrieved</param>
 /// <param name="maxNumberOfItemsToReturn"> The maximum number of items to return with this retrieval query. When set to 0, no limitations are specified.</param>
 /// <param name="sortClauses">The order by specifications for the sorting of the resultset. When not specified, no sorting is applied.</param>
 /// <param name="entityFactoryToUse">The EntityFactory to use when creating entity objects during a GetMulti() call.</param>
 /// <param name="filter">Extra filter to limit the resultset. Predicate expression can be null, in which case it will be ignored.</param>
 /// <param name="roleInstance">RoleEntity instance to use as a filter for the MembershipEntity objects to return</param>
 /// <param name="storeInformationInstance">StoreInformationEntity instance to use as a filter for the MembershipEntity objects to return</param>
 /// <param name="pageNumber">The page number to retrieve.</param>
 /// <param name="pageSize">The page size of the page to retrieve.</param>
 public bool GetMulti(ITransaction containingTransaction, IEntityCollection collectionToFill, long maxNumberOfItemsToReturn, ISortExpression sortClauses, IEntityFactory entityFactoryToUse, IPredicateExpression filter, IEntity roleInstance, IEntity storeInformationInstance, int pageNumber, int pageSize)
 {
     this.EntityFactoryToUse = entityFactoryToUse;
     IEntityFields fieldsToReturn = EntityFieldsFactory.CreateEntityFieldsObject(ProductSearchEngine.EntityType.MembershipEntity);
     IPredicateExpression selectFilter = CreateFilterUsingForeignKeys(roleInstance, storeInformationInstance, fieldsToReturn);
     if(filter!=null)
     {
         selectFilter.AddWithAnd(filter);
     }
     return this.PerformGetMultiAction(containingTransaction, collectionToFill, maxNumberOfItemsToReturn, sortClauses, selectFilter, null, null, null, pageNumber, pageSize);
 }
コード例 #8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="EntityCollectionProxyBase"/> class.
        /// </summary>
        /// <param name="collection">
        /// The collection.
        /// </param>
        protected EntityCollectionProxyBase(IEntityCollection collection)
        {
            this.Key = collection.Key;
            this.ParentKey = collection.ParentKey;
            this.ProviderKey = collection.ProviderKey;
            this.SortOrder = collection.SortOrder;
            this.Name = collection.Name;
            this.ExtendedData = collection.ExtendedData;

            this.Initialize(collection.ProviderKey);
        }
コード例 #9
0
ファイル: ForumDAO.cs プロジェクト: priaonehaha/HnD
 /// <summary>Retrieves in the calling ForumCollection object all ForumEntity objects which have data in common with the specified related Entities. If one is omitted, that entity is not used as a filter. </summary>
 /// <param name="containingTransaction">A containing transaction, if caller is added to a transaction, or null if not.</param>
 /// <param name="collectionToFill">Collection to fill with the entity objects retrieved</param>
 /// <param name="maxNumberOfItemsToReturn"> The maximum number of items to return with this retrieval query. When set to 0, no limitations are specified.</param>
 /// <param name="sortClauses">The order by specifications for the sorting of the resultset. When not specified, no sorting is applied.</param>
 /// <param name="entityFactoryToUse">The EntityFactory to use when creating entity objects during a GetMulti() call.</param>
 /// <param name="filter">Extra filter to limit the resultset. Predicate expression can be null, in which case it will be ignored.</param>
 /// <param name="sectionInstance">SectionEntity instance to use as a filter for the ForumEntity objects to return</param>
 /// <param name="defaultSupportQueueInstance">SupportQueueEntity instance to use as a filter for the ForumEntity objects to return</param>
 /// <param name="pageNumber">The page number to retrieve.</param>
 /// <param name="pageSize">The page size of the page to retrieve.</param>
 public bool GetMulti(ITransaction containingTransaction, IEntityCollection collectionToFill, long maxNumberOfItemsToReturn, ISortExpression sortClauses, IEntityFactory entityFactoryToUse, IPredicateExpression filter, IEntity sectionInstance, IEntity defaultSupportQueueInstance, int pageNumber, int pageSize)
 {
     this.EntityFactoryToUse = entityFactoryToUse;
     IEntityFields fieldsToReturn = EntityFieldsFactory.CreateEntityFieldsObject(SD.HnD.DAL.EntityType.ForumEntity);
     IPredicateExpression selectFilter = CreateFilterUsingForeignKeys(sectionInstance, defaultSupportQueueInstance, fieldsToReturn);
     if(filter!=null)
     {
         selectFilter.AddWithAnd(filter);
     }
     return this.PerformGetMultiAction(containingTransaction, collectionToFill, maxNumberOfItemsToReturn, sortClauses, selectFilter, null, null, null, pageNumber, pageSize);
 }
コード例 #10
0
        /// <summary>
        /// Gets a generic page of Entities.
        /// </summary>
        /// <param name="collection">
        /// The collection.
        /// </param>
        /// <param name="page">
        /// The page.
        /// </param>
        /// <param name="itemsPerPage">
        /// The items per page.
        /// </param>
        /// <param name="sortBy">
        /// The sort by.
        /// </param>
        /// <param name="sortDirection">
        /// The sort direction.
        /// </param>
        /// <returns>
        /// The <see cref="Page"/>.
        /// </returns>
        public static Page <object> GetPagedEntities(
            this IEntityCollection collection,
            long page,
            long itemsPerPage,
            string sortBy = "",
            SortDirection sortDirection = SortDirection.Ascending)
        {
            var resolved = collection.ResolveProvider();

            return(resolved == null
                       ? new Page <object>()
                       : resolved.GetPagedEntities(page, itemsPerPage, sortBy, sortDirection));
        }
コード例 #11
0
 /// <summary>
 /// Sets the parent to root
 /// </summary>
 /// <param name="collection">
 /// The collection.
 /// </param>
 internal static void SetParent(this IEntityCollection collection)
 {
     if (collection.ParentKey == null)
     {
         return;
     }
     if (!MerchelloContext.HasCurrent)
     {
         return;
     }
     collection.ParentKey = null;
     MerchelloContext.Current.Services.EntityCollectionService.Save(collection);
 }
コード例 #12
0
        public void SubscribeToCollection(IEntityCollection collection)
        {
            var disposer = new CompositeDisposable
            {
                collection.EntityAdded.Subscribe(entity => entityAdded.OnNext(entity)),
                collection.EntityRemoved.Subscribe(entity => entityRemoved.OnNext(entity)),
                collection.EntityComponentsAdded.Subscribe(components => entityComponentsAdded.OnNext(components)),
                collection.EntityComponentsRemoving.Subscribe(components => entityComponentsRemoving.OnNext(components)),
                collection.EntityComponentsRemoved.Subscribe(components => entityComponentsRemoved.OnNext(components))
            };

            subscriptions.Add(collection.Name, disposer);
        }
コード例 #13
0
ファイル: Helpers.cs プロジェクト: saugkim/aaa_SpiceSharp
        /// <summary>
        /// Validates the collection of entities using the default rules.
        /// </summary>
        /// <param name="entities">The entities.</param>
        /// <returns>
        /// The rules used to validate the collection.
        /// </returns>
        public static IRules Validate(this IEntityCollection entities)
        {
            var rules = _defaultRules();

            foreach (var entity in entities)
            {
                if (entity is IRuleSubject subject)
                {
                    subject.Apply(rules);
                }
            }
            return(rules);
        }
コード例 #14
0
        private static void AddExits(IEntityCollection <ExitPoint> exitPoints, string[] exits)
        {
            bool isFirstExit = true;

            foreach (var exit in exits)
            {
                var ep = Entity.Create <ExitPoint>();
                ep.Name = exit;
                ep.IsDefaultExitPoint = isFirstExit;
                exitPoints.Add(ep);
                isFirstExit = false;
            }
        }
コード例 #15
0
ファイル: Excel.cs プロジェクト: incoplex/OfficeSharp
        // exports a collection to a workbook starting at the specified location
        public static dynamic ExportEntityCollection(IEntityCollection collection, string Workbook, string Worksheet, string Range, List <string> ColumnNames)
        {
            List <ColumnMapping> mappings = new List <ColumnMapping>();
            ColumnMapping        map      = default(ColumnMapping);

            foreach (string name in ColumnNames)
            {
                map = new ColumnMapping("", name);
                map.TableField.DisplayName = name;
                mappings.Add(map);
            }

            return(ExportEntityCollection(collection, Workbook, Worksheet, Range, mappings));
        }
コード例 #16
0
 /// <summary>
 /// Initializes a new instance of the <see cref="EntityFilterGroup"/> class.
 /// </summary>
 /// <param name="collection">
 /// The collection.
 /// </param>
 public EntityFilterGroup(IEntityCollection collection)
     : base(collection.EntityTfKey, collection.ProviderKey)
 {
     this.ParentKey    = collection.ParentKey;
     this.Key          = collection.Key;
     this.CreateDate   = collection.CreateDate;
     this.UpdateDate   = collection.UpdateDate;
     this.Name         = collection.Name;
     this.IsFilter     = collection.IsFilter;
     this.ExtendedData = collection.ExtendedData;
     this.SortOrder    = collection.SortOrder;
     this.Filters      = new EntityFilterCollection();
     this.ResetDirtyProperties();
 }
コード例 #17
0
 /// <summary>
 /// Initializes a new instance of the <see cref="EntityFilterGroup"/> class.
 /// </summary>
 /// <param name="collection">
 /// The collection.
 /// </param>
 public EntityFilterGroup(IEntityCollection collection)
     : base(collection.EntityTfKey, collection.ProviderKey)
 {
     this.ParentKey = collection.ParentKey;
     this.Key = collection.Key;
     this.CreateDate = collection.CreateDate;
     this.UpdateDate = collection.UpdateDate;
     this.Name = collection.Name;
     this.IsFilter = collection.IsFilter;
     this.ExtendedData = collection.ExtendedData;
     this.SortOrder = collection.SortOrder;
     this.Filters = new EntityFilterCollection();
     this.ResetDirtyProperties();
 }
コード例 #18
0
 public void AddRange(IEntityCollection <CalendarDate> entities)
 {
     using (var writer = _connection.BeginBinaryImport("COPY calendar_date (feed_id, service_id, date, exception_type) FROM STDIN (FORMAT BINARY)"))
     {
         foreach (var calendarDate in entities)
         {
             writer.StartRow();
             writer.Write(_id, NpgsqlTypes.NpgsqlDbType.Integer);
             writer.Write(calendarDate.ServiceId, NpgsqlTypes.NpgsqlDbType.Text);
             writer.Write(calendarDate.Date.ToUnixTime(), NpgsqlTypes.NpgsqlDbType.Bigint);
             writer.Write(calendarDate.ExceptionType, NpgsqlTypes.NpgsqlDbType.Integer);
         }
     }
 }
コード例 #19
0
ファイル: Excel.cs プロジェクト: incoplex/OfficeSharp
        // exports collection to a new workbook starting at cell A1 on the first worksheet
        public static dynamic ExportEntityCollection(IEntityCollection collection)
        {
            dynamic result = null;

            try
            {
                ExcelHelper excel = new ExcelHelper();
                excel.CreateWorkbook();

                List <string> columnNames = new List <string>();

                // get column properties
                IEnumerable <IEntityProperty> columnProperties = collection.OfType <IEntityObject>().First().Details.Properties.All();

                int columnCounter = 1;
                int rowCounter    = 1;

                // add columns names to the list
                foreach (IEntityProperty entityProperty in columnProperties)
                {
                    columnNames.Add(entityProperty.Name);

                    // add column headers to Excel workbook
                    excel.Cells(rowCounter, columnCounter, entityProperty.DisplayName);
                    columnCounter += 1;
                }

                // add values on the row following the headers
                rowCounter = 2;

                // iterate the collection and extract values by column name
                foreach (IEntityObject entityObj in collection)
                {
                    for (int i = 0; i <= columnNames.Count - 1; i++)
                    {
                        excel.Cells(rowCounter, i + 1, LightSwitchHelper.GetValue(entityObj, columnNames[i]));
                    }
                    rowCounter += 1;
                }

                excel.ShowWorkbook();
                result = excel.Workbook;
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(result);
        }
コード例 #20
0
 protected override void VisitEntityCollection(IEntityCollection entityCollection, MetaMember member)
 {
     if (member.IsComposition)
     {
         bool lastIsChild = this._isChild;
         this._isChild = true;
         IEnumerable <Entity> children = entityCollection.Entities;
         foreach (Entity child in children)
         {
             this.Visit(child);
         }
         this._isChild = lastIsChild;
     }
 }
コード例 #21
0
        /// <summary>
        ///     Implementation: gets all fields that are applicable to a set of types.
        /// </summary>
        private static IEnumerable <Field> GetAllFields(IEnumerable <EntityType> types)
        {
            var fields = new HashSet <Field>( );

            foreach (EntityType type in GetAllTypes(types))
            {
                IEntityCollection <Field> typeFields = type.Fields;
                if (typeFields != null)
                {
                    fields.AddRange(typeFields);
                }
            }
            return(fields);
        }
コード例 #22
0
        /// <summary>
        /// Adds the diode model that can be used to define minimum constraints.
        /// </summary>
        /// <param name="circuit">The circuit.</param>
        public static void AddRectifyingModel(IEntityCollection circuit)
        {
            if (circuit.Contains(DiodeModelName))
            {
                return;
            }
            var model = new VoltageSwitchModel(DiodeModelName);

            model.Parameters.OnResistance  = 1e-6;
            model.Parameters.OffResistance = 1e9;
            model.Parameters.Hysteresis    = 1e-3;
            model.Parameters.Threshold     = 0.0;
            circuit.Add(model);
        }
コード例 #23
0
        protected override void ApplicationStarted()
        {
            _collection  = EntityDatabase.GetCollection();
            _groupSystem = new ExampleReactToGroupSystem();

            for (var i = 0; i < EntityCount; i++)
            {
                var entity = _collection.CreateEntity();
                entity.AddComponents(new SimpleReadComponent(), new SimpleWriteComponent());
            }

            RunSingleThread();
            RunMultiThreaded();
        }
コード例 #24
0
 protected override void VisitEntityCollection(IEntityCollection entityCollection, PropertyInfo propertyInfo)
 {
     if (propertyInfo.GetCustomAttributes(typeof(CompositionAttribute), false).Any())
     {
         bool lastIsChild = this._isChild;
         this._isChild = true;
         IEnumerable <Entity> children = entityCollection.Entities;
         foreach (Entity child in children)
         {
             this.Visit(child);
         }
         this._isChild = lastIsChild;
     }
 }
コード例 #25
0
        /// <summary>
        /// Builds the query conditions.
        /// </summary>
        /// <param name="reportConditions">The report conditions.</param>
        /// <param name="context">The context.</param>
        /// <param name="settings">Conversion settings.</param>
        /// <returns>List{QueryCondition}.</returns>
        internal static List <QueryCondition> BuildQueryConditions(IEntityCollection <ReportCondition> reportConditions, FromEntityContext context, ReportToQueryConverterSettings settings)
        {
            List <QueryCondition> queryConditions = new List <QueryCondition>();

            foreach (ReportCondition reportCondition in reportConditions)
            {
                // TODO Sort out analyser field crap (i.e. hidden/display name etc)?? Do we need this??
                ConditionType conditionType = ConditionType.Unspecified;
                if (reportCondition.Operator != null)
                {
                    string[] conditionOperatorParts = reportCondition.Operator.Alias.Split(':');
                    string   conditionOperator      = conditionOperatorParts.Length == 2 ? conditionOperatorParts[1].Substring(4) : conditionOperatorParts[0].Substring(4);
                    conditionType = (ConditionType)Enum.Parse(typeof(ConditionType), conditionOperator, true);
                }

                ScalarExpression scalarExpression = null;

                if (reportCondition.ConditionExpression == null)
                {
                    context.ReportInvalidConditions[reportCondition.Id] = reportCondition.Name;
                    if (!settings.SchemaOnly)
                    {
                        continue;
                    }
                }
                else
                {
                    scalarExpression = BuildExpression(reportCondition.ConditionExpression, context);
                    if (scalarExpression == null)
                    {
                        EventLog.Application.WriteWarning("the condition expression id: {0} is invalid.", reportCondition.ConditionExpression.Id.ToString());
                        if (!settings.SchemaOnly)
                        {
                            continue; // TODO: log warning .. should we just abort the query if it refers to an invalid expression in a condition .. because it means we'll get more rows.
                        }
                    }
                }

                QueryCondition queryCondition = new QueryCondition
                {
                    EntityId   = reportCondition.Id,
                    Operator   = conditionType,
                    Expression = scalarExpression
                };
                BuildConditionParameter(reportCondition, queryCondition, context);
                queryConditions.Add(queryCondition);
            }
            return(queryConditions);
        }
コード例 #26
0
        private static IfcNamedUnit resolveUnit(IIfcPhysicalQuantity quan)
        {
            IEntityCollection ifcModel = quan.Model.Instances;

            if (quan is IfcQuantityLength)
            {
                IfcQuantityLength ifcValue = (IfcQuantityLength)quan;
                return(ifcValue.Unit != null
                    ? ifcValue.Unit
                    : ifcModel.FirstOrDefault <IfcNamedUnit>(ifcNamedUnit => ifcNamedUnit.UnitType.Equals(IfcUnitEnum.LENGTHUNIT)));
            }
            else if (quan is IfcQuantityArea)
            {
                IfcQuantityArea ifcValue = (IfcQuantityArea)quan;
                return(ifcValue.Unit != null
                    ? ifcValue.Unit
                    : ifcModel.FirstOrDefault <IfcNamedUnit>(ifcNamedUnit => ifcNamedUnit.UnitType.Equals(IfcUnitEnum.AREAUNIT)));
            }
            else if (quan is IfcQuantityVolume)
            {
                IfcQuantityVolume ifcValue = (IfcQuantityVolume)quan;
                return(ifcValue.Unit != null
                    ? ifcValue.Unit
                    : ifcModel.FirstOrDefault <IfcNamedUnit>(ifcNamedUnit => ifcNamedUnit.UnitType.Equals(IfcUnitEnum.VOLUMEUNIT)));
            }
            else if (quan is IfcQuantityTime)
            {
                IfcQuantityTime ifcValue = (IfcQuantityTime)quan;
                return(ifcValue.Unit != null
                    ? ifcValue.Unit
                    : ifcModel.FirstOrDefault <IfcNamedUnit>(ifcNamedUnit => ifcNamedUnit.UnitType.Equals(IfcUnitEnum.TIMEUNIT)));
            }
            else if (quan is IfcQuantityWeight)
            {
                IfcQuantityWeight ifcValue = (IfcQuantityWeight)quan;
                return(ifcValue.Unit != null
                    ? ifcValue.Unit
                    : ifcModel.FirstOrDefault <IfcNamedUnit>(ifcNamedUnit => ifcNamedUnit.UnitType.Equals(IfcUnitEnum.MASSUNIT)));
            }
            else if (quan is IfcQuantityCount)
            {
                IfcQuantityCount ifcValue = (IfcQuantityCount)quan;
                return(ifcValue.Unit);
            }
            else
            {
                return(null);
            }
        }
コード例 #27
0
        public DownloadManagerViewModel(IDownloadService downloadService, IDataContext dataContext, IAnalyticsService analyticsService)
        {
            m_DownloadService  = downloadService ?? throw new ArgumentNullException(nameof(downloadService));
            m_AnalyticsService = analyticsService ?? throw new ArgumentNullException(nameof(analyticsService));
            m_DownloadService.SetDownloadProgress(ProgressHandler);
            m_DownloadService.SetDownloadFinished(FinishHandler);
            m_ReleaseCollection = dataContext.GetCollection <ReleaseEntity> ();
            CreateCommands();
            RestoreSettings();

            m_SelectedSection = m_Sections.First();
            m_PauseColor      = WhiteColor;
            m_PlayColor       = LightGrayColor;
            ObserverEvents.SubscribeOnEvent("synchronizedReleases", RefreshAfterSynchronize);
        }
コード例 #28
0
        /// <summary>
        ///     Implementation: gets all relationships that are applicable to a set of types.
        /// </summary>
        /// <param name="types">The types.</param>
        /// <param name="direction">The direction.</param>
        /// <returns></returns>
        public static IEnumerable <Relationship> GetAllRelationships(IEnumerable <EntityType> types, Direction direction)
        {
            var relationships = new HashSet <Relationship>( );

            foreach (EntityType type in GetAllTypes(types))
            {
                IEntityCollection <Relationship> typeRelationships = direction == Direction.Forward ? type.Relationships : type.ReverseRelationships;

                if (typeRelationships != null)
                {
                    relationships.AddRange(typeRelationships);
                }
            }
            return(relationships);
        }
コード例 #29
0
ファイル: Entity.cs プロジェクト: gkudel/mvc-for-net
 private void AllowEditCollection(Entity e, bool value)
 {
     if (e.EntityCtx.IsNotNull())
     {
         e.EntityCtx.Properties.Where(p => p.ReletedEntity.IsNotNull() && p.ReletedEntity.Related == Releted.List).
         ToList().ForEach((p) =>
         {
             IEntityCollection collection = e[p.Name] as IEntityCollection;
             if (collection.IsNotNull())
             {
                 collection.AllowEdit = value;
             }
         });
     }
 }
コード例 #30
0
        /// <summary>
        /// Updates sibling sort orders for deletions.
        /// </summary>
        /// <param name="collection">
        /// The collection.
        /// </param>
        private void UpdateSiblingSortOrders(IEntityCollection collection)
        {
            var siblings = collection.ParentKey == null
                               ? this.GetRootLevelEntityCollections(collection.EntityType)
                               : this.GetChildren(collection.ParentKey.Value);

            var updates = siblings.Where(x => x.SortOrder > collection.SortOrder).ToArray();

            foreach (var update in updates)
            {
                ((EntityCollection)update).SortOrder -= 1;
            }

            Save(updates);
        }
コード例 #31
0
        private object ConvertRightSide(object value, IEntityCollection data)
        {
            var networkCard = new NetworkCard();

            networkCard.MacAddress = value as string;

            var key = "";

            Properties.TryGetValue("IP Address", out key);
            object ipAddress;

            data.Entities.TryGetValue(key, out ipAddress);
            networkCard.IPAddress = ipAddress as string;
            return(networkCard);
        }
コード例 #32
0
        public static IEntityCollection <T> BulkLoad <T>(this IEntityCollection <T> list, IEnumerable <T> data, bool clear)
            where T : class
        {
            list.BeginInit();

            if (clear)
            {
                list.Clear();
            }

            list.AddRange(data);
            list.EndInit(true);

            return(list);
        }
コード例 #33
0
        public DownloadService(IDataContext dataContext)
        {
            m_DataContext = dataContext;
            m_Collection  = m_DataContext.GetCollection <DownloadFileEntity> ();

            m_Entity = m_Collection.FirstOrDefault();
            if (m_Entity == null)
            {
                m_Entity = new DownloadFileEntity {
                    DownloadingReleases = new List <DownloadReleaseEntity> ()
                };
                m_Collection.Add(m_Entity);
            }
            m_SpeedTimer.Interval = TimeSpan.FromSeconds(1);
            m_SpeedTimer.Tick    += SpeedTimerTick;
        }
コード例 #34
0
        /// <summary>
        /// Maps a <see cref="EntityCollectionDisplay"/> to an <see cref="IEntityCollection"/>.
        /// </summary>
        /// <param name="display">
        /// The display.
        /// </param>
        /// <param name="destination">
        /// The destination.
        /// </param>
        /// <returns>
        /// The <see cref="IEntityCollection"/>.
        /// </returns>
        public static IEntityCollection ToEntityCollection(
            this EntityCollectionDisplay display,
            IEntityCollection destination)
        {
            if (!Guid.Empty.Equals(display.Key))
            {
                destination.Key = display.Key;
            }
            destination.Name        = display.Name;
            destination.ProviderKey = display.ProviderKey;
            destination.EntityTfKey = display.EntityTfKey;
            destination.ParentKey   = display.ParentKey.GetValueOrDefault();
            ((EntityCollection)destination).SortOrder = display.SortOrder;

            return(destination);
        }
コード例 #35
0
ファイル: EntityDatabase.cs プロジェクト: tromagon/Gonity
        void IEntityDatabaseCallback.OnComponentRemoved(ECSComponent component, Type componentType)
        {
            IEntityCollection entityCollection = component as IEntityCollection;

            if (entityCollection != null)
            {
                entityCollection.RemoveAll();
            }

            (_componentMap[componentType] as ComponentList).Remove(component);

            if (_componentMap[componentType].Count == 0)
            {
                _componentMap.Remove(componentType);
            }
        }
コード例 #36
0
        /// <summary>
        /// Set up the simulation.
        /// </summary>
        /// <param name="entities">The entities that are included in the simulation.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="entities"/> is <c>null</c>.</exception>
        private void Setup(IEntityCollection entities)
        {
            // Validate the entities
            entities.ThrowIfNull(nameof(entities));
            if (entities.Count == 0)
            {
                // No entities! Don't stop here, but at least warn the user.
                SpiceSharpWarning.Warning(this, Properties.Resources.Simulations_NoEntities.FormatString(Name));
            }

            // Create all simulation states
            CreateStates();

            // Create all entity behaviors (using the created simulation states)
            CreateBehaviors(entities);
        }
コード例 #37
0
 /// <summary>
 /// Adds range of entities
 /// </summary>
 /// <param name="entities"></param>
 public void AddRange(IEntityCollection <Shape> entities)
 {
     using (var writer = _connection.BeginBinaryImport("COPY shape (feed_id, id, shape_pt_lat, shape_pt_lon, shape_pt_sequence, shape_dist_traveled) FROM STDIN (FORMAT BINARY)"))
     {
         foreach (var shapePoint in entities)
         {
             writer.StartRow();
             writer.Write(_id, NpgsqlTypes.NpgsqlDbType.Integer);
             writer.Write(shapePoint.Id, NpgsqlTypes.NpgsqlDbType.Text);
             writer.Write(shapePoint.Latitude, NpgsqlTypes.NpgsqlDbType.Real);
             writer.Write(shapePoint.Longitude, NpgsqlTypes.NpgsqlDbType.Real);
             writer.Write(shapePoint.Sequence, NpgsqlTypes.NpgsqlDbType.Integer);
             writer.Write(shapePoint.DistanceTravelled, NpgsqlTypes.NpgsqlDbType.Real);
         }
     }
 }
コード例 #38
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SubcircuitDefinition"/> class.
 /// </summary>
 /// <param name="entities">The entities.</param>
 /// <param name="pins">The pins.</param>
 /// <exception cref="ArgumentNullException">Thrown if <paramref name="entities"/> is <c>null</c>.</exception>
 public SubcircuitDefinition(IEntityCollection entities, params string[] pins)
 {
     Entities = entities.ThrowIfNull(nameof(entities));
     if (pins != null)
     {
         _pins = new string[pins.Length];
         for (var i = 0; i < pins.Length; i++)
         {
             _pins[i] = pins[i].ThrowIfNull("node {0}".FormatString(i + 1));
         }
     }
     else
     {
         _pins = Array <string> .Empty();
     }
 }
コード例 #39
0
 public void AddRange(IEntityCollection <Frequency> entities)
 {
     using (var writer = _connection.BeginBinaryImport("COPY frequency (feed_id, trip_id, start_time, end_time, headway_secs, exact_times) FROM STDIN (FORMAT BINARY)"))
     {
         foreach (var frequency in entities)
         {
             writer.StartRow();
             writer.Write(_id, NpgsqlTypes.NpgsqlDbType.Integer);
             writer.Write(frequency.TripId, NpgsqlTypes.NpgsqlDbType.Text);
             writer.Write(frequency.StartTime, NpgsqlTypes.NpgsqlDbType.Text);
             writer.Write(frequency.EndTime, NpgsqlTypes.NpgsqlDbType.Text);
             writer.Write(frequency.HeadwaySecs, NpgsqlTypes.NpgsqlDbType.Text);
             writer.Write(frequency.ExactTimes, NpgsqlTypes.NpgsqlDbType.Integer);
         }
     }
 }
コード例 #40
0
        private async Task RemoveBaseTreeHasLicence(IEntity entity, ISession session, IUnitOfWork unitOfWork, CancellationToken ct)
        {
            // Object is new or deleted --> return direct
            if (!entity.IsLoaded || entity.IsDeleted())
            {
                return;
            }

            // #27178 do not check if the licence management is deactivated
            if (!entity.Columns.Contains("IsLicenceNode"))
            {
                return;
            }

            var bOld = await entity.GetValueAsync <bool>("IsLicenceNode[O]", ct).ConfigureAwait(false);

            var bNew = await entity.GetValueAsync <bool>("IsLicenceNode", ct).ConfigureAwait(false);

            // Flag is removed
            if (bOld && !bNew)
            {
                // Build MN-TableName and FK-ColumName
                string strMNTable = entity.Tablename + "HasLicence";

                IMetaTable mTable = await session.MetaData().GetTableAsync(entity.Tablename, ct).ConfigureAwait(false);

                var mRels = await mTable.GetChildRelationsAsync(ct).ConfigureAwait(false);

                IMetaTableRelation mnRelation = mRels.FirstOrDefault((r) => r.ChildTableName == strMNTable);

                Query qOhL = Query.From(strMNTable)
                             .Where(c => c.Column(mnRelation.ChildColumnName) == entity.GetValue(mnRelation.ParentColumnName))
                             .GetQuery();

                // Get the MN-RelationObject
                IEntityCollection colMN = await session.Source().GetCollectionAsync(qOhL, EntityCollectionLoadType.Bulk, ct).ConfigureAwait(false);

                // Process each Object in ObjectHasLicence Table
                foreach (IEntity eMN in colMN)
                {
                    // Delete and Save
                    eMN.MarkForDeletion();

                    await unitOfWork.PutAsync(eMN, cancellationToken : ct).ConfigureAwait(false);
                }
            }
        }
コード例 #41
0
        public void BulkSave(IConnectionProvider conn, IEntityCollection entitiesToSave, IEntityDaoFactory daoFactory)
        {
            IEntityCollection newEntities, changedEntities, removedEntities;
            SplitCollectionForInsertUpdateAndDeleteOperations(entitiesToSave, out newEntities, out changedEntities, out removedEntities);

            bool connIsLocal = !conn.IsOpen;
            if (connIsLocal)
                conn.OpenConnection();

            try
            {
                BulkInsert(conn, newEntities, daoFactory);
                BulkUpdate(conn, changedEntities, daoFactory);
                BulkDelete(conn, removedEntities, daoFactory);
            }
            finally
            {
                if (connIsLocal)
                    conn.CloseConnection();
            }
        }
コード例 #42
0
 private static void SplitCollectionForInsertUpdateAndDeleteOperations(IEntityCollection entitiesToSave, out IEntityCollection newEntities, out IEntityCollection changedEntities, out IEntityCollection removedEntities)
 {
     IDbTable table = entitiesToSave.IDbTable;
     newEntities = table.NewEntityCollection();
     changedEntities = table.NewEntityCollection();
     removedEntities = table.NewEntityCollection();
     foreach (IEntity entity in entitiesToSave)
     {
         switch (entity.EntityState)
         {
             case EntityState.New:
                 newEntities.Add(entity);
                 break;
             case EntityState.OutOfSync:
                 changedEntities.Add(entity);
                 break;
             case EntityState.PendingDeletion:
                 removedEntities.Add(entity);
                 break;
         }
     }
 }
コード例 #43
0
 /// <summary>
 /// Retrieves in the calling AccountCollection object all AccountEntity objects
 /// which are related via a relation of type 'm:n' with the passed in RoleEntity. 
 /// </summary>
 /// <param name="containingTransaction">A containing transaction, if caller is added to a transaction, or null if not.</param>
 /// <param name="collectionToFill">Collection to fill with the entity objects retrieved</param>
 /// <param name="maxNumberOfItemsToReturn"> The maximum number of items to return with this retrieval query. 
 /// If the used Dynamic Query Engine supports it, 'TOP' is used to limit the amount of rows to return. When set to 0, no limitations are specified.</param>
 /// <param name="sortClauses">The order by specifications for the sorting of the resultset. When not specified, no sorting is applied.</param>
 /// <param name="entityFactoryToUse">The EntityFactory to use when creating entity objects during a GetMulti() call.</param>
 /// <param name="roleInstance">RoleEntity object to be used as a filter in the m:n relation</param>
 /// <param name="pageNumber">The page number to retrieve.</param>
 /// <param name="pageSize">The page size of the page to retrieve.</param>
 /// <returns>true if succeeded, false otherwise</returns>
 public bool GetMultiUsingRoleCollectionViaUser(ITransaction containingTransaction, IEntityCollection collectionToFill, long maxNumberOfItemsToReturn, ISortExpression sortClauses, IEntityFactory entityFactoryToUse, IEntity roleInstance, int pageNumber, int pageSize)
 {
     IEntityFields fieldsToReturn = EntityFieldsFactory.CreateEntityFieldsObject(Auction.Entities.EntityType.AccountEntity);
     RelationCollection relations = new RelationCollection();
     relations.Add(AccountEntity.Relations.UserEntityUsingAccountId, "User_");
     relations.Add(UserEntity.Relations.RoleEntityUsingRoleId, "User_", string.Empty, JoinHint.None);
     IPredicateExpression selectFilter = new PredicateExpression();
     selectFilter.Add(new FieldCompareValuePredicate(roleInstance.Fields[(int)RoleFieldIndex.Id], ComparisonOperator.Equal));
     return GetMulti(containingTransaction, collectionToFill, maxNumberOfItemsToReturn, sortClauses, entityFactoryToUse, selectFilter, relations, pageNumber, pageSize);
 }
コード例 #44
0
 /// <summary>
 /// Retrieves in the calling AccountCollection object all AccountEntity objects
 /// which are related via a relation of type 'm:n' with the passed in UserEntity. 
 /// </summary>
 /// <param name="containingTransaction">A containing transaction, if caller is added to a transaction, or null if not.</param>
 /// <param name="collectionToFill">Collection to fill with the entity objects retrieved</param>
 /// <param name="maxNumberOfItemsToReturn"> The maximum number of items to return with this retrieval query. 
 /// If the used Dynamic Query Engine supports it, 'TOP' is used to limit the amount of rows to return. When set to 0, no limitations are specified.</param>
 /// <param name="sortClauses">The order by specifications for the sorting of the resultset. When not specified, no sorting is applied.</param>
 /// <param name="entityFactoryToUse">The EntityFactory to use when creating entity objects during a GetMulti() call.</param>
 /// <param name="userInstance">UserEntity object to be used as a filter in the m:n relation</param>
 /// <param name="prefetchPathToUse">the PrefetchPath which defines the graph of objects to fetch.</param>
 /// <returns>true if succeeded, false otherwise</returns>
 public bool GetMultiUsingUserCollectionViaDonor_(ITransaction containingTransaction, IEntityCollection collectionToFill, long maxNumberOfItemsToReturn, ISortExpression sortClauses, IEntityFactory entityFactoryToUse, IEntity userInstance, IPrefetchPath prefetchPathToUse)
 {
     IEntityFields fieldsToReturn = EntityFieldsFactory.CreateEntityFieldsObject(Auction.Entities.EntityType.AccountEntity);
     RelationCollection relations = new RelationCollection();
     relations.Add(AccountEntity.Relations.DonorEntityUsingAccountId, "Donor_");
     relations.Add(DonorEntity.Relations.UserEntityUsingUpdatedBy, "Donor_", string.Empty, JoinHint.None);
     IPredicateExpression selectFilter = new PredicateExpression();
     selectFilter.Add(new FieldCompareValuePredicate(userInstance.Fields[(int)UserFieldIndex.Id], ComparisonOperator.Equal));
     return GetMulti(containingTransaction, collectionToFill, maxNumberOfItemsToReturn, sortClauses, entityFactoryToUse, selectFilter, relations, prefetchPathToUse);
 }
コード例 #45
0
ファイル: ForumDAO.cs プロジェクト: priaonehaha/HnD
 /// <summary>Retrieves in the calling ForumCollection object all ForumEntity objects which are related via a relation of type 'm:n' with the passed in UserEntity.</summary>
 /// <param name="containingTransaction">A containing transaction, if caller is added to a transaction, or null if not.</param>
 /// <param name="collectionToFill">Collection to fill with the entity objects retrieved</param>
 /// <param name="maxNumberOfItemsToReturn"> The maximum number of items to return with this retrieval query. When set to 0, no limitations are specified.</param>
 /// <param name="sortClauses">The order by specifications for the sorting of the resultset. When not specified, no sorting is applied.</param>
 /// <param name="entityFactoryToUse">The EntityFactory to use when creating entity objects during a GetMulti() call.</param>
 /// <param name="userInstance">UserEntity object to be used as a filter in the m:n relation</param>
 /// <param name="prefetchPathToUse">the PrefetchPath which defines the graph of objects to fetch.</param>
 /// <param name="pageNumber">The page number to retrieve.</param>
 /// <param name="pageSize">The page size of the page to retrieve.</param>
 /// <returns>true if succeeded, false otherwise</returns>
 public bool GetMultiUsingUsersWhoStartedThreads(ITransaction containingTransaction, IEntityCollection collectionToFill, long maxNumberOfItemsToReturn, ISortExpression sortClauses, IEntityFactory entityFactoryToUse, IEntity userInstance, IPrefetchPath prefetchPathToUse, int pageNumber, int pageSize)
 {
     RelationCollection relations = new RelationCollection();
     relations.Add(ForumEntity.Relations.ThreadEntityUsingForumID, "Thread_");
     relations.Add(ThreadEntity.Relations.UserEntityUsingStartedByUserID, "Thread_", string.Empty, JoinHint.None);
     IPredicateExpression selectFilter = new PredicateExpression();
     selectFilter.Add(new FieldCompareValuePredicate(userInstance.Fields[(int)UserFieldIndex.UserID], ComparisonOperator.Equal));
     return this.GetMulti(containingTransaction, collectionToFill, maxNumberOfItemsToReturn, sortClauses, entityFactoryToUse, selectFilter, relations, prefetchPathToUse, pageNumber, pageSize);
 }
コード例 #46
0
ファイル: Word.cs プロジェクト: sjnaughton/OfficeSharp
        // Exports an IEntityCollection to a table in either the active (UseActiveDocument = True) or a new document (UseActiveDocument = False)
        public static dynamic ExportEntityCollection(IEntityCollection collection, bool UseActiveDocument)
        {
            dynamic doc = null;
            WordHelper wordProxy = new WordHelper();
            bool bUseActiveDocument = false;
            dynamic rg = null;

            // if Word is active then use it
            if (wordProxy.GetWord())
            {
                // obtain a reference to the selection range
                if (UseActiveDocument)
                {
                    rg = wordProxy.Word.Selection.Range;
                    bUseActiveDocument = true;
                }
                else
                {
                    wordProxy.CreateDocument();
                }
            }
            else
            {
                wordProxy.CreateWord();
                wordProxy.CreateDocument();
            }

            List<string> columnNames = new List<string>();

            // get column properties
            IEnumerable<IEntityProperty> columnProperties = collection.OfType<IEntityObject>().First().Details.Properties.All();
            int columnCounter = 1;
            int rowCounter = 1;

            // add table
            dynamic oTable = null;
            if (bUseActiveDocument)
            {
                oTable = wordProxy.AddTable(1, columnProperties.Count(), rg);
            }
            else
            {
                oTable = wordProxy.AddTable(1, columnProperties.Count());
            }

            // add columns names to the list
            foreach (IEntityProperty entityProperty in columnProperties)
            {
                columnNames.Add(entityProperty.Name);

                // add column headers to table
                wordProxy.SetTableCell(oTable, 1, columnCounter, entityProperty.DisplayName);
                columnCounter += 1;
            }

            // add values on the row following the headers
            rowCounter = 2;

            // iterate the collection and extract values by column name
            foreach (IEntityObject entityObj in collection)
            {
                oTable.Rows.Add();
                for (int i = 0; i <= columnNames.Count - 1; i++)
                {
                    wordProxy.SetTableCell(oTable, rowCounter, i + 1, LightSwitchHelper.GetValue(entityObj, columnNames[i]));
                }
                rowCounter += 1;
            }

            doc = wordProxy.Document;
            wordProxy.ShowDocument();

            return doc;
        }
コード例 #47
0
 private IProductCollection Convert(IEntityCollection ec)
 {
     return new ProductCollection(ec);
 }
コード例 #48
0
ファイル: Word.cs プロジェクト: sjnaughton/OfficeSharp
        // Exports an IEntityCollection to a table in given Document. BookmarkName is the name of the bookmark associated
        // with the table.
        public static dynamic ExportEntityCollection(string DocumentPath, string BookmarkName, int StartRow, bool BuildColumnHeadings, IEntityCollection collection, List<ColumnMapping> ColumnNames)
        {
            dynamic functionReturnValue = null;
            dynamic doc = null;
            WordHelper wordProxy = new WordHelper();

            // if Word is active then use it
            if (!wordProxy.GetWord())
            {
                if (!wordProxy.CreateWord())
                {
                    throw new System.Exception("Could not start Microsoft Word.");
                }
            }

            wordProxy.OpenDocument(DocumentPath);
            doc = wordProxy.Document;

            functionReturnValue = ExportEntityCollection(doc, BookmarkName, StartRow, BuildColumnHeadings, collection, ColumnNames);
            wordProxy.ShowDocument();
            return functionReturnValue;
        }
コード例 #49
0
 protected override void VisitEntityCollection(IEntityCollection entityCollection, PropertyInfo propertyInfo)
 {
     if (propertyInfo.GetCustomAttributes(typeof(CompositionAttribute), false).Any())
     {
         bool lastIsChild = this._isChild;
         this._isChild = true;
         IEnumerable<Entity> children = entityCollection.Entities;
         foreach (Entity child in children)
         {
             this.Visit(child);
         }
         this._isChild = lastIsChild;
     }
 }
コード例 #50
0
 protected override void VisitEntityCollection(IEntityCollection entityCollection, PropertyInfo propertyInfo)
 {
     // look for any invalid updates made to composed children
     if (propertyInfo.GetCustomAttributes(typeof(CompositionAttribute), false).Length == 1 && entityCollection.HasValues)
     {
         AssociationAttribute assoc = (AssociationAttribute)propertyInfo.GetCustomAttributes(typeof(AssociationAttribute), false).SingleOrDefault();
         foreach (Entity childEntity in entityCollection.Entities)
         {
             CheckInvalidChildUpdates(childEntity, assoc);
         }
     }
 }
コード例 #51
0
            protected override void VisitEntityCollection(IEntityCollection entityCollection, PropertyInfo propertyInfo)
            {
                // Check for [ExternalReference] properties, if found we can skip visiting these
                // external entities so they will not be included in our change set.
                if (propertyInfo.GetCustomAttributes(typeof(ExternalReferenceAttribute), true).Any())
                {
                    return;
                }

                bool isComposition = propertyInfo.GetCustomAttributes(typeof(CompositionAttribute), false).Any();
                List<int> currentIds = new List<int>();
                List<int> originalIds = new List<int>();

                // Set associations for any new entities that have been explicitly added to the
                // entity reference (e.g. Order/OrderDetail scenario) and are part of this changeset,
                // or all entities if this is a composition. Note that the UnmodifiedOperationAdder
                // has already caused compositional associations to load, so they will have values.
                if (entityCollection.HasValues)
                {
                    foreach (Entity entity in entityCollection.Entities)
                    {
                        int id;
                        if (this._entityIdMap.TryGetValue(entity, out id))
                        {
                            // add the entity to the current associations if this is a composition
                            // or if the child is New and the parent is not Deleted.
                            bool shouldIncludeNewAssociation = this._currentChangeSetEntry.Entity.EntityState != EntityState.Deleted && entity.EntityState == EntityState.New;
                            if (isComposition || shouldIncludeNewAssociation)
                            {
                                currentIds.Add(id);
                            }

                            if (isComposition && (entity.EntityState != EntityState.New))
                            {
                                // for compositions, we need to add all non-new entities to
                                // the original associations map
                                originalIds.Add(id);
                            }
                        }
                    }
                }

                // For compositions, set original associations for any removed entities that are part of this changeset
                if (isComposition)
                {
                    int[] associatedIds = this.FindOriginalChildren(entityCollection.Association).Select(p => p.Id).ToArray();
                    if (associatedIds.Length > 0)
                    {
                        originalIds.AddRange(associatedIds.ToArray());
                    }
                }

                if (currentIds.Count > 0)
                {
                    Dictionary<string, int[]> associatedEntities = (Dictionary<string, int[]>)this._currentChangeSetEntry.Associations;
                    if (associatedEntities == null)
                    {
                        associatedEntities = new Dictionary<string, int[]>();
                        this._currentChangeSetEntry.Associations = associatedEntities;
                    }
                    associatedEntities.Add(propertyInfo.Name, currentIds.ToArray());
                }

                if (originalIds.Count > 0)
                {
                    Dictionary<string, int[]> associatedEntities = (Dictionary<string, int[]>)this._currentChangeSetEntry.OriginalAssociations;
                    if (associatedEntities == null)
                    {
                        associatedEntities = new Dictionary<string, int[]>();
                        this._currentChangeSetEntry.OriginalAssociations = associatedEntities;
                    }
                    associatedEntities.Add(propertyInfo.Name, originalIds.ToArray());
                }
            }
コード例 #52
0
ファイル: Word.cs プロジェクト: sjnaughton/OfficeSharp
        // Exports an IEntityCollection to a table in a Word document located at DocumentPath. BookmarkName is the name of the bookmark associated
        // with the table.
        public static dynamic ExportEntityCollection(string DocumentPath, string BookmarkName, int StartRow, bool BuildColumnHeadings, IEntityCollection collection)
        {
            dynamic doc = null;
            dynamic word = null;
            dynamic result = null;

            try
            {
                word = GetWord();
                if ((word != null))
                {
                    doc = GetDocument(word, DocumentPath);
                    if ((doc != null))
                    {
                        result = ExportEntityCollection(doc, BookmarkName, StartRow, BuildColumnHeadings, collection);
                        word.Visible = true;
                    }
                    else
                    {
                        throw new System.Exception("Could not open the document '" + DocumentPath + "'.");
                    }
                }
                else
                {
                    throw new System.Exception("Could not obtain a reference to Microsoft Word.");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return result;
        }
コード例 #53
0
        /// <summary>
        /// Maps a <see cref="EntityCollectionDisplay"/> to an <see cref="IEntityCollection"/>.
        /// </summary>
        /// <param name="display">
        /// The display.
        /// </param>
        /// <param name="destination">
        /// The destination.
        /// </param>
        /// <returns>
        /// The <see cref="IEntityCollection"/>.
        /// </returns>
        public static IEntityCollection ToEntityCollection(
            this EntityCollectionDisplay display,
            IEntityCollection destination)
        {
            if (!Guid.Empty.Equals(display.Key)) destination.Key = display.Key;
            destination.Name = display.Name;
            destination.ProviderKey = display.ProviderKey;
            destination.EntityTfKey = display.EntityTfKey;
            destination.ParentKey = display.ParentKey.GetValueOrDefault();
            ((EntityCollection)destination).SortOrder = display.SortOrder;

            return destination;
        }
コード例 #54
0
ファイル: Word.cs プロジェクト: sjnaughton/OfficeSharp
        // Exports an IEntityCollection to a table in given Document. BookmarkName is the name of the bookmark associated
        // with the table.
        public static dynamic ExportEntityCollection(dynamic Document, string BookmarkName, int StartRow, bool BuildColumnHeadings, IEntityCollection collection, List<string> ColumnNames)
        {
            List<ColumnMapping> mappings = new List<ColumnMapping>();
            ColumnMapping map = default(ColumnMapping);

            foreach (string name in ColumnNames)
            {
                map = new ColumnMapping("", name);
                map.TableField.DisplayName = name;
                mappings.Add(map);
            }

            return ExportEntityCollection(Document, BookmarkName, StartRow, BuildColumnHeadings, collection, mappings);
        }
コード例 #55
0
 /// <summary>
 /// Visit the specified <see cref="IEntityCollection"/>.
 /// </summary>
 /// <param name="entityCollection">The <see cref="IEntityCollection"/>.</param>
 /// <param name="propertyInfo">The <see cref="PropertyInfo"/> for the collection member.</param>
 protected virtual void VisitEntityCollection(IEntityCollection entityCollection, PropertyInfo propertyInfo)
 {
 }
コード例 #56
0
        public override void FixtureSetup()
        {
            base.FixtureSetup();

            DbPreTestDataWorker.DeleteAllEntityCollections();

            _service = MerchelloContext.Current.Services.EntityCollectionService;

            this._query = ProxyQueryManager.Current.Instance<ProductCollectionTreeQuery>();

            var providerKey = Constants.ProviderKeys.EntityCollection.StaticProductCollectionProviderKey;

            root1 = _service.CreateEntityCollectionWithKey(EntityType.Product, providerKey, "root1", false);

            root2 = _service.CreateEntityCollectionWithKey(EntityType.Product, providerKey, "root2", false);

            a = _service.CreateEntityCollection(EntityType.Product, providerKey, "a", false);
            a.ParentKey = root1.Key;

            b = _service.CreateEntityCollection(EntityType.Product, providerKey, "b", false);
            b.ParentKey = root1.Key;

            c = _service.CreateEntityCollection(EntityType.Product, providerKey, "c", false);
            c.ParentKey = root1.Key;

            _service.Save(new [] { a, b, c });

            a1 = _service.CreateEntityCollection(EntityType.Product, providerKey, "a1", false);
            a1.ParentKey = a.Key;

            a2 = _service.CreateEntityCollection(EntityType.Product, providerKey, "a2", false);
            a2.ParentKey = a.Key;

            _service.Save(new[] { a1, a2 });

            a1a = _service.CreateEntityCollection(EntityType.Product, providerKey, "a1a", false);
            a1a.ParentKey = a1.Key;

            a1b = _service.CreateEntityCollection(EntityType.Product, providerKey, "a1b", false);
            a1b.ParentKey = a1.Key;

            _service.Save(new[] { a1a, a1b });

            c1 = _service.CreateEntityCollection(EntityType.Product, providerKey, "c1", false);
            c1.ParentKey = c.Key;

            c2 = _service.CreateEntityCollection(EntityType.Product, providerKey, "c2", false);
            c2.ParentKey = c.Key;

            _service.Save(new[] { c1, c2 });

            c2a = _service.CreateEntityCollection(EntityType.Product, providerKey, "c2a", false);
            c2a.ParentKey = c2.Key;

            _service.Save(c2a);

            _merchello = new MerchelloHelper();
        }
コード例 #57
0
ファイル: Word.cs プロジェクト: sjnaughton/OfficeSharp
        // Exports an IEntityCollection to a table in given Document. BookmarkName is the name of the bookmark associated
        // with the table.
        public static dynamic ExportEntityCollection(dynamic Document, string BookmarkName, int StartRow, bool BuildColumnHeadings, IEntityCollection collection, List<ColumnMapping> ColumnNames)
        {
            // get column properties
            int columnCounter = 1;
            int rowCounter = StartRow;

            // validate that the Document argument is expected type of Word.Document
            if (!IsWordDocumentObject(Document))
            {
                throw new System.ArgumentException("'Document' is not the expected type of dynamic. Expected dynamic should be a Word.Document dynamic.", "Document");
            }

            // validate the BookmarkName argument
            if (!IsValidBookmark(Document, BookmarkName))
            {
                throw new System.ArgumentException("'BookmarkName' was not found in 'Document'", "BookmarkName");
            }

            // validate that the bookmark is part of a table
            if (Document.Bookmarks(BookmarkName).Range.Tables.Count == 0)
            {
                throw new System.ArgumentException("No table was found at the bookmark", "BookmarkName");
            }

            // add table
            dynamic oTable = null;
            oTable = Document.Bookmarks(BookmarkName).Range.Tables(1);

            // validate the StartRow argument
            if (StartRow > oTable.Rows.Count)
            {
                throw new System.ArgumentException("'StartRow' is greater then the number of rows in the table", "StartRow");
            }

            // add columns names to the list
            foreach (ColumnMapping map in ColumnNames)
            {
                if (columnCounter > oTable.Columns.Count)
                {
                    oTable.Columns.Add();
                }
                if (BuildColumnHeadings)
                {
                    if (map.TableField.DisplayName.Length > 0)
                    {
                        oTable.Cell(rowCounter, columnCounter).Range.Text = map.TableField.DisplayName;
                    }
                    else
                    {
                        oTable.Cell(rowCounter, columnCounter).Range.Text = map.TableField.Name;
                    }
                }
                columnCounter += 1;
            }

            // add values on the row following the headers
            if (BuildColumnHeadings)
            {
                rowCounter += 1;
            }

            // iterate the collection and extract values by column name
            foreach (IEntityObject entityObj in collection)
            {
                for (int i = 0; i <= ColumnNames.Count - 1; i++)
                {
                    if (rowCounter > oTable.Rows.Count)
                    {
                        oTable.Rows.Add();
                    }
                    try
                    {
                        oTable.Cell(rowCounter, i + 1).Range.Text = LightSwitchHelper.GetValue(entityObj, ColumnNames[i].TableField.Name);
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                }
                rowCounter += 1;
            }

            return Document;
        }
コード例 #58
0
ファイル: Word.cs プロジェクト: sjnaughton/OfficeSharp
        // Exports an IEntityCollection to a table in given Document. BookmarkName is the name of the bookmark associated
        // with the table.
        public static dynamic ExportEntityCollection(string DocumentPath, string BookmarkName, int StartRow, bool BuildColumnHeadings, IEntityCollection collection, List<string> ColumnNames)
        {
            dynamic functionReturnValue = null;
            List<ColumnMapping> mappings = new List<ColumnMapping>();
            ColumnMapping map = default(ColumnMapping);

            dynamic doc = null;
            WordHelper wordProxy = new WordHelper();

            // if Word is active then use it
            if (!wordProxy.GetWord())
            {
                if (!wordProxy.CreateWord())
                {
                    throw new System.Exception("Could not start Microsoft Word.");
                }
            }

            wordProxy.OpenDocument(DocumentPath);
            doc = wordProxy.Document;

            foreach (string name in ColumnNames)
            {
                map = new ColumnMapping("", name);
                map.TableField.DisplayName = name;
                mappings.Add(map);
            }

            functionReturnValue = ExportEntityCollection(doc, BookmarkName, StartRow, BuildColumnHeadings, collection, mappings);
            wordProxy.ShowDocument();
            return functionReturnValue;
        }
コード例 #59
0
ファイル: MUserDAO.cs プロジェクト: trogalko/kalibrasi
 /// <summary>
 /// Retrieves in the calling MUserCollection object all MUserEntity objects which have data in common
 /// with the specified related Entities. If one is omitted, that entity is not used as a filter. 
 /// </summary>
 /// <param name="containingTransaction">A containing transaction, if caller is added to a transaction, or null if not.</param>
 /// <param name="collectionToFill">Collection to fill with the entity objects retrieved</param>
 /// <param name="maxNumberOfItemsToReturn"> The maximum number of items to return with this retrieval query. 
 /// If the used Dynamic Query Engine supports it, 'TOP' is used to limit the amount of rows to return. 
 /// When set to 0, no limitations are specified.</param>
 /// <param name="sortClauses">The order by specifications for the sorting of the resultset. When not specified, no sorting is applied.</param>
 /// <param name="entityFactoryToUse">The EntityFactory to use when creating entity objects during a GetMulti() call.</param>
 /// <param name="filter">Extra filter to limit the resultset. Predicate expression can be null, in which case it will be ignored.</param>
 /// <param name="mhakAksesInstance">MHakAksesEntity instance to use as a filter for the MUserEntity objects to return</param>
 /// <param name="pageNumber">The page number to retrieve.</param>
 /// <param name="pageSize">The page size of the page to retrieve.</param>
 public bool GetMulti(ITransaction containingTransaction, IEntityCollection collectionToFill, long maxNumberOfItemsToReturn, ISortExpression sortClauses, IEntityFactory entityFactoryToUse, IPredicateExpression filter, IEntity mhakAksesInstance, int pageNumber, int pageSize)
 {
     base.EntityFactoryToUse = entityFactoryToUse;
     IEntityFields fieldsToReturn = EntityFieldsFactory.CreateEntityFieldsObject(Kalibrasi.Data.EntityType.MUserEntity);
     IPredicateExpression selectFilter = CreateFilterUsingForeignKeys(mhakAksesInstance, fieldsToReturn);
     if(filter!=null)
     {
         selectFilter.AddWithAnd(filter);
     }
     return base.PerformGetMultiAction(containingTransaction, collectionToFill, maxNumberOfItemsToReturn, sortClauses, selectFilter, null, null, null, pageNumber, pageSize);
 }
コード例 #60
0
 /// <summary>
 /// Retrieves in the calling EffectCollection object all EffectEntity objects
 /// which are related via a relation of type 'm:n' with the passed in DecisionNodeEntity. 
 /// </summary>
 /// <param name="containingTransaction">A containing transaction, if caller is added to a transaction, or null if not.</param>
 /// <param name="collectionToFill">Collection to fill with the entity objects retrieved</param>
 /// <param name="maxNumberOfItemsToReturn"> The maximum number of items to return with this retrieval query. 
 /// If the used Dynamic Query Engine supports it, 'TOP' is used to limit the amount of rows to return. When set to 0, no limitations are specified.</param>
 /// <param name="sortClauses">The order by specifications for the sorting of the resultset. When not specified, no sorting is applied.</param>
 /// <param name="entityFactoryToUse">The EntityFactory to use when creating entity objects during a GetMulti() call.</param>
 /// <param name="decisionNodeInstance">DecisionNodeEntity object to be used as a filter in the m:n relation</param>
 /// <param name="pageNumber">The page number to retrieve.</param>
 /// <param name="pageSize">The page size of the page to retrieve.</param>
 /// <returns>true if succeeded, false otherwise</returns>
 public bool GetMultiUsingDecisionNodeCollectionViaRule(ITransaction containingTransaction, IEntityCollection collectionToFill, long maxNumberOfItemsToReturn, ISortExpression sortClauses, IEntityFactory entityFactoryToUse, IEntity decisionNodeInstance, int pageNumber, int pageSize)
 {
     IEntityFields fieldsToReturn = EntityFieldsFactory.CreateEntityFieldsObject(policyDB.EntityType.EffectEntity);
     RelationCollection relations = new RelationCollection();
     relations.Add(EffectEntity.Relations.RuleEntityUsingEffectId, "Rule_");
     relations.Add(RuleEntity.Relations.DecisionNodeEntityUsingConditionId, "Rule_", string.Empty, JoinHint.None);
     IPredicateExpression selectFilter = new PredicateExpression();
     selectFilter.Add(new FieldCompareValuePredicate(decisionNodeInstance.Fields[(int)DecisionNodeFieldIndex.Id], ComparisonOperator.Equal));
     return GetMulti(containingTransaction, collectionToFill, maxNumberOfItemsToReturn, sortClauses, entityFactoryToUse, selectFilter, relations, pageNumber, pageSize);
 }