schangxiang@126.com
2025-11-04 f5ed29dc26c7cd952d56ec5721a2efc43cd25992
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
using DataEntity;
using DataEntity.Device;
using DataEntity.Page;
using DataEntity.Share;
using DataRWDAL.Base;
using HxEnum;
using MySql.Data.MySqlClient;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Data;
using XCommon.Log;
using XCommon.MySql;
using XCommon.SqlSugar;
using XImagingXhandler.XDAL;
 
namespace DataRWDAL
{
    public class ExperimentRunChoiceBacteraDB : BaseDB
    {
 
        /// <summary>
        /// 根据设备Id,获取设备信息
        /// </summary>
        /// <param name="runChoiceBacteraId"></param>
        /// <returns></returns>
        public static ExperimentRunChoiceBacteraModel GetInfodById(string runChoiceBacteraId)
        {
            using (var db = GetInstance())
            {
                var model = db.Queryable<ExperimentRunChoiceBacteraModel>().Single(it => it.RunChoiceBacteraId.Equals(runChoiceBacteraId));
                model.IdentificationName =
                        EnumManagement.GetEnumDescription(EnumManagement.GetField<IdentificationEnum>(model.Identification));
 
                return model;
            }
        }
 
        #region 获取分页数据
        /// <summary>
        /// 获取分页数据
        /// </summary>
        /// <param name="pagination"></param>
        /// <param name="condition"></param>
        /// <returns></returns>
        public static Tuple<List<ExperimentRunChoiceBacteraModel>, int> GetPageData(Pagination pagination, ExperimentRunChoiceBacteraModel condition)
        {
            using (var db = GetInstance())
            {
                var whereExpression = LinqExtensions.True<ExperimentRunChoiceBacteraModel>();
                if (condition.StartTime != DateTime.MinValue)
                {
                    whereExpression = whereExpression.And(it => it.TakePhotoTime >= condition.StartTime);
                }
                if (condition.EndTime != DateTime.MinValue)
                {
                    whereExpression = whereExpression.And(it => it.TakePhotoTime <= condition.EndTime);
                }
                if (!string.IsNullOrEmpty(condition.SourceBarcode))
                {
                    whereExpression = whereExpression.And(it => it.SourceBarcode.Contains(condition.SourceBarcode));
                }
                if (condition.Identification != -1)
                {
                    whereExpression = whereExpression.And(it => it.Identification == condition.Identification);
                }
                if (!string.IsNullOrEmpty(condition.ExperimentId))
                {
                    whereExpression = whereExpression.And(it => it.ExperimentId.Contains(condition.ExperimentId));
                }
 
                // u => u.Sort
                return GetPage<ExperimentRunChoiceBacteraModel>(pagination, whereExpression, u => u.TakePhotoTime, OrderByType.Desc);
            }
        }
        #endregion
 
        #region 登录挑菌数据
        /// <summary>
        /// 登录挑菌数据
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static int Add(ExperimentRunChoiceBacteraModel model)
        {
            using (var db = GetInstance())
            {
                Shared.ExpChoiceBactera = model;
                return db.Insertable<ExperimentRunChoiceBacteraModel>(model).ExecuteCommand();
            }
        }
        #endregion
    }
}