Example #1
0
        static int Main(string[] args)
        {
            try
            {
                CancellationTokenSource cancellationTokenSource = new CancellationTokenSource();
                AppDomain.CurrentDomain.ProcessExit += (s, e) =>
                {
                    logger.LogInformation("Process exit");
                    cancellationTokenSource.Cancel();
                };
                IConfiguration configuration = (new ConfigurationBuilder()).AddUserSecrets(Assembly.GetExecutingAssembly()).Build();
                RemindersRepository = new Repository.DB.ReminderDbRepository();
                ITelegramBotClient telegramClient     = new TelegramBotClient(configuration["token"]);
                ConversationHolder conversationHolder = new ConversationHolder();
                telegramClient.OnUpdate              += conversationHolder.OnUpdate;
                telegramClient.OnReceiveError        += conversationHolder.OnApiError;
                telegramClient.OnReceiveGeneralError += conversationHolder.OnError;
                telegramClient.StartReceiving(new UpdateType[] { UpdateType.Message, UpdateType.CallbackQuery }, cancellationTokenSource.Token);

                NotificationSender notificationSender = new NotificationSender(telegramClient);
                notificationSender.SendNotificationsAsync(cancellationTokenSource.Token);

                cancellationTokenSource.Token.WaitHandle.WaitOne();
            }
            catch (Exception ex)
            {
                logger.LogError(ex.ToString());
            }
            return(0);
        }
Example #2
0
 public RemindersService(
     IRemindersRepository remindersRepository,
     IRemindersUtilityService reminderUtilityService,
     IDateTimeService dateTimeService)
 {
     this.remindersRepository    = remindersRepository;
     this.reminderUtilityService = reminderUtilityService;
     this.dateTimeService        = dateTimeService;
 }
Example #3
0
        public CreateReminderViewModel(IRemindersRepository repo, IDialogCoordinator dialogService)
        {
            _remindersRepo = repo;
            _dialogService = dialogService;

            CurrentReminder = new Model.Reminder();

            CreateCommand = new RelayCommand(CreateReminder);
            CancelCommand = new RelayCommand(CancelCreation);
        }
Example #4
0
        public MainViewModel(IRemindersRepository repo, IDialogCoordinator dialogService,
                             ICustomDialogService customDialogService)
        {
            _remindersRepo       = repo;
            _dialogService       = dialogService;
            _customDialogService = customDialogService;

            SelectedPath    = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "reminders.xml");
            SortedReminders = CollectionViewSource.GetDefaultView(_remindersRepo.Reminders);
            SortedReminders.SortDescriptions.Add(new SortDescription("NextAppearanceTime", ListSortDirection.Ascending));

            DispatcherTimerSetup();

            SaveCommand    = new RelayCommand(SaveReminders);
            CreateCommand  = new RelayCommand(CreateReminder);
            DeleteCommand  = new RelayCommand(DeleteReminder);
            SetPathCommand = new RelayCommand(SetPath);
        }
 public RemindersContainer(IRemindersRepository reminderRepo)
 {
     this._reminderRepo = reminderRepo;
 }