Beispiel #1
0
        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 tbSpecies).species_id;

                CTDBEntities ct = new CTDBEntities();
                var          q  = from c in ct.tbSpecies
                                  where c.species_id == id
                                  select c;
                List <tbSpecies> sl = q.ToList <tbSpecies>();
                tbSpecies        s  = sl[0];
                {
                    cspeciesID.Text      = s.species_id.ToString();
                    cspeciesNote.Text    = s.species_note;
                    cspeciesLatin.Text   = s.species_latin;
                    cspeciesCHN.Text     = s.species_CHN;
                    cspeciesOrder.Text   = s.species_Order;
                    cspeciesFamily.Text  = s.species_Family;
                    cspeciesGenus.Text   = s.species_Genus;
                    cspeciesSpecies.Text = s.species_Species;
                }

                string str = "";
                //str += ct.tbSpecimen.Where(c => c.species_id == s.species_id).Count<tbSpecimen>() ;
                lbSPcount.Text = ct.tbSpecimen.Where(c => c.species_id == s.species_id).Count <tbSpecimen>().ToString();
            }
        }
Beispiel #2
0
        private void csmSpecies_SelectedIndexChanged(object sender, EventArgs e)
        {
            tbSpecies ts = (csmSpecies.SelectedItem as tbSpecies);

            lbSpeciesCHN.Text   = ts.species_CHN;
            lbSpeciesLatin.Text = ts.species_latin;
            csmNote.Text        = csmSpecies.Text.Trim();
        }
Beispiel #3
0
        //operations
        /// <summary> set values </summary>
        /// <param name="s"></param>
        void setDBValue(tbSpecies s)
        {
            s.species_note  = cspeciesNote.Text.Trim();
            s.species_CHN   = cspeciesCHN.Text.Trim();
            s.species_latin = cspeciesLatin.Text.Trim();

            s.species_Order   = cspeciesOrder.Text.Trim();
            s.species_Family  = cspeciesFamily.Text.Trim();
            s.species_Genus   = cspeciesGenus.Text.Trim();
            s.species_Species = cspeciesSpecies.Text.Trim();

            s.species_LSID = "-";
            s.date_in      = DateTime.Now;
            s.UserId       = Guid.Parse(CTHelper.GetConfig("userid"));
        }
Beispiel #4
0
        private void bSpeciesAdd_Click(object sender, EventArgs e)
        {
            tbSpecies s = new tbSpecies();

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

            ct.tbSpecies.Add(s);
            ct.SaveChanges();   //将修改保存到数据库中
            if ((dataGridView1.DataSource as List <tbSpecies>) != null)
            {
                refreshdata(null, null, (dataGridView1.DataSource as List <tbSpecies>).Count);
            }
            else
            {
                refreshdata(null, null);
            }
        }
Beispiel #5
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);
        }
Beispiel #6
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());
            }
        }
Beispiel #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);
        }