⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 default.cs

📁 动易SiteFactory&#8482 网上商店系统1.0源代码
💻 CS
📖 第 1 页 / 共 2 页
字号:
                    return false;
                }
                finally
                {
                    command.Dispose();
                    connection.Close();
                    connection.Dispose();
                }
            }
            return true;
        }

        public static bool FolderCheck(string filepath)
        {
            try
            {
                using (FileStream stream = new FileStream(filepath + @"\a.Txt", FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite))
                {
                }
                File.Delete(filepath + @"\a.Txt");
                return true;
            }
            catch
            {
                return false;
            }
        }

        public void InstallFileCheck()
        {
            bool error = false;
            this.TblInstallFileCheck.Rows.Add(BinDllCheck(ref error));
            TableRow row = new TableRow();
            TableCell cell = new TableCell();
            cell.Attributes["bgcolor"] = "#ffffff";
            cell.Attributes["width"] = "85%";
            TableCell cell2 = new TableCell();
            cell2.Attributes["bgcolor"] = "#ffffff";
            cell2.Attributes["width"] = "15%";
            Image child = new Image();
            DirectoryInfo info = new DirectoryInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App_Data"));
            if (info.GetFiles("*.sql").Length > 0)
            {
                cell.Text = "数据库查询脚本文件存在!";
                child.ImageUrl = "images/ok.gif";
                cell2.Controls.Add(child);
            }
            else
            {
                cell.Text = "数据库查询脚本文件没有!";
                child.ImageUrl = "images/error.gif";
                cell2.Controls.Add(child);
                error = true;
            }
            row.Cells.Add(cell);
            row.Cells.Add(cell2);
            this.TblInstallFileCheck.Rows.Add(row);
            string fileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Config\Site.config");
            foreach (string str5 in ((ReadSiteConfigElement(fileName, "AdvertisementDir") + "," + ReadSiteConfigElement(fileName, "IncludeFilePath")) + ",Skin,Config,Template,Temp,UploadFiles").Split(new char[] { ',' }))
            {
                TableRow row2 = new TableRow();
                TableCell cell3 = new TableCell();
                cell3.Attributes["bgcolor"] = "#ffffff";
                cell3.Attributes["width"] = "85%";
                TableCell cell4 = new TableCell();
                cell4.Attributes["bgcolor"] = "#ffffff";
                cell4.Attributes["width"] = "15%";
                Image image2 = new Image();
                if (!FolderCheck(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, str5)))
                {
                    cell3.Text = "对 " + str5 + " 目录没有写入和删除权限!";
                    image2.ImageUrl = "images/error.gif";
                    cell4.Controls.Add(image2);
                    error = true;
                }
                else
                {
                    cell3.Text = "对 " + str5 + " 目录权限验证通过!";
                    image2.ImageUrl = "images/ok.gif";
                    cell4.Controls.Add(image2);
                }
                row2.Cells.Add(cell3);
                row2.Cells.Add(cell4);
                this.TblInstallFileCheck.Rows.Add(row2);
            }
            if (error)
            {
                this.NextButtonStep2.Visible = false;
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!base.IsPostBack)
            {
                string str;
                string strA = ConfigurationManager.AppSettings["Version"];
                if (string.Compare(strA, ProductVersion) >= 0)
                {
                    base.Response.Redirect("~/");
                }
                if (string.Compare(ReadSiteConfigElement(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Config\Site.config"), "ProductEdition"), "eShop", true) == 0)
                {
                    str = "PowerEasy SiteFactory eShop 1.0";
                }
                else
                {
                    str = "PowerEasy SiteFactory CMS 1.0";
                }
                using (StreamReader reader = new StreamReader(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "License.txt"), Encoding.Default))
                {
                    this.TxtLicense.Value = reader.ReadToEnd();
                }
                this.LblProductName1.Text = str;
                this.LblProductName2.Text = str;
                this.LblProductName3.Text = str;
                this.LblProductCopyright.Text = FvInfo.LegalCopyright;
            }
        }

        protected void PreviousButtonStep3_Click(object sender, EventArgs e)
        {
            this.InstallFileCheck();
        }

        public static string ReadSiteConfigElement(string fileName, string element)
        {
            XmlTextReader reader = new XmlTextReader(fileName);
            string str = string.Empty;
            while (reader.Read())
            {
                if (string.Compare(reader.Name, element, true) == 0)
                {
                    str = reader.ReadString();
                    break;
                }
            }
            reader.Close();
            return str;
        }

        private void SetConfig(string valueList)
        {
            string str = valueList.Split(new char[] { ';' })[0];
            string str2 = valueList.Split(new char[] { ';' })[1];
            string str3 = valueList.Split(new char[] { ';' })[2];
            string str4 = valueList.Split(new char[] { ';' })[3];
            string str5 = valueList.Split(new char[] { ';' })[4];
            string fileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Config\Site.config");
            WriteSiteConfigElement(fileName, "SiteTitle", str);
            WriteSiteConfigElement(fileName, "SiteUrl", str2);
            WriteSiteConfigElement(fileName, "ManageDir", str3);
            WriteSiteConfigElement(fileName, "SiteManageCode", str4);
            WriteSiteConfigElement(fileName, "VirtualPath", str5);
        }

        public static void WriteSiteConfigElement(string fileName, string element, string value)
        {
            XmlDocument document = new XmlDocument();
            document.Load(fileName);
            foreach (XmlNode node in document.DocumentElement.ChildNodes)
            {
                foreach (XmlNode node2 in node.ChildNodes)
                {
                    if (string.Compare(node2.Name, element, true) == 0)
                    {
                        node2.InnerText = value;
                        break;
                    }
                }
            }
            document.Save(fileName);
        }

        protected void WzdInstall_FinishButtonClick(object sender, WizardNavigationEventArgs e)
        {
            try
            {
                IncludeFile.CreateAllIncludeFile();
            }
            catch
            {
            }
            base.Response.Redirect("~/");
        }

        protected void WzdInstall_NextButtonClick(object sender, WizardNavigationEventArgs e)
        {
            switch (e.CurrentStepIndex)
            {
                case 0:
                    this.InstallFileCheck();
                    return;

                case 1:
                {
                    string connectionString = WebConfigurationManager.ConnectionStrings["Connection String"].ConnectionString;
                    this.TxtDataSource.Text = connectionString.Split(new char[] { ';' })[0].Split(new char[] { '=' })[1];
                    this.TxtDataBase.Text = connectionString.Split(new char[] { ';' })[1].Split(new char[] { '=' })[1];
                    this.TxtUserID.Text = connectionString.Split(new char[] { ';' })[2].Split(new char[] { '=' })[1];
                    return;
                }
                case 2:
                {
                    string str2 = "server=" + this.TxtDataSource.Text + ";database=" + this.TxtDataBase.Text + ";uid=" + this.TxtUserID.Text + ";pwd=" + this.TxtPassword.Text;
                    try
                    {
                        SqlConnection connection = new SqlConnection(str2);
                        connection.Open();
                        connection.Close();
                        this.HdnPassword.Value = this.TxtPassword.Text;
                    }
                    catch (SqlException)
                    {
                        this.LblCheckConnectString.Visible = true;
                        e.Cancel = true;
                    }
                    break;
                }
                case 3:
                {
                    string fileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Config\Site.config");
                    this.TxtSiteTitle.Text = ReadSiteConfigElement(fileName, "SiteTitle");
                    this.TxtSiteUrl.Text = ReadSiteConfigElement(fileName, "SiteUrl");
                    this.TxtManageDir.Text = ReadSiteConfigElement(fileName, "ManageDir");
                    this.TxtSiteManageCode.Text = ReadSiteConfigElement(fileName, "SiteManageCode");
                    return;
                }
                case 4:
                {
                    string connectString = "server=" + this.TxtDataSource.Text + ";database=" + this.TxtDataBase.Text + ";uid=" + this.TxtUserID.Text + ";pwd=" + this.HdnPassword.Value;
                    string valueList = this.TxtSiteTitle.Text + ";" + this.TxtSiteUrl.Text + ";" + this.TxtManageDir.Text + ";" + this.TxtSiteManageCode.Text + ";" + base.Request.ApplicationPath;
                    try
                    {
                        this.SetConfig(valueList);
                        System.Configuration.Configuration configuration = WebConfigurationManager.OpenWebConfiguration("~");
                        AppSettingsSection section = (AppSettingsSection) configuration.GetSection("appSettings");
                        ConnectionStringsSection section2 = (ConnectionStringsSection) configuration.GetSection("connectionStrings");
                        section2.ConnectionStrings["Connection String"].ConnectionString = connectString;
                        section.Settings["Version"].Value = ProductVersion;
                        configuration.Save();
                        try
                        {
                            ChangeAdminPassword(connectString, this.TxtAdminPassword.Text.Trim());
                        }
                        catch (Exception exception)
                        {
                            this.LblErrorMessage.Text = exception.Message;
                            e.Cancel = true;
                        }
                    }
                    catch
                    {
                        this.LblErrorMessage.Text = "配置信息没有写入,可能是因为Config配置文件下的AppSettings.config、ConnectionStrings.config及Site.config三个文件是只读文件!\r\n<br/>或者是它们的ASPNET(XP)或Network Service(Server)用户没有修改权限!";
                        e.Cancel = true;
                    }
                    break;
                }
                default:
                    return;
            }
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -