Esempio n. 1
0
        //tbSpecimen operations
        /// <summary> set values </summary>
        /// <param name="s"></param>
        void setDBValue(tbSpecimen s)
        {
            s.species_id = (csmSpecies.SelectedItem as tbSpecies).species_id;
            s.sp_note    = CutString(csmNote.Text, 50);

            s.sp_spid                = csmSPID.Text;//实际标本号-不是必须字段
            s.specimen_age           = csmAge.Text;
            s.specimen_sex           = (csmSex.SelectedItem as tbTag).tag_id;
            s.specimen_dry_save_path = csmDriedSpecimenSavePosition.Text;
            //s.sp_description = csmDescrip.Text;

            s.sp_collector     = csmCollector.Text;
            s.sp_collect_place = csmCollectPlace.Text;
            s.sp_collect_time  = csmCollectTime.Text;
            s.sp_identifier    = csmIdentifier.Text;

            s.sp_dehydrant     = csmDehydrant.Text;
            s.sp_drycirletime  = int.Parse(csmDryCycleTime.Text);
            s.sp_dryinstrument = csmDryInstrument.Text;

            s.sp_preserve_status = csmPS.Text;

            //s.Abstract = csmSpecies.Text.Trim() + "-" + csmSPID.Text;
            s.Abstract = CutString(lbSpeciesLatin.Text, 28) + " : " + CutString(csmSPID.Text, 18);
            s.UserId   = Guid.Parse(CTHelper.GetConfig("userid"));
            s.date_in  = DateTime.Now;
        }
Esempio n. 2
0
        private void bsmAdd_Click(object sender, EventArgs e)
        {
            var s = new tbSpecimen();

            setDBValue(s);
            CTDBEntities ct = new CTDBEntities();

            ct.tbSpecimen.Add(s);
            ct.SaveChanges();   //将修改保存到数据库中
            refreshdata(dataGridView1.RowCount);
        }
Esempio n. 3
0
        //load selected information
        private void dataGridView1_SelectionChanged(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedRows.Count == 1)
            {
                int rid = dataGridView1.SelectedRows[0].Index;
                int id  = ((dataGridView1.DataSource as ArrayList)[rid] as tbSpecimen).sp_id;

                // (int)(dataGridView1.SelectedRows[0].Cells[0].Value as tbSpecimen);
                //tbSpecimen ss = dataGridView1.SelectedRows[0].Cells[0].Value as tbSpecimen;
                //Console.WriteLine(ss.sp_spid.ToString());
                CTDBEntities ct = new CTDBEntities();
                var          q  = from c in ct.tbSpecimen where c.sp_id == id select c;
                tbSpecimen   s  = q.ToList <tbSpecimen>()[0];

                csmID.Text = s.sp_id.ToString();

                csmSPID.Text = s.sp_spid;

                csmCollector.Text    = s.sp_collector;
                csmCollectPlace.Text = s.sp_collect_place;
                csmCollectTime.Text  = s.sp_collect_time;
                csmIdentifier.Text   = s.sp_identifier;

                csmDehydrant.Text     = s.sp_dehydrant;
                csmDryInstrument.Text = s.sp_dryinstrument;
                csmDryCycleTime.Text  = s.sp_drycirletime.ToString();

                CTHelper.setControl(csmSpecies, (int)s.species_id);
                CTHelper.setControl(csmSex, (int)s.specimen_sex);
                csmAge.Text = s.specimen_age;
                csmDriedSpecimenSavePosition.Text = s.specimen_dry_save_path;

                csmPS.Text   = s.sp_preserve_status;
                csmNote.Text = s.sp_note;
                //lbFilecount.Text = ct.tbFile.Where<tbFile>(c => c.f_pid == s.sp_id && c.f_table == "ctdb-specimen").Count<tbFile>().ToString();

                ucFileInfo1.ParaDatasetID = s.sp_id;
                mitDelete.Enabled         = dataGridView1.Rows.Count > 0;

                lbSPcount.Text = ct.tbScan.Where(c => c.sp_id == id).Count <tbScan>().ToString();
            }
        }
