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);
     }
 }
Ejemplo n.º 2
0
        public void GetRotationOperates(Guid rotationID, DataTable dataTable, System.Windows.Media.Color alternativeColor, System.Windows.Media.Color defaultColor)
        {
            try
            {
                string connectionString = WanTai.Common.Configuration.GetConnectionString();
                string commandText      = "SELECT RotationOperate.*, OperationConfiguration.OperationName FROM RotationOperate left join OperationConfiguration"
                                          + " on RotationOperate.OperationID = OperationConfiguration.OperationID where RotationID=@RotationID";

                using (SqlConnection conn = new SqlConnection(connectionString))
                {
                    conn.Open();

                    using (SqlCommand cmd = new SqlCommand(commandText, conn))
                    {
                        cmd.Parameters.AddWithValue("@RotationID", rotationID);

                        using (SqlDataReader reader = cmd.ExecuteReader(CommandBehavior.Default))
                        {
                            int index = 1;
                            while (reader.Read())
                            {
                                System.Data.DataRow dRow = dataTable.NewRow();
                                dRow["Number"] = index;
                                if (index % 2 == 0)
                                {
                                    dRow["Color"] = alternativeColor;
                                }
                                else
                                {
                                    dRow["Color"] = defaultColor;
                                }
                                dRow["OperationID"]   = reader["OperationID"];
                                dRow["OperationName"] = reader["OperationName"];
                                dRow["StartTime"]     = reader["StartTime"].ToString();
                                if (reader["EndTime"] != DBNull.Value)
                                {
                                    dRow["EndTime"] = reader["EndTime"].ToString();
                                }

                                dRow["State"]    = ConvertEnumStatusToText((RotationOperateStatus)((short)reader["State"]));
                                dRow["ErrorLog"] = reader["ErrorLog"];

                                index++;
                                dataTable.Rows.Add(dRow);
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                string errorMessage = e.Message + System.Environment.NewLine + e.StackTrace;
                LogInfoController.AddLogInfo(LogInfoLevelEnum.Error, errorMessage, SessionInfo.LoginName, this.GetType().ToString() + "->GetRotationOperates", SessionInfo.ExperimentID);
                throw;
            }
        }
 public IList <PoolingRulesConfiguration> GetPoolingRulesConfigurations()
 {
     try
     {
         using (WanTaiEntities entities = new WanTaiEntities())
         {
             var records = entities.PoolingRulesConfigurations.OrderBy(c => c.TubeNumber);
             return(records.ToList <PoolingRulesConfiguration>());
         }
     }
     catch (Exception e)
     {
         string errorMessage = e.Message + System.Environment.NewLine + e.StackTrace;
         LogInfoController.AddLogInfo(LogInfoLevelEnum.Error, errorMessage, SessionInfo.LoginName, this.GetType().ToString() + "->GetPoolingRulesConfigurations", SessionInfo.ExperimentID);
         throw;
     }
 }
Ejemplo n.º 4
0
 public TubesBatch GetTubesBatchByID(Guid batchID)
 {
     try
     {
         using (WanTaiEntities entities = new WanTaiEntities())
         {
             TubesBatch record = entities.TubesBatches.Where(c => c.TubesBatchID == batchID).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() + "->" + "GetTubesBatchByID()", SessionInfo.ExperimentID);
         throw;
     }
 }
Ejemplo n.º 5
0
 public List <OperationConfiguration> GetDisplayedOperationConfigurations()
 {
     try
     {
         using (WanTaiEntities entities = new WanTaiEntities())
         {
             var records = entities.OperationConfigurations.Where(c => c.DisplayFlag == true && c.ActiveStatus == true).OrderBy(c => c.OperationSequence);
             return(records.ToList <OperationConfiguration>());
         }
     }
     catch (Exception e)
     {
         string errorMessage = e.Message + System.Environment.NewLine + e.StackTrace;
         LogInfoController.AddLogInfo(LogInfoLevelEnum.Error, errorMessage, SessionInfo.LoginName, this.GetType().ToString() + "->" + "GetDisplayedOperationConfigurations()", SessionInfo.ExperimentID);
         throw;
     }
 }
Ejemplo n.º 6
0
 public TestingItemConfiguration GetTestingItem(Guid TestingItemID)
 {
     try
     {
         using (WanTaiEntities entities = new WanTaiEntities())
         {
             TestingItemConfiguration record = entities.TestingItemConfigurations.Where(c => c.TestingItemID == TestingItemID).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() + "->GetTestingItem", SessionInfo.ExperimentID);
         throw;
     }
 }
Ejemplo n.º 7
0
 public bool Create(TestingItemConfiguration configuration)
 {
     try
     {
         using (WanTaiEntities entities = new WanTaiEntities())
         {
             entities.AddToTestingItemConfigurations(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);
     }
 }
Ejemplo n.º 8
0
        public bool CallScanScript()
        {
            string scanTubeScriptName = WanTai.Common.Configuration.GetTubesScanScriptName();

            try
            {
                IProcessor processor = ProcessorFactory.GetProcessor();
                processor.StartScript(scanTubeScriptName);
            }
            catch (Exception e)
            {
                string errorMessage = e.Message + System.Environment.NewLine + e.StackTrace;
                LogInfoController.AddLogInfo(LogInfoLevelEnum.Error, errorMessage, SessionInfo.LoginName, this.GetType().ToString() + "->" + "CallScanScript()", SessionInfo.ExperimentID);
                return(false);
            }

            return(true);
        }
Ejemplo n.º 9
0
        public RotationInfo GetRotationInfo(Guid rotationID)
        {
            try
            {
                using (WanTaiEntities entities = new WanTaiEntities())
                {
                    RotationInfo rotation = entities.RotationInfoes.FirstOrDefault(c => c.RotationID == rotationID);

                    return(rotation);
                }
            }
            catch (Exception e)
            {
                string errorMessage = e.Message + System.Environment.NewLine + e.StackTrace;
                LogInfoController.AddLogInfo(LogInfoLevelEnum.Error, errorMessage, SessionInfo.LoginName, this.GetType().ToString() + "->" + "GetRotationInfo(Guid rotationID)", SessionInfo.ExperimentID);
                throw;
            }
        }
Ejemplo n.º 10
0
        public List <RotationInfo> GetCurrentRotationInfos(Guid experimentID)
        {
            try
            {
                using (WanTaiEntities entities = new WanTaiEntities())
                {
                    var rotations = entities.RotationInfoes.Where(c => c.ExperimentID == experimentID).OrderBy(c => c.RotationSequence);

                    return(rotations.ToList <RotationInfo>());
                }
            }
            catch (Exception e)
            {
                string errorMessage = e.Message + System.Environment.NewLine + e.StackTrace;
                LogInfoController.AddLogInfo(LogInfoLevelEnum.Error, errorMessage, SessionInfo.LoginName, this.GetType().ToString() + "->" + "GetCurrentRotationInfos()", SessionInfo.ExperimentID);
                throw;
            }
        }
Ejemplo n.º 11
0
 public bool DeleteExperiment(Guid experimentID)
 {
     try
     {
         using (WanTaiEntities entities = new WanTaiEntities())
         {
             ExperimentsInfo experimentsInfo = entities.ExperimentsInfoes.FirstOrDefault(p => p.ExperimentID == experimentID);
             entities.ExperimentsInfoes.DeleteObject(experimentsInfo);
             return(true);
         }
     }
     catch (Exception ex)
     {
         string errorMessage = ex.Message + System.Environment.NewLine + ex.StackTrace;
         LogInfoController.AddLogInfo(LogInfoLevelEnum.Error, errorMessage, SessionInfo.LoginName, this.GetType().Name, SessionInfo.ExperimentID);
         return(false);
     }
 }
Ejemplo n.º 12
0
 public bool CreateExperiment(ExperimentsInfo experimentInfo)
 {
     try
     {
         using (WanTaiEntities entities = new WanTaiEntities())
         {
             entities.AddToExperimentsInfoes(experimentInfo);
             entities.SaveChanges();
             return(true);
         }
     }
     catch (Exception ex)
     {
         string errorMessage = ex.Message + System.Environment.NewLine + ex.StackTrace;
         LogInfoController.AddLogInfo(LogInfoLevelEnum.Error, errorMessage, SessionInfo.LoginName, this.GetType().Name, SessionInfo.ExperimentID);
         return(false);
     }
 }
Ejemplo n.º 13
0
        public List <Carrier> GetCarrier()
        {
            List <Carrier> list = new List <Carrier>();

            try
            {
                using (WanTaiEntities entities = new WanTaiEntities())
                {
                    list = entities.Carriers.ToList();
                }
            }
            catch (Exception ex)
            {
                string errorMessage = ex.Message + System.Environment.NewLine + ex.StackTrace;
                LogInfoController.AddLogInfo(LogInfoLevelEnum.Error, errorMessage, SessionInfo.LoginName, this.GetType().Name, SessionInfo.ExperimentID);
            }
            return(list);
        }
        //only can be used when typeId>=100
        public List <ReagentAndSupply> GetAllByTypeAndRotationId(int typeId, Guid rotationId)
        {
            List <ReagentAndSupply> list = new List <ReagentAndSupply>();

            try
            {
                string connectionString = WanTai.Common.Configuration.GetConnectionString();
                string commandText      = "select distinct ReagentAndSupplies.* from ReagentAndSupplies inner join ReagentsAndSuppliesConsumption"
                                          + " on ReagentAndSupplies.ItemID =ReagentsAndSuppliesConsumption.ReagentAndSupplieID"
                                          + " where ItemType=@ItemType and ReagentsAndSuppliesConsumption.RotationID=@RotationID"
                                          + " and ReagentAndSupplies.ExperimentID=@ExperimentID";

                using (SqlConnection conn = new SqlConnection(connectionString))
                {
                    conn.Open();

                    using (SqlCommand cmd = new SqlCommand(commandText, conn))
                    {
                        cmd.Parameters.AddWithValue("@ItemType", typeId);
                        cmd.Parameters.AddWithValue("@RotationID", rotationId);
                        cmd.Parameters.AddWithValue("@ExperimentID", SessionInfo.ExperimentID);

                        using (SqlDataReader reader = cmd.ExecuteReader(CommandBehavior.Default))
                        {
                            while (reader.Read())
                            {
                                list.Add(new ReagentAndSupply()
                                {
                                    ItemID = (Guid)reader["ItemID"], ItemType = (short)reader["ItemType"]
                                });
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                string errorMessage = e.Message + System.Environment.NewLine + e.StackTrace;
                LogInfoController.AddLogInfo(LogInfoLevelEnum.Error, errorMessage, SessionInfo.LoginName, this.GetType().ToString() + "->GetNextLogs", SessionInfo.ExperimentID);
                throw;
            }

            return(list);
        }
Ejemplo n.º 15
0
        public bool Delete(Guid TestingItemID)
        {
            try
            {
                using (WanTaiEntities entities = new WanTaiEntities())
                {
                    var record = entities.TestingItemConfigurations.Where(c => c.TestingItemID == TestingItemID).FirstOrDefault();
                    entities.DeleteObject(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() + "->Delete", SessionInfo.ExperimentID);
                return(false);
            }
        }
Ejemplo n.º 16
0
        public bool UpdateActiveStatus(Guid TestingItemID, bool status)
        {
            try
            {
                using (WanTaiEntities entities = new WanTaiEntities())
                {
                    TestingItemConfiguration record = entities.TestingItemConfigurations.Where(p => p.TestingItemID == TestingItemID).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);
            }
        }
Ejemplo n.º 17
0
        public bool Create(List <RotationInfo> rotationInfoList)
        {
            try
            {
                using (WanTaiEntities entities = new WanTaiEntities())
                {
                    var oldRotations = entities.RotationInfoes.Where(c => c.ExperimentID == SessionInfo.ExperimentID);

                    if (oldRotations.Count() > 0)
                    {
                        foreach (RotationInfo old in oldRotations)
                        {
                            entities.DeleteObject(old);
                        }
                    }

                    foreach (RotationInfo rotationInfo in rotationInfoList)
                    {
                        entities.AddToRotationInfoes(rotationInfo);
                        if (rotationInfo.TubesBatchID != null)
                        {
                            var plates = entities.Plates.Where(P => P.TubesBatchID == rotationInfo.TubesBatchID);
                            foreach (Plate plate in plates)
                            {
                                plate.RotationID = rotationInfo.RotationID;
                            }
                        }
                    }

                    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 bool EditPoolingRules(Guid PoolingRulesID, PoolingRulesConfiguration item)
        {
            try
            {
                using (WanTaiEntities entities = new WanTaiEntities())
                {
                    PoolingRulesConfiguration record = entities.PoolingRulesConfigurations.Where(p => p.PoolingRulesID == PoolingRulesID).FirstOrDefault();
                    record.PoolingRulesName = item.PoolingRulesName;
                    record.TubeNumber       = item.TubeNumber;

                    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() + "->EditPoolingRules", SessionInfo.ExperimentID);
                return(false);
            }
        }
Ejemplo n.º 19
0
 public bool UpdateExperimentState(Guid ExperimentID, int State)
 {
     try
     {
         using (WanTaiEntities entities = new WanTaiEntities())
         {
             ExperimentsInfo tempExperimentsInfo = entities.ExperimentsInfoes.FirstOrDefault(p => p.ExperimentID == ExperimentID);
             if (tempExperimentsInfo != null)
             {
                 tempExperimentsInfo.State = (short)State;
                 entities.SaveChanges();
             }
         }
         return(true);
     }
     catch (Exception ex)
     {
         string errorMessage = ex.Message + System.Environment.NewLine + ex.StackTrace;
         LogInfoController.AddLogInfo(LogInfoLevelEnum.Error, errorMessage, SessionInfo.LoginName, this.GetType().Name, SessionInfo.ExperimentID);
         return(false);
     }
 }
Ejemplo n.º 20
0
        public bool EditTestingItems(Guid TestingItemID, TestingItemConfiguration item)
        {
            try
            {
                using (WanTaiEntities entities = new WanTaiEntities())
                {
                    TestingItemConfiguration record = entities.TestingItemConfigurations.Where(p => p.TestingItemID == TestingItemID).FirstOrDefault();
                    record.TestingItemName  = item.TestingItemName;
                    record.TestingItemColor = item.TestingItemColor;
                    record.DisplaySequence  = item.DisplaySequence;
                    record.WorkListFileName = item.WorkListFileName;

                    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() + "->EditTestingItems", SessionInfo.ExperimentID);
                return(false);
            }
        }
Ejemplo n.º 21
0
        public bool CanDelete(Guid TestingItemID)
        {
            try
            {
                string connectionString = WanTai.Common.Configuration.GetConnectionString();
                string commandText      = "select count(*) from TestItem_TubeGroup where TestingItemID=@TestingItemID";
                using (SqlConnection conn = new SqlConnection(connectionString))
                {
                    conn.Open();

                    using (SqlCommand cmd = new SqlCommand(commandText, conn))
                    {
                        cmd.Parameters.AddWithValue("@TestingItemID", TestingItemID);

                        using (SqlDataReader reader = cmd.ExecuteReader(CommandBehavior.Default))
                        {
                            if (reader.Read())
                            {
                                int count = (int)reader.GetValue(0);
                                if (count > 0)
                                {
                                    return(false);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                string errorMessage = e.Message + System.Environment.NewLine + e.StackTrace;
                LogInfoController.AddLogInfo(LogInfoLevelEnum.Error, errorMessage, SessionInfo.LoginName, this.GetType().ToString() + "->CanDelete", SessionInfo.ExperimentID);
                throw;
            }

            return(true);
        }
 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);
     }
 }
Ejemplo n.º 23
0
 public void GetSingleSubOperations(Guid operationID, ref List <OperationConfiguration> operations)
 {
     using (WanTaiEntities entities = new WanTaiEntities())
     {
         OperationConfiguration operation = entities.OperationConfigurations.FirstOrDefault(P => P.OperationID == operationID);
         if (operation != null)
         {
             if (operation.OperationType == 0)
             {
                 operations.Add(operation);
             }
             else
             {
                 string subOperationIDs = operation.SubOperationIDs;
                 if (!string.IsNullOrEmpty(subOperationIDs))
                 {
                     string[] IDs = subOperationIDs.Split(new char[] { ',' });
                     Guid     guid;
                     for (int i = 0; i < IDs.Length; i++)
                     {
                         try
                         {
                             guid = Guid.Parse(IDs[i]);
                             GetSingleSubOperations(guid, ref operations);
                         }
                         catch (Exception ex)
                         {
                             LogInfoController.AddLogInfo(LogInfoLevelEnum.Error, ex.Message, null, this.GetType().ToString() + "->" + "GetSingleSubOperations(Guid operationID, ref List<OperationConfiguration> operations)", null);
                             continue;
                         }
                     }
                 }
             }
         }
     }
 }
 public bool CanDelete(Guid PoolingRulesID)
 {
     try
     {
         using (WanTaiEntities entities = new WanTaiEntities())
         {
             var records = entities.TubeGroups.Where(p => p.PoolingRulesID == PoolingRulesID).Count();
             if (records == 0)
             {
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
     }
     catch (Exception e)
     {
         string errorMessage = e.Message + System.Environment.NewLine + e.StackTrace;
         LogInfoController.AddLogInfo(LogInfoLevelEnum.Error, errorMessage, SessionInfo.LoginName, this.GetType().ToString() + "->CanDelete", SessionInfo.ExperimentID);
         return(false);
     }
 }
Ejemplo n.º 25
0
 public bool ExperimentNameExists(string experimentName)
 {
     try
     {
         using (WanTaiEntities entities = new WanTaiEntities())
         {
             ExperimentsInfo experimentInfo = entities.ExperimentsInfoes.FirstOrDefault(p => p.ExperimentName == experimentName);
             if (experimentInfo != null)
             {
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
     }
     catch (Exception ex)
     {
         string errorMessage = ex.Message + System.Environment.NewLine + ex.StackTrace;
         LogInfoController.AddLogInfo(LogInfoLevelEnum.Error, errorMessage, SessionInfo.LoginName, this.GetType().Name, SessionInfo.ExperimentID);
         return(false);
     }
 }
Ejemplo n.º 26
0
        public DataTable GetTubes(Guid BatchID, List <LiquidType> LiquidTypeList)
        {
            try
            {
                DataTable Tubes = new DataTable();
                for (int i = 1; i < 37; i++)
                {
                    DataColumn Column = new DataColumn("Position" + i.ToString());
                    Tubes.Columns.Add(Column);
                    Column = new DataColumn("Grid" + i.ToString());
                    Tubes.Columns.Add(Column);
                    Column = new DataColumn("BarCode" + i.ToString());
                    Tubes.Columns.Add(Column);
                    Column = new DataColumn("TubeType" + i.ToString());
                    Column.DefaultValue = Tubetype.IsNull;
                    Tubes.Columns.Add(Column);
                    Column = new DataColumn("TubePosBarCode" + i.ToString());
                    Tubes.Columns.Add(Column);
                    Column = new DataColumn("TextItemCount" + i.ToString());
                    Column.DefaultValue = "0,0,#C0C0C0"; //是否扫描到,采血管、阴阳补、选择颜色
                    Tubes.Columns.Add(Column);
                    Column = new DataColumn("IconName" + i.ToString());
                    Tubes.Columns.Add(Column);
                    Column = new DataColumn("Visibility" + i.ToString());
                    Column.DefaultValue = "Hidden";//Collapsed Hidden Visible
                    Tubes.Columns.Add(Column);
                    Column = new DataColumn("IsEnabled" + i.ToString());
                    Column.DefaultValue = "True";//Collapsed Hidden Visible
                    Tubes.Columns.Add(Column);
                    Column = new DataColumn("IsSelected" + i.ToString());
                    Column.DefaultValue = "#316AC5";//Collapsed Hidden Visible
                    Tubes.Columns.Add(Column);
                    Column = new DataColumn("DetailView" + i.ToString());
                    Column.DefaultValue = "";//Collapsed Hidden Visible
                    Tubes.Columns.Add(Column);
                    Column = new DataColumn("DetailViewTime" + i.ToString());
                    Column.DefaultValue = DateTime.Now;//Collapsed Hidden Visible
                    Tubes.Columns.Add(Column);

                    Column = new DataColumn("TestingItem" + i.ToString());
                    Column.DefaultValue = "";//Collapsed Hidden Visible
                    Tubes.Columns.Add(Column);

                    Column = new DataColumn("Background" + i.ToString());
                    Column.DefaultValue = null;//Collapsed Hidden Visible
                    Tubes.Columns.Add(Column);
                }
                for (int i = 0; i < 16; i++)
                {
                    DataRow dataRow = Tubes.NewRow();
                    Tubes.Rows.Add(dataRow);
                }
                //1(Position);1;1(Grid);Tube 13*100mm 16 Pos;Tube1;013/035678;11
                using (WanTai.DataModel.WanTaiEntities wanTaiEntities = new WanTaiEntities())
                {
                    var TubesGroup = wanTaiEntities.TubeGroups.Where(Batch => Batch.TubesBatchID == BatchID);
                    foreach (TubeGroup tubeGroup in TubesGroup)
                    {
                        var tubes = wanTaiEntities.Tubes.Where(tube => tube.TubeGroupID == tubeGroup.TubeGroupID);
                        foreach (Tube tube in tubes)
                        {
                            int Position = tube.Grid;
                            int Grid     = tube.Position - 1;
                            Tubes.Rows[Grid]["Position" + Position.ToString()] = Position;
                            Tubes.Rows[Grid]["Grid" + Position.ToString()]     = Grid + 1;
                            Tubes.Rows[Grid]["BarCode" + Position.ToString()]  = tube.BarCode;
                            Tubes.Rows[Grid]["TubeType" + Position.ToString()] = Tubetype.Tube;

                            Tubes.Rows[Grid]["TubePosBarCode" + Position.ToString()] = tube.TubePosBarCode;
                            tubeGroup.TestingItemConfigurations.Load();
                            Tubes.Rows[Grid]["TextItemCount" + Position.ToString()] = "1,1,#C0C0C0";

                            Tubes.Rows[Grid]["DetailView" + Position.ToString()] += tubeGroup.TubesGroupName + " " + tubeGroup.PoolingRulesConfiguration.PoolingRulesName;
                            foreach (TestingItemConfiguration TestingItem in tubeGroup.TestingItemConfigurations)
                            {
                                Tubes.Rows[Grid]["TextItemCount" + Position.ToString()] += ",;" + TestingItem.TestingItemColor;
                                Tubes.Rows[Grid]["DetailView" + Position.ToString()]    += " " + TestingItem.TestingItemName;
                            }

                            Tubes.Rows[Grid]["DetailView" + Position.ToString()] += ",";
                            Tubes.Rows[Grid]["IconName" + Position.ToString()]    = "1";
                            Tubes.Rows[Grid]["Visibility" + Position.ToString()]  = "Visible";
                            Tubes.Rows[Grid]["IsEnabled" + Position.ToString()]   = "True";
                            Tubes.Rows[Grid]["IsSelected" + Position.ToString()]  = "#316AC5";
                        }
                    }
                    foreach (SystemFluidConfiguration _SystemFluidConfiguration in wanTaiEntities.SystemFluidConfigurations)
                    {
                        if (Tubes.Rows[(int)(_SystemFluidConfiguration.Position - 1)]["TubeType" + _SystemFluidConfiguration.Grid.ToString()].ToString() == "-1")
                        {
                            continue;
                        }
                        Tubes.Rows[(int)(_SystemFluidConfiguration.Position - 1)]["TubeType" + _SystemFluidConfiguration.Grid.ToString()]   = (Tubetype)_SystemFluidConfiguration.ItemType;
                        Tubes.Rows[(int)(_SystemFluidConfiguration.Position - 1)]["Visibility" + _SystemFluidConfiguration.Grid.ToString()] = "Visible";
                        Tubes.Rows[(int)(_SystemFluidConfiguration.Position - 1)]["IsEnabled" + _SystemFluidConfiguration.Grid.ToString()]  = "True";
                        Tubes.Rows[(int)(_SystemFluidConfiguration.Position - 1)]["IsSelected" + _SystemFluidConfiguration.Grid.ToString()] = "#316AC5";
                        LiquidType _LiquidType = LiquidTypeList.Find(delegate(LiquidType lt) { return(lt.TypeId == _SystemFluidConfiguration.ItemType); });
                        if (_LiquidType != null)
                        {
                            Tubes.Rows[(int)(_SystemFluidConfiguration.Position - 1)]["TextItemCount" + _SystemFluidConfiguration.Grid.ToString()] = "1,2," + _LiquidType.Color;
                        }
                    }
                }

                Tubes.Namespace = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                return(Tubes);
            }
            catch (Exception e)
            {
                string errorMessage = e.Message + System.Environment.NewLine + e.StackTrace;
                LogInfoController.AddLogInfo(LogInfoLevelEnum.Error, errorMessage, SessionInfo.LoginName, this.GetType().ToString() + "->" + "GetTubes()", SessionInfo.ExperimentID);
                throw;
            }
        }
Ejemplo n.º 27
0
        public DataTable GetTubes(List <LiquidType> LiquidTypeList, DateTime fileBeforeCreatedTime, out string ErrMsg, out string SystemFluid)
        {
            ErrMsg      = "success";
            SystemFluid = "";
            try
            {
                DataTable Tubes = new DataTable();
                for (int i = 1; i < 37; i++)
                {
                    DataColumn Column = new DataColumn("Position" + i.ToString());
                    Tubes.Columns.Add(Column);
                    Column = new DataColumn("Grid" + i.ToString());
                    Tubes.Columns.Add(Column);
                    Column = new DataColumn("BarCode" + i.ToString());
                    Tubes.Columns.Add(Column);
                    Column = new DataColumn("TubeType" + i.ToString());
                    Column.DefaultValue = Tubetype.IsNull;
                    Tubes.Columns.Add(Column);
                    Column = new DataColumn("TubePosBarCode" + i.ToString());
                    Tubes.Columns.Add(Column);
                    Column = new DataColumn("TextItemCount" + i.ToString());
                    Column.DefaultValue = "0,0,#C0C0C0"; //是否扫描到,采血管、阴阳补、选择颜色 #FFC0CB
                    Tubes.Columns.Add(Column);
                    Column = new DataColumn("IconName" + i.ToString());
                    Tubes.Columns.Add(Column);
                    Column = new DataColumn("Visibility" + i.ToString());
                    Column.DefaultValue = "Hidden";//Collapsed Hidden Visible
                    Tubes.Columns.Add(Column);
                    Column = new DataColumn("IsEnabled" + i.ToString());
                    Column.DefaultValue = "True";//Collapsed Hidden Visible
                    Tubes.Columns.Add(Column);
                    Column = new DataColumn("IsSelected" + i.ToString());
                    Column.DefaultValue = "#316AC5";//Collapsed Hidden Visible
                    Tubes.Columns.Add(Column);
                    Column = new DataColumn("DetailView" + i.ToString());
                    Column.DefaultValue = "";//Collapsed Hidden Visible
                    Tubes.Columns.Add(Column);
                    Column = new DataColumn("DetailViewTime" + i.ToString());
                    Column.DefaultValue = DateTime.Now;//Collapsed Hidden Visible
                    Tubes.Columns.Add(Column);

                    Column = new DataColumn("TestingItem" + i.ToString());
                    Column.DefaultValue = "";//Collapsed Hidden Visible
                    Tubes.Columns.Add(Column);

                    Column = new DataColumn("Background" + i.ToString());
                    Column.DefaultValue = null;//Collapsed Hidden Visible
                    Tubes.Columns.Add(Column);
                }
                for (int i = 0; i < 16; i++)
                {
                    DataRow dataRow = Tubes.NewRow();
                    Tubes.Rows.Add(dataRow);
                }

                string scanFilePath = WanTai.Common.Configuration.GetEvoOutputPath() + WanTai.Common.Configuration.GetTubeScanResultFileName();
                if (System.IO.File.Exists(scanFilePath))
                {
                    System.IO.FileInfo fileInfo         = new System.IO.FileInfo(scanFilePath);
                    DateTime           fileModifiedTime = fileInfo.LastWriteTime;
                    if (DateTime.Compare(fileBeforeCreatedTime, fileModifiedTime) > 0)
                    {
                        ErrMsg = "System can not find the scan file";
                        throw new Exception("System can not find the scan file");
                    }
                }
                else
                {
                    ErrMsg = "System can not find the scan file";
                    throw new Exception("System can not find the scan file");
                }

                using (System.IO.StreamReader mysr = new System.IO.StreamReader(scanFilePath))
                {
                    string   strline;
                    string[] aryline;
                    strline = mysr.ReadLine();
                    //1(Position);1;1(Grid);Tube 13*100mm 16 Pos;Tube1;013/035678;11
                    while ((strline = mysr.ReadLine()) != null)
                    {
                        aryline = strline.Split(new char[] { ';' });
                        if (aryline[6] == "$$$" || aryline[6] == "")
                        {
                            continue;
                        }
                        int Position = int.Parse(aryline[0]);
                        int Grid     = int.Parse(aryline[2]) - 1;
                        Tubes.Rows[Grid]["Position" + Position.ToString()] = Position;
                        Tubes.Rows[Grid]["Grid" + Position.ToString()]     = Grid + 1;
                        Tubes.Rows[Grid]["BarCode" + Position.ToString()]  = aryline[6];
                        Tubes.Rows[Grid]["TubeType" + Position.ToString()] = Tubetype.Tube;
                        if (!string.IsNullOrEmpty(aryline[5]))
                        {
                            Tubes.Rows[Grid]["TubePosBarCode" + Position.ToString()] = aryline[5];
                        }
                        Tubes.Rows[Grid]["TextItemCount" + Position.ToString()] = "1,1,#C0C0C0";
                        Tubes.Rows[Grid]["IconName" + Position.ToString()]      = "1";
                        Tubes.Rows[Grid]["Visibility" + Position.ToString()]    = "Visible";
                        Tubes.Rows[Grid]["IsEnabled" + Position.ToString()]     = "True";
                        Tubes.Rows[Grid]["IsSelected" + Position.ToString()]    = "#316AC5";
                    }
                }
                StringBuilder builder = new StringBuilder();

                StringBuilder SystemFluidName = new StringBuilder();
                using (WanTai.DataModel.WanTaiEntities _WanTaiEntities = new WanTaiEntities())
                {
                    foreach (SystemFluidConfiguration _SystemFluidConfiguration in _WanTaiEntities.SystemFluidConfigurations)
                    {
                        if (Tubes.Rows[(int)(_SystemFluidConfiguration.Position - 1)]["TubeType" + _SystemFluidConfiguration.Grid.ToString()].ToString() == "-1")
                        {
                            continue;
                        }

                        if (Tubes.Rows[(int)(_SystemFluidConfiguration.Position - 1)]["TubeType" + _SystemFluidConfiguration.Grid.ToString()].ToString() == "Tube")
                        {
                            builder.Append("[" + _SystemFluidConfiguration.Grid.ToString() + "," + _SystemFluidConfiguration.Position.ToString() + "]");
                        }
                        Tubes.Rows[(int)(_SystemFluidConfiguration.Position - 1)]["TubeType" + _SystemFluidConfiguration.Grid.ToString()]   = (Tubetype)_SystemFluidConfiguration.ItemType;
                        Tubes.Rows[(int)(_SystemFluidConfiguration.Position - 1)]["Visibility" + _SystemFluidConfiguration.Grid.ToString()] = "Visible";
                        Tubes.Rows[(int)(_SystemFluidConfiguration.Position - 1)]["IsEnabled" + _SystemFluidConfiguration.Grid.ToString()]  = "True";
                        Tubes.Rows[(int)(_SystemFluidConfiguration.Position - 1)]["IsSelected" + _SystemFluidConfiguration.Grid.ToString()] = "#316AC5";
                        //  Tubes.Rows[(int)(_SystemFluidConfiguration.Position - 1)]["BarCode" + _SystemFluidConfiguration.Grid.ToString()] = Tubes.Rows[(int)(_SystemFluidConfiguration.Position - 1)]["BarCode" + _SystemFluidConfiguration.Grid.ToString()].ToString()+ "[不能分组]";
                        LiquidType _LiquidType = LiquidTypeList.Find(delegate(LiquidType lt) { return(lt.TypeId == _SystemFluidConfiguration.ItemType); });
                        if (_LiquidType != null)
                        {
                            Tubes.Rows[(int)(_SystemFluidConfiguration.Position - 1)]["TextItemCount" + _SystemFluidConfiguration.Grid.ToString()] = "1,2," + _LiquidType.Color;
                            SystemFluidName.Append(_LiquidType.TypeName + ";");
                        }
                    }
                    Tubes.TableName = builder.ToString();
                }
                string message = "";
                foreach (LiquidType _liquidType in LiquidTypeList)
                {
                    if (SystemFluidName.ToString().IndexOf(_liquidType.TypeName + ";") < 0)
                    {
                        message     += _liquidType.TypeName + "、";
                        SystemFluid += _liquidType.TypeId + ",";
                    }
                }
                if (message.Length > 0)
                {
                    ErrMsg = "没有" + message.Substring(0, message.Length - 1) + "!";
                }

                Tubes.Namespace = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                return(Tubes);
            }
            catch (Exception e)
            {
                string errorMessage = e.Message + System.Environment.NewLine + e.StackTrace;
                LogInfoController.AddLogInfo(LogInfoLevelEnum.Error, errorMessage, SessionInfo.LoginName, this.GetType().ToString() + "->" + "GetTubes()", SessionInfo.ExperimentID);
                throw;
            }
        }