Example #1
0
        // 清单导入
        public List <AnswerDto> AnswerImport(string ossPath)
        {
            // 从OSS下载文件
            string downLoadFilePath = basePath + @"Content\Excel\ExcelImport\" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".xlsx";

            OSSClientHelper.GetObject(ossPath, downLoadFilePath);
            Workbook         book  = Workbook.Load(downLoadFilePath, false);
            Worksheet        sheet = book.Worksheets[0];
            List <AnswerDto> list  = new List <AnswerDto>();

            for (int i = 0; i < 100000; i++)
            {
                string shopCode = sheet.GetCell("A" + (i + 2)).Value == null ? "" : sheet.GetCell("A" + (i + 2)).Value.ToString().Trim();
                if (string.IsNullOrEmpty(shopCode))
                {
                    break;
                }
                AnswerDto answer = new AnswerDto();
                answer.ShopCode      = shopCode;
                answer.ShopName      = sheet.GetCell("B" + (i + 2)).Value == null ? "" : sheet.GetCell("B" + (i + 2)).Value.ToString().Trim();
                answer.CheckCode     = sheet.GetCell("C" + (i + 2)).Value == null ? "" : sheet.GetCell("C" + (i + 2)).Value.ToString().Trim();
                answer.CheckTypeName = sheet.GetCell("D" + (i + 2)).Value == null ? "" : sheet.GetCell("D" + (i + 2)).Value.ToString().Trim();
                answer.Column1       = sheet.GetCell("E" + (i + 2)).Value == null ? "" : sheet.GetCell("E" + (i + 2)).Value.ToString().Trim();
                answer.Column2       = sheet.GetCell("F" + (i + 2)).Value == null ? "" : sheet.GetCell("F" + (i + 2)).Value.ToString().Trim();
                answer.Column3       = sheet.GetCell("G" + (i + 2)).Value == null ? "" : sheet.GetCell("G" + (i + 2)).Value.ToString().Trim();
                answer.Column4       = sheet.GetCell("H" + (i + 2)).Value == null ? "" : sheet.GetCell("H" + (i + 2)).Value.ToString().Trim();
                answer.Column5       = sheet.GetCell("I" + (i + 2)).Value == null ? "" : sheet.GetCell("I" + (i + 2)).Value.ToString().Trim();
                answer.Column6       = sheet.GetCell("J" + (i + 2)).Value == null ? "" : sheet.GetCell("J" + (i + 2)).Value.ToString().Trim();
                answer.Column7       = sheet.GetCell("K" + (i + 2)).Value == null ? "" : sheet.GetCell("K" + (i + 2)).Value.ToString().Trim();
                answer.Column8       = sheet.GetCell("L" + (i + 2)).Value == null ? "" : sheet.GetCell("L" + (i + 2)).Value.ToString().Trim();
                answer.Column9       = sheet.GetCell("M" + (i + 2)).Value == null ? "" : sheet.GetCell("M" + (i + 2)).Value.ToString().Trim();
                list.Add(answer);
            }
            return(list);
        }
Example #2
0
        // 导入市场基金详情
        public List <DMFDetailDto> DMFDetailImport(string ossPath)
        {
            // 从OSS下载文件
            string downLoadFilePath = basePath + @"Content\Excel\ExcelImport\" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".xlsx";

            OSSClientHelper.GetObject(ossPath, downLoadFilePath);
            Workbook            book  = Workbook.Load(downLoadFilePath, false);
            Worksheet           sheet = book.Worksheets[0];
            List <DMFDetailDto> list  = new List <DMFDetailDto>();

            for (int i = 0; i < 10000; i++)
            {
                string shopName = sheet.GetCell("A" + (i + 3)).Value == null ? "" : sheet.GetCell("A" + (i + 3)).Value.ToString();
                if (string.IsNullOrEmpty(shopName))
                {
                    break;
                }
                DMFDetailDto dmfDetail = new DMFDetailDto();
                dmfDetail.ShopName    = shopName;
                dmfDetail.DMFItemName = sheet.GetCell("B" + (i + 3)).Value == null ? "" : sheet.GetCell("B" + (i + 3)).Value.ToString();
                dmfDetail.Budget      = sheet.GetCell("C" + (i + 3)).Value == null ? "" : sheet.GetCell("C" + (i + 3)).Value.ToString();
                dmfDetail.AcutalAmt   = sheet.GetCell("D" + (i + 3)).Value == null ? "" : sheet.GetCell("D" + (i + 3)).Value.ToString();
                dmfDetail.Remark      = sheet.GetCell("E" + (i + 3)).Value == null ? "" : sheet.GetCell("E" + (i + 3)).Value.ToString();
                list.Add(dmfDetail);
            }
            return(list);
        }
