public static ClientDataSet.EntityNodeTypeDataTable GetCustomEntityNodeTypesByEntityId(Guid organizationId, Guid?instanceId, Guid entityId) { using (EntityNodeTypeTableAdapter adapter = new EntityNodeTypeTableAdapter(OrganizationProvider.GetConnectionString(organizationId))) { return(adapter.GetEntityNodeTypesByEntityId(entityId, organizationId, instanceId)); } }
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); }
public static void ChangeParentEntityNodeType(Guid entityId, Guid sourceId, Guid destinationId) { Guid organizationId = UserContext.Current.OrganizationId; EntityNodeType source = EntityFieldProvider.Entities[entityId.ToString("N")].CustomNodeTypes[sourceId.ToString("N")]; EntityNodeType dest = EntityFieldProvider.Entities[entityId.ToString("N")].CustomNodeTypes[destinationId.ToString("N")]; int indexDest = EntityFieldProvider.Entities[entityId.ToString("N")].CustomNodeTypes.IndexOf(dest); EntityFieldProvider.Entities[entityId.ToString("N")].CustomNodeTypes.Remove(source); EntityFieldProvider.Entities[entityId.ToString("N")].CustomNodeTypes.Insert(indexDest, source); using (EntityNodeTypeTableAdapter adapter = new EntityNodeTypeTableAdapter(OrganizationProvider.GetConnectionString(organizationId))) { int order = 1; foreach (EntityNodeType ent in EntityFieldProvider.Entities[entityId.ToString("N")].CustomNodeTypes) { ClientDataSet.EntityNodeTypeRow row = GetEntityNodeType(ent.Id, organizationId); row.OrderNumber = order; adapter.Update(row); order++; } } }
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 DeleteEntityNodeType(Guid entityNodeTypeId) { Guid organizationId = UserContext.Current.OrganizationId; ClientDataSet.EntityNodeTypeRow row = GetEntityNodeType(entityNodeTypeId, organizationId); if (row != null) { row.Deleted = true; using (EntityNodeTypeTableAdapter adapter = new EntityNodeTypeTableAdapter(OrganizationProvider.GetConnectionString(organizationId))) { adapter.Update(row); } } }
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); } } }