示例#1
0
        /// <summary>
        /// 作者:Kylin
        /// 时间:2014.07.31
        /// 描述:查询学员学习累积进度详情
        /// </summary>
        /// <param name="list"></param>
        /// <returns></returns>
        public static bool CreateStudyProgressDetail(List<StudyProgressDetail> list)
        {
            try
            {
                using (var edb = new EmeReportsEntities())
                {
                    //using (var tran = new TransactionScope(TransactionScopeOption.Required))
                    {
                        foreach (var model in list)
                        {
                            if (
                                !edb.StudyProgressDetail.Any(p => p.BranchId == model.BranchId && EntityFunctions.DiffDays(p.OprDate, model.OprDate) == 0 && p.ProductSCode == model.ProductSCode && p.RateCourses == model.RateCourses.Value))
                            {
                                edb.Entry(model).State = EntityState.Added;
                            }
                        }
                        var result = edb.SaveChanges() > 0;
                        //tran.Complete();
                        return result;
                    }
                }
            }
            catch (Exception ex)
            {
                // 异常日志消息队列
                var edb = new EmeLogsEntities();
                var exceptrionLog = new ExceptionLogs()
                {
                    ExceptionType = CommonHelper.To<int>(ExceptionType.Function),
                    Message = string.Format("ServiceReportBLL-CreateStudyProgressDetail:{0};{1};{2}", ex.Message, ex.InnerException.Message, ex.HelpLink),
                    IsTreat = false,
                    CreateBy = null,
                    CreateTime = DateTime.Now
                };
                edb.Entry(exceptrionLog).State = EntityState.Added;
                edb.SaveChanges();

                return false;
            }
        }
示例#2
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="areaId"></param>
 /// <param name="oprDate"></param>
 /// <returns></returns>
 public static bool IsExistReportByDate(int areaId, DateTime oprDate)
 {
     using (var edb = new EmeReportsEntities())
     {
         return edb.StudyProgressTotal.Any(p => p.OprDate == oprDate && p.AreaId == areaId);
     }
 }
示例#3
0
 /// <summary>
 /// 作者:Kylin
 /// 时间:2014.03.13
 /// 描述:查询学员学习累积进度
 /// </summary>
 /// <param name="searchDate"></param>
 /// <param name="productSCode"></param>
 /// <param name="rateCourses"></param>
 /// <returns></returns>
 public static List<StudyProgressTotal> GetStudyProgressTotal(DateTime searchDate, string productSCode, decimal rateCourses)
 {
     using (var edb = new EmeReportsEntities())
     {
         return edb.StudyProgressTotal.AsNoTracking().Where(p => p.OprDate == searchDate
             && p.ProductSCode == productSCode
                     && p.RateCourses == rateCourses).ToList();
     }
 }
示例#4
0
 /// <summary>
 /// 作者:Kylin
 /// 时间:2014.03.13
 /// 描述:查询学员学习累积进度
 /// </summary>
 /// <param name="searchDate"></param>
 /// <param name="areaId"></param>
 /// <param name="productSCode"></param>
 /// <param name="rateCourses"></param>
 /// <returns></returns>
 public static List<StudyProgressTotal> GetStudyProgressTotal(int areaId, DateTime searchDate, string productSCode, decimal rateCourses)
 {
     using (var edb = new EmeReportsEntities())
     {
         if (areaId == 0)//全国
         {
             return
                 edb.StudyProgressTotal.AsNoTracking()
                     .Where(p => EntityFunctions.DiffDays(p.OprDate, searchDate) == 0
                         && p.ProductSCode == productSCode
                         && p.RateCourses == rateCourses)
                     .ToList();
         }
         else
         {
             return
                 edb.StudyProgressTotal.AsNoTracking()
                     .Where(p => p.AreaId == areaId
                         && EntityFunctions.DiffDays(p.OprDate, searchDate) == 0
                         && p.ProductSCode == productSCode
                         && p.RateCourses == rateCourses)
                     .ToList();
         }
     }
 }
示例#5
0
 /// <summary>
 /// 作者:Kylin
 /// 时间:2014.08.26
 /// 描述:查询学员学习累积进度详情
 /// </summary>
 /// <param name="saId"></param>
 /// <param name="branchId"></param>
 /// <param name="searchDate"></param>
 /// <param name="productSCode"></param>
 /// <param name="rateCourses"></param>
 /// <returns></returns>
 public static List<StudentStudyProgressDetail> GetStudentStudyProgressDetailTotal(int branchId, int saId, DateTime searchDate, string productSCode, decimal rateCourses)
 {
     using (var edb = new EmeReportsEntities())
     {
         return edb.StudentStudyProgressDetail.AsNoTracking().Where(p => p.BranchId == branchId && p.SAId == saId
             && EntityFunctions.DiffDays(p.OprDate, searchDate) == 0
               && p.ProductSCode == productSCode
                     && p.RateCourses == rateCourses).ToList();
     }
 }
