private void UpdateOrder(object data, string TypeOfUpdate) { Monitor.Enter(_object); try { if (TypeOfUpdate == "ObsOrdersPlaced") { List<Order> tempOrders = (List<Order>)data; Trace.WriteLine(((List<Order>)data).Count()); foreach (var x in tempOrders) { List<ArticleModel> tempArticles = new List<ArticleModel>(); x.Articles.ForEach(y => tempArticles.Add(new ArticleModel { ID = y.ID, BasePrice = y.BasePrice, Name = y.Name, IsActive = y.IsActive, Ingredients = y.Ingredients })); uiContext.Send(ran => // sends the changes to the UI { if (Orders.Any(y => y.ID == x.ID) == false) Orders.Add(new OrderModel { ID = x.ID, CustomerID = x.CustomerID, Orderstatus = x.Orderstatus, Price = x.Price, TimeCreated = x.TimeCreated, Articles = tempArticles }); }, null); } } } finally { Monitor.Exit(_object); } }
private string BuildUrl(string sortPropertyName, string linkText) { var orderDirectionQuery = string.Empty; var routeValues = new RouteValueDictionary(); foreach (var key in viewContext_.RequestContext.HttpContext.Request.QueryString.AllKeys.Where(key => key != null)) { routeValues[key] = viewContext_.RequestContext.HttpContext.Request.QueryString[key]; } var arrowSpan = Tag.Span.Class("t-order-icon"); if (Orders.Any(x => x.PropertyName == sortPropertyName)) { if (Orders.First(x => x.PropertyName == sortPropertyName).Direction == GridParameters.Ascending) { orderDirectionQuery += sortPropertyName + GridParameters.PropertyDirectionSeparator + GridParameters.Descending; AddOrUpdate(routeValues, GridParameters.OrderKey, orderDirectionQuery); arrowSpan.Class(GridClass.TopIcon); } else { routeValues.Remove(GridParameters.OrderKey); arrowSpan.Class(GridClass.BottomIcon); } } else { orderDirectionQuery += sortPropertyName + GridParameters.PropertyDirectionSeparator + GridParameters.Ascending; AddOrUpdate(routeValues, GridParameters.OrderKey, orderDirectionQuery); } var url = UrlHelper.GenerateUrl(null, null, null, routeValues, RouteTable.Routes, GridModel.Context.RequestContext, true); var link = Tag.A(url).Id(sortPropertyName).Class(GridClass.GridShift).Html(linkText).Html(arrowSpan.Style("display:inline-block")).ToString(); return(link); }
private void UpdateOrder(object data, string TypeOfUpdate) { Monitor.Enter(_object); try { if (TypeOfUpdate == "ObsOrdersDone") { List <Order> tempOrders = (List <Order>)data; Trace.WriteLine(((List <Order>)data).Count()); foreach (var x in tempOrders) { uiContext.Send(ran => // sends the changes to the UI { if (Orders.Any(y => y.ID == x.ID) == false) { Orders.Add(x); } }, null); } } } finally { Monitor.Exit(_object); } }
private void CalcLevelForJump() { if (Orders == null || !Orders.Any()) { return; } lock (this) { JumpedOrders.Clear(); } OrderUpJumpLevel = null; var workersSumm = 0; var myOrders = ((IHaveMyOrders)ParentViewModel).MyOrders.ToArray(); var calculatedOrders = Orders.Where(o => o.Workers > 0 && (o.Amount > 0.05m || o.Amount < 0.01m) && o.Active && o.Type == OrderTypeEnum.Standart && (!(ParentViewModel is IHaveMyOrders) || myOrders.All(myOrder => myOrder.Id != o.Id))) .OrderBy(o => o.Price).ToList(); var workersAll = calculatedOrders.Sum(o => o.Workers); calculatedOrders.ForEach(o => { if (OrderUpJumpLevel != null) { return; } lock (this) { JumpedOrders.Add(o); } workersSumm += o.Workers; if (workersSumm * 100 / workersAll >= WorkersPercentLimit) { OrderUpJumpLevel = o; } }); this.RaisePropertyChanged(vm => vm.JumpedOrders); if (OrderUpJumpLevel == null || Math.Abs((_lastJumpOnServerDateTime - DateTime.Now).TotalMilliseconds) < 60) { return; } //MarketLogger.Information( // $"OneServerMarketViewModel JumpedOrders.Count:{JumpedOrders.Count} {Server} JumpTo OrderId: {OrderUpJumpLevel.Id} OrderPrice:{OrderUpJumpLevel.Price} speedSumBelow:{speedSumm}"); _lastJumpOnServerDateTime = CatchUp ? DoJump(OrderUpJumpLevel) : DateTime.Now; }
public string OrderSummmary() { if (!Orders.Any()) { return($"No order created yet"); } return($"You have selected this store {SelectedStore} and {Orders.Last().ToString()}"); }
public string OrdersToString() { if (!Orders.Any()) { return(""); } return(string.Join(",", Orders.Select(x => x.Field + (x.Ascending ? " ASC" : " DESC")))); }
public async Task UpdateOrders(Account acccount) { try { if (acccount == null) { throw new ArgumentNullException(nameof(acccount)); } if (account.AccountName != Account.AccountName) { throw new ArgumentException($"{account.AccountName} doesnt match {Account.AccountName}"); } var result = await ExchangeService.GetOpenOrdersAsync(Account.AccountInfo.User.Exchange, Account.AccountInfo.User).ConfigureAwait(true); Action <IEnumerable <Order> > action = res => { lock (lockOrders) { if (!res.Any()) { Orders.Clear(); return; } var updated = (from o in Orders join r in res on o.ClientOrderId equals r.ClientOrderId select o.Update(r)).ToList(); var remove = Orders.Where(o => !res.Any(r => r.ClientOrderId.Equals(o.ClientOrderId, StringComparison.Ordinal))).ToList(); foreach (var order in remove) { Orders.Remove(order); } var add = res.Where(r => !Orders.Any(o => o.ClientOrderId.Equals(r.ClientOrderId, StringComparison.Ordinal))).ToList(); foreach (var order in add) { Orders.Add(order); } } }; if (Dispatcher == null) { action(result); } else { Dispatcher.Invoke(action, result); } } catch (Exception ex) { OnException(ex.Message, ex); } }
/// <inheritdoc cref="ICanBeSerialised.ToEntity"/> public Entity ToEntity() { var orders = Orders.Any() ? Orders .Select(o => o.ToEntity() as Order) .ToList() : new List <Order>(); return(new Client(Id, FirstName, LastName, SecondName, PhoneNumber, Email, Password, orders, Access)); }
public IEnumerable <Order> ExtractSelectedOrders() { if (Orders.Any(x => x.SelectedQuantity > 0 && x.SelectedQuantity < x.Quantity)) { Orders.ToList().ForEach(x => x.IsSelected = false); var newOrders = FixSelectedOrders(); newOrders.ToList().ForEach(x => x.IsSelected = true); } return(SelectedOrders); }
public void ClearSelectedOrders() { if (Orders.Any(x => x.Selected)) { foreach (var item in Orders.Where(x => x.Selected)) { item.NotSelected(); } EventServiceFactory.EventService.PublishEvent(EventTopicNames.RefreshSelectedTicket); } }
public void PrintOrders() { if (!Orders.Any(p => p.Flight != null)) { System.Console.WriteLine("No Orders Loaded."); } foreach (var order in Orders) { order.PrintFlightOrders(); } }
public bool StoreChangeCheck() { if (!Orders.Any()) { return(false); } if (Orders.Last().OrderDate.AddDays(1).CompareTo(DateTime.Now) > 0) { return(true); } return(false); }
public Order GetCurrentOrder() { string orderIdPlusOrdPrefix = PosId + GetCurrOrdPrefix(false); if (Orders != null && Orders.Any(x => x.ClOrdId.StartsWith(orderIdPlusOrdPrefix))) { //There will be only one order with this prefix, which could be updated many times (index) return(Orders.Where(x => x.ClOrdId.StartsWith(orderIdPlusOrdPrefix)).FirstOrDefault()); } else { return(Orders.OrderByDescending(x => x.OrderId).FirstOrDefault()); } }
public void ClearSelectedOrders() { if (Orders.Any(x => x.Selected)) { foreach (var item in Orders.Where(x => x.Selected)) { item.NotSelected(); } var so = new SelectedOrdersData { SelectedOrders = SelectedTicket.SelectedOrders, Ticket = SelectedTicket }; so.PublishEvent(EventTopicNames.SelectedOrdersChanged); } }
public SaveOrdersModel(string uids) : this(0) { var uid = uids.Split <int>().ToList(); Orders = DB.Orders.Where(x => uid.Contains(x.ID)).ToList(); OrderList = uids; if (Orders.Any()) { MinDate = Orders.Min(x => x.CreateDate); MaxDate = Orders.Max(x => x.CreateDate); } Count = Orders.Count; }
public bool OrderTimeLimitCheck() { if (!Orders.Any()) { return(false); } if (Orders.Last().OrderDate.AddHours(2).CompareTo(DateTime.Now) > 0) { return(true); } return(false); }
public async Task LoadData() { if (Orders == null) { Orders = new ObservableCollection <Order>(); } foreach (var order in await _orderRepository.GetOrdersAsync()) { if (!Orders.Any(e => e.Id == order.Id)) { Orders.Add(order); } } }
public void ClearOrders() { if (Orders.Any(p => p.Flight != null)) { foreach (var order in Orders) { order.Flight = null; } System.Console.Write("Successfully cleared loaded Orders. "); } else { System.Console.Write("There are no Orders loaded to any Flights found. "); } }
public async Task UpdateOrders(Account acccount) { try { var result = await ExchangeService.GetOpenOrdersAsync(Account.AccountInfo.User.Exchange, Account.AccountInfo.User); Action <IEnumerable <Order> > action = res => { lock (lockOrders) { if (!res.Any()) { Orders.Clear(); return; } var updated = (from o in Orders join r in res on o.ClientOrderId equals r.ClientOrderId select o.Update(r)).ToList(); var remove = Orders.Where(o => !res.Any(r => r.ClientOrderId.Equals(o.ClientOrderId))); foreach (var order in remove) { Orders.Remove(order); } var add = res.Where(r => !Orders.Any(o => o.ClientOrderId.Equals(r.ClientOrderId))); foreach (var order in add) { Orders.Add(order); } } }; if (Dispatcher == null) { action(result); } else { Dispatcher.Invoke(action, result); } } catch (Exception ex) { OnException("OrdersViewModel.UpdateOrders", ex); } }
public OrdersViewModel( IInterProcessBusSubscriber interProcessBusSubscriber, OrderServiceInvoker orderServiceInvoker, IMessageBoxService messageBoxService) { orderEvents = new List <string>() { "OrderCreatedEvent", "OrderAddressChangedEvent", "OrderDeletedEvent" }; growlNotifications.Top = SystemParameters.WorkArea.Top + topOffset; growlNotifications.Left = SystemParameters.WorkArea.Left + SystemParameters.WorkArea.Width - leftOffset; var stream = interProcessBusSubscriber.GetEventStream(); disposables.Add(stream .Do(x => { logger.Info("{0} in Rx stream", x); }) .Where(x => orderEvents.Contains(x)) .Subscribe(async x => { logger.Info("Refreshing orders on {0}", x); var newOrders = await orderServiceInvoker.CallService(service => service.GetAllOrdersAsync()); this.Orders = new List <OrderViewModel>( newOrders.Select(ord => new OrderViewModel(ord, messageBoxService, orderServiceInvoker))); this.HasOrders = Orders.Any(); if (this.HasOrders) { growlNotifications.AddNotification(new Notification { Title = "Orders changed", ImageUrl = "pack://application:,,,/Images/metroInfo.png", Message = "New/modified orders have been obtained from the ReadModel. Click on the right hand side panel to see them" }); } }) ); }
public bool ValidateOrder() { bool result = true; if (string.IsNullOrEmpty(Lote)) { App.Current.MainPage.DisplayAlert("TSHIRT", "Debe ingresar un codigo de Lote", "OK"); return(false); } if (Orders.Any(item => string.IsNullOrEmpty(item.OrderValue1))) { App.Current.MainPage.DisplayAlert("TSHIRT", "Ingresar nombre de Almacen en productos", "OK"); return(false); } return(result); }
/// <summary> /// Method for managing orders coming in from the other terminals /// over web API throws an exception if the ordernumber is incorrect for the call /// that the client can use to know that it was an incorrect call /// </summary> /// <param name="orderNo">The order's Number</param> /// <param name="typeOrder">Type of order command: PlaceOrder, DoneOrder, RemoveOrder</param> private void ManageOrders(int orderNo, TypeOrder typeOrder) { Trace.WriteLine(typeOrder.ToString() + " "); switch (typeOrder) { // handle a new order. throws an exception if there is already an order with same number case TypeOrder.placeorder: if (Orders.Any(x => x.ID == orderNo) != true) { Orders.Add(new Order { ID = orderNo, CustomerID = 99, Orderstatus = 0, Price = 99, TimeCreated = GetRandomTime() }); } else { throw new Exception(); } break; // handle an order that is ready to get picked up. throws an exception if there isnt any order with that ordernumber case TypeOrder.doneorder: var tempOrder = Orders.Single(x => x.ID == orderNo); if (Orders.Contains(tempOrder) == true) { Orders.Remove(tempOrder); tempOrder.Orderstatus = 1; OrdersDone.Add(tempOrder); } break; // handle removing an order. throws an exception if there isnt any order with that ordernumber case TypeOrder.removeorder: tempOrder = OrdersDone.Single(x => x.ID == orderNo); if (OrdersDone.Contains(tempOrder) == true) { OrdersDone.Remove(tempOrder); } break; default: throw new Exception(); break; } }
private void OrderCreatorViewModelOnCardSaved(object sender, Order newOrder) { if (Orders.Any(o => o.Order.Id == newOrder.Id)) { var oldListItem = Orders.FirstOrDefault(order => order.Order.Id == newOrder.Id); oldListItem.Order = newOrder; } else { DataBaseService.AddOrder(newOrder); } var DataBaseOrder = DataBaseService.GetAllOrders(); Orders.Clear(); foreach (var order in DataBaseOrder) { Orders.Add(new OrderListItem(order)); } }
public void ClearFlights() { if (Flights.Any()) { Flights.Clear(); if (Orders.Any(p => p.Flight != null)) { foreach (var order in Orders) { order.Flight = null; } } System.Console.Write("Successfully cleared loaded flights. "); } else { System.Console.Write("There are no Flights found. "); } }
/// <summary> /// Initializes a new instance of the <see cref="DetachedFlowQuery{TSource}" /> class. /// </summary> /// <param name="criteriaFactory"> /// The criteria factory. /// </param> /// <param name="alias"> /// The alias. /// </param> /// <param name="options"> /// The options. /// </param> /// <param name="query"> /// The query. /// </param> protected internal DetachedFlowQuery ( Func <Type, string, ICriteria> criteriaFactory, string alias = null, FlowQueryOptions options = null, IMorphableFlowQuery query = null ) : base(criteriaFactory, alias, options, query) { if (Constructor != null) { if (Orders.Any(x => !x.IsBasedOnSource)) { var newOrders = OrderHelper.GetSourceBasedOrdersFrom(Orders.ToArray(), Constructor, Data); Orders.Clear(); Orders.AddRange(newOrders); } } }
private void Bdc2_Load(object sender, EventArgs e) { _bdcPresenter = new BdcPresenterPage(this, _repositoryOrder, _repositoryStock); _bdcPresenter.Diplay(); gridControlOrder.DataSource = Orders; gridViewOrder.Columns[0].Visible = false; gridViewOrder.Columns[3].Visible = false; if (!Orders.Any()) { return; } gridViewOrder.RowCellClick += gridViewOrder_CellClick; gridViewOrderLine.RowCellClick += gridViewOrderLine_CellClick; gridControlOrderLine.DataSource = Orders.First().OrderLines; gridViewOrderLine.Columns[0].Visible = false; gridViewOrderLine.Columns[3].Visible = false; gridViewOrderLine.Columns[4].Visible = false; gridViewOrderLine.Columns[1].Caption = Resources.Produit; gridViewOrderLine.Columns[2].Caption = Resources.Quantité; // GCDisplayProduct.DataSource = Orders.First().Products; layoutViewProduct.Columns["Id"].Visible = false; layoutViewProduct.Columns["Photo"].LayoutViewField.TextVisible = false; layoutViewProduct.CardMinSize = new Size(350, 200); var riPictureEdit = GCDisplayProduct.RepositoryItems.Add("PictureEdit") as RepositoryItemPictureEdit; if (riPictureEdit != null) { riPictureEdit.SizeMode = PictureSizeMode.Squeeze; layoutViewProduct.Columns["Photo"].ColumnEdit = riPictureEdit; } }
private void RemoveOrderFromList(Guid orderId) { var orderToRemove = Orders.FirstOrDefault(o => o.Id.Equals(orderId)); if (orderToRemove != null && _orderToCreate != null && _orderToCreate.Order != null && orderToRemove.Id == _orderToCreate.Order.Id) { _orderToCreate = null; } InvokeOnMainThread(() => { Orders.Remove(orderToRemove); if (Orders.Any()) { return; } Close(); }); }
public bool HasActiveTimers() { return(Orders.Any(x => x.ProductTimerValue != null && x.ProductTimerValue.IsActive)); }
/// <summary> /// ... /// </summary> async void LoadOrders() { // To avoid having the slide-in aniamtion freezing // takes 450ms for animation to complete await Task.Delay(450); ////Sql connection //List<DisplayObject> filteredList = new List<DisplayObject>(); //List<DisplayObject> res = (await new Library.Repository.OrdersRepository("Orders").GetAllAsync(1)).ToList(); //// Filter and smash together if the same OrderID //// This is done because of how each ingredient is an //// unique SQL row and has to be stuck into the same string //res.ForEach(a => //{ // bool isMatch = false; // // ... // filteredList // .Where(b => b.ArticleOrderID == a.ArticleOrderID) // .ToList() // .ForEach(c => // { // c.Ingredients.Add(new Ingredient { Name = a.IngredientsName }); // c.IngredientsName += String.Format(", {0}", a.IngredientsName); // isMatch = true; // }); // // Return to avoid duplicate // if (isMatch) // return; // // New object // filteredList.Add(a); //}); //filteredList.ForEach(d => { Orders.Add(d); }); var tempOrders = (await Global.OrderRepo.GetAllAsync()).ToList(); tempOrders.ForEach(async x => { if (x.Orderstatus == 1) { await Global.OrderRepo.GetAllAsync(x); List<ArticleModel> tempArticles = new List<ArticleModel>(); x.Articles.ForEach(y => tempArticles.Add(new ArticleModel { ID = y.ID, BasePrice = y.BasePrice, Name = y.Name, IsActive = y.IsActive, Ingredients = y.Ingredients })); if (Orders.Any(y => y.ID == x.ID) == false) Orders.Add(new OrderModel { ID = x.ID, CustomerID = x.CustomerID, Orderstatus = x.Orderstatus, Price = x.Price, TimeCreated = x.TimeCreated, Articles = tempArticles }); } }); //Orders.Add(a) //List<Order> tempOrders = (await General.ordersRepo.GetAllAsync()).ToList(); //foreach (var item in tempOrders) //{ // Orders.Add(item); //} }
public string GetHistoryOfOrders() => !Orders.Any() ? "No histrory" : string.Join("", Orders.Select(x => x.ToString()));