Exemplo n.º 1
0
        public TradingReportService(
            IEmailService emailService,
            IConvertService convertService,
            ISystemClock systemClock,
            ILog log,
            NotificationsSettings monthlyNotificationsSettings, //injected as named parameter
            NotificationsSettings dailyNotificationsSettings,   //injected as named parameter

            IClientAccountClient clientAccountClient,

            Backend.Contracts.IAccountsApi accountsApi,
            Backend.Contracts.IAccountHistoryApi accountHistoryApi,
            Backend.Contracts.ITradeMonitoringReadingApi tradeMonitoringReadingApi,
            Backend.Contracts.IAssetPairsReadingApi assetPairsReadingApi,

            IOvernightSwapHistoryRepository overnightSwapHistoryRepository)
        {
            _emailService   = emailService;
            _convertService = convertService;
            _systemClock    = systemClock;
            _log            = log;
            _monthlyNotificationsSettings = monthlyNotificationsSettings;
            _dailyNotificationsSettings   = dailyNotificationsSettings;

            _clientAccountClient = clientAccountClient;

            _accountsApi               = accountsApi;
            _accountHistoryApi         = accountHistoryApi;
            _tradeMonitoringReadingApi = tradeMonitoringReadingApi;
            _assetPairsReadingApi      = assetPairsReadingApi;

            _overnightSwapHistoryRepository = overnightSwapHistoryRepository;
        }
Exemplo n.º 2
0
        public async Task ChangeUserNotificationSettings(UserNotificationsSettingsDto settingsDto, UserAndOrganizationDTO userOrg)
        {
            var settings = await _usersDbSet
                           .Where(u => u.Id == userOrg.UserId && u.OrganizationId == userOrg.OrganizationId)
                           .Select(u => u.NotificationsSettings)
                           .FirstOrDefaultAsync();

            if (settings == null)
            {
                settings = new NotificationsSettings
                {
                    OrganizationId = userOrg.OrganizationId
                };
                var user = await _usersDbSet.FirstAsync(u => u.Id == userOrg.UserId && u.OrganizationId == userOrg.OrganizationId);

                user.NotificationsSettings = settings;
            }

            settings.ModifiedBy                       = userOrg.UserId;
            settings.EventsAppNotifications           = settingsDto.EventsAppNotifications;
            settings.EventsEmailNotifications         = settingsDto.EventsEmailNotifications;
            settings.ProjectsAppNotifications         = settingsDto.ProjectsAppNotifications;
            settings.ProjectsEmailNotifications       = settingsDto.ProjectsEmailNotifications;
            settings.MyPostsAppNotifications          = settingsDto.MyPostsAppNotifications;
            settings.MyPostsEmailNotifications        = settingsDto.MyPostsEmailNotifications;
            settings.FollowingPostsAppNotifications   = settingsDto.FollowingPostsAppNotifications;
            settings.FollowingPostsEmailNotifications = settingsDto.FollowingPostsEmailNotifications;

            await _uow.SaveChangesAsync(userOrg.UserId);
        }
Exemplo n.º 3
0
        public void Init(NotificationsSettings settings, INotificationListener listener)
        {
            // Store the settings for later references.
            mSettings = settings;

            // Convert category groups to JSON. Invalid groups (empty name or ID) will be
            // automatically ignored in native side.
            var categoryGroupJson = AndroidNotificationHelper.ToJson(settings.CategoryGroups);

            // Convert categories to JSON.
            var categories = new List <NotificationCategory>();

            categories.Add(settings.DefaultCategory);

            if (settings.UserCategories != null)
            {
                categories.AddRange(settings.UserCategories);
            }

            var categoriesJson = AndroidNotificationHelper.ToJson(categories.ToArray());

            // Listener info
            var name = listener.Name;
            var backgroundNotificationMethod = Helper.GetMethodName(listener.NativeNotificationFromBackgroundHandler);
            var foregroundNotificationMethod = Helper.GetMethodName(listener.NativeNotificationFromForegroundHandler);

            // Initialize native Android client, which may send some launch notification data during the process.
            AndroidNotificationNative._InitNativeClient(categoryGroupJson, categoriesJson, name, backgroundNotificationMethod, foregroundNotificationMethod);

            mIsInitialized = true;
        }