示例#6
0
 /// <summary>
 /// 作者:Kylin
 /// 时间:2014.07.31
 /// 描述:除员学习累积进度详情
 /// </summary>
 /// <param name="oprDate"></param>
 /// <param name="synFromFun"></param>
 /// <returns></returns>
 public static ObjectResult<int?> DeleteStudyProgressDetail(DateTime oprDate, string synFromFun)
 {
     using (var edb = new EmeReportsEntities())
     {
         return edb.DeleteStudyProgressDetail(oprDate, synFromFun);
     }
 }
示例#7
0
        /// <summary>
        /// 作者:Kylin
        /// 时间:2015.2.06
        /// 描述:Syn Create Study Progress 
        /// </summary>
        /// <param name="rateCoursesType"></param>
        /// <param name="productSCodes"></param>
        /// <param name="oprDate"></param>
        public static void SynCreateStudyProgress(string[] rateCoursesType, IEnumerable<string> productSCodes, DateTime oprDate)
        {
            var edb = new EmeReportsEntities();
            try
            {
                if (!edb.SynLog.Any(p => EntityFunctions.DiffDays(p.SynDate, oprDate) == 0))
                {

                    var addSynLogItem = new SynLog
                    {
                        Remark = string.Format("Eme.BLL.Eme.SynCreateStudyProgress begin syn create progress detail!{0} ", DateTime.Now),
                        SynDate = oprDate,
                        SynFlag = ConvertEnum.SynFlagForSynchronizing,
                        SynFrom = "Eme.BLL.Eme.SynCreateStudyProgress",
                        CreateTime = DateTime.Now
                    };
                    edb.Entry(addSynLogItem).State = EntityState.Added;
                    edb.SaveChanges();

                    CreateStudyProgress(rateCoursesType, productSCodes, oprDate);

                    var addItem = edb.SynLog.SingleOrDefault(p => EntityFunctions.DiffDays(p.SynDate, oprDate) == 0 && p.SynFrom == "Eme.BLL.Eme.SynCreateStudyProgress");
                    if (addItem != null)
                    {
                        addItem.SynFlag = ConvertEnum.SynFlagForSuccess;
                        addItem.Remark = string.Format("Eme.BLL.Eme.SynCreateStudyProgress; update by system at{0} ; create success!", DateTime.Now);
                        edb.Entry(addItem).State = EntityState.Modified;
                        edb.SaveChanges();
                    }
                }
                else if (edb.SynLog.Any(p => EntityFunctions.DiffDays(p.SynDate, oprDate) == 0 && p.SynFlag == ConvertEnum.SynFlagForFailed))
                {
                    var restult = edb.DeleteStudyProgressDetail(oprDate, "Eme.BLL.Eme.SynCreateStudyProgress");
                    if (restult.Any(p => p <= 0))
                    {
                        CreateStudyProgress(rateCoursesType, productSCodes, oprDate);
                    }
                }
            }
            catch (Exception ex)
            {
                // 异常日志消息队列
                var addItem = edb.SynLog.SingleOrDefault(p => EntityFunctions.DiffDays(p.SynDate, oprDate) == 0 && p.SynFrom == "Eme.BLL.Eme.SynCreateStudyProgress");
                if (addItem != null)
                {
                    addItem.SynFlag = ConvertEnum.SynFlagForFailed;
                    addItem.Remark = string.Format("ReportBLL-Eme.BLL.Eme.SynCreateStudyProgress:{0};{1};{2}",
                        ex.Message, ex.InnerException.Message, ex.HelpLink);
                    addItem.CreateTime = DateTime.Now;
                    edb.Entry(addItem).State = EntityState.Modified;
                }
                else
                {
                    addItem = new SynLog
                    {
                        SynFlag = ConvertEnum.SynFlagForFailed,
                        Remark = string.Format("ReportBLL-Eme.BLL.Eme.SynCreateStudyProgress:{0};{1};{2};{3}",
                            ex.Message, ex.InnerException.Message, ex.HelpLink, DateTime.Now)
                    };
                    edb.Entry(addItem).State = EntityState.Added;
                }
                edb.SaveChanges();
            }
        }