static void Main(string[] args)
        {
            HttpClient http       = new HttpClient();
            string     webSiteUrl = "http://www.posta.md/ro/tracking?id=RH263108004CN";
            var        response   = http.GetByteArrayAsync(webSiteUrl);
            string     source     = Encoding.GetEncoding("utf-8").GetString(response.Result, 0, response.Result.Length - 1);

            source = WebUtility.HtmlDecode(source);
            HtmlDocument htmlDoc = new HtmlDocument();

            htmlDoc.LoadHtml(source);

            List <HtmlNode> nodes = htmlDoc.DocumentNode.Descendants().Where(w => (w.Name == "div" && w.Attributes["class"] != null) && w.Attributes["class"].Value.Contains("row clearfix")).ToList();

            OrderTracking orderTracking = new OrderTracking();

            foreach (HtmlNode node in nodes)
            {
                orderTracking.AddItem(node);
            }

            SmppServer smppServer = new SmppServer();

            smppServer.ConnectToSmppServerSmsCarrier();
            smppServer.SendSms();

            Console.ReadLine();
        }
Beispiel #2
0
        /// <summary>
        /// 配送状态跟踪
        /// </summary>
        /// <param name="order_id"></param>
        /// <returns></returns>
        public OrderTracking FindOrderTracking(string order_id)
        {
            var           apirel        = openApi.OrderTracking(order_id, consumer_key, consumer_secret);
            OrderTracking orderTracking = null;

            if (apirel.code == 200 && apirel.data != null)
            {
                orderTracking = new OrderTracking()
                {
                    state_code      = apirel.code.ToString(),
                    last_updated_at = apirel.data.last_updated_at.ToString()
                };

                if (apirel.data.deliveryman_info != null)
                {
                    orderTracking.deliveryman_info = new DeliveryMan()
                    {
                        name  = apirel.data.deliveryman_info.name,
                        phone = apirel.data.deliveryman_info.phone
                    };
                }

                if (apirel.data.tracking_info != null)
                {
                    orderTracking.tracking_info = new Tracking()
                    {
                        latitude  = apirel.data.tracking_info.latitude,
                        longitude = apirel.data.tracking_info.longitude
                    };
                }
            }

            return(orderTracking);
        }
        public List <OrderTracking> SetupOrderTracking(Order order)
        {
            var whenApproved  = DateTime.UtcNow.ToPacificTime().AddDays(-10);
            var orderTracking = new List <OrderTracking>();

            var tracking = new OrderTracking();

            tracking.DateCreated = whenApproved;
            tracking.Description = "Description1";
            tracking.Order       = order;
            tracking.StatusCode  = OrderStatusCodeRepository.GetNullableById(OrderStatusCode.Codes.Requester);
            tracking.User        = order.CreatedBy;
            orderTracking.Add(tracking);

            Order order1 = order;

            var count     = 1;
            var approvals = ApprovalRepository.Queryable.Where(a => a.Order.Id == order1.Id && a.Completed).OrderBy(b => b.StatusCode.Level);

            foreach (var approval in approvals)
            {
                tracking             = new OrderTracking();
                tracking.DateCreated = whenApproved.AddDays(count);
                tracking.Description = "Description" + count;
                tracking.Order       = order;
                tracking.StatusCode  = approval.StatusCode;
                tracking.User        = approval.User;

                orderTracking.Add(tracking);
                count++;
            }


            return(orderTracking);
        }
        public void OrderPaid(Order order, LineItem lineItem, decimal quantity, string overrideDescription = null)
        {
            var user        = _userRepository.GetById(_userIdentity.Current);
            var description = overrideDescription;

            if (string.IsNullOrWhiteSpace(description))
            {
                description = string.Format("{0} paid {1} of {2}", user.FullName, string.Format("{0:0.###}", quantity), lineItem.Description);
            }

            var trackingEvent = new OrderTracking
            {
                User        = user,
                StatusCode  = order.StatusCode,
                Description = description
            };

            order.AddTracking(trackingEvent);

            if (string.IsNullOrWhiteSpace(overrideDescription))
            {
                _notificationService.OrderPaid(order, lineItem, user, quantity);
            }
            else
            {
                _notificationService.OrderPaid(order, lineItem, user, quantity, string.Format("{0} by {1}", description, user.FullName));
            }
        }
        public bool AddOrder(Order order)
        {
            if (order != null)
            {
                int orderId = GetLastOrderId();
                order.OrderNumber = ++orderId;
                order.Status      = OrderStatus.Registered;

                Orders.Add(order);

                //сохраняем историю
                var newOrderTracking = new OrderTracking()
                {
                    ChangesCount         = 0,
                    Modified             = DateTime.Now,
                    ChangeType           = ChangeType.NoChanges,
                    OrderNumber          = order.OrderNumber,
                    Status               = order.Status,
                    Products             = order.Products,
                    Cost                 = order.Cost,
                    PostNumber           = order.PostNumber,
                    RecipientPhoneNumber = order.RecipientPhoneNumber,
                    RecipientFirstName   = order.RecipientFirstName,
                    RecipientLastName    = order.RecipientLastName,
                    RecipientMiddleName  = order.RecipientMiddleName
                };
                OrdersTracking.Add(newOrderTracking);

                return(true);
            }
            return(false);
        }
        public IHttpActionResult GetOrderTracking(string version, int UserId)
        {
            try
            {
                List <OrderTracking> objOrderList = new List <OrderTracking>();
                DataSet ds = new DataSet();
                ds = BzWebsite.GetOrderTracking(version, UserId);
                ds.Tables[0].TableName = "Orders";
                ds.Tables[1].TableName = "OrderItems";

                var Orders     = ds.Tables["Orders"].AsEnumerable();
                var OrderItems = ds.Tables["OrderItems"].AsEnumerable();
                //var kgpBrands = ds1.Tables["KGPBrands"].AsEnumerable();
                foreach (var item in Orders)
                {
                    OrderTracking objOrder = new OrderTracking();
                    objOrder.OrderId        = item.Field <int>("OrderId");
                    objOrder.TotalSaleValue = item.Field <decimal>("TotalSaleValue");
                    objOrder.DeliveryCharge = item.Field <decimal>("DeliveryCharge");
                    objOrder.OrderStatus    = item.Field <string>("OrderStatus");
                    objOrder.OrderDate      = item.Field <string>("PurchasedDate");
                    List <OrderItems> objItems = new List <OrderItems>();

                    objOrder.OrderItems = objItems;
                    objOrderList.Add(objOrder);
                }
                foreach (var item1 in objOrderList)
                {
                    foreach (var item2 in OrderItems)
                    {
                        if (item2.Field <int>("OrderId") == item1.OrderId)
                        {
                            item1.OrderItems.Add(new OrderItems
                            {
                                // RecordId =item2.Field<long>("RecordId"),
                                PackageId     = item2.Field <int>("PackageId"),
                                ProductName   = item2.Field <string>("ProductName"),
                                TechnicalName = item2.Field <string>("TechnicalName"),
                                OrderStatus   = item2.Field <string>("OrderStatus"),
                                OrderDate     = item2.Field <string>("PurchasedDate"),
                                DeliveryDate  = item2.Field <string>("DeilveredDate"),
                                Quantity      = item2.Field <short>("Quantity"),
                                PackSize      = item2.Field <string>("PackSize"),
                                UnitPrice     = item2.Field <decimal>("UnitPrice"),
                                SaleValue     = item2.Field <decimal>("SaleValue"),
                                ImagePath     = item2.Field <string>("ImagePath")
                            });
                        }
                    }
                }
                return(Ok(new { Orders = objOrderList, Status = true }));
            }
            catch (Exception ex)
            {
                LogDal.ErrorLog(this.GetType().Name, MethodBase.GetCurrentMethod().Name, ex.Message, 0);
                return(Ok(new { KGPApiReponse = "", Status = false }));
            }
        }