Exemplo n.º 4
0
        // public async Task EnableNotifications(Guid stuedntId)
        // {
        //     //TODO call google calendar api
        //     // to set notifications
        //     await setNotifications(stuedntId, true);
        // }
        //
        // public async Task DisableNotifications(Guid stuedntId)
        // {
        //     //TODO call google calendar api
        //     // to defable notifications
        //     await setNotifications(stuedntId, false);
        // }

        public async Task SetNotificationSettings(NotificationsSettings settings)
        {
            Task apiCall = null;

            // update calendar notifications
            if (settings.NotificationType == "Google")
            {
                apiCall = _calendar.SetNotificationsInCalendar(settings);
            }

            Task dbCall = this.changeNottificationsSettingsInDb(settings);
            await Task.WhenAll(apiCall ?? dbCall, dbCall);
        }
Exemplo n.º 5
0
 //constr for db
 internal User(string name, Credentials credentials, UserType type,
               List <Invitation> invitationList, TeacherProfile teacherProfile, UserProfile userProfile, bool isActive,
               List <Notification> notifiesList, NotificationsSettings notificationsSettings, int id = 0)
 {
     Id = id;
     Ensure.String.IsNotNullOrWhiteSpace(name);
     Credentials           = Ensure.Any.IsNotNull(credentials);
     Type                  = type;
     TeacherProfile        = Ensure.Any.IsNotNull(teacherProfile);
     UserProfile           = Ensure.Any.IsNotNull(userProfile);
     IsActive              = isActive;
     Invitations           = Ensure.Any.IsNotNull(invitationList);
     Notifications         = Ensure.Any.IsNotNull(notifiesList);
     NotificationsSettings = Ensure.Any.IsNotNull(notificationsSettings);
 }
Exemplo n.º 6
0
 public User(string name, Credentials credentials, bool isTeacher,
             UserType type, string avatarLink = "", int id = 0)
 {
     Id = id;
     Ensure.String.IsNotNullOrWhiteSpace(name);
     Credentials           = Ensure.Any.IsNotNull(credentials);
     Type                  = type;
     TeacherProfile        = new TeacherProfile();
     UserProfile           = new UserProfile(name, Credentials.Email, isTeacher, avatarLink);
     IsActive              = true;
     Invitations           = new List <Invitation>();
     Notifies              = new List <string>();
     Notifications         = new List <Notification>();
     NotificationsSettings = new NotificationsSettings();
 }
Exemplo n.º 7
0
        // public async Task<IEnumerable<Lesson>> GetLessonsForStudent(Guid studentId)
        // {
        //     var student = _context.Students.Include("Group").FirstOrDefault(s => s.Id == studentId);
        //     var lessons = await _context.Lessons.Include("Subject")
        //         .Where(l => l.Subject.GroupId == student.Group.Id)
        //         .OrderBy(l=>l.Week)
        //         .ThenBy(l=>l.DayOfWeek)
        //         .ThenBy(l=>l.TimeStart)
        //         .ToListAsync();
        //     //
        //     return lessons;
        // }

        public async Task UpdateNotification(NotificationsSettings notificationsInfo)
        {
            // if notification not exist in table create it and set data
            var notificationsInfoFromDb =
                await _context.NotificationsSettings.FirstOrDefaultAsync(
                    n => n.StudentId == notificationsInfo.StudentId);

            if (notificationsInfoFromDb == null)
            {
                await _context.NotificationsSettings.AddAsync(notificationsInfo);

                return;
            }

            notificationsInfoFromDb.IsNotificationsOn = notificationsInfo.IsNotificationsOn;
            notificationsInfoFromDb.TimeBeforeLesson  = notificationsInfo.TimeBeforeLesson;
        }
