donetCMS采集时自动添加水印

  一、增加一个水印类
/Foosun.CMS.Collect.WaterMark.cs

文件内容如下:
CODE:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Foosun.CMS;
using System.Drawing;
using System.Drawing.Imaging;
using Foosun.CMS.Common;

namespace Foosun.CMS.Collect
{
class WaterMark
{
public WaterMark()
{
;
}
//张涛
public void GetWaterMark(string fileNamePath)
{
Foosun.CMS.sys Sys = new Foosun.CMS.sys();
DataTable dt_sys = Sys.WaterStart();
//实现水印、缩图

Foosun.CMS.Common.FSImage fd = new Foosun.CMS.Common.FSImage(0, 0, fileNamePath);




if (dt_sys.Rows[0]["PrintPicTF"].ToString() == "7")
{
//时间:2008-07-21 修改者:吴静岚
//实现水印、缩图
// FSImage fd = new FSImage(0, 0, Server.MapPath(_fileNamePath));
fd.Diaph = dt_sys.Rows[0]["PintPictrans"].ToString();
//--wjl>
fd.Quality = 100;
fd.Title = dt_sys.Rows[0]["PrintWord"].ToString();
fd.FontSize = Convert.ToInt32(dt_sys.Rows[0]["Printfontsize"].ToString());
if (dt_sys.Rows[0]["PrintBTF"].ToString() == "1")
fd.StrStyle = FontStyle.Bold;
fd.FontColor = ColorTranslator.FromHtml("#" + dt_sys.Rows[0]["Printfontcolor"].ToString());
fd.BackGroudColor = Color.White;
fd.FontFamilyName = dt_sys.Rows[0]["Printfontfamily"].ToString();
fd.Waterpos = dt_sys.Rows[0]["PrintPosition"].ToString();
fd.Watermark();
}
else
{
//时间:2008-07-21 修改者:吴静岚 1
//实现水印、缩图

//时间:2008-08-04 修改者:吴静岚 2
//实现水印、缩图
double a_picsize = Convert.ToDouble(dt_sys.Rows[0]["PrintPicsize"]);
fd.Waterpos = dt_sys.Rows[0]["PrintPosition"].ToString();
fd.Height = Convert.ToInt32(a_picsize * 10);
fd.Width = Convert.ToInt32(a_picsize * 10);
//--wjl 2
fd.Diaph = dt_sys.Rows[0]["PintPictrans"].ToString();
//--wjl 1>
fd.WaterPath = Foosun.Common.ServerInfo.GetRootPath().TrimEnd('\\') + @"\" + Foosun.Config.UIConfig.dirFile + @"\RemoteFiles\watermark.png";
fd.WaterPicturemark();
}
dt_sys.Clear(); dt_sys.Dispose();
}
}
}
二、然后修改这个类
:/Foosun.CMS.Collect.PageRes.cs

找到
CODE:
string newname = FileNum + SeriesNum.ToString().PadLeft(3, '0') + "." + r.extname;


while (File.Exists(_localpath +"\\"+ newname))
{
SeriesNum++;
newname = FileNum + SeriesNum.ToString().PadLeft(3, '0') + "." + r.extname;
}
newpath = _localpath + "\\" + newname;
newurl = _localurl + newname;
wb.DownloadFile(url,newpath);


在下面加一条:
CODE:
waterMark.GetWaterMark(newpath);


再找到
CODE:
else
{
newurl = _localurl + r.orgname + "." + r.extname;
wb.DownloadFile(url, _localpath + "\\" + r.orgname + "." + r.extname);


在下面加一条:
CODE:
waterMark.GetWaterMark(newpath);
三、注意,只支持水印图片放在
这个目录
files\RemoteFiles\watermark.png

posted on 2009-09-11 11:29 9who 阅读(117) 评论(1) 编辑 收藏

评论

#1楼  回复 引用 查看   

你好,在园里看到你用NETCMS二次开发过,我是新手,刚从NETCMS,有很多不懂的地方,想向你取取经,
2010-07-09 18:21 | Q玲珑      

导航

<2009年9月>
303112345
6789101112
13141516171819
20212223242526
27282930123
45678910

公告


欢迎光临 9who的博客!本博客文章适合初学者,其中有部分ASP.NET内容转载了网上比较经典文章,如有侵权请联系本人!
昵称:9who
园龄:4年7个月
粉丝:10
关注:0

搜索

 
 

常用链接

随笔分类

随笔档案

相册

博客园链接

资源站链接

积分与排名

  • 积分 - 187713
  • 排名 - 454

最新评论

阅读排行榜

评论排行榜