예제 #1
0
        public void Traverse_SetProperty_ShouldTraverseAll()
        {
            var tree = new List <Node>();

            var a = new Node(0);

            a.AddNode(new Node(1));
            a.AddNode(new Node(2));

            var b = new Node(3);

            b.AddNode(new Node(4));

            tree.Add(a);
            tree.Add(b);

            foreach (var treeNode in tree)
            {
                TreeStructureHelper.Traverse <Node, int?>(treeNode, GetTester, (node, o) => node.Tester = o);
            }

            foreach (var node in tree)
            {
                node.Tester.Should().Be(node.TesterId);
            }
        }
        public EventControlViewModel(ChunkControlViewModel chunkControlViewModel)
        {
            this.chunkControlViewModel = chunkControlViewModel;

            RemoveMeCommand = new Command(RemoveMeCommandExecute);

            //  TransactionEventTypes = new List<TransactionEventType>(Enum.GetValues(typeof(TransactionEventType)).Cast<TransactionEventType>());
            TransactionCompletions = new List <TransactionCompletion>(Enum.GetValues(typeof(TransactionCompletion)).Cast <TransactionCompletion>());

            Actors = new ObservableCollection <ActorViewModel>();

            foreach (var actor in MainPageViewModel.ParserResult.Actors)
            {
                var role = MainPageViewModel.GetActorRole(actor.ActorKindId);
                Actors.Add(new ActorViewModel(actor.Id, actor.FullName, role.Name, role.Id));
            }

            TransactionInstances = new ObservableCollection <TransactionViewModel>();

            foreach (var instance in MainPageViewModel.ParserResult.ProcessInstance.GetTransactions())
            {
                var kind = MainPageViewModel.ProcessKind.GetTransactionById(instance.TransactionKindId);
                var vm   = new TransactionViewModel(instance, kind.Name);
                TransactionInstances.Add(vm);

                TreeStructureHelper.Traverse(instance, TransactionInstances, (i, list) =>
                {
                    var tKind = MainPageViewModel.ProcessKind.GetTransactionById(i.TransactionKindId);
                    list.Add(new TransactionViewModel(i, tKind.Name));
                });
            }

            var lastChunk = MainPageViewModel.SecondLastChunk();

            if (this.chunkControlViewModel.Events.Count > 1)
            {
                CreationTime =
                    ((EventControlViewModel)chunkControlViewModel.Events[chunkControlViewModel.Events.Count - 2]
                     .DataContext).CreationTime;
            }
            else if (lastChunk != null && lastChunk.Events.Count > 0)
            {
                CreationTime = ((EventControlViewModel)(lastChunk.Events[lastChunk.Events.Count - 1]
                                                        .DataContext)).CreationTime;
            }
            else
            {
                CreationTime = "01-02-2018 15:34:23";
            }
        }
예제 #3
0
        private static void CreateTransactionElements(ProcessKind process, XElement transactionsElement)
        {
            foreach (var kind in process.GetTransactions())
            {
                var rootElement = CreateTransactionKindElement(kind);

                TreeStructureHelper.Traverse(kind, rootElement, (node, element) =>
                {
                    var childElement = CreateTransactionKindElement(node);
                    element.Add(childElement);
                });

                transactionsElement.Add(rootElement);
            }
        }
        public XElement Create(ProcessInstance process)
        {
            var root = new XElement(XmlParsersConfig.ElementProcessInstance,
                                    new XAttribute(XmlParsersConfig.AttributeId, process.Id),
                                    new XAttribute(XmlParsersConfig.AttributeKindId, process.ProcessKindId),
                                    new XAttribute(XmlParsersConfig.AttributeStartTime, process.StartTime.HasValue ? process.StartTime.Value.ToString(XmlParsersConfig.DateTimeFormat) : string.Empty),
                                    new XAttribute(XmlParsersConfig.AttributeExpectedEndTime, process.ExpectedEndTime.HasValue ? process.ExpectedEndTime.Value.ToString(XmlParsersConfig.DateTimeFormat) : string.Empty));

            foreach (var transaction in process.GetTransactions())
            {
                var element = CreateTransactionElement(transaction);
                TreeStructureHelper.Traverse(transaction, element, (t, e) => e.Add(CreateTransactionElement(t)));
                root.Add(element);
            }


            return(root);
        }
예제 #5
0
        private static DataTable CreateDataTable(List <TransactionInstance> transactions)
        {
            var table = new DataTable();

            table.Columns.Add("Id", typeof(int));
            table.Columns.Add("Identificator", typeof(string));
            table.Columns.Add("Completion", typeof(float));
            table.Columns.Add("Completion type", typeof(String));
            table.Columns.Add("Parent id", typeof(int));

            //     table.Columns.Add("", typeof(DateTime));

            foreach (var root in transactions)
            {
                table.Rows.Add(root.Id, root.Identificator, root.CompletionNumber, root.Completion, root.ParentId);
                TreeStructureHelper.Traverse(root, table, (node, t) => t.Rows.Add(node.Id, node.Identificator, node.CompletionNumber, node.Completion, node.ParentId));
            }

            return(table);
        }
        public async Task <ProcessSimulation> LoadAsync(string caseName)
        {
            var processKind = await LoadDefinitionAsync();

            var caseXml = await SimulationCases.LoadXmlAsync(caseName);

            var simulation = new RentalContractSimulationFromXml(caseXml);

            simulation.Prepare();
            var transactions = simulation.ProcessInstance.GetTransactions();

            foreach (var instance in transactions)
            {
                TreeStructureHelper.Traverse <TransactionInstance, TransactionKind>(instance,
                                                                                    (node) => processKind.GetTransactionById(node.Id), (transactionInstance, transactionKind) =>
                {
                    transactionInstance.TransactionKind = transactionKind;
                });
            }

            return(simulation);
        }