Ejemplo n.º 1
0
        // GET http://localhost:8005/api/sync/vehicles/{reqDate}/{serialNo}
        public IHttpActionResult GetAllVehicles(DateTime reqDate, string serialNo)
        {
            serialNo = serialNo.Trim().ToLower();

            var terminal = TerminalServices.GetTerminalBySerial(serialNo);

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

            var result = new MarketVehiclesSyncCollection();

            var allVehicles = _marketServices.GetAllValidMarketVehicles(terminal.TenantId, reqDate, true).MarketVehicles;

            var results = new List <MarketVehiclesSync>();

            foreach (var p in allVehicles)
            {
                var sync   = new MarketVehiclesSync();
                var mapped = AutoMapper.Mapper.Map(p, sync);
                results.Add(mapped);
            }

            result.Count         = results.Count;
            result.TerminalLogId = TerminalServices.CreateTerminalLog(reqDate, terminal.TenantId, results.Count, terminal.TerminalId,
                                                                      TerminalLogTypeEnum.MarketVehiclesSync).TerminalLogId;
            result.Vehicles = results;
            return(Ok(result));
        }
        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));
        }
        public IHttpActionResult GetAccounts(DateTime reqDate, string serialNo)
        {
            serialNo = serialNo.Trim().ToLower();

            var terminal = TerminalServices.GetTerminalBySerial(serialNo);

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

            var result = new AccountSyncCollection();

            var allAccounts = _accountServices.GetAllValidAccounts(terminal.TenantId, EnumAccountType.All, null, reqDate, true);

            var accounts = new List <AccountSync>();

            foreach (var p in allAccounts)
            {
                var account       = new AccountSync();
                var mappedAccount = AutoMapper.Mapper.Map(p, account);
                mappedAccount.CountryName    = p.GlobalCountry.CountryName;
                mappedAccount.CurrencyName   = p.GlobalCurrency.CurrencyName;
                mappedAccount.PriceGroupName = p.TenantPriceGroups.Name;
                mappedAccount.PriceGroupID   = p.PriceGroupID;
                mappedAccount.FullAddress    = p.FullAddress;
                accounts.Add(mappedAccount);
            }

            result.Count         = accounts.Count;
            result.TerminalLogId = TerminalServices.CreateTerminalLog(reqDate, terminal.TenantId, accounts.Count(), terminal.TerminalId, TerminalLogTypeEnum.AccountsSync).TerminalLogId;
            result.Accounts      = accounts;
            return(Ok(result));
        }
