コード例 #1
0
        public string QueryPCRTestResult(Guid itemId)
        {
            try
            {
                using (WanTaiEntities entities = new WanTaiEntities())
                {
                    var result = entities.PCRTestResults.Where(c => c.ItemID == itemId);
                    if (result != null && result.Count() > 0)
                    {
                        PCRTestResult testResult = result.FirstOrDefault();
                        return(testResult.PCRContent);
                    }
                }
            }
            catch (Exception e)
            {
                string errorMessage = e.Message + System.Environment.NewLine + e.StackTrace;
                LogInfoController.AddLogInfo(LogInfoLevelEnum.Error, errorMessage, SessionInfo.LoginName, this.GetType().ToString() + "->QueryPCRTestResult", SessionInfo.ExperimentID);
            }

            return(null);
        }
コード例 #2
0
        private bool processStratageneFile(string fileName, Guid rotationId, Plate plate, out bool isRightPositionNumber)
        {
            isRightPositionNumber = true;
            OleDbConnectionStringBuilder connectionStringBuilder = new OleDbConnectionStringBuilder();

            connectionStringBuilder.Provider   = "Microsoft.Jet.OLEDB.4.0";
            connectionStringBuilder.DataSource = fileName;
            connectionStringBuilder.Add("Mode", "Read");
            connectionStringBuilder.Add("Extended Properties", "Excel 8.0;IMEX=1;TypeGuessRows=0;ImportMixedTypes=Text");
            bool isRightFormat = false;
            bool hasWellColumn = false;
            bool hasDyeColumn  = false;
            bool hasCtColumn   = false;

            using (OleDbConnection con = new OleDbConnection(connectionStringBuilder.ToString()))
            {
                con.Open();
                DataTable dtSchema = con.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new object[] { null, null, null, "TABLE" });
                string    Sheet1   = dtSchema.Rows[0].Field <string>("TABLE_NAME");

                DataTable sheetColumns = con.GetOleDbSchemaTable(OleDbSchemaGuid.Columns, new object[] { null, null, Sheet1, null });
                foreach (DataRow row in sheetColumns.Rows)
                {
                    string strColumnName = row["COLUMN_NAME"].ToString();
                    if (strColumnName == "Well")
                    {
                        hasWellColumn = true;
                    }
                    else if (strColumnName == "Dye")
                    {
                        hasDyeColumn = true;
                    }
                    if (strColumnName == "Ct (dR)")
                    {
                        hasCtColumn = true;
                    }
                }

                if (hasWellColumn && hasDyeColumn && hasCtColumn)
                {
                    isRightFormat = true;
                }

                if (!isRightFormat)
                {
                    return(isRightFormat);
                }

                OleDbDataAdapter da = new OleDbDataAdapter("select [Well],[Dye],[Ct (dR)] from [" + Sheet1 + "]", con);
                DataTable        dt = new DataTable();
                da.Fill(dt);
                Dictionary <int, DataRow> dc = controller.GetPCRPositionsByPlateID(plate.PlateID, currentExperimentId);
                System.Collections.Generic.Dictionary <string, StratagenePCRColumnData> dataList = new System.Collections.Generic.Dictionary <string, StratagenePCRColumnData>();

                foreach (DataRow row in dt.Rows)
                {
                    StratagenePCRColumnData sData = new StratagenePCRColumnData()
                    {
                        Well = row[0].ToString(), Dye = row[1].ToString(), Ct = row[2].ToString()
                    };
                    sData.XmlContent = "<Well>" + sData.Well + "</Well><Dye>" + sData.Dye + "</Dye><Ct>" + sData.Ct + "</Ct>";
                    if (!dataList.ContainsKey(sData.Well))
                    {
                        dataList.Add(sData.Well, sData);
                    }
                    else
                    {
                        StratagenePCRColumnData _sData = (StratagenePCRColumnData)dataList[sData.Well];
                        if (_sData.DataList == null)
                        {
                            _sData.DataList = new List <PCRColumnData>();
                            _sData.DataList.Add(sData);
                        }
                        else
                        {
                            _sData.DataList.Add(sData);
                        }
                    }
                }

                if (dc.Count != dataList.Count)
                {
                    isRightPositionNumber = false;
                    if (!isRightPositionNumber)
                    {
                        MessageBoxResult selectResult = MessageBox.Show("PCR仪检测结果和混样数不一致,请检查操作是否正确?“是”将按现有规则导入", "系统提示", MessageBoxButton.YesNo);
                        if (selectResult == MessageBoxResult.No)
                        {
                            return(isRightFormat);
                        }
                        else
                        {
                            isRightPositionNumber = true;
                        }
                    }
                }

                foreach (StratagenePCRColumnData sData in dataList.Values)
                {
                    PCRTestResult info = new PCRTestResult();
                    info.ItemID     = WanTaiObjectService.NewSequentialGuid();
                    info.RotationID = rotationId;
                    info.Position   = controller.ChangeCharacterToPositionNumber(sData.Well);
                    info.CreateTime = DateTime.Now;

                    //calculate
                    if (dc.ContainsKey(info.Position))
                    {
                        DataRow  dcrow    = dc[info.Position];
                        bool     isSingle = (int)dcrow["TubeNumber"] == 1 ? true : false;
                        Tubetype tubeType = (Tubetype)((short)dcrow["TubeType"]);
                        info.Result = checkPCRResult(sData, dcrow["TestName"].ToString(), isSingle, tubeType);
                    }

                    info.ExperimentID = currentExperimentId;
                    if (plate.BarCode != null)
                    {
                        info.BarCode = plate.BarCode;
                    }

                    info.PlateID = plate.PlateID;
                    string xmlContent = sData.XmlContent;
                    if (sData.DataList != null && sData.DataList.Count > 0)
                    {
                        foreach (StratagenePCRColumnData data in sData.DataList)
                        {
                            xmlContent = xmlContent + data.XmlContent;
                        }
                    }
                    info.PCRContent = "<PCRContent>" + xmlContent + "</PCRContent>";
                    pcrResultList.Add(info);
                }
            }

            return(isRightFormat);
        }
