Exemplo n.º 1
0
    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        int index = Convert.ToInt32(e.CommandArgument);

        //apply
        if (e.CommandName == "_apply")
        {
            MojoCube.Web.Site.Config config = new MojoCube.Web.Site.Config();
            config.GetData(1, MojoCube.Api.UI.Language.GetLanguage());

            config.SiteTheme = ((Label)GridView1.Rows[index].FindControl("lblFileName")).Text;
            config.UpdateData(config.pk_Config);

            AlertDiv.InnerHtml = MojoCube.Web.String.ShowAlert("success", "主题已修改成功");
        }
        //delete
        if (e.CommandName == "_delete")
        {
            string fileName = ((Label)GridView1.Rows[index].FindControl("lblFileName")).Text;
            bool   IsDelete = MojoCube.Api.File.IO.DeleteDirectory(Server.MapPath("../../Themes/" + fileName));
            if (IsDelete)
            {
                AlertDiv.InnerHtml = MojoCube.Web.String.ShowAlert("success", "主题已删除成功");
            }
            else
            {
                AlertDiv.InnerHtml = MojoCube.Web.String.ShowAlert("danger", "主题已删除失败");
            }
        }

        MojoCube.Web.Site.Cache cache = new MojoCube.Web.Site.Cache();
        cache.RemoveAllCache();
        GridBind();
    }
Exemplo n.º 2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Request.QueryString["type"] != null)
            {
                switch (Request.QueryString["type"])
                {
                case "0":
                    MojoCube.Web.Site.Config config = new MojoCube.Web.Site.Config();
                    config.GetData(1, MojoCube.Api.UI.Language.GetLanguage());

                    if (!config.IsSiteOpen)
                    {
                        lblInfo.Text = config.ClosedInfo;
                    }

                    break;
                }
            }

            this.Title = lblInfo.Text;
        }
    }
