예제 #1
0
        public void PushNotification(WF_CaseNotifications notification, string receiver, NotificationSources source, Action <WF_CaseNotificationReceivers> handler = null)
        {
            EmailService.SendWorkFlowEmail(
                _entities.GlobalUserView.FirstOrDefault(p => p.EmployeeID == _currentUser)?.EmployeeName,
                new[] { receiver },
                notification.WF_FlowCases.Subject,
                (NotificationTypes)notification.NotificationType);
            WF_CaseNotificationReceivers not = new WF_CaseNotificationReceivers
            {
                WF_CaseNotifications = notification,
                SourceType           = (int)source,
                Created      = DateTime.UtcNow,
                LastUpdated  = DateTime.UtcNow,
                IsRead       = 0,
                IsDissmissed = 0,
                Receiver     = receiver,
                StatusId     = 1
            };

            handler?.Invoke(not);
            _entities.WF_CaseNotificationReceivers.Add(not);
            if (not.IsDissmissed == 0)
            {
                NotificationSender.PushNotificationMessages(new[] { receiver }, () => not.CaseNotificationReceiverId);
            }
        }
예제 #2
0
        public bool SetNotificationDismissed(int caseNotificationReceiverId)
        {
            WF_CaseNotificationReceivers target = _entities.WF_CaseNotificationReceivers.FirstOrDefault(p => p.CaseNotificationReceiverId == caseNotificationReceiverId);

            if (target == null)
            {
                return(false);
            }
            target.IsDissmissed = 1;
            return(_entities.SaveChanges() > 0);
        }
예제 #3
0
        public WF_CaseNotificationReceivers SetNotificationAsRead(int caseNotificationReceiverId)
        {
            WF_CaseNotificationReceivers target = _entities.WF_CaseNotificationReceivers.Include("WF_CaseNotifications").FirstOrDefault(p => p.CaseNotificationReceiverId == caseNotificationReceiverId);

            if (target == null)
            {
                return(null);
            }
            target.IsRead = 1;
            _entities.SaveChanges();
            return(target);
        }
예제 #4
0
        public void PushNotification(WF_FlowCases flowCase, int?flowstepId, string comments, string receiver, NotificationTypes type, NotificationSources source)
        {
            WF_CaseNotificationReceivers not = new WF_CaseNotificationReceivers
            {
                WF_CaseNotifications = CreateNotification(flowCase, flowstepId, comments, type),
                SourceType           = (int)source,
                Created      = DateTime.UtcNow,
                LastUpdated  = DateTime.UtcNow,
                IsRead       = 0,
                IsDissmissed = 0,
                Receiver     = receiver,
                StatusId     = 1
            };

            _entities.WF_CaseNotificationReceivers.Add(not);
            NotificationSender.PushNotificationMessages(new[] { receiver }, () => not.CaseNotificationReceiverId);
        }
        public object get_notification_info(int notificationId)
        {
            Singleton <ILogWritter> .Instance?.WriteLog("WorkFlow-get_notification_info", notificationId.ToString());

            ApplicationUser manager = new ApplicationUser(Entities, User.Identity.Name);
            WF_CaseNotificationReceivers receiver = manager.NotificationManager.SetNotificationAsRead(notificationId);

            manager.UpdateLastChecked(receiver.WF_CaseNotifications.FlowCaseId, User.Identity.Name);
            manager.NotificationManager.SetNotificationDismissed(notificationId);
            return(new NotificationResult
            {
                flowCaseId = receiver.WF_CaseNotifications.FlowCaseId,
                notificationId = notificationId,
                created = receiver.Created,
                notificationType = receiver.WF_CaseNotifications.NotificationType,
                comments =
                    receiver.WF_CaseNotifications.WF_FlowCases.WF_CaseNotifications.Where(
                        p => p.StatusId > 0 && p.NotificationType == (int)NotificationTypes.Comments || p.NotificationType == (int)NotificationTypes.AppFinishedAbort || p.NotificationType == (int)NotificationTypes.RejectApp || p.NotificationType == (int)NotificationTypes.AppFinishedRejected)
                    .Select(p => new CaseNotification
                {
                    CaseNotificationId = p.CaseNotificationId,
                    Created = p.Created,
                    Sender = p.Sender,
                    Comments = p.Comments,
                    Source = p.Source,
                    NotificationType = p.NotificationType,
                }).ToArray(),
                sender = receiver.WF_CaseNotifications.Sender,
                receiver = receiver.Receiver,
                isDissmissed = receiver.IsDissmissed,
                attachments =
                    receiver.WF_CaseNotifications.WF_FlowCases.WF_FlowCases_Attachments.Where(p => p.StatusId > 0)
                    .Select(p => new
                {
                    attachmentId = p.AttachementId,
                    fileName = p.OriFileName,
                    fileSize = p.FileSize,
                    lastUpdated = p.LastUpdated
                })
            });
        }
        public ActionResult ViewItem(int flowcaseid, int caseNotificationReceiverId, bool enableCancel = false)
        {
            ApplicationUser manager = new ApplicationUser(WFEntities, this.Username);

            manager.UpdateLastChecked(flowcaseid, this.Username);
            WF_CaseNotificationReceivers not = manager.NotificationManager.SetNotificationAsRead(caseNotificationReceiverId);

            ViewBag.Notification = not;
            ViewBag.Comments     = manager.NotificationManager.GetComments(flowcaseid);
            ViewBag.Attachments  = manager.GetAttachments(flowcaseid);
            manager.NotificationManager.SetNotificationDismissed(caseNotificationReceiverId);
            FlowInfo info     = manager.GetFlowAndCase(flowcaseid);
            var      flowType = WFEntities.WF_FlowTypes.FirstOrDefault(p => p.FlowTypeId == info.FlowTypeId);

            ViewBag.FlowType = flowType;
            ViewBag.Cities   = WFEntities.Cities.ToArray();
            var properties = manager.GetProperties(flowcaseid);

            ViewBag.Properties   = properties;
            ViewBag.Attachments  = manager.GetAttachments(flowcaseid);
            ViewBag.EnableCancel = enableCancel &&
                                   info.CaseInfo.Applicant.EqualsIgnoreCase(User.Identity.Name) &&
                                   (!info.CaseInfo.RelatedFlowCaseId.HasValue || info.CaseInfo.RelatedFlowCaseId == 0) &&
                                   not.WF_CaseNotifications.NotificationType == (int)NotificationTypes.AppFinishedApproved;
            if (flowType.TemplateType.HasValue && flowType.TemplateType.Value == 7)
            {
                var prop = properties.PropertyInfo.FirstOrDefault(p => p.PropertyName.ToLower().Equals("brand") && p.StatusId < 0);
                if (prop != null)
                {
                    var brand    = properties.Values.FirstOrDefault(p => p.PropertyId == prop.FlowPropertyId)?.StringValue;
                    var shopList = WFEntities.BLSShopView
                                   .Where(s => s.Brand.ToLower().Equals(brand.ToLower()))
                                   .Select(s => new { s.ShopCode, s.ShopName })
                                   .ToDictionary(s => s.ShopCode, s => s.ShopName);
                    ViewBag.ShopList = shopList;
                }
            }
            return(PartialView("ViewNotification", info));
        }