Example #3
0
        // 导入月批售概况
        public List <MonthSaleDto> MonthSaleImport(string ossPath)
        {
            // 从OSS下载文件
            string downLoadFilePath = basePath + @"Content\Excel\ExcelImport\" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".xlsx";

            OSSClientHelper.GetObject(ossPath, downLoadFilePath);
            Workbook            book  = Workbook.Load(downLoadFilePath, false);
            Worksheet           sheet = book.Worksheets[0];
            List <MonthSaleDto> list  = new List <MonthSaleDto>();

            for (int i = 0; i < 10000; i++)
            {
                string shopName = sheet.GetCell("A" + (i + 3)).Value == null ? "" : sheet.GetCell("A" + (i + 3)).Value.ToString();
                if (string.IsNullOrEmpty(shopName))
                {
                    break;
                }
                MonthSaleDto monthSale = new MonthSaleDto();
                monthSale.ShopName        = shopName;
                monthSale.YearMonth       = sheet.GetCell("B" + (i + 3)).Value == null ? "" : sheet.GetCell("B" + (i + 3)).Value.ToString();
                monthSale.ActualSaleCount = sheet.GetCell("C" + (i + 3)).Value == null ? "" : sheet.GetCell("C" + (i + 3)).Value.ToString();
                monthSale.ActualSaleAmt   = sheet.GetCell("D" + (i + 3)).Value == null ? "" : sheet.GetCell("D" + (i + 3)).Value.ToString();
                list.Add(monthSale);
            }
            return(list);
        }
        // 导入区域
        public List <AreaDto> AreaImport(string ossPath)
        {
            // 从OSS下载文件
            string downLoadFilePath = basePath + @"Excel\ExcelImport\" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".xlsx";

            OSSClientHelper.GetObject(ossPath, downLoadFilePath);
            Workbook       book  = Workbook.Load(downLoadFilePath, false);
            Worksheet      sheet = book.Worksheets[0];
            List <AreaDto> list  = new List <AreaDto>();

            for (int i = 0; i < 10000; i++)
            {
                string areaCode = sheet.GetCell("A" + (i + 3)).Value == null ? "" : sheet.GetCell("A" + (i + 3)).Value.ToString().Trim();
                if (string.IsNullOrEmpty(areaCode))
                {
                    break;
                }
                AreaDto area = new AreaDto();
                area.AreaCode   = areaCode;
                area.AreaName   = sheet.GetCell("B" + (i + 3)).Value == null ? "" : sheet.GetCell("B" + (i + 3)).Value.ToString().Trim();
                area.AreaType   = sheet.GetCell("C" + (i + 3)).Value == null ? "" : sheet.GetCell("C" + (i + 3)).Value.ToString().Trim();
                area.ParentCode = sheet.GetCell("D" + (i + 3)).Value == null ? "" : sheet.GetCell("D" + (i + 3)).Value.ToString().Trim();
                string useChk = sheet.GetCell("E" + (i + 3)).Value == null ? "" : sheet.GetCell("E" + (i + 3)).Value.ToString().Trim();
                if (useChk == "1")
                {
                    area.UseChk = true;
                }
                else
                {
                    area.UseChk = false;
                }
                list.Add(area);
            }
            return(list);
        }
