protected string GetImgUrl(string serverFileName, string folder) { QJVRMS.Business.ResourceType.ImageType obj = new QJVRMS.Business.ResourceType.ImageType(); //yangguang //return obj.PreviewPath_170_Read + "/" + folder + "/" + serverFileName; return obj.GetPreviewPathRead(folder, serverFileName, "170"); }
protected string GetImgUrl(string serverFileName, string folder) { QJVRMS.Business.ResourceType.ImageType obj = new QJVRMS.Business.ResourceType.ImageType(); //yangguang //return obj.PreviewPath_170_Read + "/" + folder + "/" + serverFileName; return(obj.GetPreviewPathRead(folder, serverFileName, "170")); }
/// <summary> /// 根据资源类型生成对应的类,image video document /// </summary> /// <param name="resourceType"></param> /// <returns></returns> public static IResourceType getResourceTypeByString(string resourceType) { IResourceType obj; resourceType = resourceType.ToLower(); if (resourceType.Equals("image")) { obj = new ImageType(); } else if (resourceType.Equals("video")) { obj = new VideoType(); } else if (resourceType.Equals("document")) { obj = new DocumentType(); } else { obj = new OtherType(); } return obj; }
protected string GetImgUrl(string ItemSerialNum, string ImageType, string folder) { QJVRMS.Business.ResourceType.ImageType obj = new QJVRMS.Business.ResourceType.ImageType(); //yangguang //string imagePath = obj.PreviewPath_170_Read + "/" + folder + "/" + ItemSerialNum + ImageType; if (ImageType.ToLower() == ".cr2" || ImageType.ToLower() == ".nef" || ImageType.ToLower() == ".psd") { ImageType = ".jpg"; } string imagePath = obj.GetPreviewPathRead(folder, ItemSerialNum + ImageType, "170"); return(imagePath); //return UIBiz.CommonInfo.GetImageUrl(170, folder, ItemSerialNum, ImageType); }
private bool SaveImage(string userName, string fileType, string tempPath) { ImageType obj = new ImageType(); //yangguang //string savePath = obj.SourcePath; string savePath = obj.GetSourcePath(); savePath = Path.Combine(savePath, userName); //string resourceseq = new Resource().GetSN(ResourceTypeFactory.getResourceType(fileType.Substring(1)).ResourceSNPrefix); string fileFullPath = Path.Combine(savePath, resourceseq + fileType); bool bImage = false; try { if (!Directory.Exists(savePath)) { Directory.CreateDirectory(savePath); } //保存原图 if (SaveFile(fileFullPath, tempPath)) { string SlImageRootPath = Path.Combine(obj.PreviewPath_170, userName); if (!Directory.Exists(SlImageRootPath)) Directory.CreateDirectory(SlImageRootPath); ArrayList sarray = new ArrayList(); sarray.Add(fileFullPath); ArrayList aarray = new ArrayList(); aarray.Add(Path.Combine(SlImageRootPath, resourceseq + fileType)); ImageController.ToZipImage(sarray, aarray, 170); SlImageRootPath = Path.Combine(obj.PreviewPath_400, username); if (!Directory.Exists(SlImageRootPath)) Directory.CreateDirectory(SlImageRootPath); sarray = new ArrayList(); sarray.Add(fileFullPath); aarray = new ArrayList(); aarray.Add(Path.Combine(SlImageRootPath, resourceseq + fileType)); ImageController.ToZipImage(sarray, aarray, 400); bImage = true; } } catch (Exception e1) { LogWriter.WriteExceptionLog(e1, true); return false; } finally { } return bImage; }
protected string GetImgUrl(string ItemSerialNum, string ImageType, string folder) { QJVRMS.Business.ResourceType.ImageType obj = new QJVRMS.Business.ResourceType.ImageType(); //yangguang //string imagePath = obj.PreviewPath_170_Read + "/" + folder + "/" + ItemSerialNum + ImageType; if (ImageType.ToLower() == ".cr2" || ImageType.ToLower() == ".nef" || ImageType.ToLower() == ".psd") ImageType = ".jpg"; string imagePath = obj.GetPreviewPathRead(folder, ItemSerialNum + ImageType, "170"); return imagePath; //return UIBiz.CommonInfo.GetImageUrl(170, folder, ItemSerialNum, ImageType); }
protected void Page_Load(object sender, EventArgs e) { try { string state = get_LinkParam("state"); string path = Server.MapPath(SAVEPATH); if (string.IsNullOrEmpty(state)) { string temppath = Server.MapPath(TEMPPATH); if (File.Exists(temppath)) path = temppath; } string showType = get_LinkParam("show"); if (string.IsNullOrEmpty(showType)) { XmlDocument doc = new XmlDocument(); doc.Load(Server.MapPath(XMLPATH)); if (doc != null) { XmlNode node = doc.SelectSingleNode("Root/ShowType"); showType = node.InnerText; } } ImageType obj = new ImageType(); FileStream s = new FileStream(Server.MapPath(EXAMPLEPATH), FileMode.Open, FileAccess.Read); byte[] b = new byte[int.Parse(s.Length.ToString())]; s.Read(b, 0, int.Parse(s.Length.ToString())); s.Close(); FileStream s1 = new FileStream(path, FileMode.Open, FileAccess.Read); byte[] b1 = new byte[int.Parse(s1.Length.ToString())]; s1.Read(b1, 0, int.Parse(s1.Length.ToString())); s1.Close(); QJImagePro.Handles.PictureHandle pic = QJImagePro.PictureFactory.CreateHandle(QJImagePro.PictureType.Jpeg); byte[] by = pic.Watermarking(b, b1, 72, int.Parse(showType)); HttpContext.Current.Response.ClearContent(); HttpContext.Current.Response.ContentType = "image/Jpeg"; HttpContext.Current.Response.BinaryWrite(by); } catch { Response.Write("图片路径不正确!"); Response.End(); } }
private void InitData() { GiftBiz biz = new GiftBiz(); DataTable dt = biz.GetGiftTypeList(); ddlGiftType.DataSource = dt; ddlGiftType.DataTextField = "TypeName"; ddlGiftType.DataValueField = "TypeID"; ddlGiftType.DataBind(); if (ViewState["Id"] != null) { GiftInfo model = biz.GetModel(ViewState["Id"].ToString()); if (model != null) { txtTitle.Text = model.Title; txtRemark.Text = model.Remark; txtQuantity.Text = model.Quantity.ToString(); ddlGiftType.SelectedValue = model.TypeId; Resource objResource = new Resource(); ResourceEntity model1 = null; ImageType objImg = new ImageType(); model1 = objResource.GetResourceInfoByItemId(model.ImageId.ToString()); imgGift.ImageUrl = objImg.GetPreviewPathRead(model1.FolderName, model1.ServerFileName, "170"); //objImg.ge /* ImageStorage imageModel = ImageStorage.GetImageStorageModel(new Guid(model.ImageId)); imgGift.ImageUrl = UIBiz.CommonInfo.GetImageUrl(170, imageModel.FolderName, imageModel.ItemSerialNum, imageModel.ImageType); */ this.catalogTree.ImagesItemId = model.ImageId; } } }
/// <summary> /// 根据文件扩展名来生成对应的资源类型 /// </summary> /// <param name="fileExtention"></param> /// <returns></returns> public static IResourceType getResourceType(string fileExtention) { IResourceType obj; fileExtention = fileExtention.ToLower(); if (ArrayContains(new ImageType().FileExtention, fileExtention)) { obj = new ImageType(); } else if (ArrayContains(new VideoType().FileExtention, fileExtention)) { obj = new VideoType(); } else if (ArrayContains(new DocumentType().FileExtention, fileExtention)) { obj = new DocumentType(); } else { obj = new OtherType(); } return obj; }
protected void btnDelete_Click(object sender, EventArgs e) { string[] ids = chbIds.Value.Split(",".ToCharArray()); ResourceEntity re = null; Resource r = new Resource(); foreach (string id in ids) { //单个删除 re = r.GetResourceInfoByItemId(id); string ItemSerialNum = ""; string ImageType = ""; string str = "";//判断170图片或者400图片有没有被删除 bool isValidate = Resource.DeleteResource(re.ItemId); string attachmentFolder = string.Empty; string sourceFolder = string.Empty; string attachmentsFolder = string.Empty; if (re.ResourceType.ToLower().Equals("image")) { string _170Folder; string _400Folder; ImageType obj = new ImageType(); //yangguang //sourceFolder = obj.SourcePath; //attachmentsFolder = obj.SourcePath; //_170Folder = obj.PreviewPath_170; //_400Folder = obj.PreviewPath_400; //sourceFolder = Path.Combine(sourceFolder, re.FolderName); //_170Folder = Path.Combine(_170Folder, re.FolderName); //_400Folder = Path.Combine(_400Folder, re.FolderName); //try //{ // File.Delete(Path.Combine(sourceFolder, re.ServerFileName)); // File.Delete(Path.Combine(_170Folder, re.ServerFileName)); // File.Delete(Path.Combine(_400Folder, re.ServerFileName)); //} //catch { } try { File.Delete(obj.GetSourcePath(re.FolderName, re.ServerFileName)); attachmentsFolder = obj.SourcePaths[obj.PathNumber].Trim(); File.Delete(obj.GetPreviewPath(re.FolderName, re.ServerFileName, "170")); File.Delete(obj.GetPreviewPath(re.FolderName, re.ServerFileName, "400")); } catch { } //这里还要加上附件的删除 DataTable dt = Resource.GetAttachList(new Guid(id)); string fileName = ""; attachmentsFolder = Path.Combine(attachmentsFolder, re.FolderName); attachmentsFolder = Path.Combine(attachmentsFolder, UIBiz.CommonInfo.AttachFolder); for (int i = 0; i < dt.Rows.Count; i++) { fileName = dt.Rows[i]["fileName"].ToString(); fileName = Path.Combine(attachmentsFolder, fileName); try { File.Delete(fileName); } catch (Exception ex) { LogWriter.WriteExceptionLog(ex); } } } } bind(); }
protected void Page_Load(object sender, EventArgs e) { string result = string.Empty; string type = get_LinkParam("type"); string id = string.Empty; string body = string.Empty; Resource rs = new Resource(); switch (type) { case "orderNew"://OrderNew.aspx string mailFrom = ConfigurationManager.AppSettings["mailFrom"]; string mailSubject1 = ConfigurationManager.AppSettings["mailSubject"]; if (string.IsNullOrEmpty(mailSubject1)) { mailSubject1 = "有新的订单"; } Tool t1 = new Tool(); mailFrom = t1.GetValue(Tool.GetDocument("/xml/System.xml"), "from"); if (Session["OrderNew"] != null && Session["OrderNew"].ToString() != string.Empty) body = Session["OrderNew"].ToString(); Orders obj1 = new Orders(); obj1.sendNewOrder(mailFrom, mailSubject1, body); break; case "validate"://Validating.aspx string mail = get_LinkParam("mail"); string subject = get_LinkParam("subject"); if (Session["Validate"] != null && Session["Validate"].ToString() != string.Empty) body = Session["Validate"].ToString(); Tool t = new Tool(); XmlDocument doc = Tool.GetDocument("/xml/System.xml"); string smtpHost = t.GetValue(doc, "host"); string smtpUserName = t.GetValue(doc, "userName"); string smtpPassword = t.GetValue(doc, "password"); string fromEmail = t.GetValue(doc, "from"); Tool.sendMail(smtpHost, smtpUserName, smtpPassword, fromEmail, mail, subject, body); break; case "send"://OrdersManage.aspx OrderNotPass.aspx OrderDetail.aspx string _userEmail = get_LinkParam("mail"); string mailSubject = get_LinkParam("subject"); string mailBody = string.Empty; if (Session["MailBody"] != null && Session["MailBody"].ToString() != string.Empty) mailBody = Session["MailBody"].ToString(); if (!string.IsNullOrEmpty(_userEmail) && !string.IsNullOrEmpty(mailBody)) { Orders obj = new Orders(); obj.sendNewOrderToUser(_userEmail, mailSubject, mailBody); } break; case "error": //error.aspx string html = string.Empty; if(Session["ErrorHtml"] != null && Session["ErrorHtml"].ToString() != string.Empty) html = Session["ErrorHtml"].ToString(); if (!string.IsNullOrEmpty(html)) { XmlDocument doc1 = Tool.GetDocument("/xml/System.xml"); Tool tool = new Tool(); string host = tool.GetValue(doc1, "host"); string username = tool.GetValue(doc1, "userName"); string pass = tool.GetValue(doc1, "password"); string from = tool.GetValue(doc1, "from"); string adminUid = ConfigurationManager.AppSettings["superAdminId"]; string adminEmail = new MemberShipManager().GetUserEmailByUserID(adminUid); string to = adminEmail; string subject1 = "错误信息"; Tool.sendMail(host, username, pass, from, to, subject1, html); } break; case "exif": #region EXIF信息 string folderName = get_LinkParam("folder"); string fileName = get_LinkParam("file"); string yRootPath = string.Empty; try { ImageType obj = new ImageType(); yRootPath = obj.GetSourcePath(folderName, fileName); EXIFMetaData em = new EXIFMetaData(); EXIFMetaData.Metadata m = em.GetEXIFMetaData(yRootPath); StringBuilder sb = new StringBuilder(); sb.Append("<table>"); sb.Append("<tr><td align=\"left\" valign=\"top\" width=\"100px\">"); sb.Append("<span>设备制造商:</span>"); sb.Append("</td><td style=\"word-wrap:break-word;word-break:break-all;\">"); sb.Append("<strong>"); sb.Append(string.IsNullOrEmpty(m.EquipmentMake.DisplayValue) ? string.Empty : m.EquipmentMake.DisplayValue.Replace("\0", string.Empty)); sb.Append("</strong>"); sb.Append("</td></tr>"); sb.Append("<tr><td align=\"left\" valign=\"top\" width=\"100px\">"); sb.Append("<span>摄影机型号:</span>"); sb.Append("</td><td>"); sb.Append("<strong>"); sb.Append(string.IsNullOrEmpty(m.CameraModel.DisplayValue) ? string.Empty : m.CameraModel.DisplayValue.Replace("\0", string.Empty)); sb.Append("</strong>"); sb.Append("</td></tr>"); sb.Append("<tr><td align=\"left\" valign=\"top\" width=\"100px\">"); sb.Append("<span>颜色表示:</span>"); sb.Append("</td><td>"); sb.Append("<strong>"); sb.Append(string.IsNullOrEmpty(m.ColorSpace.DisplayValue) ? string.Empty : m.ColorSpace.DisplayValue); sb.Append("</strong>"); sb.Append("</td></tr>"); sb.Append("<tr><td align=\"left\" valign=\"top\" width=\"100px\">"); sb.Append("<span>闪关灯模式:</span>"); sb.Append("</td><td>"); sb.Append("<strong>"); sb.Append(string.IsNullOrEmpty(m.Flash.DisplayValue) ? string.Empty : m.Flash.DisplayValue); sb.Append("</strong>"); sb.Append("</td></tr>"); sb.Append("<tr><td align=\"left\" valign=\"top\" width=\"100px\">"); sb.Append("<span>焦距:</span>"); sb.Append("</td><td>"); sb.Append("<strong>"); sb.Append(string.IsNullOrEmpty(m.FocalLength.DisplayValue) ? string.Empty : m.FocalLength.DisplayValue); sb.Append("</strong>"); sb.Append("</td></tr>"); sb.Append("<tr><td align=\"left\" valign=\"top\" width=\"100px\">"); sb.Append("<span>曝光时间:</span>"); sb.Append("</td><td>"); sb.Append("<strong>"); sb.Append(string.IsNullOrEmpty(m.ExposureTime.DisplayValue) ? string.Empty : m.ExposureTime.DisplayValue); sb.Append("</strong>"); sb.Append("</td></tr>"); sb.Append("<tr><td align=\"left\" valign=\"top\" width=\"100px\"><span>ISO:</span>"); sb.Append("</td><td>"); sb.Append("<strong>"); sb.Append(string.IsNullOrEmpty(m.ISOSpeed.DisplayValue) ? string.Empty : m.ISOSpeed.DisplayValue); sb.Append("</strong>"); sb.Append("</td></tr>"); sb.Append("<tr><td align=\"left\" valign=\"top\" width=\"100px\"><span>光源:</span>"); sb.Append("</td><td>"); sb.Append("<strong>"); sb.Append(string.IsNullOrEmpty(m.LightSource.DisplayValue) ? string.Empty : m.LightSource.DisplayValue); sb.Append("</strong>"); sb.Append("</td></tr>"); sb.Append("<tr><td align=\"left\" valign=\"top\" width=\"100px\"><span>曝光程序:</span>"); sb.Append("</td><td>"); sb.Append("<strong>"); sb.Append(string.IsNullOrEmpty(m.ExposureProg.DisplayValue) ? string.Empty : m.ExposureProg.DisplayValue); sb.Append("</strong>"); sb.Append("</td></tr>"); sb.Append("<tr><td align=\"left\" valign=\"top\" width=\"100px\"><span>曝光补偿:</span>"); sb.Append("</td><td>"); sb.Append("<strong>"); sb.Append(string.IsNullOrEmpty(m.ExposureBias.DisplayValue) ? string.Empty : m.ExposureBias.DisplayValue); sb.Append("</strong>"); sb.Append("</td></tr>"); sb.Append("<tr><td align=\"left\" valign=\"top\" width=\"100px\"><span>相机拍照时间:</span>"); sb.Append("</td><td>"); sb.Append("<strong>"); sb.Append(string.IsNullOrEmpty(m.DatePictureTaken.DisplayValue) ? string.Empty : m.DatePictureTaken.DisplayValue.Replace("\0", string.Empty)); sb.Append("</strong>"); sb.Append("</td></tr>"); sb.Append("<tr><td align=\"left\" valign=\"top\" width=\"100px\"><span>宽度:</span>"); sb.Append("</td><td>"); sb.Append("<strong>"); sb.Append(string.IsNullOrEmpty(m.ImageWidth.DisplayValue) ? string.Empty : m.ImageWidth.DisplayValue); sb.Append("</strong>"); sb.Append("</td></tr>"); sb.Append("<tr><td align=\"left\" valign=\"top\" width=\"100px\"><span>高度:</span>"); sb.Append("</td><td>"); sb.Append("<strong>"); sb.Append(string.IsNullOrEmpty(m.ImageHeight.DisplayValue) ? string.Empty : m.ImageHeight.DisplayValue); sb.Append("</strong>"); sb.Append("</td></tr>"); sb.Append("<tr><td align=\"left\" valign=\"top\" width=\"100px\"><span>水平分辨率:</span>"); sb.Append("</td><td>"); sb.Append("<strong>"); sb.Append(string.IsNullOrEmpty(m.XResolution.DisplayValue) ? string.Empty : m.XResolution.DisplayValue); sb.Append("</strong>"); sb.Append("</td></tr>"); sb.Append("<tr><td align=\"left\" valign=\"top\" width=\"100px\"><span>垂直分辨率:</span>"); sb.Append("</td><td>"); sb.Append("<strong>"); sb.Append(string.IsNullOrEmpty(m.YResolution.DisplayValue) ? string.Empty : m.YResolution.DisplayValue); sb.Append("</strong>"); sb.Append("</td></tr>"); sb.Append("</table>"); result = sb.ToString(); } catch { if (string.IsNullOrEmpty(result)) { result = "<span style=\"color:red; padding:5px 5px 5px 5px;\">获取信息失败!!</span>"; } } #endregion break; } Response.Write(result); Response.End(); }
//删除文件 protected void btnDel_Click(object sender, EventArgs e) { ResourceEntity re = null; Resource r = new Resource(); if (ViewState["model"] != null) { re = ViewState["model"] as ResourceEntity; } else { re = r.GetResourceInfoByItemId(this.Hidden_ItemId.Value); } string ItemSerialNum = ""; string ImageType = ""; string str = "";//判断170图片或者400图片有没有被删除 ItemSerialNum = lb_ItemSerialNum.Text; //ImageType = lb_ImageType.Text; //bool isValidate = QJVRMS.Business.ImageStorageClass.DeleteImageStorage(new Guid(this.Hidden_ItemId.Value)); bool isValidate = Resource.DeleteResource(re.ItemId); string attachmentFolder = string.Empty; string sourceFolder = string.Empty; string attachmentsFolder = string.Empty; if (re.ResourceType.ToLower().Equals("image")) { string _170Folder; string _400Folder; ImageType obj = new ImageType(); //yangguang //sourceFolder = obj.SourcePath; //attachmentsFolder = obj.SourcePath; //_170Folder = obj.PreviewPath_170; //_400Folder = obj.PreviewPath_400; //sourceFolder = Path.Combine(sourceFolder, re.FolderName); //_170Folder = Path.Combine(_170Folder, re.FolderName); //_400Folder = Path.Combine(_400Folder, re.FolderName); //try { // File.Delete(Path.Combine(sourceFolder, re.ServerFileName)); // File.Delete(Path.Combine(_170Folder, re.ServerFileName)); // File.Delete(Path.Combine(_400Folder, re.ServerFileName)); //} //catch { } try { File.Delete(obj.GetSourcePath(re.FolderName, re.ServerFileName)); attachmentsFolder = obj.SourcePaths[obj.PathNumber].Trim(); File.Delete(obj.GetPreviewPath(re.FolderName, re.ServerFileName, "170")); File.Delete(obj.GetPreviewPath(re.FolderName, re.ServerFileName, "400")); } catch { } } else if (re.ResourceType.ToLower().Equals("video")) { string _previewPolder = CommonInfo.VideoPreviewPath; VideoType obj = new VideoType(); //sourceFolder = obj.SourcePath; //attachmentsFolder = obj.SourcePath; //_previewPolder = obj.PreviewPath; //try { // File.Delete(Path.Combine(sourceFolder, re.ServerFileName)); // File.Delete(Path.Combine(Path.Combine(Path.Combine(_previewPolder, "flv"), re.FolderName), re.ServerFileName)); // File.Delete(Path.Combine(Path.Combine(Path.Combine(_previewPolder, "image"), re.FolderName), re.ServerFileName)); // File.Delete(Path.Combine(Path.Combine(Path.Combine(_previewPolder, "smallflv"), re.FolderName), re.ServerFileName)); //} //catch { //} try { File.Delete(obj.GetSourcePath(string.Empty, re.ServerFileName)); attachmentsFolder = obj.SourcePaths[obj.PathNumber].Trim(); File.Delete(obj.GetPreviewPath(re.FolderName, re.ServerFileName, "flv")); File.Delete(obj.GetPreviewPath(re.FolderName, re.ServerFileName, "image")); File.Delete(obj.GetPreviewPath(re.FolderName, re.ServerFileName, "smallflv")); } catch { } } //sourceFolder = Path.Combine(sourceFolder, CurrentUser.UserLoginName); //sourceFolder = Path.Combine(sourceFolder, WebUI.UIBiz.CommonInfo.AttachFolder); #region 删除物理文件 by ciqq 2010-4-2 //SlImageRootPath = WebUI.UIBiz.CommonInfo.SlImageRootPath170; //if (Directory.Exists(SlImageRootPath + "\\" + CurrentUser.UserLoginName)) //{ // File.Delete(SlImageRootPath + "\\" + CurrentUser.UserLoginName + "\\" + ItemSerialNum + ImageType); // str = "170目录下的图片已被删除!"; //} //SlImageRootPath = WebUI.UIBiz.CommonInfo.SlImageRootPath400; //if (Directory.Exists(SlImageRootPath + "\\" + CurrentUser.UserLoginName)) //{ // File.Delete(SlImageRootPath + "\\" + CurrentUser.UserLoginName + "\\" + ItemSerialNum + ImageType); // str += "400目录下的图片已被删除!"; //} //SlImageRootPath = WebUI.UIBiz.CommonInfo.ImageRootPath; //if (Directory.Exists(SlImageRootPath + "\\" + CurrentUser.UserLoginName)) //{ // File.Delete(SlImageRootPath + "\\" + CurrentUser.UserLoginName + "\\" + ItemSerialNum + ImageType); // str += "Source目录下的图片已被删除!"; //} //删除所有的附件 //string sourceFolder = Path.Combine(WebUI.UIBiz.CommonInfo.ImageRootPath, this.hiFolder.Value); string fileName = ""; attachmentsFolder = Path.Combine(attachmentsFolder, re.FolderName); attachmentsFolder = Path.Combine(attachmentsFolder, UIBiz.CommonInfo.AttachFolder); for (int i = 0; i < this.attList.Rows.Count; i++) { fileName = this.attList.DataKeys[i].Values[1].ToString(); fileName = Path.Combine(attachmentsFolder, fileName); try { File.Delete(fileName); } catch(Exception ex) { LogWriter.WriteExceptionLog(ex); } } //foreach (GridViewRow gvr in this.attList.Rows) { // fileName = Path.Combine(attachmentFolder, gvr.Cells[0].Text); // try { // File.Delete(fileName); // } // catch (Exception ex) { // LogWriter.WriteExceptionLog(ex); // } //} #endregion LogEntity model = new LogEntity(); model.id = Guid.NewGuid(); model.userId = CurrentUser.UserId; model.userName = CurrentUser.UserLoginName; model.EventType = ((int)LogType.DeleteResource).ToString(); model.EventResult = "成功"; model.EventContent = "图片序号:" + re.ItemSerialNum; model.IP = HttpContext.Current.Request.UserHostAddress; model.AddDate = DateTime.Now; new Logs().Add(model); Response.Write("<script language='javascript'>window.close();</script>"); Response.End(); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string ids = Request.QueryString["ids"]; if (string.IsNullOrEmpty(ids)) { return; } ids = ids.TrimEnd(";".ToCharArray()); string[] arrIds = ids.Split(";".ToCharArray()); ImageType objImageType = new ImageType(); IResourceType rt = null; string physicalPath = string.Empty; List<string> zipFileList = new List<string>(); foreach (string id in arrIds) { ResourceEntity re = null; Resource r = new Resource(); re = r.GetResourceInfoByItemId(id); //physicalPath = objImageType.GetSourcePath(re.FolderName, re.ServerFileName); rt = ResourceTypeFactory.getResourceTypeByString(re.ResourceType); physicalPath = rt.GetSourcePath(re.FolderName, re.ServerFileName); if (!string.IsNullOrEmpty(physicalPath)) { zipFileList.Add(physicalPath); } //记录下载日志 Resource.Production_Hires_Down_Log(re.ItemSerialNum,Path.GetExtension(re.ServerFileName), CurrentUser.UserName, "", "", re.FolderName, false, re.ResourceType); } Response.ContentType = "application/octet-stream"; Response.AppendHeader("content-disposition", "attachment; filename=\"Download.zip\""); Response.CacheControl = "Private"; Response.Cache.SetExpires(DateTime.Now.AddMinutes(3)); byte[] buffer = new byte[4096]; ZipOutputStream zipOutputStream = new ZipOutputStream(Response.OutputStream); zipOutputStream.SetLevel(3); foreach (string fileName in zipFileList) { Stream fs = File.OpenRead(fileName); // or any suitable inputstream ZipEntry entry = new ZipEntry(ZipEntry.CleanName(Path.GetFileName(fileName))); entry.Size = fs.Length; zipOutputStream.PutNextEntry(entry); int count = fs.Read(buffer, 0, buffer.Length); while (count > 0) { zipOutputStream.Write(buffer, 0, count); count = fs.Read(buffer, 0, buffer.Length); if (!Response.IsClientConnected) { break; } Response.Flush(); } fs.Close(); } zipOutputStream.Close(); Response.Flush(); Response.End(); } }
protected void attList_RowDeleting(object sender, GridViewDeleteEventArgs e) { ResourceEntity re = null; Resource r = new Resource(); if (ViewState["model"] != null) { re = ViewState["model"] as ResourceEntity; } else { re = r.GetResourceInfoByItemId(this.Hidden_ItemId.Value); } string sourceFolder = string.Empty; ImageType imageType = new ImageType(); if (re.ResourceType.ToLower().Equals("image")) { sourceFolder = imageType.SourcePath;//CommonInfo.ImageRootPath; } else if (re.ResourceType.ToLower().Equals("video")) { sourceFolder = imageType.VideoPath;//CommonInfo.VideoRootPath; } sourceFolder = Path.Combine(sourceFolder, re.FolderName); sourceFolder = Path.Combine(sourceFolder, WebUI.UIBiz.CommonInfo.AttachFolder); //sourceFolder = Path.Combine(WsourceFolder, this.hiFolder.Value); //sourceFolder = Path.Combine(sourceFolder, UIBiz.CommonInfo.AttachFolder); string fileName = this.attList.DataKeys[e.RowIndex].Values[1].ToString();//this.attList.Rows[e.RowIndex].Cells[0].Text; fileName = Path.Combine(sourceFolder, fileName); try { File.Delete(fileName); string key = this.attList.DataKeys[e.RowIndex].Values[0].ToString(); Resource.DeleteAttach(new Guid(key)); LoadAttach(); } catch (Exception ex) { LogWriter.WriteExceptionLog(ex); } }
protected void GetImageInfo(Guid itemId) { Resource rs = new Resource(); ResourceEntity r = rs.GetResourceInfoByItemId(itemId.ToString()); if (!r.ResourceType.ToLower().Equals("image")) { return; } //水印图片 FileStream s1 = new FileStream(Server.MapPath(IMAGEPATH), FileMode.Open, FileAccess.Read); byte[] b1 = new byte[int.Parse(s1.Length.ToString())]; s1.Read(b1, 0, int.Parse(s1.Length.ToString())); s1.Close(); ImageType obj = new ImageType(); //yangguang //string strPhysicalPath = Path.Combine(Path.Combine(obj.SourcePath,r.FolderName),r.ServerFileName); string strPhysicalPath = obj.GetSourcePath(r.FolderName, r.ServerFileName); if (File.Exists(strPhysicalPath)) { Stream iStream = null; String tmpFilePath=string.Empty; try { byte[] buffer = new Byte[10000]; int length; long dataToRead; string filepath = strPhysicalPath; string filename = Path.GetFileName(filepath); //压缩 String tmpFileName=DateTime.Now.ToString("yyyyMMddhhmmss")+".bin"; //yangguang //tmpFilePath=Path.Combine(obj.SourcePath,tmpFileName); tmpFilePath = Path.Combine(obj.SourcePaths[obj.PathNumber].Trim(), tmpFileName);//obj.GetSourcePath(string.Empty, tmpFileName); System.Drawing.Image srcImage = System.Drawing.Image.FromFile(filepath); int imgWidth = srcImage.Width; int imgHeight = srcImage.Height; if (imgWidth > 1000 || imgHeight > 1000) { ArrayList sarray = new ArrayList(); sarray.Add(strPhysicalPath); ArrayList aarray = new ArrayList(); aarray.Add(tmpFilePath); ImageController.ToZipImage(sarray, aarray, 1000); iStream = new FileStream(tmpFilePath, FileMode.Open, FileAccess.Read, FileShare.Read); } else { iStream = new FileStream(filepath, FileMode.Open, FileAccess.Read, FileShare.Read); } //用户选择的原图 byte[] b = new byte[int.Parse(iStream.Length.ToString())]; iStream.Read(b, 0, int.Parse(iStream.Length.ToString())); iStream.Close(); QJImagePro.Handles.PictureHandle pic = QJImagePro.PictureFactory.CreateHandle(QJImagePro.PictureType.Jpeg); string showType = GetShowType(); int type = string.IsNullOrEmpty(showType) ? 0 : int.Parse(showType); byte[] by = pic.Watermarking(b, b1, 72, type); Response.ContentType = "image/Jpeg"; Response.BinaryWrite(by); } catch (Exception ex) { LogWriter.WriteExceptionLog(ex); } finally { if (iStream != null) { iStream.Close(); } if (File.Exists(tmpFilePath)) { File.Delete(tmpFilePath); } } } }
/// <summary> /// 返回源文件的拍摄日期,用了EXIFEextactor第三方组件 /// </summary> /// <param name="serverFileName"></param> /// <param name="serverFolderName"></param> /// <param name="resourceType"></param> /// <param name="previewType"></param> /// <returns></returns> public static DateTime GetResourceShotDateTime(string serverFileName,string serverFolderName,string resourceType,string previewType) { DateTime dt=DateTime.MinValue; string filePath = string.Empty; string folder = string.Empty; if (resourceType.ToLower().Equals("image")) { IResourceType obj = new ImageType(); //yangguang //folder = obj.SourcePath; //folder = Path.Combine(folder, serverFolderName); //filePath = Path.Combine(folder, serverFileName); filePath = obj.GetSourcePath(serverFolderName, serverFileName); try { Goheer.EXIF.EXIFextractor er2 = new Goheer.EXIF.EXIFextractor(filePath, "", ""); string s = string.Empty; if (er2["DTDigitized"] != null) { s = er2["DTDigitized"].ToString(); } else if (er2["DTOrig"] != null) { s = er2["DTOrig"].ToString(); } else if (er2["Date Time"] != null) { s = er2["Date Time"].ToString(); } if (!string.IsNullOrEmpty(s)) { string[] arr = s.Split(" ".ToCharArray()); string s1 = arr[0].Replace(":", "-") + " " + arr[1]; dt = Convert.ToDateTime(s1.ToString()); } } catch (Exception ex) { LogWriter.WriteExceptionLog(ex); } } else if (resourceType.ToLower().Equals("video")) { } return dt; }
public void ProcessRequest(HttpContext context) { //context.Response.ContentType = "text/plain"; //context.Response.Write("Hello World"); HttpRequest Request = context.Request; HttpResponse Response = context.Response; Response.ContentType = "text/plain"; string action = Request.QueryString["action"]; if (string.IsNullOrEmpty(action)) { } else if (action.Trim().ToLower().Equals("validatealert")) { //是否提醒 Resource obj = new Resource(); string userId = Request.QueryString["userId"]; string isSuperAdmin=Request.QueryString["isSuperAdmin"]; if (!string.IsNullOrEmpty(userId)) { if(string.IsNullOrEmpty(isSuperAdmin)) { isSuperAdmin="0"; } if (obj.IsAlertAdmin(new Guid(userId),isSuperAdmin)) { Response.Write("1"); //有新的图片等待审核 Response.End(); } else { Response.Write("0"); //没有需要审核的图片 Response.End(); } } Response.Write("0"); //不用提醒 Response.End(); } else if (action.Trim().ToLower().Equals("delbatch")) { //批量删除 string itemIds = Request.Form["itemIds"]; if (string.IsNullOrEmpty(itemIds)) { Response.Write("0"); //参数错误 Response.End(); } itemIds = itemIds.TrimEnd(";".ToCharArray()); string userId = Request.QueryString["userId"]; string[] arrId = itemIds.Split(";".ToCharArray()); foreach (string id in arrId) { //删除的图片要记录一下 byte[] buffer; ResourceEntity re = null; Resource r = new Resource(); re = r.GetResourceInfoByItemId(id); string ItemSerialNum = ""; string ImageType = ""; string str = "";//判断170图片或者400图片有没有被删除 ItemSerialNum = re.ItemSerialNum; //ItemSerialNum = lb_ItemSerialNum.Text; //ImageType = lb_ImageType.Text; //bool isValidate = QJVRMS.Business.ImageStorageClass.DeleteImageStorage(new Guid(this.Hidden_ItemId.Value)); bool isValidate = Resource.DeleteResource(re.ItemId); string attachmentFolder = string.Empty; string sourceFolder = string.Empty; string attachmentsFolder = string.Empty; if (re.ResourceType.ToLower().Equals("image")) { string _170Folder; string _400Folder; ImageType obj = new ImageType(); try { //记录图片 string img = obj.GetPreviewPath(re.FolderName, re.ServerFileName, "170"); ImageHelper objImgHelper = new ImageHelper(img); objImgHelper.Resize(80); using (MemoryStream ms = new MemoryStream()) { objImgHelper.GetImage().Save(ms, ImageFormat.Jpeg); buffer = ms.ToArray(); } objImgHelper.Dispose(); //记录日志 if (!string.IsNullOrEmpty(userId)) { User objUser = new MemberShipManager().GetUser(new Guid(userId)); if (objUser != null) { //日志,所有的删除,只记录一次 LogEntity model = new LogEntity(); model.id = Guid.NewGuid(); model.userId = objUser.UserId; model.userName = objUser.UserLoginName; model.EventType = ((int)LogType.DeleteResource).ToString(); model.EventResult = "成功"; model.EventContent = "图片序号:"+re.ItemSerialNum; model.IP = HttpContext.Current.Request.UserHostAddress; model.AddDate = DateTime.Now; new Logs().Add(model); r.SaveDeletedImage(model.id, buffer); } } File.Delete(obj.GetSourcePath(re.FolderName, re.ServerFileName)); attachmentsFolder = obj.SourcePaths[obj.PathNumber].Trim(); File.Delete(obj.GetPreviewPath(re.FolderName, re.ServerFileName, "170")); File.Delete(obj.GetPreviewPath(re.FolderName, re.ServerFileName, "400")); } catch { } } else if (re.ResourceType.ToLower().Equals("video")) { string _previewPolder = CommonInfo.VideoPreviewPath; VideoType obj = new VideoType(); try { File.Delete(obj.GetSourcePath(string.Empty, re.ServerFileName)); attachmentsFolder = obj.SourcePaths[obj.PathNumber].Trim(); File.Delete(obj.GetPreviewPath(re.FolderName, re.ServerFileName, "flv")); File.Delete(obj.GetPreviewPath(re.FolderName, re.ServerFileName, "image")); File.Delete(obj.GetPreviewPath(re.FolderName, re.ServerFileName, "smallflv")); } catch { } } //sourceFolder = Path.Combine(sourceFolder, CurrentUser.UserLoginName); //sourceFolder = Path.Combine(sourceFolder, WebUI.UIBiz.CommonInfo.AttachFolder); #region 删除物理文件 by ciqq 2010-4-2 //删除所有的附件 //string sourceFolder = Path.Combine(WebUI.UIBiz.CommonInfo.ImageRootPath, this.hiFolder.Value); //根据资源ID获得所有的附件 DataTable dt = Resource.GetAttachList(new Guid(id)); //dt.Columns.Add("fileNamefileLength"); //foreach (DataRow dr in dt.Rows) //{ // dr["fileNamefileLength"] = dr["filename"].ToString() + " ( " + Tool.toFileSize(Convert.ToInt64(dr["fileLength"].ToString())) + " ) "; //} //this.attList.DataSource = dt; //this.attList.DataBind(); string fileName = ""; attachmentsFolder = Path.Combine(attachmentsFolder, re.FolderName); attachmentsFolder = Path.Combine(attachmentsFolder, UIBiz.CommonInfo.AttachFolder); for (int i = 0; i < dt.Rows.Count; i++) { //fileName = this.attList.DataKeys[i].Values[1].ToString(); fileName = dt.Rows[i]["filename"].ToString(); fileName = Path.Combine(attachmentsFolder, fileName); try { File.Delete(fileName); } catch (Exception ex) { LogWriter.WriteExceptionLog(ex); } } #endregion } Response.Write("0"); //不用提醒 Response.End(); } }
protected void GetImageInfo(Guid itemId) { Resource rs = new Resource(); ResourceEntity r = rs.GetResourceInfoByItemId(itemId.ToString()); //更新浏览次数 rs.UpdateResourceViewCount(itemId.ToString()); ImageType obj = new ImageType(); //yangguang //string yRootPath = obj.PreviewPath_400_Read; // 400预览图路径 folderName = r.FolderName; serviceFileName = r.ServerFileName; //yRootPath = yRootPath + r.FolderName + @"/" + r.ServerFileName; string yRootPath = obj.GetPreviewPathRead(r.FolderName, r.ServerFileName, "400"); folder = r.FolderName; //this.imgsrc.Src = yRootPath; this.lb_Description.Text = GetString(r.Description, 25); this.lb_FileName.Text = r.FileName; this.lb_Caption.Text = GetString(r.Caption, 25); this.lb_Author.Text = r.Author; this.lb_fileLength.Text = QJVRMS.Common.Tool.toFileSize(r.FileSize); this.lb_ImageType.Text = Path.GetExtension(r.FileName); this.lb_ItemSerialNum.Text = r.ItemSerialNum; this.lb_Keyword.Text = r.Keyword; this.lb_shotDate.Text = r.shotDate.ToString("yyyy-MM-dd"); this.lb_uploadDate.Text = r.uploadDate.ToString("yyyy-MM-dd"); this.pageTitle.Text = r.Caption; this.lb_viewCount.Text = r.ViewCount.ToString(); string enableDate = ""; if (r.StartDate.ToString("yyyy-MM-dd") != "1900-01-01") { enableDate += r.StartDate.ToString("yyyy-MM-dd"); } enableDate += " -- "; if (r.EndDate.ToString("yyyy-MM-dd") != "1900-01-01") { enableDate += r.EndDate.ToString("yyyy-MM-dd"); } this.lb_SN.Text = r.ItemSerialNum; //if (enableDate != " -- ") { // this.lb_enableDate.Text = enableDate; //} //if (r.HasCopyright == 1) { // this.pSource.Visible = false; //} //else { // this.pSource.Visible = true; //} if (r.ResourceType.Equals("image")) { ImageInfo o = rs.GetImageInfoBySN(r.ItemSerialNum); if (o != null) { switch (o.Hvsp.ToUpper()) { case "H": this.lb_Hvsp.Text = "横图"; break; case "V": this.lb_Hvsp.Text = "竖图"; break; case "S": this.lb_Hvsp.Text = "方图"; break; case "P": this.lb_Hvsp.Text = "全景图"; break; default: this.lb_Hvsp.Text = "横图"; break; } this.lb_Size.Text = o.Width.ToString() + "x" + o.Height.ToString(); } } StringBuilder OutString = new StringBuilder(""); using (DataSet ds = GetResourceCatalog(itemId.ToString())) { if (ds != null && ds.Tables[0].Rows.Count != 0) { DataTable cataTable = ds.Tables[0]; for (int i = 0; i < cataTable.Rows.Count; i++) { OutString.Append(cataTable.Rows[i]["CatalogName"].ToString() + " "); } this.lb_Category.Text = OutString.ToString(); } } //判断是否具有下载权限 this.pDownload.Visible = IsSuperAdmin || rs.IsUserResource(CurrentUser.UserId, r.ItemId, (int)OperatorMethod.Download); this.pEdit.Visible = IsSuperAdmin || rs.IsUserResource(CurrentUser.UserId, r.ItemId, (int)OperatorMethod.Modify); }
protected string showImage(string ServerFileName, string ServerFolderName, string ResourceType, int status, string ItemId) { StringBuilder sb = new StringBuilder(""); string imageUrl = string.Empty; /*string image = @"<a href='../PicDetail.aspx?ItemID={0}' target='_blank'> <img id='Img1' alt='' onmousemove='showPic(this.src,event);' onmouseout='hiddenPic();' src='{1}'/></a>"; */ string image = @"<img id='Img1' alt='' src='/CreateImage.aspx?f={0}&s={1}'/>"; string videoText = @"<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='400' height='300' id='QuanJingFilm' align='middle'> <param name='allowScriptAccess' value='always' /> <param name='allowFullScreen' value='false' /> <param name='movie' value='../../UI/flash/QJFilm.swf' /> <param name='quality' value='autohigh' /> <param name='bgcolor' value='#ffffff' /> <param name='wmode' value='opaque' /> <param name='FlashVars' value='videoUrl={0}&imgUrl={1}&SerailNumber={2}' /> <embed src='../../UI/flash/qjFilm.swf' quality='autohigh' bgcolor='#ffffff' width='400' height='300' wmode='opaque' flashvars='videoUrl={0}&imgUrl={1}&SerailNumber={2}' name='QuanJingFilm' align='middle' allowscriptaccess='always' allowfullscreen='false' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' /> </object>"; if (ResourceType.Equals("image")) { //imageUrl = UIBiz.CommonInfo.GetResourceImageUrl(400, ServerFileName, ServerFolderName); ImageType objImg = new ImageType(); //yangguang //imageUrl = objImg.PreviewPath_400_Read + "/" + ServerFolderName + "/" + ServerFileName; imageUrl = objImg.GetPreviewPath(ServerFolderName, ServerFileName, "400"); //sb.Append(string.Format(image, ItemId, imageUrl)); sb.Append(string.Format(image, ServerFolderName, ServerFileName)); } else if (ResourceType.Equals("video")) { imageUrl = GetVideoImgUrl(ServerFolderName, Path.GetFileNameWithoutExtension(ServerFileName), status); string videoUrl = string.Empty; videoUrl = GetSmallFlvUrl(ServerFolderName, Path.GetFileNameWithoutExtension(ServerFileName), status); sb.Append(string.Format(videoText, videoUrl, imageUrl, ItemId)); } return sb.ToString(); }
private string SaveImage() { //HttpPostedFile f = Request.Files["Filedata"]; HttpPostedFile f = this.fuImage.PostedFile; string filename = f.FileName; string filetype = Path.GetExtension(filename).ToLower(); ImageType obj = new ImageType(); string savePath = obj.GetSourcePath(obj.SourcePaths); savePath = Path.Combine(savePath, CurrentUser.UserLoginName); //string retSn = new Resource().GetSN(ResourceTypeFactory.getResourceType(filetype).ResourceSNPrefix) + filetype; string resourceseq = new Resource().GetSN(ResourceTypeFactory.getResourceType(filetype.Substring(1)).ResourceSNPrefix); string fileFullPath = Path.Combine(savePath, resourceseq + filetype); bool slImage; try { if (!Directory.Exists(savePath)) { Directory.CreateDirectory(savePath); } //保存原图 f.SaveAs(fileFullPath); string SlImageRootPath; SlImageRootPath = Path.Combine(obj.PreviewPath_170, CurrentUser.UserLoginName); if (!Directory.Exists(SlImageRootPath)) { Directory.CreateDirectory(SlImageRootPath); } ArrayList sarray = new ArrayList(); sarray.Add(fileFullPath); ArrayList aarray = new ArrayList(); aarray.Add(Path.Combine(SlImageRootPath, resourceseq + filetype)); ImageController.ToZipImage(sarray, aarray, 170); SlImageRootPath = Path.Combine(obj.PreviewPath_400, CurrentUser.UserLoginName); if (!Directory.Exists(SlImageRootPath)) { Directory.CreateDirectory(SlImageRootPath); } sarray = new ArrayList(); sarray.Add(fileFullPath); aarray = new ArrayList(); aarray.Add(Path.Combine(SlImageRootPath, resourceseq + filetype)); ImageController.ToZipImage(sarray, aarray, 400); //将原图的长x宽保存起来 System.Drawing.Image m_Image = System.Drawing.Image.FromFile(fileFullPath); Int32 height = Convert.ToInt32(m_Image.Height.ToString()); Int32 width = Convert.ToInt32(m_Image.Width.ToString()); string hvsp = string.Empty; if (height > width) { hvsp = "v"; } else if (width > height) { hvsp = "h"; } else { hvsp = "s"; } Dictionary<string, string> dct = new Dictionary<string, string>(); dct.Add("Width", width.ToString()); dct.Add("Height", height.ToString()); dct.Add("Hvsp", hvsp); List<QJVRMS.Business.ResourceWS.DictionaryEntry> lst = new List<QJVRMS.Business.ResourceWS.DictionaryEntry>(); foreach (string key in dct.Keys) { QJVRMS.Business.ResourceWS.DictionaryEntry de = new QJVRMS.Business.ResourceWS.DictionaryEntry(); de.Key = key; de.Value = dct[key]; lst.Add(de); } QJVRMS.Business.ResourceWS.DictionaryEntry[] result = lst.ToArray(); Resource r = new Resource(); r.insertResourceAttributes(resourceseq, result); //Response.Write(resourceseq + filetype + ":" + f.FileName); return resourceseq + filetype; } catch (Exception e1) { Response.Write("保存图片出现错误" + e1.Message); LogWriter.WriteExceptionLog(e1, true); } finally { } return string.Empty; }
//图片路径 protected string GetImgUrl(string ItemSerialNum, string fileType,string folder) { //return UIBiz.CommonInfo.GetImageUrl(170, folder, ItemSerialNum, ImageType); ImageType obj=new ImageType(); //yangguang //string _ret = obj.PreviewPath_170_Read + "/" + folder + "/" + ItemSerialNum + ""+fileType; if (fileType.ToLower() == ".cr2" || fileType.ToLower() == ".nef" || fileType.ToLower() == ".psd") fileType = ".jpg"; string _ret = obj.GetPreviewPathRead(folder, ItemSerialNum + "" + fileType, "170"); return _ret; }
public string CatalogImagesContent(string catalogId, string userId, string featureId, int pageSize, int pageNum, string param, string type) { int pageCount = 0; QJVRMS.Business.FeatureWS.FeatureService feature = new QJVRMS.Business.FeatureWS.FeatureService(); DataSet ds = feature.SearchResource(string.Empty, new DateTime(2000, 1, 1, 1, 1, 1).ToString(), DateTime.MaxValue.ToString(), catalogId, userId, pageSize, pageNum - 1, ref pageCount, "image,other", string.Empty, 2, new Guid(featureId), type); if (ds == null && ds.Tables.Count == 0) { return(string.Empty); } pageCount = string.IsNullOrEmpty(ds.Tables[0].Rows[0][0].ToString()) ? 0 : int.Parse(ds.Tables[0].Rows[0][0].ToString()); DataTable dt = ds.Tables[1]; StringBuilder sb = new StringBuilder(); if (pageCount > pageSize) { sb.Append(GetCatalogPage(pageSize, pageNum, pageCount, catalogId)); } sb.Append("<div style=\"text-align:right; padding-right:10px;\"><input type=\"checkbox\" name=\"fullname\" onclick=\"OnCheckBox(this)\"/>全选</div>"); sb.Append("<table width=\"100%\" border=\"0\">"); sb.Append("<tr>"); string id = string.Empty; ResourceType.ImageType imageType = new ResourceType.ImageType(); for (int i = 0; i < dt.Rows.Count; i++) { if (i % 4 == 0 && i != 0) { sb.Append("</tr><tr>"); } id = dt.Rows[i]["ID"].ToString(); sb.Append("<td class=\"imagetd\" valign=\"bottom\" id=\"" + id + "td\">"); sb.Append("<table><tr><td valign=\"bottom\">"); if (param.ToLower().IndexOf(id.ToLower()) != -1) { sb.Append("<img id=\"" + id + "img\" style=\"cursor:pointer;\" "); sb.Append("onmouseover=\"OnMUp('" + id + "')\" onmouseout=\"OnMOut('" + id + "')\" "); sb.Append("onclick=\"AddImage('" + id + "', '" + dt.Rows[i]["Caption"].ToString() + "')\" "); //yangguang //sb.Append("src=\"" + imageType.PreviewPath_170_Read + dt.Rows[i]["ServerFolderName"].ToString() + "/" + dt.Rows[i]["ServerFileName"].ToString() + "\" alt=\"\"/>"); sb.Append("src=\"" + imageType.GetPreviewPathRead(dt.Rows[i]["ServerFolderName"].ToString(), dt.Rows[i]["ServerFileName"].ToString(), "170") + "\" alt=\"\"/>"); } else { sb.Append("<img id=\"" + id + "img\" style=\"cursor:pointer;\" "); sb.Append("onmouseover=\"OnMUp('" + id + "')\" onmouseout=\"OnMOut('" + id + "')\" "); sb.Append("onclick=\"AddImage('" + id + "', '" + dt.Rows[i]["Caption"].ToString() + "')\" "); //yangguang //sb.Append("src=\"" + imageType.PreviewPath_170_Read + dt.Rows[i]["ServerFolderName"].ToString() + "/" + dt.Rows[i]["ServerFileName"].ToString() + "\" alt=\"\"/>"); sb.Append("src=\"" + imageType.GetPreviewPathRead(dt.Rows[i]["ServerFolderName"].ToString(), dt.Rows[i]["ServerFileName"].ToString(), "170") + "\" alt=\"\"/>"); } sb.Append("</td></tr>"); sb.Append("<tr><td>"); sb.Append("<div>"); if (param.ToLower().IndexOf(id.ToLower()) != -1) { sb.Append("<input type=\"checkbox\" id=\"" + id + "\" name=\"image\" value=\"" + dt.Rows[i]["Caption"].ToString() + "\" checked style=\"display:none;\" />"); } else { sb.Append("<input type=\"checkbox\" id=\"" + id + "\" name=\"image\" value=\"" + dt.Rows[i]["Caption"].ToString() + "\" style=\"display:none;\"/>"); } sb.Append("<table width=\"100%\"><tr><td valign=\"middle\" align=\"left\" width=\"90%\">"); sb.Append("<span style=\"float:left;\">" + dt.Rows[i]["Caption"].ToString() + "</span>"); sb.Append("</td><td valign=\"middle\" align=\"right\">"); if (param.ToLower().IndexOf(id.ToLower()) != -1) { sb.Append("<img id=\"" + id + "check\" src=\"../../images/swfuploadEnd.gif\">"); } else { sb.Append("<img id=\"" + id + "check\" style=\"display:none;\" src=\"../../images/swfuploadEnd.gif\">"); } sb.Append("</td></tr></table>"); sb.Append("</div>"); sb.Append("</td></tr></table>"); sb.Append("</td>"); } sb.Append("</tr>"); sb.Append("</table>"); if (pageCount > pageSize) { sb.Append(GetCatalogPage(pageSize, pageNum, pageCount, catalogId)); } sb.Append("<div style=\"text-align:right; padding-right:10px;\"><input type=\"checkbox\" name=\"fullname\" onclick=\"OnCheckBox(this)\"/>全选</div>"); return(sb.ToString()); }
public string CatalogImagesContent(string catalogId, string userId, string featureId, int pageSize, int pageNum, string param, string type) { int pageCount = 0; QJVRMS.Business.FeatureWS.FeatureService feature = new QJVRMS.Business.FeatureWS.FeatureService(); DataSet ds = feature.SearchResource(string.Empty, new DateTime(2000, 1, 1, 1, 1, 1).ToString(), DateTime.MaxValue.ToString(), catalogId, userId, pageSize, pageNum - 1, ref pageCount, "image,other", string.Empty, 2, new Guid(featureId), type); if (ds == null && ds.Tables.Count == 0) return string.Empty; pageCount = string.IsNullOrEmpty(ds.Tables[0].Rows[0][0].ToString()) ? 0 : int.Parse(ds.Tables[0].Rows[0][0].ToString()); DataTable dt = ds.Tables[1]; StringBuilder sb = new StringBuilder(); if (pageCount > pageSize) sb.Append(GetCatalogPage(pageSize, pageNum, pageCount, catalogId)); sb.Append("<div style=\"text-align:right; padding-right:10px;\"><input type=\"checkbox\" name=\"fullname\" onclick=\"OnCheckBox(this)\"/>全选</div>"); sb.Append("<table width=\"100%\" border=\"0\">"); sb.Append("<tr>"); string id = string.Empty; ResourceType.ImageType imageType = new ResourceType.ImageType(); for (int i = 0; i < dt.Rows.Count; i++) { if (i % 4 == 0 && i != 0) sb.Append("</tr><tr>"); id = dt.Rows[i]["ID"].ToString(); sb.Append("<td class=\"imagetd\" valign=\"bottom\" id=\"" + id + "td\">"); sb.Append("<table><tr><td valign=\"bottom\">"); if (param.ToLower().IndexOf(id.ToLower()) != -1) { sb.Append("<img id=\"" + id + "img\" style=\"cursor:pointer;\" "); sb.Append("onmouseover=\"OnMUp('" + id + "')\" onmouseout=\"OnMOut('" + id + "')\" "); sb.Append("onclick=\"AddImage('" + id + "', '" + dt.Rows[i]["Caption"].ToString() + "')\" "); //yangguang //sb.Append("src=\"" + imageType.PreviewPath_170_Read + dt.Rows[i]["ServerFolderName"].ToString() + "/" + dt.Rows[i]["ServerFileName"].ToString() + "\" alt=\"\"/>"); sb.Append("src=\"" + imageType.GetPreviewPathRead(dt.Rows[i]["ServerFolderName"].ToString(), dt.Rows[i]["ServerFileName"].ToString(), "170") + "\" alt=\"\"/>"); } else { sb.Append("<img id=\"" + id + "img\" style=\"cursor:pointer;\" "); sb.Append("onmouseover=\"OnMUp('" + id + "')\" onmouseout=\"OnMOut('" + id + "')\" "); sb.Append("onclick=\"AddImage('" + id + "', '" + dt.Rows[i]["Caption"].ToString() + "')\" "); //yangguang //sb.Append("src=\"" + imageType.PreviewPath_170_Read + dt.Rows[i]["ServerFolderName"].ToString() + "/" + dt.Rows[i]["ServerFileName"].ToString() + "\" alt=\"\"/>"); sb.Append("src=\"" + imageType.GetPreviewPathRead(dt.Rows[i]["ServerFolderName"].ToString(), dt.Rows[i]["ServerFileName"].ToString(), "170") + "\" alt=\"\"/>"); } sb.Append("</td></tr>"); sb.Append("<tr><td>"); sb.Append("<div>"); if (param.ToLower().IndexOf(id.ToLower()) != -1) sb.Append("<input type=\"checkbox\" id=\"" + id + "\" name=\"image\" value=\"" + dt.Rows[i]["Caption"].ToString() + "\" checked style=\"display:none;\" />"); else sb.Append("<input type=\"checkbox\" id=\"" + id + "\" name=\"image\" value=\"" + dt.Rows[i]["Caption"].ToString() + "\" style=\"display:none;\"/>"); sb.Append("<table width=\"100%\"><tr><td valign=\"middle\" align=\"left\" width=\"90%\">"); sb.Append("<span style=\"float:left;\">" + dt.Rows[i]["Caption"].ToString() + "</span>"); sb.Append("</td><td valign=\"middle\" align=\"right\">"); if (param.ToLower().IndexOf(id.ToLower()) != -1) { sb.Append("<img id=\"" + id + "check\" src=\"../../images/swfuploadEnd.gif\">"); } else { sb.Append("<img id=\"" + id + "check\" style=\"display:none;\" src=\"../../images/swfuploadEnd.gif\">"); } sb.Append("</td></tr></table>"); sb.Append("</div>"); sb.Append("</td></tr></table>"); sb.Append("</td>"); } sb.Append("</tr>"); sb.Append("</table>"); if (pageCount > pageSize) sb.Append(GetCatalogPage(pageSize, pageNum, pageCount, catalogId)); sb.Append("<div style=\"text-align:right; padding-right:10px;\"><input type=\"checkbox\" name=\"fullname\" onclick=\"OnCheckBox(this)\"/>全选</div>"); return sb.ToString(); }
private string BuildString(List<DetailInfo> list, string itemId, int s, int e, string guid) { ImageType obj = new ImageType(); //yangguang //string yRootPath = obj.PreviewPath_170_Read; // 400预览图路径@"e:\\DSC_3257.jpg" string path = string.Empty; string hvsp = string.Empty; string id = string.Empty; StringBuilder sb = new StringBuilder(); for (int i = s - 1; i < e; i++) { //yangguang //path = yRootPath + list[i].FolderName + @"/" + list[i].ServerFileName; path = obj.GetPreviewPathRead(list[i].FolderName, list[i].ServerFileName, "170"); id = list[i].ItemId; if (id == itemId) { sb.Append("<li>"); sb.Append("<a href=\"PicDetail.aspx?type=1&ItemID=" + id + "&guid=" + guid + "\"><img src=\"" + path + "\" class=\"liimg1\" /></a>"); sb.Append("</li>"); } else { sb.Append("<li>"); sb.Append("<a href=\"PicDetail.aspx?type=1&ItemID=" + id + "&guid=" + guid + "\"><img src=\"" + path + "\" class=\"liimg\" /></a>"); sb.Append("</li>"); } } return sb.ToString(); }