Beispiel #1
0
        public override List <DetectedInfo> Read()
        {
            string  sReportXml = ConfigurationManager.AppSettings[stringRes.reportPath];
            DataSet ds         = new DataSet();

            ds.ReadXml(sReportXml);
            DataTable                dt          = ds.Tables[0];
            List <DetectedInfo>      heights     = new List <DetectedInfo>();
            Dictionary <int, string> nameValDict = new Dictionary <int, string>();

            for (int i = 0; i < dt.Columns.Count; i++)
            {
                nameValDict.Add(i, dt.Columns[i].Caption);
            }

            foreach (DataRow dr in dt.Rows)
            {
                DetectedInfo detectResult = new DetectedInfo();
                for (int i = 0; i < dr.ItemArray.Count(); i++)
                {
                    if (nameValDict[i] == "Z1")
                    {
                        detectResult.Z1 = 10 * double.Parse(dr.ItemArray[i].ToString());
                    }
                    if (nameValDict[i] == "Z2")
                    {
                        detectResult.Z2 = 10 * double.Parse(dr.ItemArray[i].ToString());
                    }
                    if (nameValDict[i] == "Vh")
                    {
                        detectResult.LiquidVol = double.Parse(dr.ItemArray[i].ToString());
                    }
                    if (nameValDict[i] == "Vl")
                    {
                        detectResult.SepVol = double.Parse(dr.ItemArray[i].ToString());
                    }
                }
                if (detectResult.Z1 < detectResult.Z2)
                {
                    throw new Exception("Z1 must be greater than Z2");
                }
                heights.Add(detectResult);
            }
            return(heights);
        }
Beispiel #2
0
        public override List<DetectedInfo> Read()
        {
            string sReportXml = ConfigurationManager.AppSettings[stringRes.reportPath];
            DataSet ds = new DataSet();
            ds.ReadXml(sReportXml);
            DataTable dt = ds.Tables[0];
            List<DetectedInfo> heights = new List<DetectedInfo>();
            Dictionary<int, string> nameValDict = new Dictionary<int, string>();
            for (int i = 0; i < dt.Columns.Count; i++)
            {
                nameValDict.Add(i, dt.Columns[i].Caption);
            }

            foreach (DataRow dr in dt.Rows)
            {

                DetectedInfo detectResult = new DetectedInfo();
                for (int i = 0; i < dr.ItemArray.Count(); i++)
                {
                    if (nameValDict[i] == "Z1")
                        detectResult.Z1 = 10 * double.Parse(dr.ItemArray[i].ToString());
                    if (nameValDict[i] == "Z2")
                        detectResult.Z2 = 10 * double.Parse(dr.ItemArray[i].ToString());
                }
                if (detectResult.Z1 < detectResult.Z2)
                    throw new Exception("Z1 must be greater than Z2");
                heights.Add(detectResult);
            }
            return heights;
        }
