public async Task SelectOneNodeByNodeId()
        {
            Node _searchedNode;
            Node _getNode;

            //arrange
            using (var ctxSave = new DataContext(_opt.Options))
            {
                NodeRepository _db = new NodeRepository(ctxSave);
                await _db.InsertNodeAsync(_node1);

                await _db.InsertNodeAsync(_node2);
            }
            using (var ctxRead = new DataContext(_opt.Options))
            {
                _searchedNode = (
                    from n in ctxRead.Nodes
                    where n.NodeName == "France"
                    select n
                    ).FirstOrDefault();
            }
            //act
            using (var ctxGet = new DataContext(_opt.Options))
            {
                NodeRepository _db = new NodeRepository(ctxGet);
                _getNode = await _db.SelectNodeAsync(_searchedNode.NodeId);
            }
            //assert
            Assert.AreEqual(_searchedNode.NodeId, _getNode.NodeId,
                            $"No Matching Nodes: [searchedNode {_searchedNode.NodeId}] and [getNode {_getNode.NodeId}]");
        }
        public async Task UpdateOneNode()
        {
            // arrange
            Node _modifiedNode;
            Node _retrievedModifiedNode;

            using (var ctxSave = new DataContext(_opt.Options))
            {
                NodeRepository _db = new NodeRepository(ctxSave);
                await _db.InsertNodeAsync(_node8);
            }
            // act
            using (var ctxRead = new DataContext(_opt.Options))
            {
                _modifiedNode = (
                    from n in ctxRead.Nodes
                    where n.NodeName == "Perpendicular"
                    select n
                    ).FirstOrDefault();
            }
            _modifiedNode.NodeName  = "Triangular";
            _modifiedNode.NodeTopic = NodeTopics.Individual;
            _modifiedNode.HasEdits  = true;
            using (var ctxDelete = new DataContext(_opt.Options))
            {
                NodeRepository _db = new NodeRepository(ctxDelete);
                _retrievedModifiedNode = await _db.DeleteNodeAsync(_modifiedNode);
            }
            // assert
            Assert.AreEqual(_modifiedNode.NodeId, _retrievedModifiedNode.NodeId);
            Assert.AreEqual(_modifiedNode.NodeType, _retrievedModifiedNode.NodeType);
            Assert.AreNotEqual(_node8.NodeName, _retrievedModifiedNode.NodeName);
            Assert.AreNotEqual(_node8.NodeTopic, _retrievedModifiedNode.NodeTopic);
        }
        public async Task InsertOneNode()
        {
            //arrange
            Node _n1 = new Node
            {
                NodeName  = "Germany",
                NodeType  = NodeValueTypes.Name,
                NodeTopic = NodeTopics.Country,
                HasEdits  = false
            };

            //act
            using (var ctxSave = new DataContext(_opt.Options))
            {
                NodeRepository _db = new NodeRepository(ctxSave);
                await _db.InsertNodeAsync(_n1);
            }
            int _nodeCount = 0;

            using (var ctxRead = new DataContext(_opt.Options))
            {
                _nodeCount = (
                    from n in ctxRead.Nodes
                    where n.NodeName == "Germany"
                    select n
                    ).ToList().Count();
            }
            //assert
            Assert.AreEqual(1, _nodeCount);
        }
        public async Task InsertNodeSetAndThenSelectAllPaginatedNodes()
        {
            //arrange
            DataRequestParams _params           = _reqParams;
            int _selectCount                    = 0;
            int _pageCount                      = 0;
            IEnumerable <Node> _nodeSetToInsert = new List <Node>
            {
                _node1, _node2, _node3, _node7, _node8
            };
            int _insertCount       = _nodeSetToInsert.Count();
            int _expectedPageCount = (_insertCount + _params.PageSize - 1) / _params.PageSize;

            //act
            using (var ctxInsertSet = new DataContext(_opt.Options))
            {
                NodeRepository _db  = new NodeRepository(ctxInsertSet);
                var            _ins = await _db.InsertNodeSetAsync(_nodeSetToInsert);
            }
            // act pagination
            using (var ctxReadSet = new DataContext(_opt.Options))
            {
                NodeRepository _db = new NodeRepository(ctxReadSet);
                while (_selectCount < _insertCount)
                {
                    var _sel = await _db.SelectAllNodesAsync(_params);

                    _pageCount++;
                    _selectCount += _sel.Count();
                }
            }
            //assert
            Assert.AreEqual(_expectedPageCount, _pageCount,
                            $"Expected {_expectedPageCount} pages but executed ]{_pageCount} pages");
        }
