예제 #1
0
        /// <summary>
        /// 设置FTP对象信息
        /// </summary>
        private static void SetFtpConfigInfo()
        {
            FTPConfigInfoCollection ftpconfiginfocollection = (FTPConfigInfoCollection)SerializationHelper.Load(typeof(FTPConfigInfoCollection), m_configfilepath);

            FTPConfigInfoCollection.FTPConfigInfoCollectionEnumerator fcice = ftpconfiginfocollection.GetEnumerator();

            //遍历集合并设置相应的FTP信息(静态)对象
            while (fcice.MoveNext())
            {
                if (fcice.Current.Name == "ForumAttach")
                {
                    m_forumattach = fcice.Current;
                    continue;
                }

                if (fcice.Current.Name == "SpaceAttach")
                {
                    m_spaceattach = fcice.Current;
                    continue;
                }

                if (fcice.Current.Name == "AlbumAttach")
                {
                    m_albumattach = fcice.Current;
                    continue;
                }

                if (fcice.Current.Name == "MallAttach")
                {
                    m_mallattach = fcice.Current;
                    continue;
                }
            }
        }
예제 #2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         string ftpType = GetParam(DNTRequest.GetString("ftptype"));
         FTPConfigInfoCollection ftpconfiginfocollection =
             (FTPConfigInfoCollection)SerializationHelper.Load(typeof(FTPConfigInfoCollection), Server.MapPath("../../config/ftp.config"));
         Allowupload.Items[0].Attributes.Add("onclick", "ShowFtpLayout(true)");
         Allowupload.Items[1].Attributes.Add("onclick", "ShowFtpLayout(false)");
         foreach (FTPConfigInfo fci in ftpconfiginfocollection)
         {
             if (fci.Name == ftpType)  //绑定论坛FTP设置
             {
                 Serveraddress.Text                = fci.Serveraddress;
                 Serverport.Text                   = fci.Serverport.ToString();
                 Username.Text                     = fci.Username;
                 Password.Text                     = fci.Password;
                 hiddpassword.Value                = fci.Password;
                 Mode.SelectedValue                = fci.Mode.ToString();
                 Uploadpath.Text                   = fci.Uploadpath;
                 Timeout.Text                      = fci.Timeout.ToString();
                 Allowupload.SelectedValue         = fci.Allowupload.ToString();
                 Remoteurl.Text                    = fci.Remoteurl;
                 Reservelocalattach.SelectedValue  = fci.Reservelocalattach.ToString();
                 Reserveremoteattach.SelectedValue = fci.Reserveremoteattach.ToString();
                 if (fci.Allowupload == 0)
                 {
                     FtpLayout.Attributes.Add("style", "display:none");
                 }
                 else
                 {
                     FtpLayout.Attributes.Add("style", "display:block");
                 }
             }
         }
         if (Serveraddress.Text != "")   //如果设置完全则返回
         {
             return;
         }
         FtpLayout.Attributes.Add("style", "display:none");
         foreach (FTPConfigInfo fci in ftpconfiginfocollection)
         {
             if (fci.Serveraddress != "")
             {
                 Serveraddress.Text = fci.Serveraddress;
                 Serverport.Text    = fci.Serverport.ToString();
                 Username.Text      = fci.Username;
                 Password.Text      = fci.Password;
                 Mode.SelectedValue = fci.Mode.ToString();
                 Uploadpath.Text    = ftpType.ToLower();
                 Timeout.Text       = fci.Timeout.ToString();
                 Remoteurl.Text     = fci.Remoteurl.Replace(fci.Name.ToLower(), ftpType.ToLower());
                 Reservelocalattach.SelectedValue  = fci.Reservelocalattach.ToString();
                 Reserveremoteattach.SelectedValue = fci.Reserveremoteattach.ToString();
             }
         }
     }
 }
