Esempio n. 1
0
        //[HttpPost]
        //public JsonResult CheckExportData()
        //{
        //    IService.Spm.ISpm_ExpressInfoService eis = OpeCur.ServiceSession.Spm_ExpressInfo;
        //    List<ExViewModel> list = eis.GetViewList(LambdaHelper.CreateEquals<Spm_ExpressInfo>("Company", OpeCur.AccountNow.AllMerchant, OpeCur.UsrHasMerchantCode));
        //    if (list.Count().Equals(0))
        //    {
        //        return OpeCur.AjaxMsgNOOK("没有可以导出的数据");
        //    }
        //    else
        //    {
        //        return OpeCur.AjaxMsgOK("可以导出");
        //    }
        //}
        public ActionResult Export()
        {
            IService.Spm.ISpm_ExpressInfoService eis = OpeCur.ServiceSession.Spm_ExpressInfo;
            //var dt = await Task.Run(() => { return eis.GetViewDataTable(LambdaHelper.CreateEquals<Spm_ExpressInfo>("Company", OpeCur.AccountNow.AllMerchant, OpeCur.UsrHasMerchantCode)); });
            var dt = eis.GetViewDataTable(LambdaHelper.T_CreateEquals <Spm_ExpressInfo>("Company", OpeCur.AccountNow.AllMerchant, OpeCur.UsrHasMerchantCode));

            if (dt.Rows.Count > 0)
            {
                var exportFileName = string.Concat(
                    "ExpressInfo",
                    DateTime.Now.ToString("yyyyMMddHHmmss"),
                    ".xlsx");

                return(new ExportExcelResult
                {
                    SheetName = "快递信息",
                    FileName = exportFileName,
                    ExportData = dt
                });
            }
            else
            {
                return(OpeCur.JsMsg("没有符合条件的数据"));
            }
        }