public override void Osvezi() { IsBusy = true; m_Artikli.Clear(); using (var svc = new BackendServiceClient()) { svc.VratiArtikleCompleted += (s, e) => { var artikli = e.Result.Select(Mapper.Map).ToList(); m_Artikli = new BindingList <Artikal>(artikli); artikalBindingSource.DataSource = m_Artikli; IsBusy = false; }; svc.VratiJediniceMeraCompleted += (s, e) => { jedinicaMereBindingSource.DataSource = e.Result.Select(Mapper.Map); }; svc.VratiPdvCompleted += (s, e) => { pdvBindingSource.DataSource = e.Result.Select(Mapper.MapPdv); }; svc.VratiJediniceMeraAsync(); svc.VratiPdvAsync(); svc.VratiArtikleAsync(); } }
private void SacuvajDobavljaca() { if (m_Dobavljac != null && m_Dobavljac.Validator.IsValid(m_Dobavljac)) { using (var svc = new BackendServiceClient()) { svc.SacuvajDobavljacaCompleted += (s, e) => OnSendMessage(new MessageSaved()); svc.SacuvajDobavljacaAsync(Mapper.Map(m_Dobavljac)); } } }
private void SacuvajArtikal(Artikal artikal) { if (artikal != null && artikal.Validator.IsValid(artikal)) { var a = Mapper.Map(artikal); using (var svc = new BackendServiceClient()) { svc.SacuvajArtikalCompleted += (s, e) => OnSendMessage(new MessageSaved()); svc.SacuvajArtikalAsync(a); } } }
public override void Osvezi() { using (var svc = new BackendServiceClient()) { IsBusy = true; svc.VratiDobavljaceCompleted += (s, e) => { dobavljacBindingSource1.DataSource = e.Result.Select(Mapper.Map); IsBusy = false; }; svc.VratiDobavljaceAsync(); } }
private static void StartManufacturing(NotificationServiceClient notificationClient) { BackendServiceClient client = new BackendServiceClient(); WriteConsole("Start Manufactoring Triggered!"); List <FactoryStatistic> stats = client.GetFactoryStats(null, null).ToList(); WriteConsole("**************************Current Statistics***************"); stats.ForEach(stat => WriteConsole(string.Format("{0}:{1}", stat.Status, stat.Count))); WriteConsole("*************************************************************"); Request request = client.GetNextRequest(); if (stats.First(s => s.Status.ToLower() == "inprogress").Count > 0) { notificationClient.PublishMachineChange(0, 0, 0, "Error-AlreadyInProgress"); WriteConsole("There is an Item already in production"); WriteConsole("Enter C clear production or Q to exit:"); string c = Console.ReadLine(); if (c.ToLower() == "c" || c.ToLower() == "clear") { client.ClearInProgress(); } else { return; } } if (stats.First(s => s.Status.ToLower() == "done").Count > 300) { notificationClient.PublishMachineChange(0, 0, 0, "DailyLimit"); WriteConsole("Maximuim number of items to produce per day exceeded"); return; } if (request != null) { WriteConsole("Will start processing Request Number: " + request.Id.ToString()); RequestStatus currentStatus = Statuses.First(s => s.Id == request.StatusId); WriteConsole("Current Status of the request is " + currentStatus.Name); notificationClient.PublishMachineChange(request.Id.Value, request.StatusId.Value, 0, "Manufacturing"); TransitionRequest(request, currentStatus); StartManufacturing(notificationClient); } else { WriteConsole("No more requests!"); } }
protected override void Sacuvaj() { if (Dobavljac.Validator.IsValid(Dobavljac)) { using (var svc = new BackendServiceClient()) { svc.SacuvajDobavljacaCompleted += (s, e) => { Dobavljac.Id = e.Result; Close(); }; svc.SacuvajDobavljacaAsync(Mapper.Map(Dobavljac)); } } }
private void Sacuvaj() { if (m_Artikal.Validator.IsValid(m_Artikal)) { var a = Mapper.Map(m_Artikal); using (var svc = new BackendServiceClient()) { svc.SacuvajArtikalCompleted += (s, e) => { m_Artikal.Id = e.Result; Close(); }; svc.SacuvajArtikalAsync(a); } } }
private static async Task <List <Match> > WaitingMatchAsync() { using var backendChannel = GrpcChannel.ForAddress(BackendUrl); var backendClient = new BackendServiceClient(backendChannel); var cts = new CancellationTokenSource(TimeSpan.FromSeconds(ApiTimeout)); using var stream = backendClient.FetchMatches(GetFetchMatchesRequest()); var matches = new List <Match>(); while (await stream.ResponseStream.MoveNext(cts.Token)) { matches.Add(stream.ResponseStream.Current.Match); } return(matches); }
static void Main(string[] args) { /////////////////////////////////Set up Publish Events InstanceContext site = new InstanceContext(new Program()); NotificationServiceClient client = new NotificationServiceClient(site); ////////////////////////////////End Setup BackendServiceClient backendClient = new BackendServiceClient(); Statuses = backendClient.GetRequestStatuses().ToList(); WriteConsole("Launching the Microship Machine.. Hold on"); WriteConsole("Hi... I'm you Microship manufacturing machine."); WriteConsole("I can only process one request at a time. No multiThreading required here!"); client.PublishMachineChange(0, 0, 0, "StartManufacturing"); StartManufacturing(client); Console.ReadLine(); }
public static void TransitionRequest(Request request, RequestStatus currentStatus) { BackendServiceClient client = new BackendServiceClient(); if (currentStatus.NextStatusId.HasValue && currentStatus.NextStatusId.Value > 0) { RequestStatus nextStatus = Statuses.First(s => s.Id == currentStatus.NextStatusId.Value); if (currentStatus.Duration > 0) { WriteConsole("I will take " + currentStatus.Duration.ToString() + " seconds to proceed to " + nextStatus.Name); Thread.Sleep(currentStatus.Duration * 1000); } client.TransitionRequest(request.Id.ToString(), currentStatus.NextStatusId.ToString(), nextStatus.NotifyCustomer.ToString(), nextStatus.NotifyManager.ToString()); TransitionRequest(request, nextStatus); } else { WriteConsole("Request " + request.Id.ToString() + " was completed successfully!!"); } }
public Entity DoSomething(int context) { BackendServiceClient backend = new BackendServiceClient(); BackendDTOOfEntityExceptionwB_PKy7mS result = null; result = backend.Process(context); if (result.Exceptions.Count() > 0) { throw result.Exceptions[0]; } result.Messages.ToList().ForEach(m => { switch (m.Type) { case "Event": SomethingIsHappening(m.Text); break; } } ); return result.Data[0]; }
private static async Task AssignTicketAsync(AllocationResponse allocationResponse, Match match) { var assignmentGroup = new AssignmentGroup(); assignmentGroup.Assignment = new Assignment { Connection = $"{allocationResponse.Address}:{allocationResponse.Ports[0].Port}" }; foreach (var ticket in match.Tickets) { assignmentGroup.TicketIds.Add(ticket.Id); } var assignTicketsRequest = new AssignTicketsRequest(); assignTicketsRequest.Assignments.Add(assignmentGroup); using var backendChannel = GrpcChannel.ForAddress(BackendUrl); var backendClient = new BackendServiceClient(backendChannel); await backendClient.AssignTicketsAsync(assignTicketsRequest); }