public ActionResult Index(HttpPostedFileBase file)
        {
            file.SaveAs(Server.MapPath("img/") + Path.GetFileName(file.FileName));
            tbl_upload t = new tbl_upload();

            t.imgname = Path.GetFileName(file.FileName);
            db.tbl_upload.Add(t);
            db.SaveChanges();
            return(View());
        }
        public ActionResult Index(HttpPostedFileBase file)
        {
            file.SaveAs(Server.MapPath("/upload") + "/" + Path.GetFileName(file.FileName));
            tbl_upload t = new tbl_upload();

            t.imgname = Path.GetFileName(file.FileName);
            db.tbl_upload.Add(t);
            db.SaveChanges();
            ViewBag.data = "File Uploaded SuccessFully";
            return(View(db.tbl_upload.ToList()));
        }
        private async Task <PTresult> ImportJYY_async(string[] Lines, IProgress <ProgressReportModel> progress, ProgressReportModel report)
        {
            int totalN = Lines.Length;
            int add_N  = 0;
            int all_N  = 0;

            await Task.Run(() =>
            {
                log.Info($"    enter ImportJYY_async.");
                foreach (string Line in Lines)
                {
                    string[] lineStr = Line.Split(',');
                    string sYM       = lineStr[0]; // 1  分年月,
                    string sCli      = lineStr[1]; // 2  診所代碼,
                    string sIid      = lineStr[2]; // 3  機構代碼,
                    string sUid      = lineStr[3]; // 4  身分證字號,
                    string sBd       = lineStr[4]; // 5  生日,
                    string sInsD     = lineStr[5]; // 6  入院日期,
                    string sOutD     = lineStr[6]; // 7  出院日期,
                    string sCname    = lineStr[7]; // 8  姓名,

                    using (BSDataContext dc = new BSDataContext())
                    {
                        var q = from p in dc.tbl_upload
                                where (p.YM == sYM) && (p.uid == sUid)
                                select p;
                        if (q.Count() == 0)
                        {
                            try
                            {
                                tbl_upload newUP = new tbl_upload()
                                {
                                    YM    = sYM,
                                    Cli   = sCli,
                                    iid   = sIid,
                                    uid   = sUid,
                                    bd    = sBd,
                                    InsD  = sInsD,
                                    OutD  = sOutD,
                                    cname = sCname,
                                    QDATE = _qdate
                                };
                                dc.tbl_upload.InsertOnSubmit(newUP);
                                dc.SubmitChanges();
                                add_N++;
                            }
                            catch (Exception ex)
                            {
                                Logging.Record_error(ex.Message);
                                log.Error(ex.Message);
                            }
                        }
                    }
                    all_N++;
                    report.PercentageComeplete = all_N * 100 / totalN;
                    progress.Report(report);
                }
                log.Info($"    exit ImportJYY_async.");
            });

            return(new PTresult()
            {
                NewPT = add_N,
                AllPT = all_N
            });
        }