Ejemplo n.º 5
0
        // call example through URI http://localhost:8005/api/sync/get-pallet-tracking?ReqDate=2014-11-23&SerialNo=920013c000814
        public IHttpActionResult GetPallettracking(DateTime reqDate, string serialNo)
        {
            serialNo = serialNo.Trim().ToLower();

            var terminal = TerminalServices.GetTerminalBySerial(serialNo);

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

            var result = new PalletTrackingSyncCollection();

            var allPallets = ProductServices.GetAllPalletTrackings(terminal.TenantId, terminal.WarehouseId, reqDate).ToList();
            var pallets    = new List <PalletTrackingSync>();

            foreach (var p in allPallets)
            {
                var pallet       = new PalletTrackingSync();
                var mappedPallet = AutoMapper.Mapper.Map(p, pallet);
                pallets.Add(mappedPallet);
            }

            result.Count              = pallets.Count;
            result.TerminalLogId      = TerminalServices.CreateTerminalLog(reqDate, terminal.TenantId, pallets.Count(), terminal.TerminalId, TerminalLogTypeEnum.PalletTrackingSync).TerminalLogId;
            result.PalletTrackingSync = pallets;
            return(Ok(result));
        }
        // GET http://localhost:8005/api/sync/productserials/{reqDate}/{serialNo}
        // GET http://localhost:8005/api/sync/productserials/2014-11-23/920013c000814
        public IHttpActionResult GetSerials(DateTime reqDate, string serialNo)
        {
            serialNo = serialNo.Trim().ToLower();

            var terminal = TerminalServices.GetTerminalBySerial(serialNo);

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

            var result = new ProductSerialSyncCollection();

            var allSerials = ProductServices.GetAllProductSerialsByTenantId(terminal.TenantId, reqDate);

            var serials = new List <ProductSerialSync>();

            foreach (var p in allSerials)
            {
                var serial       = new ProductSerialSync();
                var mappedSerial = AutoMapper.Mapper.Map(p, serial);
                serials.Add(mappedSerial);
            }

            result.Count          = serials.Count;
            result.TerminalLogId  = TerminalServices.CreateTerminalLog(reqDate, terminal.TenantId, serials.Count, terminal.TerminalId, TerminalLogTypeEnum.ProductSerialSync).TerminalLogId;
            result.ProductSerials = serials;
            return(Ok(result));
        }
        public IHttpActionResult GetTenantPriceGroupDetails(DateTime reqDate, string serialNo)
        {
            serialNo = serialNo.Trim().ToLower();

            var terminal = TerminalServices.GetTerminalBySerial(serialNo);

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

            var result = new TenantPriceGroupDetailSyncCollection();

            var allGroupDetails = _productPriceService.GetAllTenantPriceGroupDetails(terminal.TenantId, true).Where(x => (x.DateUpdated ?? x.DateCreated) >= reqDate).ToList();

            var groupDetails = new List <TenantPriceGroupDetailSync>();

            foreach (var p in allGroupDetails)
            {
                var detail = new TenantPriceGroupDetailSync();
                AutoMapper.Mapper.Map(p, detail);
                groupDetails.Add(detail);
            }

            result.Count         = groupDetails.Count;
            result.TerminalLogId = TerminalServices.CreateTerminalLog(reqDate, terminal.TenantId, groupDetails.Count(), terminal.TerminalId, TerminalLogTypeEnum.TenantPriceGroupDetailsSync).TerminalLogId;
            result.TenantPriceGroupDetailSync = groupDetails;
            return(Ok(result));
        }
        // GET http://localhost:8005/api/sync/inventorystocks/{reqDate}/{serialNo}
        // GET http://localhost:8005/api/sync/inventorystocks/2014-11-23/920013c000814
        public IHttpActionResult GetInventorystocks(DateTime reqDate, string serialNo)
        {
            serialNo = serialNo.Trim().ToLower();

            var terminal = TerminalServices.GetTerminalBySerial(serialNo);

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

            var result = new InventoryStockSyncCollection();

            var allInventoryStocks = ProductServices.GetAllInventoryStocks(terminal.TenantId, terminal.WarehouseId, reqDate);

            var inventoryStocks = new List <InventoryStockSync>();

            foreach (var p in allInventoryStocks)
            {
                var inventory = new InventoryStockSync();
                var mapped    = AutoMapper.Mapper.Map(p, inventory);
                inventoryStocks.Add(mapped);
            }

            result.Count           = inventoryStocks.Count;
            result.TerminalLogId   = TerminalServices.CreateTerminalLog(reqDate, terminal.TenantId, inventoryStocks.Count, terminal.TerminalId, TerminalLogTypeEnum.InventoryStockSync).TerminalLogId;
            result.InventoryStocks = inventoryStocks;
            return(Ok(result));
        }