Esempio n. 4
0
        static public string ExportPIDXML(int id)
        {
            string r = "";

            try
            {
                //https://blog.csdn.net/xjj51296646/article/details/4241548
                XmlDocument xmldoc = new XmlDocument();
                //加入XML的声明段落,<?xml version="1.0" encoding="gb2312"?>
                XmlDeclaration xmldecl = xmldoc.CreateXmlDeclaration("1.0", "UTF-8", null);
                xmldoc.AppendChild(xmldecl);
                //加入一个根元素
                XmlElement xmlroot = xmldoc.CreateElement("", "pid", "");
                xmlroot.SetAttribute("type", "DATASET");
                xmldoc.AppendChild(xmlroot);

                XmlElement xmlroot2 = xmldoc.CreateElement("", "metadatas", "");
                xmlroot.AppendChild(xmlroot2);

                XmlElement xmlmeta = xmldoc.CreateElement("", "metadata", "");
                xmlmeta.SetAttribute("type", "Metadata");
                xmlroot2.AppendChild(xmlmeta);

                List <Tuple <string, string> > ht = new List <Tuple <string, string> >();
                CTDBEntities ct      = new CTDBEntities();
                tbSlice      slice   = ct.tbSlice.FirstOrDefault(s => s.slice_id == id);
                tbScan       scan    = ct.tbScan.FirstOrDefault(s => s.scan_id == slice.scan_id);
                string       part    = scan.scan_specimen_Body;
                tbSpecimen   sp      = ct.tbSpecimen.FirstOrDefault(s => s.sp_id == slice.sp_id);
                tbSpecies    species = ct.tbSpecies.FirstOrDefault(s => s.species_id == sp.species_id);
                string       spname  = species.species_latin;


                string pid = "21.86116.3/CT.slice." + slice.slice_id.ToString();
                xmlmeta.AppendChild(addnode(xmldoc, "pid", pid));
                string url = "http://ct.especies.cn/slice/info/" + slice.slice_id.ToString();
                xmlmeta.AppendChild(addnode(xmldoc, "url", url));

                string funding = "the Strategic Priority Research Program of the Chinese Academy of Sciences(Grant No. XDA19050203)";
                xmlmeta.AppendChild(addnode(xmldoc, "funding", funding));
                xmlmeta.AppendChild(addnode(xmldoc, "copyright", "CC BY 4.0"));

                string title_zh = spname + " " + part + " 显微CT扫描和标注数据";
                xmlmeta.AppendChild(addnode(xmldoc, "title_zh", title_zh));
                string title_en = "Micro-CT Slice and Label Data of " + spname + " " + part;
                xmlmeta.AppendChild(addnode(xmldoc, "title_en", title_en));

                string description_zh = title_zh;
                xmlmeta.AppendChild(addnode(xmldoc, "description_zh", description_zh));
                string description_en = title_en;
                xmlmeta.AppendChild(addnode(xmldoc, "description_en", description_en));

                string keyword_zh = spname + ";显微CT;结构标注";
                xmlmeta.AppendChild(addnode(xmldoc, "keyword_zh", keyword_zh));
                string keyword_en = spname + ";Micro CT;structural label";
                xmlmeta.AppendChild(addnode(xmldoc, "keyword_en", keyword_en));

                xmlmeta.AppendChild(addnode(xmldoc, "resource_type", "采集数据"));
                xmlmeta.AppendChild(addnode(xmldoc, "publisher_zh", "动物科学数据中心"));
                xmlmeta.AppendChild(addnode(xmldoc, "publisher_en", "Scientific Data Center of Zoology"));

                string f = Application.StartupPath + "\\meta.xml";
                if (File.Exists(f))
                {
                    File.Delete(f);
                }
                xmldoc.Save(f);
                System.Diagnostics.Process.Start(f);
            }
            catch (Exception ee)
            {
                MessageBox.Show("记录有问题,导出失败\r\n" + ee.ToString());
            }
            return(r);
        }
