Пример #1
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);
     }
 }
Пример #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();
            }
        }