private void scanDeserializedMoveDerivedsInsideBuildTreeShadow(OrderList ordersFlat) {
			string msig = " BufferedSerializerDerivedOrdersSelfRestore::RestoreDerivedFromItself(): ";
			int derivedsFound = 0;

			List<Order> foundSoRemoveFromRoot = new List<Order>();
			foreach (Order orderWithDeriveds in ordersFlat) {
				if (orderWithDeriveds.DerivedOrdersGuids == null) continue;
				foreach (string guidToFind in orderWithDeriveds.DerivedOrdersGuids) {
					string ident = "orderWithDeriveds[" + orderWithDeriveds.GUID + "] has derivedGuid[" + guidToFind + "]";
					if (orderWithDeriveds.GUID == guidToFind) {
						string msg = ident + " DerivedOrdersGuids contains my own Guid: cyclic links ONE leveldeep (TODO: MANY leveldeep)";
						Assembler.PopupException(msg + msig);
						continue;
					}
					
					Order orderFound = null;
					foreach (Order orderEveryScanning in ordersFlat) {
						if (orderEveryScanning.GUID != guidToFind) continue;
						orderFound = orderEveryScanning;
						break;
					}
					
					if (orderFound == null) {
						string msg = ident + " but I couldn't find it"
							+ " among ordersAllDeserialized; you won't see derived[" + guidToFind + "] in ExecutionForm";
						Assembler.PopupException(msg + msig);
						continue;
					}
					
					derivedsFound++;
					
					if (orderWithDeriveds.DerivedOrders.Contains(orderFound)) {
						string msg = "ALREADY_UNFLATTENED_INTO_SHADOWTREE: you already restored DerivedOrders from DerivedOrdersGuids"
							+ "; no need for the second pass; you don't want duplicates in DerivedOrders"
							+ "; get rid of this redundant invocation upstack";
						throw new Exception(msg + msig);
					}
				
					orderWithDeriveds.DerivedOrders.Add(orderFound);
					orderFound.DerivedFrom = orderWithDeriveds;
					foundSoRemoveFromRoot.Add(orderFound);
				}
			}
			
			foreach (Order order in ordersFlat) {
				if (foundSoRemoveFromRoot.Contains(order)) continue;
				base.Insert(0, order);
			}

			string stats = "DERIVEDS_MOVED[" + derivedsFound + "] = ordersFlat.Count[" + ordersFlat.Count + "] - base.Count[" + base.Count + "]";
			//Assembler.PopupException(stats + msig);
		}
Ejemplo n.º 2
0
 public OrderSystem(MealData mealData)
 {
     _mealData = mealData;
     InitializeComponent();
     InitialMealButton();
     InitialMealButtonClick();
     InitialMealGroup();
     InitialGridView();
     _controlPage = new ControlPage();
     _orderList = new OrderList();
     _controlPage.CheckButton(_previousPageButton, _nextPageButton);
     _controlPage.InitialPage(MAX_PAGE, MAX_MEAL_PAGE, TOTAL_MEAL, _pageNumberLabel);
     _controlPage.InitialMealButton(_meal);
 }
Ejemplo n.º 3
0
		/// <summary>
		/// Initializes a new instance of the <see cref="EntityRegistry"/>.
		/// </summary>
		/// <param name="storage">The special interface for direct access to the storage.</param>
		public EntityRegistry(IStorage storage)
		{
			if (storage == null)
				throw new ArgumentNullException(nameof(storage));

			Storage = storage;

			ConfigManager.TryRegisterService(storage);

			Exchanges = new ExchangeList(storage) { BulkLoad = true };
			ExchangeBoards = new ExchangeBoardList(storage) { BulkLoad = true };
			Securities = new SecurityList(this);
			Trades = new TradeList(storage);
			MyTrades = new MyTradeList(storage);
			Orders = new OrderList(storage);
			OrderFails = new OrderFailList(storage);
			Portfolios = new PortfolioList(storage);
			Positions = new PositionList(storage);
			News = new NewsList(storage);
		}