Esempio n. 5
0
        /// <summary>导出元数据方法</summary>
        /// <param name="id">slice表的 slice_id </param>
        static public void ExportMeta(int id)
        {
            try
            {
                List <Tuple <string, string> > ht = new List <Tuple <string, string> >();
                CTDBEntities ct = new CTDBEntities();

                tbSlice slice = ct.tbSlice.FirstOrDefault(s => s.slice_id == id);
                ht.Add(new Tuple <string, string>("URL", "http://ct.especies.cn/slice/info/" + slice.slice_id.ToString()));
                ht.Add(new Tuple <string, string>("Slice ID", slice.slice_id.ToString()));
                ht.Add(new Tuple <string, string>("Slice Number", slice.slice_para_SliceNumber.ToString()));
                ht.Add(new Tuple <string, string>("Slice File Type", slice.slice_para_ResultFileType.ToString()));
                ht.Add(new Tuple <string, string>("Slice Resolution", slice.slice_para_PixelSize.ToString()));


                tbScan scan = ct.tbScan.FirstOrDefault(s => s.scan_id == slice.scan_id);
                //ht.Add(new Tuple<string, string>("Scan ID", scan.scan_id.ToString()));
                ht.Add(new Tuple <string, string>("Scan Voltage", scan.scan_para_SourceVoltage.ToString()));
                ht.Add(new Tuple <string, string>("Scan Power", scan.scan_para_SourcePower.ToString()));
                ht.Add(new Tuple <string, string>("Scan Binning", scan.scan_para_CameraBinning.ToString()));
                ht.Add(new Tuple <string, string>("Scan Lens", scan.scan_para_LensMultiple.ToString()));
                ht.Add(new Tuple <string, string>("Scan Exposure", scan.scan_para_Exposure.ToString()));
                ht.Add(new Tuple <string, string>("Scan Time", scan.scan_date));
                ht.Add(new Tuple <string, string>("Scan Operator", scan.scan_operator));
                ht.Add(new Tuple <string, string>("Scan Part", scan.scan_specimen_Body));

                //tbTag ttag = ct.tbTag.FirstOrDefault(s => s.tag_id == scan.scan_tag_SpecimenAlive);
                //ht.Add(new Tuple<string, string>("Specimen Status", ttag.tag_tag));
                ht.Add(new Tuple <string, string>("Specimen Status", FormTag.GetTagTag(scan.scan_tag_SpecimenAlive)));

                tbEquipment equip = ct.tbEquipment.FirstOrDefault(s => s.e_id == scan.e_id);
                ht.Add(new Tuple <string, string>("Equipment", equip.e_name));

                tbSpecimen sp = ct.tbSpecimen.FirstOrDefault(s => s.sp_id == slice.sp_id);
                ht.Add(new Tuple <string, string>("Specimen ID", sp.sp_spid));
                ht.Add(new Tuple <string, string>("Specimen Collector", sp.sp_collector));
                ht.Add(new Tuple <string, string>("Specimen Time", sp.sp_collect_time));
                ht.Add(new Tuple <string, string>("Specimen Place", sp.sp_collect_place));
                ht.Add(new Tuple <string, string>("Specimen Identifier", sp.sp_identifier));

                ht.Add(new Tuple <string, string>("Preprocess", sp.sp_dehydrant));


                tbSpecies species = ct.tbSpecies.FirstOrDefault(s => s.species_id == sp.species_id);
                ht.Add(new Tuple <string, string>("Specie Name", species.species_latin));
                ht.Add(new Tuple <string, string>("Specie Genus", species.species_Genus));
                ht.Add(new Tuple <string, string>("Specie Family", species.species_Family));


                string f = Application.StartupPath + "\\meta.txt";
                if (File.Exists(f))
                {
                    File.Delete(f);
                }
                //foreach (System.Collections.DictionaryEntry item in ht)
                foreach (Tuple <string, string> item in ht)
                {
                    string s = item.Item1 + "\t:\t" + item.Item2;
                    CTHelper.AddLog(s, f);
                }

                System.Diagnostics.Process.Start(f);
            }
            catch (Exception ee)
            {
                MessageBox.Show("记录有问题,导出失败\r\n" + ee.ToString());
            }
        }
Esempio n. 6
0
        private void FormUpload_Load(object sender, EventArgs e)
        {
            lbDataset.Text = ParaDatasetID.ToString();
            UserID         = CTHelper.GetConfig("userid");

            CTDBEntities ct = new CTDBEntities();

            if (ParaTable == "ctdb-slice")
            {
                this.Text        = "CTDB - Slice File";
                lbTableName.Text = "SliceID";
                tbSlice s = ct.tbSlice.Where(c => c.slice_id == ParaDatasetID).Single();
                lbDSName.Text               = s.Abstract;
                lbSpecimenID.Text           = s.tbScan.tbSpecimen.sp_id.ToString();
                mitCreatedFromSlice.Visible = true;
                cdFileRef.Visible           = false;
            }
            else if (ParaTable == "ctdb-scan")
            {
                this.Text        = "CTDB - Scan Source File";
                lbTableName.Text = "ScanID";
                tbScan s = ct.tbScan.Where(c => c.scan_id == ParaDatasetID).Single();
                lbDSName.Text     = s.Abstract;
                lbSpecimenID.Text = s.tbSpecimen.sp_id.ToString();
                cdFileRef.Visible = false;
            }
            else if (ParaTable == "ctdb-label")
            {
                this.Text        = "CTDB - Tissue Label File";
                lbTableName.Text = "LabelID";
                tbLabel s = ct.tbLabel.Where(c => c.label_id == ParaDatasetID).Single();
                lbDSName.Text               = s.label_id.ToString();
                lbSpecimenID.Text           = s.tbSlice.tbScan.tbSpecimen.sp_id.ToString();
                mitCreatedFromLabel.Visible = true;
                cdFileRef.Visible           = false;
            }
            else if (ParaTable == "ctdb-specimen")
            {
                this.Text        = "CTDB - Specimen's Demo File";
                lbTableName.Text = "SpecimenID";
                tbSpecimen s = ct.tbSpecimen.Where(c => c.sp_id == ParaDatasetID).Single();
                lbSpecimenID.Text = s.sp_id.ToString();
                lbDSName.Text     = s.Abstract;
                // cdFileRef.Enabled = true;
            }
            else if (ParaTable == "ctdb-scanpara")
            {
                this.Text        = "CTDB - scan parameter's picture file";
                lbTableName.Text = "";
                tbScan s = ct.tbScan.Where(c => c.scan_id == ParaDatasetID).Single();
                lbDSName.Text     = s.Abstract;
                lbSpecimenID.Text = s.tbSpecimen.sp_id.ToString();
                cdFileRef.Visible = false;
            }
            else
            {
                this.Close();
            }


            CTHelper.setControlTag(cdFileType, 14, ParaFileType); // 14 filetype, 指定的Image
            CTHelper.setControlTag(cdFileOpenStatus, 31, 30);     //31 share method, 30 share in group
            CTHelper.LoadControl(cdFileRef, "tbRef", 4);          // 14 filetype, 11 image
            cdFileAuthor.Text = CTHelper.GetConfig("username");

            refreshdb();
        }
