Esempio n. 1
0
        protected void loginBtn_Click(object sender, EventArgs e)
        {
            if (SiteConfig.UserConfig.EnableCheckCodeOfLogin)
            {
                string vCode = this.Session["ValidateCode"].ToString();
                if (string.IsNullOrEmpty(vCode))
                {
                    function.WriteErrMsg("<li>验证码无效,请刷新验证码重新登录</li>", "/User/Login");
                }
                if (string.Compare(this.TxtValidateCode.Text.Trim(), vCode, true) != 0)
                {
                    function.WriteErrMsg("<li>验证码不正确</li>", "/User/Login");
                }
            }
            //根据用户名和密码验证会员身份,并取得会员信息
            string     AdminName = this.TxtUserName.Text.Trim();
            string     AdminPass = this.TxtPassword.Text.Trim();
            M_UserInfo info      = new M_UserInfo();

            info = bll.AuthenticateUser(AdminName, AdminPass);
            if (info.IsNull)
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('用户名或密码错误!!')", true);
            }
            else
            {
                if (info.Status != 0)
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('你的帐户未通过验证或被锁定,请与网站管理员联系!!')", true);
                }
                bll.SetLoginState(info, "Day");
                M_Site_SiteList siteM   = new M_Site_SiteList();
                B_Site_SiteList siteBll = new B_Site_SiteList();
                siteM = siteBll.SelByUserID(info.UserID.ToString());
                if (siteM == null)
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('你无对应的权限!!')", true);
                }
                else
                {
                    Response.Redirect(CustomerPageAction.customPath + "Site/SiteDetail.aspx?siteID=" + siteM.SiteID);
                }
            }
        }
        protected void Update(int rowNum, string id)//Update WebSite with index=0,Name,Port,PPath,Domain
        {
            IISWebSite  site = new IISWebSite();
            GridViewRow gr   = EGV.Rows[rowNum];

            site.SiteName = ((TextBox)gr.FindControl("EditSiteName")).Text.Trim();
            site.Port     = ((TextBox)gr.FindControl("EditPort")).Text.Trim();
            //site.PhysicalPath = ((TextBox)gr.FindControl("EditPhySicalPath")).Text.Trim();
            //site.DomainName = ((TextBox)gr.FindControl("EditDomain")).Text.Trim();
            IISHelper iisM = new IISHelper();
            DataTable dt   = iisM.GetWebSiteList();

            dt.DefaultView.RowFilter = "SiteID=" + id;
            DataRow dr = dt.DefaultView.ToTable().Rows[0];

            //-----有更改才更新,先更新域名
            if (!(dr["SiteName"] as string).Equals(site.SiteName))
            {
                iisHelper.ChangeSiteName(dr["SiteName"] as string, site.SiteName);
            }
            if (!(dr["SitePort"] as string).Equals(site.Port))
            {
                iisHelper.ChangeSitePort(site.SiteName, site.Port);
            }
            //if (!(dr["PhysicalPath"] as string).Equals(site.PhysicalPath))
            //    iisHelper.ChangeSitePath(site.SiteName, site.PhysicalPath);
            //if (!(dr["Domain"] as string).Equals(site.DomainName))
            //    iisHelper.ChangeSiteDomain(site.SiteName, site.DomainName);

            B_Site_SiteList siteBll   = new B_Site_SiteList();
            M_Site_SiteList siteModel = new M_Site_SiteList();

            siteModel         = siteBll.SelBySiteID(id);
            siteModel.EndDate = DataConvert.CDate(((TextBox)gr.FindControl("EditEndDate")).Text.Trim());
            siteBll.UpdateModel(siteModel);
            Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('修改完成');location=location;", true);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            IdentityAnalogue ia = new IdentityAnalogue();

            ia.CheckEnableSA();
            //---------------指定管理员权限管理
            M_Site_SiteList siteM   = new M_Site_SiteList();
            B_Site_SiteList siteBll = new B_Site_SiteList();

            if (badmin.CheckLogin())
            {
                //如果是管理员登录则不判断
            }
            else if (buser.CheckLogin())
            {
                string siteID = iis.Sites[siteName].Id.ToString();
                //非管理员用户登录,开始判断
                siteM = siteBll.SelByUserID(buser.GetLogin().UserID.ToString());//查找有无为该用户分配权限
                if (siteM == null || !siteBll.AuthCheck(siteID, buser.GetLogin().UserID.ToString()))
                {
                    function.WriteErrMsg("你没有管理站点的权限");
                }
                this.Title = "独立控制台-文件浏览";
            }
            else
            {
                function.WriteErrMsg("无权访问该页面"); return;
            }
            //--------------

            if (function.isAjax())//删除
            {
                string[] siteInfo;
                //站点名,索引,目标文件
                string action = Request.Form["action"];
                if (action.Equals("beginDown"))//开始下载
                {
                    siteInfo = Request.Form["fullPath"].Split(':');
                    Int32.TryParse(siteInfo[1], out index);
                    StationGroup.RootPath = iis.Sites[siteInfo[0]].Applications[0].VirtualDirectories[index].PhysicalPath;
                    if (!Directory.Exists(StationGroup.RootPath + StationGroup.ZipSavePath))
                    {
                        Directory.CreateDirectory(StationGroup.RootPath + StationGroup.ZipSavePath);
                    }
                    if (File.Exists(StationGroup.RootPath + StationGroup.ZipSavePath + StationGroup.ZipName))
                    {
                        File.Delete(StationGroup.RootPath + StationGroup.ZipSavePath + StationGroup.ZipName);
                    }
                    //ThreadPool.QueueUserWorkItem(MyThreadWork, tempPath + StationGroup.ZipName);
                    ThreadPool.QueueUserWorkItem(MyThreadWork, sg);
                    Response.End();
                }
                else if (action.Equals("getProgress"))
                {
                    Response.Write(progStatus);
                    Response.End();
                }
                else if (action.Equals("getUnZipProg"))
                {
                    //根据长度 ,计算出百分比值后返回
                    Response.Write(ZipClass.GetPercent(ZipClass.unZipTotal, ZipClass.unZipProgress));
                    Response.End();
                }
                siteInfo = Request.Form["fullPath"].Split(':');
                int i = 0;
                if (siteInfo.Length < 3 || !Int32.TryParse(siteInfo[1], out i))
                {
                    Response.Write("信息错误,无法删除"); Response.Flush(); Response.End();
                }
                string path = GetPath(siteInfo[0], i, siteInfo[2]);//获取全路径
                if (action.Equals("del"))
                {
                    try
                    {
                        if (!DeleteDirAndFile(path))
                        {
                            Response.Write("文件不存在"); Response.Flush(); Response.End();
                        }
                    }
                    catch (Exception ex) { Response.Write(ex.Message); Response.Flush(); Response.End(); }//Response.Write("删除失败,目标文件正在使用或你无权限删除");
                }
                else if (action.Equals("rename"))
                {
                    string newPath = GetPath(siteInfo[0], i, "\\" + siteInfo[3]);
                    //Response.Write(siteInfo[2]+":"+siteInfo[3]);
                    if (!path.Equals(newPath))
                    {
                        RenameDirAndFile(path.Trim(), newPath.Trim());
                    }
                }
                Response.Clear();
                Response.Write(1);
                Response.Flush(); Response.End();
            }
            //----------------AJAX END;

            siteName = Server.HtmlEncode(Request.QueryString["siteName"]);
            if (string.IsNullOrEmpty(siteName) || string.IsNullOrEmpty(Request.QueryString["index"]) || iis.Sites[siteName] == null)
            {
                function.WriteErrMsg("未选择要访问的站点名或该站点不存在.");
            }
            Int32.TryParse(Request.QueryString["index"], out index);
            StationGroup.RootPath = iis.Sites[siteName].Applications[0].VirtualDirectories[index].PhysicalPath;
            if (string.IsNullOrEmpty(iis.Sites[siteName].Bindings[index].Host))
            {
                url = "http://LocalHost:" + iis.Sites[siteName].Bindings[index].EndPoint.Port;
            }
            else
            {
                url = "http://" + iis.Sites[siteName].Bindings[index].Host + ":" + iis.Sites[siteName].Bindings[index].EndPoint.Port;
            }

            if (!IsPostBack)
            {
                Call.HideBread(Master);
                Repeater1.DataSource = GetDirAndFileList();
                Repeater1.DataBind();

                string command = Request["command"];//如beginSetup开始安装等,快云安装传过来的
                if (!string.IsNullOrEmpty(command))
                {
                    switch (command)
                    {
                    case "beginSetup":
                        Page.ClientScript.RegisterStartupScript(this.GetType(), "", "beginDown();", true);    //调用前台开始下载方法
                        break;

                    default:
                        break;
                    }
                }//Command End;
            }
        }