コード例 #1
0
        public JsonResult UploadExcel(int packageId, Guid ruleGUID)
        {
            var files         = Request.Files;
            var convertResult = ConvertExcelToList(files);
            var data          = new List <BaoYangPackagePromotionDetail>();
            var flag          = false;

            if (!string.IsNullOrEmpty(convertResult.Item2))
            {
                return(Json(new { status = false, msg = convertResult.Item2 }));
            }

            var manager = new VipBaoYangPackageManager();

            var validated = manager.ValidatedUploadData(ruleGUID, convertResult.Item1);

            if (!validated.Item1)
            {
                return(Json(new { status = false, msg = validated.Item2 }));
            }

            var extension    = Path.GetExtension(files[0].FileName);
            var uploadResult = new UploadFileManager().UploadFile(convertResult.Item4, FileType.VipBaoYangPackage, extension, files[0].FileName, HttpContext.User.Identity.Name);

            if (!string.IsNullOrEmpty(uploadResult.Item1) && !string.IsNullOrEmpty(uploadResult.Item2))
            {
                flag = manager.BatchBaoYangPakckagePromotion(packageId, ruleGUID, convertResult.Item3, uploadResult.Item2, HttpContext.User.Identity.Name);
                if (flag)
                {
                    data = convertResult.Item1;
                }
            }

            return(Json(new { status = flag, data = data }));
        }