Esempio n. 7
0
        //add
        private void btnAdd_Click(object sender, EventArgs e)
        {
            CTDBEntities ct = new CTDBEntities();

            //create species
            var s1 = new tbSpecies();

            s1.species_note  = cspeciesNote.Text;
            s1.species_Order = cspeciesOrder.Text;

            s1.date_in = DateTime.Now;
            s1.UserId  = Guid.Parse(CTHelper.GetConfig("userid"));
            ct.tbSpecies.Add(s1);
            ct.SaveChanges();   //将修改保存到数据库中

            //create specimen
            var s2 = new tbSpecimen();

            s2.species_id = s1.species_id;

            s2.sp_spid                = csmSPID.Text; //实际标本号-不是必须字段
            s2.specimen_sex           = (csmSex.SelectedItem as tbTag).tag_id;
            s2.specimen_age           = csmAge.Text;
            s2.sp_note                = csmNote.Text;
            s2.specimen_dry_save_path = csmSavePosition.Text;

            s2.sp_collector     = csmCollector.Text;
            s2.sp_collect_place = csmCollectPlace.Text;
            s2.sp_collect_time  = csmCollectTime.Text;

            s2.sp_dehydrant    = csmDehydrant.Text;
            s2.sp_drycirletime = int.Parse(GetStringNumber(csmDryCycleTime.Text));
            //s2.sp_dryinstrument = "-";

            s2.Abstract           = s1.species_note + "-" + s2.sp_id;
            s2.date_in            = DateTime.Now;
            s2.UserId             = Guid.Parse(CTHelper.GetConfig("userid"));
            s2.sp_preserve_status = "-";
            ct.tbSpecimen.Add(s2);
            ct.SaveChanges();   //将修改保存到数据库中

            //create scan record
            var s3 = new tbScan();

            s3.sp_id = s2.sp_id;
            s3.e_id  = (int)cscanEquipment.SelectedValue;

            s3.scan_specimen_Body    = cscanTagSpecimenParty.Text;
            s3.scan_source_save_path = cscanPath.Text;
            //s3.scan_timebegin = DateTime.Parse(cscanTimeBegin.Text);
            s3.scan_date = cscanTimeBegin.Text;

            s3.scan_para_CameraBinning = cscanCameraBinning.Text;
            s3.scan_para_SourceVoltage = double.Parse(GetStringNumber(cscanSourceVoltage.Text));
            s3.scan_para_SourceCurrent = double.Parse(GetStringNumber(cscanSourceCurrent.Text));
            s3.scan_para_Exposure      = double.Parse(GetStringNumber(cscanExposure.Text));

            s3.Abstract = s2.Abstract + "-" + s3.scan_specimen_Body;
            s3.date_in  = DateTime.Now;
            s3.UserId   = Guid.Parse(CTHelper.GetConfig("userid"));
            ct.tbScan.Add(s3);
            ct.SaveChanges();   //将修改保存到数据库中

            //create slice record
            var s4 = new tbSlice();

            s4.scan_id         = s3.scan_id;
            s4.slice_save_path = csliceSavePath.Text;

            s4.date_in  = DateTime.Now;
            s4.UserId   = Guid.Parse(CTHelper.GetConfig("userid"));
            s4.Abstract = s3.Abstract;
            ct.tbSlice.Add(s4);
            ct.SaveChanges();   //将修改保存到数据库中

            refreshdata(null, null);
        }