public string Show(string shortPath, string imageSize = null) { string result = null; string sizePath = null; while (true) { if (string.IsNullOrWhiteSpace(shortPath)) { Error = G.L["upload_ShortPath"]; break; } EImageSize imageSizeEnum = THelper.ConvertToEnum(imageSize, EImageSize.middle); int size = Convert.ToInt32(imageSizeEnum); string sizeShortPath = FileHelper.GetSizePath(shortPath, size); string sizePathTrue = m_config.Dir + sizeShortPath + ".true"; if (File.Exists(sizePathTrue)) { result = m_config.OssUrl + sizeShortPath; break; } string path = m_config.Dir + shortPath; sizePath = m_config.Dir + sizeShortPath; if (!PsHelper.Thumb(path, sizePath, size, size)) { Error = G.L["upload_NoLargeFile"]; break; } AliOssLogic aliOss = new AliOssLogic(); if (!aliOss.Add(sizeShortPath, sizePath)) { Error = G.L["upload_OssAdd"]; break; } if (!FileHelper.CreateFile(sizePathTrue)) { Error = G.L["upload_CreateTrue"]; break; } result = m_config.OssUrl + sizeShortPath; break; } FileHelper.DeleteFile(sizePath); return(result); }
public string GetQrcode(int id, Func <bool> func) { string result = null; while (true) { if (id <= 0) { Error = G.L["qr_id"]; break; } string shortPath = string.Format(m_path, id); string path = m_serverDir + shortPath; string pathTrue = path + c_append; if (FileHelper.CheckFile(pathTrue)) { result = m_ossUrl + shortPath; break; } if (func != null) { if (!func()) { Error = G.L["qr_func"]; break; } } string home = string.Format(m_home, id); if (!GenerateQrcode(home, path)) { Error = G.L["qr_generate"]; break; } AliOssLogic aliOss = new AliOssLogic(); if (!aliOss.Add(shortPath, path)) { Error = G.L["qr_ossadd"]; break; } if (!FileHelper.CreateFile(pathTrue)) { Error = G.L["qr_createFileTrue"]; break; } if (!FileHelper.DeleteFile(path)) { Error = G.L["qr_deleteFile"]; break; } result = m_ossUrl + shortPath; break; } return(result); }