Example #5
0
        public void NodesCanHaveAConstraint()
        {
            SUT         = new NodeRepository(ModelType.Full3D);
            nodeFactory = new NodeFactory(ModelType.Full3D, SUT);
            node1       = nodeFactory.Create(0, 0, 0);

            Assert.IsFalse(SUT.IsConstrained(node1, DegreeOfFreedom.X));
            Assert.IsFalse(SUT.IsConstrained(node1, DegreeOfFreedom.Y));
            Assert.IsFalse(SUT.IsConstrained(node1, DegreeOfFreedom.Z));
            Assert.IsFalse(SUT.IsConstrained(node1, DegreeOfFreedom.XX));
            Assert.IsFalse(SUT.IsConstrained(node1, DegreeOfFreedom.YY));
            Assert.IsFalse(SUT.IsConstrained(node1, DegreeOfFreedom.ZZ));

            SUT.ConstrainNode(node1, DegreeOfFreedom.X);
            Assert.IsTrue(SUT.IsConstrained(node1, DegreeOfFreedom.X));
            Assert.IsFalse(SUT.IsConstrained(node1, DegreeOfFreedom.Y));

            SUT.ConstrainNode(node1, DegreeOfFreedom.Y);
            Assert.IsTrue(SUT.IsConstrained(node1, DegreeOfFreedom.X));
            Assert.IsTrue(SUT.IsConstrained(node1, DegreeOfFreedom.Y));

            SUT.ConstrainNode(node1, DegreeOfFreedom.Z);
            Assert.IsTrue(SUT.IsConstrained(node1, DegreeOfFreedom.Z));

            SUT.ConstrainNode(node1, DegreeOfFreedom.XX);
            Assert.IsTrue(SUT.IsConstrained(node1, DegreeOfFreedom.XX));

            SUT.ConstrainNode(node1, DegreeOfFreedom.YY);
            Assert.IsTrue(SUT.IsConstrained(node1, DegreeOfFreedom.YY));

            SUT.ConstrainNode(node1, DegreeOfFreedom.ZZ);
            Assert.IsTrue(SUT.IsConstrained(node1, DegreeOfFreedom.ZZ));
        }
        public async Task InsertNodeSetAndThenSelectAllNodes()
        {
            //arrange
            DataRequestParams _params = _reqParams;

            _params.PageSize = 100;
            IEnumerable <Node> _nodeSetSelected;
            IEnumerable <Node> _nodeSetInserted;
            int _insertCount = 0;
            int _selectCount = 0;
            IEnumerable <Node> _nodeSetToInsert = new List <Node>
            {
                _node1, _node2, _node3, _node7, _node8
            };

            //act
            using (var ctxInsertSet = new DataContext(_opt.Options))
            {
                NodeRepository _db = new NodeRepository(ctxInsertSet);
                _nodeSetInserted = await _db.InsertNodeSetAsync(_nodeSetToInsert);
            }
            _insertCount = _nodeSetToInsert.Count();
            using (var ctxReadSet = new DataContext(_opt.Options))
            {
                NodeRepository _db = new NodeRepository(ctxReadSet);
                _nodeSetSelected = await _db.SelectAllNodesAsync(_params);
            }
            _selectCount = _nodeSetSelected.Count();
            //assert
            Assert.AreEqual(_selectCount, _insertCount,
                            $"Inserted Count {_insertCount} is not selected count from DB {_selectCount}");
        }
