public async Task <ActionResult> DownloadAsync(string id)
        {
            try
            {
                var session = await facade.GetAsync(id);

                var contract = EditorContractXML.From(session.SerializedContract);
                return(File(Encoding.UTF8.GetBytes(session.SerializedContract), "application/xml", contract.Name + "_" + contract.Id + ".dascontract"));
            }
            catch (NotFoundException)
            {
                return(NotFound());
            }
        }
Beispiel #2
0
        async Task LoadCurrentContractAsync()
        {
            Loading = true;

            try
            {
                ContractFileSession = await ContractFileSessionService.GetAsync(Id);

                Contract = EditorContractXML.From(ContractFileSession.SerializedContract);
            }
            catch (Exception e)
            {
                initialException = e;
            }

            Loading = false;
        }
Beispiel #3
0
        public void SerializationWithEmptyContract()
        {
            var contract = new EditorContract()
            {
                Id   = "contract",
                Name = "Contract"
            };

            //Serialize
            var serializedContract = EditorContractXML.To(contract);

            //Deserialize
            var deserializedContract = EditorContractXML.From(serializedContract);

            //Check
            Assert.AreEqual("contract", deserializedContract.Id);
            Assert.AreEqual("Contract", deserializedContract.Name);
        }
Beispiel #4
0
        public void SerializationWithNoDiagram()
        {
            var contract = new EditorContract()
            {
                Id        = "contract",
                Name      = "Contract",
                DataModel = GetExampleDataModel()
            };

            //Serialize
            var serializedContract = EditorContractXML.To(contract);

            //Deserialize
            var deserializedContract = EditorContractXML.From(serializedContract);

            //Check
            Assert.AreEqual("contract", deserializedContract.Id);
            Assert.AreEqual("Contract", deserializedContract.Name);
            AssertExampleDataModel(deserializedContract.DataModel);
        }
Beispiel #5
0
        public void SerializationWithDiagram()
        {
            var contract = new EditorContract()
            {
                Id        = "contract",
                Name      = "Contract",
                DataModel = GetExampleDataModel(),
                Processes = new ContractProcesses()
                {
                }
            };

            contract.ReplaceSafely(BPMNProcessDiagram.FromXml(GetExampleBPMN()));
            contract.Processes.Main.UserActivities.First().Form = new ContractForm()
            {
                Id = "XXX"
            };
            contract.Processes.Main.BusinessActivities.First().Diagram = DMNProcessDiagram.FromXml("YYY");
            contract.Processes.Main.ScriptActivities.First().Script    = "ZZZ";
            contract.Processes.Main.StartEvents.First().StartForm      = new ContractForm()
            {
                Id = "XXXX"
            };

            contract.Processes.Main.StartEvents.First().StartForm.Fields.Add(new ContractFormField()
            {
                PropertyBinding = new ContractPropertyBinding()
                {
                    Property = contract.DataModel.Entities[0].PrimitiveProperties[0]
                }
            });
            contract.Processes.Main.UserActivities.First().Form.Fields.Add(new ContractFormField()
            {
                PropertyBinding = new ContractPropertyBinding()
                {
                    Property = contract.DataModel.Entities[0].PrimitiveProperties[0]
                }
            });

            //Serialize
            var serializedContract = EditorContractXML.To(contract);

            //Deserialize
            var deserializedContract = EditorContractXML.From(serializedContract);

            //Check
            Assert.AreEqual("XXXX", contract.Processes.Main.StartEvents.First().StartForm.Id);
            Assert.AreEqual("XXX", contract.Processes.Main.UserActivities.First().Form.Id);
            Assert.AreEqual("YYY", contract.Processes.Main.BusinessActivities.First().Diagram.DiagramXML);
            Assert.AreEqual("ZZZ", contract.Processes.Main.ScriptActivities.First().Script);

            Assert.AreEqual(contract.DataModel.Entities[0].PrimitiveProperties[0],
                            contract.Processes.Main.StartEvents.First().StartForm.Fields[0].PropertyBinding.Property);
            Assert.AreEqual(contract.DataModel.Entities[0].PrimitiveProperties[0],
                            contract.Processes.Main.UserActivities.First().Form.Fields[0].PropertyBinding.Property);


            Assert.AreEqual("contract", deserializedContract.Id);
            Assert.AreEqual("Contract", deserializedContract.Name);
            AssertExampleDataModel(deserializedContract.DataModel);
            Assert.AreEqual(GetExampleBPMN(), deserializedContract.Processes.Diagram.DiagramXML);
            AssertExampleProcess(contract.Processes.Main);
        }