/// <summary> /// 删除一组套图 /// </summary> /// <param name="fileIdentity"></param> public static void DeleteImages(string fileIdentity) { if (ImageList.Count == 0) { return; } var result = FileUploadManager.FileExists(fileIdentity); if (result) { return; } ImageList.ForEach(v => { var folderPath = Path.Combine(FileUploadManager.BaseFolder, v.Key.ToString()); if (!Directory.Exists(folderPath)) { return; } var filePath = Path.Combine(folderPath, fileIdentity); if (File.Exists(filePath)) { ThreadPool.QueueUserWorkItem(delegate { File.Delete(filePath); }); } }); }
/// <summary> /// 生成标准图片 /// </summary> /// <param name="fileIdentity"></param> /// <param name="newFileName"></param> public static void CreateStandardImages(string fileIdentity, string newFileName) { if (ImageList.Count == 0) { return; } var result = FileUploadManager.FileExists(fileIdentity); if (!result) { return; } var filePath = FileUploadManager.GetFilePhysicalFullPath(fileIdentity); Image uploadImage = Image.FromFile(filePath); //判断是否为标准图片 if (!ImageUtility.CheckImagePixels(uploadImage)) { uploadImage.Dispose();//后面的zoomauto会删除的,资源要提前释放 //重命名文件 var bytes = FileUploadManager.GetFileData(fileIdentity); var imageHelp = new ImageUtility { SavePath = filePath }; imageHelp.ZoomAuto(bytes, 640, 480); } }
public static void OriginalImageSaveByDFIS(string fileIdentity, string destFileName) { if (string.IsNullOrWhiteSpace(fileIdentity) || string.IsNullOrWhiteSpace(destFileName)) { return; } var result = FileUploadManager.FileExists(fileIdentity); if (result) { var filePath = FileUploadManager.GetFilePhysicalFullPath(fileIdentity); CreateStandardImages(fileIdentity, destFileName); HttpUploader.UploadFile(UploadURL, FileGroup, "Original", filePath, destFileName, "", UserName, UploadMethod.Update); } }
public void ImportPostIncome(string fileIdentity, string companyCode, ref List <PostIncomeInfo> successList, ref List <ImportPostIncome> faultList, ref string message) { if (FileUploadManager.FileExists(fileIdentity)) { string destinationPath = string.Empty; MoveFile(fileIdentity, ref destinationPath); DataSet ds = ConvertExcel2DataSet(destinationPath); BatachCreate(ds.Tables[0], companyCode, ref successList, ref faultList, ref message); } else { throw new BizException(ResouceManager.GetMessageString(InvoiceConst.ResourceTitle.PostIncome, "PostIncome_NoFile")); } }
/// <summary> /// 原始图片保存 /// </summary> /// <param name="fileIdentity"></param> /// <param name="destFileName"></param> public static void OriginalImageSave(string fileIdentity, string destFileName) { if (string.IsNullOrWhiteSpace(fileIdentity) || string.IsNullOrWhiteSpace(destFileName)) { return; } var result = FileUploadManager.FileExists(fileIdentity); if (result) { var filePath = FileUploadManager.GetFilePhysicalFullPath(fileIdentity); CreateStandardImages(fileIdentity, destFileName); var fileExtensionName = FileUploadManager.GetFileExtensionName(fileIdentity); var savePath = FilePathHelp.GetFileSavePath(fileExtensionName.ToLower()); OriginalImageSave(fileIdentity, destFileName, savePath); } }
/// <summary> /// 生成一组套图 /// </summary> /// <param name="fileIdentity"></param> /// <param name="newFileName"></param> public static void CreateImages(string fileIdentity, string newFileName) { if (ImageList.Count == 0) { return; } var result = FileUploadManager.FileExists(fileIdentity); if (!result) { return; } var bytes = FileUploadManager.GetFileData(fileIdentity); ImageList.ForEach(v => ThreadPool.QueueUserWorkItem( delegate { var imgageHelp = new ImageUtility(); imgageHelp.ZoomAuto(bytes, (int)v.Value.Width, (int)v.Value.Height, true); })); }
/// <summary> /// 保存视频文件 /// </summary> /// <param name="fileIdentity"></param> /// <param name="destFileName"></param> public static void Save(string fileIdentity, string destFileName) { if (string.IsNullOrWhiteSpace(fileIdentity) || string.IsNullOrWhiteSpace(destFileName)) { return; } var result = FileUploadManager.FileExists(fileIdentity); if (result) { var fileExtensionName = FileUploadManager.GetFileExtensionName(fileIdentity).ToUpper(); var filePath = FileUploadManager.GetFilePhysicalFullPath(fileIdentity); if (Image360FileExtensionName.Contains(fileExtensionName)) { if (destFileName.IndexOf(".") == -1) { destFileName = destFileName + "." + fileExtensionName; } var savePath = FilePathHelp.GetFileSavePath(fileExtensionName.ToLower()); savePath += FilePathHelp.GetSubFolderName(destFileName); foreach (string localPath in LocalPathList) { string path = localPath + savePath.Replace("/", "\\"); //判断文件夹是否存在 if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } destFileName = path + destFileName; //FLV文件重命名操作,不进行DFIS处理 File.Copy(filePath, destFileName, true); } } } }
public static void CreateImagesByNewegg(string fileIdentity, string newFileName, bool isNeedWatermark) { if (ImageList.Count == 0) { return; } var result = FileUploadManager.FileExists(fileIdentity); if (!result) { return; } var bytes = FileUploadManager.GetFileData(fileIdentity); ImageList.ForEach(v => ThreadPool.QueueUserWorkItem( delegate { var imageHelp = new ImageUtility { FileName = newFileName, MidFilepath = v.Key.ToString() }; imageHelp.Upload += Upload; imageHelp.ZoomAuto(bytes, (int)v.Value.Width, (int)v.Value.Height, isNeedWatermark); })); }
/// <summary> /// 上传批量添加中文词库 /// </summary> /// <param name="uploadFileInfo"></param> public virtual void BatchImportSegment(string uploadFileInfo) { //segmentInfoAppService.BatchImportSegment(uploadFileInfo); if (FileUploadManager.FileExists(uploadFileInfo)) { string configPath = AppSettingManager.GetSetting("MKT", "PostSegmentInfoFilesPath"); if (!Path.IsPathRooted(configPath)) { configPath = Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase, configPath); } string destinationPath = Path.Combine(configPath, uploadFileInfo); string folder = Path.GetDirectoryName(destinationPath); if (!Directory.Exists(folder)) { Directory.CreateDirectory(folder); } FileUploadManager.MoveFile(uploadFileInfo, destinationPath); using (var reader = new StreamReader(destinationPath, Encoding.Default)) { var lines = new HashSet <string>(); while (!reader.EndOfStream) { var value = reader.ReadLine().Trim().Replace("\t", " "); if (!string.IsNullOrEmpty(value)) { lines.Add(value); } } if (!lines.Any()) { //throw new BizException("导入的txt文件没有任何内容"); throw new BizException(ResouceManager.GetMessageString("MKT.Keywords", "Keywords_HasNotActiveDataInTxt")); } if (lines.Count > 2000) { //throw new BizException("导入的关键字不能超过2000个"); throw new BizException(ResouceManager.GetMessageString("MKT.Keywords", "Keywords_KeywordsMoreThan2000")); } string companyCode = "8601"; //[Mark][Alan.X.Luo 硬编码] int sameSegment = 0; int failedSegment = 0; int seccussfulSegment = 0; lines.Where(e => !string.IsNullOrEmpty(e)).ForEach(e => { var keywords = e.Trim(); SegmentInfo item = new SegmentInfo(); item.Keywords = new LanguageContent(); item.Keywords.Content = e; item.Keywords.LanguageCode = "zh-CN"; item.CompanyCode = "8601"; //[Mark][Alan.X.Luo 硬编码] if (keywordDA.CheckSegmentInfo(item)) { sameSegment++; } else if (e.Length > 50) { failedSegment++; //also can add a property to counting the case } else { item.Status = KeywordsStatus.Waiting; item.CompanyCode = companyCode; keywordDA.AddSegmentInfo(item); seccussfulSegment++; } }); StringBuilder message = new StringBuilder(); if (failedSegment > 0) { //message.AppendLine(failedSegment.ToString() + "条数据导入失败!"); message.AppendLine(failedSegment.ToString() + ResouceManager.GetMessageString("MKT.Keywords", "Keywords_ImportFailed")); } if (sameSegment > 0) { //message.AppendLine(sameSegment.ToString() + "条数据已经存在数据库!"); message.AppendLine(sameSegment.ToString() + ResouceManager.GetMessageString("MKT.Keywords", "Keywords_AlreadyInDataBase")); } if (seccussfulSegment > 0) { //message.AppendLine(seccussfulSegment.ToString() + "条数据导入成功!"); message.AppendLine(seccussfulSegment.ToString() + ResouceManager.GetMessageString("MKT.Keywords", "Keywords_ImportSuccess")); } if (!string.IsNullOrEmpty(message.ToString())) { throw new BizException(message.ToString()); } } } else { //throw new BizException("上传文件丢失!"); throw new BizException(ResouceManager.GetMessageString("MKT.Keywords", "Keywords_UploadFileLost")); } }
/// <summary> /// 批量添加产品页面关键字 /// </summary> /// <param name="item"></param> //public virtual void AddProductPageKeywords(ProductPageKeywords item) //{ // keywordDA.AddProductPageKeywords(item); //} /// <summary> /// 上传批量添加产品页面关键字 /// </summary> /// <param name="uploadFileInfo"></param> public virtual void BatchImportProductKeywords(string uploadFileInfo) { if (FileUploadManager.FileExists(uploadFileInfo)) { string configPath = AppSettingManager.GetSetting("MKT", "PostProductKeywordsFilePath"); if (!Path.IsPathRooted(configPath)) { configPath = Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase, configPath); } string ExtensionName = FileUploadManager.GetFilePhysicalFullPath(uploadFileInfo); string destinationPath = Path.Combine(configPath, ExtensionName); string folder = Path.GetDirectoryName(destinationPath); if (!Directory.Exists(folder)) { Directory.CreateDirectory(folder); } FileUploadManager.MoveFile(uploadFileInfo, destinationPath); DataTable table = keywordDA.ReadExcelFileToDataTable(destinationPath); if (table != null && table.Rows != null && table.Rows.Count > 0) { if (table.Columns[0].ColumnName == "Item No#") { string ProductID = string.Empty; List <string> ProductList = new List <string>(); for (int i = 0; i < table.Rows.Count; i++) { if (table.Rows[i]["Item No#"] != DBNull.Value && !string.IsNullOrEmpty(table.Rows[i]["Item No#"].ToString())) { ProductID = table.Rows[i]["Item No#"] == null ? string.Empty : table.Rows[i]["Item No#"].ToString().Trim(); if (!ProductList.Contains(ProductID)) { ProductList.Add(ProductID); } } } int count = string.IsNullOrEmpty(AppSettingManager.GetSetting("MKT", "ProductKeywordsExcelBatchCount")) ? 100 : int.Parse(AppSettingManager.GetSetting("MKT", "ProductKeywordsExcelBatchCount")); if (ProductList.Count > count) { //throw new BizException(string.Format("导入的条数超过限制,最大{0}条!", count.ToString())); throw new BizException(string.Format(ResouceManager.GetMessageString("MKT.Keywords", "Keywords_LimitCount"), count.ToString())); } else if (ProductList.Count == 0) { //throw new BizException("导入的Excel无有效数据,导入失败!"); throw new BizException(ResouceManager.GetMessageString("MKT.Keywords", "Keywords_HasNotActiveData")); } else { foreach (string id in ProductList) { //[Mark][Alan.X.Luo 硬编码] keywordDA.InsertProductKeywordsListBatch(id, "8601"); } } } else { //throw new BizException("导入的Excel文件列名无效!"); throw new BizException(ResouceManager.GetMessageString("MKT.Keywords", "Keywords_HasNotActiveData")); } } else { //throw new BizException("Execl中没有数据,或者工作簿名称不是Sheet1或者格式不正确!"); throw new BizException(ResouceManager.GetMessageString("MKT.Keywords", "Keywords_HasNotActiveData")); } } }