Ejemplo n.º 9
0
        public IHttpActionResult VanSalesDailyReport(VanSalesDailyCashSync model)
        {
            var serialNumber = model.SerialNumber.Trim().ToLower();

            var terminal = TerminalServices.GetTerminalBySerial(serialNumber);

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

            var TransactionLog = TerminalServices.CheckTransactionLog(model.TransactionLogId, terminal.TerminalId);

            if (TransactionLog == true)
            {
                return(Conflict());
            }

            model.TenantId = terminal.TenantId;


            var result = _vanSalesService.SaveVanSalesDailyReport(model);

            var terminalLog = TerminalServices.CreateTerminalLog(DateTime.UtcNow, terminal.TenantId, 0, terminal.TerminalId, TerminalLogTypeEnum.VanSalesDailyReport).TerminalLogId;

            var report = Mapper.Map <VanSalesDailyCash, VanSalesDailyCashSync>(result);

            report.UserId       = model.UserId;
            report.SerialNumber = model.SerialNumber;
            report.TerminalId   = model.TerminalId;
            return(Ok(report));
        }
        // GET http://localhost:8005/api/sync/stocktakes/{reqDate}/{serialNo}
        // GET http://localhost:8005/api/sync/stocktakes/2014-11-23/920013c000814
        public IHttpActionResult GetStockTakes(DateTime reqDate, string serialNo)
        {
            serialNo = serialNo.Trim().ToLower();

            var terminal = TerminalServices.GetTerminalBySerial(serialNo);

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

            var result = new StockTakeSyncCollection();

            var allstockTakes = _stockTakeApiService.GetAllStockTakes(terminal.TenantId, terminal.WarehouseId, reqDate, true);

            var stockTakes = new List <StockTakeSync>();

            foreach (var p in allstockTakes)
            {
                var stockTake = new StockTakeSync();
                var mapped    = AutoMapper.Mapper.Map(p, stockTake);
                mapped.StockTakeStatusId = p.Status;
                mapped.WarehouseName     = p.TenantWarehouse.WarehouseName;
                stockTakes.Add(mapped);
            }

            result.Count         = stockTakes.Count;
            result.TerminalLogId = TerminalServices
                                   .CreateTerminalLog(reqDate, terminal.TenantId, stockTakes.Count, terminal.TerminalId,
                                                      TerminalLogTypeEnum.StockTakeSync).TerminalLogId;
            result.StockTakes = stockTakes;
            return(Ok(result));
        }
        // GET http://localhost:8005/api/sync/product-stock/{serialNo}/{productId}
        public IHttpActionResult GetInventoryStockForProduct(string serialNo, int productId, int warehouseId)
        {
            serialNo = serialNo.Trim().ToLower();

            var terminal = TerminalServices.GetTerminalBySerial(serialNo);

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

            var result = new InventoryStockSync();

            var inventoryStock = ProductServices.GetInventoryStocksByProductAndTenantLocation(productId, warehouseId);

            result = AutoMapper.Mapper.Map(inventoryStock, result);
            if (result != null)
            {
                result.LocationDetails = _commonDbServices.LocationsByProductDetails(productId, warehouseId);

                result.Count = result.LocationDetails.ProductDetails.Count;

                result.TerminalLogId = TerminalServices
                                       .CreateTerminalLog(DateTime.UtcNow, terminal.TenantId, 1, terminal.TerminalId,
                                                          TerminalLogTypeEnum.InventoryStockSync).TerminalLogId;

                return(Ok(result));
            }
            return(BadRequest("No stock information available for the requested product in the warehouse."));
        }
Ejemplo n.º 12
0
        // GET http://localhost:8005/api/sync/vehicles/{serialNo}
        public IHttpActionResult GetAllMarketSchedules(string serialNo, DateTime reqDate)
        {
            serialNo = serialNo.Trim().ToLower();

            var terminal = TerminalServices.GetTerminalBySerial(serialNo);

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


            var result = new MarketRouteScheduleSyncCollection();

            var allRouteSchedules = _vanSalesService.GetAllMarketRouteSchedules(terminal.TenantId, reqDate);

            var results = new List <MarketRouteScheduleSync>();

            foreach (var p in allRouteSchedules)
            {
                var sync   = new MarketRouteScheduleSync();
                var mapped = Mapper.Map(p, sync);
                results.Add(mapped);
            }

            result.Count                = results.Count;
            result.TerminalLogId        = TerminalServices.CreateTerminalLog(reqDate, terminal.TenantId, results.Count, terminal.TerminalId, TerminalLogTypeEnum.MarketRouteScheduleSync).TerminalLogId;
            result.MarketRouteSchedules = results;
            return(Ok(result));
        }
        // GET: api/HandheldUserSync
        // call example through URI http://localhost:8005/api/GetProducts?ReqDate=2014-11-23&SerialNo=920013c000814
        public IHttpActionResult GetProducts(DateTime reqDate, string serialNo)
        {
            serialNo = serialNo.Trim().ToLower();

            var terminal = TerminalServices.GetTerminalBySerial(serialNo);

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

            var result = new ProductMasterSyncCollection();

            var allProducts = ProductServices.GetAllValidProductMasters(terminal.TenantId, reqDate, true);
            var products    = new List <ProductMasterSync>();

            foreach (var p in allProducts)
            {
                var product       = new ProductMasterSync();
                var mappedProduct = AutoMapper.Mapper.Map(p, product);
                mappedProduct.ProductGroupName = p.Name;
                mappedProduct.DepartmentName   = p.TenantDepartment.DepartmentName;
                mappedProduct.TaxPercent       = p.GlobalTax.PercentageOfAmount;
                products.Add(mappedProduct);
            }

            result.Count         = products.Count;
            result.TerminalLogId = TerminalServices.CreateTerminalLog(reqDate, terminal.TenantId, products.Count(), terminal.TerminalId, TerminalLogTypeEnum.ProductsSync).TerminalLogId;
            result.Products      = products;
            return(Ok(result));
        }
