コード例 #1
0
 public Result Delete(Model.DB.User model)
 {
     UserRA.Delete(model.id.ToString());
     MessageBiz.Send(model.id.ToString(), MessageTypeEnum.User_Forbidden);
     model.created_by = user_id;
     return(Result(UserDA.Delete(model)));
 }
コード例 #2
0
 public MessageService(IPushNotificationProvider pushNotificationProvider)
 {
     PushNotification = pushNotificationProvider;
     UnitOfWork       = new CoreUnitOfWork();
     MessageBiz       = new MessageBiz(UnitOfWork);
     NotificationBiz  = new NotificationBiz(UnitOfWork);
 }
コード例 #3
0
        /// <summary>
        /// 自动的执行任务
        /// </summary>
        /// <remarks>
        /// Interval 单位为毫秒
        /// Begin 从 2019-1-1 0:0:0 开始计时执行
        /// </remarks>
        public override void Run()
        {
            if (!enableXmpp)
            {
                return;
            }

            var stopwatch = new Stopwatch();

            stopwatch.Start();

            Logger.Info("开始保存聊天消息数据");

            MessageBiz biz   = new MessageBiz();
            int        count = biz.Save2DB();

            stopwatch.Stop();

            if (count >= 0)
            {
                Logger.Info($"聊天消息数据保存完成,共处理条 {count} 数据。耗时:{ToTime(stopwatch.ElapsedMilliseconds)}");
            }
            else
            {
                Logger.Error("聊天消息数据保存失败");
            }
        }
コード例 #4
0
 public DataSourceResult ReadSentMessages(DataSourceRequest request, UserIdentity user)
 {
     return(MessageBiz
            .Read(message => message.SenderId == user.UserId, noTracking: true)
            .OrderByDescending(message => message.CreateDate)
            .Include(message => message.Receiver)
            .MapTo <MessagePM>()
            .ToDataSourceResult(request));
 }
コード例 #5
0
        public void CreateMessage(int senderId, int receiverId, string text)
        {
            var message      = MessageBiz.Add(senderId, receiverId, text);
            var notification = NotificationBiz.Add(NotificationType.WriteMessage, senderId, null, receiverId);

            UnitOfWork.SaveChanges();

            // Send notification
            PushNotification.Send(receiverId, PushNotificationType.NewNotification, NotificationBiz.ProcessNotification(notification).GetNotificationPM());
        }
コード例 #6
0
        public void DeleteMessages(IEnumerable <int> ids, UserIdentity user)
        {
            //TODO: put here a security check
            var messages = ids.Select(id => new Message()
            {
                Id = id
            });

            messages.ForEach(message => MessageBiz.Remove(message));
            UnitOfWork.SaveChanges();
        }
コード例 #7
0
 public AppStatisticsService()
 {
     UnitOfWork         = new CoreUnitOfWork();
     ArticleBiz         = new ArticleBiz(UnitOfWork);
     BlogBiz            = new BlogBiz(UnitOfWork);
     VisitBiz           = new VisitBiz(UnitOfWork);
     UserBiz            = new UserBiz(UnitOfWork);
     CommentBiz         = new CommentBiz(UnitOfWork);
     MessageBiz         = new MessageBiz(UnitOfWork);
     FeaturedContentBiz = new FeaturedContentBiz(UnitOfWork);
 }
コード例 #8
0
        public Result UpdateStatusOrder(StatusOrder model)
        {
            string status_order = ((int)model.status).ToString();

            if (UserRA.Exists(model.id.ToString()))
            {
                UserRA.Set(model.id.ToString(), "status_order", status_order);
            }
            MessageBiz.Send(model.id.ToString(), MessageTypeEnum.User_Order_Status, status_order);
            return(Result(UserDA.UpdateStatusOrder(model)));
        }
コード例 #9
0
        public DashboardModelContainer GetUserDashboardData(int userId)
        {
            var today = DateTime.Now.Date;

            return(new DashboardModelContainer()
            {
                PendingComments = CommentBiz.ReadNotConfirmedComments(userId).Take(4).MapTo <CommentInfoPM>().ToList(),
                ArticlesCount = ArticleBiz.ReadUserPublishedContents(userId, ContentType.Article).Count(),
                BlogPostsCount = BlogBiz.ReadUserTotalPublishedPostsCount(userId),
                TodayTotallVisits = VisitBiz.ReadUserTodayTotalVisits(userId),
                LatestMessages = MessageBiz.ReadUserMessages(userId, 4).MapTo <MessagePM>().ToList()
            });
        }
