Beispiel #1
0
        /// <summary>
        /// 1. upload file (excel/txt)
        /// 2. parse excel column value
        /// 3. batch insert posdata
        /// 4. insert uploadlog
        /// 5. copy file to success directory
        /// p.s parameter need login id and  model-ok
        /// p.s need remote test upload file method can be right
        /// </summary>
        /// <returns></returns>
        public List <string> UploadFile()
        {
            List <string> _ListError = new List <string>();
            // string _FilePath = Upload();
            string    _FilePath   = this._commonFileService.Upload();
            UploadLog _ReportFile = this._uploadLogService.GetByName(Path.GetFileName(_FilePath));

            if (_ReportFile != null)
            {
                throw new Exception(" don't upload duplicate file  ");
            }
            IQueryable <Pos> _PosData = parse(_FilePath);

            if (checkData(_PosData))
            {
                int _LoginID = HttpContext.Current.Request["LoginID"].ToString() != "" ? Convert.ToInt32(HttpContext.Current.Request["LoginID"].ToString()) : 0;
                _ListError = _posService.MiltiCreate(_PosData, _LoginID);
                bool _Success = _ListError.Count > 1 ? false : true;
                //  string _ServerFileName = saveToSuccess(_LoginID, _FilePath, "Pos");
                string _ServerFileName = this._commonFileService.SaveToSuccess(_LoginID, _FilePath, "Pos");
                string _UploadLogError = insertUploadLog(_LoginID, _FilePath, "Pos", _Success, _ServerFileName);
                if (_UploadLogError != "")
                {
                    _ListError.Add(_UploadLogError);
                }
                if (_ListError.Count > 0)
                {
                    _ListError[0] = _ListError[0] + "ms";
                }
            }
            else
            {
                throw new Exception(" please confirm your file format ");
            }
            return(_ListError);
        }