Beispiel #7
0
        public ActionResult CurrentData(DataManager dm)
        {
            context.Configuration.ProxyCreationEnabled = false;
            //var RFSOfacilities = new UserManagement().getUserFacilityList();
            //int? facility_id = -1;
            //if (new UserManagement().getCurrentuserFacility() != null)
            //    facility_id = new UserManagement().getCurrentuserFacility();
            //var RFSOfacilities = new UserManagement().getUserFacilityList();
            int?facility_id = -1;

            if (new UserManagement().getCurrentuserFacility() != null)
            {
                facility_id = new UserManagement().getCurrentuserFacility();
            }
            var RFSOfacilities = new UserManagement().getUserFacilityList();

            OrderTracking obj   = new OrderTracking();
            IEnumerable   data  = context.View_Order_TrackingModule_1.Where(b => (b.OrderStatusId == 6 || b.OrderStatusId == 4 || b.OrderStatusId == 7 || b.OrderStatusId == 8 || b.OrderStatusId == 9 || b.OrderStatusId == 2 || b.OrderStatusId == 3) && b.FacilityCode == 99999).OrderByDescending(a => a.OrderStatusDateChanged).ToList();
            int           count = context.View_Order_TrackingModule_1.Where(b => (b.OrderStatusId == 6 || b.OrderStatusId == 4 || b.OrderStatusId == 7 || b.OrderStatusId == 8 || b.OrderStatusId == 9 || b.OrderStatusId == 2 || b.OrderStatusId == 3) && b.FacilityCode == 99999).OrderByDescending(a => a.OrderStatusDateChanged).ToList().Count;

            DataOperations operation = new DataOperations();

            //Performing filtering operation
            if (dm.Where != null)
            {
                data = operation.PerformWhereFilter(data, dm.Where, "and");
                var filtered = (IEnumerable <object>)data;
                count = filtered.Count();
            }
            //Performing search operation
            if (dm.Search != null)
            {
                data = operation.PerformSearching(data, dm.Search);
                var searched = (IEnumerable <object>)data;
                count = searched.Count();
            }
            //Performing sorting operation
            if (dm.Sorted != null)
            {
                data = operation.PerformSorting(data, dm.Sorted);
            }

            //Performing paging operations
            if (dm.Skip > 0)
            {
                data = operation.PerformSkip(data, dm.Skip);
            }
            if (dm.Take > 0)
            {
                data = operation.PerformTake(data, dm.Take);
            }

            return(Json(new { result = data, count = count }, JsonRequestBehavior.AllowGet));
            //return Json(data, JsonRequestBehavior.AllowGet);
        }
