Пример #1
0
        public static Guid InsertEntityNodeType(Guid organizationId, Guid?instanceId, string name, Guid entityId, int orderNumber)
        {
            ClientDataSet.EntityNodeTypeDataTable table = new ClientDataSet.EntityNodeTypeDataTable();
            ClientDataSet.EntityNodeTypeRow       row   = table.NewEntityNodeTypeRow();

            Entity entity = EntityFieldProvider.Entities[entityId.ToString("N")];

            row.EntityNodeTypeId = Guid.NewGuid();
            row.Name             = name;
            row.EntityId         = entityId;
            if (entity.HierarchyStartLevel == EntityLevel.Instance)
            {
                if (instanceId.HasValue)
                {
                    row.InstanceId = instanceId.Value;
                }
            }
            row.OrganizationId = organizationId;
            if (orderNumber == 0)
            {
                row.OrderNumber = entity.GetCustomNodeTypes(organizationId, instanceId).Count + 1;
            }
            else
            {
                row.OrderNumber = orderNumber;
            }
            table.AddEntityNodeTypeRow(row);

            using (EntityNodeTypeTableAdapter adapter = new EntityNodeTypeTableAdapter(OrganizationProvider.GetConnectionString(organizationId)))
            {
                adapter.Update(row);
            }

            return(row.EntityNodeTypeId);
        }
Пример #2
0
        public static DataView GetEntityNodeTypesByEntityId(Guid organizationId, Guid?instanceId, Guid entityId)
        {
            ClientDataSet.EntityNodeTypeDataTable table = GetCustomEntityNodeTypesByEntityId(organizationId, instanceId, entityId);

            ClientDataSet.EntityNodeTypeRow row = null;
            foreach (EntityNodeType ent in EntityFieldProvider.Entities[entityId.ToString("N")].NodeTypes)
            {
                row = table.NewEntityNodeTypeRow();
                row.EntityNodeTypeId = ent.Id;
                row.OrganizationId   = organizationId;
                row.EntityId         = entityId;
                row.Name             = ent.Name;
                row.OrderNumber      = ent.OrderNumber;
                table.AddEntityNodeTypeRow(row);
            }
            table.DefaultView.Sort = "OrderNumber ASC";

            return(table.DefaultView);
        }