http://www.sufeinet.com/plugin.php?id=keke_group

苏飞论坛

 找回密码
 马上注册

QQ登录

只需一步,快速开始

分布式系统框架(V2.0) 轻松承载百亿数据,千万流量!讨论专区 - 源码下载 - 官方教程

HttpHelper爬虫框架(V2.7-含.netcore) HttpHelper官方出品,爬虫框架讨论区 - 源码下载 - 在线测试和代码生成

HttpHelper爬虫类(V2.0) 开源的爬虫类,支持多种模式和属性 源码 - 代码生成器 - 讨论区 - 教程- 例子

查看: 3242|回复: 2

[Asp.Net] 安装类写好代码后安装程序老提示无压缩文件

[复制链接]
发表于 2014-8-25 08:42:26 | 显示全部楼层 |阅读模式
3)安装并复制文件
           复制文件的操作在OnBeforeInstall方法中就已经完成,在该方法中可以替换数据库连接字符串操作等。

[C#] 纯文本查看 复制代码
protected override void OnBeforeInstall(IDictionary savedState)
        {
            if (ExistSqlServerService())
            {
                if (IsExistSitePort())
                {
                    MessageBox.Show("站点端口号重复", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
                if (IsExistSiteName(Context.Parameters["sitename"].ToString()))
                {
                    MessageBox.Show("站点名称重复", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
                base.OnBeforeInstall(savedState);

                unRAR("Message.rar"); //解压文件
                unRAR("MoreUpload.rar");
                /*
                 * 设置webconfig连接字符串
                 */
                string webconfigpath = Path.Combine(this.Context.Parameters["installdir"].ToString(), "Web.config");
                string webcofnigstring = File.ReadAllText(webconfigpath).Replace("#constring#", GetConnectionString(Context.Parameters["dbname"].ToString()));
                webcofnigstring = webcofnigstring.Replace("#siteport#", Context.Parameters["siteport"].ToString());
                webcofnigstring = webcofnigstring.Replace("#comConn#", "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=" + Context.Parameters["user"].ToString() + ";Password=" + Context.Parameters["pwd"].ToString() + ";Initial Catalog=" + Context.Parameters["dbname"].ToString() + ";Data Source=" + Context.Parameters["server"].ToString());
                File.WriteAllText(webconfigpath, webcofnigstring);

                ////安装IIS
                //if (string.Empty == GetIISVerstion())
                //{
                //    IISInstall(this.Context.Parameters["installdir"].ToString() + "IIS6.0_XPSP3", this.Context.Parameters["installdir"].ToString() + "iis.txt");
                //}

            }
            else
            {
                MessageBox.Show("检测到您的电脑没有安装SQL SERVER,无法继续安装此产品", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                this.Rollback(savedState);
            }

        }

      上面代码中解压了两个文件,主要是在安装完创建站点时还需要创建虚拟目录。之所以要先压缩放到WEB项目里,是因为生成安装程序时会检测项目的生成是否成功(是否可以不让它检测成功呢? 还不清楚),一般只要我们把发布好的项目COPY到新建项目下就可以,但是独立的项目文件夹有自己独立的bin目录和webconfig文件,是不能混合在一起生成成功的,但是又需要一次完全安装,那么可以先压缩做为WEB项目下的文件,待复制完后再解压。
----------------------------------------------------------------------------------------------------------------
红色这句话难道要自己添加压缩包吗?




1. 开通SVIP会员,免费下载本站所有源码,不限次数据,不限时间
2. 加官方QQ群,加官方微信群获取更多资源和帮助
3. 找站长苏飞做网站、商城、CRM、小程序、App、爬虫相关、项目外包等点这里
 楼主| 发表于 2014-8-25 08:57:14 | 显示全部楼层
笑脸是这个  
QQ截图20140825084900.png
发表于 2014-9-5 23:33:25 | 显示全部楼层
强烈支持楼主ing……
您需要登录后才可以回帖 登录 | 马上注册

本版积分规则

QQ|手机版|小黑屋|手机版|联系我们|关于我们|广告合作|苏飞论坛 ( 豫ICP备18043678号-2)

GMT+8, 2024-6-1 23:55

© 2014-2021

快速回复 返回顶部 返回列表