Beispiel #3
0
        //public bool HasBuffyCoat()
        //{
        //    string reportPath = ConfigurationManager.AppSettings[stringRes.reportPath];
        //    int pos = reportPath.LastIndexOf('\\');
        //    string sDir = reportPath.Substring(0, pos);
        //    string sPath = sDir + "\\hasBuffy.txt";
        //    bool bHasBuffy = false;
        //    if (!File.Exists(sPath))
        //        return false;
        //    using (StreamReader sr = new StreamReader(sPath))
        //    {
        //        string s = sr.ReadLine();
        //        bHasBuffy = bool.Parse(s);
        //    }
        //    return bHasBuffy;
        //}
        public override List<DetectedInfo> Read()
        {
            List<DetectedInfo> heights = new List<DetectedInfo>();

            string reportPath = GlobalVars.Instance.ResultFile;//ConfigurationManager.AppSettings[stringRes.reportPath];
            int line = 1;

            var unitIsMM = ConfigurationManager.AppSettings["UnitIsMM"];
            double ratio = 1;
            if (unitIsMM != null && !bool.Parse(unitIsMM))
                ratio = 0.1;
            using (StreamReader sr = new StreamReader(reportPath))
            {
                string sContent = "";
                bool bFirstRow = true;
                int curRow = 0;
                while (true)
                {
                    sContent = sr.ReadLine();
                    if (sContent == null)
                        break;
                    if (sContent == "")
                        continue;
                    if (bFirstRow)
                    {
                        bFirstRow = false;
                        continue;
                    }

                    DetectedInfo detectedInfo = new DetectedInfo();
                    int infoIndex = (curRow - 1);
                    string[] vals = sContent.Split(',');
                    detectedInfo.Z1 = double.Parse(vals[1]) * ratio;
                    detectedInfo.Z2 = double.Parse(vals[2]) * ratio;
                    //if(barcodes != null)
                    //    detectedInfo.sBarcode = trimedBarcodes[line-1];//vals[0];
                    line++;
                    heights.Add(detectedInfo);
                    if(GlobalVars.Instance.IsRedCell)
                    {
                        if (detectedInfo.Z1 < 5 )
                            throw new Exception("Z1 cannot be smaller than 5mm at line: " + line);
                        detectedInfo.Z2 = 5;
                    }
                    else if (detectedInfo.Z1 < 0 || detectedInfo.Z2 < 0)
                        throw new Exception("Z1,Z2 cannot be smaller than 0 at line: " + line);
                    curRow++;
                }
            }
            return heights;
        }
Beispiel #4
0
        //public bool HasBuffyCoat()
        //{
        //    string reportPath = ConfigurationManager.AppSettings[stringRes.reportPath];
        //    int pos = reportPath.LastIndexOf('\\');
        //    string sDir = reportPath.Substring(0, pos);
        //    string sPath = sDir + "\\hasBuffy.txt";
        //    bool bHasBuffy = false;
        //    if (!File.Exists(sPath))
        //        return false;
        //    using (StreamReader sr = new StreamReader(sPath))
        //    {
        //        string s = sr.ReadLine();
        //        bHasBuffy = bool.Parse(s);
        //    }
        //    return bHasBuffy;
        //}

        public override List <DetectedInfo> Read()
        {
            List <DetectedInfo> heights = new List <DetectedInfo>();



            string reportPath = GlobalVars.Instance.ResultFile;//ConfigurationManager.AppSettings[stringRes.reportPath];
            int    line       = 1;

            var    unitIsMM = ConfigurationManager.AppSettings["UnitIsMM"];
            double ratio    = 1;

            if (unitIsMM != null && !bool.Parse(unitIsMM))
            {
                ratio = 0.1;
            }
            using (StreamReader sr = new StreamReader(reportPath))
            {
                string sContent  = "";
                bool   bFirstRow = true;
                int    curRow    = 0;
                while (true)
                {
                    sContent = sr.ReadLine();
                    if (sContent == null)
                    {
                        break;
                    }
                    if (sContent == "")
                    {
                        continue;
                    }
                    if (bFirstRow)
                    {
                        bFirstRow = false;
                        continue;
                    }

                    DetectedInfo detectedInfo = new DetectedInfo();
                    int          infoIndex    = (curRow - 1);
                    string[]     vals         = sContent.Split(',');
                    detectedInfo.Z1 = double.Parse(vals[1]) * ratio;
                    detectedInfo.Z2 = double.Parse(vals[2]) * ratio;
                    //if(barcodes != null)
                    //    detectedInfo.sBarcode = trimedBarcodes[line-1];//vals[0];
                    line++;
                    heights.Add(detectedInfo);
                    if (GlobalVars.Instance.IsRedCell)
                    {
                        if (detectedInfo.Z1 < 5)
                        {
                            throw new Exception("Z1 cannot be smaller than 5mm at line: " + line);
                        }
                        detectedInfo.Z2 = 5;
                    }
                    else if (detectedInfo.Z1 < 0 || detectedInfo.Z2 < 0)
                    {
                        throw new Exception("Z1,Z2 cannot be smaller than 0 at line: " + line);
                    }
                    curRow++;
                }
            }
            return(heights);
        }