Exemplo n.º 3
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        MojoCube.Web.Site.Config config = new MojoCube.Web.Site.Config();
        config.GetData(1, MojoCube.Api.UI.Language.GetLanguage());

        if (config.pk_Config > 0)
        {
            config.SiteName        = txtSiteName.Text.Trim();
            config.SiteTitle       = txtSiteTitle.Text.Trim();
            config.SiteKeyword     = txtSEO_Keyword.Text.Trim();
            config.SiteDescription = txtSEO_Description.Text.Trim();
            config.SiteUrl         = txtSiteUrl.Text.Trim();
            config.SiteCopyRight   = txtContent.Text.Trim();
            config.SiteContact     = txtSiteContact.Text.Trim();
            config.ContactUs       = txtDescription.Text.Trim();
            config.StatisticsCode  = txtStatisticsCode.Text.Trim();
            config.ShareCode       = txtShareCode.Text.Trim();
            config.IsSiteOpen      = MojoCube.Web.String.StringToBool(ddlStatus.SelectedValue);
            config.SiteCounter     = MojoCube.Web.String.StringToBool(ddlCounter.SelectedValue);
            config.IsBoundIP       = MojoCube.Web.String.StringToBool(ddlBoundIP.SelectedValue);
            config.BoundIP         = txtBoundIP.Text.Trim();
            config.UrlExtension    = ddlExtension.SelectedValue;
            config.SearchType      = int.Parse(ddlSearchType.SelectedValue);
            config.SiteNotify      = txtNotify.Text.Trim();
            config.ClosedInfo      = txtClosedInfo.Text.Trim();

            //Logo
            string logo = GetLogo();
            if (logo != "")
            {
                config.SiteLogo = logo;
            }

            config.SiteLogoPath     = "Site/Logo";
            config.ArticleImagePath = "Article/[Category]";
            config.ProductImagePath = "Product/[Category]";
            config.ADImagePath      = "Site/Banner";
            config.WM_Text          = txtShowWM.Text.Trim();

            //字体、大小
            if (txtShowFS.Text.Trim() != "")
            {
                config.WM_Font     = txtShowFS.Text.Trim().Split('|')[0];
                config.WM_FontSize = int.Parse(txtShowFS.Text.Trim().Split('|')[1]);
            }

            //边距
            if (txtPadding.Text.Trim() != "")
            {
                config.WM_Bottom = int.Parse(txtPadding.Text.Trim().Split('|')[0]);
                config.WM_Right  = int.Parse(txtPadding.Text.Trim().Split('|')[1]);
            }

            config.WM_Rotate = int.Parse(ddlRotate.SelectedValue);
            config.WM_Size   = int.Parse(ddlSize.SelectedValue);
            config.WM_Alpha  = int.Parse(ddlAlpha.SelectedValue);

            //RGB
            if (txtRGB.Text.Trim() != "")
            {
                config.WM_Red   = int.Parse(txtRGB.Text.Trim().Split('|')[0]);
                config.WM_Green = int.Parse(txtRGB.Text.Trim().Split('|')[1]);
                config.WM_Blue  = int.Parse(txtRGB.Text.Trim().Split('|')[2]);
            }

            config.WM_IsShow = MojoCube.Web.String.StringToBool(ddlShowWM.SelectedValue);

            //限制宽高
            if (txtShowWH.Text.Trim() != "")
            {
                config.WM_Show_W = int.Parse(txtShowWH.Text.Trim().Split('|')[0]);
                config.WM_Show_H = int.Parse(txtShowWH.Text.Trim().Split('|')[1]);
            }

            config.WM_Mode = MojoCube.Web.String.StringToBool(ddlModeWM.SelectedValue);

            //水印图片
            string wm = GetWM();
            if (wm != "")
            {
                config.WM_ImagePath = wm;
            }

            config.ShowService        = MojoCube.Web.String.StringToBool(ddlService.SelectedValue);
            config.ArticleTitleLength = MojoCube.Web.String.ToInt(txtArticleTitleLength.Text.Trim());
            config.Terms = txtTerms.Text.Trim();

            config.UpdateData(config.pk_Config);
        }
        else
        {
            config.IndexID          = 1;
            config.SiteName         = txtSiteName.Text.Trim();
            config.SiteTitle        = txtSiteTitle.Text.Trim();
            config.SiteKeyword      = txtSEO_Keyword.Text.Trim();
            config.SiteDescription  = txtSEO_Description.Text.Trim();
            config.SiteContentType  = "text/html; charset=utf-8";
            config.SiteUrl          = txtSiteUrl.Text.Trim();
            config.SiteLogo         = GetLogo();
            config.SiteCopyRight    = txtContent.Text.Trim();
            config.SiteContact      = txtSiteContact.Text.Trim();
            config.SiteNotify       = txtNotify.Text.Trim();
            config.MapCode          = string.Empty;
            config.StatisticsCode   = txtStatisticsCode.Text.Trim();
            config.ShareCode        = txtShareCode.Text.Trim();
            config.OtherMeta        = string.Empty;
            config.ContactUs        = txtDescription.Text.Trim();
            config.IsSiteOpen       = MojoCube.Web.String.StringToBool(ddlStatus.SelectedValue);
            config.ClosedInfo       = txtClosedInfo.Text.Trim();
            config.ShowPageSize     = 10;
            config.AllowComment     = true;
            config.SiteLogoPath     = "Site/Logo";
            config.ArticleImagePath = "Article/[Category]";
            config.ProductImagePath = "Product/[Category]";
            config.ADImagePath      = "Site/Banner";
            config.ImgSize_S_W      = 120;
            config.ImgSize_S_H      = 100;
            config.ImgSize_M_W      = 200;
            config.ImgSize_M_H      = 200;
            config.SiteTheme        = "Default";
            config.WM_Text          = txtShowWM.Text.Trim();

            //字体、大小
            if (txtShowFS.Text.Trim() != "")
            {
                config.WM_Font     = txtShowFS.Text.Trim().Split('|')[0];
                config.WM_FontSize = int.Parse(txtShowFS.Text.Trim().Split('|')[1]);
            }
            else
            {
                config.WM_Font     = "Arial";
                config.WM_FontSize = 50;
            }

            //边距
            if (txtPadding.Text.Trim() != "")
            {
                config.WM_Bottom = int.Parse(txtPadding.Text.Trim().Split('|')[0]);
                config.WM_Right  = int.Parse(txtPadding.Text.Trim().Split('|')[1]);
            }
            else
            {
                config.WM_Bottom = 10;
                config.WM_Right  = 10;
            }

            config.WM_Rotate = int.Parse(ddlRotate.SelectedValue);
            config.WM_Size   = int.Parse(ddlSize.SelectedValue);
            config.WM_Alpha  = int.Parse(ddlAlpha.SelectedValue);

            //RGB
            if (txtRGB.Text.Trim() != "")
            {
                config.WM_Red   = int.Parse(txtRGB.Text.Trim().Split('|')[0]);
                config.WM_Green = int.Parse(txtRGB.Text.Trim().Split('|')[1]);
                config.WM_Blue  = int.Parse(txtRGB.Text.Trim().Split('|')[2]);
            }
            else
            {
                config.WM_Red   = 255;
                config.WM_Green = 255;
                config.WM_Blue  = 255;
            }

            config.WM_IsShow = MojoCube.Web.String.StringToBool(ddlShowWM.SelectedValue);

            //限制宽高
            if (txtShowWH.Text.Trim() != "")
            {
                config.WM_Show_W = int.Parse(txtShowWH.Text.Trim().Split('|')[0]);
                config.WM_Show_H = int.Parse(txtShowWH.Text.Trim().Split('|')[1]);
            }
            else
            {
                config.WM_Show_W = 300;
                config.WM_Show_H = 300;
            }

            config.WM_Mode            = MojoCube.Web.String.StringToBool(ddlModeWM.SelectedValue);
            config.WM_ImagePath       = GetWM();
            config.SiteCounter        = MojoCube.Web.String.StringToBool(ddlCounter.SelectedValue);
            config.SiteFlow           = 0;
            config.UrlExtension       = ddlExtension.SelectedValue;
            config.IsBoundIP          = MojoCube.Web.String.StringToBool(ddlBoundIP.SelectedValue);
            config.BoundIP            = txtBoundIP.Text.Trim();
            config.Target             = "_self";
            config.SearchType         = int.Parse(ddlSearchType.SelectedValue);
            config.ShowService        = MojoCube.Web.String.StringToBool(ddlService.SelectedValue);
            config.ArticleTitleLength = MojoCube.Web.String.ToInt(txtArticleTitleLength.Text.Trim());
            config.Terms    = txtTerms.Text.Trim();
            config.Language = MojoCube.Api.UI.Language.GetLanguage();

            config.InsertData();
        }

        Response.Redirect("Config.aspx?info=1&active=" + Request.QueryString["active"]);
    }
