namespace Kesion.NET.WebSite
{
    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 Kesion.Publics;
    using Kesion.BLL;
    using Kesion.Cache;
    using Kesion.APPCode;
    public partial class Admin_Include_SaveBeyondfile : System.Web.UI.Page
    {
        public int ChannelID = 0;
        protected void Page_Load(object sender, EventArgs e)
        {
            Context.Response.Cache.SetCacheability(HttpCacheability.NoCache);  //禁止缓存

            KSSecurity.CheckPermissions(1, false);

           

            ChannelID = Utils.StrToInt(KSCMS.S("Channelid"), 0);
  

            //this.Title = KSCMS.S("PageTitle");
            this.Title="远程抓取图片";
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            string BeyoundFile = this.TextBox1.Text;
            string SavePath = Public.GetUpfilesDir();

            string filename = string.Empty;
            filename = Utils.RndNum(5);
            filename += DateTime.Now.ToFileTimeUtc();
            try
            {
                filename += BeyoundFile.Substring(BeyoundFile.LastIndexOf("."));
            }
            catch
            { 
               
            }
            SavePath += filename;

            if (Public.SaveRemoteFile(BeyoundFile, SavePath).Equals(true))
            {
                #region 远程附件
                if (MyCache.GetCacheConfig(59).ToString() == "1")
                {
                    FtpWeb ft = new FtpWeb();
                    if (ft.Upload(SavePath) == "success")
                    {
                        if (MyCache.GetCacheConfig(67)=="1") HtmlTags.Function.DelFile(SavePath);
                        SavePath = MyCache.GetCacheConfig(65) + SavePath;
                    }
                    ft = null;
                }
                #endregion
                KSCMS.Die(@"<script>alert('恭喜，成功保存了远程图片!'); top.frames[""main""].document.getElementById('"+KSCMS.S("fieldID").Trim() +"').value='" + SavePath + "';top.box.close();</script>");
            }
            else
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "page", "<script>alert('对不起，保存失败!');</script>");
                this.TextBox1.Text = "";
            }
           

        }
}
}