Beispiel #1
0
        public void readtextfrompath()
        {
            ReadXMLdoc xml = new ReadXMLdoc();

            textBox2.Text = xml.readtext("Program");

            textBox4.Text = xml.readtext("InvincibleCMS");

            textBox5.Text = xml.readtext("SqlUrl");

            textBox6.Text = xml.readtext("DataBase");

            textBox7.Text = xml.readtext("LoginSystem");

            textBox1.Text = xml.readtext("Localhost");
        }
Beispiel #2
0
        private void button14_Click(object sender, EventArgs e)
        {
            string     LoginSystempath = textBox7.Text;
            ReadXMLdoc xml             = new ReadXMLdoc();

            if (string.IsNullOrEmpty(LoginSystempath))
            {
                LoginSystempath = "地址4";
            }
            if (xml.xmlisExists())
            {
                if (xml.updatexmldoc("LoginSystem", LoginSystempath))
                {
                    MessageBox.Show("保存成功!");
                }
            }
        }
Beispiel #3
0
        private void button11_Click(object sender, EventArgs e)
        {
            string     DataBasepath = textBox6.Text;
            ReadXMLdoc xml          = new ReadXMLdoc();

            if (string.IsNullOrEmpty(DataBasepath))
            {
                DataBasepath = "地址3";
            }
            if (xml.xmlisExists())
            {
                if (xml.updatexmldoc("DataBase", DataBasepath))
                {
                    MessageBox.Show("保存成功!");
                }
            }
        }
Beispiel #4
0
        private void button7_Click(object sender, EventArgs e)
        {
            string     Sqlpath = textBox5.Text;
            ReadXMLdoc xml     = new ReadXMLdoc();

            if (string.IsNullOrEmpty(Sqlpath))
            {
                Sqlpath = "地址2";
            }
            if (xml.xmlisExists())
            {
                if (xml.updatexmldoc("SqlUrl", Sqlpath))
                {
                    MessageBox.Show("保存成功!");
                }
            }
        }
Beispiel #5
0
        //保存项目基本文件路径
        private void button8_Click(object sender, EventArgs e)
        {
            string     Invincepath = textBox4.Text;
            ReadXMLdoc xml         = new ReadXMLdoc();

            if (string.IsNullOrEmpty(Invincepath))
            {
                Invincepath = "地址1";
            }
            if (xml.xmlisExists())
            {
                if (xml.updatexmldoc("InvincibleCMS", Invincepath))
                {
                    MessageBox.Show("保存成功!");
                }
            }
        }
Beispiel #6
0
        private void button6_Click(object sender, EventArgs e)
        {
            string     projectpath = textBox2.Text;
            ReadXMLdoc xml         = new ReadXMLdoc();

            if (string.IsNullOrEmpty(projectpath))
            {
                projectpath = "地址0";
            }
            if (xml.xmlisExists())
            {
                if (xml.updatexmldoc("Program", projectpath))
                {
                    MessageBox.Show("保存成功!");
                }
            }
        }