コード例 #10
0
        public async Task <IActionResult> GetHistoryMessageListStartByTopMsgAsync([FromQuery] GetHistoryMessageListStartByTopMsgRequestDto requestDto)
        {
            var biz   = new MessageBiz();
            var model = await biz.GetAsync(requestDto.TopMsgId);

            if (model != null)
            {
                requestDto.TopMsgDate = model?.CreationDate;
            }
            var result = await biz.GetHistoryMessageListStartByTopMsgAsync(requestDto);

            return(Success(result));
        }
コード例 #11
0
        private void createMessageFor(string fromPersonId, string toPersonId, string subject, string body)
        {
            fromPersonId.IsNullOrWhiteSpaceThrowArgumentException();
            toPersonId.IsNullOrWhiteSpaceThrowArgumentException();
            subject.IsNullOrWhiteSpaceThrowArgumentException();
            body.IsNullOrWhiteSpaceThrowArgumentException();

            Person fromPerson = PersonBiz.Find(fromPersonId);

            fromPerson.IsNullThrowException();

            Message message = new Message(fromPersonId, fromPerson, toPersonId, subject, body, MessageENUM.Free, null);

            MessageBiz.Create(message);
        }
コード例 #12
0
ファイル: BuySellDocBiz.cs プロジェクト: dovanduy/Library
 public BuySellDocBiz(IRepositry <BuySellDoc> entityDal, BuySellItemBiz buySellItemBiz, BizParameters bizParameters, OwnerBiz ownerBiz, CustomerBiz customerBiz, ShopBiz shopBiz, DeliverymanBiz deliverymanBiz, FreightOfferTrxBiz freightOfferTrxBiz, VehicalTypeBiz vehicalTypeBiz, MessageBiz messageBiz, PeopleMessageBiz peopleMessageBiz, SalesmanBiz salesmanBiz, BuySellDocHistoryBiz buySellDocHistoryBiz)
     : base(entityDal, bizParameters)
 {
     _ownerBiz             = ownerBiz;
     _customerBiz          = customerBiz;
     _shopBiz              = shopBiz;
     _buySellBiz           = entityDal as BuySellDocBiz;
     _buySellItemBiz       = buySellItemBiz;
     _freightOfferTrxBiz   = freightOfferTrxBiz;
     _deliverymanBiz       = deliverymanBiz;
     _vehicalTypeBiz       = vehicalTypeBiz;
     _messageBiz           = messageBiz;
     _peopleMessageBiz     = peopleMessageBiz;
     _salesmanBiz          = salesmanBiz;
     _buySellDocHistoryBiz = buySellDocHistoryBiz;
 }
コード例 #13
0
 public Result UpdateStatus(StatusUser model)
 {
     if (model.status != StatusUserEnum.Allowed)
     {
         UserRA.Delete(model.id.ToString());
     }
     if (model.status != StatusUserEnum.Forbidden)
     {
         MessageBiz.Send(model.id.ToString(), MessageTypeEnum.User_Forbidden);
     }
     else if (model.status == StatusUserEnum.ForcedOffline)
     {
         MessageBiz.Send(model.id.ToString(), MessageTypeEnum.User_ForcedOffline);
     }
     return(Result(UserDA.UpdateStatus(model)));
 }
コード例 #14
0
        public IActionResult AddMessageInfo([FromBody] List <AddMessageInfoRequestDto> requestDtoList)
        {
            var messageBiz  = new MessageBiz();
            var messageList = new List <MessageModel>();

            foreach (var dto in requestDtoList)
            {
                DateTime dtStart = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1));
                long     lTime   = long.Parse(dto.CreationDate + "0000");
                TimeSpan toNow   = new TimeSpan(lTime);
                var      msgDate = dtStart.Add(toNow);

                var model = new MessageModel
                {
                    MsgGuid         = Guid.NewGuid().ToString("N"),
                    TopicGuid       = dto.TopicGuid,
                    FromGuid        = dto.FromGuid,
                    ToGuid          = dto.ToGuid,
                    Context         = dto.Context,
                    IsHtml          = dto.IsHtml,
                    CreatedBy       = UserID,
                    CreationDate    = msgDate,
                    LastUpdatedBy   = UserID,
                    LastUpdatedDate = DateTime.Now,
                    OrgGuid         = "OrgGuid",
                    Enable          = true
                };
                if (!string.IsNullOrWhiteSpace(dto.MessageGuid))
                {
                    model.MsgGuid = dto.MessageGuid;
                }
                messageList.Add(model);
            }
            if (messageList.Count > 0)
            {
                var isAddSuccess = messageBiz.Push2Redis(messageList);
                if (!isAddSuccess)
                {
                    return(Failed(ErrorCode.DataBaseError, "批量添加失败!"));
                }
                DoctorOfflineMessageNotification(messageList.FirstOrDefault());
            }
            return(Success());
        }
