//connect button
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                mainForm.treeView1.Nodes[0].Nodes.Clear();//clear nodes

                dataBase       = comboBox2.Text.Trim();
                authentication = comboBox3.Text.Trim();
                loginId        = comboBox4.Text.Trim();
                pwd            = textBox1.Text.Trim();

                GetDataBaseInfo();
                WriteConfiguration();

                //Get DataBase Information in background
                Task_Helper_DG.TaskRun(() =>
                {
                    GetDataBaseInfoBack();
                });

                this.Close();
                this.Dispose();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
        //Connect
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                mainForm.treeView1.Nodes[0].Nodes.Clear();//clear nodes

                serverName = textBox1.Text.Trim();
                port       = textBox2.Text.Trim();
                loginId    = textBox3.Text.Trim();
                pwd        = textBox4.Text.Trim();

                GetDataBaseInfo();

                mainForm.button7.Enabled  = false; //SqlServerStatement
                mainForm.button24.Enabled = true;  //MySqlStatement
                mainForm.button30.Enabled = false; //OracleSqlStatement

                WriteConfiguration();

                Task_Helper_DG.TaskRun(() =>
                {
                    GetDataBaseInfoBack();
                });

                WindowClose();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Example #3
0
        /// <summary>
        /// DownLoad Images
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public JsonResult DownLoadImages(Guid id, string title)
        {
            string dirInput      = Path.Combine(Server.MapPath("~/Uploads"), id.ToString());
            string outPutZipFile = Path.Combine(Server.MapPath("~/Uploads/OutPut"), title + ".zip");
            string OutPutZipDir  = Server.MapPath("~/Uploads/OutPut");

            if (!Directory.Exists(dirInput))
            {
                Directory.CreateDirectory(dirInput);
            }

            IO_Helper_DG.ZipDir(dirInput, outPutZipFile);

            Task_Helper_DG.TaskRun(() =>
            {
                foreach (var item in Directory.GetFiles(OutPutZipDir))
                {
                    if (!item.Equals(outPutZipFile))
                    {
                        System.IO.File.Delete(item);
                    }
                }
            });

            FileStream fileStream = new FileStream(outPutZipFile, FileMode.Open);
            long       fileSize   = fileStream.Length;

            byte[] fileBuffer = new byte[fileSize];
            fileStream.Read(fileBuffer, 0, (int)fileSize);
            //如果不写fileStream.Close()语句,用户在下载过程中选择取消,将不能再次下载
            fileStream.Close();

            Response.ContentType = "application/octet-stream";
            Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(title + ".zip", Encoding.UTF8));
            Response.AddHeader("Content-Length", fileSize.ToString());

            Response.BinaryWrite(fileBuffer);
            Response.End();
            Response.Close();

            return(OK("download success"));
        }