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); }
private static ClientDataSet.EntityNodeTypeRow GetEntityNodeType(Guid entityNodeTypeId, Guid organizationId) { using (EntityNodeTypeTableAdapter adapter = new EntityNodeTypeTableAdapter(OrganizationProvider.GetConnectionString(organizationId))) { ClientDataSet.EntityNodeTypeDataTable table = adapter.GetEntityNodeType(entityNodeTypeId); return((table.Count > 0) ? table[0] : null); } }
public static void UpdateEntityNodeType(Guid organizationId, Guid entityNodeTypeId, string name, int orderNumber) { using (EntityNodeTypeTableAdapter adapter = new EntityNodeTypeTableAdapter(OrganizationProvider.GetConnectionString(organizationId))) { ClientDataSet.EntityNodeTypeDataTable table = adapter.GetEntityNodeType(entityNodeTypeId); if (table.Count > 0) { ClientDataSet.EntityNodeTypeRow row = table[0]; row.Name = name; row.OrderNumber = orderNumber; adapter.Update(row); } } }
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); }