Esempio n. 1
0
        public void ExecuteCmdletBase(PSCmdlet callingCmdlet)
        {
            if (Domain == null)
            {
                callingCmdlet.WriteWarning("No valid domain has been provided.");

                return;
            }

            if (!Domain.CheckIsValid())
            {
                callingCmdlet.WriteWarning("An invalid domain object has been provided.");

                return;
            }

            Model.IDatabaseInfo dbInfo = Domain;

            using (MappingToolDatabaseDataContext dataContext = new MappingToolDatabaseDataContext(dbInfo.ConnectionString))
            {
                dataContext.CommandTimeout = 180;
                if (MapId != Guid.Empty)
                {
                    /// Find maps by ID.
                    ///

                    Model.Map map = GetMapById(dataContext, MapId);

                    callingCmdlet.WriteObject(map);
                }
                else if (!string.IsNullOrEmpty(MapName))
                {
                    /// Find maps by name.
                    ///

                    List <Model.Map> maps = GetMapsByName(dataContext, MapName);

                    callingCmdlet.WriteObject(maps, true);
                }
                else
                {
                    /// Fine all maps.
                    ///

                    List <Model.Map> maps = GetAllMaps(dataContext);

                    callingCmdlet.WriteObject(maps, true);
                }
            }
        }
Esempio n. 2
0
        private List <Model.Domain> GetDomainsByName(MappingToolDatabaseDataContext dataContext, string domainName)
        {
            var dbDomainNodes = from qDomainNode in dataContext.Nodes
                                where qDomainNode.NodeTypeUid == DomainNodeType
                                select qDomainNode;

            var dbMatchingNodes = from qMetadata in dataContext.Metadatas
                                  join qDomainNode in dbDomainNodes on qMetadata.NodeUid equals qDomainNode.NodeUid
                                  where qMetadata.MetadataName == "Name" && qMetadata.MetadataValue == domainName
                                  select qDomainNode;

            List <Model.Domain> matchingDomains = new List <Model.Domain>();

            if (dbMatchingNodes == null || dbMatchingNodes.Count() == 0)
            {
                return(matchingDomains);
            }

            foreach (var dbDomainNode in dbMatchingNodes)
            {
                if (!dbDomainNode.DomainUid.HasValue || dbDomainNode.DomainUid.Value == Guid.Empty)
                {
                    continue;
                }

                Model.Domain domain = new Model.Domain();
                domain.DomainId = dbDomainNode.DomainUid.Value;
                domain.NodeId   = dbDomainNode.NodeUid;
                domain.Name     = domainName;

                Model.IDatabaseInfo dbInfo = domain;
                dbInfo.DatabaseServer = DatabaseServer;
                dbInfo.DatabaseName   = DatabaseName;

                matchingDomains.Add(domain);
            }

            return(matchingDomains);
        }
Esempio n. 3
0
        private List <Model.Domain> GetAllDomains(MappingToolDatabaseDataContext dataContext)
        {
            var dbAllDomainNodes = from qDomainNode in dataContext.Nodes
                                   where qDomainNode.NodeTypeUid == DomainNodeType
                                   select qDomainNode;

            var dbAllDomainNodesAndNames = from qMetadata in dataContext.Metadatas
                                           join qDomainNode in dbAllDomainNodes on qMetadata.NodeUid equals qDomainNode.NodeUid
                                           where qMetadata.MetadataName == "Name"
                                           select new { qDomainNode.NodeUid, qDomainNode.DomainUid.Value, qMetadata.MetadataValue };

            List <Model.Domain> allDomains = new List <Model.Domain>();

            if (dbAllDomainNodesAndNames == null || dbAllDomainNodesAndNames.Count() == 0)
            {
                return(allDomains);
            }

            foreach (var domainNodeAndName in dbAllDomainNodesAndNames)
            {
                if (domainNodeAndName.Value != Guid.Empty)
                {
                    Model.Domain domain = new Model.Domain();
                    domain.DomainId = domainNodeAndName.Value;
                    domain.NodeId   = domainNodeAndName.NodeUid;
                    domain.Name     = domainNodeAndName.MetadataValue;

                    Model.IDatabaseInfo dbInfo = domain;
                    dbInfo.DatabaseServer = DatabaseServer;
                    dbInfo.DatabaseName   = DatabaseName;

                    allDomains.Add(domain);
                }
            }

            return(allDomains);
        }
Esempio n. 4
0
        private Model.Domain GetDomainById(MappingToolDatabaseDataContext dataContext, Guid domainId)
        {
            var dbDomainNodes = from qDomainNode in dataContext.Nodes
                                where qDomainNode.DomainUid == domainId && qDomainNode.NodeTypeUid == DomainNodeType
                                select qDomainNode;

            if (dbDomainNodes == null || dbDomainNodes.Count() == 0)
            {
                return(null);
            }

            var dbDomainNode = dbDomainNodes.First();

            var dbMatchingMetadata = from qMetadata in dataContext.Metadatas
                                     where qMetadata.NodeUid == dbDomainNode.NodeUid && qMetadata.MetadataName == "Name"
                                     select qMetadata;

            string domainName = string.Empty;

            if (dbMatchingMetadata != null && dbMatchingMetadata.Count() > 0)
            {
                var domainMetadata = dbMatchingMetadata.First();
                domainName = domainMetadata.MetadataValue;
            }

            Model.Domain domain = new Model.Domain();
            domain.DomainId = domainId;
            domain.NodeId   = dbDomainNode.NodeUid;
            domain.Name     = domainName;

            Model.IDatabaseInfo dbInfo = domain;
            dbInfo.DatabaseServer = DatabaseServer;
            dbInfo.DatabaseName   = DatabaseName;

            return(domain);
        }