예제 #1
0
 public void TestImportHCData()
 {
     var sFile = @"D:\he\Doc\20180724发物流人力计算管控系统Dashboard\testData\HCData.xlsx";
     var sErr = string.Empty;
     var nImp = WLE_Data.ImportHCData(new FileInfo(sFile), out sErr);
     Assert.IsTrue(nImp > 0);
     Assert.AreEqual(string.Empty, sErr);
 }
예제 #2
0
 public void TestImportWeekData()
 {
     //var sFile = @"D:\he\Doc\20180724发物流人力计算管控系统Dashboard\testData0821\WeekData_badTest.xlsx";
     //var sFile = @"D:\he\Doc\20180724发物流人力计算管控系统Dashboard\testData\WeekData.xlsx";
     //var sFile = @"D:\he\Doc\20180724发物流人力计算管控系统Dashboard\testData\WeekData1.xlsx";
     var sFile = @"D:\he\Doc\20180724发物流人力计算管控系统Dashboard\bug\Week Data导入了一个空行产生全0日期.xlsx";
     var sErr = string.Empty;
     var nImp = WLE_Data.ImportWeekData(new FileInfo(sFile), out sErr);
     Assert.IsTrue(nImp > 0);
     Assert.AreEqual(string.Empty, sErr);
 }
예제 #3
0
        private ActionResult DownloadData_HCData(string bu, string selYear)
        {
            var fn  = string.Format("{0}_{1}.xlsx", "HCData", DateTimeHelper.GetToday());
            var bys = WLE_Data.GetHCData_Down(bu, selYear);

            if (null == bys)
            {
                return(new EmptyResult());
            }
            return(File(bys, ExcelType.XLSX_MIME, fn));
        }
예제 #4
0
        private ActionResult DownloadData_WeekData(string bu, string startWeek, string endWeek)
        {
            var fn  = string.Format("{0}_{1}_{2}.xlsx", "WeekData", startWeek, endWeek);
            var bys = WLE_Data.GetWeekData_Down(bu, startWeek, endWeek);

            if (null == bys)
            {
                return(new EmptyResult());
            }
            return(File(bys, ExcelType.XLSX_MIME, fn));
        }
예제 #5
0
        public ActionResult DownloadMonthData(string selKind)
        {
            if (!CommonInfo.HasRight(TRightID.DOWNLOAD))
            {
                return(new HttpUnauthorizedResult());
            }
            var fn  = string.Format("{0}_{1}.xlsx", "MonthData", selKind);
            var bys = WLE_Data.GetMonthData_Down(selKind);

            if (null == bys)
            {
                return(new EmptyResult());
            }
            return(File(bys, ExcelType.XLSX_MIME, fn));
        }
예제 #6
0
        public static bool ImpUpload(string dataType, HttpPostedFileBase file, out string sErrImp)
        {
            sErrImp = string.Empty;
            var fileName = Path.GetFileName(file.FileName);
            var fileTemp = Path.Combine(GetTempDirBase(), fileName);

            file.SaveAs(fileTemp);

            long nRec = 0;

            try
            {
                var fi = new FileInfo(fileTemp);
                switch (dataType)
                {
                case "WeekData":
                    nRec = WLE_Data.ImportWeekData(fi, out sErrImp);
                    break;

                case "MonthData":
                    nRec = WLE_Data.ImportMonthData(fi, out sErrImp);
                    break;

                case "HCData":
                    nRec = WLE_Data.ImportHCData(fi, out sErrImp);
                    break;
                }

                LogHelper.WriteInfo(typeof(BLLHelper), string.Format("DoUploadCond:{0}", nRec));
            }
            catch (Exception ex)
            {
                LogHelper.WriteError(typeof(BLLHelper), ex);
                sErrImp = string.Format("Excel数据有问题。<br>{0}", ex.Message);
            }
            finally
            {
                if (CustomConfig.bDeleteTempFile)
                {
                    File.Delete(fileTemp);
                }
            }
            return(nRec > 0);
        }