コード例 #3
0
        private bool processBIORADFile(string fileName, Guid rotationId, Plate plate, out bool isRightPositionNumber)
        {
            isRightPositionNumber = true;
            string formatTitle   = "Well,Fluor,Target,Content,Sample,Cq,Starting Quantity (SQ)";
            bool   isRightFormat = false;

            System.Collections.Generic.Dictionary <string, BIORADPCRColumnData> dataList = new System.Collections.Generic.Dictionary <string, BIORADPCRColumnData>();

            using (FileStream stream = File.Open(fileName, FileMode.Open, FileAccess.Read))
            {
                using (StreamReader reader = new StreamReader(stream))
                {
                    while (!reader.EndOfStream)
                    {
                        string content = reader.ReadLine();
                        if (isRightFormat)
                        {
                            string[] values = content.Split(',');
                            if (values.Count() < 6)
                            {
                                break;
                            }
                            BIORADPCRColumnData bioData = new BIORADPCRColumnData();
                            bioData.Well       = values[0];
                            bioData.Fluor      = values[1];
                            bioData.Cq         = values[5];
                            bioData.XmlContent = "<Well>" + values[0] + "</Well><Fluor>" + values[1] + "</Fluor><Cq>" + values[5] + "</Cq>";

                            if (!dataList.ContainsKey(bioData.Well))
                            {
                                dataList.Add(bioData.Well, bioData);
                            }
                            else
                            {
                                BIORADPCRColumnData _bioData = (BIORADPCRColumnData)dataList[bioData.Well];
                                if (_bioData.DataList == null)
                                {
                                    _bioData.DataList = new List <PCRColumnData>();
                                    _bioData.DataList.Add(bioData);
                                }
                                else
                                {
                                    _bioData.DataList.Add(bioData);
                                }
                            }
                        }

                        if (!isRightFormat && content.StartsWith(formatTitle))
                        {
                            isRightFormat = true;
                        }
                    }
                }
            }

            if (!isRightFormat)
            {
                return(isRightFormat);
            }

            Dictionary <int, DataRow> dc = controller.GetPCRPositionsByPlateID(plate.PlateID, currentExperimentId);

            if (dc.Count != dataList.Count)
            {
                isRightPositionNumber = false;
                if (!isRightPositionNumber)
                {
                    MessageBoxResult selectResult = MessageBox.Show("PCR仪检测结果和混样数不一致,请检查操作是否正确?“是”将按现有规则导入", "系统提示", MessageBoxButton.YesNo);
                    if (selectResult == MessageBoxResult.No)
                    {
                        return(isRightFormat);
                    }
                    else
                    {
                        isRightPositionNumber = true;
                    }
                }
            }

            foreach (BIORADPCRColumnData bioData in dataList.Values)
            {
                PCRTestResult info = new PCRTestResult();
                info.ItemID     = WanTaiObjectService.NewSequentialGuid();
                info.RotationID = rotationId;
                info.Position   = controller.ChangeCharacterToPositionNumber(bioData.Well);
                info.CreateTime = DateTime.Now;
                //calculate
                if (dc.ContainsKey(info.Position))
                {
                    DataRow  row      = dc[info.Position];
                    bool     isSingle = (int)row["TubeNumber"] == 1 ? true : false;
                    Tubetype tubeType = (Tubetype)((short)row["TubeType"]);
                    info.Result = checkPCRResult(bioData, row["TestName"].ToString(), isSingle, tubeType);
                }

                info.ExperimentID = currentExperimentId;
                if (plate.BarCode != null)
                {
                    info.BarCode = plate.BarCode;
                }

                info.PlateID = plate.PlateID;
                string xmlContent = bioData.XmlContent;
                if (bioData.DataList != null && bioData.DataList.Count > 0)
                {
                    foreach (BIORADPCRColumnData data in bioData.DataList)
                    {
                        xmlContent = xmlContent + data.XmlContent;
                    }
                }
                info.PCRContent = "<PCRContent>" + xmlContent + "</PCRContent>";
                pcrResultList.Add(info);
            }

            return(isRightFormat);
        }
