Esempio n. 1
0
        public static Guid InsertEntityNode(Guid organizationId, Guid?instanceId, string name, Guid entityNodeTypeId, Guid entityId, Guid parentEntityNodeId, EntityLevel level)
        {
            ClientDataSet.EntityNodeDataTable table = new ClientDataSet.EntityNodeDataTable();
            ClientDataSet.EntityNodeRow       row   = table.NewEntityNodeRow();

            row.EntityNodeId = Guid.NewGuid();
            row.Name         = name;
            if (level == EntityLevel.Instance)
            {
                if (instanceId.HasValue)
                {
                    row.InstanceId = instanceId.Value;
                }
            }
            row.OrganizationId   = organizationId;
            row.EntityNodeTypeId = entityNodeTypeId;
            row.EntityId         = entityId;
            row.FullPath         = string.Empty;
            if (parentEntityNodeId != Guid.Empty)
            {
                row.ParentEntityNodeId = parentEntityNodeId;
            }
            row.OrderNumber = 0;
            table.AddEntityNodeRow(row);

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

            return(row.EntityNodeId);
        }
Esempio n. 2
0
        public static void MergeEntityNode(Guid sourceId, Guid targetId)
        {
            Guid organizationId = UserContext.Current.OrganizationId;

            ClientDataSet.EntityNodeRow sourceRow = GetEntityNode(sourceId, organizationId);
            ClientDataSet.EntityNodeRow destRow   = GetEntityNode(targetId, organizationId);

            if (sourceRow != null && destRow != null)
            {
                destRow.Name = sourceRow.Name;

                sourceRow.Deleted = true;

                using (EntityNodeTableAdapter adapter = new EntityNodeTableAdapter(OrganizationProvider.GetConnectionString(organizationId)))
                {
                    adapter.Update(destRow);
                    adapter.Update(sourceRow);
                }
            }
        }
Esempio n. 3
0
        public static void UpdateEntityNodePath(Guid entityNodeId, string fullPath)
        {
            Guid organizationId = UserContext.Current.OrganizationId;

            ClientDataSet.EntityNodeRow row = GetEntityNode(entityNodeId, organizationId);
            if (row != null)
            {
                row.FullPath = fullPath;

                using (EntityNodeTableAdapter adapter = new EntityNodeTableAdapter(OrganizationProvider.GetConnectionString(organizationId)))
                {
                    adapter.Update(row);
                }
            }
        }
Esempio n. 4
0
        private static void DeleteChildEntityNodes(ClientDataSet.EntityNodeRow parentRow, Guid organizationId)
        {
            parentRow.Deleted = true;

            ClientDataSet.EntityNodeDataTable table = null;
            using (EntityNodeTableAdapter adapter = new EntityNodeTableAdapter(OrganizationProvider.GetConnectionString(organizationId)))
            {
                adapter.Update(parentRow);

                table = adapter.GetEntityNodesByParentEntityNodeId(parentRow.EntityNodeId);
            }

            foreach (ClientDataSet.EntityNodeRow row in table)
            {
                DeleteChildEntityNodes(row, organizationId);
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Changes the parent of the specified entity node.
        /// </summary>
        /// <param name="entityNodeId">The identifier of the entity node.</param>
        /// <param name="parentEntityNodeId">The identifier of new parent of the entity node.</param>
        public static void ChangeParentEntityNode(Guid entityNodeId, Guid?parentEntityNodeId)
        {
            Guid organizationId = UserContext.Current.OrganizationId;

            ClientDataSet.EntityNodeRow row = GetEntityNode(entityNodeId, organizationId);
            if (row != null)
            {
                if (parentEntityNodeId.HasValue && (parentEntityNodeId.Value != Guid.Empty))
                {
                    row.ParentEntityNodeId = parentEntityNodeId.Value;
                }
                else
                {
                    row.SetParentEntityNodeIdNull();
                }

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