Exemple #1
0
 /// <summary>
 /// 作者:Kylin
 /// 时间:2014.08.26
 /// 描述:创建SA下学员学习累积进度详情
 /// </summary>
 /// <param name="list"></param>
 /// <returns></returns>
 public static bool CreateSAStudentStudyProgressDetail(List<StudentStudyProgressDetail> list)
 {
     try
     {
         using (var edb = new EmeReportsEntities())
         {
             // using (var tran = new TransactionScope(TransactionScopeOption.Required))
             {
                 foreach (var model in list)
                 {
                     if (
                         !edb.StudentStudyProgressDetail.Any(p => p.BranchId == model.BranchId && p.SAId == model.SAId && 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-CreateSAStudentStudyProgressDetail:{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;
     }
 }
Exemple #2
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();
            }
        }