Пример #1
0
        public void SendNotification(string lead_id_encrypted)
        {
            List <HomeVM>                homeVMList    = new List <HomeVM>();
            List <HomeModel>             homeModelList = new List <HomeModel>();
            RealTimeNotificationBusiness realTimeNotificationBusiness = new RealTimeNotificationBusiness(unitOfWork);
            HomeBusiness      homeBusiness      = new HomeBusiness(unitOfWork);
            LeadAuditBusiness leadAuditBusiness = new LeadAuditBusiness(unitOfWork);
            int         maxLeadAuditId          = 0;
            int         companyid              = Convert.ToInt32(Context.User.Identity.Name.Split(new[] { '|' })[1]);
            int         curentuserid           = Convert.ToInt32(Context.User.Identity.Name.Split(new[] { '|' })[0]);
            List <int?> realTimeNotificationId = realTimeNotificationBusiness.GetNotifyClientByCompanyId(companyid, curentuserid, lead_id_encrypted.Decrypt(), ref maxLeadAuditId);

            homeModelList = homeBusiness.GetRecentActivitiesForHome(1, 1, maxLeadAuditId, false, 0, 0);
            AutoMapper.Mapper.Map(homeModelList, homeVMList);

            foreach (int userid in realTimeNotificationId)
            {
                Clients.User(userid.Encrypt()).NewNotification(new { RecentActivities = homeVMList.Select(x => new { CreatedBy = x.CreatedBy, ImageURL = x.ImageURL, LeadAuditId = x.LeadAuditId, ActivityText = x.ActivityText, ActivityCreatedTime = x.ActivityCreatedTime }), MaxLeadAuditID = maxLeadAuditId.Encrypt() });
            }
        }