public static void Register() { IConsumerService consumerServ = new ConsumerService(); var plugins = Bootstrapper.GetInstance <IConsumerPlugin>("ConsumerPlugin"); consumerServ.RegisterOnChannel(plugins); }
static void Main(string[] args) { var consumerService = new ConsumerService(); consumerService.Consumer(); Console.ReadLine(); }
static void Main(string[] args) { Console.BackgroundColor = ConsoleColor.Cyan; var service = new ConsumerService(); service.Consume("TOPPER", "NO", "IDNO2"); }
public async Task <ConsumerService> Save(ConsumerService newData) { ConsumerService dbModel = null; var isNew = newData.ConsumerServiceId == 0; if (isNew) { dbModel = _context.ConsumerServices.Add(newData); } else { dbModel = await _context.ConsumerServices.SingleOrDefaultAsync(x => x.ConsumerServiceId == newData.ConsumerServiceId); if (dbModel != null) { CustomMapper.MapEntity(newData, dbModel); } } await _context.SaveChangesAsync(); if (isNew) { _context.Entry(dbModel).Reference(c => c.SystemUser).Load();; } return(CustomMapper.MapEntity(dbModel, newData));; }
static void Main(string[] args) { Console.BackgroundColor = ConsoleColor.Green; var service = new ConsumerService(); service.Consume("mytopic", "G", "G"); }
//绑定数据到买家数据 private void BuyerInforDetail(string customTid) { string buyerNick = TradeService.GetTrade(customTid).buyer_nick; List <Alading.Entity.Consumer> buyerList = ConsumerService.GetConsumer(p => p.nick == buyerNick); if (buyerList.Count > 0) { BuyerNick.Text = buyerNick; Birthday.Text = (buyerList.First().birthday ?? DateTime.Parse(Alading.Taobao.Constants.DEFAULT_TIME)).ToString("yyyy-MM-dd"); register.Text = (buyerList.First().created ?? DateTime.Parse(Alading.Taobao.Constants.DEFAULT_TIME)).ToString("yyyy-MM-dd"); lastLogin.Text = (buyerList.First().last_visit ?? DateTime.Parse(Alading.Taobao.Constants.DEFAULT_TIME)).ToString("yyyy-MM-dd"); zip.Text = buyerList.First().buyer_zip; if (buyerList.First().sex == "f") { sex.SelectedIndex = 0; } else if (buyerList.First().sex == "m") { sex.SelectedIndex = 1; } level.Text = "信用等级:" + buyerList.First().level.ToString(); score.Text = "信用总分:" + buyerList.First().score.ToString(); total.Text = buyerList.First().buyer_total_num.ToString(); goodNum.Text = buyerList.First().buyer_good_num.ToString(); ((ILinearGauge)rating.Gauges[0]).Scales[0].Value = (float)buyerList.First().level * 90 / 20; } }
public ActionResult ConsumerDetails(int id) { var svc = new ConsumerService(); var model = svc.GetConsumerByID(id); return(View(model)); }
/// 初始化界面绑定 private void InitFormValues() { dateCreateTrade.DateTime = DateTime.Now; //订单时间 dateEndTrade.DateTime = DateTime.Now.AddDays(Constants.DEFAULT_END_DAYS); //默认为15天过后 #region 客户名称 cmbConsumerName.Properties.DataSource = ConsumerService.GetAllConsumer(); cmbConsumerName.Properties.NullText = "请选择客户"; #endregion #region 收款方式 cmbPayWay.Properties.DataSource = CodeService.GetCode(p => p.CodeCategory == Constants.CODE_TRADE_TYPE); cmbPayWay.EditValue = Constants.DEFAULT_TRADE_TYPE; #endregion #region 销售人员 cmbSeller.Properties.DataSource = UserService.GetAllUser();//待添加条件选择 cmbSeller.Properties.NullText = "请选择销售人员"; #endregion #region 承担方式 cmbStandWay.Properties.DataSource = CodeService.GetCode(p => p.CodeCategory == Constants.CODE_POSTFEE_OWNER); cmbStandWay.EditValue = Constants.DEFAULT_POSTFEE_OWNER; #endregion #region 物流信息系列绑定 try { cmbShippingType.Properties.DataSource = CodeService.GetCode(p => p.CodeCategory == Constants.CODE_SHIPPING_TYPE); cmbShippingType.EditValue = Constants.DEFAULT_SHIPPING_TYPE; // 物流公司 List <LogisticCompany> companySource = LogisticCompanyService.GetLogisticCompany(p => p.shippingType == cmbShippingType.EditValue.ToString()); cmbShipCompany.Properties.DataSource = companySource; cmbShipCompany.EditValue = companySource.FirstOrDefault(p => p.isdefault == true).code; //物流模板 List <LogisticCompanyTemplate> templateSource = LogisticCompanyTemplateService.GetLogisticCompanyTemplate(p => p.LogisticCompanyCode == cmbShipCompany.EditValue.ToString()); cmbShippingTemplate.Properties.DataSource = templateSource; cmbShippingTemplate.EditValue = templateSource.FirstOrDefault().TemplateCode; } catch (Exception ex) { } #endregion #region 所属店铺 cmbOwnerShop.Properties.DataSource = ShopService.GetAllShop(); cmbOwnerShop.Properties.NullText = "请选择店铺"; cmbOwnerShop.Properties.PopupWidth = 400; #endregion radioHasTicket.EditValue = false; //默认不开票 txtPostFee.Text = "10"; //默认邮费为10元 txtDiscountRate.Text = "1.0"; //默认不打折 txtDicountOutFee.Text = "0.0"; txtDiscountFee.Text = "0.0"; }
public ActionResult Index(string Exchange, string QeueuName, string Address, int TypeId) { IConsumerService consumerServ = new ConsumerService(); consumerServ.Add(Exchange, QeueuName, Address, TypeId); return(Index()); }
// GET: Consumer public ActionResult Index() { var service = new ConsumerService(); var model = service.GetConsumers(); ViewBag.TotalCount = model.ToList().Count(); return(View(model)); }
public ActionResult DeleteConsumer(int id) { var service = new ConsumerService(); service.DeleteConsumer(id); TempData["Save Result"] = ("The Consumer was removed"); return(RedirectToAction("Index")); }
static void Main(string[] args) { ProviderService providerService = new ProviderService(); providerService.DeployServiceHost(); ConsumerService consumerService = new ConsumerService(); consumerService.ClientService(); }
public async Task <decimal?> GetTotalHours(ConsumerService consumerService) { decimal?result = 0; if (consumerService.ServiceId != null && consumerService.UsedHoursStartDate != null && consumerService.UsedHoursEndDate != null && consumerService.ConsumerId != null) { result = await _context.vTimeSheetDatas.Where(x => x.ClientID == consumerService.ConsumerId && x.ServiceID == consumerService.ServiceId && x.Date1 >= consumerService.UsedHoursStartDate && x.Date1 <= consumerService.UsedHoursEndDate).SumAsync(x => x.SessionDuration) ?? 0m; } return(result); }
/// <summary> /// 客户 /// </summary> /// <param name="treeList"></param> public void GetConsumer(TreeList treeList) { List <Alading.Entity.Consumer> list = ConsumerService.GetAllConsumer(); foreach (Alading.Entity.Consumer item in list) { TreeListNode node = treeList.AppendNode(new object[] { item.nick }, null, item.alipay); //设置是否有子节点,有则会显示一个+号 node.HasChildren = false; } }
public static void Main(string[] args) { Thread.Sleep(TimeSpan.FromSeconds(60)); IUnitOfWork unitOfWork = new UnitOfWork(); ICassandraService cassandraService = new CassandraService(unitOfWork); IMessageService messageService = new MessageService(unitOfWork); INotifyService notify = new NotifyService(unitOfWork, messageService, cassandraService); IConsumerService consumer = new ConsumerService(unitOfWork, notify); consumer.Consume(); CreateHostBuilder(args).Build().Run(); }
public Main( ProducerService producerService, ConsumerService consumerService, IHostApplicationLifetime applicationLifetime, IConfiguration configuration, ILogger <Main> logger) { _producerService = producerService; _consumerService = consumerService; _applicationLifetime = applicationLifetime ?? throw new ArgumentNullException(nameof(applicationLifetime)); Configuration = configuration ?? throw new ArgumentNullException(nameof(configuration)); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); }
public async Task DoWorkShouldRaiseReceivedOnPublishToTopicEvent() { var mockServiceBus = new Mock <IServiceBus>(); var mockClusterManager = new Mock <IClusterManager>(); mockServiceBus.Setup(m => m.ReceiveAsync(It.IsAny <string[]>(), It.IsAny <CancellationToken>())).Verifiable(); IConsumerService consumerService = new ConsumerService(mockServiceBus.Object, mockClusterManager.Object); await consumerService.DoWorkAsync(It.IsAny <CancellationToken>()); _ = Task.Run(() => mockServiceBus.Verify(r => r.ReceiveAsync(It.IsAny <string[]>(), It.IsAny <CancellationToken>()))); }
public async Task ProducerConsumerIntegrationTest() { //arrange var car = new Car { BrandName = "Jeep", Model = "2017", IsSportCar = true, NumberOfDoors = 2 }; var message = JsonConvert.SerializeObject(car); //producer var config = new ProducerConfiguration(); var producerConfig = config.CreateConfig(); var producer = config.CreateProducer(producerConfig); var producerService = new ProducerService(); var deleveredResponse = await producerService.SendMessage(producer, "cars", message); Assert.IsNotNull(deleveredResponse); Assert.IsNotNull(deleveredResponse.TopicOffset); Assert.AreEqual(message, deleveredResponse.Result); var carResponse = JsonConvert.DeserializeObject <Car>(deleveredResponse.Result); Assert.AreEqual(car.BrandName, carResponse.BrandName); Assert.AreEqual(car.Model, carResponse.Model); Assert.AreEqual(car.IsSportCar, carResponse.IsSportCar); Assert.AreEqual(car.NumberOfDoors, carResponse.NumberOfDoors); //Consumer var consumerServiceConfig = new ConsumerServiceConfig(); var consumerConfig = consumerServiceConfig.CreateConfig(); var consumerService = new ConsumerService(); // CancellationTokenSource cts = new CancellationTokenSource(); var consumerResult = consumerService.CreateConsumerAndConsumeSingleMessage(consumerConfig, "cars", CancellationToken.None); Assert.IsNotNull(consumerResult); Assert.IsNotNull(consumerResult.TopicOffset); Assert.AreEqual(message, consumerResult.Message); var carConsumerResponse = JsonConvert.DeserializeObject <Car>(deleveredResponse.Result); Assert.IsNotNull(carConsumerResponse); Assert.AreEqual(car.BrandName, carConsumerResponse.BrandName); Assert.AreEqual(car.Model, carConsumerResponse.Model); Assert.AreEqual(car.IsSportCar, carConsumerResponse.IsSportCar); Assert.AreEqual(car.NumberOfDoors, carConsumerResponse.NumberOfDoors); }
public ActionResult ConsumerEdit(int id) { var svc = new ConsumerService(); var detail = svc.GetConsumerByID(id); var model = new ConsumerEdit { ConsumerID = detail.ConsumerID, Name = detail.Name, Email = detail.Email, Address = detail.Address, PhoneNumber = detail.PhoneNumber, }; return(View(model)); }
} // CanUsePrevAddress private bool GetConsumerInfoAndSave(AddressCurrency oAddressCurrency) { InputLocationDetailsMultiLineLocation location = this.addressLines.GetLocation(oAddressCurrency); var ukAddress = new Models.CustomerAddressModel { Line1 = location.LocationLine1, Line2 = location.LocationLine2, Line3 = location.LocationLine3, PostCode = location.LocationLine6, City = location.LocationLine4 }; ukAddress.FillDetails(); InputLocationDetailsUKLocation ukLokation = new InputLocationDetailsUKLocation { Postcode = ukAddress.PostCode, HouseName = ukAddress.HouseName, HouseNumber = ukAddress.HouseNumber, Flat = ukAddress.FlatOrApartmentNumber, PostTown = ukAddress.City, Street = ukAddress.Address1, Street2 = ukAddress.Address2, POBox = ukAddress.POBox }; var consumerService = new ConsumerService(); Result = consumerService.GetConsumerInfo( this.personalData.FirstName, this.personalData.Surname, this.personalData.Gender, this.personalData.DateOfBirth, ukLokation, location, "PL", this.customerId, this.directorId, false, this.directorId != null, this.forceCheck ); if (Result != null && !Result.HasExperianError) { Score = Result.BureauScore.HasValue ? Result.BureauScore.Value : 0; } return(Result == null || !Result.HasExperianError); } // GetConsumerInfoAndSave
public ActionResult ConsumerCreate(ConsumerCreate model) { if (!ModelState.IsValid) { return(View(model)); } var service = new ConsumerService(); if (service.ConsumerCreate(model)) { TempData["SaveResult"] = "The Consumer was created."; return(RedirectToAction("Index")); } ; ModelState.AddModelError("", "The Consumer could not be created."); return(View(model)); }
public async Task ValidateAsync_consumerExists_DoesNothing() { // Arrange var consumerContainer = new Mock <IConsumerContainer>(); var consumer = new Consumer(); var loyaltyService = new Mock <ILoyaltyService>(); var consumerDAL = new Mock <IConsumerDAL>(); var consumerIdentity = new Mock <IConsumerIdentity>(); consumerDAL.Setup(x => x.GetAsync(consumerIdentity.Object)).ReturnsAsync(consumer); var consumerGetService = new ConsumerService(consumerDAL.Object, loyaltyService.Object); // Act var action = new Func <Task>(() => consumerGetService.ValidateAsync(consumerContainer.Object)); // Assert await action.Should().NotThrowAsync <Exception>(); }
public void TestShiftLocation() { var loc = new InputLocationDetailsMultiLineLocation() { LocationLine1 = "1 Dibgate Cottages".ToUpper(), LocationLine2 = "Newington".ToUpper(), LocationLine3 = "".ToUpper(), LocationLine4 = "Folkestone".ToUpper(), LocationLine5 = "Kent".ToUpper(), LocationLine6 = "CT18 8BJ".ToUpper(), }; loc = ConsumerService.ShiftLocation(loc); Assert.That(loc.LocationLine1 != null); Assert.That(loc.LocationLine2 != null); Assert.That(loc.LocationLine3 != null); Assert.That(loc.LocationLine4 != null); Assert.That(loc.LocationLine5 != null); Assert.That(loc.LocationLine6 == null); }
public async Task CreateAsync_consumerValidationSucceed_Createsconsumer() { // Arrange var consumer = new ConsumerUpdateModel(); var expected = new Consumer(); var loyaltyService = new Mock <ILoyaltyService>(); loyaltyService.Setup(x => x.ValidateAsync(consumer)); var consumerDAL = new Mock <IConsumerDAL>(); consumerDAL.Setup(x => x.InsertAsync(consumer)).ReturnsAsync(expected); var consumerService = new ConsumerService(consumerDAL.Object, loyaltyService.Object); // Act var result = await consumerService.CreateAsync(consumer); // Assert result.Should().Be(expected); }
public async Task ValidateAsync_consumerNotExists_ThrowsError() { // Arrange var fixture = new Fixture(); var id = fixture.Create <int>(); var consumerContainer = new Mock <IConsumerContainer>(); consumerContainer.Setup(x => x.ConsumerId).Returns(id); var consumerIdentity = new Mock <IConsumerIdentity>(); var loyaltyService = new Mock <ILoyaltyService>(); var consumer = new Consumer(); var consumerDAL = new Mock <IConsumerDAL>(); consumerDAL.Setup(x => x.GetAsync(consumerIdentity.Object)).ReturnsAsync((Consumer)null); var consumerGetService = new ConsumerService(consumerDAL.Object, loyaltyService.Object); // Act var action = new Func <Task>(() => consumerGetService.ValidateAsync(consumerContainer.Object)); // Assert await action.Should().ThrowAsync <InvalidOperationException>($"Consumer not found by id {id}"); }
public override void Dispose() { if (Interlocked.Exchange(ref DisposedValue, 1) == 1) { return; } if (IsConsumer) { _providerService.FinishSessionsAsync(this).ContinueWith(t => { if (t.IsFaulted && Logger.IsError) { Logger.Error("There was an error within NDM subprotocol.", t.Exception); } }); _receiptsRequests?.CompleteAdding(); _receiptsRequests?.Dispose(); } if (!IsProvider) { return; } ConsumerService.FinishSessionsAsync(this).ContinueWith(t => { if (t.IsFaulted && Logger.IsError) { Logger.Error("There was an error within NDM subprotocol.", t.Exception); } }); DepositApprovalsRequests?.CompleteAdding(); DepositApprovalsRequests?.Dispose(); }
public async Task CreateAsync_consumerValidationFailed_ThrowsError() { // Arrange var fixture = new Fixture(); var consumer = new ConsumerUpdateModel(); var expected = fixture.Create <string>(); var loyaltyService = new Mock <ILoyaltyService>(); loyaltyService .Setup(x => x.ValidateAsync(consumer)) .Throws(new InvalidOperationException(expected)); var consumerDAL = new Mock <IConsumerDAL>(); var consumerService = new ConsumerService(consumerDAL.Object, loyaltyService.Object); var action = new Func <Task>(() => consumerService.CreateAsync(consumer)); // Assert await action.Should().ThrowAsync <InvalidOperationException>().WithMessage(expected); consumerDAL.Verify(x => x.InsertAsync(consumer), Times.Never); }
public ActionResult ConsumerEdit(int id, ConsumerEdit model) { if (!ModelState.IsValid) { return(View(model)); } if (model.ConsumerID != id) { ModelState.AddModelError("", "ID Mismatch"); return(View(model)); } var svc = new ConsumerService(); if (svc.UpdateConsumer(model)) { TempData["SaveResult"] = "The Consumer was updated."; return(RedirectToAction("Index")); } ModelState.AddModelError("", "The Consumer could not be updated"); return(View(model)); }
public ConsumerController(ConsumerService service) { _service = service; }
/// <summary> /// Initializes a new instance of the <see cref="MicroserviceServices"/> class. /// </summary> /// <param name="consumerService">The <see cref="ConsumerService" />.</param> public MicroserviceServices(ConsumerService consumerService) { _consumerService = consumerService; }