Пример #1
0
        public void VisitorCountService_Test_UpdateOrderCount()
        {
            // arrange
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(databaseName: "VisitorCountService_Test_UpdateOrderCount")
                          .Options;

            var orderCountEntity = new OrderCount {
                Date = DateTime.Now, Count = 100
            };

            using (var context = new ApplicationDbContext(options))
            {
                context.OrderCounts.Add(orderCountEntity);
                context.SaveChanges();
            }

            using (var context = new ApplicationDbContext(options))
            {
                var service = new Service(context);

                // act
                service.OrderCountService.UpdateOrderCount(orderCountEntity);

                // assert
                Assert.Equal(101, service.OrderCountService.GetAllOrderCount().Single().Count);
            }
        }
        public ActionResult OrderCount(DateTime st, DateTime et, string a, string p, string i)
        {
            var sqlWhere = SqlWhere(st, et, a, p);
            string sql =
                string.Format(
                    "select Account,Count(Id),Platform,Sum(Amount),Min(CurrencyCode) from OrderType {0} group by Account,Platform",
                    sqlWhere);
            if (!string.IsNullOrEmpty(i))
            {
                sql += " ,CurrencyCode";
            }
            IList<object[]> objs = NSession.CreateQuery(sql).List<object[]>();

            List<OrderCount> list = new List<OrderCount>();
            int sum = 0;
            foreach (object[] objectse in objs)
            {
                OrderCount oc = new OrderCount { Account = objectse[0].ToString(), OCount = Convert.ToInt32(objectse[1]), Platform = objectse[2].ToString(), TotalAmount = Math.Round(Convert.ToDouble(objectse[3].ToString()), 2), CurrencyCode = objectse[4].ToString() };
                sum += Convert.ToInt32(objectse[1]);
                list.Add(oc);
            }
            List<object> footers = new List<object>();
            footers.Add(new { OCount = sum });
            return Json(new { rows = list.OrderByDescending(f => f.OCount), footer = footers, total = list.Count });
        }
Пример #3
0
        public void OrderCountService_Test_UpdateOrderCount()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase("OrderCount_Service_UpdateOrderCount")
                          .Options;


            var orderCountEntity = new OrderCount()
            {
                Date  = DateTime.Now,
                Count = 100
            };


            using (var context = new ApplicationDbContext(options))
            {
                context.Add(orderCountEntity);
                context.SaveChanges();
            }

            using (var context = new ApplicationDbContext(options))
            {
                var service = new Service(context);
                service.OrderCountService.UpdateOrderCount(orderCountEntity);

                //act
                Assert.Equal(
                    101,
                    service.OrderCountService.GetOrderCountByDate(DateTime.Now).Count);
            }
        }
Пример #4
0
        public void OrderCountService_Test_GetOrderCountByDate()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase("OrderCount_Service_GetOrderCountByDate")
                          .Options;


            var orderEntity = new OrderCount()
            {
                Date  = DateTime.Now.Date,
                Count = 100
            };


            using (var context = new ApplicationDbContext(options))
            {
                context.OrderCounts.Add(orderEntity);
                context.SaveChanges();
            }

            using (var context = new ApplicationDbContext(options))
            {
                var service = new Service(context);
                //assert
                Assert.NotNull(
                    service.OrderCountService.GetOrderCountByDate(DateTime.Now));
            }
        }
