/// <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); } }
/// <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="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); } } } }
/// <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")); } } }