Beispiel #8
0
        public static OrderTracking OrderTracking(int?counter)
        {
            var rtValue = new OrderTracking();

            rtValue.DateCreated = DateTime.UtcNow.ToPacificTime();
            rtValue.Description = "Description" + counter.Extra();
            rtValue.Order       = new Order();
            rtValue.StatusCode  = new OrderStatusCode();

            return(rtValue);
        }
        public void OrderUpdated(Order order, string whatWasUpdated)
        {
            var user          = _userRepository.GetById((_userIdentity.Current));
            var trackingEvent = new OrderTracking
            {
                User        = user,
                StatusCode  = order.StatusCode,
                Description = whatWasUpdated
            };

            order.AddTracking(trackingEvent);
        }
Beispiel #10
0
        public void OrderReRoutedToAccountManager(Order order, string external, string originalRouting, string routedTo)
        {
            var user = _userRepository.GetById((_userIdentity.Current));

            var trackingEvent = new OrderTracking
            {
                User        = user,
                StatusCode  = order.StatusCode,
                Description = string.Format("{0}approval routed to {1} from {2}", external, routedTo, originalRouting)
            };

            order.AddTracking(trackingEvent);
        }
Beispiel #11
0
        public void OrderReRoutedToPurchaser(Order order, string routedTo)
        {
            var user = _userRepository.GetById(_userIdentity.Current);

            var trackingEvent = new OrderTracking
            {
                User        = user,
                StatusCode  = order.StatusCode,
                Description = string.Format("rerouted to purchaser {0}", routedTo)
            };

            order.AddTracking(trackingEvent);
        }
Beispiel #12
0
        public void OrderReRouted(Order order)
        {
            var trackingEvent = new OrderTracking
            {
                User        = _userRepository.GetById(_userIdentity.Current),
                StatusCode  = order.StatusCode,
                Description = "edited & rerouted"
            };

            order.AddTracking(trackingEvent);

            _notificationService.OrderReRouted(order, order.StatusCode.Level);
        }
Beispiel #13
0
        public void OrderAutoApprovalAdded(Order order, Approval approval)
        {
            //_notificationService.OrderApproved(order, approval);

            var trackingEvent = new OrderTracking
            {
                User        = approval.User,
                StatusCode  = approval.StatusCode,
                Description = "automatically approved"                         //TODO: what info do we want here?
            };

            order.AddTracking(trackingEvent);
        }
