public void TestFaultMessagesGeneration() { ProjectMappingManagerSetup.InitializeManager(ServiceProvider, "ProjectMapping.ServiceContractDsl.Tests.xml"); ServiceContract rootElement = CreateRoot(ServiceContractElementName, ServiceContractElementNamespace); Operation op1 = new Operation(Store); op1.ObjectExtender = new WCFOperationContract(); op1.Name = "op1"; op1.Action = "op1"; op1.ServiceContract = rootElement; DataContractFault fault1 = new DataContractFault(Store); fault1.Name = "fault1"; //fault1.Type = @"[DSLNAMESPACE]\[MODELELEMENTTYPE]\fault1Type@[PROJECT]\[MODELFILE]"; fault1.Operation = op1; DataContractFault fault2 = new DataContractFault(Store); fault2.Name = "fault2"; //fault2.Type = @"[DSLNAMESPACE]\[MODELELEMENTTYPE]\fault2Type@[PROJECT]\[MODELFILE]"; ; fault2.Operation = op1; processFault = true; ResolveModelElement(fault1.Name); ResolveModelElement(fault2.Name); string content = RunTemplateWithDIS(rootElement); StringAssert.Contains(content, "I" + ServiceContractElementName); StringAssert.Contains(content, ServiceContractElementNamespace); }
public void TestSoapDocumentMethodAttributeParanmeters() { ProjectMappingManagerSetup.InitializeManager(ServiceProvider, "ProjectMapping.ServiceContractDsl.Tests.xml"); ServiceContract rootElement = CreateRoot(ServiceContractElementName, ServiceContractElementNamespace); rootElement.ServiceContractModel.ImplementationTechnology = new ServiceContractAsmxExtensionProvider(); rootElement.ServiceContractModel.SerializerType = SerializerType.XmlSerializer; Operation op1 = new Operation(Store); op1.ObjectExtender = new AsmxOperationContract(); op1.Name = "op1"; op1.Action = "op1"; op1.ServiceContract = rootElement; string content = RunTemplate(rootElement); EnsureType(ref content, "MyType"); Type generatedType = CompileAndGetType(content); MethodInfo method = TypeAsserter.AssertMethod(op1.Name, generatedType); SoapDocumentMethodAttribute soapAttr = TypeAsserter.AssertAttribute <SoapDocumentMethodAttribute>(method); Assert.AreEqual(soapAttr.ParameterStyle, SoapParameterStyle.Wrapped); Assert.AreEqual <string>(soapAttr.Action, rootElement.Namespace + "/" + op1.Action); }
private void GoToCourt() { CourtClient client = new CourtClient("BasicHttpBinding_ICourt"); ServiceContract contract = new ServiceContract(); contract.CustomerName = GetName(); contract.TotalPartCost = MyAgreement.TotalPartCost; contract.TotalServicesCost = MyAgreement.TotalServicesCost; contract.Total = MyAgreement.GetTotal(); var decision = client.MakeDecision(contract); client.Close(); if (decision == -1) { GoToRepairShop(true); } if (decision == 0) { ShopManager.PayWarrantyCompensation(MyAgreement.TotalServicesCost - (MyDiscounts.GetDiscountRate() * MyAgreement.TotalServicesCost / 100)); } if (decision == 1) { ShopManager.AcceptPayment(1000); } RepairAutomationTool.RemoveDisappointedCustomer(this); }
public static async Task DistributeCall(RawRequestEnvelope requestEnvelope, ILogger log) { try { InternalContract.RequireNotNull(Startup.AsyncCallerServiceConfiguration, nameof(Startup.AsyncCallerServiceConfiguration), $"Missing {nameof(Startup.AsyncCallerServiceConfiguration)}. Please check your Nexus configuration for this function app."); // Client tenant is found in the request envelope var clientTenant = new Tenant(requestEnvelope.Organization, requestEnvelope.Environment); ServiceContract.RequireValidated(clientTenant, nameof(clientTenant)); FulcrumApplication.Context.ClientTenant = clientTenant; // Setup the tenants AC configuration (cache and refresh is handled by LeverServiceConfiguration) var clientConfig = await Startup.AsyncCallerServiceConfiguration.GetConfigurationForAsync(clientTenant); FulcrumApplication.Context.LeverConfiguration = clientConfig; // Distribute the request. RequestHandler will put back on queue if necessary, and also handle callbacks var handler = new RequestHandler(HttpSender, clientTenant, FulcrumApplication.Context.LeverConfiguration, requestEnvelope); await handler.ProcessOneRequestAsync(); } catch (Exception e) { const string errorMessage = "Failed to distribute request. (Code location 5ADA0B3E-2344-4977-922B-F7BB870EA065)"; log.LogError(e, errorMessage); Log.LogError(errorMessage, e); throw; } }
public void DoValidateCollectionItemSucceedsForUniqueNamedElements() { Store store = new Store(typeof(CoreDesignSurfaceDomainModel), typeof(ServiceContractDslDomainModel)); ServiceContractModel model; using (Transaction transaction = store.TransactionManager.BeginTransaction()) { model = store.ElementFactory.CreateElement(ServiceContractModel.DomainClassId) as ServiceContractModel; ServiceContract contract = store.ElementFactory.CreateElement(ServiceContract.DomainClassId) as ServiceContract; contract.Name = "Contract Name"; Operation part = store.ElementFactory.CreateElement(Operation.DomainClassId) as Operation; part.Name = "Part Name"; contract.Operations.Add(part); TestableOperationElementCollectionValidator target = new TestableOperationElementCollectionValidator(); ValidationResults results = new ValidationResults(); target.TestDoValidateCollectionItem(part, contract, String.Empty, results); Assert.IsTrue(results.IsValid); transaction.Commit(); } }
public async Task Update(string id, User user) { ServiceContract.RequireNotNullOrWhitespace(id, nameof(id)); ServiceContract.RequireValidated(user, nameof(user)); //TODO: Tutorial 3 - Publish an event here await _persistance.UpdateAsync(user.Id, user); }
public async Task <string> Create([FromBody] User user) { ServiceContract.RequireNotNull(user, nameof(user)); ServiceContract.RequireValidated(user, nameof(user)); return(await _persistance.CreateAsync(user)); }
public async Task PublishAsync(Guid id, JObject content) { ServiceContract.RequireNotNull(id, nameof(id)); ServiceContract.RequireNotDefaultValue(id, nameof(id)); await new BusinessEvents(BusinessEventsBaseUrl, _tenant, _tokenRefresher.GetServiceClient()).PublishAsync(id, content); }
public async Task SeedAsync(CancellationToken token = new CancellationToken()) { ServiceContract.Require(!FulcrumApplication.IsInProductionOrProductionSimulation, "This method can\'t be called in production."); var taskList = new List <Task>(); // Add some applicants var task = _capability.ApplicantService.CreateAsync(new Applicant { Name = "Johnny B. Goode" }, token); taskList.Add(task); task = _capability.ApplicantService.CreateAsync(new Applicant { Name = "Bad Cousin" }, token); taskList.Add(task); task = _capability.ApplicantService.CreateAsync(new Applicant { Name = "Willy Nilly" }, token); taskList.Add(task); await Task.WhenAll(taskList); // Add some approved members var id = await _capability.ApplicantService.CreateAsync(new Applicant { Name = "Donald Duck" }, token); await _capability.ApplicantService.ApproveAsync(id, token); id = await _capability.ApplicantService.CreateAsync(new Applicant { Name = "Mickey Mouse" }, token); await _capability.ApplicantService.ApproveAsync(id, token); }
public string BuildRdsn(Type service, QueryContext[] contexts) { //_stages = stages; _contexts = contexts; _appClassName = service.Name; //BuildInputOutputValueTypes(); BuildHeaderRdsn(service.Namespace); BuildRewrittenTypes(); _builder.AppendLine("public class " + _appClassName + "Server_impl :" + _appClassName + "Server"); _builder.BeginBlock(); BuildServiceClientsRdsn(); //thrift or protobuf BuildServiceCallsRdsn(_appClassName); foreach (var c in contexts) { //never change BuildQueryRdsn(c); } //always thrift BuildServer(_appClassName, ServiceContract.GetServiceCalls(service)); _builder.EndBlock(); BuildMain(); BuildFooter(); return(_builder.ToString()); }
public async Task ResetAsync(CancellationToken token = new CancellationToken()) { ServiceContract.Require(!FulcrumApplication.IsInProductionOrProductionSimulation, "This method can\'t be called in production."); var t1 = _capability.MemberService.DeleteAllAsync(token); var t2 = _capability.ApplicantService.DeleteAllAsync(token); await Task.WhenAll(t1, t2); }
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 }
public IHttpActionResult PutServiceContract(int id, ServiceContract serviceContract) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != serviceContract.Id) { return(BadRequest()); } db.Entry(serviceContract).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ServiceContractExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public void ShouldGenerateKnownTypeAttributeWithXsdExtendedTypes() { ProjectMappingManagerSetup.InitializeManager(ServiceProvider, "ProjectMapping.ServiceContractDsl.Tests.xml"); ServiceContract rootElement = CreateRoot(ServiceContractElementName, ServiceContractElementNamespace); rootElement.ServiceContractModel.ImplementationTechnology = new ServiceContractWCFExtensionProvider(); rootElement.ServiceContractModel.SerializerType = Microsoft.Practices.ServiceFactory.ServiceContracts.SerializerType.DataContractSerializer; Operation op1 = new Operation(Store); op1.ObjectExtender = new WCFOperationContract(); op1.Name = "op1"; op1.Action = "op1"; op1.ServiceContract = rootElement; XsdMessage request = new XsdMessage(Store); request.Name = "Request1"; request.Element = @"xsd://SampleData/BaseTypes.xsd?LandmarkPoint"; request.ServiceContractModel = rootElement.ServiceContractModel; WCFXsdMessageContract wcfXsdMc = new WCFXsdMessageContract(); wcfXsdMc.ModelElement = request; request.ObjectExtender = wcfXsdMc; op1.Request = request; string content = RunTemplate(rootElement); EnsureType(ref content, "Request1"); EnsureType(ref content, "LandmarkBase"); Type generatedType = CompileAndGetType(content); MethodInfo method = TypeAsserter.AssertMethod(op1.Name, generatedType); ServiceKnownTypeAttribute attribute = TypeAsserter.AssertAttribute <ServiceKnownTypeAttribute>(method); Assert.AreEqual <string>("LandmarkBase", attribute.Type.Name); }
private void CreateHostDesignerModel(ServiceContract 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); }
public void TestAsyncOperationGeneration() { ProjectMappingManagerSetup.InitializeManager(ServiceProvider, "ProjectMapping.ServiceContractDsl.Tests.xml"); ServiceContract rootElement = CreateRoot(ServiceContractElementName, ServiceContractElementNamespace); Operation op1 = new Operation(Store); WCFOperationContract wfcOperationContract = new WCFOperationContract(); wfcOperationContract.AsyncPattern = true; op1.ObjectExtender = wfcOperationContract; op1.Name = "op1"; op1.Action = "op1"; op1.ServiceContract = rootElement; string content = RunTemplate(rootElement); Type generatedType = CompileAndGetType(content); MethodInfo beginMethod = TypeAsserter.AssertMethod("Begin" + op1.Name, generatedType); Assert.AreEqual <int>(2, beginMethod.GetParameters().Length); Assert.AreEqual <string>("IAsyncResult", beginMethod.ReturnType.Name); MethodInfo endMethod = TypeAsserter.AssertMethod("End" + op1.Name, generatedType); Assert.AreEqual <int>(1, endMethod.GetParameters().Length); Assert.AreEqual <string>("Void", endMethod.ReturnType.Name); }
public void TestRequestGeneration() { ProjectMappingManagerSetup.InitializeManager(ServiceProvider, "ProjectMapping.ServiceContractDsl.Tests.xml"); ServiceContract rootElement = CreateRoot(ServiceContractElementName, ServiceContractElementNamespace); Operation op1 = new Operation(Store); op1.ObjectExtender = new WCFOperationContract(); op1.Name = "op1"; op1.Action = "op1"; op1.ServiceContract = rootElement; Message request = new Message(Store); request.Name = "Request1"; op1.Request = request; string content = RunTemplate(rootElement); EnsureType(ref content, "Request1"); Type generatedType = CompileAndGetType(content); MethodInfo method = TypeAsserter.AssertMethod(op1.Name, generatedType); Assert.AreEqual <int>(1, method.GetParameters().Length); Assert.AreEqual <string>("Request1", ((ParameterInfo)method.GetParameters().GetValue(0)).ParameterType.Name); Assert.AreEqual <string>("Void", method.ReturnType.Name); }
public void TestOperationGeneration() { ProjectMappingManagerSetup.InitializeManager(ServiceProvider, "ProjectMapping.ServiceContractDsl.Tests.xml"); ServiceContract rootElement = CreateRoot(ServiceContractElementName, ServiceContractElementNamespace); Operation op1 = new Operation(Store); op1.ObjectExtender = new WCFOperationContract(); op1.Name = "op1"; op1.Action = "op1"; op1.ServiceContract = rootElement; string content = RunTemplate(rootElement); Type generatedType = CompileAndGetType(content); MethodInfo method = TypeAsserter.AssertMethod(op1.Name, generatedType); Assert.AreEqual <int>(0, method.GetParameters().Length); Assert.AreEqual <string>("Void", method.ReturnType.Name); OperationContractAttribute operation = TypeAsserter.AssertAttribute <OperationContractAttribute>(method); Assert.AreEqual <string>(op1.Action, operation.Action); Assert.IsNull(operation.Name); Assert.AreEqual <bool>(op1.IsOneWay, operation.IsOneWay); Assert.AreEqual <bool>(((WCFOperationContract)op1.ObjectExtender).IsTerminating, operation.IsTerminating); Assert.AreEqual <bool>(((WCFOperationContract)op1.ObjectExtender).IsInitiating, operation.IsInitiating); Assert.AreEqual <ProtectionLevel>(((WCFOperationContract)op1.ObjectExtender).ProtectionLevel, operation.ProtectionLevel); Assert.IsNull(operation.ReplyAction); Assert.IsTrue(operation.HasProtectionLevel); }
public void ShouldGetActionValueWithDefaultUriSlashEnded() { ProjectMappingManagerSetup.InitializeManager(ServiceProvider, "ProjectMapping.ServiceContractDsl.Tests.xml"); ServiceContract rootElement = CreateRoot(ServiceContractElementName, ServiceContractElementNamespace + "/"); Operation op1 = new Operation(Store); op1.ServiceContract = rootElement; op1.ObjectExtender = new WCFOperationContract(); op1.Name = "op1"; // commit the tx and trigger the OperationAddRule so the action value will be filled with the default value this.transaction.Commit(); this.transaction = Store.TransactionManager.BeginTransaction(); op1.Name = "op2"; this.transaction.Commit(); this.transaction = null; string content = RunTemplate(rootElement); Type generatedType = CompileAndGetType(content); MethodInfo method = TypeAsserter.AssertMethod(op1.Name, generatedType); OperationContractAttribute operation = TypeAsserter.AssertAttribute <OperationContractAttribute>(method); Assert.AreEqual <string>(rootElement.Namespace + rootElement.Name + "/op2", operation.Action); }
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(); } }
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(); } }
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(); } }
public void NullParameterNameIsOkWhenThereIsACustomMessage() { var value = "A"; // ReSharper disable once ExpressionIsAlwaysNull ServiceContract.RequireAreEqual(value, value, null, "This assertion has a custom message, so null parameter name is OK"); }
public virtual async Task CreateWithSpecifiedIdAsync(string id, Invoice item, CancellationToken token = default(CancellationToken)) { ServiceContract.RequireNotNullOrWhiteSpace(id, nameof(id)); ServiceContract.RequireNotNull(item, nameof(item)); ServiceContract.RequireValidated(item, nameof(item)); await CrudController.CreateWithSpecifiedIdAsync(id, item, token); }
private static void ValidateServiceType(Type serviceType) { if (ServiceContract.IsNativeGrpcService(serviceType)) { throw new InvalidOperationException("{0} is native grpc service.".FormatWith(serviceType.FullName)); } }
/// <summary> /// /// </summary> /// <param name="entity"></param> /// <returns></returns> protected override IDictionary <string, object> Convert(ServiceContract entity) { var sqlParams = base.Convert(entity); sqlParams["TotalFee"] = (int)(entity.TotalFee * JXBC.TradeSystem.ModuleEnvironment.DBCurrencyUnit); return(sqlParams); }
public IServiceEndpointBinder <TService> GenerateServiceEndpointBinder <TService>(Type?serviceInstanceType) { if (serviceInstanceType != null && !ServiceContract.IsServiceInstanceType(serviceInstanceType)) { throw new ArgumentOutOfRangeException(nameof(serviceInstanceType)); } var serviceType = typeof(TService); ContractDescription description; Type contractType; Type channelType; lock (ProxyAssembly.SyncRoot) { (description, contractType) = GenerateContract(serviceType); channelType = ProxyAssembly.DefaultModule.GetType(ContractDescription.GetEndpointClassName(serviceType), false, false) !; if (channelType == null) { var serviceBuilder = new EmitServiceEndpointBuilder(description); channelType = serviceBuilder.Build(ProxyAssembly.DefaultModule, Logger); } } return(new EmitServiceEndpointBinder <TService>(description, serviceInstanceType, contractType, channelType, Logger)); }
public async Task <Person> FindFirstOrDefaultByNameAsync(string name, CancellationToken token = default(CancellationToken)) { ServiceContract.RequireNotNullOrWhitespace(name, nameof(name)); var result = await _gdprCapability.PersonService.FindFirstOrDefaultByNameAsync(name, token); return(result); }
public void OnServiceMethodDiscovery(ServiceMethodProviderContext <TService> context) { var serviceType = typeof(TService); if (ServiceContract.IsNativeGrpcService(serviceType)) { if (_logger.IsEnabled(LogLevel.Debug)) { _logger.LogDebug("Ignore service {0} binding: native grpc service.", serviceType.FullName); } return; } var filterContext = new ServiceMethodFilterRegistration(_serviceProvider); filterContext.Add(_rootConfiguration.GetFilters()); filterContext.Add(_serviceConfiguration.GetFilters()); var marshallerFactory = (_serviceConfiguration.MarshallerFactory ?? _rootConfiguration.DefaultMarshallerFactory).ThisOrDefault(); var serviceBinder = new AspNetCoreServiceMethodBinder <TService>( context, marshallerFactory, filterContext, _rootConfiguration.IsApiDescriptionRequested); CreateEndpointBinder().Bind(serviceBinder); }
/// <summary> /// Finds the operation from contract. /// </summary> /// <param name="contract">The contract.</param> /// <returns></returns> public Operation FindOperationFromContract(ServiceContract contract) { if (contract == null) { return(null); } return(contract.Operations.Find(delegate(Operation o) { if (o.Name == Name) { int i = 0; foreach (CodeParameter arg in _codeElement.Parameters) { if (i >= o.Arguments.Count || o.Arguments[i].Name != arg.Name) { return false; } i++; } return true; } return false; })); }
//Create the MessageTypeMappings for this contract private void CreateMessageTypeMappings(ServiceContract item) { MessageTypeMapping mtm; IDictionaryEnumerator enumerator = this.MessageTypeMappings.GetEnumerator(); while (enumerator.MoveNext()) { if (!item.MessageTypeMappings.Contains(enumerator.Key.ToString())) { mtm = new MessageTypeMapping(item, enumerator.Key.ToString()); mtm.MessageSource = (MessageSource)enumerator.Value; item.MessageTypeMappings.Add(mtm); } } }
public void Create() { //Create Contract ServiceContract serviceContract = null; if (!this.ServiceBroker.ServiceContracts.Contains(this.FullName)) { // Create service contract serviceContract = new ServiceContract( this.ServiceBroker, this.FullName); CreateMessageTypeMappings(serviceContract); serviceContract.Create(); } }
public static ServiceContract CreateServiceContract(int ID, string contractReference, string contractName, global::System.DateTime startDate, global::System.DateTime endDate, bool currentContract, byte[] rowVersion) { ServiceContract serviceContract = new ServiceContract(); serviceContract.Id = ID; serviceContract.ContractReference = contractReference; serviceContract.ContractName = contractName; serviceContract.StartDate = startDate; serviceContract.EndDate = endDate; serviceContract.CurrentContract = currentContract; serviceContract.RowVersion = rowVersion; return serviceContract; }
public void AddToServiceContracts(ServiceContract serviceContract) { base.AddObject("ServiceContracts", serviceContract); }
public override void Visit(ServiceContract node) { this.action(node); }
public override void ExplicitVisit(ServiceContract fragment) { _fragments.Add(fragment); }
int UpDateSsb() { updatedobj = null; //if (!isDirty) //return 0; if (!ValidateData()) { Cursor crs = Cursor.Current; Cursor.Current = Cursors.WaitCursor; try { Database db = null; ServiceBroker sb = null; if (ssbType != SsbEnum.Database && ssbType != SsbEnum.Login && ssbType != SsbEnum.EndPoint) { sb = dBase.ServiceBroker; } switch (ssbType) { case SsbEnum.Database: MasterKey mk = null; SSBIDatabase sbd = null; if (isEdit) { sbd = (SSBIDatabase)objToUpdate; db = sbd.DataBase; } else { db = new Database(); db.Name = txtName.Text; db.Parent = dbServ.SMOServer; } if (isEdit) { if(db.MasterKey != null && db_chkMasterKey.Checked == false) { mk = db.MasterKey; mk.Drop(); } else if (db.MasterKey == null && db_chkMasterKey.Checked) { mk = new MasterKey(); mk.Parent = db; mk.Create(db_txtMkPwd.Text); } db.Alter(); if (sbd.IsTrustworthy != db_chkTrustWorthy.Checked) sbd.IsTrustworthy = db_chkTrustWorthy.Checked; } else { db.Create(); sbd = new SSBIDatabase(db); if (db_chkMasterKey.Checked) { mk = new MasterKey(); mk.Parent = db; mk.Create(db_txtMkPwd.Text); } if (db_chkTrustWorthy.Checked) { sbd.IsTrustworthy = true; } } if (dBase == null) dBase = db; //Server serv = db.Parent; updatedobj = db; break; case SsbEnum.MessageType: MessageType mt = null; if (isEdit) mt = (MessageType)objToUpdate; else { mt = new MessageType(); mt.Parent = sb; mt.Name = txtName.Text; } if (cboUser.Text != string.Empty) mt.Owner = cboUser.Text; mt.MessageTypeValidation = (MessageTypeValidation)Enum.Parse(typeof(MessageTypeValidation), cboVal.Text); if (cboValSchema.Enabled) mt.ValidationXmlSchemaCollection = cboValSchema.Text; if (isEdit) mt.Alter(); else mt.Create(); updatedobj = mt; break; case SsbEnum.Contract: ServiceContract sc = new ServiceContract(); sc.Parent = sb; sc.Name = txtName.Text; if (cboUser.Text != string.Empty) sc.Owner = cboUser.Text; //get the message types foreach (DataGridViewRow row in dvMsgTypes.Rows) { sc.MessageTypeMappings.Add(new MessageTypeMapping(sc, row.Cells[0].Value.ToString(), (MessageSource)Enum.Parse(typeof(MessageSource), row.Cells[1].Value.ToString()))); } if (isEdit) sc.Alter(); else sc.Create(); updatedobj = sc; break; case SsbEnum.Queu: ServiceQueue q = null; if (isEdit) q = (ServiceQueue)objToUpdate; else { q = new ServiceQueue(); q.Parent = sb; q.Name = txtName.Text; } q.IsEnqueueEnabled = chkStatus.Checked; if (chkRetention.Checked) q.IsRetentionEnabled = true; //if (chkActivation.Checked) { //if(isEdit) // q.IsActivationEnabled = chkActivation.Checked; // if (chkActivation.Checked) { q.IsActivationEnabled = chkActivation.Checked; if (dBase.Name != cboQDb.Text) q.ProcedureDatabase = cboQDb.Text; StoredProcedure sp = (StoredProcedure)cboProc.SelectedItem; q.ProcedureSchema = sp.Schema; q.ProcedureName = cboProc.Text; q.MaxReaders = short.Parse(txtReaders.Text); if (rdOwner.Checked) q.ActivationExecutionContext = ActivationExecutionContext.Owner; else if (rdSelf.Checked) q.ActivationExecutionContext = ActivationExecutionContext.Self; else if (rdUser.Checked) { q.ActivationExecutionContext = ActivationExecutionContext.ExecuteAsUser; q.ExecutionContextPrincipal = txtExecuteAs.Text; } } if (isEdit) q.Alter(); else q.Create(); updatedobj = q; break; case SsbEnum.Service: BrokerService bserv = null; if (isEdit) bserv = (BrokerService)objToUpdate; else { bserv = new BrokerService(); bserv.Parent = sb; bserv.Name = txtName.Text; } if (cboUser.Text != string.Empty) bserv.Owner = cboUser.Text; ServiceQueue servq = (ServiceQueue)cboQueue.SelectedItem; bserv.QueueName = servq.Name; bserv.QueueSchema = servq.Schema; if (lbChosenCtr.Items.Count > 0) { foreach (object o in lbChosenCtr.Items) { ServiceContract servctr = o as ServiceContract; ServiceContractMapping scm = new ServiceContractMapping(bserv, servctr.Name); bserv.ServiceContractMappings.Add(scm); } } if (isEdit) bserv.Alter(); else bserv.Create(); updatedobj = bserv; break; case SsbEnum.Route: ServiceRoute srt = null; if (isEdit) srt = (ServiceRoute)objToUpdate; else { srt = new ServiceRoute(); srt.Name = txtName.Text; srt.Parent = sb; } if (cboUser.Text != string.Empty) srt.Owner = cboUser.Text; if (textBroker.Text != string.Empty) srt.BrokerInstance = textBroker.Text; if (textRemote.Text != string.Empty) srt.RemoteService = textRemote.Text; if (textLifeTime.Text != string.Empty) srt.ExpirationDate = DateTime.Parse(textLifeTime.Text); if (rdLocal.Checked) srt.Address = "LOCAL"; if (rdTransport.Checked) srt.Address = "TRANSPORT"; if (rdTCP.Checked) srt.Address = "TCP://" + txtAddress.Text; if (txtMirror.Text != string.Empty) srt.MirrorAddress = "TCP://" + txtMirror.Text; //StringCollection sColl = srt.Script(); //foreach (string s in sColl) // MessageBox.Show(s); if (isEdit) srt.Alter(); else srt.Create(); updatedobj = srt; break; case SsbEnum.RemoteBinding: RemoteServiceBinding remBind = null; if (isEdit) remBind = (RemoteServiceBinding)objToUpdate; else { remBind = new RemoteServiceBinding(); remBind.Name = txtName.Text; remBind.Parent = sb; } if (cboUser.Text != string.Empty) remBind.Owner = cboUser.Text; remBind.RemoteService = textRemServ.Text; remBind.CertificateUser = cboRemUser.Text; remBind.IsAnonymous = chkAnon.Checked; StringCollection sColl = remBind.Script(); foreach (string s in sColl) MessageBox.Show(s); if (isEdit) remBind.Alter(); else remBind.Create(); updatedobj = remBind; break; case SsbEnum.Conversation: TimeSpan ts = TimeSpan.Zero; Guid grpHandle = Guid.Empty; string convContract = "DEFAULT"; BrokerService bServ = (BrokerService)cnv_cboFrmServ.SelectedItem; string toService = cnv_txtToSrv.Text; if (cnv_txtLifetime.Text != string.Empty && cnv_txtLifetime.Text != "0") ts = TimeSpan.FromSeconds(double.Parse(cnv_txtLifetime.Text)); if (cnv_cboContract.Text != string.Empty) convContract = cnv_cboContract.Text; if (cnv_txtRelGrpHndl.Text != string.Empty) grpHandle = new Guid(cnv_txtRelGrpHndl.Text); //get a service object Service smoserv = smo.GetSSBIService(bServ.Parent.Parent, bServ.Name); if (smoserv.Connection.State == ConnectionState.Closed) smoserv.Connection.Open(); smoserv.Connection.ChangeDatabase(bServ.Parent.Parent.Name); updatedobj = smoserv.BeginDialog(toService, convContract, ts, cnv_chkEncryption.Checked, grpHandle); break; case SsbEnum.Message: SSBIConversation msgConv = (SSBIConversation)msg_cboConv.SelectedItem; string servName = msg_txtFrom.Text; //we need a service object Service msgSsbiServ = smo.GetSSBIService(dBase, msgConv.FromService); if (msgSsbiServ.Connection.State== ConnectionState.Closed) msgSsbiServ.Connection.Open(); msgSsbiServ.Connection.ChangeDatabase(dBase.Name); Conversation msgCnv = new Conversation(msgSsbiServ, msgConv.Handle); string msgType = msg_cboMsgType.SelectedText; string msgString = msg_rchMsg.Text; msgType = msg_cboMsgType.Text; MemoryStream msgBody = new MemoryStream(Encoding.ASCII.GetBytes(msgString)); Microsoft.Samples.SqlServer.Message msg = new Microsoft.Samples.SqlServer.Message(msgType, msgBody); msgCnv.Send(msg); break; case SsbEnum.Login : string pwd = ""; Login lg = new Login(); lg.Parent = dbServ.SMOServer; lg.Name = lgn_txtLoginName.Text; if (lgn_rdSql.Checked) { pwd = lgn_txtPwd.Text; lg.PasswordPolicyEnforced = lgn_chkEnforcePolicy.Checked; lg.LoginType = LoginType.SqlLogin; lg.Create(pwd); } else { lg.Create(); } updatedobj = lg; break; case SsbEnum.Certificate: string certOwner = "dbo"; int certSource = cert_cboSource.SelectedIndex; Certificate cert = new Certificate(); if(!isEdit) { cert.Name = txtName.Text; if(cboUser.Text != "") certOwner = cboUser.Text; cert.Parent = dBase; cert.Owner = certOwner; } cert.ActiveForServiceBrokerDialog = cert_chkBeginDlg.Checked; if (certSource == 0) { if (!isEdit) { if (cert_chkMasterKey.Checked) cert.Create(cert_txtCertPath.Text, CertificateSourceType.File, cert_txtPrivPath.Text, cert_txtDecrypt.Text); else cert.Create(cert_txtCertPath.Text, CertificateSourceType.File, cert_txtPrivPath.Text, cert_txtDecrypt.Text, cert_txtEncrypt.Text); } } else if (certSource == 1) { if (!isEdit) { cert.StartDate = cert_dtValidFrom.Value; cert.ExpirationDate = cert_dtExpiry.Value; cert.Subject = cert_txtCertPath.Text; if (cert_chkMasterKey.Checked) { cert.Create(); } else { cert.Create(cert_txtEncrypt.Text); } } } else if (certSource == 2) { if (!isEdit) { cert.Create(cert_txtCertPath.Text, CertificateSourceType.File); } } if (isEdit) cert.Alter(); updatedobj = cert; break; case SsbEnum.User : User usr; if (!isEdit) { usr = new User(); usr.Name = txtName.Text; usr.Parent = dBase; if(usr_chkLogin.Checked) usr.Login = usr_cboLogin.Text; } else usr = (User)objToUpdate; if (usr_cboCerts.SelectedIndex != -1) usr.Certificate = usr_cboCerts.Text; if (!isEdit) if (usr_chkLogin.Checked) usr.Create(); else smo.CreateUserWithNoLogin(usr); else usr.Alter(); updatedobj = usr; break; case SsbEnum.EndPoint : Endpoint ep = null; if (!isEdit) { ep = new Endpoint(); ep.Name = txtName.Text; ep.Parent = dbServ.SMOServer; ep.ProtocolType = ProtocolType.Tcp; ep.EndpointType = EndpointType.ServiceBroker; } else ep = ((SSBIEndpoint)objToUpdate).EndPoint; ep.Protocol.Tcp.ListenerPort = int.Parse(ep_txtPort.Text); if (ep_txtIp.Text == "ALL") ep.Protocol.Tcp.ListenerIPAddress = System.Net.IPAddress.Any; else { ep.Protocol.Tcp.ListenerIPAddress = System.Net.IPAddress.Parse(ep_txtIp.Text); } ep.Payload.ServiceBroker.EndpointAuthenticationOrder = (EndpointAuthenticationOrder)ep_cboAuth.SelectedItem; if (ep_cboCert.SelectedIndex != -1) ep.Payload.ServiceBroker.Certificate = ep_cboCert.Text; ep.Payload.ServiceBroker.EndpointEncryption = (EndpointEncryption)ep_cboEncrypt.SelectedItem; if (ep_cboAlgorithm.SelectedIndex != -1) ep.Payload.ServiceBroker.EndpointEncryptionAlgorithm = (EndpointEncryptionAlgorithm)ep_cboAlgorithm.SelectedItem; ep.Payload.ServiceBroker.IsMessageForwardingEnabled = ep_chkFwd.Checked; if (ep_txtSize.Text != string.Empty) ep.Payload.ServiceBroker.MessageForwardingSize = int.Parse(ep_txtSize.Text); if(!isEdit) ep.Create(); switch ((EndpointState)ep_cboState.SelectedIndex) { case EndpointState.Disabled : ep.Disable(); break; case EndpointState.Started : ep.Start(); break; case EndpointState.Stopped : if (isEdit) ep.Stop(); break; } if (isEdit) ep.Alter(); break; case SsbEnum.CreateListing : CreateListing(true); break; } if (isEdit) _state = SsbState.Edited; else _state = SsbState.New; Cursor.Current = crs; this.DialogResult = DialogResult.OK; ExitAndClose(); } catch (FailedOperationException e) { smo.ShowException(e); } catch (Exception ex) { smo.ShowException(ex); } finally { if(dbServ !=null) dbServ.SMOServer.ConnectionContext.Disconnect(); } } return 0; }
public void UpdateServiceContract(ServiceContract entity) { entity.Update(); }
internal static void DeploySsbObj(object obj, string svrName, string dbName, SsbEnum ssbType, bool isEdit) { Server svr = CreateServer(svrName, null, null); Database db = svr.Databases[dbName]; ServiceBroker sb = db.ServiceBroker; MessageType mt = null; ServiceContract sc = null; ServiceQueue q = null; BrokerService serv = null; ServiceRoute rt = null; RemoteServiceBinding bind = null; try { switch (ssbType) { case SsbEnum.MessageType: MessageType mtNew = new MessageType(); mtNew.Parent = sb; mt = (MessageType)obj; mtNew.Name = mt.Name; mtNew.MessageTypeValidation = mt.MessageTypeValidation; if (mt.MessageTypeValidation == MessageTypeValidation.XmlSchemaCollection) mtNew.ValidationXmlSchemaCollection = mt.ValidationXmlSchemaCollection; if (isEdit) mtNew.Alter(); else mtNew.Create(); break; case SsbEnum.Contract: ServiceContract scNew = new ServiceContract(); sc = (ServiceContract)obj; scNew.Parent = sb; scNew.Name = sc.Name; foreach (MessageTypeMapping mtm in sc.MessageTypeMappings) { if (!sb.MessageTypes.Contains(mtm.Name)) { ServiceBroker sbParent = sc.Parent; MessageType mtp = sbParent.MessageTypes[mtm.Name]; DeploySsbObj(mtp, svrName, dbName, SsbEnum.MessageType, false); } MessageTypeMapping mtmNew = new MessageTypeMapping(); mtmNew.Name = mtm.Name; mtmNew.Parent = scNew; mtmNew.MessageSource = mtm.MessageSource; scNew.MessageTypeMappings.Add(mtmNew); } if (isEdit) scNew.Alter(); else scNew.Create(); break; case SsbEnum.Queu: q = (ServiceQueue)obj; q.Parent = sb; if (isEdit) q.Alter(); else q.Create(); break; case SsbEnum.Service: serv = (BrokerService)obj; serv.Parent = sb; if (isEdit) serv.Alter(); else serv.Create(); break; case SsbEnum.Route: rt = (ServiceRoute)obj; rt.Parent = sb; if (isEdit) rt.Alter(); else rt.Create(); break; case SsbEnum.RemoteBinding: bind = (RemoteServiceBinding)obj; bind.Parent = sb; if (isEdit) bind.Alter(); else bind.Create(); break; } } catch (FailedOperationException e) { string err = string.Format("{0}", e.InnerException); //throw; } catch (Exception ex) { string errx = string.Format("{0}", ex.InnerException); } finally { svr.ConnectionContext.Disconnect(); } }
public void InsertServiceContract(ServiceContract entity) { if (String.IsNullOrEmpty(entity.OID)) entity.OID = Guid.NewGuid().ToString(); entity.Insert(); }
public void DeleteServiceContract(ServiceContract entity) { entity.Delete(); }