コード例 #15
0
ファイル: SendMessage.cs プロジェクト: Cold1986/wechat-LUIS
        public static void Start(string monthkey, string user)
        {
            MessageBiz        messageBiz      = new MessageBiz();
            SendMPNewsRequest sendNewsRequest = new SendMPNewsRequest();
            string            strConn         = @"Provider=Microsoft.Ace.OLEDB.12.0;Data Source=" + filePath + "Report Mapping.xlsx;Extended Properties='Excel 12.0;HDR=Yes;IMEX=1'";
            DataTable         ExcelTable      = GetDTFromExcel(strConn);

            if (!string.IsNullOrEmpty(user))
            {
                sendNewsRequest = GetSendMPNewsRequest(monthkey, user, ExcelTable);
                messageBiz.Send <SendMPNewsRequest>(sendNewsRequest);
            }
            else
            {
                DataView  dataView          = ExcelTable.DefaultView;
                DataTable dataTableDistinct = dataView.ToTable(true, "Name");
                for (int i = 0; i < dataTableDistinct.Rows.Count; i++)
                {
                    string account = Convert.ToString(dataTableDistinct.Rows[i][0]);
                    sendNewsRequest = GetSendMPNewsRequest(monthkey, account, ExcelTable);
                    messageBiz.Send <SendMPNewsRequest>(sendNewsRequest);
                }
            }
        }
コード例 #16
0
 public Result ResetPassword(UserPassword model)
 {
     MessageBiz.Send(model.id.ToString(), MessageTypeEnum.Password_Changed);
     return(Result(UserDA.ResetPassword(model)));
 }
コード例 #17
0
        private void createMessageFor(RejectCancelDeleteInbetweenClass rcdbc, BuySellDoc buySellDoc)
        {
            string        fromPersonId   = "";
            string        toPersonId     = "";
            Person        fromPerson     = null;
            List <string> listOfToPeople = new List <string>();

            string buySellDocId   = buySellDoc.Id;
            Person ownerPerson    = OwnerBiz.GetPersonForPlayer(buySellDoc.OwnerId);
            Person customerPerson = CustomerBiz.GetPersonForPlayer(buySellDoc.CustomerId);

            ownerPerson.IsNullThrowException();
            customerPerson.IsNullThrowException();
            switch (buySellDoc.BuySellDocumentTypeEnum)
            {
            case BuySellDocumentTypeENUM.Sale:
                fromPersonId = ownerPerson.Id;
                fromPerson   = ownerPerson;
                toPersonId   = customerPerson.Id;
                listOfToPeople.Add(toPersonId);
                break;

            case BuySellDocumentTypeENUM.Purchase:
                toPersonId   = ownerPerson.Id;
                fromPersonId = customerPerson.Id;
                fromPerson   = customerPerson;
                listOfToPeople.Add(toPersonId);

                break;

            case BuySellDocumentTypeENUM.Delivery:
                Person deliveryPerson = DeliverymanBiz.GetPersonForPlayer(buySellDoc.DeliverymanId);
                deliveryPerson.IsNullThrowException();

                fromPersonId = deliveryPerson.Id;
                fromPerson   = deliveryPerson;
                listOfToPeople.Add(ownerPerson.Id);
                listOfToPeople.Add(customerPerson.Id);
                break;

            case BuySellDocumentTypeENUM.Unknown:
            default:
                throw new Exception("Unknown document type");
            }

            Message message = new Message(
                fromPersonId,
                fromPerson,
                listOfToPeople,
                rcdbc.Subject,
                rcdbc.Comment,
                MessageENUM.Free,
                null);

            if (buySellDoc.Messages.IsNull())
            {
                buySellDoc.Messages = new List <Message>();
            }

            buySellDoc.Messages.Add(message);
            message.BuySellDocId = buySellDoc.Id;

            message.ListOfToPeopleId.IsNullOrEmptyThrowException();
            foreach (var pplId in message.ListOfToPeopleId)
            {
                Person person = PersonBiz.Find(pplId);
                person.IsNullThrowException();

                PeopleMessage pplMsg = new PeopleMessage();
                pplMsg.IsNullThrowException();
                pplMsg.PersonId  = pplId;
                pplMsg.Person    = person;
                pplMsg.MessageId = message.Id;
                PeopleMessageBiz.Create(pplMsg);
            }
            MessageBiz.Create(message);
        }
コード例 #18
0
 public Result Authority(Model.DB.User model)
 {
     MessageBiz.Send(model.id.ToString(), MessageTypeEnum.Authorization_Changed);
     return(Result(UserDA.Authority(model)));
 }