Esempio n. 1
0
        public void SetApplicationNotification(ApplicationNotification notif, bool enable)
        {
            if ((notif & ApplicationNotification.AdminNotificationMask) != 0)
            {
                CheckIsAdmin();
            }

            UserApplication up = db.SelectObjectWhere <UserApplication> ("UserId={0} AND ApplicationId={1}", user.Id, application.Id);

            if (enable)
            {
                if (up == null)
                {
                    up = new UserApplication()
                    {
                        UserId = user.Id, ApplicationId = application.Id, Notifications = notif
                    };
                    db.InsertObject <UserApplication> (up);
                }
                else
                {
                    up.Notifications |= notif;
                    db.UpdateObject(up);
                }
            }
            else if (up != null)
            {
                up.Notifications &= ~notif;
                db.UpdateObject(up);
            }
        }
Esempio n. 2
0
 IEnumerable <string> GetUsersToNotify(ApplicationNotification notif)
 {
     foreach (var user in db.SelectObjects <User> ("SELECT User.* FROM User, UserApplication WHERE UserApplication.UserId = User.Id AND UserApplication.ApplicationId={0} AND UserApplication.Notifications & {1} = {2}", application.Id, (int)notif, (int)notif))
     {
         yield return(user.Email);
     }
 }
        public Task RaiseAppEvent(string key, string value)
        {
            ApplicationNotification n = new ApplicationNotification(key, value);

            _logger.LogDebug(value);
            return(_mediator.Publish(n));
        }
Esempio n. 4
0
        public bool Execute(TaskAbstract taskAbstract)
        {
            var task       = (ForceAccountRefreshTask)taskAbstract;
            var itemId     = task.ItemID;
            var account    = _accountService.Get(task.AccountID);
            var accountant = _accountService.GetAccountantsFromAccount(account);
            var isEmailNotificationRequired = account != null && account.CobrandToUse != null && account.CobrandToUse.CobrandSettings != null
                ? account.CobrandToUse.CobrandSettings.EnableEmailNotification
                : false;
            var forceRefreshRunner = ObjectFactory.GetInstance <ForceRefreshFacade>();
            var reportProgress     = _taskService.GetTaskProgressReporter(task.ID);

            var context = RequestContext.Current;

            var numWealthItemsProcessed = 0;
            var result = forceRefreshRunner.ForceRefreshAccount(context, account, itemId, out numWealthItemsProcessed, reportProgress);

            if (result && numWealthItemsProcessed > 0 && task.ShouldSendUpdateNotification)
            {
                // Send email informing user that their financial accounts have updated
                ApplicationNotification.SendEmailForFinancialAccountsUpdated(MessageType.Email, account, numWealthItemsProcessed);
            }
            else
            {
                SendBankAccountFailureEmailNotification(account, accountant, isEmailNotificationRequired);
            }
            return(false);
        }
Esempio n. 5
0
        public List <NotificationInfo> GetApplicationNotifications()
        {
            ApplicationNotification notifs        = (ApplicationNotification)0;
            ProjectNotification     projectNotifs = (ProjectNotification)0;

            UserApplication uap = db.SelectObjectWhere <UserApplication> ("UserId={0} AND ApplicationId={1}", User.Id, application.Id);

            if (uap != null)
            {
                notifs        = uap.Notifications;
                projectNotifs = uap.ProjectNotifications;
            }

            List <NotificationInfo> list = new List <NotificationInfo> ();
            bool hasProjects             = OwnedProjects.Count > 0;

            if (hasProjects)
            {
                list.Add(new NotificationInfo("Global Notifications"));
            }

            list.Add(new NotificationInfo("New Add-in", ApplicationNotification.FirstProjectRelease, notifs));
            list.Add(new NotificationInfo("New Add-in Release", ApplicationNotification.ProjectNewRelease, notifs));

            if (IsAdmin)
            {
                list.Add(new NotificationInfo("Build Success", ApplicationNotification.ProjectBuildSuccess, notifs));
                list.Add(new NotificationInfo("Build Error", ApplicationNotification.ProjectBuildError, notifs));
                list.Add(new NotificationInfo("Project Created", ApplicationNotification.NewProject, notifs));
                list.Add(new NotificationInfo("Project Deleted", ApplicationNotification.DeleteProject, notifs));
                list.Add(new NotificationInfo("Description Changed", ApplicationNotification.ProjectDescriptionChage, notifs));
                list.Add(new NotificationInfo("Release Publish Request", ApplicationNotification.ProjectPublishReleaseRequest, notifs));
            }

            if (IsSiteAdmin)
            {
                list.Add(new NotificationInfo("New User", SiteNotification.NewUser, User.SiteNotifications));
                list.Add(new NotificationInfo("Build Bot Error", SiteNotification.BuildBotError, User.SiteNotifications));
            }

            if (hasProjects)
            {
                list.Add(new NotificationInfo("Owned Project Notifications"));
                list.Add(new NotificationInfo("Release Published", ProjectNotification.NewRelease, projectNotifs));
                list.Add(new NotificationInfo("Build Success", ProjectNotification.BuildSuccess, projectNotifs));
                list.Add(new NotificationInfo("Build Error", ProjectNotification.BuildError, projectNotifs));
            }
            return(list);
        }
Esempio n. 6
0
        private static void SendBankAccountFailureEmailNotification(Account account, IEnumerable <TaxPartnerAgent> accountant, bool emailNotificationRequired)
        {
            var sendEmailToClient = ApplicationNotification.SendBankAccountFailNotificationToClient(MessageType.Email, account);

            if (emailNotificationRequired)
            {
                foreach (var acc in accountant)
                {
                    var sendEmailToAdviser =
                        ApplicationNotification.SendBankAccountFailNotificationToAdvisor(MessageType.Email, account, acc);
                }
            }

            if (!sendEmailToClient)
            {
                ExceptionHelper.HandleException(new Exception("Could not sent email"), false);
            }
        }
Esempio n. 7
0
        public void SetApplicationNotification(ApplicationNotification notif, bool enable)
        {
            if ((notif & ApplicationNotification.AdminNotificationMask) != 0)
                CheckIsAdmin ();

            UserApplication up = db.SelectObjectWhere<UserApplication> ("UserId={0} AND ApplicationId={1}", user.Id, application.Id);
            if (enable) {
                if (up == null) {
                    up = new UserApplication () { UserId = user.Id, ApplicationId = application.Id, Notifications = notif };
                    db.InsertObject<UserApplication> (up);
                }
                else {
                    up.Notifications |= notif;
                    db.UpdateObject (up);
                }
            } else if (up != null) {
                up.Notifications &= ~notif;
                db.UpdateObject (up);
            }
        }
Esempio n. 8
0
 public void SendMail(string subject, string body, ApplicationNotification notif)
 {
     BuildService.SendMail (GetUsersToNotify (notif), subject, body);
 }
Esempio n. 9
0
 IEnumerable<string> GetUsersToNotify(ApplicationNotification notif)
 {
     foreach (var user in db.SelectObjects<User> ("SELECT User.* FROM User, UserApplication WHERE UserApplication.UserId = User.Id AND UserApplication.ApplicationId={0} AND UserApplication.Notifications & {1} = {2}", application.Id, (int)notif, (int)notif))
         yield return user.Email;
 }
Esempio n. 10
0
 public void SendMail(string subject, string body, ApplicationNotification notif)
 {
     BuildService.SendMail(GetUsersToNotify(notif), subject, body);
 }