using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
using XCommon;
namespace XImagingXhandler.XDAL
{
///
/// 孔位数据检查
///
public class WellCheck
{
#region 检查孔位号是否在某个板位上的耗材中
///
/// 检查孔位号是否在某个板位上的耗材中
///
/// 台面板位xml节点对象
/// 耗材对象
/// 板位对象
/// 待验证的孔位名称数据
///
public DataCheckResult CheckWellDataIsEnable(XmlNode xmlNode, Labware labware, Lattice lattice, string strWells)
{
//预处理已设置的孔位
string[] tWells = strWells.Split(',');
string sWell = string.Empty;
DataCheckResult dataCheckResult = new DataCheckResult();
dataCheckResult.result = 0;
XmlNode xn = xmlNode.SelectSingleNode("platform[lattice_id=" + lattice.lattice_id + "][labware_id=" + labware.labware_id + "]");
if (xn != null)
{
int row = (int)labware.number_row;
int column = (int)labware.number_column;
List strings = GenerateAllWells(labware);
for (int i = 0; i < tWells.Length; i++)
{
if (!strings.Contains(tWells[i]))
{
dataCheckResult.result = 1;
sWell += tWells[i]+",";
}
}
}
if(!string.IsNullOrEmpty(sWell))
{
dataCheckResult.missData = sWell;
}
return dataCheckResult;
}
#endregion
#region 生成指定耗材的所有孔位名称
///
/// 生成指定耗材的所有孔位名称
///
/// 耗材实体
/// 指定耗材的所有孔位名称集合
public List GenerateAllWells(Labware labware)
{
int row = (int)labware.number_row;
int column = (int)labware.number_column;
List strWells = new List();
for (int i = 1; i < row + 1; i++)
{
string rowName = ComUtility.GetRowChar(i - 1);
for (int j = 1; j < column + 1; j++)
{
string wellName = rowName + j.ToString();
strWells.Add(wellName);
}
}
return strWells;
}
#endregion
#region 检查孔位是否连续的8排
///
/// 检查孔位是否连续的8排
///
/// 耗材对象
/// 板位对象
/// 待验证的孔位名称数据文本
/// 验证结果对象
public DataCheckResult CheckWellDataIsWhole8Line( Labware labware, Lattice lattice, string strWells)
{
//预处理已设置的孔位
string[] tWells = strWells.Split(',');
string misWells = string.Empty;//保存缺失的孔位
DataCheckResult dataCheckResult = new DataCheckResult();
dataCheckResult.result = 0;
int row = (int)labware.number_row;
int column = (int)labware.number_column;
//竖着摆放
for (int i = 1; i < column + 1; i++)
{
int countofLine = 0;//每列完整的孔位
int countofColumn = 0;//整列全部缺少的孔位
for (int j = 1; j < row + 1; j++)
{
string rowName = ComUtility.GetRowChar(j - 1);
if(tWells.Contains(rowName))
{
countofLine += 1;
}
else
{
countofColumn += 1;
misWells += rowName+",";
}
}
if(countofLine< row && countofColumn< row)//缺少
{
dataCheckResult.result = 1;
dataCheckResult.missData = misWells.Substring(0,misWells.Length-1);
return dataCheckResult;
}
if(countofColumn == row)//全部缺少
{
}
if (countofLine == row)//全部完整
{
}
}
return dataCheckResult;
}
#endregion
}
}