Example #7
0
 public DependencyEngine()
 {
     graph              = new DirectedGraph <INodeInfo>();
     nodeRepository     = new NodeRepository(this);
     expressionAdder    = new ExpressionAdder(graph, nodeRepository);
     engineInstrumenter = new EngineInstrumenter();
 }
        public FailureDetection(ISwimProtocolProvider swimProtocolProvider, IConfiguration configuration, ILogger <FailureDetection> logger)
        {
            _stateMachine         = new StateMachine <SwimFailureDetectionState, SwimFailureDetectionTrigger>(SwimFailureDetectionState.Idle);
            _swimProtocolProvider = swimProtocolProvider;
            _configuration        = configuration;
            _logger = logger;

            _nodeRepository = new NodeRepository(swimProtocolProvider.Node.Hostname);

            _protocolTimer           = new System.Timers.Timer(7000);
            _pingTimer               = new System.Timers.Timer(3500);
            _protocolTimer.AutoReset = false;
            _pingTimer.AutoReset     = false;
            _protocolTimer.Elapsed  += _protocolTimer_Elapsed;
            _pingTimer.Elapsed      += _pingTimer_Elapsed;

            _stateMachine.Configure(SwimFailureDetectionState.Idle)
            .Permit(SwimFailureDetectionTrigger.Ping, SwimFailureDetectionState.Pinged)
            .Ignore(SwimFailureDetectionTrigger.Reset)
            .OnEntry((entryAction) =>
            {
                Start();
            });

            _stateMachine.Configure(SwimFailureDetectionState.Pinged)
            .Permit(SwimFailureDetectionTrigger.PingExpireLive, SwimFailureDetectionState.Alive)
            .Permit(SwimFailureDetectionTrigger.PingExpireNoResponse, SwimFailureDetectionState.PrePingReq)
            .Permit(SwimFailureDetectionTrigger.ProtocolExpireDead, SwimFailureDetectionState.Expired);

            _stateMachine.Configure(SwimFailureDetectionState.Alive)
            .Permit(SwimFailureDetectionTrigger.ProtocolExpireLive, SwimFailureDetectionState.Expired);

            _stateMachine.Configure(SwimFailureDetectionState.PrePingReq)
            .Permit(SwimFailureDetectionTrigger.PingReq, SwimFailureDetectionState.PingReqed)
            .OnEntry(entryAction =>
            {
                _stateMachine.Fire(SwimFailureDetectionTrigger.PingReq);
                BroadcastPingReq();
            });

            _stateMachine.Configure(SwimFailureDetectionState.PingReqed)
            .Permit(SwimFailureDetectionTrigger.ProtocolExpireDead, SwimFailureDetectionState.Expired)
            .Permit(SwimFailureDetectionTrigger.ProtocolExpireLive, SwimFailureDetectionState.Expired);

            _stateMachine.Configure(SwimFailureDetectionState.Expired)
            .Permit(SwimFailureDetectionTrigger.Reset, SwimFailureDetectionState.Idle)
            .OnEntryFrom(SwimFailureDetectionTrigger.ProtocolExpireDead, entryAction =>
            {
                HandleSuspectNode();
            })
            .OnEntryFrom(SwimFailureDetectionTrigger.ProtocolExpireLive, entryAction =>
            {
                HandleAliveNode();
            });

            _swimProtocolProvider.ReceivedMessage += _swimProtocolProvider_ReceivedMessage;

            RestoreKnownNodes();
            AddBootstrapNodes();
        }
Example #9
0
        static void Main(string[] args)
        {
            var artifactRepository = new NodeRepository();

            var solutionRepository = new NodeRepository();

            var finder          = new GraphBuilder(solutionRepository, artifactRepository);
            var circleFormatter = new CircleFormattingService(new NodeFormattingService());
            var solutionPaths   = Directory.GetFiles(@"E:\Cadence\ESIETooLink\Main", "Bhi.Esie.Toolink.sln", SearchOption.AllDirectories);

            solutionPaths.ToList().ForEach(p => {
                finder.BuildArtifactsOfSolution(p);
            });
            artifactRepository.Nodes.ToList().ForEach(n => {
                finder.ResolveDependencies((ArtifactNode)n);
            });

            // Here we've built the graph, would be nice to show it, wouldn't it

            var circleService = new CirclesService();

            solutionRepository.Nodes.ToList().ForEach(node =>
            {
                var circles = circleService.FindCircles(node);
                if (circles.Any())
                {
                    Console.WriteLine($"{node.Name} {circles.Count()}");
                    circles.ToList().ForEach(circle => Console.WriteLine(circleFormatter.FormatCircle(circle)));
                }
            });
        }
        public async Task <uint256> InsertMerkleProof()
        {
            var blockStream = await RpcClient.GetBlockAsStreamAsync(await RpcClient.GetBestBlockHashAsync());

            var firstBlock     = HelperTools.ParseByteStreamToBlock(blockStream);
            var block          = firstBlock.CreateNextBlockWithCoinbase(firstBlock.Transactions.First().Outputs.First().ScriptPubKey.GetDestinationPublicKeys().First(), new Money(50, MoneyUnit.MilliBTC), new ConsensusFactory());
            var firstBlockHash = firstBlock.GetHash();

            var tx = Transaction.Parse(Tx1Hex, Network.Main);

            block.AddTransaction(tx);
            tx = Transaction.Parse(Tx2Hex, Network.Main);
            block.AddTransaction(tx);
            tx = Transaction.Parse(Tx3Hex, Network.Main);
            block.AddTransaction(tx);
            tx = Transaction.Parse(Tx4Hex, Network.Main);
            block.AddTransaction(tx);
            tx = Transaction.Parse(Tx5Hex, Network.Main);
            block.AddTransaction(tx);

            rpcClientFactoryMock.AddKnownBlock((await RpcClient.GetBlockCountAsync()) + 1, block.ToBytes());
            var node      = NodeRepository.GetNodes().First();
            var rpcClient = rpcClientFactoryMock.Create(node.Host, node.Port, node.Username, node.Password);

            PublishBlockHashToEventBus(await rpcClient.GetBestBlockHashAsync());


            return(firstBlockHash);
        }
