public int ExecuteDeletion(Guid domainId, Guid rootMapId) { //SqlCommand deleteMetadataByRootMap = new SqlCommand(DeleteRootMapMetadataSql, MapDbConnection.Connection); //deleteMetadataByRootMap.Parameters.Add(new SqlParameter("@DomainUid", domainId)); //deleteMetadataByRootMap.Parameters.Add(new SqlParameter("@RootMapUid", rootMapId)); //deleteMetadataByRootMap.ExecuteNonQuery(); //SqlCommand deleteDescriptorsByRootMap = new SqlCommand(DeleteRootMapDescriptorsSql, MapDbConnection.Connection); //deleteDescriptorsByRootMap.Parameters.Add(new SqlParameter("@DomainUid", domainId)); //deleteDescriptorsByRootMap.Parameters.Add(new SqlParameter("@RootMapUid", rootMapId)); //deleteDescriptorsByRootMap.ExecuteNonQuery(); //SqlCommand deleteRelationshipsByRootMap = new SqlCommand(DeleteRootMapRelationshipsSql, MapDbConnection.Connection); //deleteRelationshipsByRootMap.Parameters.Add(new SqlParameter("@DomainUid", domainId)); //deleteRelationshipsByRootMap.Parameters.Add(new SqlParameter("@RootMapUid", rootMapId)); //deleteRelationshipsByRootMap.ExecuteNonQuery(); //SqlCommand deleteNodesByRootMap = new SqlCommand(DeleteRootMapNodesSql, MapDbConnection.Connection); //deleteNodesByRootMap.Parameters.Add(new SqlParameter("@DomainUid", domainId)); //deleteNodesByRootMap.Parameters.Add(new SqlParameter("@RootMapUid", rootMapId)); //deleteNodesByRootMap.ExecuteNonQuery(); SqlCommand deleteByRootMap = new SqlCommand(DeleteRootMapSql, MapDbConnection.Connection); deleteByRootMap.Parameters.Add(new SqlParameter("@DomainUid", domainId)); deleteByRootMap.Parameters.Add(new SqlParameter("@RootMapUid", rootMapId)); int rowsDeleted = deleteByRootMap.ExecuteNonQuery(); Guid sessionId = Guid.NewGuid(); MapTransaction beginTransaction = new MapTransaction(); beginTransaction.SessionUid = sessionId; beginTransaction.TransactionTimestamp = DateTime.Now.ToUniversalTime(); beginTransaction.User = User; beginTransaction.OperationId = TransactionType.BeginSession; beginTransaction.PersistSessionObject(SessionDbConnection); MapParameter domainParameter = new MapParameter(); domainParameter.SessionId = sessionId; domainParameter.IsDelayed = false; domainParameter.ParameterType = MapParameterType.Domain; domainParameter.Value = domainId; domainParameter.PersistSessionObject(ParametersDbConnection); MapParameter rootMapParameter = new MapParameter(); rootMapParameter.SessionId = sessionId; rootMapParameter.IsDelayed = false; rootMapParameter.ParameterType = MapParameterType.RootMap; rootMapParameter.Value = rootMapId; rootMapParameter.PersistSessionObject(ParametersDbConnection); MapTransaction createRootMapTransaction = new MapTransaction(); createRootMapTransaction.SessionUid = sessionId; createRootMapTransaction.TransactionTimestamp = DateTime.Now.ToUniversalTime(); createRootMapTransaction.User = User; createRootMapTransaction.OperationId = TransactionType.DeleteRootMap; createRootMapTransaction.DomainParameterUid = domainParameter.Id; createRootMapTransaction.RootMapParameterUid = rootMapParameter.Id; createRootMapTransaction.NodeParameterUid = rootMapParameter.Id; createRootMapTransaction.PersistSessionObject(SessionDbConnection); MapTransaction endTransaction = new MapTransaction(); endTransaction.SessionUid = sessionId; endTransaction.TransactionTimestamp = DateTime.Now.ToUniversalTime(); endTransaction.User = User; endTransaction.OperationId = TransactionType.CompleteSession; endTransaction.PersistSessionObject(SessionDbConnection); if (rowsDeleted > 0) { return(1); } else { return(0); } }
public Guid Create(Guid domainId, string name, NodeType nodeType, string originalId) { SqlCommand getDomainNodeId = new SqlCommand(GetDomainNodeId, MapDbConnection.Connection); getDomainNodeId.Parameters.Add(new SqlParameter("@NodeTypeUid", new Guid("263754C2-2F31-4D21-B9C4-6509E00A5E94"))); getDomainNodeId.Parameters.Add(new SqlParameter("@DomainUid", domainId)); Guid? domainNodeId = (Guid?)getDomainNodeId.ExecuteScalar(); if (domainNodeId == null) { return Guid.Empty; } Guid nodeId = Guid.NewGuid(); DateTime currentTime = DateTime.Now.ToUniversalTime(); SqlCommand createRootMapCommand = new SqlCommand(CreateRootMapNode, MapDbConnection.Connection); createRootMapCommand.Parameters.Add(new SqlParameter("@NodeUid", nodeId)); if (string.IsNullOrEmpty(originalId)) { createRootMapCommand.Parameters.Add(new SqlParameter("@NodeOriginalId", DBNull.Value)); } else { createRootMapCommand.Parameters.Add(new SqlParameter("@NodeOriginalId", originalId)); } createRootMapCommand.Parameters.Add(new SqlParameter("@NodeTypeUid", nodeType.Id)); createRootMapCommand.Parameters.Add(new SqlParameter("@DomainUid", domainId)); createRootMapCommand.Parameters.Add(new SqlParameter("@RootMapUid", nodeId)); createRootMapCommand.Parameters.Add(new SqlParameter("@Created", currentTime)); createRootMapCommand.Parameters.Add(new SqlParameter("@Modified", currentTime)); createRootMapCommand.Parameters.Add(new SqlParameter("@CreatedBy", User)); createRootMapCommand.Parameters.Add(new SqlParameter("@ModifiedBy", User)); createRootMapCommand.ExecuteNonQuery(); Guid metadataId = Guid.NewGuid(); SqlCommand metadataRootMapCommand = new SqlCommand(CreateRootMapNameMetadata, MapDbConnection.Connection); metadataRootMapCommand.Parameters.Add(new SqlParameter("@MetadataId", metadataId)); metadataRootMapCommand.Parameters.Add(new SqlParameter("@MetadataTypeUid", new Guid("C7628C1E-77C1-4A07-A2E8-8DE9F4E9803C"))); metadataRootMapCommand.Parameters.Add(new SqlParameter("@NodeUid", nodeId)); metadataRootMapCommand.Parameters.Add(new SqlParameter("@RelationshipUid", DBNull.Value)); metadataRootMapCommand.Parameters.Add(new SqlParameter("@DescriptorTypeUid", DBNull.Value)); metadataRootMapCommand.Parameters.Add(new SqlParameter("@MetadataName", "Name")); if (string.IsNullOrEmpty(name)) { metadataRootMapCommand.Parameters.Add(new SqlParameter("@MetadataValue", DBNull.Value)); } else { metadataRootMapCommand.Parameters.Add(new SqlParameter("@MetadataValue", name)); } metadataRootMapCommand.Parameters.Add(new SqlParameter("@RootMapUid", nodeId)); metadataRootMapCommand.Parameters.Add(new SqlParameter("@DomainUid", domainId)); metadataRootMapCommand.Parameters.Add(new SqlParameter("@Created", currentTime)); metadataRootMapCommand.Parameters.Add(new SqlParameter("@Modified", currentTime)); metadataRootMapCommand.Parameters.Add(new SqlParameter("@CreatedBy", User)); metadataRootMapCommand.Parameters.Add(new SqlParameter("@ModifiedBy", User)); metadataRootMapCommand.ExecuteNonQuery(); Guid relationshipId = Guid.NewGuid(); SqlCommand relationshipRootMapCommand = new SqlCommand(CreateRootMapRelationship, MapDbConnection.Connection); relationshipRootMapCommand.Parameters.Add(new SqlParameter("@RelationshipUid", relationshipId)); relationshipRootMapCommand.Parameters.Add(new SqlParameter("@RelationshipOriginalId", "")); relationshipRootMapCommand.Parameters.Add(new SqlParameter(@"RelationshipTypeUid", new Guid("4AFF46D7-87BE-48DD-B703-A93E38EF8FFB"))); relationshipRootMapCommand.Parameters.Add(new SqlParameter(@"DomainUid", domainId)); relationshipRootMapCommand.Parameters.Add(new SqlParameter(@"RootMapUid", nodeId)); relationshipRootMapCommand.Parameters.Add(new SqlParameter(@"Created", currentTime)); relationshipRootMapCommand.Parameters.Add(new SqlParameter(@"Modified", currentTime)); relationshipRootMapCommand.Parameters.Add(new SqlParameter(@"CreatedBy", User)); relationshipRootMapCommand.Parameters.Add(new SqlParameter(@"ModifiedBy", User)); relationshipRootMapCommand.ExecuteNonQuery(); Guid fromDescriptorId = Guid.NewGuid(); SqlCommand fromDescriptorRootMapCommand = new SqlCommand(CreateRootMapDescriptors, MapDbConnection.Connection); fromDescriptorRootMapCommand.Parameters.Add(new SqlParameter("@DescriptorUid", fromDescriptorId)); fromDescriptorRootMapCommand.Parameters.Add(new SqlParameter("@DescriptorTypeUid", new Guid("96DA1782-058C-4F9B-BB1A-31B048F8C75A"))); fromDescriptorRootMapCommand.Parameters.Add(new SqlParameter("@NodeUid", nodeId)); fromDescriptorRootMapCommand.Parameters.Add(new SqlParameter("@RelationshipUid", relationshipId)); fromDescriptorRootMapCommand.ExecuteNonQuery(); Guid toDescriptorId = Guid.NewGuid(); SqlCommand toDescriptorRootMapCommand = new SqlCommand(CreateRootMapDescriptors, MapDbConnection.Connection); toDescriptorRootMapCommand.Parameters.Add(new SqlParameter("@DescriptorUid", toDescriptorId)); toDescriptorRootMapCommand.Parameters.Add(new SqlParameter("@DescriptorTypeUid", new Guid("07C91D35-4DAC-431B-966B-64C924B8CDAB"))); toDescriptorRootMapCommand.Parameters.Add(new SqlParameter("@NodeUid", domainNodeId.Value)); toDescriptorRootMapCommand.Parameters.Add(new SqlParameter("@RelationshipUid", relationshipId)); toDescriptorRootMapCommand.ExecuteNonQuery(); Guid sessionId = Guid.NewGuid(); MapTransaction beginTransaction = new MapTransaction(); beginTransaction.SessionUid = sessionId; beginTransaction.TransactionTimestamp = DateTime.Now.ToUniversalTime(); beginTransaction.User = User; beginTransaction.OperationId = TransactionType.BeginSession; beginTransaction.PersistSessionObject(SessionDbConnection); MapParameter domainParameter = new MapParameter(); domainParameter.SessionId = sessionId; domainParameter.IsDelayed = false; domainParameter.ParameterType = MapParameterType.Domain; domainParameter.Value = domainId; domainParameter.PersistSessionObject(ParametersDbConnection); MapParameter rootMapParameter = new MapParameter(); rootMapParameter.SessionId = sessionId; rootMapParameter.IsDelayed = false; rootMapParameter.ParameterType = MapParameterType.RootMap; rootMapParameter.Value = nodeId; rootMapParameter.PersistSessionObject(ParametersDbConnection); MapTransaction createRootMapTransaction = new MapTransaction(); createRootMapTransaction.SessionUid = sessionId; createRootMapTransaction.TransactionTimestamp = DateTime.Now.ToUniversalTime(); createRootMapTransaction.User = User; createRootMapTransaction.OperationId = TransactionType.CreateRootMap; createRootMapTransaction.DomainParameterUid = domainParameter.Id; createRootMapTransaction.RootMapParameterUid = rootMapParameter.Id; createRootMapTransaction.NodeParameterUid = rootMapParameter.Id; createRootMapTransaction.NodeTypeUid = nodeType.Id; createRootMapTransaction.PersistSessionObject(SessionDbConnection); MapTransaction endTransaction = new MapTransaction(); endTransaction.SessionUid = sessionId; endTransaction.TransactionTimestamp = DateTime.Now.ToUniversalTime(); endTransaction.User = User; endTransaction.OperationId = TransactionType.CompleteSession; endTransaction.PersistSessionObject(SessionDbConnection); return nodeId; }
public int ExecuteDeletion(Guid domainId) { //SqlCommand deleteMetadataByDomain = new SqlCommand(DeleteDomainMetadataSql, MapDbConnection.Connection); //deleteMetadataByDomain.Parameters.Add(new SqlParameter("@DomainUid", domainId)); //deleteMetadataByDomain.ExecuteNonQuery(); //SqlCommand deleteDescriptorsByDomain = new SqlCommand(DeleteDomainDescriptorsSql, MapDbConnection.Connection); //deleteDescriptorsByDomain.Parameters.Add(new SqlParameter("@DomainUid", domainId)); //deleteDescriptorsByDomain.ExecuteNonQuery(); //SqlCommand deleteRelationshipsByDomain = new SqlCommand(DeleteDomainRelationshipsSql, MapDbConnection.Connection); //deleteRelationshipsByDomain.Parameters.Add(new SqlParameter("@DomainUid", domainId)); //deleteRelationshipsByDomain.ExecuteNonQuery(); //SqlCommand deleteNodesByDomain = new SqlCommand(DeleteDomainNodesSql, MapDbConnection.Connection); //deleteNodesByDomain.Parameters.Add(new SqlParameter("@DomainUid", domainId)); //deleteNodesByDomain.ExecuteNonQuery(); //SqlCommand deleteDomain = new SqlCommand(DeleteDomainSql, MapDbConnection.Connection); //deleteDomain.Parameters.Add(new SqlParameter("@DomainUid", domainId)); //deleteDomain.ExecuteNonQuery(); SqlCommand deleteByDomain = new SqlCommand(DeleteDomainSql, MapDbConnection.Connection); deleteByDomain.Parameters.Add(new SqlParameter("@DomainUid", domainId)); int rowsDeleted = deleteByDomain.ExecuteNonQuery(); Guid sessionId = Guid.NewGuid(); MapTransaction beginTransaction = new MapTransaction(); beginTransaction.SessionUid = sessionId; beginTransaction.TransactionTimestamp = DateTime.Now.ToUniversalTime(); beginTransaction.User = User; beginTransaction.OperationId = TransactionType.BeginSession; beginTransaction.PersistSessionObject(SessionDbConnection); MapParameter domainParameter = new MapParameter(); domainParameter.SessionId = sessionId; domainParameter.IsDelayed = false; domainParameter.ParameterType = MapParameterType.Domain; domainParameter.Value = domainId; domainParameter.PersistSessionObject(ParametersDbConnection); MapTransaction createRootMapTransaction = new MapTransaction(); createRootMapTransaction.SessionUid = sessionId; createRootMapTransaction.TransactionTimestamp = DateTime.Now.ToUniversalTime(); createRootMapTransaction.User = User; createRootMapTransaction.OperationId = TransactionType.DeleteDomain; createRootMapTransaction.DomainParameterUid = domainParameter.Id; createRootMapTransaction.PersistSessionObject(SessionDbConnection); MapTransaction endTransaction = new MapTransaction(); endTransaction.SessionUid = sessionId; endTransaction.TransactionTimestamp = DateTime.Now.ToUniversalTime(); endTransaction.User = User; endTransaction.OperationId = TransactionType.CompleteSession; endTransaction.PersistSessionObject(SessionDbConnection); if (rowsDeleted > 0) { return 1; } else { return 0; } }
public Guid Create(Guid domainId, string name, NodeType nodeType, string originalId) { SqlCommand getDomainNodeId = new SqlCommand(GetDomainNodeId, MapDbConnection.Connection); getDomainNodeId.Parameters.Add(new SqlParameter("@NodeTypeUid", new Guid("263754C2-2F31-4D21-B9C4-6509E00A5E94"))); getDomainNodeId.Parameters.Add(new SqlParameter("@DomainUid", domainId)); Guid?domainNodeId = (Guid?)getDomainNodeId.ExecuteScalar(); if (domainNodeId == null) { return(Guid.Empty); } Guid nodeId = Guid.NewGuid(); DateTime currentTime = DateTime.Now.ToUniversalTime(); SqlCommand createRootMapCommand = new SqlCommand(CreateRootMapNode, MapDbConnection.Connection); createRootMapCommand.Parameters.Add(new SqlParameter("@NodeUid", nodeId)); if (string.IsNullOrEmpty(originalId)) { createRootMapCommand.Parameters.Add(new SqlParameter("@NodeOriginalId", DBNull.Value)); } else { createRootMapCommand.Parameters.Add(new SqlParameter("@NodeOriginalId", originalId)); } createRootMapCommand.Parameters.Add(new SqlParameter("@NodeTypeUid", nodeType.Id)); createRootMapCommand.Parameters.Add(new SqlParameter("@DomainUid", domainId)); createRootMapCommand.Parameters.Add(new SqlParameter("@RootMapUid", nodeId)); createRootMapCommand.Parameters.Add(new SqlParameter("@Created", currentTime)); createRootMapCommand.Parameters.Add(new SqlParameter("@Modified", currentTime)); createRootMapCommand.Parameters.Add(new SqlParameter("@CreatedBy", User)); createRootMapCommand.Parameters.Add(new SqlParameter("@ModifiedBy", User)); createRootMapCommand.ExecuteNonQuery(); Guid metadataId = Guid.NewGuid(); SqlCommand metadataRootMapCommand = new SqlCommand(CreateRootMapNameMetadata, MapDbConnection.Connection); metadataRootMapCommand.Parameters.Add(new SqlParameter("@MetadataId", metadataId)); metadataRootMapCommand.Parameters.Add(new SqlParameter("@MetadataTypeUid", new Guid("C7628C1E-77C1-4A07-A2E8-8DE9F4E9803C"))); metadataRootMapCommand.Parameters.Add(new SqlParameter("@NodeUid", nodeId)); metadataRootMapCommand.Parameters.Add(new SqlParameter("@RelationshipUid", DBNull.Value)); metadataRootMapCommand.Parameters.Add(new SqlParameter("@DescriptorTypeUid", DBNull.Value)); metadataRootMapCommand.Parameters.Add(new SqlParameter("@MetadataName", "Name")); if (string.IsNullOrEmpty(name)) { metadataRootMapCommand.Parameters.Add(new SqlParameter("@MetadataValue", DBNull.Value)); } else { metadataRootMapCommand.Parameters.Add(new SqlParameter("@MetadataValue", name)); } metadataRootMapCommand.Parameters.Add(new SqlParameter("@RootMapUid", nodeId)); metadataRootMapCommand.Parameters.Add(new SqlParameter("@DomainUid", domainId)); metadataRootMapCommand.Parameters.Add(new SqlParameter("@Created", currentTime)); metadataRootMapCommand.Parameters.Add(new SqlParameter("@Modified", currentTime)); metadataRootMapCommand.Parameters.Add(new SqlParameter("@CreatedBy", User)); metadataRootMapCommand.Parameters.Add(new SqlParameter("@ModifiedBy", User)); metadataRootMapCommand.ExecuteNonQuery(); Guid relationshipId = Guid.NewGuid(); SqlCommand relationshipRootMapCommand = new SqlCommand(CreateRootMapRelationship, MapDbConnection.Connection); relationshipRootMapCommand.Parameters.Add(new SqlParameter("@RelationshipUid", relationshipId)); relationshipRootMapCommand.Parameters.Add(new SqlParameter("@RelationshipOriginalId", "")); relationshipRootMapCommand.Parameters.Add(new SqlParameter(@"RelationshipTypeUid", new Guid("4AFF46D7-87BE-48DD-B703-A93E38EF8FFB"))); relationshipRootMapCommand.Parameters.Add(new SqlParameter(@"DomainUid", domainId)); relationshipRootMapCommand.Parameters.Add(new SqlParameter(@"RootMapUid", nodeId)); relationshipRootMapCommand.Parameters.Add(new SqlParameter(@"Created", currentTime)); relationshipRootMapCommand.Parameters.Add(new SqlParameter(@"Modified", currentTime)); relationshipRootMapCommand.Parameters.Add(new SqlParameter(@"CreatedBy", User)); relationshipRootMapCommand.Parameters.Add(new SqlParameter(@"ModifiedBy", User)); relationshipRootMapCommand.ExecuteNonQuery(); Guid fromDescriptorId = Guid.NewGuid(); SqlCommand fromDescriptorRootMapCommand = new SqlCommand(CreateRootMapDescriptors, MapDbConnection.Connection); fromDescriptorRootMapCommand.Parameters.Add(new SqlParameter("@DescriptorUid", fromDescriptorId)); fromDescriptorRootMapCommand.Parameters.Add(new SqlParameter("@DescriptorTypeUid", new Guid("96DA1782-058C-4F9B-BB1A-31B048F8C75A"))); fromDescriptorRootMapCommand.Parameters.Add(new SqlParameter("@NodeUid", nodeId)); fromDescriptorRootMapCommand.Parameters.Add(new SqlParameter("@RelationshipUid", relationshipId)); fromDescriptorRootMapCommand.ExecuteNonQuery(); Guid toDescriptorId = Guid.NewGuid(); SqlCommand toDescriptorRootMapCommand = new SqlCommand(CreateRootMapDescriptors, MapDbConnection.Connection); toDescriptorRootMapCommand.Parameters.Add(new SqlParameter("@DescriptorUid", toDescriptorId)); toDescriptorRootMapCommand.Parameters.Add(new SqlParameter("@DescriptorTypeUid", new Guid("07C91D35-4DAC-431B-966B-64C924B8CDAB"))); toDescriptorRootMapCommand.Parameters.Add(new SqlParameter("@NodeUid", domainNodeId.Value)); toDescriptorRootMapCommand.Parameters.Add(new SqlParameter("@RelationshipUid", relationshipId)); toDescriptorRootMapCommand.ExecuteNonQuery(); Guid sessionId = Guid.NewGuid(); MapTransaction beginTransaction = new MapTransaction(); beginTransaction.SessionUid = sessionId; beginTransaction.TransactionTimestamp = DateTime.Now.ToUniversalTime(); beginTransaction.User = User; beginTransaction.OperationId = TransactionType.BeginSession; beginTransaction.PersistSessionObject(SessionDbConnection); MapParameter domainParameter = new MapParameter(); domainParameter.SessionId = sessionId; domainParameter.IsDelayed = false; domainParameter.ParameterType = MapParameterType.Domain; domainParameter.Value = domainId; domainParameter.PersistSessionObject(ParametersDbConnection); MapParameter rootMapParameter = new MapParameter(); rootMapParameter.SessionId = sessionId; rootMapParameter.IsDelayed = false; rootMapParameter.ParameterType = MapParameterType.RootMap; rootMapParameter.Value = nodeId; rootMapParameter.PersistSessionObject(ParametersDbConnection); MapTransaction createRootMapTransaction = new MapTransaction(); createRootMapTransaction.SessionUid = sessionId; createRootMapTransaction.TransactionTimestamp = DateTime.Now.ToUniversalTime(); createRootMapTransaction.User = User; createRootMapTransaction.OperationId = TransactionType.CreateRootMap; createRootMapTransaction.DomainParameterUid = domainParameter.Id; createRootMapTransaction.RootMapParameterUid = rootMapParameter.Id; createRootMapTransaction.NodeParameterUid = rootMapParameter.Id; createRootMapTransaction.NodeTypeUid = nodeType.Id; createRootMapTransaction.PersistSessionObject(SessionDbConnection); MapTransaction endTransaction = new MapTransaction(); endTransaction.SessionUid = sessionId; endTransaction.TransactionTimestamp = DateTime.Now.ToUniversalTime(); endTransaction.User = User; endTransaction.OperationId = TransactionType.CompleteSession; endTransaction.PersistSessionObject(SessionDbConnection); return(nodeId); }