/// <summary>
 /// 根据模具号、操作员号、起止日期、页码信息获得模具放行信息
 /// </summary>
 /// <param name="moldNR">模具号</param>
 /// <param name="pageIndex">页码</param>
 /// <param name="pageSize">页码数量</param>
 /// <returns>模具放行信息列表</returns>
 public List<MoldReleaseInfo> GetMoldReleaseInfoByMoldNRInPage(string moldNR, int pageIndex, int pageSize, string operatorId, DateTime? startDate, DateTime? endDate)
 {
     using (IUnitOfWork unitwork = MSSqlHelper.DataContext())
     {
         IReportRepository reportRep = new ReportRepository(unitwork);
         List<ReportView> reports = reportRep.GetReportViewByMoldNR(moldNR, pageIndex, pageSize, operatorId, startDate, endDate);
         IAttachmentRepository attachRep = new AttachmentRepository(unitwork);
         List<MoldReleaseInfo> moldReleaseInfos = new List<MoldReleaseInfo>();
         foreach (ReportView r in reports)
         {
             MoldReleaseInfo moldReleaseInfo = new MoldReleaseInfo()
             {
                 TesterName = r.Name,
                 TesterNR = r.OperatorID,
                 Date = r.Date,
                 TargetNR = r.MoldID,
                 ReportType = r.ReportType,
                 ReportTypeCN = r.ReportTypeCN,
                 Attach = attachRep.GetByMasterNR(r.ReportId.ToString())
             };
             moldReleaseInfos.Add(moldReleaseInfo);
         }
         return moldReleaseInfos;
     }
 }
 public List<ReportView> GetReportViewByDate(ReportType type,DateTime? startDate, DateTime? endDate)
 {
     using (IUnitOfWork unitwork = MSSqlHelper.DataContext())
     {
         IReportRepository reportRep = new ReportRepository(unitwork);
         return reportRep.GetReportViewByDate(type,startDate, endDate);
     }
 }
        /// <summary>
        /// 模具测试
        /// </summary>
        /// <param name="moldNR">模具号</param>
        /// <param name="operatorNR">操作员工号</param>
        /// <param name="files">文件列表</param>
        /// <returns>测试信息</returns>
        public Message MoldTest(string moldNR, string operatorNR, FileUP[] files,int currentCutTimes,bool moldNormal)
        {
            try
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    using (IUnitOfWork unitwork = MSSqlHelper.DataContext())
                    {
                        IReportRepository reportRep = new ReportRepository(unitwork);

                        Report report = new Report();
                        report.ReportId = GuidUtil.GenerateGUID();
                        report.MoldID = moldNR;
                        report.ReportType = ReportType.TestReport;
                        report.OperatorID = operatorNR;
                        report.Date = DateTime.Now;

                        //upload files
                        FileUpLoad(files, report.ReportId.ToString());

                        reportRep.Add(report);

                        // update the last released date
                        IMoldRepository moldRep = new MoldRepository(unitwork);
                        Mold mold = moldRep.GetById(moldNR);
                        mold.LastReleasedDate = report.Date;
                        mold.Cuttedtimes += mold.CurrentCuttimes;
                        mold.CurrentCuttimes = 0;
                        if (moldNormal)
                            mold.State = MoldStateType.Normal;
                        unitwork.Submit();

                        ts.Complete();

                        return new Message() { MsgType = MsgType.OK, Content = "实验报告上传成功!" };
                    }
                }
            }
            catch (Exception ex)
            {
                  LogUtil.log.Error(ex.ToString());
                return new Message() { MsgType = MsgType.Error, Content = ex.Message };
            }
        }