예제 #1
0
        private void lbUpdate_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            string fupdate = Application.StartupPath + "\\Updater.exe";

            if (File.Exists(fupdate))
            {
                File.Delete(fupdate);
            }
            //update updater.exe
            if (!File.Exists(fupdate))
            {
                CTHelper.DownloadFile(CTHelper.GetConfig("updateUrl") + "/Updater.exe", fupdate);
            }
            if (!File.Exists(fupdate))
            {
                CTHelper.DownloadFile(CTHelper.GetConfig("downloadurl") + "/Updater.exe", fupdate);
            }
            if (!File.Exists(fupdate))
            {
                MessageBox.Show("Fail!");
                return;
            }
            //begin to update
            ProcessStartInfo startInfo = new ProcessStartInfo();

            startInfo.FileName  = fupdate;
            startInfo.Arguments = CTHelper.GetConfig("updateUrl") + " " + Application.ExecutablePath;
            System.Diagnostics.Process.Start(startInfo);
            Application.Exit();
        }
예제 #2
0
파일: FormUpload.cs 프로젝트: wjn99wjn/CTDB
        /// <summary>upload specimen file / example /demo </summary>
        /// <param name="specimenid"></param>
        /// <param name="lll"></param>
        /// <param name="filetablep"></param>
        /// <param name="choose_number"></param>
        void uploadSpecimenFile(int specimenid, List <tbFile> lll, string filetablep, int choose_number)
        {
            //从slice表中随机找出10张图
            List <string> fl = new List <string>();

            int[] fr = CTHelper.RandomIntArray(choose_number, 0, lll.Count - 1);
            for (int i = 0; i < fr.Length; i++)
            {
                string url = CTHelper.GetConfig("downloadurl") + "ct/" + filetablep + "/" + lll[fr[i]].f_pid + "/";
                string fn  = Path.GetFileName(lll[fr[i]].f_path.Trim());
                fl.Add(url + fn);
            }

            Application.DoEvents();
            string ftmpd = CTHelper.CommonPath("app") + "\\" + "d.jpg";
            string ftmp  = "";

            //对每张图进行上传操作  同 Add功能
            note(fl.Count);
            for (int i = 0; i < fr.Length; i++)
            {
                notep();
                if (File.Exists(ftmpd))
                {
                    File.Delete(ftmpd);
                }
                CTHelper.DownloadFile(fl[i], ftmpd); //download source image
                string fn = CTHelper.GetMD5Hash(ftmpd) + ".jpg";
                if (File.Exists(ftmpd))
                {
                    Bitmap b = CTHelper.CreateDemoImage(ftmpd, 150, 150);
                    ftmp = CTHelper.CommonPath("app") + "\\" + fn;
                    b.Save(ftmp, System.Drawing.Imaging.ImageFormat.Jpeg);

                    if (File.Exists(ftmp))
                    {
                        cdFileAuthor.Text = "selected from " + filetablep;
                        string r = addFile(ftmp, ftmp, "ctdb-specimen", specimenid);
                        if (r != "")
                        {
                            MessageBox.Show(r);
                        }
                    }
                }
                if (File.Exists(ftmpd))
                {
                    File.Delete(ftmpd);
                }
                if (File.Exists(ftmp))
                {
                    File.Delete(ftmp);
                }
            }
        }