Esempio n. 1
0
        public void TestWalkerFromMessageContractWithPrimitiveMessageParts()
        {
            List <ModelElement> elementList = new List <ModelElement>();

            using (Transaction t = ServiceContractStore.TransactionManager.BeginTransaction())
            {
                ServiceContractModel root  = CreateServiceContractRoot();
                Message request            = CreateMessageContract("FooMCReq", "FooMCReq");
                PrimitiveMessagePart part1 = CreatePrimitiveMessagePart("FooPart1");
                PrimitiveMessagePart part2 = CreatePrimitiveMessagePart("FooPart2");
                PrimitiveMessagePart part3 = CreatePrimitiveMessagePart("FooPart3");

                request.MessageParts.Add(part1);
                request.MessageParts.Add(part2);
                request.MessageParts.Add(part3);
                root.Messages.Add(request);

                FullDepthElementWalker elementWalker =
                    new FullDepthElementWalker(
                        new ModelElementVisitor(elementList),
                        new EmbeddingReferenceVisitorFilter(),
                        false);

                elementWalker.DoTraverse(request);

                Assert.AreEqual(4, elementList.Count);

                t.Rollback();
            }
        }
Esempio n. 2
0
        public void TestWalkerFromServiceContractWithOperationsWithDifferentRequestAndResponse()
        {
            List <ModelElement> elementList = new List <ModelElement>();

            using (Transaction t = ServiceContractStore.TransactionManager.BeginTransaction())
            {
                ServiceContractModel root            = CreateServiceContractRoot();
                ServiceContract      serviceContract = CreateServiceContract("Foo", "Foo");
                Operation            operation1      = CreateOperationContract("FooOP1");
                Operation            operation2      = CreateOperationContract("FooOP2");

                operation1.Request  = CreateMessageContract("FooMCReq1", "FooMCReq1");
                operation1.Response = CreateMessageContract("FooMCRes1", "FooMCRes1");
                operation2.Request  = CreateMessageContract("FooMCReq2", "FooMCReq2");
                operation2.Response = CreateMessageContract("FooMCRes2", "FooMCRes2");

                serviceContract.Operations.Add(operation1);
                serviceContract.Operations.Add(operation2);
                root.ServiceContracts.Add(serviceContract);

                FullDepthElementWalker elementWalker =
                    new FullDepthElementWalker(
                        new ModelElementVisitor(elementList),
                        new EmbeddingReferenceVisitorFilter(),
                        false);

                elementWalker.DoTraverse(serviceContract);

                Assert.AreEqual(7, elementList.Count);

                t.Rollback();
            }
        }