Exemplo n.º 4
0
    //生成网站地图
    protected void btnSiteMap_Click(object sender, EventArgs e)
    {
        string strLanguage = MojoCube.Api.UI.Language.GetLanguage();

        MojoCube.Web.Site.Config config = new MojoCube.Web.Site.Config();
        config.GetData(1, strLanguage);
        string domain = config.SiteUrl;

        #region  连接数据层
        StringBuilder strSql = new StringBuilder();
        //0:导航菜单
        strSql.Append("select * from Site_Menu where Visible=1 and Language='" + strLanguage + "' order by SortID asc");
        //1:文章类别
        strSql.Append(" select * from Article_Category where Visible=1 and Language='" + strLanguage + "' order by SortID asc");
        //2:文章列表
        strSql.Append(" select * from Article_List where Issue=1 and Language='" + strLanguage + "' order by CreateDate desc");
        //3:产品类别
        strSql.Append(" select * from Product_Category where Visible=1 and Language='" + strLanguage + "' order by SortID asc");
        //4:产品列表
        strSql.Append(" select * from Product_List where Issue=1 and Language='" + strLanguage + "' order by CreateDate desc");
        //5:相册类别
        strSql.Append(" select * from Album_Category where Visible=1 and Language='" + strLanguage + "' order by SortID asc");
        //6:相册列表
        strSql.Append(" select * from Album_List where Issue=1 and Language='" + strLanguage + "' order by CreateDate desc");

        DataSet ds = MojoCube.Web.Sql.SqlQueryDS(strSql.ToString());
        #endregion

        DataTable dt = new DataTable();

        DataTable dtSM = new DataTable();
        dtSM.Columns.Add("loc");
        dtSM.Columns.Add("lastmod");
        dtSM.Columns.Add("changefreq");
        dtSM.Columns.Add("priority");

        #region  生成数据表
        //导航菜单
        dt = ds.Tables[0];
        if (dt.Rows.Count > 0)
        {
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                DataRow dr = dtSM.NewRow();
                dr["loc"]        = domain + MojoCube.Web.Site.Cache.GetUrlExtension(dt.Rows[i]["Url"].ToString(), strLanguage);
                dr["lastmod"]    = DateTime.Now;
                dr["changefreq"] = "daily";
                dr["priority"]   = "1.0";
                dtSM.Rows.Add(dr);
            }
        }

        //文章类别
        dt = ds.Tables[1];
        if (dt.Rows.Count > 0)
        {
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                DataRow dr = dtSM.NewRow();
                dr["loc"]        = domain + MojoCube.Web.Site.Cache.GetUrlExtension("NC-" + dt.Rows[i]["PageName"].ToString(), strLanguage);
                dr["lastmod"]    = DateTime.Now;
                dr["changefreq"] = "daily";
                dr["priority"]   = "1.0";
                dtSM.Rows.Add(dr);
            }
        }

        //文章列表
        dt = ds.Tables[2];
        if (dt.Rows.Count > 0)
        {
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                DataRow dr = dtSM.NewRow();
                dr["loc"]        = domain + MojoCube.Web.Site.Cache.GetUrlExtension("N-" + dt.Rows[i]["PageName"].ToString(), strLanguage);
                dr["lastmod"]    = DateTime.Now;
                dr["changefreq"] = "daily";
                dr["priority"]   = "1.0";
                dtSM.Rows.Add(dr);
            }
        }

        //产品类别
        dt = ds.Tables[3];
        if (dt.Rows.Count > 0)
        {
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                DataRow dr = dtSM.NewRow();
                dr["loc"]        = domain + MojoCube.Web.Site.Cache.GetUrlExtension("PC-" + dt.Rows[i]["PageName"].ToString(), strLanguage);
                dr["lastmod"]    = DateTime.Now;
                dr["changefreq"] = "daily";
                dr["priority"]   = "1.0";
                dtSM.Rows.Add(dr);
            }
        }

        //产品列表
        dt = ds.Tables[4];
        if (dt.Rows.Count > 0)
        {
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                DataRow dr = dtSM.NewRow();
                dr["loc"]        = domain + MojoCube.Web.Site.Cache.GetUrlExtension("P-" + dt.Rows[i]["PageName"].ToString(), strLanguage);
                dr["lastmod"]    = DateTime.Now;
                dr["changefreq"] = "daily";
                dr["priority"]   = "1.0";
                dtSM.Rows.Add(dr);
            }
        }

        //相册类别
        dt = ds.Tables[5];
        if (dt.Rows.Count > 0)
        {
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                DataRow dr = dtSM.NewRow();
                dr["loc"]        = domain + MojoCube.Web.Site.Cache.GetUrlExtension("AC-" + dt.Rows[i]["PageName"].ToString(), strLanguage);
                dr["lastmod"]    = DateTime.Now;
                dr["changefreq"] = "daily";
                dr["priority"]   = "1.0";
                dtSM.Rows.Add(dr);
            }
        }

        //相册列表
        dt = ds.Tables[6];
        if (dt.Rows.Count > 0)
        {
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                DataRow dr = dtSM.NewRow();
                dr["loc"]        = domain + MojoCube.Web.Site.Cache.GetUrlExtension("A-" + dt.Rows[i]["PageName"].ToString(), strLanguage);
                dr["lastmod"]    = DateTime.Now;
                dr["changefreq"] = "daily";
                dr["priority"]   = "1.0";
                dtSM.Rows.Add(dr);
            }
        }
        #endregion

        //保存到根目录下
        MojoCube.Api.XML.SiteMap map = new MojoCube.Api.XML.SiteMap();
        string filePath = HttpContext.Current.Server.MapPath("~/sitemap.xml");
        using (StreamWriter sw = new StreamWriter(filePath))
        {
            sw.Write(map.CreateSiteMap(dtSM));
        }

        Response.Redirect("Config.aspx?info=1&active=" + Request.QueryString["active"]);
    }