Ejemplo n.º 14
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())));
        }
        // POST http://ganetest.qsrtime.net/api/sync/post-order-processes
        public async Task <IHttpActionResult> PostOrderProcesses(OrderProcessesSyncCollection data)
        {
            data.SerialNo = data.SerialNo.Trim().ToLower();

            var terminal = TerminalServices.GetTerminalBySerial(data.SerialNo);

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

            var TransactionLog = TerminalServices.CheckTransactionLog(data.TransactionLogId, terminal.TerminalId);

            if (TransactionLog == true)
            {
                return(Conflict());
            }

            var mobileLocation = TerminalServices.GetMobileLocationByTerminalId(terminal.TerminalId);

            if (mobileLocation != null)
            {
                terminal.WarehouseId = mobileLocation.WarehouseId;
            }

            var results = new List <OrdersSync>();

            if (data.OrderProcesses != null && data.OrderProcesses.Any())
            {
                var groupedOrderProcesses = data.OrderProcesses.GroupBy(p => p.OrderToken, (key, g) => new { OrderToken = key, OrderProcesses = g.ToList() });

                foreach (var processGroup in groupedOrderProcesses)
                {
                    var orderProcesses = processGroup.OrderProcesses;
                    foreach (var item in orderProcesses)
                    {
                        var order = OrderService.SaveOrderProcessSync(item, terminal);

                        results.Add(order);

                        if (order.OrderStatusID == (int)OrderStatusEnum.AwaitingAuthorisation)
                        {
                            OrderViewModel orderViewModel = new OrderViewModel();
                            orderViewModel.OrderID   = order.OrderID;
                            orderViewModel.TenentId  = order.TenentId;
                            orderViewModel.AccountID = order.AccountID;
                            await _configHelper.CreateTenantEmailNotificationQueue($"#{order.OrderNumber} - Order Requires Authorisation", orderViewModel, null, shipmentAndRecipientInfo : null,
                                                                                   worksOrderNotificationType : WorksOrderNotificationTypeEnum.AwaitingOrderTemplate);
                        }
                    }
                }
            }

            TerminalServices.CreateTerminalLog(DateTime.UtcNow, terminal.TenantId, data.OrderProcesses.Count, terminal.TerminalId, TerminalLogTypeEnum.OrderProcessesPost);

            return(Ok(results));
        }
        // 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())));
        }