Beispiel #14
0
        /// <summary>
        /// Call notification service, THEN add the tracking.
        /// </summary>
        /// <param name="order">Order's status is at the current level</param>
        /// <param name="approval">Approval is at the current level, and completed is true</param>
        public void OrderApproved(Order order, Approval approval)
        {
            var trackingEvent = new OrderTracking
            {
                User        = _userRepository.GetById(_userIdentity.Current),
                StatusCode  = approval.StatusCode,
                Description = "approved"
            };

            order.AddTracking(trackingEvent);

            _notificationService.OrderApproved(order, approval);
        }
Beispiel #15
0
        public void OrderCancelled(Order order, string comment, OrderStatusCode previousStatus)
        {
            var user = _userRepository.GetById(_userIdentity.Current);

            var trackingEvent = new OrderTracking
            {
                User        = user,
                StatusCode  = order.StatusCode,
                Description = "cancelled"
            };

            order.AddTracking(trackingEvent);

            _notificationService.OrderCancelled(order, user, comment, previousStatus);
        }
Beispiel #16
0
        public void OrderCompleted(Order order)
        {
            var user = _userRepository.GetById(_userIdentity.Current);

            var trackingEvent = new OrderTracking
            {
                User        = user,
                StatusCode  = order.StatusCode,
                Description = "completed"
            };

            order.AddTracking(trackingEvent);

            _notificationService.OrderCompleted(order, user);
        }
Beispiel #17
0
        public void OrderCreated(Order order)
        {
            order.GenerateRequestNumber();

            var trackingEvent = new OrderTracking
            {
                User        = _userRepository.GetById(_userIdentity.Current),
                StatusCode  = _orderStatusCodeRepository.GetById(OrderStatusCode.Codes.Requester),
                Description = "created"
            };

            order.AddTracking(trackingEvent);

            _notificationService.OrderCreated(order);
        }
        public bool AlterOrder(int orderNumber, Order alteredOrder)
        {
            var order = Orders.Where(c => c.OrderNumber == orderNumber).FirstOrDefault();

            if (order != null)
            {
                order.Cost = alteredOrder.Cost ?? order.Cost;
                order.RecipientPhoneNumber = alteredOrder.RecipientPhoneNumber ?? order.RecipientPhoneNumber;
                order.RecipientFirstName   = alteredOrder.RecipientFirstName ?? order.RecipientFirstName;
                order.RecipientLastName    = alteredOrder.RecipientLastName ?? order.RecipientLastName;
                order.RecipientMiddleName  = alteredOrder.RecipientMiddleName ?? order.RecipientMiddleName;

                if (alteredOrder.Products.Count() == 0 || alteredOrder.Products == null)
                {
                    order.Products = order.Products;
                }
                else
                {
                    order.Products = alteredOrder.Products;
                }


                //сохраняем изменения
                var orderTracking = OrdersTracking.Where(c => c.OrderNumber == orderNumber).ToList();
                if (orderTracking.Count > 0)
                {
                    int trackingCount    = orderTracking.Count() - 1;
                    var newOrderTracking = new OrderTracking()
                    {
                        ChangesCount         = ++trackingCount,
                        Modified             = DateTime.Now,
                        ChangeType           = ChangeType.OrderContent,
                        OrderNumber          = order.OrderNumber,
                        Status               = order.Status,
                        Products             = order.Products,
                        Cost                 = order.Cost,
                        PostNumber           = order.PostNumber,
                        RecipientPhoneNumber = order.RecipientPhoneNumber,
                        RecipientFirstName   = order.RecipientFirstName,
                        RecipientLastName    = order.RecipientLastName,
                        RecipientMiddleName  = order.RecipientMiddleName
                    };
                    OrdersTracking.Add(newOrderTracking);
                }
                return(true);
            }
            return(false);
        }
Beispiel #19
0
        public async Task <Order> AddOrderWithoutPayment(OrderAddDto dto)
        {
            var cart = await _cartService.GetCartById(customerId : dto.CustomerId);

            var newOrder = _prepareOrderFromCart(cart);

            newOrder.PaymentMethodRef  = dto.PaymentMethodId.ToReference <PaymentMethod>();
            newOrder.ShippingMethodRef = dto.ShippingMethodId.ToReference <ShippingMethod>();
            newOrder.Trackings.Prepend(new OrderTracking
            {
                Description = OrderTracking.GetDescription(newOrder.OrderStatus),
                Status      = newOrder.OrderStatus
            });

            await Add(newOrder);

            await _cartService.ToggleActivationById(cart.ID, false);

            return(newOrder);
        }