Beispiel #7
0
        private void button1_Click(object sender, EventArgs e)
        {
            string websitename = getWebsitePath(textBox2.Text);
            string newpath     = websitename + "\\" + (textBox4.Text.Substring(textBox4.Text.LastIndexOf("\\") + 1));

            if (string.IsNullOrEmpty(txt_websitename.Text) || string.IsNullOrEmpty(textBox3.Text))
            {
                MessageBox.Show("网站名或路径不能为空");
                return;
            }
            button1.Enabled = false;
            label4.Text     = "开始生成";

            string dataname = getdatabasename(txt_websitename.Text);
            string root     = null;

            if (textBox6.Text == "地址3" || textBox6.Text == string.Empty)
            {
                root = websitename + "\\" + "数据库";
            }
            else
            {
                root = textBox6.Text;
            }

            #region 创建新的网站路径并复制网站到新地址
            //创建新的网站路径
            var createWebsite = Task <int> .Factory.StartNew(() =>
            {
                if (!string.IsNullOrEmpty(newpath))
                {
                    try
                    {
                        createWebsitePath(newpath);
                        return(1);
                    }
                    catch (Exception)
                    {
                        return(0);
                    }
                }
                else
                {
                    return(-1);
                }
            });

            //复制网站到新地址
            var relcopy = createWebsite.ContinueWith(t =>
            {//F:\工作\前端页面\玖点
                try
                {
                    relcopyfirstfiles(textBox4.Text, newpath);
                    return(1);
                }
                catch (Exception)
                {
                    return(0);
                }
            });
            #endregion

            #region 生成数据库
            var createDatabase = new Task <int>(() =>
            {
                try
                {
                    Directory.CreateDirectory(root);
                    try
                    {
                        CreateDataBase.CreateDataBaseDB(dataname, root);
                        execfile(dataname, textBox5.Text);
                        return(1);
                    }
                    catch (Exception ex)
                    {
                        string s = ex.Message;
                        return(0);
                    }
                }
                catch { return(0); }
            });
            #endregion
            #region 创建动态页面
            var createHtmlContent = new Task <int>(() =>
            {
                try
                {
                    if (chb_checkpagec.Checked)
                    {
                        //初始化静态网页参数
                        ContentFormHtml(textBox3.Text + @"\index.html");
                        return(1);
                    }
                    else
                    {
                        return(0);
                    }
                }
                catch { return(0); }
            });
            //生成动态页面
            var createNewWebsites = createHtmlContent.ContinueWith(c =>
            {
                string webpath = newpath + "\\" + "web";
                try
                {
                    foreachdiectory(webpath);
                }
                catch
                {
                    return(0);
                }
                try
                {
                    createnewwebsite(webpath, textBox3.Text);
                    updatexmldoc(webpath + @"\web.config", "server=(local);DataBase=" + dataname + ";uid=sa;pwd=123456;");

                    //修改端口号
                    ReadXMLdoc xml = new ReadXMLdoc();
                    int localhost  = Convert.ToInt32(xml.readtext("Localhost"));
                    localhost      = localhost + 1;
                    xml.updatexmldoc("Localhost", localhost.ToString());


                    string strFilePath = Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, newpath + @"\InvincibleCMS.sln");
                    if (File.Exists(strFilePath))
                    {
                        string strContent = File.ReadAllText(strFilePath);
                        strContent        = Regex.Replace(strContent, "18000", localhost.ToString());
                        File.WriteAllText(strFilePath, strContent);
                    }

                    return(1);
                }
                catch
                {
                    return(0);
                }
            });

            #endregion
            //进度条线程
            var progresstask = Task.Factory.StartNew(() =>
            {
                createWebsite.Wait();//等待网站创建完成
                if (createWebsite.Result == 1)
                {
                    Init(1, 16, "网站新路径创建成功", new Random().Next(50, 100));
                    Thread.Sleep(500);

                    Inits(16, 70, "正在复制文件", new Random().Next(50, 100), relcopy);

                    relcopy.Wait();//等待复制文件完成
                    if (relcopy.Result == 1)
                    {
                        createDatabase.Start();    //开始创建数据库
                        createHtmlContent.Start(); //开始生成页面

                        Inits(70, 75, "初始化静态网页参数中", new Random().Next(50, 100), createDatabase);
                        if (createDatabase.Result == 1)
                        {
                            Init(74, 76, "数据库创建成功", new Random().Next(50, 100));
                        }
                        Init(75, 77, "复制文件成功", new Random().Next(100, 200));
                        Thread.Sleep(500);

                        Inits(76, 90, "初始化静态网页参数中", new Random().Next(50, 100), createHtmlContent);

                        createHtmlContent.Wait();//初始化静态网页参数完成
                        Init(89, 91, "初始化静态网页参数完成", new Random().Next(50, 100));
                        Thread.Sleep(500);

                        Inits(91, 100, "动态网页生成中", new Random().Next(50, 100), createNewWebsites);

                        createNewWebsites.Wait();//动态网页生成完成
                        Init(99, 101, "动态网页生成完成", new Random().Next(50, 100));
                        button1.Enabled = true;
                    }
                    else
                    {
                        MessageBox.Show("发生错误");
                    }
                }
                else
                {
                    MessageBox.Show("发生错误");
                }
            });
        }