Esempio n. 3
0
        public void TestWalkerFromServiceContractWithOperationWithRequestAndResponseWithPrimitiveMessagePart()
        {
            List <ModelElement> elementList = new List <ModelElement>();

            using (Transaction t = ServiceContractStore.TransactionManager.BeginTransaction())
            {
                ServiceContractModel root            = CreateServiceContractRoot();
                ServiceContract      serviceContract = CreateServiceContract("Foo", "Foo");
                Operation            operation       = CreateOperationContract("FooOP");
                Message request            = CreateMessageContract("FooMCReq", "FooMCReq");
                Message response           = CreateMessageContract("FooMCRes", "FooMCRes");
                PrimitiveMessagePart part1 = CreatePrimitiveMessagePart("FooPart1");
                PrimitiveMessagePart part2 = CreatePrimitiveMessagePart("FooPart2");

                request.MessageParts.Add(part1);
                response.MessageParts.Add(part2);
                operation.Request  = request;
                operation.Response = response;
                serviceContract.Operations.Add(operation);
                root.ServiceContracts.Add(serviceContract);

                FullDepthElementWalker elementWalker =
                    new FullDepthElementWalker(
                        new ModelElementVisitor(elementList),
                        new EmbeddingReferenceVisitorFilter(),
                        false);

                elementWalker.DoTraverse(serviceContract);

                Assert.AreEqual(6, elementList.Count);

                t.Rollback();
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Does the validate.
        /// </summary>
        /// <param name="objectToValidate">The object to validate.</param>
        /// <param name="currentTarget">The current target.</param>
        /// <param name="key">The key.</param>
        /// <param name="validationResults">The validation results.</param>
        protected override void DoValidate(ModelBusReference objectToValidate, object currentTarget, string key, ValidationResults validationResults)
        {
            this.MessageTemplate = currentMessageTemplate;

            base.DoValidate(objectToValidate, currentTarget, key, validationResults);

            if (!validationResults.IsValid)
            {
                return;
            }

            ServiceReference serviceReference = currentTarget as ServiceReference;

            if (serviceReference == null)
            {
                return;
            }

            using (ModelBusReferenceResolver resolver = new ModelBusReferenceResolver())
            {
                ModelElement referencedElement = resolver.Resolve(objectToValidate);
                if (referencedElement != null)
                {
                    ServiceContractModel dcm = referencedElement.Store.ElementDirectory.FindElements <ServiceContractModel>()[0];
                    if (dcm.ImplementationTechnology == null ||
                        String.IsNullOrWhiteSpace(dcm.ProjectMappingTable) ||
                        !dcm.ImplementationTechnology.Name.Equals(GetItName(currentTarget), StringComparison.OrdinalIgnoreCase))
                    {
                        validationResults.AddResult(
                            new ValidationResult(String.Format(CultureInfo.CurrentUICulture, this.MessageTemplate, ValidatorUtility.GetTargetName(currentTarget)), currentTarget, key, String.Empty, this));
                    }
                }
            }
        }
Esempio n. 5
0
        public void TestWalkerFromServiceContractWithOperations()
        {
            List <ModelElement> elementList = new List <ModelElement>();

            using (Transaction t = ServiceContractStore.TransactionManager.BeginTransaction())
            {
                ServiceContractModel root            = CreateServiceContractRoot();
                ServiceContract      serviceContract = CreateServiceContract("Foo", "Foo");

                serviceContract.Operations.Add(CreateOperationContract("FooOP1"));
                serviceContract.Operations.Add(CreateOperationContract("FooOP2"));
                root.ServiceContracts.Add(serviceContract);

                FullDepthElementWalker elementWalker =
                    new FullDepthElementWalker(
                        new ModelElementVisitor(elementList),
                        new EmbeddingReferenceVisitorFilter(),
                        false);

                elementWalker.DoTraverse(serviceContract);

                Assert.AreEqual(3, elementList.Count);

                t.Rollback();
            }
        }
Esempio n. 6
0
        private string GetItName(object element)
        {
            if (element == null)
            {
                return(string.Empty);
            }

            ModelElement mel = element as ModelElement;

            if (mel != null)
            {
                if (!string.IsNullOrWhiteSpace(this.MessageTemplate))
                {
                    ServiceContractModel scModel = DomainModelHelper.GetElement <ServiceContractModel>(mel.Store);
                    if (scModel != null && scModel.ImplementationTechnology != null)
                    {
                        return(scModel.ImplementationTechnology.Name);
                    }
                    // try with Host
                    HostApplication hApp = DomainModelHelper.GetElement <HostApplication>(mel.Store);
                    if (hApp != null && hApp.ImplementationTechnology != null)
                    {
                        return(hApp.ImplementationTechnology.Name);
                    }
                }
            }
            return(string.Empty);
        }
        private string GetItName(object element)
        {
            if (element == null)
            {
                return(string.Empty);
            }

            ModelElement mel = element as ModelElement;

            if (mel != null)
            {
                // Try with DC model first
                if (!string.IsNullOrWhiteSpace(dcModelMessageTemplate))
                {
                    DataContractModel dcModel = DomainModelHelper.GetElement <DataContractModel>(mel.Store);
                    if (dcModel != null && dcModel.ImplementationTechnology != null)
                    {
                        return(dcModel.ImplementationTechnology.Name);
                    }
                }
                if (!string.IsNullOrWhiteSpace(dcModelMessageTemplate))
                {
                    ServiceContractModel scModel = DomainModelHelper.GetElement <ServiceContractModel>(mel.Store);
                    if (scModel != null && scModel.ImplementationTechnology != null)
                    {
                        return(scModel.ImplementationTechnology.Name);
                    }
                }
            }
            return(string.Empty);
        }
        public void TestInitialize()
        {
            serviceProvider = new MockMappingServiceProvider();

            #region Data Contract
            dcStore       = new Store(serviceProvider, typeof(CoreDesignSurfaceDomainModel), typeof(DataContractDslDomainModel));
            dcDomainModel = dcStore.GetDomainModel <DataContractDslDomainModel>();
            dcTransaction = dcStore.TransactionManager.BeginTransaction();
            dcModel       = (DataContractModel)dcDomainModel.CreateElement(new Partition(dcStore), typeof(DataContractModel), null);

            // Specify the Implementation Technology and PMT
            dcModel.ImplementationTechnology = new DataContractWcfExtensionProvider();
            dcModel.ProjectMappingTable      = projectMappingTableName;
            dc = dcStore.ElementFactory.CreateElement(DataContract.DomainClassId) as DataContract;
            primitiveDataElement      = dcStore.ElementFactory.CreateElement(PrimitiveDataType.DomainClassId) as PrimitiveDataType;
            primitiveDataElement.Name = primitiveDataElementName;
            #endregion

            #region Service Contract
            scStore       = new Store(serviceProvider, typeof(CoreDesignSurfaceDomainModel), typeof(ServiceContractDslDomainModel));
            scDomainModel = scStore.GetDomainModel <ServiceContractDslDomainModel>();
            scTransaction = scStore.TransactionManager.BeginTransaction();
            scModel       = (ServiceContractModel)scDomainModel.CreateElement(new Partition(scStore), typeof(ServiceContractModel), null);
            scModel.ImplementationTechnology = new ServiceContractWCFExtensionProvider();
            scModel.ProjectMappingTable      = projectMappingTableName;
            sc = scStore.ElementFactory.CreateElement(ServiceContract.DomainClassId) as ServiceContract;
            #endregion

            #region Validator
            // Initialize validator's config
            attributes = new NameValueCollection();
            attributes.Add("elementNameProperty", "Name");
            #endregion

            #region Simulate Model
            //Create the moniker
            //mel://[DSLNAMESPACE]\[MODELELEMENTTYPE]\[MODELELEMENT.GUID]@[PROJECT]\[MODELFILE]
            string requestMoniker = string.Format(@"mel://{0}\{1}\{2}@{3}\{4}",
                                                  primitiveDataElement.GetType().Namespace,
                                                  primitiveDataElement.GetType().Name,
                                                  primitiveDataElement.Id.ToString(),
                                                  dataContractModelProjectName, dataContractModelFileName);

            // Add a DC to the model
            dc.DataMembers.Add(primitiveDataElement);
            dcModel.Contracts.Add(dc);

            // Create a Fault that references the Data Contract
            fault      = scStore.ElementFactory.CreateElement(DataContractFault.DomainClassId) as DataContractFault;
            fault.Name = faultName;
            fault.Type = new MockModelBusReference(primitiveDataElement);

            // Create an Operation
            operation      = scStore.ElementFactory.CreateElement(Operation.DomainClassId) as Operation;
            operation.Name = operationContractName;
            operation.Faults.Add(fault);
            sc.Operations.Add(operation);

            #endregion
        }
Esempio n. 9
0
        private ServiceContractModel CreateServiceContractRoot()
        {
            ServiceContractModel serviceContractModel =
                new ServiceContractModel(ServiceContractStore);

            serviceContractModel.ProjectMappingTable = "WCF";

            return(serviceContractModel);
        }
Esempio n. 10
0
        public void TestWalkerFromMessageContractWithDataContractMessagePartsWithDataElements()
        {
            List <ModelElement> elementList = new List <ModelElement>();

            using (Transaction t = DataContractStore.TransactionManager.BeginTransaction())
            {
                DataContractModel dcRoot        = CreateDataContractRoot();
                DataContract      dataContract1 = CreateDataContract("FooDc");
                PrimitiveDataType element1      = CreatePrimitiveDataElement("FooElement1");
                PrimitiveDataType element2      = CreatePrimitiveDataElement("FooElement2");
                DataContract      dataContract2 = CreateDataContract("FooDc1");
                PrimitiveDataType element3      = CreatePrimitiveDataElement("FooElement1");
                PrimitiveDataType element4      = CreatePrimitiveDataElement("FooElement2");

                dataContract1.DataMembers.Add(element1);
                dataContract1.DataMembers.Add(element2);
                dataContract2.DataMembers.Add(element3);
                dataContract2.DataMembers.Add(element4);
                dcRoot.Contracts.Add(dataContract1);
                dcRoot.Contracts.Add(dataContract2);

                using (Transaction t1 = ServiceContractStore.TransactionManager.BeginTransaction())
                {
                    ServiceContractModel scRoot   = CreateServiceContractRoot();
                    Message request               = CreateMessageContract("FooMCReq", "FooMCReq");
                    DataContractMessagePart part1 =
                        CreateDataContractMessagePart(
                            "FooPart1",
                            GetMockMoniker(dataContract1));
                    DataContractMessagePart part2 =
                        CreateDataContractMessagePart(
                            "FooPart2",
                            GetMockMoniker(dataContract2));


                    request.MessageParts.Add(part1);
                    request.MessageParts.Add(part2);
                    scRoot.Messages.Add(request);

                    FullDepthElementWalker elementWalker =
                        new FullDepthElementWalker(
                            new ModelElementVisitor(elementList),
                            new EmbeddingReferenceVisitorFilter(),
                            false);

                    elementWalker.DoTraverse(request);

                    Assert.AreEqual(3, elementList.Count);                     // 9 elemsn with Resolver

                    t1.Rollback();
                }

                t.Rollback();
            }
        }
        protected override void DoValidate(IEnumerable <MessageBase> objectToValidate, object currentTarget, string key, Microsoft.Practices.EnterpriseLibrary.Validation.ValidationResults validationResults)
        {
            ServiceContractModel scm = currentTarget as ServiceContractModel;

            if (scm == null)
            {
                return;
            }

            if (scm.ImplementationTechnology != null &&
                !scm.ImplementationTechnology.Name.Equals(WCFExtension, StringComparison.OrdinalIgnoreCase) ||
                scm.SerializerType != SerializerType.XmlSerializer)
            {
                return;
            }

            List <PrimitiveMessagePart> parts = new List <PrimitiveMessagePart>();

            foreach (MessageBase message in objectToValidate)
            {
                if (message is XsdMessage)
                {
                    continue;
                }

                if (!GetIsWrapped(message))
                {
                    foreach (MessagePart part in message.MessageParts)
                    {
                        PrimitiveMessagePart primitivePart = part as PrimitiveMessagePart;
                        if (primitivePart != null)
                        {
                            if (parts.Count == 0)
                            {
                                parts.Add(primitivePart);
                            }
                            else
                            {
                                if (!IsValidPart(primitivePart, parts))
                                {
                                    validationResults.AddResult(
                                        new ValidationResult(this.MessageTemplate, objectToValidate, key, String.Empty, this)
                                        );
                                    return;
                                }
                            }
                        }
                    }
                }
            }
        }
        private ServiceContract CreateServiceContractModel()
        {
            scStore       = new Store(serviceProvider, typeof(CoreDesignSurfaceDomainModel), typeof(ServiceContractDslDomainModel));
            scDomainModel = scStore.GetDomainModel <ServiceContractDslDomainModel>();
            scTransaction = scStore.TransactionManager.BeginTransaction();

            scModel = (ServiceContractModel)scDomainModel.CreateElement(new Partition(scStore), typeof(ServiceContractModel), null);
            scModel.ImplementationTechnology = new ServiceContractWCFExtensionProvider();
            scModel.ProjectMappingTable      = projectMappingTableName;

            ServiceContract sc = scStore.ElementFactory.CreateElement(ServiceContract.DomainClassId) as ServiceContract;

            sc.Name = serviceContractName;

            scModel.ServiceContracts.Add(sc);
            return(sc);
        }
Esempio n. 13
0
        public void TestInitialize()
        {
            serviceProvider = new MockMappingServiceProvider();

            scStore       = new Store(serviceProvider, typeof(CoreDesignSurfaceDomainModel), typeof(ServiceContractDslDomainModel));
            scDomainModel = scStore.GetDomainModel <ServiceContractDslDomainModel>();
            scTransaction = scStore.TransactionManager.BeginTransaction();

            scModel = (ServiceContractModel)scDomainModel.CreateElement(new Partition(scStore), typeof(ServiceContractModel), null);
            scModel.ImplementationTechnology = new ServiceContractWCFExtensionProvider();
            scModel.ProjectMappingTable      = projectMappingTableName;

            ServiceContract sc = scStore.ElementFactory.CreateElement(ServiceContract.DomainClassId) as ServiceContract;

            sc.Name = serviceContractName;

            scModel.ServiceContracts.Add(sc);

            hdStore       = new Store(serviceProvider, typeof(CoreDesignSurfaceDomainModel), typeof(HostDesignerDomainModel));
            hdDomainModel = hdStore.GetDomainModel <HostDesignerDomainModel>();
            hdTransaction = hdStore.TransactionManager.BeginTransaction();
            hdModel       = (HostDesignerModel)hdDomainModel.CreateElement(new Partition(hdStore), typeof(HostDesignerModel), null);

            HostApplication app = (HostApplication)hdStore.ElementFactory.CreateElement(HostApplication.DomainClassId);

            app.ImplementationTechnology = new HostDesignerWcfExtensionProvider();

            reference = (ServiceReference)hdStore.ElementFactory.CreateElement(ServiceReference.DomainClassId);

            //mel://[DSLNAMESPACE]\[MODELELEMENTTYPE]\[MODELELEMENT.GUID]@[PROJECT]\[MODELFILE]
            string serviceMoniker = string.Format(@"mel://{0}\{1}\{2}@{3}\{4}",
                                                  sc.GetType().Namespace,
                                                  serviceContractName,
                                                  sc.Id.ToString(),
                                                  serviceContractModelProjectName, serviceContractModelFileName);

            reference.Name = serviceMelReferenceName;
            reference.ServiceImplementationType = new MockModelBusReference(sc);

            app.ServiceDescriptions.Add(reference);

            // Initialize validator's config
            attributes = new NameValueCollection();
            attributes.Add("elementNameProperty", "Name");
        }
        public void TestInitialize()
        {
            serviceProvider = new MockMappingServiceProvider();

            attributes = new NameValueCollection();
            attributes.Add("elementNameProperty", "Name");

            #region Data Contract
            dcStore       = new Store(serviceProvider, typeof(CoreDesignSurfaceDomainModel), typeof(DataContractDslDomainModel));
            dcDomainModel = dcStore.GetDomainModel <DataContractDslDomainModel>();
            dcTransaction = dcStore.TransactionManager.BeginTransaction();
            dcModel       = (DataContractModel)dcDomainModel.CreateElement(new Partition(dcStore), typeof(DataContractModel), null);
            dcModel.ProjectMappingTable = projectMappingTableName;
            dc = dcStore.ElementFactory.CreateElement(DataContract.DomainClassId) as DataContract;
            primitiveDataElement      = dcStore.ElementFactory.CreateElement(PrimitiveDataType.DomainClassId) as PrimitiveDataType;
            primitiveDataElement.Name = primitiveDataElementName;
            dc.DataMembers.Add(primitiveDataElement);
            dcModel.Contracts.Add(dc);
            #endregion

            #region Service Contract
            scStore       = new Store(serviceProvider, typeof(CoreDesignSurfaceDomainModel), typeof(ServiceContractDslDomainModel));
            scDomainModel = scStore.GetDomainModel <ServiceContractDslDomainModel>();
            scTransaction = scStore.TransactionManager.BeginTransaction();
            scModel       = (ServiceContractModel)scDomainModel.CreateElement(new Partition(scStore), typeof(ServiceContractModel), null);
            scModel.ProjectMappingTable = projectMappingTableName;
            msg      = scStore.ElementFactory.CreateElement(Message.DomainClassId) as Message;
            msg.Name = messageName;

            //Create the moniker
            //mel://[DSLNAMESPACE]\[MODELELEMENTTYPE]\[MODELELEMENT.GUID]@[PROJECT]\[MODELFILE]
            string requestMoniker = string.Format(@"mel://{0}\{1}\{2}@{3}\{4}",
                                                  primitiveDataElement.GetType().Namespace,
                                                  primitiveDataElement.GetType().Name,
                                                  primitiveDataElement.Id.ToString(),
                                                  dataContractModelProjectName, dataContractModelFileName);

            part      = scStore.ElementFactory.CreateElement(DataContractMessagePart.DomainClassId) as DataContractMessagePart;
            part.Name = partName;
            part.Type = new MockModelBusReference(primitiveDataElement);

            msg.MessageParts.Add(part);
            scModel.Messages.Add(msg);
            #endregion
        }
Esempio n. 15
0
        public async Task <IActionResult> Add()
        {
            var model = new ServiceContractModel();

            var categories = await _workOrderService.GetClientCategories((int)_workContext.CurrentCustomer.ClientId);


            model.AvailableCategories.Add(new SelectListItem {
                Text = "Select Category", Value = "0"
            });
            foreach (var item in categories)
            {
                model.AvailableCategories.Add(new SelectListItem {
                    Text = item.Category, Value = item.Category
                });
            }

            return(View(model));
        }
Esempio n. 16
0
        public void TestInitialize()
        {
            serviceProvider = new MockMappingServiceProvider();

            attributes = new NameValueCollection();
            attributes.Add("elementNameProperty", "Name");

            #region Data Contract
            dcStore       = new Store(serviceProvider, typeof(CoreDesignSurfaceDomainModel), typeof(DataContractDslDomainModel));
            dcDomainModel = dcStore.GetDomainModel <DataContractDslDomainModel>();
            dcTransaction = dcStore.TransactionManager.BeginTransaction();
            dcModel       = (DataContractModel)dcDomainModel.CreateElement(new Partition(dcStore), typeof(DataContractModel), null);
            dcModel.ProjectMappingTable = projectMappingTableName;
            fc      = dcStore.ElementFactory.CreateElement(FaultContract.DomainClassId) as FaultContract;
            fc.Name = faultContractName;
            dcModel.Contracts.Add(fc);
            #endregion

            #region Service Contract
            scStore       = new Store(serviceProvider, typeof(CoreDesignSurfaceDomainModel), typeof(ServiceContractDslDomainModel));
            scDomainModel = scStore.GetDomainModel <ServiceContractDslDomainModel>();
            scTransaction = scStore.TransactionManager.BeginTransaction();
            scModel       = (ServiceContractModel)scDomainModel.CreateElement(new Partition(scStore), typeof(ServiceContractModel), null);
            scModel.ProjectMappingTable = projectMappingTableName;
            operation      = scStore.ElementFactory.CreateElement(Operation.DomainClassId) as Operation;
            operation.Name = operationName;

            //Create the moniker
            //mel://[DSLNAMESPACE]\[MODELELEMENTTYPE]\[MODELELEMENT.GUID]@[PROJECT]\[MODELFILE]
            string requestMoniker = string.Format(@"mel://{0}\{1}\{2}@{3}\{4}",
                                                  fc.GetType().Namespace,
                                                  fc.GetType().Name,
                                                  fc.Id.ToString(),
                                                  dataContractModelProjectName, dataContractModelFileName);

            dcfault      = scStore.ElementFactory.CreateElement(DataContractFault.DomainClassId) as DataContractFault;
            dcfault.Name = dcfaultName;
            dcfault.Type = new MockModelBusReference(fc);

            operation.Faults.Add(dcfault);
            scModel.Operations.Add(operation);
            #endregion
        }
Esempio n. 17
0
        public void TestWalkerFromMessageContractWithDataContractCollectionMessagePart()
        {
            List <ModelElement> elementList = new List <ModelElement>();

            using (Transaction t = DataContractStore.TransactionManager.BeginTransaction())
            {
                DataContractModel      dcRoot                 = CreateDataContractRoot();
                DataContract           dataContract           = CreateDataContract("FooDc");
                DataContractCollection dataContractCollection = CreateDataContractCollection("FooDcc");
                dataContractCollection.DataContract = dataContract;

                dcRoot.Contracts.Add(dataContract);
                dcRoot.Contracts.Add(dataContractCollection);

                using (Transaction t1 = ServiceContractStore.TransactionManager.BeginTransaction())
                {
                    ServiceContractModel scRoot   = CreateServiceContractRoot();
                    Message request               = CreateMessageContract("FooMCReq", "FooMCReq");
                    DataContractMessagePart part1 =
                        CreateDataContractMessagePart(
                            "FooPart1",
                            GetMockMoniker(dataContract));

                    request.MessageParts.Add(part1);
                    scRoot.Messages.Add(request);

                    FullDepthElementWalker elementWalker =
                        new FullDepthElementWalker(
                            new ModelElementVisitor(elementList),
                            new EmbeddingReferenceVisitorFilter(),
                            false);

                    elementWalker.DoTraverse(request);

                    Assert.AreEqual(2, elementList.Count);                     // 4 elemsn with Resolver

                    t1.Rollback();
                }

                t.Rollback();
            }
        }
Esempio n. 18
0
        public void TestWalkerFromDomainModel()
        {
            List <ModelElement> elementList = new List <ModelElement>();

            using (Transaction t = ServiceContractStore.TransactionManager.BeginTransaction())
            {
                ServiceContractModel root = CreateServiceContractRoot();

                FullDepthElementWalker elementWalker =
                    new FullDepthElementWalker(
                        new ModelElementVisitor(elementList),
                        new EmbeddingReferenceVisitorFilter(),
                        false);

                elementWalker.DoTraverse(root);

                Assert.AreEqual(1, elementList.Count);

                t.Rollback();
            }
        }
Esempio n. 19
0
        public async Task <IActionResult> Edit(ServiceContractModel model)
        {
            if (ModelState.IsValid)
            {
                var serviceObj = _mapper.Map <ServiceContracts>(model);
                var result     = await _serviceContractModelService.UpdateServiceContract(serviceObj);

                if (result)
                {
                    SuccessNotification("The contract data has been updated successfully.");
                    return(RedirectToAction("Edit", "ServiceContracts",
                                            new { Scid = model.Scid }));
                }
                else
                {
                    ModelState.AddModelError("", "Something went wrong while updating record");
                }
            }

            return(View(model));
        }
Esempio n. 20
0
        public void ReturnSuccessForValidCollection()
        {
            Store     store     = new Store(new MockServiceProvider(), typeof(CoreDesignSurfaceDomainModel), typeof(ServiceContractDslDomainModel));
            Partition partition = new Partition(store);

            using (Transaction t = store.TransactionManager.BeginTransaction())
            {
                ServiceContractModel serviceContractModel = new ServiceContractModel(store);
                ServiceContract      sc = new ServiceContract(store);

                sc.Operations.Add(new Operation(store));
                serviceContractModel.ServiceContracts.Add(sc);

                NotEmptyOperationCollectionValidator validator = new NotEmptyOperationCollectionValidator();
                ValidationResults validationResults            = validator.Validate(sc.Operations);

                Assert.IsTrue(validationResults.IsValid);

                t.Rollback();
            }
        }
        public void ReturnSuccessForValidSerializer3()
        {
            Store     store     = new Store(new MockServiceProvider(), typeof(CoreDesignSurfaceDomainModel), typeof(ServiceContractDslDomainModel));
            Partition partition = new Partition(store);

            using (Transaction t = store.TransactionManager.BeginTransaction())
            {
                ServiceContractModel serviceContractModel = new ServiceContractModel(store);

                serviceContractModel.ImplementationTechnology = new ServiceContractAsmxExtensionProvider();
                serviceContractModel.SerializerType           = SerializerType.XmlSerializer;

                ValidationResults validationResults = new ValidationResults();
                TestImplementationTechnologyAndSerializerValidator validator = new TestImplementationTechnologyAndSerializerValidator();
                validator.TestDoValidate(serviceContractModel.SerializerType, serviceContractModel, null, validationResults);

                Assert.IsTrue(validationResults.IsValid);

                t.Rollback();
            }
        }
Esempio n. 22
0
        public async Task <IActionResult> Add(ServiceContractModel model)
        {
            if (ModelState.IsValid)
            {
                var scObj = _mapper.Map <ServiceContracts>(model);
                scObj.ClientId = (int)_workContext.CurrentCustomer.ClientId;

                var result = await _serviceContractModelService.InsertServiceContract(scObj);

                if (result)
                {
                    SuccessNotification("The contract data has been saved successfully.");
                    return(RedirectToAction("Add"));
                }
                else
                {
                    ModelState.AddModelError("", "Something went wrong while saving new contract record");
                }
            }

            return(View(model));
        }
        /// <summary>
        /// Does the validate.
        /// </summary>
        /// <param name="objectToValidate">The object to validate.</param>
        /// <param name="currentTarget">The current target.</param>
        /// <param name="key">The key.</param>
        /// <param name="validationResults">The validation results.</param>
        protected override void DoValidate(ModelBusReference objectToValidate, object currentTarget, string key, ValidationResults validationResults)
        {
            base.DoValidate(objectToValidate, currentTarget, key, validationResults);

            if (!validationResults.IsValid)
            {
                return;
            }

            ServiceReference serviceReference = currentTarget as ServiceReference;

            if (serviceReference == null)
            {
                return;
            }

            using (ModelBusReferenceResolver resolver = new ModelBusReferenceResolver())
            {
                ModelElement referencedElement = resolver.Resolve(objectToValidate);
                if (referencedElement != null)
                {
                    ServiceContractModel scm = DomainModelHelper.GetElement <ServiceContractModel>(referencedElement.Store);
                    if (scm != null && scm.ImplementationTechnology != null)
                    {
                        if (serviceReference.HostApplication.ImplementationTechnology != null &&
                            !serviceReference.HostApplication.ImplementationTechnology.Name.Equals(
                                scm.ImplementationTechnology.Name))
                        {
                            this.LogValidationResult(
                                validationResults,
                                string.Format(CultureInfo.CurrentCulture, this.MessageTemplate, serviceReference.Name),
                                currentTarget,
                                key);
                        }
                    }
                }
            }
        }
        private ServiceContract CreateServiceContract(
            ServiceContractModel model, string serviceContractName, string operationName, string requestName, string responseName)
        {
            ServiceContract serviceContract = new ServiceContract(Store);

            serviceContract.ServiceContractModel = model;
            serviceContract.Name = serviceContractName;
            WCFServiceContract serviceContractExtender = new WCFServiceContract();

            serviceContractExtender.ModelElement = serviceContract;
            serviceContract.ObjectExtender       = serviceContractExtender;

            Operation            op1    = new Operation(Store);
            WCFOperationContract wcfOp1 = new WCFOperationContract();

            op1.ObjectExtender  = wcfOp1;
            op1.Name            = operationName;
            op1.Action          = operationName;
            op1.Request         = string.IsNullOrEmpty(requestName) ? null : CreateMessageContract(requestName);
            op1.Response        = string.IsNullOrEmpty(responseName) ? null : CreateMessageContract(responseName);
            op1.ServiceContract = serviceContract;

            return(serviceContract);
        }
        /// <summary>
        /// Does the validate.
        /// </summary>
        /// <param name="objectToValidate">The object to validate.</param>
        /// <param name="currentTarget">The current target.</param>
        /// <param name="key">The key.</param>
        /// <param name="validationResults">The validation results.</param>
        protected override void DoValidate(SerializerType objectToValidate, object currentTarget, string key, ValidationResults validationResults)
        {
            if (!validationResults.IsValid)
            {
                return;
            }

            ServiceContractModel serviceContractModel = currentTarget as ServiceContractModel;

            if (serviceContractModel != null)
            {
                if (IsASMX(serviceContractModel.ImplementationTechnology.Name))
                {
                    if (objectToValidate.Equals(SerializerType.DataContractSerializer))
                    {
                        this.LogValidationResult(
                            validationResults,
                            string.Format(CultureInfo.CurrentCulture, this.MessageTemplate),
                            currentTarget,
                            key);
                    }
                }
            }
        }
 private ServiceContract CreateServiceContract(
     ServiceContractModel model, string serviceContractName, string operationName)
 {
     return(CreateServiceContract(model, serviceContractName, operationName, RequestName, ResponseName));
 }