Exemplo n.º 5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Request.QueryString["info"] != null)
            {
                AlertDiv.InnerHtml = MojoCube.Web.String.ShowAlert("success", "数据保存成功");
            }

            MojoCube.Web.Site.Config config = new MojoCube.Web.Site.Config();
            config.GetData(1, MojoCube.Api.UI.Language.GetLanguage());

            if (config.pk_Config > 0)
            {
                txtSiteName.Text           = config.SiteName;
                txtSiteTitle.Text          = config.SiteTitle;
                txtSEO_Title.Text          = config.SiteTitle;
                txtSEO_Keyword.Text        = config.SiteKeyword;
                txtSEO_Description.Text    = config.SiteDescription;
                txtSiteUrl.Text            = config.SiteUrl;
                txtContent.Text            = config.SiteCopyRight;
                txtSiteContact.Text        = config.SiteContact;
                txtDescription.Text        = config.ContactUs;
                txtStatisticsCode.Text     = config.StatisticsCode;
                txtShareCode.Text          = config.ShareCode;
                txtNotify.Text             = config.SiteNotify;
                txtClosedInfo.Text         = config.ClosedInfo;
                txtBoundIP.Text            = config.BoundIP;
                txtArticleTitleLength.Text = config.ArticleTitleLength.ToString();
                txtTerms.Text = config.Terms;

                MojoCube.Web.Sql.ddlFindByValue(ddlStatus, MojoCube.Web.String.BoolToString(config.IsSiteOpen));
                MojoCube.Web.Sql.ddlFindByValue(ddlCounter, MojoCube.Web.String.BoolToString(config.SiteCounter));
                MojoCube.Web.Sql.ddlFindByValue(ddlBoundIP, MojoCube.Web.String.BoolToString(config.IsBoundIP));
                MojoCube.Web.Sql.ddlFindByValue(ddlService, MojoCube.Web.String.BoolToString(config.ShowService));
                MojoCube.Web.Sql.ddlFindByValue(ddlExtension, config.UrlExtension);
                MojoCube.Web.Sql.ddlFindByValue(ddlSearchType, config.SearchType.ToString());

                //Logo
                if (config.SiteLogo != "")
                {
                    imgLogo.ImageUrl = "~/Files.aspx?image=" + MojoCube.Api.Text.Security.EncryptString(config.SiteLogo) + "&w=400&h=300";
                }
                else
                {
                    imgLogo.Visible = false;
                }

                txtShowWM.Text  = config.WM_Text;
                txtShowFS.Text  = config.WM_Font + "|" + config.WM_FontSize.ToString();
                txtPadding.Text = config.WM_Bottom.ToString() + "|" + config.WM_Right.ToString();
                txtRGB.Text     = config.WM_Red.ToString() + "|" + config.WM_Green.ToString() + "|" + config.WM_Blue.ToString();
                txtShowWH.Text  = config.WM_Show_W.ToString() + "|" + config.WM_Show_H.ToString();

                MojoCube.Web.Sql.ddlFindByValue(ddlRotate, config.WM_Rotate.ToString());
                MojoCube.Web.Sql.ddlFindByValue(ddlSize, config.WM_Size.ToString());
                MojoCube.Web.Sql.ddlFindByValue(ddlAlpha, config.WM_Alpha.ToString());
                MojoCube.Web.Sql.ddlFindByValue(ddlShowWM, MojoCube.Web.String.BoolToString(config.WM_IsShow));
                MojoCube.Web.Sql.ddlFindByValue(ddlModeWM, MojoCube.Web.String.BoolToString(config.WM_Mode));

                //水印图片
                if (config.WM_ImagePath != "")
                {
                    imgWM.ImageUrl = "~/Files.aspx?image=" + MojoCube.Api.Text.Security.EncryptString(config.WM_ImagePath) + "&w=400&h=300";
                }
                else
                {
                    imgWM.Visible = false;
                }
            }

            this.Title = "网站设置";
        }
    }