Пример #5
0
        public ActionResult OrderCount(DateTime st, DateTime et, string a, string p, string i)
        {
            var    sqlWhere = SqlWhere(st, et, a, p);
            string sql      =
                string.Format(
                    "select Account,Count(Id),Platform,Sum(Amount),Min(CurrencyCode) from OrderType {0} group by Account,Platform",
                    sqlWhere);

            if (!string.IsNullOrEmpty(i))
            {
                sql += " ,CurrencyCode";
            }
            IList <object[]> objs = NSession.CreateQuery(sql).List <object[]>();

            List <OrderCount> list = new List <OrderCount>();
            int sum = 0;

            foreach (object[] objectse in objs)
            {
                OrderCount oc = new OrderCount {
                    Account = objectse[0].ToString(), OCount = Convert.ToInt32(objectse[1]), Platform = objectse[2].ToString(), TotalAmount = Math.Round(Convert.ToDouble(objectse[3].ToString()), 2), CurrencyCode = objectse[4].ToString()
                };
                sum += Convert.ToInt32(objectse[1]);
                list.Add(oc);
            }
            List <object> footers = new List <object>();

            footers.Add(new { OCount = sum });
            return(Json(new { rows = list.OrderByDescending(f => f.OCount), footer = footers, total = list.Count }));
        }
Пример #6
0
        public void InsertOrder(Order order)
        {
            if (order == null)
            {
                throw new ArgumentNullException("order");
            }

            _orderRepository.Insert(order);
            _orderItemRepository.SaveChanges();

            //add or update order count
            var orderCountEntity = _orderCountService.GetOrderCountByDate(DateTime.Now);

            if (orderCountEntity != null)
            {
                _orderCountService.UpdateOrderCount(orderCountEntity);
            }
            else
            {
                var orderCountModel = new OrderCount
                {
                    Date  = DateTime.Now,
                    Count = 1
                };

                _orderCountService.InsertOrderCount(orderCountModel);
            }
        }
Пример #7
0
 public cPCLocal()
 {
     AllStatueTick     = new StatueTick();
     AllOrderCount     = new OrderCount();
     AllCountPerHour   = new CountPerHour();
     AllMcgs           = new AllMcgsStatue();
     AllStatueTestTime = new cAllStatueTestTime();
 }
Пример #8
0
        public virtual List <Message> UpdateOrderLine(Address address, Settings settings,
                                                      Func <string, bool> confirm = null,
                                                      string comment = null,
                                                      bool edit      = true)
        {
            var result = new List <Message>();

            if (address == null)
            {
                OrderCount = null;
                return(result);
            }
            var order = Price.Order;

            if (OrderCount.GetValueOrDefault() > 0)
            {
                if (OrderLine == null)
                {
                    if (order == null)
                    {
                        order       = new Order(Price, address);
                        Price.Order = order;
                        address.Orders.Add(order);
                    }
                    OrderLine         = new OrderLine(order, this, orderCount.Value);
                    orderLine.Comment = comment;
                    order.AddLine(OrderLine);
                }
                else
                {
                    OrderLine.Count   = OrderCount.Value;
                    OrderLine.Comment = comment;
                    order.UpdateStat();
                }

                if (edit)
                {
                    result.AddRange(OrderLine.EditValidate());
                    result.AddRange(EditValidate(address, settings));
                }
                else
                {
                    result = OrderLine.SaveValidate(confirmCallback: confirm);
                }
                OrderCount = OrderLine.Count;
            }

            if (OrderCount.GetValueOrDefault(0) == 0 && OrderLine != null)
            {
                if (address.RemoveLine(orderLine))
                {
                    Price.Order = null;
                }
                OrderLine = null;
            }

            return(result);
        }