Example #11
0
        private static void Main(string[] args)
        {
            var builder = new ConfigurationBuilder()
                          .SetBasePath(Directory.GetCurrentDirectory())
                          .AddJsonFile("appsettings.json");

            var configuration = builder.Build();

            BinaryTree binaryTree = new();

            binaryTree.Add(1);
            binaryTree.Add(2);
            binaryTree.Add(3);
            binaryTree.Add(4);
            binaryTree.Add(5);

            //Busca de Node
            Node node = binaryTree.Find(2);

            NodeModel model = new();

            //Preparação do dado
            model.Id    = Guid.NewGuid().ToString();
            model.Datas = binaryTree.GetAllNodes();

            NodeRepository repository = new NodeRepository(configuration["ConnectionString"], configuration["DatabaseName"]);

            //Persistencia
            repository.Insert(model);

            //recuperação
            var entidadeSalva = repository.Get(model.Id);

            //BinaryTree binaryTreeRecover = new(entidadeSalva.Datas);
        }
        public void ManyNode()
        {
            var circlesService = new CirclesService();
            var nodeRepository = new NodeRepository();
            var nodeA          = new Node("a");
            var nodeB          = new Node("b");
            var nodeC          = new Node("c");
            var nodeD          = new Node("d");
            var nodeE          = new Node("e");
            var nodeF          = new Node("f");
            var nodeG          = new Node("g");
            var nodeH          = new Node("h");

            nodeA.Add(nodeC).Add(nodeG);
            nodeB.Add(nodeC).Add(nodeH);
            nodeC.Add(nodeE);
            nodeD.Add(nodeA).Add(nodeB);
            nodeE.Add(nodeD);
            nodeF.Add(nodeE);
            nodeH.Add(nodeA);

            IList <ICircle> circles = circlesService.FindCircles(nodeE);

            Assert.IsNotNull(circles, "Even when there is no circle, there should be a valid list");
            Assert.AreEqual(1, circles.Count, "list should have one circle");
            Assert.AreEqual("e,d,a,c,e", circles[0].ToString());
        }
Example #13
0
 public IndexAction()
 {
     _articleRepository = new ArticleRepository();
     _nodeRepository = new NodeRepository();
     _articleCategoryRepository = new ArticleCategoryRepository();
     _nodeRecordRepository = new NodeRecordRepository();
 }
Example #14
0
 public SQLDBLoader(string inputPath)
     : base(inputPath)
 {
     _fileNames = new List<string>();
     _nodeRepo = new NodeRepository();
     _linkRepo = new NodeLinksRepository();
 }