Exemplo n.º 6
0
    private void GetFile()
    {
        try
        {
            if (Request.QueryString["image"] != null)
            {
                string sPath = MojoCube.Api.Text.Security.DecryptString(Request.QueryString["image"]);

                string path = "";

                if (sPath.Length > 0)
                {
                    if (sPath == "no_image.jpg")
                    {
                        path = Server.MapPath("~/Images/no_image.jpg");
                    }
                    else
                    {
                        path = Server.MapPath("~/Files/" + sPath);
                    }
                }
                else
                {
                    path = Server.MapPath("~/Images/blank.png");
                }

                ///////////////////////////////////////////////把图片文档缓存起来(开始)///////////////////////////////////////////////////////
                //获取实体的日期和时间
                DateTime input = System.IO.File.GetLastWriteTime(path);
                // 格式化日期时间,去掉毫秒和微秒:
                DateTime dt = new DateTime(input.Year, input.Month, input.Day, input.Hour, input.Minute, input.Second);
                // 获取浏览器发出的日期和时间
                string s = Request.Headers["If-Modified-Since"];

                // 判断是否修改过
                DateTime TempDate;
                if (((s != null) && DateTime.TryParse(s, out TempDate)) && (TempDate >= dt))
                {
                    // 没有修改过,使用浏览器缓存
                    Response.StatusCode = 0x130;
                }
                // 修改过,在Http头增加浏览器缓存控制
                else if (dt.ToUniversalTime() < DateTime.UtcNow)
                {
                    HttpCachePolicy cache = Response.Cache;
                    cache.SetCacheability(HttpCacheability.Public);
                    cache.SetLastModified(dt);
                }
                ///////////////////////////////////////////////把图片文档缓存起来(结束)///////////////////////////////////////////////////////

                byte[] bFile = null;

                System.Drawing.Image img = System.Drawing.Image.FromFile(path);

                int width  = img.Width;
                int height = img.Height;

                //按比例缩图
                if (Request.QueryString["w"] != null && Request.QueryString["h"] != null && sPath.Length > 0)
                {
                    if (width > height && width > int.Parse(Request.QueryString["w"]))
                    {
                        width  = int.Parse(Request.QueryString["w"]);
                        height = img.Height * width / img.Width;
                    }
                    else if (height > width && height > int.Parse(Request.QueryString["h"]))
                    {
                        height = int.Parse(Request.QueryString["h"]);
                        width  = img.Width * height / img.Height;
                    }
                    else if (width == height)
                    {
                        height = int.Parse(Request.QueryString["h"]);
                        width  = img.Width * height / img.Height;
                    }
                }

                System.Drawing.Image bitmap = null;

                //缩图并裁剪
                if (Request.QueryString["cut"] != null)
                {
                    System.IO.FileInfo myFile   = new System.IO.FileInfo(path);
                    byte[]             bytelist = CutPhoto(myFile, Request.QueryString["cut"]);
                    MemoryStream       ms1      = new MemoryStream(bytelist);
                    bitmap = (Bitmap)System.Drawing.Image.FromStream(ms1);
                    ms1.Close();
                }
                else
                {
                    bitmap = new Bitmap(width, height);
                    Graphics g = Graphics.FromImage(bitmap);
                    g.CompositingQuality = CompositingQuality.HighQuality;
                    g.SmoothingMode      = SmoothingMode.HighQuality;
                    g.InterpolationMode  = InterpolationMode.HighQualityBicubic;
                    g.DrawImage(img, new System.Drawing.Rectangle(0, 0, width, height));
                }

                //是否显示水印
                MojoCube.Web.Site.Config config = new MojoCube.Web.Site.Config();
                config.GetData(1, MojoCube.Api.UI.Language.GetLanguage());

                if (width == 582)
                {
                    config.WM_IsShow = false;
                }

                if (config.WM_IsShow && width > config.WM_Show_W || config.WM_IsShow && height > config.WM_Show_H)
                {
                    int WM_Bottom = config.WM_Bottom;
                    int WM_Right  = config.WM_Right;
                    int WM_Alpha  = config.WM_Alpha;
                    int WM_Red    = config.WM_Red;
                    int WM_Green  = config.WM_Green;
                    int WM_Blue   = config.WM_Blue;
                    int WM_Rotate = config.WM_Rotate;
                    int WM_Size   = config.WM_Size;

                    //文字模式
                    if (!config.WM_Mode)
                    {
                        string WM_Text     = config.WM_Text;
                        string WM_Font     = config.WM_Font;
                        int    WM_FontSize = config.WM_FontSize;

                        Graphics grPhoto = Graphics.FromImage(bitmap);

                        //消除锯齿
                        grPhoto.SmoothingMode     = SmoothingMode.AntiAlias;
                        grPhoto.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;

                        Font  crFont = new Font(WM_Font, WM_FontSize, FontStyle.Bold);
                        SizeF crSize = grPhoto.MeasureString(WM_Text, crFont);

                        int iRotate = WM_Rotate;

                        float pCenterX = 0;
                        float pCenterY = 0;
                        //设置字体在图片中的位置
                        float yPosFromBottom = 0;
                        float xCenterOfImg   = 0;
                        switch (WM_Size)
                        {
                        case 0:     //center
                            yPosFromBottom = height / 2 - (crSize.Height / 2);
                            pCenterX       = xCenterOfImg = width / 2;
                            pCenterY       = height / 2;
                            break;

                        case 1:     //top left
                            pCenterY = yPosFromBottom = crSize.Height / 2 - WM_Bottom;
                            pCenterX = xCenterOfImg = crSize.Width / 2 + WM_Right;
                            break;

                        case 2:     //top right
                            pCenterY = yPosFromBottom = crSize.Height / 2 - WM_Bottom;
                            pCenterX = xCenterOfImg = width - crSize.Width / 2 - WM_Right;
                            break;

                        case 3:     //bottom left
                            pCenterY = yPosFromBottom = height - WM_Bottom - (crSize.Height);
                            pCenterX = xCenterOfImg = crSize.Width / 2 + WM_Right;
                            break;

                        case 4:     //bottom right
                            pCenterY = yPosFromBottom = height - WM_Bottom - (crSize.Height);
                            pCenterX = xCenterOfImg = width - WM_Right - (crSize.Width / 2);
                            break;
                        }

                        //设置字体居中
                        StringFormat StrFormat = new StringFormat();
                        StrFormat.Alignment = StringAlignment.Center;

                        //设置绘制文本的颜色和纹理 (Alpha=153)
                        SolidBrush semiTransBrush2 = new SolidBrush(Color.FromArgb(WM_Alpha, WM_Red, WM_Green, WM_Blue));

                        //旋转水印
                        PointF pCenter = new PointF(pCenterX, pCenterY);
                        grPhoto.TranslateTransform(pCenter.X, pCenter.Y);
                        grPhoto.RotateTransform(iRotate);
                        grPhoto.TranslateTransform(-pCenter.X, -pCenter.Y);

                        //将版权信息绘制到图象上
                        grPhoto.DrawString(WM_Text, crFont, semiTransBrush2, new PointF(xCenterOfImg, yPosFromBottom), StrFormat);
                    }
                    //图片模式
                    else
                    {
                        int iMarkRightSpace  = 0;
                        int iMarkButtomSpace = 0;
                        //创建一个需要填充水银的Image对象
                        System.Drawing.Image imgWatermark = new Bitmap(Server.MapPath("~/Files/" + config.WM_ImagePath));
                        int iMarkWidth   = imgWatermark.Width;
                        int iMarkmHeight = imgWatermark.Height;

                        Graphics grWatermark = null;

                        //将位图bmWatermark加载到Graphics对象
                        grWatermark = Graphics.FromImage(bitmap);
                        ImageAttributes imageAttributes = new ImageAttributes();

                        ColorMap colorMap = new ColorMap();

                        colorMap.OldColor = Color.FromArgb(255, 0, 255, 0);
                        colorMap.NewColor = Color.FromArgb(0, 0, 0, 0);

                        ColorMap[] remapTable = { colorMap };

                        imageAttributes.SetRemapTable(remapTable, ColorAdjustType.Bitmap);

                        float[][] colorMatrixElements =
                        {
                            new float[] { 1.0f, 0.0f, 0.0f,                                 0.0f, 0.0f },
                            new float[] { 0.0f, 1.0f, 0.0f,                                 0.0f, 0.0f },
                            new float[] { 0.0f, 0.0f, 1.0f,                                 0.0f, 0.0f },
                            new float[] { 0.0f, 0.0f, 0.0f, (float)((WM_Alpha / 50) * 20) / 100f, 0.0f }, //设置透明度
                            new float[] { 0.0f, 0.0f, 0.0f,                                 0.0f, 1.0f }
                        };
                        ColorMatrix wmColorMatrix = new ColorMatrix(colorMatrixElements);

                        imageAttributes.SetColorMatrix(wmColorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);

                        iMarkRightSpace  = width - iMarkWidth - WM_Right;
                        iMarkButtomSpace = height - iMarkmHeight - WM_Bottom;

                        grWatermark.DrawImage(imgWatermark, new Rectangle(iMarkRightSpace, iMarkButtomSpace, iMarkWidth, iMarkmHeight), 0, 0, iMarkWidth, iMarkmHeight, GraphicsUnit.Pixel, imageAttributes);
                    }
                }

                MemoryStream stream = new MemoryStream();

                string fileType = MojoCube.Api.File.Function.GetContentType(sPath);

                if (fileType == "image/png")
                {
                    bitmap.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
                }
                else
                {
                    ImageCodecInfo[]  info = ImageCodecInfo.GetImageEncoders();
                    EncoderParameters ep   = new EncoderParameters(1);
                    ep.Param[0] = new EncoderParameter(Encoder.Quality, (long)100);
                    bitmap.Save(stream, info[1], ep);
                }

                bFile = stream.ToArray();

                Response.Clear();
                Response.ContentType = fileType;
                string fileName = Server.HtmlEncode(sPath.Substring(sPath.LastIndexOf('/') + 1));
                Response.AddHeader("Content-Disposition", "inline;filename=\"" + fileName + "\"");

                Response.Charset         = "";
                Response.ContentEncoding = System.Text.Encoding.Unicode;
                Response.AddHeader("Connection", "close");
                Response.BinaryWrite(bFile);

                //Response.Clear();
                bitmap.Dispose();
                stream.Dispose();
                img.Dispose();
            }
            else if (Request.QueryString["file"] != null)
            {
                string sPath = MojoCube.Api.Text.Security.DecryptString(Request.QueryString["file"]);
                byte[] bFile = null;

                System.IO.FileInfo     File = new System.IO.FileInfo(Server.MapPath("~/Files/" + sPath));
                System.IO.FileStream   FS   = File.OpenRead();
                System.IO.BinaryReader BR   = new System.IO.BinaryReader(FS);
                bFile = BR.ReadBytes((int)FS.Length);
                FS.Dispose();
                BR.Close();

                Response.Clear();
                Response.ContentType = MojoCube.Api.File.Function.GetContentType(sPath);
                string fileName = Server.HtmlEncode(sPath.Substring(sPath.LastIndexOf('/') + 1));
                Response.AddHeader("Content-Disposition", "inline;filename=\"" + fileName + "\"");

                Response.Charset         = "";
                Response.ContentEncoding = System.Text.Encoding.Unicode;
                Response.AddHeader("Connection", "close");
                Response.BinaryWrite(bFile);
            }
        }
        catch
        {
            Response.Write("Error!");
        }
    }