Пример #9
0
        public ActionResult Indexx()  //我的人力服務瀏覽
        {
            Session["CaseIDD"] = null;
            if (Session["MEMBERID"] == null)
            {
                Session["MEMBERID"] = 3;//先寫死
            }
            int memberid = (int)Session["MEMBERID"];

            List <CaseManPower> cms = new List <CaseManPower>();
            var q = (from o in db.Cases
                     join m in db.ManPower on o.CaseID equals m.CaseID
                     where o.MemberID == memberid
                     orderby o.StartDateTime
                     select o).ToList();
            List <OrderCount> oco = new List <OrderCount>();

            foreach (var a in q)
            {
                OrderCount ocou = new OrderCount();
                ocou.CaseID    = a.CaseID;
                ocou.CaseTitle = a.CaseTitle;
                ocou.Cou       = db.Orders.Where(o => o.CaseID == a.CaseID).Count();
                oco.Add(ocou);

                CaseManPower cm = new CaseManPower();
                cm.CaseID        = a.CaseID;
                cm.CaseTitle     = a.CaseTitle;
                cm.StartDateTime = a.StartDateTime;
                int caseid = a.CaseID;
                int stasid = a.StatusID;
                cm.StatusName = db.CaseStatus.Find(stasid).StatusName;
                var q2 = db.ManPower.Where(m => m.CaseID == caseid).Select(m => m);
                foreach (var x in q2)
                {
                    cm.MPName         = x.MPName;
                    cm.MPPoint        = x.MPPoint;
                    cm.MPNeedCount    = x.MPNeedCount;    //需要的人數
                    cm.MPActuralCount = x.MPActuralCount; //實際徵求到的人數
                    cm.MPTime         = x.MPTime;         //徵求時間
                    cm.MPDate         = x.MPDate;         //徵求日期
                }
                cms.Add(cm);
            }

            //MemberCaseCount mcc = new MemberCaseCount();
            //var t = mcc.casecount(memberid);
            int ccount = db.Cases.Where(o => o.MemberID == memberid).Count();

            ViewBag.allcase = ccount;
            ViewBag.MPcase  = q.Count();

            ViewBag.Count = oco;

            return(View(cms));
        }
Пример #10
0
        /// <summary>
        /// Insert OrderCount
        /// </summary>
        /// <param name="orderCount">OrderCount entity</param>
        public void InsertOrderCount(OrderCount orderCount)
        {
            if (orderCount == null)
                throw new ArgumentNullException("orderCount");

            orderCount.Date = orderCount.Date.Date;

            _orderCountRepository.Insert(orderCount);
            _orderCountRepository.SaveChanges();
        }
Пример #11
0
        // GET: MyCaseCenter/MyGood
        public ActionResult Index()      //我的物品瀏覽
        {
            Session["CaseID"] = null;
            if (Session["MEMBERID"] == null)
            {
                Session["MEMBERID"] = 12;//先寫死
            }
            int             memberid = (int)Session["MEMBERID"];
            List <CaseGood> cgs      = new List <CaseGood>();
            var             q        = (from o in db.Cases
                                        join c in db.Goods on o.CaseID equals c.CaseID
                                        where o.MemberID == memberid
                                        orderby o.StartDateTime
                                        select o).ToList();
            List <OrderCount> oco = new List <OrderCount>();

            foreach (var a in q)
            {
                OrderCount ocou = new OrderCount();
                ocou.CaseID    = a.CaseID;
                ocou.CaseTitle = a.CaseTitle;
                ocou.Cou       = db.Orders.Where(o => o.CaseID == a.CaseID).Count();
                oco.Add(ocou);

                CaseGood cg = new CaseGood();
                cg.CaseID        = a.CaseID;
                cg.CaseTitle     = a.CaseTitle;
                cg.StartDateTime = a.StartDateTime;
                int caseid = a.CaseID;
                int stasid = a.StatusID;
                cg.StatusName = db.CaseStatus.Find(stasid).StatusName;
                var q2 = db.Goods.Where(m => m.CaseID == caseid).Select(m => m);
                foreach (var x in q2)
                {
                    cg.GdsName  = x.GdsName;
                    cg.GdsPoint = x.GdsPoint;
                    cg.GdsCount = x.GdsCount;
                }

                cgs.Add(cg);
            }


            //MemberCaseCount mcc = new MemberCaseCount();
            //var t = mcc.casecount(memberid);
            int ccount = db.Cases.Where(o => o.MemberID == memberid).Count();

            ViewBag.allcase = ccount;
            ViewBag.GDcase  = q.Count();

            ViewBag.Count = oco;

            return(View(cgs));
        }