Beispiel #20
0
        private void CambiarEstadoLogic(CambiarEstaudoViewModel viewModel)
        {
            Order order       = db.Orders.Where(x => x.Id == viewModel.Id).Include(x => x.OrderProducts).FirstOrDefault();
            int   oldStatudId = order.StatusId;

            order.StatusId = viewModel.StatusId;
            bool esValidoElCambio = false;

            //Verifico si el cambio de estado es correcto
            switch (oldStatudId)
            {
            case (int)StatusOrder.Solicitado:
                //El solicitado Puede pasar a Aceptado, rechazado
                esValidoElCambio = (order.StatusId == (int)StatusOrder.Aceptado || order.StatusId == (int)StatusOrder.Rechazado);
                break;

            case (int)StatusOrder.Aceptado:
                //El entregado Puede pasar a Solicitado, Entregado o rechazado
                esValidoElCambio = (order.StatusId == (int)StatusOrder.Solicitado || order.StatusId == (int)StatusOrder.Entregado || order.StatusId == (int)StatusOrder.Rechazado);
                break;

            case (int)StatusOrder.Rechazado:
                //El solicitado Puede pasar a Aceptado
                esValidoElCambio = (order.StatusId == (int)StatusOrder.Aceptado);
                break;

            case (int)StatusOrder.Entregado:
                //El solicitado Puede pasar a Aceptado
                esValidoElCambio = (order.StatusId == (int)StatusOrder.Aceptado);
                break;

            default:
                esValidoElCambio = false;
                break;
            }

            //if (esValidoElCambio == false)
            //    return Json(new { responseCode = "-10" });


            //Si el estado es Entregado hace una actualizacion automatica del stock
            if (order.StatusId == (int)StatusOrder.Entregado)
            {
                //Recupero los que productos que tiene dados de alta
                var centerProducts = db.CenterProducts.Where(x => x.CenterId == order.CenterId).ToList();

                foreach (var item in order.OrderProducts)
                {
                    var prod = centerProducts.Where(x => x.ProductId == item.ProductId).FirstOrDefault();
                    if (prod != null)
                    {
                        //Ya axiste
                        prod.Stock = prod.Stock + item.QuantityDelivered;
                        //products_upd.Add(prod);
                        db.Entry(prod).State = EntityState.Modified;
                    }
                    else
                    {
                        //Si no existe, lo impacto
                        CenterProduct centerProduct = new CenterProduct
                        {
                            CenterId  = item.Order.CenterId,
                            ProductId = item.ProductId,
                            Stock     = item.QuantityDelivered
                        };

                        db.CenterProducts.Add(centerProduct);
                    }
                }
            }


            db.Entry(order).State = EntityState.Modified;

            OrderTracking tracking = new OrderTracking
            {
                Fecha         = DateTime.Now,
                OrderId       = viewModel.Id,
                ToStatusId    = oldStatudId,
                SinceStatusId = viewModel.StatusId,
                UsuarioId     = SessionHelper.GetUser(),
                Observation   = viewModel.Observation
            };

            db.OrderTrackings.Add(tracking);

            db.SaveChanges();

            AuditHelper.Auditar("Modificacion", order.Id.ToString(), className, ModuleDescription, WindowDescription);
        }
