Пример #1
0
        /// <summary>
        /// 确定未下发样本,flag为true代表需要显示出来,为false代表不需要显示
        /// </summary>
        private void GetNoIssueData(bool flag)
        {
            AccessManagerDS.mutex.WaitOne();
            if (conn.State == ConnectionState.Closed)
            {
                conn.Open();
            }
            num = 0;
            ds  = new DataSet();
            List <UpOrDownload_Show> sampleList = new List <UpOrDownload_Show>();//未下发样本存储列表,并将其排序

            if (flag)
            {
                DownloadList.Clear();
            }
            else
            {
                BackStageList.Clear();
            }
            string           strSelect = "select * from lisinput where [IsSend]= false";
            HashSet <string> hsID      = new HashSet <string>();//哈希表用来保存各个样本号(非重复)
            Hashtable        htID      = new Hashtable();

            taskType.Clear();
            using (OleDbDataAdapter oa = new OleDbDataAdapter(strSelect, conn))
            {
                if (oa.Fill(ds, "Down") == 0)
                {
                    //已经全部下发
                    ds.Clear();
                    conn.Close();
                    AccessManagerDS.mutex.ReleaseMutex();
                    return;
                }
                else
                {
                    //还没有完全下发
                    //用哈希表来消除重复
                    foreach (DataRow dr in ds.Tables["Down"].Rows)
                    {
                        hsID.Add(dr["SAMPLE_ID"].ToString());
                    }
                }
                ds.Clear();
            }
            DataSet singleds;

            foreach (string singleID in hsID)
            {
                strSelect = "select * from listask where [SAMPLE_ID]= '" + singleID + "'";
                singleds  = new DataSet();
                using (OleDbDataAdapter singleoa = new OleDbDataAdapter(strSelect, conn))
                {
                    if (singleoa.Fill(singleds, "single") != 0)
                    {
                        string tempItem;
                        string tempAllItem;
                        foreach (DataRow dr in singleds.Tables["single"].Rows)
                        {
                            tempItem = dr["ITEM"].ToString();
                            if (!taskType.ContainsKey(tempItem))
                            {
                                taskType.Add(tempItem, dr["Type"].ToString());//将用到的测试项目和类型都加到哈希表里
                            }
                            if (!htID.Contains(singleID))
                            {
                                //如果之前不存在
                                htID.Add(singleID, tempItem);
                            }
                            else
                            {
                                tempAllItem    = htID[singleID].ToString();
                                tempAllItem   += ("," + tempItem);
                                htID[singleID] = tempAllItem;
                            }
                        }
                        singleds.Clear();
                    }
                }
            }
            DataSet tempds;

            foreach (string tempID in htID.Keys)
            {
                singleSample            = new UpOrDownload_Show();
                singleSample.Sample_ID  = tempID;
                singleSample.Item       = htID[tempID].ToString();
                singleSample.number     = ++num;
                singleSample.IsSelected = false;
                strSelect = "select * from lisinput where [IsSend]= false and [SAMPLE_ID] ='" + tempID + "'";
                using (OleDbDataAdapter tempoa = new OleDbDataAdapter(strSelect, conn))
                {
                    tempds = new DataSet();
                    if (tempoa.Fill(tempds, "temp") != 0)
                    {
                        foreach (DataRow dr in tempds.Tables["temp"].Rows)
                        {
                            singleSample.Send_Time    = dr["SEND_TIME"] == DBNull.Value ? DateTime.Now : (DateTime)dr["SEND_TIME"];
                            singleSample.Test_Time    = singleSample.Send_Time.ToString();
                            singleSample.Patient_ID   = dr["PATIENT_ID"] == DBNull.Value ? blank : (string)dr["PATIENT_ID"];
                            singleSample.Device       = dr["Device"] == DBNull.Value ? blank : (string)dr["Device"];
                            singleSample.Kind         = dr["SAMPLE_KIND"] == DBNull.Value ? blank : (string)dr["SAMPLE_KIND"];
                            singleSample.Patient_Age  = dr["AGE"] == DBNull.Value ? 0 : Convert.ToInt32((string)dr["AGE"]);
                            singleSample.Patient_Name = dr["FIRST_NAME"] == DBNull.Value ? blank : (string)dr["FIRST_NAME"];
                            singleSample.Patient_Sex  = dr["SEX"] == DBNull.Value ? blank : (string)dr["SEX"];
                            singleSample.Emergency    = (bool)dr["EMERGENCY"];
                            break;
                        }
                    }
                    tempds.Clear();
                }
                sampleList.Add(singleSample);
            }
            if (sampleList.Count > 0)
            {
                //进行排序
                sampleList.Sort(delegate(UpOrDownload_Show x, UpOrDownload_Show y)
                {
                    return(y.Test_Time.CompareTo(x.Test_Time));
                });
                if (flag)
                {
                    //需要显示出来
                    foreach (UpOrDownload_Show temp in sampleList)
                    {
                        DownloadList.Add(temp);
                    }
                    Statusbar.SBar.NoIssueNum = DownloadList.Count;
                }
                else
                {
                    //不需要显示出来
                    foreach (UpOrDownload_Show temp in sampleList)
                    {
                        BackStageList.Add(temp);
                    }
                    Statusbar.SBar.NoIssueNum = BackStageList.Count;
                }
            }

            conn.Close();
            AccessManagerDS.mutex.ReleaseMutex();
        }