Example #5
0
        // 导入线索报告
        public List <MarketActionAfter2LeadsReportDto> LeadsReportImport(string ossPath)
        {
            // 从OSS下载文件
            string downLoadFilePath = basePath + @"Content\Excel\ExcelImport\" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".xlsx";

            OSSClientHelper.GetObject(ossPath, downLoadFilePath);
            Workbook  book  = Workbook.Load(downLoadFilePath, false);
            Worksheet sheet = book.Worksheets[0];
            List <MarketActionAfter2LeadsReportDto> list = new List <MarketActionAfter2LeadsReportDto>();

            for (int i = 0; i < 10000; i++)
            {
                string customerName = sheet.GetCell("A" + (i + 3)).Value == null?"":sheet.GetCell("A" + (i + 3)).Value.ToString();
                if (string.IsNullOrEmpty(customerName))
                {
                    break;
                }
                MarketActionAfter2LeadsReportDto report = new MarketActionAfter2LeadsReportDto();
                report.BPNO                = sheet.GetCell("B" + (i + 3)).Value == null?"":sheet.GetCell("B" + (i + 3)).Value.ToString();
                report.CustomerName        = customerName;
                report.DealCheckName       = sheet.GetCell("G" + (i + 3)).Value == null?"":sheet.GetCell("G" + (i + 3)).Value.ToString();
                report.DealModelName       = sheet.GetCell("H" + (i + 3)).Value == null?"":sheet.GetCell("H" + (i + 3)).Value.ToString();
                report.InterestedModelName = sheet.GetCell("F" + (i + 3)).Value == null?"":sheet.GetCell("F" + (i + 3)).Value.ToString();
                report.LeadsCheckName      = sheet.GetCell("E" + (i + 3)).Value == null?"":sheet.GetCell("E" + (i + 3)).Value.ToString();
                report.OwnerCheckName      = sheet.GetCell("C" + (i + 3)).Value == null?"":sheet.GetCell("C" + (i + 3)).Value.ToString();
                report.TestDriverCheckName = sheet.GetCell("D" + (i + 3)).Value == null?"":sheet.GetCell("D" + (i + 3)).Value.ToString();
                list.Add(report);
            }
            return(list);
        }
        //导入小区下经销商
        public List <ShopDto> AreaShopImport(string ossPath)
        {
            // 从OSS下载文件
            string downLoadFilePath = basePath + @"Excel\ExcelImport\" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".xlsx";

            OSSClientHelper.GetObject(ossPath, downLoadFilePath);
            Workbook       book  = Workbook.Load(downLoadFilePath, false);
            Worksheet      sheet = book.Worksheets[0];
            List <ShopDto> list  = new List <ShopDto>();

            for (int i = 0; i < 100000; i++)
            {
                string areaCode = sheet.GetCell("A" + (i + 3)).Value == null ? "" : sheet.GetCell("A" + (i + 3)).Value.ToString().Trim();
                string shopCode = sheet.GetCell("B" + (i + 3)).Value == null ? "" : sheet.GetCell("B" + (i + 3)).Value.ToString().Trim();
                if (string.IsNullOrEmpty(areaCode) || string.IsNullOrEmpty(shopCode))
                {
                    break;
                }
                ShopDto areaShop = new ShopDto();
                areaShop.AreaCode = areaCode;
                areaShop.ShopCode = shopCode;
                list.Add(areaShop);
            }
            return(list);
        }
        // 失分说明
        public List <LossResultDto> SubjectLossImport(string ossPath)
        {
            // 从OSS下载文件
            string downLoadFilePath = basePath + @"Excel\ExcelImport\" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".xlsx";

            OSSClientHelper.GetObject(ossPath, downLoadFilePath);
            Workbook             book  = Workbook.Load(downLoadFilePath, false);
            Worksheet            sheet = book.Worksheets[3];
            List <LossResultDto> list  = new List <LossResultDto>();

            for (int i = 0; i < 10000; i++)
            {
                string subjectCode = sheet.GetCell("A" + (i + 3)).Value == null ? "" : sheet.GetCell("A" + (i + 3)).Value.ToString().Trim();
                if (string.IsNullOrEmpty(subjectCode))
                {
                    break;
                }
                LossResultDto loss = new LossResultDto();
                loss.SubjectCode = subjectCode;

                loss.LossDesc = sheet.GetCell("B" + (i + 3)).Value == null ? "" : sheet.GetCell("B" + (i + 3)).Value.ToString().Trim();
                list.Add(loss);
            }
            return(list);
        }
        // 导入题目
        public List <SubjectDto> SubjectImport(string ossPath)
        {
            // 从OSS下载文件
            string downLoadFilePath = basePath + @"Excel\ExcelImport\" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".xlsx";

            OSSClientHelper.GetObject(ossPath, downLoadFilePath);
            Workbook          book  = Workbook.Load(downLoadFilePath, false);
            Worksheet         sheet = book.Worksheets[0];
            List <SubjectDto> list  = new List <SubjectDto>();

            for (int i = 0; i < 10000; i++)
            {
                string subjectCode = sheet.GetCell("A" + (i + 3)).Value == null ? "" : sheet.GetCell("A" + (i + 3)).Value.ToString().Trim();
                if (string.IsNullOrEmpty(subjectCode))
                {
                    break;
                }
                SubjectDto subject = new SubjectDto();
                subject.SubjectCode = subjectCode;
                string orderNO = sheet.GetCell("B" + (i + 3)).Value.ToString();
                if (string.IsNullOrEmpty(orderNO))
                {
                    subject.OrderNO = null;
                }
                else
                {
                    subject.OrderNO = Convert.ToInt32(sheet.GetCell("B" + (i + 3)).Value.ToString().Trim());
                }
                string fullScore = sheet.GetCell("C" + (i + 3)).Value.ToString().Trim();
                if (string.IsNullOrEmpty(fullScore))
                {
                    subject.FullScore = null;
                }
                else
                {
                    subject.FullScore = Convert.ToDecimal(sheet.GetCell("C" + (i + 3)).Value.ToString().Trim());
                }
                string lowScore = sheet.GetCell("D" + (i + 3)).Value.ToString().Trim();
                if (string.IsNullOrEmpty(lowScore))
                {
                    subject.LowScore = null;
                }
                else
                {
                    subject.LowScore = Convert.ToDecimal(sheet.GetCell("D" + (i + 3)).Value.ToString().Trim());
                }
                subject.Implementation             = sheet.GetCell("E" + (i + 3)).Value == null ? "" :sheet.GetCell("E" + (i + 3)).Value.ToString().Trim();
                subject.ExamTypeCode               = sheet.GetCell("F" + (i + 3)).Value == null ? "" : sheet.GetCell("F" + (i + 3)).Value.ToString().Trim();
                subject.RecheckTypeCode            = sheet.GetCell("G" + (i + 3)).Value == null ? "" : sheet.GetCell("G" + (i + 3)).Value.ToString().Trim();
                subject.HiddenCode_SubjectTypeName = sheet.GetCell("H" + (i + 3)).Value == null ? "" : sheet.GetCell("H" + (i + 3)).Value.ToString().Trim();
                subject.CheckPoint     = sheet.GetCell("I" + (i + 3)).Value == null ? "" : sheet.GetCell("I" + (i + 3)).Value.ToString().Trim();
                subject.InspectionDesc = sheet.GetCell("J" + (i + 3)).Value == null ? "" : sheet.GetCell("J" + (i + 3)).Value.ToString().Trim();
                subject.Remark         = sheet.GetCell("K" + (i + 3)).Value == null ? "" : sheet.GetCell("K" + (i + 3)).Value.ToString().Trim();
                list.Add(subject);
            }
            return(list);
        }
        public string AnswerPhotoDownLoad(string projectId, string shopCode)
        {
            List <AnswerPhotoDto> list = GetAnswerPhotoList("", projectId, shopCode);

            if (list == null || list.Count == 0)
            {
                return("");
            }
            string defaultPath    = HostingEnvironment.MapPath(@"~/");
            string basePath       = defaultPath + "DownLoadFile";                                          //根目录
            string downLoadfolder = DateTime.Now.ToString("yyyyMMddHHmmssfff");                            //文件下载的文件夹
            string folder         = basePath + @"\" + downLoadfolder;                                      // 文件下载的路径
            string downLoadPath   = basePath + @"\" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".zip"; //打包后的文件名

            if (!Directory.Exists(basePath))
            {
                Directory.CreateDirectory(basePath);
            }
            if (!Directory.Exists(folder))
            {
                Directory.CreateDirectory(folder);
            }

            // 从OSS把文件下载到服务器
            foreach (AnswerPhotoDto photo in list)
            {
                //string photoName = photo.ProjectId + "_" + photo.ShopCode + "_" + photo.PhotoName;
                if (!Directory.Exists(folder + @"\" + photo.ProjectId))
                {
                    Directory.CreateDirectory(folder + @"\" + photo.ProjectId);//创建期号文件夹
                }
                if (!Directory.Exists(folder + @"\" + photo.ProjectId + @"\" + photo.ShopCode))
                {
                    Directory.CreateDirectory(folder + @"\" + photo.ProjectId + @"\" + photo.ShopCode);//创建经销商代码文件夹
                }
                if (File.Exists(folder + @"\" + photo.ProjectId + @"\" + photo.ShopCode + @"\" + photo.CheckCode + "_" + photo.PhotoName + ".jpg"))
                {
                    File.Delete(folder + @"\" + photo.ProjectId + @"\" + photo.ShopCode + @"\" + photo.CheckCode + "_" + photo.PhotoName + ".jpg");
                }
                try
                {
                    OSSClientHelper.GetObject(photo.PhotoUrl, folder + @"\" + photo.ProjectId + @"\" + photo.ShopCode + @"\" + photo.CheckCode + "_" + photo.PhotoName + ".jpg");
                }
                catch (Exception ex) {
                }
            }
            // 打包文件
            if (!ZipInForFiles(list, downLoadfolder, basePath, downLoadPath, 9))
            {
                return("");
            }

            return(downLoadPath.Replace(defaultPath, ""));
        }
        /// <summary>
        /// 打包下载文件
        /// </summary>
        /// <param name="projectId"></param>
        /// <param name="bussinessType"></param>
        /// <param name="wideArea"></param>
        /// <param name="bigArea"></param>
        /// <param name="middleArea"></param>
        /// <param name="smallArea"></param>
        /// <param name="shopIdStr"></param>
        /// <param name="keyword"></param>
        /// <param name="reportFileType"></param>
        /// <param name="pageNum"></param>
        /// <param name="pageCount"></param>
        /// <returns></returns>
        public string ReportFileDownLoad(string userId, string projectId, string bussinessType, string wideArea, string bigArea, string middleArea, string smallArea, string shopIdStr, string keyword, string reportFileType, int pageNum, int pageCount)
        {
            List <ReportFileDto> list = ReportFileDownloadAllByPageSearch(projectId, bussinessType, wideArea, bigArea, middleArea, smallArea, shopIdStr, keyword, reportFileType, pageNum, pageCount);

            if (list == null || list.Count == 0)
            {
                return("");
            }
            string fileStr        = "";
            string defaultPath    = HostingEnvironment.MapPath(@"~/");
            string basePath       = defaultPath + "DownLoadFile";                                          //根目录
            string downLoadfolder = DateTime.Now.ToString("yyyyMMddHHmmssfff");                            //文件下载的文件夹
            string folder         = basePath + @"\" + downLoadfolder;                                      // 文件下载的路径
            string downLoadPath   = basePath + @"\" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".zip"; //打包后的文件名

            if (!Directory.Exists(basePath))
            {
                Directory.CreateDirectory(basePath);
            }
            if (!Directory.Exists(folder))
            {
                Directory.CreateDirectory(folder);
            }
            // 从OSS把文件下载到服务器
            foreach (ReportFileDto reportFile in list)
            {
                fileStr += reportFile.ReportFileName + ";";
                if (File.Exists(folder + @"\" + reportFile.ReportFileName))
                {
                    File.Delete(folder + @"\" + reportFile.ReportFileName);
                }
                try
                {
                    OSSClientHelper.GetObject(reportFile.Url_OSS, folder + @"\" + reportFile.ReportFileName);
                }
                catch (Exception ex) { }
            }
            // 打包文件
            if (!ZipInForFiles(list, downLoadfolder, basePath, downLoadPath, 9))
            {
                return("");
            }
            // 保存下载记录
            if (!string.IsNullOrEmpty(fileStr))
            {
                ReportFileActionLog log = new ReportFileActionLog();
                log.Action         = "批量下载";
                log.InUserId       = Convert.ToInt32(userId);
                log.ProjectId      = Convert.ToInt32(projectId);
                log.ReportFileName = fileStr;
                ReportFileActionLogSave(log);
            }
            return(downLoadPath.Replace(defaultPath, ""));
        }
        // 导入经销商
        public List <ShopDto> ShopImport(string ossPath)
        {
            // 从OSS下载文件
            string downLoadFilePath = basePath + @"Excel\ExcelImport\" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".xlsx";

            OSSClientHelper.GetObject(ossPath, downLoadFilePath);
            Workbook       book  = Workbook.Load(downLoadFilePath, false);
            Worksheet      sheet = book.Worksheets[0];
            List <ShopDto> list  = new List <ShopDto>();

            for (int i = 0; i < 10000; i++)
            {
                string shopCode = sheet.GetCell("A" + (i + 3)).Value == null ? "" : sheet.GetCell("A" + (i + 3)).Value.ToString().Trim();
                if (string.IsNullOrEmpty(shopCode))
                {
                    break;
                }
                ShopDto shop = new ShopDto();
                shop.ShopCode      = shopCode;
                shop.ShopName      = sheet.GetCell("B" + (i + 3)).Value == null ? "" : sheet.GetCell("B" + (i + 3)).Value.ToString().Trim();
                shop.ShopShortName = sheet.GetCell("C" + (i + 3)).Value == null ? "" : sheet.GetCell("C" + (i + 3)).Value.ToString().Trim();
                shop.Province      = sheet.GetCell("D" + (i + 3)).Value == null ? "" : sheet.GetCell("D" + (i + 3)).Value.ToString().Trim();
                shop.City          = sheet.GetCell("E" + (i + 3)).Value == null ? "" : sheet.GetCell("E" + (i + 3)).Value.ToString().Trim();
                shop.GroupCode     = sheet.GetCell("F" + (i + 3)).Value == null ? "" : sheet.GetCell("F" + (i + 3)).Value.ToString().Trim();
                string useChk = sheet.GetCell("G" + (i + 3)).Value == null ? "" : sheet.GetCell("G" + (i + 3)).Value.ToString().Trim();
                if (useChk == "1")
                {
                    shop.UseChk = true;
                }
                else
                {
                    shop.UseChk = false;
                }
                list.Add(shop);
            }

            return(list);
        }
        // 导入账号信息
        public List <UserInfoDto> UserInfoImport(string ossPath)
        {
            // 从OSS下载文件
            string downLoadFilePath = basePath + @"Excel\ExcelImport\" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".xlsx";

            OSSClientHelper.GetObject(ossPath, downLoadFilePath);
            Workbook           book  = Workbook.Load(downLoadFilePath, false);
            Worksheet          sheet = book.Worksheets[0];
            List <UserInfoDto> list  = new List <UserInfoDto>();

            for (int i = 0; i < 10000; i++)
            {
                string accountId = sheet.GetCell("A" + (i + 3)).Value == null ? "" : sheet.GetCell("A" + (i + 3)).Value.ToString().Trim();
                if (string.IsNullOrEmpty(accountId))
                {
                    break;
                }
                UserInfoDto userInfo = new UserInfoDto();
                userInfo.AccountId    = accountId;;
                userInfo.AccountName  = sheet.GetCell("B" + (i + 3)).Value == null ? "" : sheet.GetCell("B" + (i + 3)).Value.ToString().Trim();
                userInfo.Password     = sheet.GetCell("C" + (i + 3)).Value == null ? "" : sheet.GetCell("C" + (i + 3)).Value.ToString().Trim();
                userInfo.RoleTypeName = sheet.GetCell("D" + (i + 3)).Value == null ? "" : sheet.GetCell("D" + (i + 3)).Value.ToString().Trim();
                userInfo.Email        = sheet.GetCell("E" + (i + 3)).Value == null ? "" : sheet.GetCell("E" + (i + 3)).Value.ToString().Trim();
                userInfo.TelNO        = sheet.GetCell("F" + (i + 3)).Value == null ? "" : sheet.GetCell("F" + (i + 3)).Value.ToString().Trim();
                string useChk = sheet.GetCell("G" + (i + 3)).Value == null ? "" : sheet.GetCell("G" + (i + 3)).Value.ToString().Trim();
                if (useChk == "1")
                {
                    userInfo.UseChk = true;
                }
                else
                {
                    userInfo.UseChk = false;
                }
                list.Add(userInfo);
            }
            return(list);
        }
Example #13
0
 public static string UploadBase64Pic(string filePath, string base64Img)
 {
     if (!string.IsNullOrEmpty(base64Img) && base64Img.Contains("data:image"))
     {
         if (string.IsNullOrEmpty(filePath))
         {
             filePath = @"Bentley/" + WebConfigurationManager.AppSettings["Year"] + @"/MarketAction/" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".jpg";
         }
         base64Img = base64Img.Trim().Replace("%", "").Replace(",", "").Replace(" ", "+");
         base64Img = base64Img.Substring(base64Img.IndexOf("base64") + 6);
         if (base64Img.Length % 4 > 0)
         {
             base64Img = base64Img.PadRight(base64Img.Length + 4 - base64Img.Length % 4, '=');
         }
         Stream stream = BytesToStream(Base64ToBytes(base64Img));
         OSSClientHelper.UploadOSSFile(filePath, stream, stream.Length);
         Thread.Sleep(1);
     }
     else
     {
         filePath = base64Img;
     }
     return(filePath);
 }
        // 导入执行人员关联的经销商
        public List <UserInfoObjectDto> UserInfoObjectImport_ExcuteShop(string ossPath)
        {
            // 从OSS下载文件
            string downLoadFilePath = basePath + @"Excel\ExcelImport\" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".xlsx";

            OSSClientHelper.GetObject(ossPath, downLoadFilePath);
            Workbook  book  = Workbook.Load(downLoadFilePath, false);
            Worksheet sheet = book.Worksheets[0];
            List <UserInfoObjectDto> list = new List <UserInfoObjectDto>();

            for (int i = 0; i < 10000; i++)
            {
                string accountId = sheet.GetCell("A" + (i + 3)).Value == null ? "" : sheet.GetCell("A" + (i + 3)).Value.ToString().Trim();
                if (string.IsNullOrEmpty(accountId))
                {
                    break;
                }
                UserInfoObjectDto userInfoObject = new UserInfoObjectDto();
                userInfoObject.AccountId  = accountId;
                userInfoObject.ObjectCode = sheet.GetCell("B" + (i + 3)).Value == null ? "" : sheet.GetCell("B" + (i + 3)).Value.ToString().Trim();
                list.Add(userInfoObject);
            }
            return(list);
        }
        // 导入经销商卷别类别
        public List <ProjectShopExamTypeDto> ProjectShopExamTypeImport(string ossPath)
        {
            // 从OSS下载文件
            string downLoadFilePath = basePath + @"Excel\ExcelImport\" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".xlsx";

            OSSClientHelper.GetObject(ossPath, downLoadFilePath);
            Workbook  book  = Workbook.Load(downLoadFilePath, false);
            Worksheet sheet = book.Worksheets[0];
            List <ProjectShopExamTypeDto> list = new List <ProjectShopExamTypeDto>();

            for (int i = 0; i < 10000; i++)
            {
                string shopCode = sheet.GetCell("A" + (i + 3)).Value == null ? "" : sheet.GetCell("A" + (i + 3)).Value.ToString().Trim();
                if (string.IsNullOrEmpty(shopCode))
                {
                    break;
                }
                ProjectShopExamTypeDto projectShopExamTypeDto = new ProjectShopExamTypeDto();
                projectShopExamTypeDto.ShopCode     = shopCode;
                projectShopExamTypeDto.ExamTypeCode = sheet.GetCell("B" + (i + 3)).Value == null ? "" : sheet.GetCell("B" + (i + 3)).Value.ToString().Trim();
                list.Add(projectShopExamTypeDto);
            }
            return(list);
        }