コード例 #1
0
ファイル: ExamResultBiz.cs プロジェクト: ekarincodizm/IAS
            UploadData(string fileName, Stream rawData, string userId,string TestNo)
        {
            var res = new DTO.ResponseService<DTO.UploadResult<DTO.UploadResultHeader, DTO.ExamResultTemp>>();
            if (rawData == null)
            {
                res.ErrorMsg = Resources.errorExamResultBiz_003;
                return res;
            }

           
            //เปลี่ยนสไตล์ของวันที่เป็นแบบไทย เพื่อแสดงค่าที่เป็นปี พ.ศ.
            Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("th-TH");

            String filePath = UploadFileApplicantToTemp(rawData);

          /*  DTO.UploadData data = new DTO.UploadData
            {
                Body = new List<string>()
            };

            try
            {
                try
                {
                    //Stream rawData = FileUpload1.PostedFile.InputStream;
                    using (StreamReader sr = new StreamReader(rawData, System.Text.Encoding.GetEncoding("TIS-620")))
                    {
                        int i=0;
                        string line = string.Empty; // sr.ReadLine().Trim();
                        while ((line = sr.ReadLine()) != null)
                        {
                            if (i == 0)
                            {
                                if (line != null && line.Length > 0)
                                {
                                    if (line.Substring(0, 1) == "H")
                                    {
                                        data.Header = line;
                                    }
                                    else
                                    {
                                        res.ErrorMsg = Resources.errorExamResultBiz_001;
                                        return res;
                                    }
                                }
                            }
                            else
                            {
                                if (line.Trim().Length > 0)
                                {
                                    data.Body.Add(line.Trim());
                                }
                            }
                            i++;
                        }

                        if (i == 0)//แสดงว่าไม่ได้เข้าไปวนลูป while เลย
                        {
                            res.ErrorMsg = Resources.errorExamResultBiz_002;
                            return res;
                        }
                    }

                    res = svc.InsertAndCheckExamResultUpload(fileName, userId, TestNo);

                }
                catch (Exception ex)
                {
                    res.ErrorMsg = "กรุณาติดต่อผู้ดูแลระบบ";
                }
            }
            catch (IOException ex)
            {
                res.ErrorMsg = "กรุณาติดต่อผู้ดูแลระบบ";
            }
           * */

            res = svc.InsertAndCheckExamResultUpload(filePath, userId, TestNo);
            return res;
        }