Пример #12
0
        /// <summary>
        /// Update OrderCount
        /// </summary>
        /// <param name="orderCount">OrderCount entity</param>
        public void UpdateOrderCount(OrderCount orderCount)
        {
            if (orderCount == null)
                throw new ArgumentNullException("orderCount");

            orderCount.Date = orderCount.Date.Date;
            orderCount.Count++;

            _orderCountRepository.Update(orderCount);
            _orderCountRepository.SaveChanges();
        }
 public override int GetHashCode()
 {
     unchecked
     {
         var hash = 17;
         hash = hash * 29 + MessageType.GetHashCode();
         hash = hash * 29 + Symbol.GetHashCode();
         hash = hash * 29 + Side.GetHashCode();
         hash = hash * 29 + Price.GetHashCode();
         hash = hash * 29 + Size.GetHashCode();
         hash = hash * 29 + OrderCount.GetHashCode();
         hash = hash * 29 + Precision.GetHashCode();
         hash = hash * 29 + Time.GetHashCode();
         hash = hash * 29 + Date.GetHashCode();
         return(hash);
     }
 }
Пример #14
0
        private List <Message> EditValidate(Address address, Settings settings)
        {
            var result = new List <Message>();

            if (OrderCount.GetValueOrDefault(0) == 0 || OrderLine == null)
            {
                return(result);
            }

            if (Junk)
            {
                result.Add(
                    Message.Warning("Вы заказали препарат с ограниченным сроком годности\r\nили с повреждением вторичной упаковки."));
            }

            if (address.Orders.Where(o => o.Frozen).SelectMany(o => o.Lines).Any(l => l.ProductId == ProductId))
            {
                result.Add(Message.Warning("Товар присутствует в замороженных заказах."));
            }

            if (settings.WarnIfOrderedYesterday && address.YesterdayOrderedProductIds != null &&
                address.YesterdayOrderedProductIds.Contains(ProductId))
            {
                result.Add(Message.Warning(Util.HumanizeDaysAgo(settings.CountDayForWarnOrdered)));
            }

            if (PrevOrderAvgCount != null && OrderCount > PrevOrderAvgCount * settings.OverCountWarningFactor)
            {
                result.Add(Message.Warning("Превышение среднего заказа!"));
            }

            if (PrevOrderAvgCost != null && Cost > PrevOrderAvgCost * (1 + settings.OverCostWarningPercent / 100))
            {
                result.Add(Message.Warning("Превышение средней цены!"));
            }

            if (BuyingMatrixType == BuyingMatrixStatus.Denied)
            {
                result.Clear();
                OrderLine.Count = 0;
                result.Add(Message.Warning("Препарат запрещен к заказу."));
            }

            return(result);
        }
Пример #15
0
        public async Task <OrderCount> GetCurrentOrderActivity(Orders o)
        {
            try
            {
                if (o == null)
                {
                    return(null);
                }
                using (var dc = new EntitiesWMS())
                {
                    var order = await
                                dc.Orders
                                .Where(p => p.ERP_ID == o.ERP_ID && p.OrderID == o.OrderID)
                                .GroupBy(
                        (by) => by.SubOrderID,
                        (key, group) => new
                    {
                        Suborder = group.FirstOrDefault()
                    }).ToListAsync();

                    var oc = new OrderCount
                    {
                        Status = order.Any(p => p.Suborder.Status > (int)EnumWMSOrderStatus.Waiting) ?
                                 order.Min(p => p.Suborder.Status > (int)EnumWMSOrderStatus.Waiting ?
                                           p.Suborder.Status : (int)EnumWMSOrderStatus.Active) : (int)EnumWMSOrderStatus.Waiting,
//                        Status = order.Where(p => p.Suborder.Status > (int)EnumWMSOrderStatus.Waiting)
//                                      .DefaultIfEmpty()
//                                      .Min(p => p == null ? 0 : p.Suborder.Status),
                        All      = order.Count(),
                        Active   = order.Count(p => p.Suborder.Status == (int)EnumWMSOrderStatus.Active),
                        Done     = order.Count(p => p.Suborder.Status >= (int)EnumWMSOrderStatus.OnTarget && p.Suborder.Status <= (int)EnumWMSOrderStatus.ReadyToTake),
                        Finished = order.Count(p => p.Suborder.Status >= (int)EnumWMSOrderStatus.Cancel)
                    };

                    return(oc);
                }
            }
            catch (Exception e)
            {
                throw new Exception(string.Format("{0}.{1}: {2}", this.GetType().Name, (new StackTrace()).GetFrame(0).GetMethod().Name, e.Message));
            }
        }
