コード例 #1
0
        public ActionResult Import(string savedFileName)
        {
            var    jo = new JObject();
            string result;

            try
            {
                var fileName = string.Concat(Server.MapPath(fileSavedPath), "/", savedFileName);//可以拿掉"/",不影响

                var importZipCodes = new List <TF_SHLC>();

                var helper      = new ImportDataHelper();
                var checkResult = helper.CheckImportData(fileName, importZipCodes);

                jo.Add("Result", checkResult.Success);
                jo.Add("Msg", checkResult.Success ? string.Empty : checkResult.ErrorMessage);

                if (checkResult.Success)
                {
                    //儲存匯入的資料
                    helper.SaveImportData(importZipCodes);
                }
                result = JsonConvert.SerializeObject(jo);
            }
            catch (Exception ex)
            {
                throw;
            }
            return(Content(result, "application/json"));
        }
コード例 #2
0
        public ActionResult Import(string savedFileName)
        {
            var    jo = new JObject();
            string result;

            try
            {
                var fileName = string.Concat(Server.MapPath(fileSavedPath), "/", savedFileName);

                var importTCT   = new List <tCustomizeTopic>();
                var MemberID    = Request.Cookies["AutoLogin"]["MemberID"];
                var Category    = Request.Cookies["Category"].Value;
                var helper      = new ImportDataHelper();
                var checkResult = helper.CheckImportData(fileName, importTCT, MemberID, Category);

                jo.Add("Result", checkResult.Success);
                jo.Add("Msg", checkResult.Success ? string.Empty : checkResult.ErrorMessage);

                if (checkResult.Success)
                {
                    //儲存匯入的資料
                    helper.SaveImportData(importTCT);
                }
                Response.Cookies["Category"].Expires = DateTime.Now.AddSeconds(-1);
                result = JsonConvert.SerializeObject(jo);
            }
            catch (Exception ex)
            {
                throw;
            }
            return(Content(result, "application/json"));
        }