Ejemplo n.º 17
0
        // POST http://localhost:8005/api/sync/post-pallet-tracking
        public IHttpActionResult PostPallettracking(PalletTrackingSyncCollection data)
        {
            data.SerialNo = data.SerialNo.Trim().ToLower();

            var terminal = TerminalServices.GetTerminalBySerial(data.SerialNo);

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

            var TransactionLog = TerminalServices.CheckTransactionLog(data.TransactionLogId, terminal.TerminalId);

            if (TransactionLog == true)
            {
                return(Conflict());
            }

            var mobileLocation = TerminalServices.GetMobileLocationByTerminalId(terminal.TerminalId);

            if (mobileLocation != null)
            {
                terminal.WarehouseId = mobileLocation.WarehouseId;
            }

            var results = new PalletTrackingSyncCollection();

            if (data.PalletTrackingSync != null && data.PalletTrackingSync.Any())
            {
                foreach (var item in data.PalletTrackingSync)
                {
                    item.DateUpdated = DateTime.UtcNow;
                    var pallet = ProductServices.SavePalletTrackings(item, terminal.TenantId);

                    results.PalletTrackingSync.Add(pallet);
                    results.Count += 1;
                }
            }

            TerminalServices.CreateTerminalLog(DateTime.UtcNow, terminal.TenantId, data.PalletTrackingSync.Count, terminal.TerminalId, TerminalLogTypeEnum.PostPalletTracking);

            return(Ok(results));
        }
        // POST http://localhost:8005/api/sync/post-order-receive-count
        public IHttpActionResult PostOrderReceiveCount(OrderReceiveCountSyncCollection data)
        {
            data.SerialNo = data.SerialNo.Trim().ToLower();

            var terminal = TerminalServices.GetTerminalBySerial(data.SerialNo);

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

            var TransactionLog = TerminalServices.CheckTransactionLog(data.TransactionLogId, terminal.TerminalId);

            if (TransactionLog == true)
            {
                return(Conflict());
            }

            var mobileLocation = TerminalServices.GetMobileLocationByTerminalId(terminal.TerminalId);

            if (mobileLocation != null)
            {
                terminal.WarehouseId = mobileLocation.WarehouseId;
            }

            var results = new OrderReceiveCountSyncCollection();

            if (data.OrderReceiveCountSync != null && data.OrderReceiveCountSync.Any())
            {
                foreach (var item in data.OrderReceiveCountSync)
                {
                    var countRecord = OrderService.SaveOrderReceiveCount(item, terminal);

                    results.OrderReceiveCountSync.Add(countRecord);
                    results.Count += 1;
                }
            }

            TerminalServices.CreateTerminalLog(DateTime.UtcNow, terminal.TenantId, data.OrderReceiveCountSync.Count, terminal.TerminalId, TerminalLogTypeEnum.PostOrderReceiveCount);

            return(Ok(results));
        }
Ejemplo n.º 19
0
        //http://ganetest.qsrtime.net/api/sync/my-holidays
        public IHttpActionResult GetUserHolidayRequests(string serialNo, DateTime reqDate, int userId)
        {
            var serialNumber = serialNo.Trim().ToLower();

            var terminal = TerminalServices.GetTerminalBySerial(serialNumber);

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

            var result = new HolidaySyncCollection();

            result.HolidayResponseSync = _employeeServices.GetUserHolidays(userId, reqDate, true);

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

            return(Ok(result));
        }
Ejemplo n.º 20
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));
        }
        // 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 GetPalletDispatchMethods(DateTime reqDate, string serialNo)
        {
            var terminal = TerminalServices.GetTerminalBySerial(serialNo);

            if (terminal == null)
            {
                return(Unauthorized());
            }
            var result = new PalletDispatchMethodSyncCollection()
            {
                PalletDispatchMethods = _palletService.GetAllSentMethods().Select(m => new PalletDispatchMethodSync()
                {
                    SentMethod = m.Name, SentMethodID = m.SentMethodID
                }).ToList(),
                SerialNo = serialNo
            };

            result.Count         = result.PalletDispatchMethods.Count();
            result.TerminalLogId = TerminalServices
                                   .CreateTerminalLog(reqDate, terminal.TenantId, result.Count, terminal.TerminalId, TerminalLogTypeEnum.PalletDispatchMethodsSync).TerminalLogId;
            return(Ok(result));
        }
        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));
        }
Ejemplo n.º 24
0
        public IHttpActionResult GetAllVehicleCheckLists(string serialNo, DateTime reqDate)
        {
            serialNo = serialNo.Trim().ToLower();

            var terminal = TerminalServices.GetTerminalBySerial(serialNo);

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

            var result = new VehiclesInspectionChecklistSyncCollection
            {
                Vehicles = _vanSalesService.GetAllValidVehicleInspectionCheckList(terminal.TenantId, reqDate, true)
                           .Select(Mapper.Map <InspectionCheckListViewModel, VehicleInspectionChecklistSync>)
                           .ToList()
            };

            result.Count         = result.Vehicles.Count;
            result.TerminalLogId = TerminalServices.CreateTerminalLog(reqDate, terminal.TenantId, result.Vehicles.Count, terminal.TerminalId, TerminalLogTypeEnum.VehicleCheckLists).TerminalLogId;
            return(Ok(result));
        }
