You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
using ProductionSystem_Log;
|
|
|
|
|
using ProductionSystem_Model.DbModel.System;
|
|
|
|
|
using ProductionSystem_Model.ViewModel;
|
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
namespace ProductionSystem_Service
|
|
|
|
|
{
|
|
|
|
|
public class BaseSettingService : DbContext
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 查询基础配置
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public Sys_Base_Setting GetBaseSetting()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
return db.Queryable<Sys_Base_Setting>().First();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogHelper.Error(ex, "执行BaseSettingService下GetBaseSetting时异常");
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 更新基础配置
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="t_User"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public (bool isOk, string msg) UpdateBaseSetting(Sys_Base_Setting sysBaseSetting)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var row = db.Updateable<Sys_Base_Setting>()
|
|
|
|
|
.SetColumns(c => c.LineName == sysBaseSetting.LineName)
|
|
|
|
|
.SetColumns(c => c.PlcIp == sysBaseSetting.PlcIp)
|
|
|
|
|
.SetColumns(c => c.PlcPort == sysBaseSetting.PlcPort)
|
|
|
|
|
.SetColumns(c => c.ReadRate == sysBaseSetting.ReadRate)
|
|
|
|
|
.SetColumns(c => c.Remark == sysBaseSetting.Remark)
|
|
|
|
|
.SetColumns(c => c.UpdatedTime == DateTime.Now)
|
|
|
|
|
.SetColumns(c => c.UpdatedBy == CurrentUser.UserName)
|
|
|
|
|
.Where(m => m.Id == sysBaseSetting.Id)
|
|
|
|
|
.ExecuteCommand();
|
|
|
|
|
return (row > 0, row > 0 ? "操作成功!" : "操作失败!");
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
var errorMsg = $"执行BaseSettingService下UpdateBaseSetting时异常:{ex.Message}";
|
|
|
|
|
LogHelper.Error(ex, errorMsg);
|
|
|
|
|
return (false, errorMsg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|