public void AddProductUPHInfo(ProductUPHInfo itemui) { string methodName = MethodBase.GetCurrentMethod().Name; BaseLog.LoggingBegin(logger, methodName); try { ProductUPH items = new ProductUPH { Date = itemui.Date, Line = itemui.Line, Lesson = itemui.Lesson, TimeRange = itemui.TimeRange, Family = itemui.Family, ProductRatio = itemui.ProductRatio }; using (UnitOfWork uow = new UnitOfWork()) { IRepository<ProductUPH> ecoModelRep = new Repository<ProductUPH>("UPHDBServer"); ecoModelRep.Insert(items); uow.Commit(); } } catch (Exception e) { BaseLog.LoggingError(logger, MethodBase.GetCurrentMethod(), e); throw; } finally { BaseLog.LoggingEnd(logger, methodName); } }
public bool CheckDuplicateData(ProductUPHInfo item) { bool re = false; string methodName = MethodBase.GetCurrentMethod().Name; BaseLog.LoggingBegin(logger, methodName); IList<ProductUPHInfo> ret = new List<ProductUPHInfo>(); try { IRepository<ProductUPH> ecoModelRep = new Repository<ProductUPH>("UPHDBServer");//连接字符串 查询ProductUPH 表的数据 ret = (from q in ecoModelRep.Query() where q.Date == item.Date && q.Line == item.Line select new ProductUPHInfo { Date = q.Date, Line = q.Line, Lesson = q.Lesson, TimeRange = q.TimeRange, Family = q.Family, ProductRatio = q.ProductRatio }).ToList(); if (ret.Count != 0) { re = true; //throw new Exception("Duplicate AstCode!"); } return re; } catch (Exception e) { BaseLog.LoggingError(logger, MethodBase.GetCurrentMethod(), e); throw; } finally { BaseLog.LoggingEnd(logger, methodName); } }