using HighWayIot.Log4net;
using HighWayIot.Repository.domain;
using Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
namespace HighWayIot.Repository.service
{
///
/// 配方同步接口
///
public class ZxMesPlanTransferService
{
private static readonly Lazy lazy = new Lazy(() => new ZxMesPlanTransferService());
public static ZxMesPlanTransferService Instance
{
get
{
return lazy.Value;
}
}
private LogHelper log = LogHelper.Instance;
Repository _repository => new Repository("sqlserver");
///
/// 查询所有物料类别信息
///
///
public List GetRecipeInfos()
{
try
{
List entity = _repository.GetList();
return entity;
}
catch (Exception ex)
{
log.Error("配方同步信息获取异常", ex);
return null;
}
}
///
/// 查询所有物料类别信息
///
///
public List GetRecipeInfos(Expression> whereExpression)
{
try
{
List entity = _repository.GetList(whereExpression);
return entity;
}
catch (Exception ex)
{
log.Error("配方同步信息获取异常", ex);
return null;
}
}
///
/// 更新基准数据标识为True
///
///
public bool SetFlagTrue()
{
try
{
var result = _repository.Update(x => new ZxMesPlanTransferEntity() { RequestFlag = true }, x => x.RequestFlag == false);
return result;
}
catch (Exception ex)
{
log.Error("配方同步基准信息修改异常", ex);
return false;
}
}
///
/// 获取更新基准数据标识状态
///
///
public bool GetFlagState()
{
try
{
var result = _repository.GetById("syncsignal").RequestFlag;
return result ?? true;
}
catch (Exception ex)
{
log.Error("配方同步基准信息标识获取异常", ex);
return true;
}
}
/////
///// 有更无插
/////
/////
//public int UpdateOrAddInfos(List lists)
//{
// try
// {
// return _repository.Context.Storageable(lists).WhereColumns(x => x.RecipeName).ExecuteCommand();
// }
// catch (Exception ex)
// {
// log.Error($"更新配方数据失败", ex);
// return 0;
// }
//}
}
}