Beispiel #21
0
        public JsonResult CreateOrder(OrderCreateViewModel orderCreate)
        {
            var responseObject = new
            {
                responseCode = -1
            };

            if (orderCreate == null)
            {
                return(Json(new { responseCode = "-10" }));
            }

            try
            {
                int centerId  = orderCreate.CenterId;
                int statusId  = (int)StatusOrder.Solicitado;
                int usuarioId = SessionHelper.GetUser();

                Order order = new Order
                {
                    CenterId       = centerId,
                    InitialDate    = DateTime.Now,
                    UsuarioId      = usuarioId,
                    StatusId       = statusId,
                    OrderProducts  = new List <OrderProduct>(),
                    OrderTrackings = new List <OrderTracking>()
                };

                foreach (var item in orderCreate.OrderProductViewModels)
                {
                    OrderProduct orderProduct = new OrderProduct
                    {
                        OrderId           = order.Id,
                        ProductId         = item.ProductId,
                        Quantity          = item.Quantity,
                        QuantityDelivered = 0,
                    };


                    order.OrderProducts.Add(orderProduct);
                }

                OrderTracking tracking = new OrderTracking
                {
                    OrderId    = order.Id,
                    ToStatusId = statusId,
                    UsuarioId  = usuarioId,
                    Fecha      = DateTime.Now
                };

                order.OrderTrackings.Add(tracking);

                //Obtengo el Max Numero de pedido y le sumo 1

                var maxNumeroPedido = db.Orders.Max(x => x.NroPedido);
                order.NroPedido = maxNumeroPedido + 1;
                db.Orders.Add(order);

                db.SaveChanges();

                AuditHelper.Auditar("Alta", order.Id.ToString(), className, ModuleDescription, WindowDescription);

                responseObject = new
                {
                    responseCode = 0
                };
            }
            catch (Exception e)
            {
                responseObject = new
                {
                    responseCode = -1
                };
            }

            return(Json(responseObject));
        }
 public void Delete(OrderTracking model)
 {
     _OrderTrackingRepository.Delete(model);
 }
        public List<OrderTracking> SetupOrderTracking(Order order)
        {
            var whenApproved = DateTime.UtcNow.ToPacificTime().AddDays(-10);
            var orderTracking = new List<OrderTracking>();

            var tracking = new OrderTracking();
            tracking.DateCreated = whenApproved;
            tracking.Description = "Description1";
            tracking.Order = order;
            tracking.StatusCode = OrderStatusCodeRepository.GetNullableById(OrderStatusCode.Codes.Requester);
            tracking.User = order.CreatedBy;
            orderTracking.Add(tracking);

            Order order1 = order;

            var count = 1;
            var approvals = ApprovalRepository.Queryable.Where(a => a.Order.Id == order1.Id && a.Completed).OrderBy(b => b.StatusCode.Level);
            foreach(var approval in approvals)
            {
                tracking = new OrderTracking();
                tracking.DateCreated = whenApproved.AddDays(count);
                tracking.Description = "Description" + count;
                tracking.Order = order;
                tracking.StatusCode = approval.StatusCode;
                tracking.User = approval.User;

                orderTracking.Add(tracking);
                count++;
            }

            return orderTracking;
        }
        public static OrderTracking OrderTracking(int? counter)
        {
            var rtValue = new OrderTracking();
            rtValue.DateCreated = DateTime.UtcNow.ToPacificTime();
            rtValue.Description = "Description" + counter.Extra();
            rtValue.Order = new Order();
            rtValue.StatusCode = new OrderStatusCode();

            return rtValue;
        }
 public void Insert(OrderTracking model)
 {
     _OrderTrackingRepository.Insert(model);
 }
 public void Update(OrderTracking model)
 {
     _OrderTrackingRepository.Update(model);
 }
Beispiel #27
0
        //OrderTrackingDetails.cshtml
        //public ActionResult OrderTrackingDetails()
        //{
        //    return View();
        //}
        public ActionResult GetData(DataManager dm)
        {
            context.Configuration.ProxyCreationEnabled = false;
            //var RFSOfacilities = new UserManagement().getUserFacilityList();
            int?facility_id = -1;

            if (new UserManagement().getCurrentuserFacility() != null)
            {
                facility_id = new UserManagement().getCurrentuserFacility();
            }
            var RFSOfacilities = new UserManagement().getUserFacilityList();

            int?   productcategory = null;
            string order_no        = null;

            var _ProductCategoryId = TempData.Peek("_ProductCategoryId");

            if (_ProductCategoryId != null)
            {
                productcategory = System.Convert.ToInt32(_ProductCategoryId);
            }

            var _OrderNumber = TempData.Peek("_OrderNumber");

            if (_OrderNumber != null)
            {
                order_no = _OrderNumber.ToString();
            }


            OrderTracking obj   = new OrderTracking();
            IEnumerable   data  = obj.GetTracking(productcategory, order_no).Where(b => b.FacilityCode == facility_id).OrderByDescending(a => a.OrderStatusDateChanged).ToList();
            int           count = obj.GetTracking(productcategory, order_no).Where(b => b.FacilityCode == facility_id).OrderByDescending(a => a.OrderStatusDateChanged).ToList().Count;

            DataOperations operation = new DataOperations();

            //Performing filtering operation
            if (dm.Where != null)
            {
                data = operation.PerformWhereFilter(data, dm.Where, "and");
                var filtered = (IEnumerable <object>)data;
                count = filtered.Count();
            }
            //Performing search operation
            if (dm.Search != null)
            {
                data = operation.PerformSearching(data, dm.Search);
                var searched = (IEnumerable <object>)data;
                count = searched.Count();
            }
            //Performing sorting operation
            if (dm.Sorted != null)
            {
                data = operation.PerformSorting(data, dm.Sorted);
            }

            //Performing paging operations
            if (dm.Skip > 0)
            {
                data = operation.PerformSkip(data, dm.Skip);
            }
            if (dm.Take > 0)
            {
                data = operation.PerformTake(data, dm.Take);
            }

            return(Json(new { result = data, count = count }, JsonRequestBehavior.AllowGet));
            //return Json(data, JsonRequestBehavior.AllowGet);
        }