Example #15
0
        /// <summary>
        /// 获取用户信息
        /// </summary>
        /// <param name="account">账户名</param>
        public async Task <ExcutedResult <AccountInfo> > GetAccountInfo(string account)
        {
            try
            {
                var info = await Client.GetAccount(account);

                var accountInfo = MapperHelper <GetAccountResponse, AccountInfo> .Map(info);

                return(ExcutedResult <AccountInfo> .SuccessResult(accountInfo));
            }
            catch (ApiErrorException aex)
            {
                Log4NetHelper.WriteError(GetType(), aex, $"Point:{Point.HttpAddress} Account:{account}");
                return(ExcutedResult <AccountInfo> .SuccessResult("", null));
            }
            catch (ApiException ex)
            {
                NodeRepository.ApiException();
                Log4NetHelper.WriteError(GetType(), ex, $"Point:{Point.HttpAddress} StatusCode:{ex.StatusCode} Content:{ex.Content}");
                return(ExcutedResult <AccountInfo> .FailedResult(BusinessResultCode.ChainRequestError, "EOS request error."));
            }
            catch (Exception ex)
            {
                Log4NetHelper.WriteError(GetType(), ex, $"Point:{Point.HttpAddress} Account:{account}");
                return(ExcutedResult <AccountInfo> .FailedResult(SysResultCode.ServerException, ""));
            }
        }
Example #16
0
        public void NodeRepository_GetSemanticNetworkBySession()
        {
            using (UnitOfWorkFactory.Create()) {
                var expertRepository = new NodeRepository(GetRepository <Node>(), LinqProvider);

                var actualSemanticNetwork = expertRepository.GetSemanticNetworkBySession(_session1);

                actualSemanticNetwork.Concepts.Should().BeEquivalentTo(
                    new ConceptReadModel(
                        "notion1",
                        "type",
                        new List <VergeReadModel> {
                    new VergeReadModel("notion2", "type", "notion1", "type", "type", 20)
                },
                        new List <VergeReadModel>
                {
                    new VergeReadModel("notion1", "type", "notion2", "type", "type", 20)
                }),
                    new ConceptReadModel(
                        "notion2",
                        "type",
                        new List <VergeReadModel> {
                    new VergeReadModel("notion1", "type", "notion2", "type", "type", 20)
                },
                        new List <VergeReadModel>
                {
                    new VergeReadModel("notion2", "type", "notion1", "type", "type", 20)
                }));
            }
        }
Example #17
0
        private static void CreateNodes()
        {
            using (var unitOfWork = new UnitOfWork())
            {
                var repository = new NodeRepository(unitOfWork);

                for (int i = 0; i < NumberOfNodes; i++)
                {
                    var node = new Node("Node " + (i + 1));
                    repository.Save(node);
                }

                unitOfWork.Commit();
            }

            using (var unitOfWork = new UnitOfWork())
            {
                var repository = new MongoNodeRepository(unitOfWork);

                for (int i = 0; i < NumberOfNodes; i++)
                {
                    var node = new MongoNode("Node " + (i + 1));
                    repository.Save(node);
                }

                unitOfWork.Commit();
            }
        }
Example #18
0
        private static long LinkSqlNodes()
        {
            var stopwatch = new Stopwatch();

            stopwatch.Start();

            using (var unitOfWork = new UnitOfWork())
            {
                var repository = new NodeRepository(unitOfWork);

                IList <Node> nodes = repository.GetAll();
                foreach (Node node1 in nodes)
                {
                    foreach (Node node2 in nodes)
                    {
                        node1.AddLink(node2);
                    }
                }

                unitOfWork.Commit();
            }

            stopwatch.Stop();
            return(stopwatch.ElapsedMilliseconds);
        }
Example #19
0
        /// <summary>
        /// 获取通证余额
        /// </summary>
        /// <param name="account">账户名</param>
        /// <param name="currency">通证符号</param>
        /// <returns>余额</returns>
        public async Task <decimal> GetBalanceAsync(string account, string currency, string tokenAccount = "")
        {
            try
            {
                var response = await Client.GetCurrencyBalance(tokenAccount, account, currency);

                if (response.Any())
                {
                    return(decimal.Parse(response.First().Split(" ")[0]));
                }
                return(0);
            }
            catch (ApiErrorException e)
            {
                Log4NetHelper.WriteError(GetType(), e,
                                         $"Point:{Point.HttpAddress} Code:{e.code} ErrorName:{e.error.name} Error:{e.error.what} \naccount:{account}\ncurrency:{currency}\ntokenAccount:{tokenAccount}");
                throw;
            }
            catch (ApiException ex)
            {
                NodeRepository.ApiException();
                Log4NetHelper.WriteError(typeof(TokenClient), ex, $"StatusCode:{ex.StatusCode} Content:{ex.Content}");
                return(0);
            }
            catch (Exception ex)
            {
                Log4NetHelper.WriteError(GetType(), ex, $"Point:{Point.HttpAddress}");
                return(0);
            }
        }
