示例#1
0
 public static ContractFileSession FromContract(EditorContract contract)
 {
     return(new ContractFileSession()
     {
         SerializedContract = EditorContractXML.To(contract)
     });
 }
示例#2
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);
        }
示例#3
0
        async Task SaveAsync()
        {
            Loading = true;

            ContractFileSession.SerializedContract = EditorContractXML.To(Contract);
            try
            {
                await ContractFileSessionService.UpdateAsync(ContractFileSession);

                await successSnackbar.ShowAsync();
            }
            catch (Exception)
            {
                contractAlertController.AddAlert("Error while saving contract occured", AlertScheme.Danger);
            }

            Loading = false;
            //await LoadCurrentContractAsync();
        }
示例#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);
        }
示例#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);
        }