Beispiel #28
0
        public ActionResult CurrentDataSearch(DataManager dm, int?productCateory, /* string order_no,*/ string startdate, string enddate)
        {
            context.Configuration.ProxyCreationEnabled = false;
            //var RFSOfacilities = new UserManagement().getUserFacilityList();
            //int? facility_id = -1;
            //if (new UserManagement().getCurrentuserFacility() != null)
            //    facility_id = new UserManagement().getCurrentuserFacility();
            //var RFSOfacilities = new UserManagement().getUserFacilityList();
            int?facility_id = -1;

            if (new UserManagement().getCurrentuserFacility() != null)
            {
                facility_id = new UserManagement().getCurrentuserFacility();
            }
            var RFSOfacilities = new UserManagement().getUserFacilityList();

            DateTime?sDate;
            DateTime?eDate;

            if ((startdate != null && startdate != "") || (enddate != null && enddate != ""))
            {
                sDate = DateTime.ParseExact(startdate, "dd/MM/yyyy", null);
                eDate = DateTime.ParseExact(enddate, "dd/MM/yyyy", null);
            }
            else
            {
                sDate = null; // Convert.ToDateTime(DBNull.Value);
                eDate = null; // Convert.ToDateTime(DBNull.Value);
            }
            // sDate = DateTime.ParseExact(startdate, "dd/MM/yyyy", null);
            //eDate = DateTime.ParseExact(enddate, "dd/MM/yyyy", null);

            OrderTracking obj   = new OrderTracking();
            IEnumerable   data  = context.View_Order_TrackingModule_1.Where(b => (b.OrderStatusId == 6 || b.OrderStatusId == 4 || b.OrderStatusId == 7 || b.OrderStatusId == 8 || b.OrderStatusId == 9 || b.OrderStatusId == 2 || b.OrderStatusId == 3) && (b.DatePrepared >= sDate || b.DatePrepared == null) && (b.DatePrepared <= eDate || b.DatePrepared == null) && (b.ProductCategoryId == productCateory || productCateory == null)).OrderByDescending(a => a.OrderStatusDateChanged).ToList();
            int           count = context.View_Order_TrackingModule_1.Where(b => (b.OrderStatusId == 6 || b.OrderStatusId == 4 || b.OrderStatusId == 7 || b.OrderStatusId == 8 || b.OrderStatusId == 9 || b.OrderStatusId == 2 || b.OrderStatusId == 3) && (b.DatePrepared >= sDate || b.DatePrepared == null) && (b.DatePrepared <= eDate || b.DatePrepared == null) && (b.ProductCategoryId == productCateory || productCateory == null)).OrderByDescending(a => a.OrderStatusDateChanged).ToList().Count;

            DataOperations operation = new DataOperations();

            //Performing filtering operation
            if (dm.Where != null)
            {
                data = operation.PerformWhereFilter(data, dm.Where, "and");
                var filtered = (IEnumerable <object>)data;
                count = filtered.Count();
            }
            //Performing search operation
            if (dm.Search != null)
            {
                data = operation.PerformSearching(data, dm.Search);
                var searched = (IEnumerable <object>)data;
                count = searched.Count();
            }
            //Performing sorting operation
            if (dm.Sorted != null)
            {
                data = operation.PerformSorting(data, dm.Sorted);
            }

            //Performing paging operations
            if (dm.Skip > 0)
            {
                data = operation.PerformSkip(data, dm.Skip);
            }
            if (dm.Take > 0)
            {
                data = operation.PerformTake(data, dm.Take);
            }

            //return Json(new { result = data, count = count }, JsonRequestBehavior.AllowGet);
            return(Json(data, JsonRequestBehavior.AllowGet));
        }