Exemple #1
0
        // GET http://ganetest.qsrtime.net/api/sync/orders/{reqDate}/{serialNo}
        // GET http://ganetest.qsrtime.net/api/sync/orders/2014-11-23/920013c000814
        public IHttpActionResult GetOrders(DateTime reqDate, string serialNo)
        {
            serialNo = serialNo.Trim().ToLower();

            var terminal = TerminalServices.GetTerminalBySerial(serialNo);

            if (terminal == null)
            {
                return(Unauthorized());
            }

            reqDate = TerminalServices.GetTerminalSyncDate(reqDate, terminal.TenantId);

            var result = new OrdersSyncCollection();

            var allOrders  = OrderService.GetAllOrders(terminal.TenantId, terminal.WarehouseId, true, reqDate, true).ToList();
            var warehouses = _lookupService.GetAllWarehousesForTenant(terminal.TenantId);
            var orders     = new List <OrdersSync>();

            foreach (var p in allOrders)
            {
                var order  = new OrdersSync();
                var mapped = AutoMapper.Mapper.Map(p, order);
                mapped.TransferWarehouseName = warehouses.FirstOrDefault(x => x.WarehouseId == mapped.TransferWarehouseId)?.WarehouseName;
                orders.Add(mapped);
            }

            result.Count         = orders.Count;
            result.TerminalLogId = TerminalServices.CreateTerminalLog(reqDate, terminal.TenantId, orders.Count, terminal.TerminalId, TerminalLogTypeEnum.OrdersSync).TerminalLogId;
            result.Orders        = orders;
            return(Ok(AutoMapper.Mapper.Map(result, new OrdersSyncCollection())));
        }
        public IHttpActionResult GetPalletDispatches(DateTime reqDate, string serialNo)
        {
            serialNo = serialNo.Trim().ToLower();

            var terminal = TerminalServices.GetTerminalBySerial(serialNo);

            if (terminal == null)
            {
                return(Unauthorized());
            }

            reqDate = TerminalServices.GetTerminalSyncDate(reqDate, terminal.TenantId);

            var result = new PalletsDispatchSyncCollection();

            var allPallets = _palletService.GetAllPalletsDispatch(null, reqDate);

            result.PalletDispatchSync = AutoMapper.Mapper.Map <List <PalletsDispatch>, List <PalletDispatchSync> >(allPallets);
            result.Count         = allPallets.Count;
            result.TerminalLogId = TerminalServices
                                   .CreateTerminalLog(reqDate, terminal.TenantId, allPallets.Count, terminal.TerminalId,
                                                      TerminalLogTypeEnum.PalletingSync).TerminalLogId;

            return(Ok(AutoMapper.Mapper.Map(result, new PalletsDispatchSyncCollection())));
        }
        // call example through URI http://localhost:8005/api/sync/get-order-receive-count?ReqDate=2014-11-23&SerialNo=920013c000814
        public IHttpActionResult GetOrderReceiveCount(DateTime reqDate, string serialNo)
        {
            serialNo = serialNo.Trim().ToLower();

            var terminal = TerminalServices.GetTerminalBySerial(serialNo);

            if (terminal == null)
            {
                return(Unauthorized());
            }

            reqDate = TerminalServices.GetTerminalSyncDate(reqDate, terminal.TenantId);

            var result = new OrderReceiveCountSyncCollection();
            var orderReceiveCountsSync = new List <OrderReceiveCountSync>();

            var allOrderReceiveCounts = OrderService.GetAllOrderReceiveCounts(terminal.TenantId, terminal.WarehouseId, reqDate).ToList();

            AutoMapper.Mapper.Map(allOrderReceiveCounts, orderReceiveCountsSync);


            result.Count                 = orderReceiveCountsSync.Count;
            result.TerminalLogId         = TerminalServices.CreateTerminalLog(reqDate, terminal.TenantId, orderReceiveCountsSync.Count(), terminal.TerminalId, TerminalLogTypeEnum.OrderReceiveCountSync).TerminalLogId;
            result.OrderReceiveCountSync = orderReceiveCountsSync;
            return(Ok(result));
        }
        // GET http://ganetest.qsrtime.net/api/sync/order-processes/{reqDate}/{serialNo}
        // GET http://ganetest.qsrtime.net/api/sync/order-processes/2014-11-23/920013c000814
        public IHttpActionResult GetOrderProcesses(DateTime reqDate, string serialNo)
        {
            serialNo = serialNo.Trim().ToLower();

            var terminal = TerminalServices.GetTerminalBySerial(serialNo);

            if (terminal == null)
            {
                return(Unauthorized());
            }

            reqDate = TerminalServices.GetTerminalSyncDate(reqDate, terminal.TenantId);

            var accounts = _accountServices.GetAllAccountsSelectList(terminal.TenantId);

            var result = new OrderProcessesSyncCollection();

            var allorderProcess = OrderService.GetAllOrderProcesses(reqDate, 0, null, null, true);

            var orderProcesses = new List <OrderProcessesSync>();

            foreach (var item in allorderProcess)
            {
                var pSync = new OrderProcessesSync();
                AutoMapper.Mapper.Map(item, pSync);

                var orderProcessDetails = new List <OrderProcessDetailSync>();

                foreach (var p in item.OrderProcessDetail)
                {
                    var order = new OrderProcessDetailSync();
                    var pd    = AutoMapper.Mapper.Map(p, order);
                    orderProcessDetails.Add(pd);
                }
                pSync.OrderProcessDetails = orderProcessDetails;
                orderProcesses.Add(pSync);
            }

            result.Count         = orderProcesses.Count;
            result.TerminalLogId = TerminalServices
                                   .CreateTerminalLog(reqDate, terminal.TenantId, orderProcesses.Count, terminal.TerminalId,
                                                      TerminalLogTypeEnum.OrderProcessSync).TerminalLogId;
            result.OrderProcesses = orderProcesses;
            return(Ok(AutoMapper.Mapper.Map(result, new OrderProcessesSyncCollection())));
        }
        // GET http://ganetest.qsrtime.net/api/sync/pallets/{reqDate}/{serialNo}
        // GET http://ganetest.qsrtime.net/api/sync/pallets/2014-11-23/920013c000814
        public IHttpActionResult GetPallets(DateTime reqDate, string serialNo)
        {
            serialNo = serialNo.Trim().ToLower();

            var terminal = TerminalServices.GetTerminalBySerial(serialNo);

            if (terminal == null)
            {
                return(Unauthorized());
            }

            reqDate = TerminalServices.GetTerminalSyncDate(reqDate, terminal.TenantId);

            var result = new PalletsSyncCollection();

            var allPallets  = _palletService.GetAllPallets(null, null, null, reqDate);
            var palletSyncs = new List <PalletSync>();

            foreach (var p in allPallets)
            {
                var mapped = AutoMapper.Mapper.Map(p, new PalletSync());

                if (p.Dispatch != null)
                {
                    mapped.IsDispatched  = p.DispatchTime.HasValue;
                    mapped.DateCompleted = p.Dispatch.DateCompleted;
                }
                mapped.DateUpdated        = p.DateUpdated;
                mapped.PalletDispatchInfo = AutoMapper.Mapper.Map <PalletsDispatch, PalletDispatchSync>(p.Dispatch);
                palletSyncs.Add(mapped);
            }

            result.Count         = palletSyncs.Count;
            result.TerminalLogId = TerminalServices
                                   .CreateTerminalLog(reqDate, terminal.TenantId, palletSyncs.Count, terminal.TerminalId,
                                                      TerminalLogTypeEnum.PalletingSync).TerminalLogId;
            result.Pallets = palletSyncs;
            return(Ok(AutoMapper.Mapper.Map(result, new PalletsSyncCollection())));
        }
        public IHttpActionResult GetPalletProducts(DateTime reqDate, string serialNo)
        {
            var terminal = TerminalServices.GetTerminalBySerial(serialNo);

            if (terminal == null)
            {
                return(Unauthorized());
            }

            reqDate = TerminalServices.GetTerminalSyncDate(reqDate, terminal.TenantId);

            var result = new PalletProductsSyncCollection
            {
                PalletProducts = _palletService.GetAllPalletProductsForSync(reqDate),
                SerialNo       = serialNo
            };

            result.Count         = result.PalletProducts.Count;
            result.TerminalLogId = TerminalServices.CreateTerminalLog(reqDate, terminal.TenantId, result.Count, terminal.TerminalId, TerminalLogTypeEnum.PalletProductsSync).TerminalLogId;

            return(Ok(result));
        }
Exemple #7
0
        public IHttpActionResult GetMyMarketJobs(DateTime reqDate, string serialNo, int userId)
        {
            serialNo = serialNo.Trim().ToLower();

            var terminal = TerminalServices.GetTerminalBySerial(serialNo);

            if (terminal == null)
            {
                return(Unauthorized());
            }

            reqDate = TerminalServices.GetTerminalSyncDate(reqDate, terminal.TenantId);

            var jobs   = _marketServices.GetAllResourceJobs(userId, reqDate, true);
            var result = new MarketJobsSyncCollection {
                Jobs = jobs.Select(m => AutoMapper.Mapper.Map <MarketJobAllocationModel, MyJobSync>(m)).ToList(), Count = jobs.Count
            };

            result.TerminalLogId = TerminalServices.CreateTerminalLog(reqDate, terminal.TenantId, jobs.Count, terminal.TerminalId, TerminalLogTypeEnum.MarketJobSync).TerminalLogId;

            return(Ok(result));
        }