示例#1
0
        public async Task <FileResult> Download()
        {
            var products = await productQueries.Gets("p.is_used = 1");

            var excelInputType = new ExcelInputData()
            {
                SheetName = "VehicleType",
                Header    = new string[17] {
                    "Mã Danh Mục",
                    "Mã Sản Phẩm",
                    "Tên Sản Phẩm",
                    "Giá Thùng",
                    "Giá Lẻ",
                    "Số Lẻ Trên Thùng",
                    "Số Lượng",
                    "Đơn Vị",
                    "Đơn Vị Quy Đổi",
                    "Trọng Lượng (kg)",
                    "Thể Tích (m3)",
                    "Ngày Bắt Đầu",
                    "Ngày Kết Thúc",
                    "Mã Sản Phẩm Cha",
                    "Thuộc Tính Sản Phẩm",
                    "Serial Sản Phẩm",
                    "Nhiệt Độ"
                },
                Contents = new List <string[]>()
            };

            foreach (var product in products)
            {
                excelInputType.Contents.Add(new string[17] {
                    product.Category == null ? string.Empty : product.Category.Code,
                    $"{product.Code}_{product.CurrentUoM}",
                    product.DefaultName,
                    "0", //hardcode
                    "0", //hardcode
                    "0", //hardcode
                    "0", //hardcode
                    product.CurrentUoM.ToString(),
                    string.Empty,
                    product.CurrentWeight.ToString(),
                    product.CurrentCapacity.ToString(),
                    "0",          //hardcode
                    "0",          //hardcode
                    $"{product.Code}_{product.CurrentUoM}",
                    string.Empty, //hardcode
                    string.Empty, //hardcode
                    string.Empty  //hardcode
                });
            }

            var excelData = ExcelHelper.Create(new List <ExcelInputData>()
            {
                excelInputType
            }, ExcelExtension.xlsx);

            return(File(excelData.Data, excelData.ContentType, $"Product.{excelData.Extension.ToString()}"));
            //return excelData.Data;
        }
示例#2
0
        public async Task <FileResult> DownloadTypes()
        {
            var types = await vehicleQueries.GetTypes();

            var excelInputType = new ExcelInputData()
            {
                SheetName = "VehicleType",
                Header    = new string[4] {
                    "Mã Loại Phương Tiện",
                    "Tên Loại Phương Tiện",
                    "Thời gian soạn hàng có palleted (phút)",
                    "Thời gian soạn hàng không có palleted (phút)"
                },
                Contents = new List <string[]>()
            };

            foreach (var type in types)
            {
                excelInputType.Contents.Add(new string[4] {
                    type.Code,
                    type.Name,
                    "0", //hardcode
                    "0"  //hardcode
                });
            }

            var excelData = ExcelHelper.Create(new List <ExcelInputData>()
            {
                excelInputType
            }, ExcelExtension.xlsx);

            return(File(excelData.Data, excelData.ContentType, $"VehicleType.{excelData.Extension.ToString()}"));
        }
示例#3
0
        public async Task <FileResult> Downloads()
        {
            var vehicles = await vehicleQueries.Gets();

            var excelInputType = new ExcelInputData()
            {
                SheetName = "Vehicle",
                Header    = new string[19] {
                    "Mã Tổ Chức",
                    "Mã Phương Tiện",
                    "Kiểu Phương Tiện",
                    "Biển Số Xe",
                    "Nhiệt Độ",
                    "Số Ngăn",
                    "Sức ChứaThể Tích (m3)",
                    "Sức Chứa Trọng Lượng (kg)",
                    "Thời Gian Bắt Đầu",
                    "Thời Gian Kết Thúc",
                    "Thời Gian Bắt Đầu Nghỉ Trưa",
                    "Thời Gian Kết Thúc Nghỉ Trưa",
                    "Chi Phí Cố Định",
                    "Chi phí trên km",
                    "Chi Phí Thuê Xe",
                    "Độ Thân Thuộc",
                    "Tốc Độ",
                    "Tổng Trọng Lượng",
                    "Lái Xe Mặc Định"
                },
                Contents = new List <string[]>()
            };

            foreach (var vehicle in vehicles)
            {
                excelInputType.Contents.Add(new string[19] {
                    vehicle.OrgCode,
                    vehicle.Code,
                    vehicle.Type.Code,
                    vehicle.Name,
                    vehicle.TemperatureType,
                    vehicle.ZoneCount.ToString(),
                    vehicle.Capacity.ToString(),
                    vehicle.Weight.ToString(),
                    vehicle.StartTime,
                    vehicle.EndTime,
                    vehicle.StartLunchTime,
                    vehicle.EndLunchTime,
                    "0", //hardcode
                    "0", //hardcode
                    "0", //hardcode
                    "0", //hardcode,
                    vehicle.Speed.ToString(),
                    (vehicle.Weight + vehicle.VehicleWeight).ToString(),
                    string.Empty //hardcode
                });
            }

            var excelData = ExcelHelper.Create(new List <ExcelInputData>()
            {
                excelInputType
            }, ExcelExtension.xlsx);

            return(File(excelData.Data, excelData.ContentType, $"Vehicle.{excelData.Extension.ToString()}"));
        }