Ejemplo n.º 25
0
        //GET http://localhost:8005/api/sync/users/{reqDate}/{serialNo}
        //GET http://localhost:8005/api/sync/users/2014-11-23/920013c000814
        public IHttpActionResult GetUsers(DateTime reqDate, string serialNo)
        {
            serialNo = serialNo.Trim().ToLower();

            Terminals terminal = TerminalServices.GetTerminalBySerial(serialNo);

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

            var             users    = UserService.GetAuthUsersByTenantAndDateUpdated(terminal.TenantId, reqDate);
            List <UserSync> newUsers = new List <UserSync>();

            foreach (var usr in users)
            {
                UserSync newUser = new UserSync();
                newUser.UserId = usr.UserId;

                var resourceId = UserService.GetResourceIdByUserId(usr.UserId);
                newUser.IsResource = resourceId > 0;
                newUser.ResourceId = resourceId;

                newUser.Username = usr.UserName;
                newUser.Password = usr.UserPassword;
                newUser.Name     = usr.DisplayName;
                newUser.IsActive = usr.IsActive;

                newUser.IsDeleted   = usr.IsDeleted;
                newUser.DateUpdated = usr.DateUpdated;

                //get parent warehouse to check permissions
                int warehouseId = terminal.WarehouseId;

                var location = _tenantLocationServices.GetActiveTenantLocationById(terminal.WarehouseId);

                if (location.IsMobile == true)
                {
                    warehouseId = location.ParentWarehouseId ?? warehouseId;
                }

                newUser.PurchaseOrderPerm          = _activityServices.PermCheck("Handheld", "PurchaseOrderPerm", usr.UserId, warehouseId);
                newUser.SalesOrderPerm             = _activityServices.PermCheck("Handheld", "SalesOrderPerm", usr.UserId, warehouseId);
                newUser.TransferOrderPerm          = _activityServices.PermCheck("Handheld", "TransferOrderPerm", usr.UserId, warehouseId);
                newUser.GoodsReturnPerm            = _activityServices.PermCheck("Handheld", "GoodsReturnPerm", usr.UserId, warehouseId);
                newUser.StockTakePerm              = _activityServices.PermCheck("Handheld", "StockTakePerm", usr.UserId, warehouseId);
                newUser.PalletingPerm              = _activityServices.PermCheck("Handheld", "PalletingPerm", usr.UserId, warehouseId);
                newUser.WorksOrderPerm             = _activityServices.PermCheck("Handheld", "WorksOrderPerm", usr.UserId, warehouseId);
                newUser.MarketRoutesPerm           = _activityServices.PermCheck("Handheld", "MarketRoutesPerm", usr.UserId, warehouseId);
                newUser.RandomJobsPerm             = _activityServices.PermCheck("Handheld", "RandomJobsPerm", usr.UserId, warehouseId);
                newUser.PODPerm                    = _activityServices.PermCheck("Handheld", "PODPerm", usr.UserId, warehouseId);
                newUser.StockEnquiryPerm           = _activityServices.PermCheck("Handheld", "StockEnquiryPerm", usr.UserId, warehouseId);
                newUser.EndOfDayPerm               = _activityServices.PermCheck("Handheld", "EndOfDayPerm", usr.UserId, warehouseId);
                newUser.HolidaysPerm               = _activityServices.PermCheck("Handheld", "HolidaysPerm", usr.UserId, warehouseId);
                newUser.AddProductsOnScan          = _activityServices.PermCheck("Handheld", "AddProductsOnScan", usr.UserId, warehouseId);
                newUser.DirectSalesPerm            = _activityServices.PermCheck("Handheld", "DirectSalesPerm", usr.UserId, warehouseId);
                newUser.WastagesPerm               = _activityServices.PermCheck("Handheld", "WastagesPerm", usr.UserId, warehouseId);
                newUser.GeneratePalletLabelsPerm   = _activityServices.PermCheck("Handheld", "GeneratePalletLabelsPerm", usr.UserId, warehouseId);
                newUser.GoodsReceiveCountPerm      = _activityServices.PermCheck("Handheld", "GoodsReceiveCountPerm", usr.UserId, warehouseId);
                newUser.HandheldOverridePerm       = _activityServices.PermCheck("Handheld", "HandheldOverridePerm", usr.UserId, warehouseId);
                newUser.ExchangeOrdersPerm         = _activityServices.PermCheck("Handheld", "ExchangeOrdersPerm", usr.UserId, warehouseId);
                newUser.AllowModifyPriceInTerminal = _activityServices.PermCheck("Handheld", "AllowModifyPriceInTerminal", usr.UserId, warehouseId);
                newUser.PrintBarcodePerm           = _activityServices.PermCheck("Handheld", "PrintBarcodePerm", usr.UserId, warehouseId);
                newUser.PendingOrdersPerm          = _activityServices.PermCheck("Handheld", "PendingOrdersPerm", usr.UserId, warehouseId);

                newUsers.Add(newUser);
            }

            int count = users.Count();

            try
            {
                UsersSyncCollection collection = new UsersSyncCollection
                {
                    Count         = count,
                    TerminalLogId = TerminalServices
                                    .CreateTerminalLog(reqDate, terminal.TenantId, count, terminal.TerminalId,
                                                       TerminalLogTypeEnum.UsersSync).TerminalLogId,
                    Users = newUsers
                };

                return(Ok(collection));
            }
            catch (Exception ex)
            {
                throw new Exception("Exception while getting user sync collection - " + ex.Message.ToString(), ex.InnerException);
            }
        }
