public bool EditConfiguration(Guid itemId, ReagentAndSuppliesConfiguration item) { try { using (WanTaiEntities entities = new WanTaiEntities()) { ReagentAndSuppliesConfiguration record = entities.ReagentAndSuppliesConfigurations.Where(p => p.ItemID == itemId).FirstOrDefault(); record.EnglishName = item.EnglishName; record.DisplayName = item.DisplayName; record.Position = item.Position; record.Grid = item.Grid; record.Unit = item.Unit; record.ItemType = item.ItemType; record.CalculationFormula = item.CalculationFormula; record.ContainerName = item.ContainerName; record.BarcodePrefix = item.BarcodePrefix; record.Color = item.Color; 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() + "->EditConfiguration", SessionInfo.ExperimentID); return(false); } }
private void CheckHeaterScanResult(DataTable dtScan) { if (dtScan.Rows.Count == 0) { return; } string str1 = "+"; string str2 = "-"; List <PlateBase> PCRLiquidTups = ViewPlates.FindAll(P => (P.ItemType > 0 && P.ItemType < 100 && P.ItemType % 5 == 0)); foreach (PlateBase tub in PCRLiquidTups) { string liquidName = tub.EnglishName.Replace(str1, string.Empty).Replace(str2, string.Empty); ReagentSuppliesType liquidType = reagentSuppliesType.FirstOrDefault(P => P.TypeId == tub.ItemType.ToString()); if (liquidType != null) { liquidName = liquidType.TypeName + " " + liquidName; } if (dtScan.Columns.Contains(liquidName)) { double columnValue = saveConvertion.GetSafeDouble(dtScan.Rows[0][liquidName]); tub.FirstAddVolume = columnValue; tub.Correct = tub.FirstAddVolume >= (tub.NeedVolume + tub.CurrentVolume); ReagentAndSuppliesConfiguration reagent = reagentAndSupplies.FirstOrDefault(P => P.BarcodePrefix == tub.BarcodePrefix); if (reagent != null) { reagent.FirstAddVolume += tub.FirstAddVolume; } } } }
/// <summary> /// Check plates by Scan Result,and Update Volume to DataGrid /// </summary> /// <param name="dtScan"></param> private void CheckByScanResult(DataTable dtScan) { for (int i = 0; i < dtScan.Rows.Count; i++) { foreach (Control.PlateBase plate in ViewPlates) { if (plate.ItemType < 100) { continue; } if (plate.CarrierGrid == (int)dtScan.Rows[i]["Grid"] && plate.Position == (int)dtScan.Rows[i]["Position"] && dtScan.Rows[i]["Barcode"] != null && dtScan.Rows[i]["Barcode"].ToString().StartsWith(plate.BarcodePrefix) ) { plate.Barcode = dtScan.Rows[i]["Barcode"].ToString(); plate.FirstAddVolume = 0; plate.Correct = true; ReagentAndSuppliesConfiguration reagent = reagentAndSupplies.FirstOrDefault(P => P.DisplayName == plate.ChineseName); if (reagent != null) { reagent.FirstAddVolume += (double)dtScan.Rows[i]["Volume"]; } } } } }
private void btnConfirm_Click(object sender, RoutedEventArgs e) { string gridName = ((Button)sender).CommandParameter.ToString(); ReagentAndSuppliesConfiguration selectedItem = (ReagentAndSuppliesConfiguration)dataGridDictionary[gridName].CurrentCell.Item; FrameworkElement eletem = dataGridDictionary[gridName].Columns[3].GetCellContent(selectedItem); DataGridTemplateColumn temple = (dataGridDictionary[gridName].Columns[3] as DataGridTemplateColumn); TextBox txt = (TextBox)temple.CellTemplate.FindName("txtAddVolume", eletem); ConfirmAddVolume(txt.Text.Trim(), selectedItem); btnSave.IsEnabled = reagentAndSupplies.FirstOrDefault(P => P.Correct == false) == null; }
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(); }
public string GetBarcodePrefix(short itemType) { string barcodePrefix = null; using (WanTaiEntities entities = new WanTaiEntities()) { ReagentAndSuppliesConfiguration reagentConfig = entities.ReagentAndSuppliesConfigurations.FirstOrDefault(P => P.ItemType == itemType); if (reagentConfig != null) { barcodePrefix = reagentConfig.BarcodePrefix; } else { LogInfoController.AddLogInfo(LogInfoLevelEnum.Error, itemType.ToString() + "doesn't exist ein ReagentAndSuppliesConfiguration", "", this.GetType().Name, null); } } return(barcodePrefix); }
public bool Create(ReagentAndSuppliesConfiguration configuration) { try { using (WanTaiEntities entities = new WanTaiEntities()) { entities.AddToReagentAndSuppliesConfigurations(configuration); 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() + "->Create", SessionInfo.ExperimentID); return(false); } }
public ReagentAndSuppliesConfiguration GetConfiguration(Guid itemId) { try { using (WanTaiEntities entities = new WanTaiEntities()) { ReagentAndSuppliesConfiguration record = entities.ReagentAndSuppliesConfigurations.Where(p => p.ItemID == itemId).FirstOrDefault(); return(record); } } catch (Exception e) { string errorMessage = e.Message + System.Environment.NewLine + e.StackTrace; LogInfoController.AddLogInfo(LogInfoLevelEnum.Error, errorMessage, SessionInfo.LoginName, this.GetType().ToString() + "->GetConfiguration", SessionInfo.ExperimentID); throw; } }
public bool UpdateActiveStatus(Guid itemId, bool status) { try { using (WanTaiEntities entities = new WanTaiEntities()) { ReagentAndSuppliesConfiguration record = entities.ReagentAndSuppliesConfigurations.Where(p => p.ItemID == itemId).FirstOrDefault(); record.ActiveStatus = status; 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() + "->UpdateActiveStatus", SessionInfo.ExperimentID); return(false); } }
private void InitField() { if (!string.IsNullOrEmpty(editedItemId)) { ReagentAndSuppliesConfiguration item = controller.GetConfiguration(new Guid(editedItemId)); this.name_textBox.Text = item.EnglishName; this.displayName_textBox.Text = item.DisplayName; foreach (ComboBoxItem comboxItem in type_comboBox.Items) { ReagentSuppliesType reagentSuppliesType = (ReagentSuppliesType)comboxItem.DataContext; if (reagentSuppliesType.TypeId == item.ItemType.ToString()) { comboxItem.IsSelected = true; break; } } this.barcode_textBox.Text = item.BarcodePrefix; foreach (ComboBoxItem comboxItem in carrier_comboBox.Items) { if (comboxItem.Content.ToString() == item.ContainerName) { comboxItem.IsSelected = true; break; } } this.grid_textBox.Text = item.Grid.ToString(); this.position_textBox.Text = item.Position.ToString(); this.color_Control.Background = new SolidColorBrush() { Color = (Color)ColorConverter.ConvertFromString(item.Color) }; this.unit_label.Content = item.Unit; this.calculation_textBox.Text = item.CalculationFormula; } }
private bool ConfirmAddVolume(string addVolume, ReagentAndSuppliesConfiguration item) { Regex r; string regexMessage; if (item.ItemType < 100) { r = new Regex("^([0-9]+)(\\.([0-9])+)?$"); regexMessage = "格式错误,请输入非零数字"; } else { r = new Regex("^([0-9]+)$"); regexMessage = "格式错误,请输入正整数"; } if (!r.Match(addVolume).Success) { MessageBox.Show(regexMessage, "系统提示"); return(false); } item.FirstAddVolume = Math.Round(Convert.ToDouble(addVolume), 3); if (isFirstRotation) { if (item.FirstAddVolume < item.NeedVolume) { string message = item.DisplayName + "为" + addVolume.ToString() + item.Unit + "建议量为" + (item.NeedVolume).ToString() + item.Unit + "。是否继续确认?“是”确认,“否”继续添加。"; MessageBoxResult msResult = MessageBox.Show(message, "系统提示", MessageBoxButton.YesNo, MessageBoxImage.Information); if (msResult == MessageBoxResult.No) { return(false); } } } else { //check if 剩余量>总需求量-消耗量 if (item.CurrentVolume < (item.TotalNeedValueAndConsumption + item.NeedVolume)) { //check if 当前量>总需求量-消耗量 if ((item.FirstAddVolume + item.CurrentVolume) < (item.TotalNeedValueAndConsumption + item.NeedVolume)) { string message = item.DisplayName + "为" + addVolume.ToString() + item.Unit + "建议量为" + (item.TotalNeedValueAndConsumption + item.NeedVolume - item.CurrentVolume).ToString() + item.Unit + "。是否继续确认?“是”确认,“否”继续添加。"; MessageBoxResult msResult = MessageBox.Show(message, "系统提示", MessageBoxButton.YesNo, MessageBoxImage.Information); if (msResult == MessageBoxResult.No) { return(false); } } } } item.Correct = true; if (ViewPlates.FirstOrDefault(P => (P.ChineseName == item.DisplayName && P.ItemType == item.ItemType)) != null) { ViewPlates.FirstOrDefault(P => (P.ChineseName == item.DisplayName && P.ItemType == item.ItemType)).FirstAddVolume = item.FirstAddVolume; } foreach (UIElement uiElement in DeskTopWithGrid.Children) { if (uiElement is CarrierBase) { ((CarrierBase)uiElement).ShiningStop(item.ItemID); } } return(true); }
public RubbishAlert(Guid RotationID) { InitializeComponent(); double lenghtUnit = deskTop.Width / 84; imgKingFisher.Width = lenghtUnit * 24; imgKingFisher.Height = lenghtUnit * 24; imgKingFisher.Margin = new Thickness(-lenghtUnit * 2 * 1.4, lenghtUnit * 1, 0, lenghtUnit * 2); deskTop.Children.Add(desktopService.DrawCoordinate(deskTop.Width, 69, lenghtUnit)); List <CarrierBase> carriers = desktopService.GetCarriers(lenghtUnit, 1.4); List <ReagentAndSuppliesConfiguration> supplies = new ReagentSuppliesConfigurationController(). GetRotationVolume(SessionInfo.ExperimentID, RotationID, new short[] { 0 }, ReagentAndSuppliesConfiguration.CurrentVolumeFieldName).FindAll(P => P.ItemType >= 100 && P.ItemType < 200); List <PlateBase> plates = new List <PlateBase>(); if (supplies.Exists(P => P.ItemType == 101)) { ReagentAndSuppliesConfiguration supply = supplies.First(P => P.ItemType == 101); PlateBase plate = new Control.Plate(); plate.DisplayName = supply.DisplayName; plate.ChineseName = supply.DisplayName; plate.NeedVolume = 1; plate.CurrentVolume = 1; plate.Grid = 1; plate.Position = 1; plate.ContainerName = "001"; plate.Color = new SolidColorBrush((Color)ColorConverter.ConvertFromString(supply.Color)); plate.ItemType = (short)supply.ItemType; plate.BarcodePrefix = supply.BarcodePrefix; plate.ConfigurationItemID = supply.ItemID; plate.Correct = false; plates.Add(plate); } Brush PCRPlateColor = new SolidColorBrush(Colors.Red); foreach (ReagentAndSuppliesConfiguration supply in supplies) { Brush color = new SolidColorBrush((Color)ColorConverter.ConvertFromString(supply.Color)); if (supply.ItemType == DiTiType.DiTi1000)//DiTi1000 { //int position = 1; //int grid = 1; //string containerName = supply.ContainerName; //int totalCount = int.Parse(decimal.Ceiling(decimal.Parse((supply.CurrentVolume / 96).ToString())).ToString()); //for (int i = 0; i < totalCount; i++) //{ // PlateBase plate = new WanTai.View.Control.Plate(); // plate.DisplayName = supply.DisplayName + " " + (i + 1).ToString(); // plate.ChineseName = supply.DisplayName; // plate.NeedVolume = 1; // plate.CurrentVolume = 1; // plate.Grid = grid; // plate.Position = position; // plate.ContainerName = "006"; // plate.Color = color; // plate.ItemType = (short)supply.ItemType; // plate.ConfigurationItemID = supply.ItemID; // plate.Correct = false; // plates.Add(plate); // position++; // if (i == 5) break; //} } else if (supply.ItemType == DiTiType.DiTi200)//DiTi200 { //int position = 1; //int grid = 1; //string containerName = supply.ContainerName; //int totalCount = int.Parse(decimal.Ceiling(decimal.Parse((supply.CurrentVolume / 96).ToString())).ToString()); //for (int i = 0; i < totalCount; i++) //{ // PlateBase plate = new WanTai.View.Control.Plate(); // plate.DisplayName = supply.DisplayName + " " + (i + 1).ToString(); // plate.ChineseName = supply.DisplayName; // plate.NeedVolume = 1; // plate.CurrentVolume = 1; // plate.Grid = grid; // plate.Position = position; // plate.ContainerName = "007"; // plate.Color = color; // plate.ItemType = (short)supply.ItemType; // plate.ConfigurationItemID = supply.ItemID; // plate.Correct = false; // plates.Add(plate); // position++; // if (i == 3) break; //} } else if (supply.ItemType == 103) //&& supply.NeedVolume>0)//PCR Plate { PCRPlateColor = color; int position = 2; int grid = 1; //string containerName = supply.ContainerName; //for (int i = 0; i < supply.CurrentVolume; i++) //{ PlateBase plate = new WanTai.View.Control.Plate(); plate.DisplayName = supply.DisplayName; plate.ChineseName = supply.DisplayName; plate.NeedVolume = 1; plate.CurrentVolume = 1; plate.Grid = grid; plate.Position = position; plate.ContainerName = "002"; plate.Color = color; plate.ItemType = (short)supply.ItemType; plate.ConfigurationItemID = supply.ItemID; plate.Correct = false; plates.Add(plate); //position++; //if (i == 2) break; //} } } /* * //DW96Plate3、DW96Plate4、DW96Plate5 * PlateBase PCRPlate = new WanTai.View.Control.Plate(); * PCRPlate.DisplayName = "DW96Plate3"; * PCRPlate.ChineseName = "DW96Plate3"; * PCRPlate.NeedVolume = 1; * PCRPlate.CurrentVolume = 1; * PCRPlate.Grid = 1; * PCRPlate.Position = 1; * PCRPlate.ContainerName = "002"; * PCRPlate.Color = PCRPlateColor; * PCRPlate.ItemType = 100; * PCRPlate.ConfigurationItemID = new Guid(); * PCRPlate.Correct = false; * plates.Add(PCRPlate); * * PlateBase PCRPlate = new WanTai.View.Control.Plate(); * PCRPlate.DisplayName = "DW96Plate4"; * PCRPlate.ChineseName = "DW96Plate4"; * PCRPlate.NeedVolume = 1; * PCRPlate.CurrentVolume = 1; * PCRPlate.Grid = 1; * PCRPlate.Position = 2; * PCRPlate.ContainerName = "002"; * PCRPlate.Color = PCRPlateColor; * PCRPlate.ItemType = 102; * PCRPlate.ConfigurationItemID = new Guid(); * PCRPlate.Correct = false; * plates.Add(PCRPlate); * * PCRPlate = new WanTai.View.Control.Plate(); * PCRPlate.DisplayName = "DW96Plate5"; * PCRPlate.ChineseName = "DW96Plate5"; * PCRPlate.NeedVolume = 1; * PCRPlate.CurrentVolume = 1; * PCRPlate.Grid = 1; * PCRPlate.Position = 3; * PCRPlate.ContainerName = "002"; * PCRPlate.Color = PCRPlateColor; * PCRPlate.ItemType = 103; * PCRPlate.ConfigurationItemID = new Guid(); * PCRPlate.Correct = false; * plates.Add(PCRPlate); */ foreach (CarrierBase c in carriers) { c.UpdatePlate(plates.FindAll(P => P.ContainerName == c.CarrierName)); deskTop.Children.Add(c); c.Scan(); } this.RotationID = RotationID; }
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(); } }