Ejemplo n.º 4
0
        /// <summary>
        /// 添加一条记录
        /// </summary>
        public int Add(OrderList entity, IDbTransaction tran)
        {
            string sql = @"insert into [OrderList]
                               ([orderid], [productid], [count], [productProterys], [marketPrice], [oemPrice], [deliveryTypeid])
                               values
                               (@orderid, @productid, @count, @productProterys, @marketPrice, @oemPrice, @deliveryTypeid)";

            object param = new
            {
                orderid = entity.Orderid,
                productid = entity.Productid,
                count = entity.Count,
                productProterys = entity.ProductProterys,
                marketPrice = entity.MarketPrice,
                oemPrice = entity.OemPrice,
                deliveryTypeid = entity.DeliveryTypeid
            };
            int count = tran.Connection.Execute(sql, param, tran);
            return count;
        }
Ejemplo n.º 5
0
        private void button1_Click(object sender, EventArgs e)
        {
            OrderList bob = new OrderList();

            try
            {
                bob = ol.SearchOrder(Convert.ToInt32(cmbSupp.SelectedIndex + 1),
                                        dtpFrom.Value.ToString("yyyy-MM-dd"),
                                        dtpTo.Value.ToString("yyyy-MM-dd"));

                dataGridView2.DataSource = bob;
                if (bob.Count == 0)
                {
                    MessageBox.Show("No Items Found");
                }
            }
            catch (Exception d)
            {
                MessageBox.Show("ERROR: " + d);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 添加一条记录
        /// </summary>
        public ResultSet Add(OrderList entity)
        {
            Func<OrderList, ResultStatus> validate = (_entity) =>
            {
                return new ResultStatus();
            };

            Func<OrderList, ResultStatus> op = (_entity) =>
            {
                int ret = new OrderListDal().Add(entity);
                if (ret > 0)
                    return new ResultStatus();
                else
                    return new ResultStatus()
                    {
                        Success = false,
                        Code = StatusCollection.AddFailed.Code,
                        Description = StatusCollection.AddFailed.Description
                    };
            };

            return HandleBusiness(entity, op, validate);
        }
 public Customer(string aFullName, string anAddress)
 {
     mFullName = aFullName;
     mAddress = anAddress;
     mOrders = new OrderList();
 }
Ejemplo n.º 8
0
 public object Post(OrderList request)
 {
     var query = AutoQuery.CreateQuery(request, Request.GetRequestParams()).And(e=>!e.Del);
     var result = AutoQuery.Execute(request, query);
      //   return result;
     return new {total = result.Total, result = result.Results};
 }
Ejemplo n.º 9
0
        public string AddOrder(int userid, int productid, int pronum)
        {
            string result = "1";
            Order order = new Order();
            OrderBll orderbll = new OrderBll();
            OrderList orderlist = new OrderList();
            OrderListBll orderlistbll = new OrderListBll();

            ProductBll pbll = new ProductBll();
            UsersBll ubll = new UsersBll();
            try
            {
                //检查 当前用户是否有末完成的订单  有不能
                //if (orderbll.GetAll("*", " [status]=1 and userid=" + userid, null, "id").Entity.Count <= 0)
                //{

                var p = pbll.GetByPrimaryKey(productid).Entity;
                var u = ubll.GetByPrimaryKey(userid).Entity;
                order.UserId = userid;
                order.ReciverName = u.UserName;
                order.PayMentTypeId = 1;//货到付款
                order.RevicerAddress = u.Address;
                order.RevicerTel = u.Mobile;
                order.Status = 1;//
                order.RealPrice = pronum * p.OemPrice;
                order.TotalPrice = pronum * p.OemPrice;
                order.Count = 1;
                order.OrderTime = DateTime.Now;
                order.OrderNo = OrderHelper.GetProNo();
                //添加订单
                int orderaddid = orderbll.AddAndReturn(order);

                //添加订单详情
                orderlist.Count = order.Count;
                orderlist.Productid = productid;
                orderlist.Orderid = orderaddid;
                orderlist.OemPrice = p.OemPrice;
                orderlist.MarketPrice = p.MarketPrice;
                orderlistbll.Add(orderlist);
                //}
                //else
                //{
                //    result = "-2";
                //}

            }
            catch
            {

                result = "-1";
            }

            return result;
        }
Ejemplo n.º 10
0
        public void AddOrderList(Users u, int productid, int num, int orderid)
        {
            OrderList orderlist = new OrderList();
            OrderListBll orderlistbll = new OrderListBll();

            ProductBll pbll = new ProductBll();
            var p = pbll.GetByPrimaryKey(productid).Entity;

            //添加订单详情
            orderlist.Count = num;
            orderlist.Productid = productid;
            orderlist.Orderid = orderid;
            orderlist.OemPrice = p.OemPrice;
            orderlist.MarketPrice = p.MarketPrice;
            orderlistbll.Add(orderlist);
        }
Ejemplo n.º 11
0
 private async Task ExecuteLimitOrders(OrderList orderList)
 {
     foreach (var orderWrapperBuy in orderList.LimitOrdersBuy.OrderBy(itm => itm.Order.Id))
         foreach (var orderWrapperSell in orderList.LimitOrdersSell.OrderBy(itm => itm.Order.Id))
             if (orderWrapperBuy.Order.Price >= orderWrapperSell.Order.Price && 
                 orderWrapperBuy.Order.Asset == orderWrapperSell.Order.Asset &&
                 orderWrapperBuy.Order.TraderId != orderWrapperSell.Order.TraderId)
                 try
                 {
                     await ExecuteOrders(orderWrapperBuy.Order, orderWrapperSell.Order);
                 }
                 finally
                 {
                     orderList.CleanUpFullfiledLimitOrders();
                 }
 }
		public void InitializeScanDeserializedMoveDerivedsInsideBuildTreeShadow(OrderList ordersAllDeserialized) {
			base.Clear();
			this.ordersAll = ordersAllDeserialized;
			this.scanDeserializedMoveDerivedsInsideBuildTreeShadow(this.ordersAll);
		}
Ejemplo n.º 13
0
        private static LimitOrder[] GetRankedOrders(MarketOrder marketOrder, OrderList orderList)
        {
            var worsSpread = orderList.CalcWorstSpread(marketOrder.Asset);

            if (worsSpread <= 0)
                return marketOrder.Action == OrderAction.Buy
                    ? orderList.LimitOrdersSell.Where(
                        itm => itm.Order.Asset == marketOrder.Asset && itm.Order.TraderId != marketOrder.TraderId)
                        .OrderBy(itm => itm.Order.Price)
                        .Select(itm => itm.Order)
                        .ToArray()
                    : orderList.LimitOrdersBuy.Where(
                        itm => itm.Order.Asset == marketOrder.Asset && itm.Order.TraderId != marketOrder.TraderId)
                        .OrderByDescending(itm => itm.Order.Price)
                        .Select(itm => itm.Order)
                        .ToArray();


            var resultOrderList = marketOrder.Action == OrderAction.Buy
                ? orderList.LimitOrdersSell.Where(
                    itm => itm.Order.Asset == marketOrder.Asset && itm.Order.TraderId != marketOrder.TraderId).ToArray()
                : orderList.LimitOrdersBuy.Where(
                    itm => itm.Order.Asset == marketOrder.Asset && itm.Order.TraderId != marketOrder.TraderId).ToArray();

            foreach (var orderWrapper in resultOrderList)
                orderWrapper.Rank = orderWrapper.Order.Price;


            return marketOrder.Action == OrderAction.Buy
                ? resultOrderList.OrderBy(itm => itm.Rank).Select(itm => itm.Order).ToArray()
                : resultOrderList.OrderByDescending(itm => itm.Rank).Select(itm => itm.Order).ToArray();

        }
Ejemplo n.º 14
0
        private static OrderList SeparateOrders(OrderBase[] orders)
        {

            var result = new OrderList();

            foreach (var orderBase in orders)
            {
                var marketOrder = orderBase as MarketOrder;
                if (marketOrder != null)
                    result.MarketOrders.Add(marketOrder);

                var limitOrder = orderBase as LimitOrder;
                if (limitOrder != null)
                {
                    if (limitOrder.Action == OrderAction.Buy)
                        result.LimitOrdersBuy.Add(OrderWrapper.Create(limitOrder)); 

                    if (limitOrder.Action == OrderAction.Sell)
                        result.LimitOrdersSell.Add(OrderWrapper.Create(limitOrder));
                }
            }

            result.MarketOrders = result.MarketOrders.OrderBy(itm => itm.Id).ToList();
            result.LimitOrdersBuy = result.LimitOrdersBuy.OrderByDescending(itm => itm.Order.Price).ToList();
            result.LimitOrdersSell = result.LimitOrdersSell.OrderBy(itm => itm.Order.Price).ToList();

            return result;
        }
Ejemplo n.º 15
0
 private void menuOrder_Click(object sender, EventArgs e)
 {
     OrderList ucOrderList = new OrderList();
     pnlMain.Controls.Clear();
     pnlMain.Controls.Add(ucOrderList);
 }
Ejemplo n.º 16
0
        public static Order FromExcelRange(ExcelRange excelRange, int row, OrderList.Columns columns)
        {
            var dateOrTime = excelRange[row, columns.Date].Value;
            DateTime date;

            if (dateOrTime is DateTime)
            {
                date = (DateTime)dateOrTime;
            }
            else if (dateOrTime is double)
            {
                date = DateTime.FromOADate((double)dateOrTime);
            }
            else
            {
                return null;
            }

            var no = excelRange[row, columns.No].Text.Trim();

            if (!NO_REGEX.IsMatch(no))
            {
                return null;
            }

            var nc12Matches = NC12_REGEX.Match(excelRange[row, columns.Nc12].Text.Trim());

            if (!nc12Matches.Success)
            {
                return null;
            }

            var nc12 = nc12Matches.Groups[1].Value;

            var programNameMatches = PROGRAM_NAME_REGEX.Match(excelRange[row, columns.ProgramName].Text.Trim());

            if (!programNameMatches.Success)
            {
                return null;
            }

            var programName = "PROGRAM " + programNameMatches.Groups[1].Value;

            var quantity = 0;

            Int32.TryParse(excelRange[row, columns.Quantity].Text.Trim(), out quantity);

            if (quantity < 1)
            {
                return null;
            }

            var workCenter = excelRange[row, columns.WorkCenter].Text.Trim();

            return new Order()
            {
                Date = date,
                No = no,
                Nc12 = nc12,
                ProgramName = programName,
                Quantity = quantity,
                WorkCenter = workCenter
            };
        }
            public OrderMailMergeDataSource(OrderList orders)
            {
                this.mOrders = orders;

                // When the data source is initialized, it must be positioned before the first record.
                this.mRecordIndex = -1;
            }
Ejemplo n.º 18
0
        private async Task ExecuteMarketOrders(OrderList orderList)
        {
            var marketOrders = orderList.MarketOrders.ToArray();

            foreach (var marketOrder in marketOrders)
                while (!marketOrder.IsOrderFullfiled())
                    try
                    {
                        var limitOrders = GetRankedOrders(marketOrder, orderList);

                        //If there is no limit orders to execute the market order - exit from the loop
                        if (limitOrders == null || limitOrders.Length == 0)
                            break;

                        foreach (var limitOrder in limitOrders)
                            await ExecuteOrders(marketOrder, limitOrder);

                    }
                    finally
                    {
                        orderList.CleanUpFullfiledLimitOrders();
                    }

        }