Ejemplo n.º 26
0
        public IHttpActionResult GetMyMarketRoutes(DateTime reqDate, string serialNo)
        {
            serialNo = serialNo.Trim().ToLower();

            var terminal = TerminalServices.GetTerminalBySerial(serialNo);

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

            var result = new MarketRouteSyncCollection();

            var warehouseId = terminal.WarehouseId;

            var mobileLocation = TerminalServices.GetMobileLocationByTerminalId(terminal.TerminalId);

            if (mobileLocation != null)
            {
                warehouseId = mobileLocation.WarehouseId;
            }

            var allRoutes = _vanSalesService.GetMyMarketRoutes(terminal.TenantId, warehouseId, reqDate);

            var results = new List <MarketRouteSync>();

            foreach (var p in allRoutes)
            {
                DateTime       nextAppointment = DateTime.MinValue;
                DateTime       lastAppointment = DateTime.MinValue;
                RecurrenceInfo info            = new RecurrenceInfo();
                var            appt            = _vanSalesService.GetMarketRouteScheduleById(p.RouteScheduleId);

                Appointment newAppt = DevExpress.XtraScheduler.Compatibility.StaticAppointmentFactory.CreateAppointment(AppointmentType.Pattern);
                newAppt.RecurrenceInfo.FromXml(appt.RecurrenceInfo);
                newAppt.Start = appt.StartTime;
                newAppt.End   = appt.EndTime;

                if (appt.RecurrenceInfo != null)
                {
                    info.FromXml(appt.RecurrenceInfo);

                    OccurrenceCalculator calc = OccurrenceCalculator.CreateInstance(info);
                    nextAppointment = calc.FindNextOccurrenceTimeAfter(new DateTime(reqDate.Year, reqDate.Month, reqDate.Day, 0, 0, 0), newAppt);

                    if (!newAppt.SameDay && nextAppointment.Date != reqDate.Date)
                    {
                        var reqDate2 = reqDate.AddDays(-1);
                        nextAppointment = calc.FindNextOccurrenceTimeAfter(new DateTime(reqDate2.Year, reqDate2.Month, reqDate2.Day, 0, 0, 0), newAppt);
                    }
                }

                else
                {
                    nextAppointment = newAppt.Start;

                    if (!newAppt.SameDay && nextAppointment.Date != reqDate.Date)
                    {
                        nextAppointment = newAppt.Start.AddDays(1);
                    }
                }

                if (reqDate.Date == nextAppointment.Date && appt.WarehouseId == warehouseId || (!newAppt.SameDay && reqDate.Date == nextAppointment.Date.AddDays(1)))
                {
                    var sync   = new MarketRouteSync();
                    var mapped = Mapper.Map(p, sync);
                    results.Add(mapped);
                }
            }

            result.Count         = results.Count;
            result.TerminalLogId = TerminalServices.CreateTerminalLog(reqDate, terminal.TenantId, results.Count, terminal.TerminalId, TerminalLogTypeEnum.DayMarketRouteSync).TerminalLogId;
            result.MarketRoutes  = results;
            return(Ok(result));
        }