示例#1
0
 private void lboxDB_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (lboxDB.SelectedIndex > 0)
     {
         tbFile f = lboxDB.SelectedItem as tbFile;
         lbDBFile.Text = f.f_id + ":" + f.f_md5 + ":";
         CTHelper.setControl(cdFileType, (int)f.f_filetype);
         CTHelper.setControl(cdFileOpenStatus, (int)f.open_status);
         CTHelper.setControl(cdFileRef, (int)f.ref_id);
         cdFileAuthor.Text = f.f_author;
     }
 }
示例#2
0
        private void btnSliceFileAdd_Click(object sender, EventArgs e)
        {
            FormUpload dlg = new FormUpload();
            int        id  = int.Parse(clID.Text);

            dlg.ParaDatasetID = id;
            dlg.ParaTable     = "ctdb-slice";
            dlg.ParaFileType  = 12;
            if (sender is ToolStripMenuItem)
            {
                if ((sender as ToolStripMenuItem).Name == "cmitAddFileStack")
                {
                    dlg.ParaFileType = 93;
                }
            }

            dlg.ShowDialog();

            using (CTDBEntities ct = new CTDBEntities())
            {
                var q = from c in ct.tbFile where c.f_pid == id && c.f_table == dlg.ParaTable select c;
                //  clNumberSlice.Text = q.Count<tbFile>().ToString();

                //更新文件数量
                var s = ct.tbSlice.FirstOrDefault(st => st.slice_id == id);
                s.slice_para_SliceNumber = q.Count <tbFile>();
                if (s.slice_para_SliceNumber > 0)
                {
                    tbFile t = q.ToList <tbFile>()[0];
                    // clResultFileType.Text = System.IO.Path.GetExtension(t.f_path);
                    // s.slice_para_ResultFileType = clResultFileType.Text;
                }
                ct.SaveChanges();
            }

            refreshDatagridview(id.ToString());
        }
示例#3
0
        /// <summary>add a new file to database and server</summary>
        /// <param name="f">source image</param>
        /// <param name="fpath">source path</param>
        /// <param name="dsid"></param>
        /// <param name="para_table"></param>
        /// <returns></returns>
        string addFile(string f, string fpath, string para_table, int dsid)
        {
            string r = "";

            try
            {
                //upload to server
                this.Enabled = false;
                //核心上传
                if (checkUploadFile.Checked)
                {
                    r = CTHelper.UploadAPI(f, dsid.ToString(), "upload", para_table, "iozct", UserID);
                }
                this.Enabled = true;
                string md5 = CTHelper.GetMD5Hash(f);

                //insert to database
                var t = new tbFile();
                t.f_path  = fpath;                       //原名
                t.f_pid   = dsid;                        //父表记录ID
                t.f_table = para_table;                  //对应的附表参数
                string pn = Path.GetFileNameWithoutExtension(fpath);
                if (pn.Length >= 4)
                {
                    t.f_name = pn.Substring(pn.Length - 4, 4) + ".jpg"; //排序专用名
                }
                else
                {
                    t.f_name = pn + ".jpg";
                }

                t.f_md5       = md5;                                             //md5值
                t.f_author    = cdFileAuthor.Text;                               //版权人 copyright owner
                t.f_filetype  = (cdFileType.SelectedItem as tbTag).tag_id;       // file type, default according the file extension, most Image = 11
                t.open_status = (cdFileOpenStatus.SelectedItem as tbTag).tag_id; //share method, default 11 , most = 30

                t.f_fpid  = 0;                                                   //??
                t.sp_id   = int.Parse(lbSpecimenID.Text);                        //specimen id
                t.ref_id  = (cdFileRef.SelectedItem as tbRef).ref_id;            //
                t.f_count = 1;

                t.date_in = DateTime.Now;
                t.date_up = DateTime.Now;
                t.UserId  = Guid.Parse(UserID);

                CTDBEntities ct = new CTDBEntities();
                ct.tbFile.Add(t);
                ct.SaveChanges();   //将修改保存到数据库中

                return(r);
            }
            catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)
            {
                r = dbEx.ToString();
                return(r);
            }
            finally
            {
                this.Enabled = true;
            }
        }