Example #20
0
        public TileItem(INode node)
            : base(node)
        {
            Header      = Node.GetProperty <string>("header");
            Description = Node.GetProperty <string>("description");
            BodyText1   = Node.GetProperty <string>("bodyText1");
            BodyText2   = Node.GetProperty <string>("bodyText2");

            int mediaId = Node.GetProperty <int>("pageImage");

            if (mediaId != 0)
            {
                PictureUrl = new Media(mediaId).GetImageUrl();
            }

            PublishDate = Node.GetProperty <DateTime>("publishDate");
            if (PublishDate == DateTime.MinValue)
            {
                PublishDate = Node.CreateDate;
            }

            Url   = library.NiceUrl(Node.Id);
            Link  = NodeRepository.GetLink(Node.GetProperty <string>("link"));
            Image = CreateImageItem(Node.GetProperty <string>("pageImage"));
        }
        //UtilityLogic utility = new UtilityLogic();
        public void BeginProcess()
        {
            UtilityLogic.LogMessage("Initializing nodes...");
            var nodes = new NodeRepository().GetAll();

            if (nodes == null || nodes.Count() < 1)
            {
                UtilityLogic.LogError("No node is configured!");
            }
            else
            {
                foreach (var node in nodes)
                {
                    try
                    {
                        CbaListener.StartUpListener(node.ID.ToString(), node.HostName, Convert.ToInt32(node.Port));
                        UtilityLogic.LogMessage(node.Name + " now listening on port " + node.Port);
                    }
                    catch (Exception ex)
                    {
                        UtilityLogic.LogError("Message: " + ex.Message + " \t InnerException " + ex.InnerException);
                    }
                }
            }
        }
        public void RepoSolutionCircle()
        {
            var circlesService = new CirclesService();
            var solutionA      = new SolutionNode("SolutionA");
            var solutionB      = new SolutionNode("SolutionB");
            var solutionC      = new SolutionNode("SolutionC");
            var artifactA      = solutionA.CreatesArtifact("ArtifactA", "a");
            var artifactD      = solutionA.CreatesArtifact("ArtifactD", "d");

            var artifactB = solutionB.CreatesArtifact("ArtifactB", "b");
            var artifactC = solutionC.CreatesArtifact("ArtifactC", "c");

            // the circle
            artifactA.DependsOn(artifactB);
            artifactB.DependsOn(artifactC);
            artifactC.DependsOn(artifactD);

            NodeRepository repo = new NodeRepository();

            repo.Add(solutionA);
            repo.Add(solutionB);
            repo.Add(solutionC);
            IList <ICircle> circles = circlesService.FindCircles(repo);

            Assert.IsNotNull(circles, "Even when there is no circle, there should be a valid list");
            Assert.AreEqual(1, circles.Count, "list should have one circles");
            Assert.AreEqual("SolutionA:ArtifactA,SolutionB:ArtifactB,SolutionC:ArtifactC,SolutionA:ArtifactD", circles[0].ToString());
        }
Example #23
0
        /// <summary>
        /// 获取信息
        /// </summary>
        /// <returns></returns>
        public async Task <ExcutedResult> GetInfo()
        {
            try
            {
                var result = await Client.GetInfo();

                if (result == null)
                {
                    return(ExcutedResult.FailedResult(BusinessResultCode.ChainRequestError, "Chain request  error"));
                }

                return(ExcutedResult.SuccessResult(result));
            }
            catch (ApiException ex)
            {
                NodeRepository.ApiException();
                Log4NetHelper.WriteError(typeof(InfoClient), ex,
                                         $"Point:{Point.HttpAddress} StatusCode:{ex.StatusCode} Content:{ex.Content}");
                return(ExcutedResult.FailedResult(BusinessResultCode.ChainRequestError, "Chain request  error."));
            }
            catch (Exception ex)
            {
                Log4NetHelper.WriteError(GetType(), ex, $"Point:{Point.HttpAddress}");
                return(ExcutedResult.FailedResult(SysResultCode.ServerException, ""));
            }
        }
