using iWareCommon.Utils;
using iWareSql.WmsDBModel;
using System;
using System.Linq;
namespace iWareSql.DataAccess
{
public class WmsConfigEncryptionHandler
{
///
/// 是否触发
///
///
///
public static bool IsTrigger(WmsDBModel.WmsDBModel edm)
{
//模拟
//return true;
var dbList = edm.wms_config_encryption.Where(x => x.IsDelete == false).ToList();
if (dbList?.Count > 0)
{
var fisrt = dbList.OrderBy(x => x.Id).First();
//解密时间
var deTime = DESEncryptHelper.Decrypt(fisrt.IssueTime);
var valieTime = Convert.ToDateTime(deTime);
var nowTime = DateTime.Now;
if (nowTime > valieTime)
{
return true;
}
return false;
}
return false;
//*/
}
///
/// 是否验证密码成功
///
///
///
public static bool ValidtePassword(WmsDBModel.WmsDBModel edm, string valiPasswrod)
{
var dbList = edm.wms_config_encryption.ToList();
if (dbList?.Count > 0)
{
var fisrt = dbList.Where(x => x.IsDelete == false).OrderBy(x => x.Id).First();
var dePassword = DESEncryptHelper.Decrypt(fisrt.PassWord);
if (valiPasswrod == dePassword)
{
//删除该数据
edm.wms_config_encryption.Remove(fisrt);
edm.SaveChanges();
return true;
}
return false;
}
return false;
}
}
}