コード例 #1
0
ファイル: ErpHub.cs プロジェクト: war-man/OSalesOnline
        //public void Send(int id, string message)
        //{
        //    InternalNotificationsRepository notificationsRepository = new InternalNotificationsRepository(new Domain.Staff.ErpStaffDbContext());
        //    var q = notificationsRepository.GetInternalNotificationsById(id);

        //    var listStaffCanView = StaffClients.Where(x => ("," + q.PlaceOfReceipt + ",").Contains("," + x.UserLoggedId + ",")).Select(x => x.ConnectionID).ToList();

        //    Clients.Clients(listStaffCanView).addNotification(id, message);
        //    //Clients.All.addNotification(id, message);
        //}
        #endregion

        #region Tạo mới notifications sử dụng trực tiếp trong controller
        public static void CreateNotifications(int?Id, string title, string CreateUserName, string ProfileImage, string ModuleName, DateTime?CreateDate, int?IdTask, int?SendUserId)
        {
            var path = Erp.BackOffice.Helpers.Common.GetSetting("Staff");

            if (!string.IsNullOrEmpty(ProfileImage))
            {
                ProfileImage = path + ProfileImage;
            }
            else
            {
                ProfileImage = "~/assets/img/no-avatar.png";
            }
            var listStaffCanView = StaffClients.Where(x => ("," + SendUserId + ",").Contains("," + x.UserLoggedId + ",")).Select(x => x.ConnectionID).ToList();
            var content          = Contentmessage(Id, IdTask, ProfileImage, title, CreateUserName, CreateDate, "Detail", ModuleName);
            //chuẩn bị nội dung của alert hiển thị kèm thông báo
            string message = "<span class=\"blue\"><b>"
                             + CreateUserName + "</b></span> <a href=\"/" + ModuleName + "/" + "Detail" + "/"
                             + Id + "\">" + " " + title + " ...</a></span><span class=\"msg-time\"><i class=\"ace-icon fa fa-clock-o\"></i> "
                             + CreateDate.Value.ToString("HH:mm dd/MM/yyyy") + "</span></span></a>";

            //gửi thông báo đến notifications của người nhận
            hubContext.Clients.Clients(listStaffCanView).addNotification(IdTask, content);
            //gửi alert kèm thông báo cho người dùng thấy.
            hubContext.Clients.Clients(listStaffCanView).alert(message, ProfileImage);
        }
コード例 #2
0
        public void Send(int id, string message)
        {
            InternalNotificationsRepository notificationsRepository = new InternalNotificationsRepository(new Domain.Staff.ErpStaffDbContext());
            var q = notificationsRepository.GetInternalNotificationsById(id);

            var listStaffCanView = StaffClients.Where(x => ("," + q.PlaceOfReceipt + ",").Contains("," + x.UserLoggedId + ",")).Select(x => x.ConnectionID).ToList();

            Clients.Clients(listStaffCanView).addNotification(id, message);
            //Clients.All.addNotification(id, message);
        }
コード例 #3
0
        public static void SendAlerts(int receiverUserId, int senderUserId, string title)
        {
            UserRepository userRepository   = new UserRepository(new Domain.ErpDbContext());
            var            senderUser       = userRepository.GetUserById(senderUserId);
            var            ProfileImage     = Erp.BackOffice.Helpers.Common.KiemTraTonTaiHinhAnh(senderUser.ProfileImage, "Staff", "user");
            var            listStaffCanView = StaffClients.Where(x => ("," + receiverUserId + ",").Contains("," + x.UserLoggedId + ",")).Select(x => x.ConnectionID).ToList();
            //chuẩn bị nội dung của alert hiển thị kèm thông báo
            string message = "<span class=\"blue\"><b>"
                             + senderUser.FullName + "</b></span>" + title + " ...</span><span class=\"msg-time\"><i class=\"ace-icon fa fa-clock-o\"></i> "
                             + DateTime.Now.ToString("HH:mm dd/MM/yyyy") + "</span></span></a>";

            //gửi alert kèm thông báo cho người dùng thấy.
            hubContext.Clients.Clients(listStaffCanView).alert(message, ProfileImage);
        }
コード例 #4
0
        public void loadUrl(string url, int userId)
        {
            var listStaffCanView = StaffClients.Where(x => x.UserLoggedId == userId).Select(x => x.ConnectionID).ToList();

            Clients.Clients(listStaffCanView).loadUrl(url);
        }