Example #24
0
        public DepartmentItem(INode node)
            : base(node)
        {
            Department = Node.GetProperty <string>("name");
            Address    = Node.GetProperty <string>("address");
            Other      = Node.GetProperty <string>("other");


            OpeningHours = Node.GetProperty <string>("openingHours");
            GeoCoords    = Node.GetProperty <string>("geoInfo");

            if (!string.IsNullOrEmpty(Node.GetProperty <string>("employeeImage")))
            {
                Employee = NodeRepository.GetEmployee(Node.GetProperty <string>("employeeImage"));
            }

            DepartmentImage = CreatePictureUrl(Node.GetProperty <string>("departmentImage"));

            if (!string.IsNullOrEmpty(Node.GetProperty <string>("link")))
            {
                Link = NodeRepository.GetLink(Node.GetProperty <string>("link"));
            }
            Image = CreateImageItem(Node.GetProperty <string>("image"));

            EmailBookTryCar     = Node.GetProperty <string>("emailBookTryCar");
            EmailServicebooking = Node.GetProperty <string>("emailServiceBooking");
        }
Example #25
0
        protected ZipFolderItem CreateFolderOnFileSystem2(ZipFolderItem folder)
        {
            Action action = () => NodeRepository.ZipFile.AddDirectoryByName(folder.QualifiedIdentifier);

            NodeRepository.PerformWriteAction(action);

            return(NodeRepository.GetFolderItem(folder.QualifiedIdentifier));
        }
Example #26
0
        public ExpressionAdder(DirectedGraph <INodeInfo> graph, NodeRepository nodeRepository)
        {
            var definitionComparer = new DefinitionComparer();

            definitionToNodeLookup = new Dictionary <IDefinitionIdentity, INodeInfo>(definitionComparer);
            this.graph             = graph;
            this.nodeRepository    = nodeRepository;
        }
Example #27
0
 public void Setup()
 {
     SUT         = new NodeRepository(ModelType.Truss1D);
     nodeFactory = new NodeFactory(ModelType.Truss1D, SUT);
     node1       = nodeFactory.Create(0);
     node2       = nodeFactory.Create(1);
     node3       = nodeFactory.Create(2);
 }
Example #28
0
        protected void DeleteFolderOnFileSystem2(ZipFolderItem folder)
        {
            Action action = () => {
                var entriesToRemove = folder.Node.GetDescendants(true).Select(n => n.FileEntry).ToArray();
                NodeRepository.ZipFile.RemoveEntries(entriesToRemove);
            };

            NodeRepository.PerformWriteAction(action);
        }
Example #29
0
        public void CanCreateAndAddtoTheRepository()
        {
            NodeRepository repository = new NodeRepository(ModelType.Truss1D);
            this.SUT = new NodeFactory(ModelType.Truss1D, repository);
            Assert.AreEqual(0, repository.Count);

            this.SUT.Create(0);
            Assert.AreEqual(1, repository.Count);
        }
Example #30
0
        /// <summary>
        /// Disposes the <see cref="NodeRepository"/> and
        /// underlying <see cref="ZipFile"/>.
        /// </summary>
        /// <param name="disposing">If disposing equals <c>false</c>, the method
        /// has been called by the runtime from inside the finalizer.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && !IsDisposed)
            {
                NodeRepository.Dispose();
            }

            base.Dispose(disposing);
        }
Example #31
0
 public Car(INode node)
     : base(node)
 {
     Header        = Node.GetProperty <string>("header");
     Description   = Node.GetProperty <string>("price");
     PictureUrl    = CreatePictureUrl(Node.GetProperty <string>("tileImage"));
     Link          = NodeRepository.GetLink(Node.GetProperty <string>("link"), Node);
     NodeTypeAlias = UmbracoEnum.GetDocType(node);
 }
Example #32
0
        public void Close()
        {
            //Would include this with IDisposable if I had more time.
            _nodeRepo.Close();
            _linkRepo.Close();

            _nodeRepo = null;
            _linkRepo = null;
        }
Example #33
0
        public ZipFolderItem ResolveFolderResourcePath2(string submittedFolderPath, FileSystemTask context)
        {
            if (String.IsNullOrEmpty(submittedFolderPath) || submittedFolderPath == ZipNodeRepository.RootFolderPath)
            {
                return(GetFileSystemRootImplementation() as ZipFolderItem);
            }

            return(NodeRepository.GetFolderItem(submittedFolderPath));
        }