예제 #3
0
        protected void SaveFtpInfo_Click(object sender, EventArgs e)
        {
            string ftpType = GetParam(DNTRequest.GetString("ftptype"));

            if (Serveraddress.Text.Trim() == "" || Serverport.Text.Trim() == "" || Username.Text.Trim() == "" ||
                Password.Text.Trim() == "" || Uploadpath.Text.Trim() == "" || Timeout.Text.Trim() == "" || Remoteurl.Text.Trim() == "")
            {
                base.RegisterStartupScript("", "<script>alert('远程附件设置各项不允许为空');window.location.href='global_ftpsetting.aspx?ftptype=" + ftpType + "';</script>");
                return;
            }
            if (Uploadpath.Text.EndsWith("/"))
            {
                base.RegisterStartupScript("", "<script>alert('附件保存路径不允许以“/”结尾');window.location.href='global_ftpsetting.aspx?ftptype=" + ftpType + "';</script>");
                return;
            }
            if (Remoteurl.Text.EndsWith("/"))
            {
                base.RegisterStartupScript("", "<script>alert('远程访问 URL 不允许以“/”结尾');window.location.href='global_ftpsetting.aspx?ftptype=" + ftpType + "';</script>");
                return;
            }
            if (!Utils.IsNumeric(Serverport.Text) || int.Parse(Serverport.Text) < 1)
            {
                base.RegisterStartupScript("", "<script>alert('远程访问端口必须为数字并且大于1');window.location.href='global_ftpsetting.aspx?ftptype=" + ftpType + "';</script>");
                return;
            }
            if (!Utils.IsNumeric(Timeout.Text) || int.Parse(Timeout.Text) < 0)
            {
                base.RegisterStartupScript("", "<script>alert('超时时间必须为数字并且大于1');window.location.href='global_ftpsetting.aspx?ftptype=" + ftpType + "';</script>");
                return;
            }
            FTPConfigInfoCollection ftpConfigInfoCollection =
                (FTPConfigInfoCollection)SerializationHelper.Load(typeof(FTPConfigInfoCollection), Server.MapPath("../../config/ftp.config"));
            bool isEdit = false;

            foreach (FTPConfigInfo fci in ftpConfigInfoCollection)
            {
                if (fci.Name == ftpType)
                {
                    fci.Serveraddress       = Serveraddress.Text;
                    fci.Serverport          = int.Parse(Serverport.Text);
                    fci.Username            = Username.Text;
                    fci.Password            = Password.Text;
                    fci.Mode                = int.Parse(Mode.SelectedValue);
                    fci.Uploadpath          = Uploadpath.Text;
                    fci.Timeout             = int.Parse(Timeout.Text);
                    fci.Allowupload         = int.Parse(Allowupload.SelectedValue);
                    fci.Remoteurl           = Remoteurl.Text;
                    fci.Reservelocalattach  = int.Parse(Reservelocalattach.SelectedValue);
                    fci.Reserveremoteattach = int.Parse(Reserveremoteattach.SelectedValue);
                    isEdit = true;
                    break;
                }
            }
            if (!isEdit)
            {
                FTPConfigInfo fci = new FTPConfigInfo();
                fci.Name                = ftpType;
                fci.Serveraddress       = Serveraddress.Text;
                fci.Serverport          = int.Parse(Serverport.Text);
                fci.Username            = Username.Text;
                fci.Password            = Password.Text;
                fci.Mode                = int.Parse(Mode.SelectedValue);
                fci.Uploadpath          = ftpType.ToLower();
                fci.Timeout             = int.Parse(Timeout.Text);
                fci.Allowupload         = int.Parse(Allowupload.SelectedValue);
                fci.Remoteurl           = Remoteurl.Text;
                fci.Reservelocalattach  = int.Parse(Reservelocalattach.SelectedValue);
                fci.Reserveremoteattach = int.Parse(Reserveremoteattach.SelectedValue);
                ftpConfigInfoCollection.Add(fci);
            }
            SerializationHelper.Save(ftpConfigInfoCollection, Server.MapPath("../../config/ftp.config"));
            Response.Redirect("global_ftpsetting.aspx?ftptype=" + ftpType);
        }