public void AddConsumption(DataTable dt, short volumeType) { try { using (WanTaiEntities entities = new WanTaiEntities()) { for (int i = 0; i < dt.Rows.Count; i++) { if (((double)dt.Rows[i]["AddVolume"]) > 0) { ReagentsAndSuppliesConsumption consumption = new ReagentsAndSuppliesConsumption(); consumption.ItemID = WanTaiObjectService.NewSequentialGuid(); consumption.Volume = (double)dt.Rows[i]["AddVolume"]; consumption.UpdateTime = DateTime.Now; consumption.ReagentAndSupplieID = Guid.Parse(dt.Rows[i]["ReagentAndSuppolieID"].ToString()); consumption.ExperimentID = SessionInfo.ExperimentID; consumption.RotationID = SessionInfo.PraperRotation.RotationID; consumption.VolumeType = volumeType; entities.ReagentsAndSuppliesConsumptions.AddObject(consumption); } } entities.SaveChanges(); } } catch (Exception ex) { string errorMessage = ex.Message + System.Environment.NewLine + ex.StackTrace; LogInfoController.AddLogInfo(LogInfoLevelEnum.Error, errorMessage, SessionInfo.LoginName, this.GetType().Name, SessionInfo.ExperimentID); } }
public void UpdataRotationOperateStatus(RotationOperate _RotationOperate, RotationInfoStatus State) { using (WanTaiEntities _WanTaiEntities = new WanTaiEntities()) { RotationOperate NewRotationOperate = _WanTaiEntities.RotationOperates.Where(rotationOperate => (rotationOperate.OperationID == _RotationOperate.OperationID && rotationOperate.RotationID == _RotationOperate.RotationID)).FirstOrDefault(); if (NewRotationOperate == null) { NewRotationOperate = new RotationOperate(); NewRotationOperate.RotationOperateID = WanTaiObjectService.NewSequentialGuid(); NewRotationOperate.StartTime = _RotationOperate.StartTime; NewRotationOperate.ExperimentID = _RotationOperate.ExperimentID; NewRotationOperate.OperationConfigurationReference.Value = _WanTaiEntities.OperationConfigurations.Where(Operation => Operation.OperationID == _RotationOperate.OperationID).FirstOrDefault(); NewRotationOperate.RotationID = _RotationOperate.RotationID; NewRotationOperate.State = (short)State; _WanTaiEntities.AddToRotationOperates(NewRotationOperate); } else { NewRotationOperate.State = (short)State; NewRotationOperate.EndTime = _RotationOperate.EndTime; NewRotationOperate.ErrorLog = _RotationOperate.ErrorLog; } _WanTaiEntities.SaveChanges(); } }
public bool EditByTypeId(List <SystemFluidConfiguration> recordList, short typeId) { try { using (WanTaiEntities entities = new WanTaiEntities()) { var records = entities.SystemFluidConfigurations.Where(p => p.ItemType == typeId); foreach (SystemFluidConfiguration record in records) { entities.DeleteObject(record); } foreach (SystemFluidConfiguration record in recordList) { record.ItemID = WanTaiObjectService.NewSequentialGuid(); entities.AddToSystemFluidConfigurations(record); } entities.SaveChanges(); return(true); } } catch (Exception e) { string errorMessage = e.Message + System.Environment.NewLine + e.StackTrace; LogInfoController.AddLogInfo(LogInfoLevelEnum.Error, errorMessage, SessionInfo.LoginName, this.GetType().ToString() + "." + MethodBase.GetCurrentMethod(), SessionInfo.ExperimentID); return(false); } }
private void btnSave_Click(object sender, RoutedEventArgs e) { string userName = txtUserName.Text.Trim(); string password = txtPassword.Password.Trim(); if (userName == string.Empty) { MessageBox.Show("用户名不允许为空", "系统提示"); return; } if (password == string.Empty) { MessageBox.Show("密码不允许为空", "系统提示"); return; } if (System.Text.Encoding.Default.GetByteCount(userName) > 255) { MessageBox.Show("用户名最大长度为127个汉字。", "系统提示"); return; } string passwordTwo = txtPasswordTwo.Password.Trim(); if (System.Text.Encoding.Default.GetByteCount(password) > 255) { MessageBox.Show("密码最大长度为127个汉字。", "系统提示"); return; } if (password == passwordTwo) { if (userInfoController.GetUserByName(userName) != null) { MessageBox.Show("用户名[" + userName + "]已经存在。", "系统提示"); } else { UserInfo userInfo = new UserInfo() { UserID = WanTaiObjectService.NewSequentialGuid(), CreateName = SessionInfo.LoginName, LoginName = userName, LoginPassWord = password, CreateTime = DateTime.Now, RoleName = comboRole.SelectedValue.ToString() }; string message; userInfoController.Add(userInfo, out message); LogInfoController.AddLogInfo(LogInfoLevelEnum.Operate, "添加用户 成功", SessionInfo.LoginName, this.GetType().Name, SessionInfo.ExperimentID); MessageBox.Show(message, "系统提示"); this.Close(); } } else { MessageBox.Show("两次输入密码不一致!请重新输入。", "系统提示"); } }
private void save_Click(object sender, RoutedEventArgs e) { if (!validate()) { return; } ReagentAndSuppliesConfiguration configuration = new ReagentAndSuppliesConfiguration(); configuration.EnglishName = name_textBox.Text; configuration.DisplayName = displayName_textBox.Text; configuration.Position = int.Parse(position_textBox.Text); configuration.Grid = int.Parse(grid_textBox.Text); configuration.Unit = unit_label.Content.ToString(); ComboBoxItem selectedItem = type_comboBox.SelectedItem as ComboBoxItem; ReagentSuppliesType type = (ReagentSuppliesType)selectedItem.DataContext; configuration.ItemType = short.Parse(type.TypeId); configuration.CalculationFormula = calculation_textBox.Text; ComboBoxItem carrier_selectedItem = carrier_comboBox.SelectedItem as ComboBoxItem; configuration.ContainerName = carrier_selectedItem.Content.ToString(); configuration.BarcodePrefix = barcode_textBox.Text; configuration.Color = color_Control.Background.ToString(); bool result = false; if (string.IsNullOrEmpty(editedItemId)) { configuration.ItemID = WanTaiObjectService.NewSequentialGuid(); configuration.ActiveStatus = true; result = controller.Create(configuration); WanTai.Controller.LogInfoController.AddLogInfo(LogInfoLevelEnum.Operate, "新建试剂耗材:" + configuration.EnglishName + " " + (result == true ? "成功" : "失败"), SessionInfo.LoginName, this.GetType().ToString(), null); } else { result = controller.EditConfiguration(new Guid(editedItemId), configuration); WanTai.Controller.LogInfoController.AddLogInfo(LogInfoLevelEnum.Operate, "修改试剂耗材:" + configuration.EnglishName + " " + (result == true ? "成功" : "失败"), SessionInfo.LoginName, this.GetType().ToString(), null); } if (result) { MessageBox.Show("保存成功", "系统提示"); } else { MessageBox.Show("保存失败", "系统提示"); } this.Close(); }
private void btnSave_Click(object sender, RoutedEventArgs e) { string experimentName = txtExperimentName.Text.Trim(); if (experimentName == string.Empty) { errInfo.Text = "实验名称不能为空。"; return; } else if (System.Text.Encoding.Default.GetByteCount(experimentName) > 255) { errInfo.Text = "实验名称允许最大长度为127个汉字"; return; } ExperimentController controller = new ExperimentController(); if (controller.ExperimentNameExists(experimentName)) { errInfo.Text = "实验名称\"" + txtExperimentName.Text + "\"已存在。"; return; } ExperimentsInfo experimentsInfo = new ExperimentsInfo(); experimentsInfo.ExperimentID = WanTaiObjectService.NewSequentialGuid(); experimentsInfo.ExperimentName = experimentName; experimentsInfo.LoginName = txtOrperatorName.Text; experimentsInfo.Remark = txtRemark.Text; experimentsInfo.StartTime = DateTime.Now; experimentsInfo.State = (short)ExperimentStatus.Create;; SessionInfo.CurrentExperimentsInfo = experimentsInfo; if (controller.CreateExperiment(experimentsInfo)) { SessionInfo.ExperimentID = experimentsInfo.ExperimentID; SessionInfo.RotationFormulaParameters = new Dictionary <Guid, FormulaParameters>(); SessionInfo.PraperRotation = null; LogInfoController.AddLogInfo(LogInfoLevelEnum.Operate, "新建实验 成功", SessionInfo.LoginName, this.GetType().Name, SessionInfo.ExperimentID); this.DialogResult = true; this.Close(); } else { errInfo.Text = "添加实验失败。"; } }
/// <summary> /// /// </summary> /// <param name="logLevel">0 debug,1 info,2 warning,3 error,10 operate</param> /// <param name="logContent"></param> /// <param name="loginName"></param> /// <param name="module"></param> /// <param name="experimentID"></param> public static void AddLogInfo(LogInfoLevelEnum logLevel, string logContent, string loginName, string module, Guid?experimentID) { LogInfo logInfo = new LogInfo() { LogID = WanTaiObjectService.NewSequentialGuid(), LogContent = logContent, LogLevel = (short)logLevel, LoginName = loginName, CreaterTime = DateTime.Now, ExperimentID = experimentID, Module = module }; using (WanTaiEntities wanTaiEntities = new WanTaiEntities()) { wanTaiEntities.AddToLogInfoes(logInfo); wanTaiEntities.SaveChanges(); } }
private void save_Click(object sender, System.Windows.RoutedEventArgs e) { if (!validate()) { return; } bool result = false; ComboBoxItem selectedItem = (ComboBoxItem)liquidType_comboBox.SelectedItem; foreach (DataGridCellInfo cell in dataGrid1.SelectedCells) { int columnIndex = CommFuntion.GetDataGridCellColumnIndex(cell); int rowIndex = CommFuntion.GetDataGridCellRowIndex(cell); SystemFluidConfiguration liquidConfiguration = new SystemFluidConfiguration(); liquidConfiguration.ItemID = WanTaiObjectService.NewSequentialGuid(); liquidConfiguration.Position = rowIndex; liquidConfiguration.Grid = columnIndex; liquidConfiguration.ItemType = ((LiquidType)selectedItem.DataContext).TypeId; if (volume_TextBox.IsVisible) { liquidConfiguration.Volume = double.Parse(volume_TextBox.Text); } result = controller.Create(liquidConfiguration); if (!result) { WanTai.Controller.LogInfoController.AddLogInfo(LogInfoLevelEnum.Operate, "新建:" + ((LiquidType)selectedItem.DataContext).TypeName + " 失败", SessionInfo.LoginName, this.GetType().ToString(), null); MessageBox.Show("保存失败!", "系统提示"); break; } } if (result) { WanTai.Controller.LogInfoController.AddLogInfo(LogInfoLevelEnum.Operate, "新建:" + ((LiquidType)selectedItem.DataContext).TypeName + " 成功", SessionInfo.LoginName, this.GetType().ToString(), null); MessageBox.Show("保存成功!", "系统提示"); } this.Close(); }
private void save_Click(object sender, RoutedEventArgs e) { if (!validate()) { return; } TestingItemConfiguration config = new TestingItemConfiguration(); config.TestingItemName = name_textBox.Text; config.TestingItemColor = color_Control.Background.ToString(); config.DisplaySequence = short.Parse(displaySequence_textBox.Text); config.WorkListFileName = workListFileName_textBox.Text; bool result = false; if (string.IsNullOrEmpty(editTestItemId)) { config.TestingItemID = WanTaiObjectService.NewSequentialGuid(); config.ActiveStatus = true; result = controller.Create(config); LogInfoController.AddLogInfo(LogInfoLevelEnum.Operate, "新建检测项目:" + config.TestingItemName + " " + (result == true ? "成功" : "失败"), SessionInfo.LoginName, this.GetType().ToString(), null); } else { result = controller.EditTestingItems(new Guid(editTestItemId), config); LogInfoController.AddLogInfo(LogInfoLevelEnum.Operate, "修改检测项目:" + config.TestingItemName + " " + (result == true ? "成功" : "失败"), SessionInfo.LoginName, this.GetType().ToString(), null); } if (result) { MessageBox.Show("保存成功", "系统提示"); this.DialogResult = true; } else { MessageBox.Show("保存失败", "系统提示"); } this.Close(); }
public static void InstertKingFisherLog(Guid experimentID, DateTime dtStart, DateTime dtEnd, out string ErrMsg) { ErrMsg = "success"; using (SqlConnection con = new SqlConnection(WanTai.Common.Configuration.GetKingFisherConnectionString())) { try { SqlCommand cmd = new SqlCommand(); cmd.Connection = con; cmd.CommandText = "select * from tbl_log where creation_time between @dtStart and @dtEnd ";// + dtStart.ToUniversalTime().ToString() + "' and '" + dtEnd.ToString() + "'"; DateTime _dtStart = dtStart.ToUniversalTime(); DateTime _dtEnd = dtEnd.ToUniversalTime(); cmd.Parameters.AddWithValue("@dtStart", _dtStart); cmd.Parameters.AddWithValue("@dtEnd", _dtEnd); con.Open(); SqlDataReader dReader = cmd.ExecuteReader(); using (WanTaiEntities wanTaiEntities = new WanTaiEntities()) { while (dReader.Read()) { LogInfo logInfo = new LogInfo() { LogID = WanTaiObjectService.NewSequentialGuid(), LogContent = dReader["object_name"].ToString() + " " + dReader["message"].ToString(), LogLevel = (int)LogInfoLevelEnum.KingFisher, LoginName = SessionInfo.LoginName, CreaterTime = DateTime.Parse(dReader["creation_time"].ToString()).ToLocalTime(), ExperimentID = experimentID, Module = "KingFisherLog" }; wanTaiEntities.AddToLogInfoes(logInfo); } wanTaiEntities.SaveChanges(); } }catch (Exception ex) { ErrMsg = "连接KingFisher数据库失败!"; WanTai.Common.CommonFunction.WriteLog(ex.ToString()); } } }
private void save_Click(object sender, RoutedEventArgs e) { if (!validate()) { return; } PoolingRulesConfiguration config = new PoolingRulesConfiguration(); config.PoolingRulesName = name_textBox.Text; config.TubeNumber = int.Parse(tubeNumber_textBox.Text); bool result = false; if (string.IsNullOrEmpty(editPoolingRuleId)) { config.PoolingRulesID = WanTaiObjectService.NewSequentialGuid(); config.ActiveStatus = true; result = controller.Create(config); LogInfoController.AddLogInfo(LogInfoLevelEnum.Operate, "新建混样方式:" + config.PoolingRulesName + " " + (result == true ? "成功" : "失败"), SessionInfo.LoginName, this.GetType().ToString(), null); } else { result = controller.EditPoolingRules(new Guid(editPoolingRuleId), config); LogInfoController.AddLogInfo(LogInfoLevelEnum.Operate, "修改混样方式:" + config.PoolingRulesName + " " + (result == true ? "成功" : "失败"), SessionInfo.LoginName, this.GetType().ToString(), null); } if (result) { MessageBox.Show("保存成功", "系统提示"); this.DialogResult = true; } else { MessageBox.Show("保存失败", "系统提示"); } this.Close(); }
public void AddConsumption(Guid rotationID, Guid reagentAndSupplieID, double volume, short volumeType) { try { using (WanTaiEntities entities = new WanTaiEntities()) { ReagentsAndSuppliesConsumption consumption = new ReagentsAndSuppliesConsumption(); consumption.ItemID = WanTaiObjectService.NewSequentialGuid(); consumption.Volume = volume; consumption.UpdateTime = DateTime.Now; consumption.ReagentAndSupplieID = reagentAndSupplieID; consumption.ExperimentID = SessionInfo.ExperimentID; consumption.RotationID = rotationID; consumption.VolumeType = volumeType; entities.ReagentsAndSuppliesConsumptions.AddObject(consumption); entities.SaveChanges(); } } catch (Exception ex) { string errorMessage = ex.Message + System.Environment.NewLine + ex.StackTrace; LogInfoController.AddLogInfo(LogInfoLevelEnum.Error, errorMessage, SessionInfo.LoginName, this.GetType().Name, SessionInfo.ExperimentID); } }
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); }
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); }
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); }
private void btnSave_Click(object sender, RoutedEventArgs e) { //MessageBoxResult msResult = MessageBox.Show("确认保存么", "系统提示", MessageBoxButton.YesNo, MessageBoxImage.Information); //if (msResult == MessageBoxResult.No) //{ // return; //} ReagentsAndSuppliesConsumptionController consumptionController = new ReagentsAndSuppliesConsumptionController(); ReagentAndSuppliesController reagentController = new ReagentAndSuppliesController(); PlateController plateController = new PlateController(); foreach (PlateBase plate in ViewPlates) { if (plate.ItemType == 101 && (plate.DisplayName.EndsWith("1") || plate.DisplayName.EndsWith("2"))) { string plateName = ""; if (plate.DisplayName.EndsWith("1")) { plateName = PlateName.DWPlate1; } if (plate.DisplayName.EndsWith("2")) { plateName = PlateName.DWPlate2; } plateController.UpdateBarcode(plateName, 0, SessionInfo.PraperRotation.RotationID, plate.Barcode); } ReagentAndSupply reagent = new ReagentAndSupply(); if ((isFirstRotation) || (!isFirstRotation && (plate.ItemType >= 100 && plate.ItemType < 200))) { reagent.ItemID = WanTaiObjectService.NewSequentialGuid(); reagent.BarCode = plate.Barcode; reagent.ItemType = plate.ItemType; reagent.ExperimentID = SessionInfo.ExperimentID; reagent.ConfigurationItemID = plate.ConfigurationItemID; reagentController.AddReagentAndSupplies(reagent); } else { reagent.ItemID = new ReagentAndSuppliesController().GetReagentID(SessionInfo.ExperimentID, plate.BarcodePrefix); if (reagent.ItemID == Guid.Empty) { reagent.ItemID = WanTaiObjectService.NewSequentialGuid(); reagent.BarCode = plate.Barcode; reagent.ItemType = plate.ItemType; reagent.ExperimentID = SessionInfo.ExperimentID; reagent.ConfigurationItemID = plate.ConfigurationItemID; reagentController.AddReagentAndSupplies(reagent); } } ReagentsAndSuppliesConsumption calcReagentConsumption = new ReagentsAndSuppliesConsumption(); calcReagentConsumption.ItemID = WanTaiObjectService.NewSequentialGuid(); if (plate.ActualSavedVolume > 0) { calcReagentConsumption.Volume = plate.ActualSavedVolume; } else { calcReagentConsumption.Volume = plate.NeedVolume; } calcReagentConsumption.UpdateTime = DateTime.Now; calcReagentConsumption.ExperimentID = SessionInfo.ExperimentID; calcReagentConsumption.RotationID = SessionInfo.PraperRotation.RotationID; calcReagentConsumption.VolumeType = ConsumptionType.Need; calcReagentConsumption.ReagentAndSupplieID = reagent.ItemID; consumptionController.AddConsumption(calcReagentConsumption); ReagentsAndSuppliesConsumption scanReagentConsumption = new ReagentsAndSuppliesConsumption(); scanReagentConsumption.ItemID = WanTaiObjectService.NewSequentialGuid(); scanReagentConsumption.UpdateTime = DateTime.Now; scanReagentConsumption.ExperimentID = SessionInfo.ExperimentID; scanReagentConsumption.RotationID = SessionInfo.PraperRotation.RotationID; scanReagentConsumption.VolumeType = ConsumptionType.FirstAdd; if (reagent.ItemType == DiTiType.DiTi200 || reagent.ItemType == DiTiType.DiTi1000) { scanReagentConsumption.Volume = plate.FirstAddVolume * 96; } else { scanReagentConsumption.Volume = plate.FirstAddVolume; } scanReagentConsumption.ReagentAndSupplieID = reagent.ItemID; consumptionController.AddConsumption(scanReagentConsumption); } btnScan.IsEnabled = false; btnManual.IsEnabled = false; btnSave.IsEnabled = false; btnNext.IsEnabled = true; btnSupplies.IsEnabled = false; btnReagent.IsEnabled = false; btnTestItem.IsEnabled = false; SessionInfo.NextButIndex = 3; ////MessageBox.Show("保存成功!", "系统提示"); }
public static void SampleTracking(Guid ExperimentsID, Guid OperationID, Guid RotationID, int OperationSequence, Guid NexRotationID, DateTime FileCreateTime, bool GroupOperation) { using (WanTai.DataModel.WanTaiEntities _WanTaiEntities = new DataModel.WanTaiEntities()) { string PCRBarCodesFile = WanTai.Common.Configuration.GetEvoOutputPath() + WanTai.Common.Configuration.GetPlatesBarCodesFile(); if (File.Exists(PCRBarCodesFile)) { System.IO.FileInfo fileInfo = new System.IO.FileInfo(PCRBarCodesFile); DateTime fileModifiedTime = fileInfo.LastWriteTime; if (DateTime.Compare(FileCreateTime, fileModifiedTime) < 0) { List <string> PCRPlateBarcodes = new List <string>(); Dictionary <string, string> MixPlateBarcodes = new Dictionary <string, string>(); using (FileStream fileStream = new System.IO.FileStream(PCRBarCodesFile, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.ReadWrite)) { using (System.IO.StreamReader mysr = new System.IO.StreamReader(fileStream)) { string strline; //1(Position);1;1(Grid);Tube 13*100mm 16 Pos;Tube1;013/035678;11 while ((strline = mysr.ReadLine()) != null) { string BarCode = strline.Split(';')[strline.Split(';').Length - 1].Replace("\"", ""); if (strline.IndexOf("PCR Plate;") > 0) { PCRPlateBarcodes.Add(BarCode); } else if (strline.IndexOf("DW 96 Plate") > 0) { if (strline.IndexOf("DW 96 Plate 1;") > 0) { MixPlateBarcodes.Add("DW 96 Plate 1", BarCode); } else if (strline.IndexOf("DW 96 Plate 2;") > 0) { MixPlateBarcodes.Add("DW 96 Plate 2", BarCode); } } } } } if (PCRPlateBarcodes.Count() > 0) { List <Plate> Plates = _WanTaiEntities.Plates.Where(plate => (plate.RotationID == RotationID && plate.PlateType == (short)PlateType.PCR_Plate)).OrderBy(plate => plate.PlateID).ToList(); int index = 0; foreach (Plate _plate in Plates) { if (index < PCRPlateBarcodes.Count()) { _plate.BarCode = PCRPlateBarcodes[index]; } index++; } } if (MixPlateBarcodes.Count() > 0) { foreach (string plateName in MixPlateBarcodes.Keys) { if (GroupOperation && NexRotationID != new Guid()) { Plate _plate = _WanTaiEntities.Plates.Where(plate => (plate.RotationID == NexRotationID && plate.PlateType == (short)PlateType.Mix_Plate) && plate.PlateName == plateName).FirstOrDefault(); if (_plate != null) { _plate.BarCode = MixPlateBarcodes[plateName]; } } else if (!GroupOperation) { Plate _plate = _WanTaiEntities.Plates.Where(plate => (plate.RotationID == RotationID && plate.PlateType == (short)PlateType.Mix_Plate) && plate.PlateName == plateName).FirstOrDefault(); if (_plate != null) { _plate.BarCode = MixPlateBarcodes[plateName]; } } } } _WanTaiEntities.SaveChanges(); } } if (!Directory.Exists(WanTai.Common.Configuration.GetSampleTrackingOutPutPath())) { return; } string[] FileNames = Directory.GetFiles(WanTai.Common.Configuration.GetSampleTrackingOutPutPath(), "*.csv"); if (FileNames.Length == 0) { return; } foreach (string FileName in FileNames) { System.IO.FileInfo fileInfo = new System.IO.FileInfo(FileName); DateTime fileModifiedTime = fileInfo.LastWriteTime; if (DateTime.Compare(FileCreateTime, fileModifiedTime) > 0) { continue; } string fileNameWithoutExtension = System.IO.Path.GetFileNameWithoutExtension(FileName); Guid _RotationID = RotationID; int _OperationSequence = OperationSequence; if (NexRotationID != new Guid() && GroupOperation) { var Plates = _WanTaiEntities.Plates.Where(plate => plate.RotationID == NexRotationID && plate.PlateType == (short)PlateType.Mix_Plate && plate.BarCode == fileNameWithoutExtension); if (Plates.FirstOrDefault() != null) { _RotationID = NexRotationID; _OperationSequence = 1; } } using (FileStream fileStream = new System.IO.FileStream(FileName, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.ReadWrite)) { using (System.IO.StreamReader mysr = new System.IO.StreamReader(fileStream)) { using (CsvReader csv = new CsvReader(mysr, true)) { // 格式化字段出错时,触发事件csv_ParseError csv.DefaultParseErrorAction = ParseErrorAction.RaiseEvent; csv.ParseError += new EventHandler <ParseErrorEventArgs>(delegate(object sender, ParseErrorEventArgs e) { // 如果错误是字段不存在,则跳转到下一行 if (e.Error is MissingFieldCsvException) { // Console.Write("--MISSING FIELD ERROR OCCURRED"); e.Action = ParseErrorAction.AdvanceToNextLine; } }); if (GroupOperation) { ReagentAndSuppliesConfiguration ReagentAndSupplie = _WanTaiEntities.ReagentAndSuppliesConfigurations.Where(ReagentAndSupplies => ReagentAndSupplies.ItemType == 205).FirstOrDefault(); if (ReagentAndSupplie != null) { if (fileInfo.Name.IndexOf(ReagentAndSupplie.BarcodePrefix) >= 0) { foreach (string[] result in csv) { if (string.IsNullOrEmpty(result[1])) { continue; } float _temp = 0; if (string.IsNullOrEmpty(result[4]) || !float.TryParse(result[4], out _temp)) { continue; } if (string.IsNullOrEmpty(result[6]) || !float.TryParse(result[6], out _temp)) { continue; } _WanTaiEntities.AddToSampleTrackings(new SampleTracking() { ItemID = WanTaiObjectService.NewSequentialGuid(), RackID = result[0], CavityID = result[1], Position = result[2], SampleID = result[3], CONCENTRATION = float.Parse(result[4]), VOLUME = string.IsNullOrEmpty(result[6]) ? 0 : float.Parse(result[6]), SampleErrors = result[13], ExperimentsID = ExperimentsID, OperationID = OperationID, OperationSequence = _OperationSequence, RotationID = _RotationID, FileName = fileInfo.Name, CreateTime = DateTime.Now }); } continue; } } } //var query = csv.Where(c => c[1] != c[3] && !string.IsNullOrEmpty(c[4]) && c[4] != "0"); var query = csv.Where(c => !(c[1] == c[3] && !string.IsNullOrEmpty(c[4]) && c[4] == "1")); if (query == null) { continue; } foreach (string[] result in query) { if (string.IsNullOrEmpty(result[1])) { continue; } float _temp = 0; if (string.IsNullOrEmpty(result[4]) || !float.TryParse(result[4], out _temp)) { continue; } if (string.IsNullOrEmpty(result[6]) || !float.TryParse(result[6], out _temp)) { continue; } _WanTaiEntities.AddToSampleTrackings(new SampleTracking() { ItemID = WanTaiObjectService.NewSequentialGuid(), RackID = result[0], CavityID = result[1], Position = result[2], SampleID = result[3], CONCENTRATION = float.Parse(result[4]), VOLUME = string.IsNullOrEmpty(result[6]) ? 0 : float.Parse(result[6]), SampleErrors = result[13], ExperimentsID = ExperimentsID, OperationID = OperationID, OperationSequence = _OperationSequence, RotationID = _RotationID, FileName = fileInfo.Name, CreateTime = DateTime.Now }); } /***************************************************************************************************************************** * StringBuilder sBuilder2 = new StringBuilder(); * while (csv.ReadNextRecord()) * { * if (csv[1] != csv[3] && float.Parse(csv[4]) != 0) * sBuilder2.Append(csv[7] + ";"); * //for (int i = 0; i < fieldCount; i++) * // Console.Write(string.Format("{0} = {1};", headers[i], csv[i])); * //Console.WriteLine(); * } * int fieldCount = csv.FieldCount; * string[] headers = csv.GetFieldHeaders(); * var query = csv.Where(c => c[1] != c[3] && float.Parse(c[4])!=0); * StringBuilder sBuilder = new StringBuilder(); * StringBuilder sBuilder1 = new StringBuilder(); * foreach (string[] filed in query) * { * sBuilder.Append(filed[0] + ";" + filed[1] + ";" + filed[3] + ";" + filed[4] + ";" + float.Parse(filed[4]).ToString()); * sBuilder1.Append(filed[7]+";"); * } * * //var m = from n in csv where n[] < 5 orderby n select n; ************************************************************************************************************************************************/ } } } } _WanTaiEntities.SaveChanges(); } }
private void save_button_Click(object sender, RoutedEventArgs e) { if (!validate()) { return; } List <RotationInfo> rotationInfoList = new List <RotationInfo>(); foreach (DataRow row in dataTable.Rows) { RotationInfo rotationInfo = new RotationInfo(); rotationInfo.RotationID = WanTaiObjectService.NewSequentialGuid(); rotationInfo.ExperimentID = SessionInfo.ExperimentID; if (row["TubesBatchID"] != null && !string.IsNullOrEmpty(row["TubesBatchID"].ToString())) { rotationInfo.TubesBatchID = new Guid(row["TubesBatchID"].ToString()); } if (row["RotationName"] != null && !string.IsNullOrEmpty(row["RotationName"].ToString())) { rotationInfo.RotationName = row["RotationName"].ToString(); } rotationInfo.State = (short)RotationInfoStatus.Create; rotationInfo.CreateTime = DateTime.Now; OperationConfiguration operation = row["Operation"] as OperationConfiguration; rotationInfo.OperationID = operation.OperationID; rotationInfo.OperationName = operation.OperationName; rotationInfo.RotationSequence = (short)row["Sequence"]; rotationInfoList.Add(rotationInfo); } if (controller.Create(rotationInfoList)) { //if (SessionInfo.PraperRotation == null) //{ Guid RotationID = Guid.Empty; if (SessionInfo.PraperRotation != null) { RotationID = SessionInfo.PraperRotation.RotationID; } SessionInfo.PraperRotation = rotationInfoList.FirstOrDefault(); FormulaParameters formulaParameters = SessionInfo.RotationFormulaParameters[RotationID]; SessionInfo.RotationFormulaParameters.Remove(RotationID); if (!SessionInfo.RotationFormulaParameters.ContainsKey(SessionInfo.PraperRotation.RotationID)) { SessionInfo.RotationFormulaParameters.Add(SessionInfo.PraperRotation.RotationID, formulaParameters); } else { SessionInfo.RotationFormulaParameters[SessionInfo.PraperRotation.RotationID] = formulaParameters; } // } // MessageBox.Show("保存成功!", "系统提示"); if (NextStepEvent != null) { NextStepEvent(sender, e); } this.next_button.IsEnabled = true; } else { MessageBox.Show("保存失败!", "系统提示"); } }
private void save_Click(object sender, RoutedEventArgs e) { if (!validate()) { return; } OperationConfiguration config = new OperationConfiguration(); config.OperationName = name_textBox.Text; config.OperationType = (short)((OperationType)type_comboBox.SelectedIndex); config.OperationSequence = short.Parse(sequence_textBox.Text); config.DisplayFlag = display_checkBox.IsChecked; if (!string.IsNullOrEmpty(runTime_textBox.Text)) { config.RunTime = int.Parse(runTime_textBox.Text); } if (files_listBox.Items.Count > 0) { string allscripts = string.Empty; foreach (string script in files_listBox.Items) { if (!string.IsNullOrEmpty(editOperationId) && editOperation_ScriptFileName.Contains(script)) { allscripts = allscripts + "," + script; } else { string fileName = System.IO.Path.GetFileName(script); if (!System.IO.File.Exists(scriptPath + fileName)) { System.IO.File.Copy(script, scriptPath + fileName); } else { fileName = System.IO.Path.GetFileNameWithoutExtension(fileName) + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + System.IO.Path.GetExtension(fileName); System.IO.File.Copy(script, scriptPath + fileName); } allscripts = allscripts + "," + fileName; } } if (allscripts.StartsWith(",")) { allscripts = allscripts.Substring(1); } config.ScriptFileName = allscripts; } if (type_comboBox.SelectedIndex == (int)OperationType.Grouping) { string subOperationIds = string.Empty; foreach (UIElement element in operationList_stackPanel.Children) { if (element is CheckBox && (bool)((CheckBox)element).IsChecked) { OperationConfiguration operation = (OperationConfiguration)((CheckBox)element).DataContext; if (string.IsNullOrEmpty(subOperationIds)) { subOperationIds = operation.OperationID.ToString(); } else { subOperationIds = subOperationIds + "," + operation.OperationID.ToString(); } } } config.SubOperationIDs = subOperationIds; } else { config.StartOperationFileName = startFileName_textBox.Text; config.EndOperationFileName = endFileName_textBox.Text; } bool result = false; if (string.IsNullOrEmpty(editOperationId)) { config.OperationID = WanTaiObjectService.NewSequentialGuid(); config.ActiveStatus = true; result = controller.Create(config); WanTai.Controller.LogInfoController.AddLogInfo(LogInfoLevelEnum.Operate, "新建操作:" + config.OperationName + " " + (result == true ? "成功" : "失败"), SessionInfo.LoginName, this.GetType().ToString(), null); } else { result = controller.EditOperation(new Guid(editOperationId), config); WanTai.Controller.LogInfoController.AddLogInfo(LogInfoLevelEnum.Operate, "修改操作:" + config.OperationName + " " + (result == true ? "成功" : "失败"), SessionInfo.LoginName, this.GetType().ToString(), null); } if (result) { MessageBox.Show("保存成功", "系统提示"); this.DialogResult = true; } else { MessageBox.Show("保存失败", "系统提示"); } this.Close(); }