/// <summary>
        /// 根据模具警报类型获得模具警报信息
        /// </summary>
        /// <param name="type">模具警报类型</param>
        /// <returns>模具警报信息列表</returns>
        public List <MoldWarnInfo> GetMoldWarnInfo(MoldWarnType type)
        {
            using (IUnitOfWork unitwork = MSSqlHelper.DataContext())
            {
                IMoldRepository     moldRepostitory = new MoldRepository(unitwork);
                List <MoldView>     molds           = moldRepostitory.GetByWarnType(type);
                List <MoldWarnInfo> moldWarnInfos   = new List <MoldWarnInfo>();

                foreach (MoldView m in molds)
                {
                    MoldWarnInfo moldWarnInfo = new MoldWarnInfo()
                    {
                        MoldNR          = m.MoldNR,
                        Type            = m.TypeName,
                        ProjectName     = m.ProjectName,
                        MaxLendHour     = (double)m.MaxLendHour,
                        LendTime        = (DateTime)m.LastRecordDate,
                        CurrentPosition = m.StorageRecordNR.HasValue ? moldRepostitory.GetMoldCurrPosiByRecordNR((Guid)m.StorageRecordNR) : string.Empty
                    };
                    moldWarnInfos.Add(moldWarnInfo);
                }

                return(moldWarnInfos);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 根据模具警报状态获得模具视图
        /// </summary>
        /// <param name="type">模具警报状态</param>
        /// <returns>模具视图列表</returns>
        public List <MoldView> GetByWarnType(MoldWarnType type)
        {
            List <MoldView> molds = type == MoldWarnType.OutTime ?
                                    (context.MoldView.Where(m => (m.State == MoldStateType.NotReturned) && (m.LastRecordDate.Value.AddHours((double)m.MaxLendHour) < DateTime.Now)).ToList())
                : (context.MoldView.Where(m => (m.State == MoldStateType.NotReturned) && (m.LastRecordDate.Value.AddHours((double)m.MaxLendHour) >= DateTime.Now)).ToList());

            return(molds.Distinct().ToList());
        }
Exemplo n.º 3
0
 /// <summary>
 /// 根据模具警报状态获得模具视图
 /// </summary>
 /// <param name="type">模具警报状态</param>
 /// <returns>模具视图列表</returns>
 public List<MoldView> GetByWarnType(MoldWarnType type)
 {
     List<MoldView> molds = type == MoldWarnType.OutTime ?
         (context.MoldView.Where(m => (m.State == MoldStateType.NotReturned) && (m.LastRecordDate.Value.AddHours((double)m.MaxLendHour) < DateTime.Now)).ToList())
         : (context.MoldView.Where(m => (m.State == MoldStateType.NotReturned) && (m.LastRecordDate.Value.AddHours((double)m.MaxLendHour) >= DateTime.Now)).ToList());
     return molds.Distinct().ToList();
 }
        /// <summary>
        /// 根据模具警报类型获得模具警报信息
        /// </summary>
        /// <param name="type">模具警报类型</param>
        /// <returns>模具警报信息列表</returns>
        public List<MoldWarnInfo> GetMoldWarnInfo(MoldWarnType type)
        {
            using (IUnitOfWork unitwork = MSSqlHelper.DataContext())
            {
                IMoldRepository moldRepostitory = new MoldRepository(unitwork);
                List<MoldView> molds = moldRepostitory.GetByWarnType(type);
                List<MoldWarnInfo> moldWarnInfos = new List<MoldWarnInfo>();

                foreach (MoldView m in molds)
                {
                    MoldWarnInfo moldWarnInfo = new MoldWarnInfo()
                    {
                        MoldNR = m.MoldNR,
                        Type = m.TypeName,
                        ProjectName = m.ProjectName,
                        MaxLendHour = (double)m.MaxLendHour,
                        LendTime = (DateTime)m.LastRecordDate,
                        CurrentPosition = m.StorageRecordNR.HasValue ? moldRepostitory.GetMoldCurrPosiByRecordNR((Guid)m.StorageRecordNR) : string.Empty
                    };
                    moldWarnInfos.Add(moldWarnInfo);
                }

                return moldWarnInfos;
            }
        }