Exemplo n.º 8
0
        public async Task Execute(Message message, TelegramBotClient client)
        {
            // todo перевірка наяності свовіщень
            Console.WriteLine("We are here !");
            var student = await _repository.GetUserByTelegramId(message.From.Id);

            var notificationEntity = new NotificationsSettings
            {
                StudentId         = student.Id,
                IsNotificationsOn = false
            };
            await _repository.UpdateNotification(notificationEntity);

            await _repository.SaveAsync();

            await _jobsManager.RefreshJobs();

            await Bot.BotClient.SendTextMessageAsync(message.Chat.Id, "Сповіщення вимкнено !");
        }
        /// <summary>
        /// Save or update records for the table
        /// </summary>
        /// <param name="listDataNotificationsSettings">List of data to store NotificationsSettings.</param>
        /// <returns>The result of processing the list.</returns>
        /// <author>Mauricio Suárez.</author>
        public bool SaveNotificationsSettings(List <NotificationsSettingsDto> listNotificationsSettingsDto)
        {
            using (SecurityManagmentEntities context = new SecurityManagmentEntities())
            {
                ObjectContext objectContext           = ((IObjectContextAdapter)context).ObjectContext;
                ObjectSet <NotificationsSettings> set = objectContext.CreateObjectSet <NotificationsSettings>();
                string[] entityOrderDetailKeys        = set.EntitySet.ElementType.KeyMembers.Select(k => k.Name).ToArray();

                bool[] resultValidateInsertOrUpdate = ConditionalQuery.ValidatePrimaryKeyValueInDto(listNotificationsSettingsDto, entityOrderDetailKeys);

                int resultValidateInsertOrUpdateCount = resultValidateInsertOrUpdate.Count();

                int i = 0;
                foreach (NotificationsSettingsDto dtoNotificationsSettings in listNotificationsSettingsDto)
                {
                    if (resultValidateInsertOrUpdateCount > 0)
                    {
                        NotificationsSettings entityOrderDetail = null;
                        if (resultValidateInsertOrUpdate[i])
                        {
                            entityOrderDetail = Mapper.Map <NotificationsSettingsDto, NotificationsSettings>(dtoNotificationsSettings);
                            context.Entry(entityOrderDetail).State = System.Data.Entity.EntityState.Modified;
                            context.NotificationsSettings.Attach(entityOrderDetail);
                        }
                        else
                        {
                            context.NotificationsSettings.Add(Mapper.Map <NotificationsSettingsDto, NotificationsSettings>(dtoNotificationsSettings));
                        }
                    }
                    else
                    {
                        context.NotificationsSettings.Add(Mapper.Map <NotificationsSettingsDto, NotificationsSettings>(dtoNotificationsSettings));
                    }
                    i++;
                }

                context.SaveChanges();
            }

            return(true);
        }
Exemplo n.º 10
0
        public async Task UpdateNotification(NotificationsSettings notificationsSettings)
        {
            var student = await _context.Students.Include(s => s.NotificationsSettings)
                          .FirstOrDefaultAsync(s => s.Id == notificationsSettings.StudentId);

            // check if notifications entity exists
            if (student.NotificationsSettingsId == null || student.NotificationsSettings == null)
            {
                // if not exists - create
                notificationsSettings.Id = Guid.NewGuid();
                await _context.NotificationsSettings.AddAsync(notificationsSettings);

                student.NotificationsSettingsId = notificationsSettings.Id;
                return;
            }

            // if exists - update
            student.NotificationsSettings.IsNotificationsOn = notificationsSettings.IsNotificationsOn;
            student.NotificationsSettings.TimeBeforeLesson  = notificationsSettings.TimeBeforeLesson;
            student.NotificationsSettings.NotificationType  = notificationsSettings.NotificationType;
        }
Exemplo n.º 11
0
        public async Task Execute(Message message, TelegramBotClient client)
        {
            // todo перевірка наявності сповіщень
            var student = await _repository.GetUserByTelegramId(message.From.Id);

            if (student == null)
            {
                // todo Bot : винести текст команд в статичний класс
                await Bot.BotClient.SendTextMessageAsync(message.Chat.Id, "Щоб користуватись сповіщеннями, їх потрібно увімкнути на сайті <domain> ");
            }
            var notificationEntity = new NotificationsSettings
            {
                StudentId         = student.Id,
                IsNotificationsOn = true
            };
            await _repository.UpdateNotification(notificationEntity);

            await _repository.SaveAsync();

            await _jobsManager.RefreshJobs();

            await Bot.BotClient.SendTextMessageAsync(message.Chat.Id, "Сповіщення увімкнено !");
        }
Exemplo n.º 12
0
        public void Init(NotificationsSettings settings, INotificationListener listener)
        {
            // Authorization options.
            var iOSAuthOptions = iOSNotificationHelper.ToIOSNotificationAuthOptions(settings.iOSAuthOptions);

            // Listener.
            var iOSListenerInfo = iOSNotificationHelper.ToIOSNotificationListenerInfo(listener);

            // Categories.
            var categories = new List <NotificationCategory>();

            categories.Add(settings.DefaultCategory);

            if (settings.UserCategories != null)
            {
                categories.AddRange(settings.UserCategories);
            }

            var    iOSCategories     = iOSNotificationHelper.ToIOSNotificationCategories(categories.ToArray());
            string iOSCategoriesJson = iOSNotificationHelper.ToIOSNotificationCategoriesJson(iOSCategories);

            iOSNotificationNative._InitNotifications(ref iOSAuthOptions, ref iOSListenerInfo, iOSCategoriesJson);
            mIsInitialized = true;
        }