Example #34
0
        public void Setup()
        {
            db = new Db();
            db.SetupTables();

            nodeRepository = new NodeRepository(db.Connection);

            Seed.Nodes(db);
        }
        public void SetupContext()
        {
            var configuration = new Configuration();
            configuration.Configure();
            configuration.AddAssembly(typeof(Equipment).Assembly);
            new SchemaExport(configuration).Execute(false, true, false, false);

            _sessionFactory = configuration.BuildSessionFactory();

            CreateInitialData();

            _repository = new NodeRepository();
        }
Example #36
0
        public void NodesCanHaveAConstraint()
        {
            SUT = new NodeRepository(ModelType.Full3D);
            nodeFactory = new NodeFactory(ModelType.Full3D, SUT);
            node1 = nodeFactory.Create(0, 0, 0);

            Assert.IsFalse(SUT.IsConstrained(node1, DegreeOfFreedom.X));
            Assert.IsFalse(SUT.IsConstrained(node1, DegreeOfFreedom.Y));
            Assert.IsFalse(SUT.IsConstrained(node1, DegreeOfFreedom.Z));
            Assert.IsFalse(SUT.IsConstrained(node1, DegreeOfFreedom.XX));
            Assert.IsFalse(SUT.IsConstrained(node1, DegreeOfFreedom.YY));
            Assert.IsFalse(SUT.IsConstrained(node1, DegreeOfFreedom.ZZ));

            SUT.ConstrainNode(node1, DegreeOfFreedom.X);
            Assert.IsTrue(SUT.IsConstrained(node1, DegreeOfFreedom.X));
            Assert.IsFalse(SUT.IsConstrained(node1, DegreeOfFreedom.Y));

            SUT.ConstrainNode(node1, DegreeOfFreedom.Y);
            Assert.IsTrue(SUT.IsConstrained(node1, DegreeOfFreedom.X));
            Assert.IsTrue(SUT.IsConstrained(node1, DegreeOfFreedom.Y));

            SUT.ConstrainNode(node1, DegreeOfFreedom.Z);
            Assert.IsTrue(SUT.IsConstrained(node1, DegreeOfFreedom.Z));

            SUT.ConstrainNode(node1, DegreeOfFreedom.XX);
            Assert.IsTrue(SUT.IsConstrained(node1, DegreeOfFreedom.XX));

            SUT.ConstrainNode(node1, DegreeOfFreedom.YY);
            Assert.IsTrue(SUT.IsConstrained(node1, DegreeOfFreedom.YY));

            SUT.ConstrainNode(node1, DegreeOfFreedom.ZZ);
            Assert.IsTrue(SUT.IsConstrained(node1, DegreeOfFreedom.ZZ));
        }
Example #37
0
 /// <summary>
 /// Initializes a new instance of the <see cref="NodeFactory" /> class.
 /// </summary>
 /// <param name="typeOfModel">The type of model for which this factory will be creating new nodes.</param>
 /// <param name="repository">The repository with which to register newly created nodes.</param>
 internal NodeFactory(ModelType typeOfModel, NodeRepository repository)
 {
     this.modelType = typeOfModel;
     this.repo = repository;
 }
Example #38
0
 public NodeRecordAction()
 {
     _nodeRecordRepository = new NodeRecordRepository();
     _nodeRepository = new NodeRepository();
 }
 /// <summary>
 /// Creates NodeListViewModel instance using given repository.
 /// </summary>
 public NodeListViewModel(IRepository<Node> pRepository)
 {
     mNodeRepository = pRepository as NodeRepository;
     GetAllNodes();
 }
Example #40
0
 public NodeAction()
 {
     _articleCategoryRepository = new ArticleCategoryRepository();
     _nodeRepository = new NodeRepository();
 }
Example #41
0
 public void Setup()
 {
     SUT = new NodeRepository(ModelType.Truss1D);
     nodeFactory = new NodeFactory(ModelType.Truss1D, SUT);
     node1 = nodeFactory.Create(0);
     node2 = nodeFactory.Create(1);
     node3 = nodeFactory.Create(2);
 }
Example #42
0
 public SQLDBLoader()
     : base()
 {
     _nodeRepo = new NodeRepository();
     _linkRepo = new NodeLinksRepository();
 }