using Model;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Tool
{
public class SqlHelper
{
private ConnectionConfig connection2 = null;
public SqlSugarClient db2 = null;
private ConnectionConfig connection3 = null;
public SqlSugarClient db3 = null;
public SqlHelper()
{
string SqlIP2 = "192.168.2.2";
string SqlIP3 = "192.168.2.3";
string database = "MESDB";
string uid = "sa";
string pwd = "8ik,9ol.";
connection2 = new ConnectionConfig()
{
ConnectionString = "server='" + SqlIP2 + "';initial catalog='" + database + "';uid='" + uid + "';pwd='" + pwd + "'",
DbType = DbType.SqlServer,
IsAutoCloseConnection = true,
InitKeyType = InitKeyType.Attribute
};
db2 = new SqlSugarClient(connection2);
connection3 = new ConnectionConfig()
{
ConnectionString = "server='" + SqlIP3 + "';initial catalog='" + database + "';uid='" + uid + "';pwd='" + pwd + "'",
DbType = DbType.SqlServer,
IsAutoCloseConnection = true,
InitKeyType = InitKeyType.Attribute
};
db3 = new SqlSugarClient(connection3);
}
#region t_CMCC_Jinji
[SugarTable("t_CMCC_Jinji")]
public class t_CMCC_Jinji
{
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
public int id { get; set; }
public string type { get; set; }
public string snimei { get; set; }
public string inname { get; set; }
public DateTime? inTime { get; set; }
public string endname { get; set; }
public DateTime? endTime { get; set; }
}
#endregion
#region t_CMCC_JinjiPower
[SugarTable("t_CMCC_JinjiPower")]
public class t_CMCC_JinjiPower
{
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
public int id { get; set; }
public string type { get; set; }
public string snimei { get; set; }
public string Devcode { get; set; }
public string Band { get; set; }
public string Channel { get; set; }
public string Result { get; set; }
public string kind { get; set; }
public string textname { get; set; }
public string Powername { get; set; }
public DateTime? PowerTime { get; set; }
}
#endregion
#region t_CMCC_JinjiLine
[SugarTable("t_CMCC_JinjiLine")]
public class t_CMCC_JinjiLine
{
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
public int id { get; set; }
///
/// 机型
///
public string type { get; set; }
///
/// 金机编码
///
public string snimei { get; set; }
///
/// 夹具号
///
public string Devcode { get; set; }
///
/// 类别
///
public string kind { get; set; }
///
/// 第几项线损
///
public string several_line_loss { get; set; }
public string LTE_BAND_TX_LOW_LOSS { get; set; }
public string LTE_BAND_TX_MID_LOSS { get; set; }
public string LTE_BAND_TX_HIGH_LOSS { get; set; }
public string LTE_BAND_RX_LOW_LOSS { get; set; }
public string LTE_BAND_RX_MID_LOSS { get; set; }
public string LTE_BAND_RX_HIGH_LOSS { get; set; }
///
/// 线损文件名称
///
public string textname { get; set; }
///
/// 录入人员名称
///
public string Linename { get; set; }
///
/// 录入时间
///
public DateTime? LineTime { get; set; }
}
#endregion
#region t_DD_UserDetail
[SugarTable("t_DD_UserDetail")]
public class t_DD_UserDetail
{
///
/// 姓名
///
public string username { get; set; }
///
/// 工号
///
public string jobnumber { get; set; }
///
/// 公司
///
public string companyName { get; set; }
///
/// 部门
///
public string workPlace { get; set; }
///
/// 职位
///
public string position { get; set; }
}
#endregion
public UserModel GetUser(string jobnumber)
{
try
{
var userModel = db2.Queryable().Where(it => it.jobnumber == jobnumber && it.companyName == "重庆盟讯电子科技有限公司").First();
if (userModel == null)
{
return null;
}
return new UserModel() { userName = jobnumber, nickName = userModel.username, bumen = userModel.workPlace, zhiwei = userModel.position };
}
// return db.Queryable().Where(it => it.jobnumber == jobnumber && it.companyName == "重庆盟讯电子科技有限公司").First().username;
//}
catch (System.Exception ee)
{
LogHelper.WriteLog(ee.ToString());
throw ee;
}
}
}
}