예제 #1
0
        protected void ButtonRegister_Click(object sender, EventArgs e)
        {
            //验证信息输入

            //写入数据库Client表

            Client cToAdd = new Client();
            cToAdd.UserName = TextBoxUserName.Text;
            cToAdd.Pwd = TextBoxPWD.Text;
            cToAdd.Email = TextBoxEMail.Text;
            cToAdd.RegisterTime = DateTime.Now;

            string connstr = ConfigurationManager.ConnectionStrings["connStr"].ConnectionString;
            conn = new MySqlConnection(connstr);
            mg = new MonoGrid(conn);
            mg.Client.InsertOnSubmit(cToAdd);
            mg.SubmitChanges();
        }
예제 #2
0
        protected void btnUpload_Click(object sender, EventArgs e)
        {
            HttpFileCollection files = HttpContext.Current.Request.Files;
            Task tToUpload = new Task ();
            tToUpload.IDTask = DateTime.Now.ToString ("yyyyMMddHHmmss");
            string folder = Server.MapPath (@"~/Files/Upload/" + tToUpload.IDTask);
            if (!Directory.Exists (folder))
                Directory.CreateDirectory (folder);

            for (int i = 0; i < files.Count; i++) {
                if (i < files.Count && i < 10) {
                    if (files[i].FileName != "" || files[i] != null) {
                        HttpPostedFile myFile = files[i];
                        string FileName = myFile.FileName.ToString ().Trim ();
                        this.lblAttachmentError.Text = "<" + FileName + ">";
                        // Show file name
                        // Empty value in Browse Box
                        if (myFile.FileName.Trim () == "") {
                            this.lblAttachmentError.Text = "No file selected.";
                            return;
                        }

                        if (myFile.ContentLength != 0) {
                            this.lblAttachment.Text += "<BR>" + FileName;
                            this.lblAttachmentError.Text = "";
                            string temp=null;
                            if (FileName.EndsWith("mol2")) {

                             temp=this.Request.PhysicalApplicationPath.ToString ().Trim () + @"Files/Upload/" + tToUpload.IDTask + @"/" + tToUpload.IDTask + ".mol2";
                            }
                            else
                             temp=this.Request.PhysicalApplicationPath.ToString ().Trim () + @"Files/Upload/" + tToUpload.IDTask + @"/" + FileName;
                            myFile.SaveAs (temp);
                        }
                        else
                        {
                            this.lblAttachmentError.Text = "File not found.";
                            return;
                        }
                    }
                } else
                    this.lblAttachmentError.Text = "Uploaded File exceed limits.";

            }

            //Mol文件内节点个数
            string molPath = folder + @"/" + tToUpload.IDTask + ".mol2";
            string[] molStrings = System.IO.File.ReadAllLines (molPath);
            int molCount = (from str in molStrings
                where str == "@<TRIPOS>MOLECULE"
                select str).Count ();

            tToUpload.MolCount=molCount;
            tToUpload.UserID=1;
            tToUpload.Status=0;
            tToUpload.UploadTime=DateTime.Now;
            tToUpload.Intro="无";

            string connstr = ConfigurationManager.ConnectionStrings["connStr"].ConnectionString;
            MySqlConnection conn = new MySqlConnection (connstr);
            MonoGrid mg = new MonoGrid (conn);
            mg.Task.InsertOnSubmit (tToUpload);
            mg.SubmitChanges ();
            //检测其他文件的完整性合法性
            //写入数据库

            FileHelper.Grand(Server.MapPath("~/Files/Upload"),tToUpload.IDTask);
        }