Inheritance: NodeService.SoapTypeElement
Esempio n. 1
0
        public static ISoapTypeElement GetSoapType <SoapType>(Guid typeUid) where SoapType : ISoapTypeElement
        {
            lock (_lock)
            {
                if (_soapTypes.ContainsKey(typeUid))
                {
                    return(_soapTypes[typeUid]);
                }

                using (MappingToolDatabaseDataContext mappingDb = new MappingToolDatabaseDataContext())
                {
                    if (typeof(SoapType).IsAssignableFrom(typeof(SoapNodeType)))
                    {
                        var nodeType = (from dbNodeType in mappingDb.NodeTypes where dbNodeType.NodeTypeUid == typeUid select dbNodeType).First();

                        SoapNodeType soapNodeType = new SoapNodeType();
                        soapNodeType.Id   = nodeType.NodeTypeUid;
                        soapNodeType.Name = nodeType.NodeTypeName;

                        return((ISoapTypeElement)soapNodeType);
                    }
                    else if (typeof(SoapType).IsAssignableFrom(typeof(SoapDescriptorType)))
                    {
                        var nodeType = (from dbNodeType in mappingDb.DescriptorTypes where dbNodeType.DescriptorTypeUid == typeUid select dbNodeType).First();

                        SoapDescriptorType soapDescriptorType = new SoapDescriptorType();
                        soapDescriptorType.Id   = nodeType.DescriptorTypeUid;
                        soapDescriptorType.Name = nodeType.DescriptorTypeName;

                        return((ISoapTypeElement)soapDescriptorType);
                    }
                    else if (typeof(SoapType).IsAssignableFrom(typeof(SoapRelationshipType)))
                    {
                        var nodeType = (from dbNodeType in mappingDb.RelationshipTypes where dbNodeType.RelationshipTypeUid == typeUid select dbNodeType).First();

                        SoapRelationshipType soapRelationshipType = new SoapRelationshipType();
                        soapRelationshipType.Id   = nodeType.RelationshipTypeUid;
                        soapRelationshipType.Name = nodeType.RelationshipTypeName;

                        return((ISoapTypeElement)soapRelationshipType);
                    }
                    else if (typeof(SoapType).IsAssignableFrom(typeof(SoapMetadataType)))
                    {
                        var nodeType = (from dbNodeType in mappingDb.MetadataTypes where dbNodeType.MetadataTypeUid == typeUid select dbNodeType).First();

                        SoapMetadataType soapMetadataType = new SoapMetadataType();
                        soapMetadataType.Id   = nodeType.MetadataTypeUid;
                        soapMetadataType.Name = nodeType.MetadataTypeName;

                        return((ISoapTypeElement)soapMetadataType);
                    }
                    else
                    {
                        throw new NotSupportedException("The requested type is not supported");
                    }
                }
            }
        }
        public TransactionToken AddNode(TransactionToken domainId, SoapNodeType nodeType, string originalId)
        {
            AddNodeTransactionOperation operation = new AddNodeTransactionOperation(Connection, TokenFactory);

            operation.DomainId = TokenFactory.ProcessToken(domainId);
            operation.NodeType = nodeType;
            operation.OriginalId = originalId;

            Operations.Enqueue(operation);

            return operation.ResultTokens.First();
        }
Esempio n. 3
0
        public TransactionToken AddNode(TransactionToken domainId, SoapNodeType nodeType, string originalId)
        {
            AddNodeTransactionOperation operation = new AddNodeTransactionOperation(Connection, TokenFactory);

            operation.DomainId   = TokenFactory.ProcessToken(domainId);
            operation.NodeType   = nodeType;
            operation.OriginalId = originalId;

            Operations.Enqueue(operation);

            return(operation.ResultTokens.First());
        }
        public SoapNode AddNode(Guid domainId, SoapNodeType nodeType, string originalId)
        {
            SoapNode soapNode = null;
            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                using (MappingToolDatabaseDataContext mappingDb = new MappingToolDatabaseDataContext())
                {
                    var domains = from dbDomain in mappingDb.Domains where dbDomain.DomainUid == domainId select dbDomain;

                    Domain domain;

                    if (domains.Count() > 0)
                    {
                        domain = domains.First();
                    }
                    else
                    {
                        domain = new Domain();
                        domain.DomainUid = domainId;
                        domain.DomainOriginalId = domainId.ToString();

                        mappingDb.Domains.InsertOnSubmit(domain);
                        mappingDb.SubmitChanges();
                    }

                    Node node = CreateNode(nodeType.Id, originalId);

                    domain.Nodes.Add(node);

                    mappingDb.SubmitChanges();

                    soapNode = new SoapNode();
                    soapNode.Domain = domainId;
                    soapNode.Id = node.NodeUid;
                    soapNode.NodeType = nodeType;
                }
            });
            return soapNode;
        }
        public List<SoapTypeElement> GetAllSoapTypes()
        {
            List<SoapTypeElement> soapTypes = new List<SoapTypeElement>();
            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                using (MappingToolDatabaseDataContext mappingDb = new MappingToolDatabaseDataContext())
                {
                    var metadataTypes = from dbMetadataTypes in mappingDb.MetadataTypes select dbMetadataTypes;
                    var nodeTypes = from dbNodeTypes in mappingDb.NodeTypes select dbNodeTypes;
                    var descriptorTypes = from dbDescriptorTypes in mappingDb.DescriptorTypes select dbDescriptorTypes;
                    var relationshipTypes = from dbRelationshipTypes in mappingDb.RelationshipTypes select dbRelationshipTypes;

                    foreach (var metadataType in metadataTypes)
                    {
                        SoapMetadataType soapMetadataType = new SoapMetadataType();
                        soapMetadataType.Id = metadataType.MetadataTypeUid;
                        soapMetadataType.Name = metadataType.MetadataTypeName;

                        soapTypes.Add(soapMetadataType);
                    }

                    foreach (var nodeType in nodeTypes)
                    {
                        SoapNodeType soapNodeType = new SoapNodeType();
                        soapNodeType.Id = nodeType.NodeTypeUid;
                        soapNodeType.Name = nodeType.NodeTypeName;

                        soapTypes.Add(soapNodeType);
                    }

                    foreach (var descriptorType in descriptorTypes)
                    {
                        SoapDescriptorType soapDescriptorType = new SoapDescriptorType();
                        soapDescriptorType.Id = descriptorType.DescriptorTypeUid;
                        soapDescriptorType.Name = descriptorType.DescriptorTypeName;

                        soapTypes.Add(soapDescriptorType);
                    }

                    foreach (var relationshipType in relationshipTypes)
                    {
                        SoapRelationshipType soapRelationshipType = new SoapRelationshipType();
                        soapRelationshipType.Id = relationshipType.RelationshipTypeUid;
                        soapRelationshipType.Name = relationshipType.RelationshipTypeName;

                        soapTypes.Add(soapRelationshipType);
                    }
                }
            });
            return soapTypes;
        }