Пример #16
0
        private void orderCount_Click(object sender, EventArgs e)
        {
            SqlOrderRepository orders = new SqlOrderRepository(connectionString);

            OrderCount        oo   = orders.RetrieveOrderCount(startDatePicker.Value, endDatePicker.Value);
            List <OrderCount> list = new List <OrderCount>();

            list.Add(oo);
            dataGridView1.DataSource = list;

            for (int i = 0; i < dataGridView1.Columns.Count; i++)
            {
                DataGridViewColumn columnOne = dataGridView1.Columns[0];
                columnOne.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;

                DataGridViewColumn columnTwo = dataGridView1.Columns[1];
                columnTwo.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;

                DataGridViewColumn columnThree = dataGridView1.Columns[2];
                columnThree.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            }
        }
Пример #17
0
        public void OrderCountService_Test_InsertOrderCount()
        {
            // arrange
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(databaseName: "OrderCountService_Test_InsertOrderCount")
                          .Options;

            var orderCountEntity = new OrderCount {
                Date = DateTime.Now.Date, Count = 100
            };

            using (var context = new ApplicationDbContext(options))
            {
                var service = new Service(context);

                // act
                service.OrderCountService.InsertOrderCount(orderCountEntity);

                // assert
                Assert.NotNull(service.OrderCountService.GetOrderCountByDate(DateTime.Now));
            }
        }
Пример #18
0
        public async Task <OrderCount> GetCurrentSubOrderActivity(Orders ord)
        {
            try
            {
                if (ord == null)
                {
                    return(null);
                }

                using (var dc = new EntitiesWMS())
                {
                    var order = await dc.Orders
                                .Where(p => p.ERP_ID == ord.ERP_ID && p.OrderID == ord.OrderID && p.SubOrderID == ord.SubOrderID)
                                .Join(dc.Commands,
                                      o => o.ID,
                                      c => c.Order_ID,
                                      (o, c) => new { Order = o, Command = c }).ToListAsync();

                    var oc = new OrderCount
                    {
                        Status = order.FirstOrDefault().Order.Status,
//                        order.Where(p => p.Command.Status > (int)EnumWMSCommandStatus.Waiting)
//                                      .DefaultIfEmpty()
//                                      .Min(p => (p == null || p.Command == null) ? 0 : p.Command.Status),
                        All      = order.Count(p => p.Command.Target.StartsWith("W:32")),
                        Active   = order.Count(p => p.Command.Status == (int)EnumWMSCommandStatus.Active),
                        Done     = order.Count(p => p.Command.Target.StartsWith("W:32") && p.Command.Status >= (int)EnumWMSCommandStatus.Canceled),
                        Finished = order.Count(p => p.Command.Target.StartsWith("W:32") && p.Command.Status == (int)EnumWMSCommandStatus.Finished)
                    };

                    return(oc);
                }
            }
            catch (Exception e)
            {
                throw new Exception(string.Format("{0}.{1}: {2}", this.GetType().Name, (new StackTrace()).GetFrame(0).GetMethod().Name, e.Message));
            }
        }
Пример #19
0
 public OrderCountModel(OrderCount orderCount)
 {
     this.Count       = orderCount.count;
     this.Status      = orderCount.status;
     this.RequestType = orderCount.requesttype;
 }