Esempio n. 1
0
        public ActionResult DownLoadExcel()
        {
            List <OrderBookingListViewModel> orderData = new List <OrderBookingListViewModel>();

            string beginDateTime = SessionDispatchSearchModel.BeginDateTime.HasValue ? SessionDispatchSearchModel.BeginDateTime.Value.ToString("yyyy/MM/dd") : string.Empty;
            string endDateTime   = SessionDispatchSearchModel.EndDateTime.HasValue ? SessionDispatchSearchModel.EndDateTime.Value.ToString("yyyy/MM/dd") : string.Empty;
            string postalName    = string.Empty;

            if (SessionDispatchSearchModel.PostalCode.HasValue)
            {
                var queryPostal = _codeDetailService.GetLabel("PostalCode", SessionDispatchSearchModel.PostalCode.Value);
                if (!string.IsNullOrEmpty(queryPostal))
                {
                    postalName = queryPostal;
                }
            }

            string searchText = string.Format("任務調派查詢條件:起訖時間({0}~{1}),地區({2}),車主({3})", beginDateTime, endDateTime, postalName, SessionDispatchSearchModel.DriverName);

            //限制只能為公司報價的
            var user = _aspNetUsersService.GetUserModelByName(User.Identity.Name);

            SessionDispatchSearchModel.QuotedCompanyId = user.CompanyId;

            orderData = _bookingService.GetDispatchBookingList(SessionDispatchSearchModel);

            string searchDateStr = "任務調派報表_" + DateTime.Now.ToString("yyyyMMddHHmm");
            var    fileStream    = _bookingService.GenerateDispatchOrderXlsx(orderData, "任務調派報表", searchText, searchDateStr + ".xlsx");

            return(File(fileStream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "QueryOrderData.xlsx"));
        }
        public ActionResult DownLoadExcel()
        {
            List <OrderBookingListViewModel> orderData = new List <OrderBookingListViewModel>();
            ResponseViewModel result = new ResponseViewModel();

            string beginDateTime = SessionOrderSearchModel.BeginDateTime.HasValue ? SessionOrderSearchModel.BeginDateTime.Value.ToString("yyyy/MM/dd") : string.Empty;
            string endDateTime   = SessionOrderSearchModel.EndDateTime.HasValue ? SessionOrderSearchModel.EndDateTime.Value.ToString("yyyy/MM/dd") : string.Empty;

            string postalName = string.Empty;

            if (SessionOrderSearchModel.PostalCode.HasValue)
            {
                var queryPostal = _codeDetailService.GetLabel("PostalCode", SessionOrderSearchModel.PostalCode.Value);
                if (!string.IsNullOrEmpty(queryPostal))
                {
                    postalName = queryPostal;
                }
            }

            string searchText = string.Format("網路搶單查詢條件:起訖時間({0}~{1}),地區({2})", beginDateTime, endDateTime, postalName);

            // 限制只能為公司報價的
            var user = _aspNetUsersService.GetUserModelByName(User.Identity.Name);

            //不能顯示公司下的訂單
            SessionOrderSearchModel.ExcludeCompanyId = user.CompanyId;

            SessionOrderSearchModel.ProcessStatusList.Add((byte)BookingProcessStatusEnum.Quote);
            orderData = _bookingService.GetOrderBookingList(SessionOrderSearchModel);

            string searchDateStr = "網路搶單報表_" + DateTime.Now.ToString("yyyyMMddHHmm");
            var    fileStream    = _bookingService.GenerateGrabOrderXlsx(orderData, "網路搶單報表", searchText, searchDateStr + ".xlsx");

            return(File(fileStream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "QueryOrderData.xlsx"));
        }