程序员人生 网站导航

风讯donetCMS采集时自动添加水印的方法

栏目:DedeCMS时间:2014-02-27 13:37:03

网(LieHuo.Net)教程 风讯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 + @"RemoteFileswatermark.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);
三、注意,只支持水印图片放在
这个目录
filesRemoteFileswatermark.png

------分隔线----------------------------
------分隔线----------------------------

最新技术推荐