コード例 #4
0
        private bool processABIFile(string fileName, Guid rotationId, Plate plate, out bool isRightPositionNumber)
        {
            isRightPositionNumber = true;
            string                  formatTitle         = "Well,Sample Name,Detector,Task,Ct,StdDev Ct,Qty,Mean Qty,StdDev Qty,Filtered,Tm";
            bool                    isRightFormat       = false;
            ABIPCRColumnData        previousMainAbiData = null;
            List <ABIPCRColumnData> dataList            = new List <ABIPCRColumnData>();

            using (FileStream stream = File.Open(fileName, FileMode.Open, FileAccess.Read))
            {
                using (StreamReader reader = new StreamReader(stream))
                {
                    while (!reader.EndOfStream)
                    {
                        string content = reader.ReadLine();
                        if (isRightFormat)
                        {
                            string[] values = content.Split(',');
                            if (values.Count() < 5)
                            {
                                break;
                            }
                            ABIPCRColumnData abiData = new ABIPCRColumnData();
                            abiData.Well       = values[0];
                            abiData.Detector   = values[2];
                            abiData.Ct         = values[4];
                            abiData.XmlContent = "<Well>" + values[0] + "</Well><Detector>" + values[2] + "</Detector><Ct>" + values[4] + "</Ct>";

                            if (string.IsNullOrEmpty(abiData.Well))
                            {
                                if (previousMainAbiData.DataList == null)
                                {
                                    previousMainAbiData.DataList = new List <PCRColumnData>();
                                }

                                previousMainAbiData.DataList.Add(abiData);
                            }
                            else
                            {
                                previousMainAbiData = abiData;
                                dataList.Add(previousMainAbiData);
                            }
                        }

                        if (!isRightFormat && content.StartsWith(formatTitle))
                        {
                            isRightFormat = true;
                        }
                    }
                }
            }

            if (!isRightFormat)
            {
                return(isRightFormat);
            }

            Dictionary <int, DataRow> dc = controller.GetPCRPositionsByPlateID(plate.PlateID, currentExperimentId);

            if (dc.Count != dataList.Count)
            {
                isRightPositionNumber = false;
                if (!isRightPositionNumber)
                {
                    MessageBoxResult selectResult = MessageBox.Show("PCR仪检测结果和混样数不一致,请检查操作是否正确?“是”将按现有规则导入", "系统提示", MessageBoxButton.YesNo);
                    if (selectResult == MessageBoxResult.No)
                    {
                        return(isRightFormat);
                    }
                    else
                    {
                        isRightPositionNumber = true;
                    }
                }
            }

            foreach (ABIPCRColumnData abiData in dataList)
            {
                PCRTestResult info = new PCRTestResult();
                info.ItemID     = WanTaiObjectService.NewSequentialGuid();
                info.RotationID = rotationId;
                info.Position   = controller.ChangeCharacterToPositionNumber(abiData.Well);
                info.CreateTime = DateTime.Now;
                //calculate
                if (dc.ContainsKey(info.Position))
                {
                    DataRow  row      = dc[info.Position];
                    bool     isSingle = (int)row["TubeNumber"] == 1 ? true : false;
                    Tubetype tubeType = (Tubetype)((short)row["TubeType"]);
                    info.Result = checkPCRResult(abiData, row["TestName"].ToString(), isSingle, tubeType);
                }

                info.ExperimentID = currentExperimentId;
                if (plate.BarCode != null)
                {
                    info.BarCode = plate.BarCode;
                }

                info.PlateID = plate.PlateID;

                string xmlContent = abiData.XmlContent;
                if (abiData.DataList != null)
                {
                    foreach (ABIPCRColumnData data in abiData.DataList)
                    {
                        xmlContent = xmlContent + data.XmlContent;
                    }
                }
                info.PCRContent = "<PCRContent>" + xmlContent + "</PCRContent>";
                pcrResultList.Add(info);
            }

            return(isRightFormat);
        }