Ejemplo n.º 1
0
        public string getNoticeContent(string optype)
        {
            List <Notice> notices = NoticeRepository.getNoticeContent();
            string        result  = string.Empty;

            if (notices.Count > 0)
            {
                foreach (var item in notices)
                {
                    if (DateTime.Compare(item.Start_Time, DateTime.Now) < 0 && item.State == "未开始")
                    {
                        var dt = NoticeRepository.GetById(item.UID);
                        dt.State = "进行中";
                        NoticeRepository.Update(dt);
                        unitOfWork.Commit();
                        if (item.Scope.Trim() == optype.Trim())
                        {
                            result += item.Notice_Content + "                              ";
                        }
                    }
                    else if (DateTime.Compare(item.End_Time, DateTime.Now) < 0)
                    {
                        var dt = NoticeRepository.GetById(item.UID);
                        dt.State = "已过时";
                        NoticeRepository.Update(dt);
                        unitOfWork.Commit();
                    }
                    else if (item.Scope.Trim() == optype.Trim())
                    {
                        result += item.Notice_Content + "                                 ";
                    }
                }
            }
            return(result);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 删
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public ExcutedResult DeleteNoticeInfo(string id)
 {
     try
     {
         Guid guid = Guid.Empty;
         if (string.IsNullOrEmpty(id) || !Guid.TryParse(id, out guid))
         {
             throw new BusinessException(BusinessResultCode.ArgumentError, "参数错误或无效");
         }
         var notice = _noticeRepository.GetById(guid);
         if (notice == null)
         {
             throw new BusinessException(BusinessResultCode.DataNotExist, "数据不存在,请刷新!");
         }
         else
         {
             _noticeRepository.Delete(notice);
             return(ExcutedResult.SuccessResult());
         }
     }
     catch (BusinessException businessException)
     {
         return(ExcutedResult.FailedResult(businessException.ErrorCode, businessException.Message));
     }
     catch (Exception ex)
     {
         return(ExcutedResult.FailedResult(SysResultCode.ServerException, "发生异常,请稍后再试或联系管理员"));
     }
 }
Ejemplo n.º 3
0
        public bool DeleteNotice(long id)
        {
            bool isSuccess = true;
            var  notice    = noticeRepository.GetById(id);

            try
            {
                noticeRepository.Delete(notice);
                SaveRecord();
                ServiceUtil <Notice> .WriteActionLog(id, ENUMOperation.DELETE);
            }
            catch (Exception ex)
            {
                isSuccess = false;
                logger.Error("Error in deleting Notice", ex);
            }
            return(isSuccess);
        }