Exemplo n.º 13
0
        public void ExecuteTestToEditNitificationsSettings()
        {
            ExecuteTestToAccountNameNotificationsSettings();
            System.Threading.Thread.Sleep(2000);
            NotificationsSettings notificationssettings = new NotificationsSettings();

            notificationssettings.NtfcNewMessageForm();
            System.Threading.Thread.Sleep(2000);
            notificationssettings.NtfcMeetingAutomaticallyAcceptedForm();
            System.Threading.Thread.Sleep(2000);
            notificationssettings.NtfcMeetingScheduledForm();
            System.Threading.Thread.Sleep(2000);
            notificationssettings.NtfcMeetingDeclinedForm();
            System.Threading.Thread.Sleep(2000);
            notificationssettings.NtfcMeetingCanceledForm();
            System.Threading.Thread.Sleep(2000);
            notificationssettings.NtfcMeetingUpdatedForm();
            System.Threading.Thread.Sleep(2000);
            notificationssettings.NtfcMeetingConfirmedForm();
            System.Threading.Thread.Sleep(2000);
            notificationssettings.NtfcMeetingRequestedForm();
            System.Threading.Thread.Sleep(2000);
            notificationssettings.NtfcNewAlertForm();
            System.Threading.Thread.Sleep(2000);
            notificationssettings.BNtfcMeetingScheduledForm();
            System.Threading.Thread.Sleep(2000);
            notificationssettings.BNtfcMeetingDeclinedForm();
            System.Threading.Thread.Sleep(2000);
            notificationssettings.BNtfcMeetingCanceledForm();
            System.Threading.Thread.Sleep(2000);
            notificationssettings.BNtfcMeetingUpdatedForm();
            System.Threading.Thread.Sleep(2000);
            notificationssettings.BNtfcMeetingConfirmedForm();
            System.Threading.Thread.Sleep(2000);
            notificationssettings.BNtfcMeetingRequestedForm();
            System.Threading.Thread.Sleep(2000);
            notificationssettings.BNtfcMeetingAutomaticallyAcceptedForm();
            System.Threading.Thread.Sleep(2000);
            notificationssettings.BNtfcNewMessageForm();
            System.Threading.Thread.Sleep(2000);
            notificationssettings.BNtfcNewAlertForm();
            System.Threading.Thread.Sleep(2000);
            notificationssettings.PNtfcMeetingRequestedForm();
            System.Threading.Thread.Sleep(2000);
            notificationssettings.PNtfcNewMessageForm();
            System.Threading.Thread.Sleep(2000);
            notificationssettings.PNtfcMeetingAutomaticallyAcceptedForm();
            System.Threading.Thread.Sleep(2000);
            notificationssettings.PNtfcMeetingScheduledForm();
            System.Threading.Thread.Sleep(2000);
            notificationssettings.PNtfcMeetingDeclinedForm();
            System.Threading.Thread.Sleep(2000);
            notificationssettings.PNtfcMeetingCanceledForm();
            System.Threading.Thread.Sleep(2000);
            notificationssettings.PNtfcMeetingUpdatedForm();
            System.Threading.Thread.Sleep(2000);
            notificationssettings.PNtfcMeetingConfirmedForm();
            System.Threading.Thread.Sleep(2000);
            notificationssettings.PNtfcNewAlertForm();
            System.Threading.Thread.Sleep(2000);
            //notificationssettings.NtfcTransactionalEmailForm();
            System.Threading.Thread.Sleep(2000);
            //notificationssettings.NtfcBatchEmailForm();
            System.Threading.Thread.Sleep(2000);
            //notificationssettings.NtfcPushNotificationsForm();
        }
 public NotificationsSettingsUpdateRequestBuilder(NotificationsSettings settings)
     : this()
 {
     this.Settings = settings;
 }
 public static NotificationsSettingsUpdateRequestBuilder Update(NotificationsSettings settings)
 {
     return(new NotificationsSettingsUpdateRequestBuilder(settings));
 }
 public void Init(NotificationsSettings settings, INotificationListener listener)
 {
     Debug.LogWarning(UNSUPPORTED_MESSAGE);
 }