using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
using XCommon;
using XCoreBLL.Resource;
using XImagingXhandler.XDAL;
namespace XCore
{
public class ChoiceBll
{
string strCurrentCulture = "";
public ChoiceBll()
{
strCurrentCulture = System.Threading.Thread.CurrentThread.CurrentCulture.Name;
}
#region 从xml节点构建挑选聚落实体类对象
public MethodChoice GenerateMethodChoiceDataByXmlNode(XmlNode xmlNode)
{
MethodChoice methodChoice = new MethodChoice();
methodChoice.isrun = xmlNode.SelectSingleNode("isrun").InnerText;
methodChoice.status = xmlNode.SelectSingleNode("status").InnerText;
methodChoice.name = xmlNode.SelectSingleNode("name").InnerText;
methodChoice.label = xmlNode.SelectSingleNode("label").InnerText;
methodChoice.strIndex = xmlNode.SelectSingleNode("strIndex").InnerText;
methodChoice.armText = xmlNode.SelectSingleNode("arm/text").InnerText;
methodChoice.armValue = xmlNode.SelectSingleNode("arm/value").InnerText;
methodChoice.headType = xmlNode.SelectSingleNode("headType").InnerText;
methodChoice.labwaretipText = xmlNode.SelectSingleNode("labwaretip/text").InnerText;
methodChoice.labwaretipValue = xmlNode.SelectSingleNode("labwaretip/value").InnerText;
methodChoice.positionText = xmlNode.SelectSingleNode("position/text").InnerText;
methodChoice.positionValue = xmlNode.SelectSingleNode("position/value").InnerText;
methodChoice.bacteriaText= xmlNode.SelectSingleNode("bacteria/text").InnerText;
methodChoice.bacteriaValue = xmlNode.SelectSingleNode("bacteria/value").InnerText;
string strchs = xmlNode.SelectSingleNode("channels").InnerText;
methodChoice.channels = ComUtility.GetChannelsFromXml(strchs);
methodChoice.filePath = xmlNode.SelectSingleNode("filePath").InnerText;
methodChoice.beginLine = xmlNode.SelectSingleNode("beginLine").InnerText;
methodChoice.transferDataTable = GenerateTransferFileDataTable(xmlNode);
methodChoice.sourceLabware = xmlNode.SelectSingleNode("sourceLabware").InnerText;
methodChoice.sourceWell = xmlNode.SelectSingleNode("sourceWell").InnerText;
methodChoice.startPos = xmlNode.SelectSingleNode("startPos").InnerText;
return methodChoice;
}
#endregion
#region 从xml节点构建挑选菌落的表对象
public DataTable GenerateTransferFileDataTable(XmlNode xmlNode)
{
XmlNode xmlNode2 = xmlNode.SelectSingleNode("transferDataTable");
DataTable dataTable = new DataTable();
foreach (XmlNode childNode in xmlNode2.ChildNodes)
{
DataColumn dataColumn = new DataColumn();
dataColumn.ColumnName = childNode.Name.ToString();
dataTable.Columns.Add(dataColumn);
}
if (xmlNode2.ChildNodes[0] != null)
{
for (int i = 0; i < xmlNode2.ChildNodes[0].ChildNodes.Count; i++)
{
DataRow dataRow = dataTable.NewRow();
for (int j = 0; j < xmlNode2.ChildNodes.Count; j++)
{
dataRow[j] = xmlNode2.ChildNodes[j].ChildNodes[i].InnerText;
}
dataTable.Rows.Add(dataRow);
}
}
return dataTable;
}
#endregion
#region 从xml节点构建挑选转移实体类对象
public MethodChoiceAndTransfer GenerateMethodChoiceAndTransferDataByXmlNode(XmlNode xmlNode)
{
MethodChoiceAndTransfer methodChoice = new MethodChoiceAndTransfer();
methodChoice.isrun = xmlNode.SelectSingleNode("isrun").InnerText;
methodChoice.status = xmlNode.SelectSingleNode("status").InnerText;
methodChoice.label = xmlNode.SelectSingleNode("label").InnerText;
methodChoice.name = xmlNode.SelectSingleNode("name").InnerText;
methodChoice.strIndex = xmlNode.SelectSingleNode("strIndex").InnerText;
// 机械臂
methodChoice.armText = xmlNode.SelectSingleNode("arm/text").InnerText;
methodChoice.armValue = xmlNode.SelectSingleNode("arm/value").InnerText;
#region 移液枪通道
methodChoice.headType = xmlNode.SelectSingleNode("headType").InnerText;
string strchs = xmlNode.SelectSingleNode("channels").InnerText;
methodChoice.channels = ComUtility.GetChannelsFromXml(strchs);
#endregion
// 菌落信息
methodChoice.bacteriaText = xmlNode.SelectSingleNode("bacteria/text").InnerText;
methodChoice.bacteriaValue = xmlNode.SelectSingleNode("bacteria/value").InnerText;
// 挑菌方式
methodChoice.choiceMode = Convert.ToInt32(xmlNode.SelectSingleNode("choiceMode").InnerText);
// 挑菌耗材
methodChoice.choiceLabwareText = xmlNode.SelectSingleNode("choiceLabware/text").InnerText;
methodChoice.choiceLabwareValue = xmlNode.SelectSingleNode("choiceLabware/value").InnerText;
// 枪头耗材
methodChoice.tipsLabwareText = xmlNode.SelectSingleNode("labwaretip/text").InnerText;
methodChoice.tipsLabwareValue = xmlNode.SelectSingleNode("labwaretip/value").InnerText;
// 自动开关盖
methodChoice.autoOpenCloseCover = Convert.ToInt32(xmlNode.SelectSingleNode("autoOpenCloseCover").InnerText);
// 挑菌调节高度
methodChoice.choiceOffset = float.Parse(xmlNode.SelectSingleNode("choiceOffset").InnerText);
#region 超声探测
methodChoice.isEnableultrasonic = (xmlNode.SelectSingleNode("isEnableultrasonic").InnerText.ToLower().ToString() == "true" ? true : false);
// 从xml获取超声子页面数据
methodChoice.ultrasonicData = UltrasonicBll.GenerateMethodUltrasonicChildDataByXmlNode(xmlNode);
#endregion
// 获取挑菌前环境设置参数
methodChoice.choiceAgoAspirateData = CommonBll.GenerateChoiceAgoAspirateChildDataByXmlNode(xmlNode);
return methodChoice;
}
#endregion
#region 检查所有属性设置是否满足要求
///
/// 检查所有属性设置是否满足要求
///
/// 挑选属性对象
/// 检查所有属性设置是否满足要求
public MethodPropertyInfo CheckProperty(MethodChoice methodChoice)
{
MethodPropertyInfo methodPropertyInfo = new MethodPropertyInfo();
if (strCurrentCulture == "zh-CN")
{
methodPropertyInfo.property_tips_info = ChoiceResourceCHS.tipsInfo.ToString();
if (methodChoice.armText == null || methodChoice.armText == "")
{
methodPropertyInfo.property_name_info = ChoiceResourceCHS.armText.ToString();
}
if (methodChoice.bacteriaText == null || methodChoice.bacteriaText == "")
{
methodPropertyInfo.property_name_info = ChoiceResourceCHS.bacteriaText.ToString();
}
if (methodChoice.labwareText == null || methodChoice.labwareText == "")
{
methodPropertyInfo.property_name_info = ChoiceResourceCHS.labwareText.ToString();
}
if (methodChoice.labwaretipText == null || methodChoice.labwaretipText == "")
{
methodPropertyInfo.property_name_info = ChoiceResourceCHS.labwaretipText.ToString();
}
if (methodChoice.positionText == null || methodChoice.positionText == "")
{
methodPropertyInfo.property_name_info = ChoiceResourceCHS.positionText.ToString();
}
}
else if (strCurrentCulture == "en-US")
{
methodPropertyInfo.property_tips_info = ChoiceResourceENU.tipsInfo.ToString();
if (methodChoice.armText == null || methodChoice.armText == "")
{
methodPropertyInfo.property_name_info = ChoiceResourceENU.armText.ToString();
}
if (methodChoice.bacteriaText == null || methodChoice.bacteriaText == "")
{
methodPropertyInfo.property_name_info = ChoiceResourceENU.bacteriaText.ToString();
}
if (methodChoice.labwareText == null || methodChoice.labwareText == "")
{
methodPropertyInfo.property_name_info = ChoiceResourceENU.labwareText.ToString();
}
if (methodChoice.labwaretipText == null || methodChoice.labwaretipText == "")
{
methodPropertyInfo.property_name_info = ChoiceResourceENU.labwaretipText.ToString();
}
if (methodChoice.positionText == null || methodChoice.positionText == "")
{
methodPropertyInfo.property_name_info = ChoiceResourceENU.positionText.ToString();
}
}
return methodPropertyInfo;
}
#endregion
}
}