Пример #2
0
        /// <summary>
        /// 获取没有上传的样本数据
        /// </summary>
        private void GetNoSendData()
        {
            AccessManagerDS.mutex.WaitOne();
            if (conn.State == ConnectionState.Closed)
            {
                conn.Open();
            }
            num = 0;
            ds  = new DataSet();
            UploadList.Clear();
            List <UpOrDownload_Show> sampleList = new List <UpOrDownload_Show>();//未上传样本存储列表,并将其排序
            string strSelect = "select * from lisoutput where [ISSEND]= 0";

            using (OleDbDataAdapter oa = new OleDbDataAdapter(strSelect, conn))
            {
                if (oa.Fill(ds, "Up") == 0)
                {
                    //已经全部上传了
                    ds.Clear();
                    conn.Close();
                    AccessManagerDS.mutex.ReleaseMutex();
                    return;
                }
                else
                {
                    //有一些样本没有上传
                    //先往哈希表里写入样本号
                    Hashtable htID = new Hashtable();//选用哈希表来消除重复
                    string    tempItem;
                    string    tempID;
                    string    tempAllItem;
                    foreach (DataRow dr in ds.Tables["Up"].Rows)
                    {
                        tempID   = dr["SAMPLE_ID"].ToString() + "&" + dr["SEND_TIME"].ToString();
                        tempItem = dr["ITEM"].ToString();
                        if (!htID.ContainsKey(tempID))
                        {
                            //第一次进入这个样本号
                            htID.Add(tempID, tempItem);//首先给项目赋值
                        }
                        else
                        {
                            tempAllItem  = htID[tempID].ToString();
                            tempAllItem += ("," + tempItem);
                            htID[tempID] = tempAllItem;
                        }
                    }
                    DataSet tempDs;
                    foreach (var tempSampleID in htID.Keys)
                    {
                        singleSample            = new UpOrDownload_Show();
                        singleSample.number     = ++num;
                        singleSample.IsSelected = false;
                        string[] s = tempSampleID.ToString().Split('&');
                        singleSample.Sample_ID = s[0];
                        singleSample.Item      = (string)htID[tempSampleID];
                        singleSample.Test_Time = s[1];
                        strSelect = "select * from lisoutput where [ISSEND]= 0 and [SAMPLE_ID]='" + singleSample.Sample_ID + "' and [SEND_TIME]=#" + singleSample.Test_Time + "#";
                        using (OleDbDataAdapter tempOa = new OleDbDataAdapter(strSelect, conn))
                        {
                            tempDs = new DataSet();
                            if (tempOa.Fill(tempDs, "temp") != 0)
                            {
                                foreach (DataRow dr in tempDs.Tables["temp"].Rows)
                                {
                                    //singleSample.Test_Time = dr["SEND_TIME"] == DBNull.Value ? DateTime.Now.ToString() : dr["SEND_TIME"].ToString();
                                    singleSample.Patient_ID = dr["PATIENT_ID"] == DBNull.Value ? blank : (string)dr["PATIENT_ID"];
                                    singleSample.Device     = dr["Device"] == DBNull.Value ? blank : (string)dr["Device"];
                                    singleSample.Kind       = dr["Type"] == DBNull.Value ? blank : (string)dr["Type"];
                                    break;
                                }
                            }
                            tempDs.Clear();
                        }
                        //UploadList.Add(singleSample);
                        sampleList.Add(singleSample);
                    }
                }
                ds.Clear();
            }
            if (sampleList.Count > 0)
            {
                //排序操作
                sampleList.Sort(delegate(UpOrDownload_Show x, UpOrDownload_Show y)
                {
                    return(y.Test_Time.CompareTo(x.Test_Time));
                });
                foreach (UpOrDownload_Show temp in sampleList)
                {
                    UploadList.Add(temp);
                }
                Statusbar.SBar.NoSendNum = UploadList.Count();
            }
            AccessManagerDS.mutex.ReleaseMutex();
            conn.Close();
        }