Пример #1
0
        private void CmdProcess_Exited(object sender, EventArgs e)
        {
            string myConnString = "user id=" + UpdateInfo.DBusername + ";data source=" + UpdateInfo.DBSID + ";password="******"insert into system_version_info(modulename,modulecode,version,publish_date,update_date,remark) " +
                                  "values('" + name + "','" + code + "','" + ver + "','" + publishdate + "',to_char(sysdate, 'yyyy-mm-dd hh24:mi:ss'),'" + keyword + "')";

            try {
                if (UpdateInfo.DBType.Equals("sqlserver"))
                {
                    sql = "insert into system_version_info(modulename,modulecode,version,publish_date,update_date,remark) " +
                          "values('" + name + "','" + code + "','" + ver + "','" + publishdate + "', convert(varchar(20),getdate(),121),'" + keyword + "')";
                    myConnString = "Initial Catalog=" + UpdateInfo.DBSID + ";Data Source=" + UpdateInfo.DBDataSource + ";User ID=" + UpdateInfo.DBusername + "; Password="******"插点版本信息你数据库里去,又不会怀孕。干嘛呢?" + e1.Message, "提示");
            }

            MessageBox.Show("SQL语句执行完毕!", "提示");
        }
        public bool OnNextButton()
        {
            if (string.IsNullOrEmpty(this.textBox2.Text))
            {
                MessageBox.Show("请选择备份目录", "提示");
                return(false);
            }
            if (string.IsNullOrEmpty(this.textBox1.Text) || string.IsNullOrEmpty(this.textBox4.Text))
            {
                MessageBox.Show("Sorry,你必须得连接数据库,否则,最后执行SQL就悲催了。");
                return(false);
            }
            else
            {
                XmlHelper.Delete("/root/DBConfig", "");
                XmlHelper.Insert("/root", "DBConfig", "", "");
                XmlHelper.Insert("/root/DBConfig", "username", "", this.textBox1.Text);
                XmlHelper.Insert("/root/DBConfig", "password", "", this.textBox3.Text);
                XmlHelper.Insert("/root/DBConfig", "SID", "", this.textBox4.Text);
                string myConnString = "";
                if (this.radioButton1.Checked)
                {
                    XmlHelper.Insert("root/DBConfig", "TYPE", "", "oracle");
                    myConnString = "user id=" + this.textBox1.Text + ";data source=" + this.textBox4.Text + ";password="******"select 1 from dual");
                }
                else
                {
                    XmlHelper.Insert("/root/DBConfig", "DataSource", "", this.textBox5.Text);
                    XmlHelper.Insert("root/DBConfig", "TYPE", "", "sqlserver");
                    myConnString = "Initial Catalog=" + this.textBox4.Text + ";Data Source=" + this.textBox5.Text + ";User ID=" + this.textBox1.Text + "; Password="******"select 1");
                }
            }
            if (!Checked)
            {
                DialogResult dr = MessageBox.Show("更新包版本检查不通过,是否继续", "提示", MessageBoxButtons.OKCancel);
                if (dr != DialogResult.OK)
                {
                    return(false);
                }
            }


            cf = new CopyFileFrame();
            cf.servicespath = this.Parent.Tag as string;
            cf.bakToPath    = this.textBox2.Text;
            cf.Closing     += new CancelEventHandler(cf_Closing);
            cf.ShowDialog();


            return(true);
        }
        void Button1Click(object sender, EventArgs e)
        {
            //将数据库配置写入xml,方便以后调用
            XmlHelper.Update("root/DBConfig/username", "", this.textBox1.Text);
            XmlHelper.Update("root/DBConfig/password", "", this.textBox3.Text);
            XmlHelper.Update("root/DBConfig/SID", "", this.textBox4.Text);
            if (this.radioButton1.Checked)
            {
                XmlHelper.Update("root/DBConfig/TYPE", "", "oracle");
            }
            else
            {
                XmlHelper.Update("root/DBConfig/DataSource", "", this.textBox5.Text);
                XmlHelper.Update("root/DBConfig/TYPE", "", "sqlserver");
            }
            //组成数据库连接字符串
            string  myConnString = "";
            string  sql          = "select * from (select version  from system_version_info where modulecode='{0}' and modulename='{1}'  order by version,update_date desc) where  rownum=1 ";
            DataSet ds           = new DataSet();

            if (this.radioButton1.Checked)
            {
                myConnString = "user id=" + this.textBox1.Text + ";data source=" + this.textBox4.Text + ";password="******"select top 1 version  from system_version_info where modulecode='{0}' and modulename='{1}'  order by version,update_date desc";
                myConnString = "Initial Catalog=" + this.textBox4.Text + ";Data Source=" + this.textBox5.Text + ";User ID=" + this.textBox1.Text + "; Password="******"";

            if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                //根据获取到的DS转成string
                cur = (ds.Tables[0].Rows[0][0]) as string;
            }

            if (string.IsNullOrEmpty(cur))
            {
                this.label2.ForeColor = Color.Red;
                this.label2.Text      = "未能检查到先前的版本。";
                MessageBox.Show("你更新的版本从来没有更新过。");
                return;
            }
            this.label2.Text = string.Format(checkverstr, UpdateInfo.Ver, cur);

            //根据字符串cur计算出下一个版本号
            string[] curtemp = cur.Split('.');
            if (curtemp.Length < 3)
            {
                MessageBox.Show("版本号规则不匹配,无法计算应更新版本。");
                return;
            }
            int    should_w = Int32.Parse(curtemp[curtemp.Length - 2]) + 1;                                                                 //计算倒数二个版本代号 并 加 1
            string curTou   = cur.Substring(0, cur.Length - (curtemp[curtemp.Length - 1].Length + curtemp[curtemp.Length - 2].Length + 1)); //截取出版本号头位置
            string should   = curTou + should_w;                                                                                            //计算出去掉测试位的版本号

            if (UpdateInfo.Ver.StartsWith(should))
            {
                this.label2.ForeColor = Color.Green;
                Checked = true;
            }
            else
            {
                this.label2.ForeColor = Color.Red;
                MessageBox.Show("你所更新的版本不符合要求,先更新“" + should + "”版本!", "警告");
            }
        }