Beispiel #1
0
        /// <summary>
        /// Validates action
        /// </summary>
        protected override void Validate()
        {
            if (string.IsNullOrEmpty(Details))
            {
                AddBrokenRule(ActionBusinessRule.ActionMessageRequired);
            }
            if (Details != null && Details.Length > 1000)
            {
                AddBrokenRule(ActionBusinessRule.ActionMessageLengthNotExceed1000);
            }
            if ((Contacts == null || Contacts.Count == 0) && SelectAll == false)
            {
                AddBrokenRule(ActionBusinessRule.ContactsRequired);
            }
            if (RemindOn != null)
            {
                DateTime outResult;
                if (!DateTime.TryParse(RemindOn.ToString(), out outResult))
                {
                    AddBrokenRule(ActionBusinessRule.RemindOnInvalid);
                }
            }
            DateTime today = DateTime.Now.ToUniversalTime();

            if (RemindOn.HasValue)
            {
                DateTime reminderDate = RemindOn.Value;
                DateTime actionDate   = new DateTime(ActionDate.Value.Year, ActionDate.Value.Month, ActionDate.Value.Day, ActionStartTime.Value.Hour, ActionStartTime.Value.Minute, ActionStartTime.Value.Second);
                var      result       = DateTime.Compare(actionDate, reminderDate);
                if (result < 0 && (ReminderTypes.Contains(ReminderType.Email) || ReminderTypes.Contains(ReminderType.TextMessage) || ReminderTypes.Contains(ReminderType.PopUp)))
                {
                    AddBrokenRule(ActionBusinessRule.RemindOndateInvalid);
                }
            }
        }
Beispiel #2
0
 protected override void Validate()
 {
     if (!IsTourDetailsValid())
     {
         AddBrokenRule(TourBusinessRule.DetailsMaxLengthReached);
     }
     if (!IsCommunityValid())
     {
         AddBrokenRule(TourBusinessRule.CommunityRequired);
     }
     if (!IsTourTypeValid())
     {
         AddBrokenRule(TourBusinessRule.TourTypeRequired);
     }
     if (!IsContactsCountValid())
     {
         AddBrokenRule(TourBusinessRule.ContactsRequired);
     }
     if (!IsReminderTypeValid())
     {
         AddBrokenRule(TourBusinessRule.ReminderNotApplicable);
     }
     if ((ReminderTypes != null && ReminderTypes.Any()) && !IsReminderDateValid())
     {
         AddBrokenRule(TourBusinessRule.ReminderDateNotValid);
     }
     if (!IsTourDateValid())
     {
         AddBrokenRule(TourBusinessRule.TourDateNotValid);
     }
 }
        private static bool GetReminderChannelForType(ReminderTypes type, out StringBuilder reminderChannelName)
        {
            reminderChannelName = new StringBuilder();
            switch (type)
            {
            case ReminderTypes.Run:
                reminderChannelName.Append("Runner");
                break;

            case ReminderTypes.Task:
                reminderChannelName.Append("Task");
                break;

            case ReminderTypes.Project:
                reminderChannelName.Append("Project");
                break;

            case ReminderTypes.DebugTask:
                reminderChannelName.Append("Debug");
                break;

            case ReminderTypes.DebugProject:
                reminderChannelName.Append("Debug");
                break;

            default:
                return(false);
            }

            reminderChannelName.Append("ReminderChannel");
            return(true);
        }
Beispiel #4
0
        internal ReminderReader(IServiceProvider services, string filePath = "", ReminderTypes type = ReminderTypes.Run)
        {
            FilePath     = filePath;
            ReminderType = type;

            _client = services.GetRequiredService <DiscordSocketClient>();
            _logger = services.GetRequiredService <ILogger <CommandHandler> >();
        }
Beispiel #5
0
        protected virtual ulong?GetReminderChannelForType(SocketGuild guild, ReminderTypes reminderType)
        {
            var channel = new GuildSettingsApi().GetReminderChannelForType(guild.Id, reminderType);

            if (channel == null)
            {
                ReminderServiceLog.Warning($"{guild.Name} does not have a type {reminderType} channel set");
            }
            return(channel);
        }
Beispiel #6
0
        public async Task <List <EventTaskAssignmentModel> > GetAssignmentsByType(ReminderTypes type)
        {
            using (IDbConnection db = new SqliteConnection(LoadConnectionString()))
            {
                var query         = $"Select * from {TableName} where AssignmentType = @AssignmentType";
                var dynamicParams = new DynamicParameters(new EventTaskAssignmentModel {
                    AssignmentType = (int)type
                });
                var data = await db.QueryAsync <EventTaskAssignmentModel>(query, dynamicParams);

                return(data.ToList());
            }
        }
Beispiel #7
0
 public AddReminderFormViewModel(INavigationService navigationService)
 {
     azureService       = DependencyService.Get <AzureService>();
     _navigationService = navigationService;
     ReminderTypes.Add("Veterinario");
     ReminderTypes.Add("Alimentacion");
     ReminderTypes.Add("Higine");
     ReminderTypes.Add("Ocio");
     reminder = new Reminder();
     OnSaveReminderCommand = new DelegateCommand(async() => await RunSafe(SaveReminder()));
     OnCancelCommand       = new DelegateCommand(async() => await _navigationService.GoBackAsync());
     OnGetPetsCommand      = new DelegateCommand(async() => await GetPets());
     OnGetPetsCommand.Execute();
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="Reminder"/> class,
 /// with minimal required parameters to create the new entity.
 /// </summary>
 /// <param name="userId">
 /// Id of the user that this reminder pertains to. A value of 0 indicates that this is a company-wide reminder.
 /// </param>
 /// <param name="reminderType">
 /// The type of this reminder object.
 /// </param>
 /// <param name="dueTime">
 /// The 24-hour time that the reminder should be sent. The time should be in even 5 minute increments. For example: '13:45:00' or '08:00:00'.
 /// </param>
 /// <param name="dueDaysOfWeek">
 /// The comma-separated list of the days of the week when the reminder should be sent. For example: 'Mon,Tue,Wed,Thu,Fri' or 'Tue,Sat'.
 /// </param>
 /// <param name="distributionMethods">
 /// The comma-separated list of the transport method(s) indicating how the reminder message should be sent.
 /// </param>
 /// <param name="active">
 /// The status of the reminder. If true, this reminder is active and will be evaluated at the
 /// <see cref="DueTime"/> and <see cref="DueDaysOfWeek"/>. If false, this reminder is inactive
 /// and will not be evaluated. If false for user-specific reminders, then the company-wide
 /// reminder of the same reminder type will apply.
 /// </param>
 /// <param name="enabled">
 /// The value indicating whether or not the reminder is enabled. If true, the reminder is enabled
 /// and will be sent at the <see cref="DueTime"/> and <see cref="DueDaysOfWeek"/>. If false, the
 /// reminder is disabled and will not be sent. A user with an active but disabled reminder will not
 /// receive that reminder type regardless of how company-wide reminders are configured.
 /// </param>
 public Reminder(
     int userId,
     ReminderTypes reminderType,
     DateTimeOffset dueTime,
     DaysOfTheWeek dueDaysOfWeek,
     ReminderDistributionMethods distributionMethods,
     bool active,
     bool enabled)
 {
     UserId              = userId;
     ReminderType        = reminderType;
     DueTime             = dueTime;
     DueDaysOfWeek       = dueDaysOfWeek;
     DistributionMethods = distributionMethods;
     Active              = active;
     Enabled             = enabled;
 }
Beispiel #9
0
        protected internal virtual void ProcessReminders(ReminderTypes type)
        {
            if (type == ReminderTypes.Project)
            {
                ReminderServiceLog.Warning("Recurring reminders are disabled until design refactor is complete");
                return;
            }
            //Get list of Event Assignments by type
            var eventTaskAssignments = GetListOfAssignments(type);
            //Filter into reminders that are due
            var dueReminders = eventTaskAssignments.Where(ShouldSendReminder);

            //Send reminders if required
            foreach (var reminder in dueReminders)
            {
                SendReminder(reminder);
            }
        }
        internal async Task <ulong?> GetReminderChannelForType(ulong guildId, ReminderTypes type)
        {
            ulong?result;

            if (GetReminderChannelForType(type, out var reminderChannelName) == false)
            {
                return(null);
            }

            var query         = $"Select {reminderChannelName.ToString()} from {TableName} where GuildId=@GuildId";
            var dynamicParams = new { GuildId = guildId };

            try
            {
                using IDbConnection db = new SqliteConnection(LoadConnectionString());
                result = await db.QueryFirstAsync <ulong?>(query, dynamicParams);
            }
            catch (Exception e)
            {
                result = null;
            }

            return(result);
        }
Beispiel #11
0
        public bool IsReminderTypeValid()
        {
            bool result = ((ReminderTypes != null && ReminderTypes.Any()) && TourDate <= DateTime.Now.ToUniversalTime()) ? false : true;

            return(result);
        }
Beispiel #12
0
 internal List <EventTaskAssignmentModel> GetAllAssignmentsByType(ReminderTypes type)
 {
     return(_repo.GetAssignmentsByType(type).Result);
 }
Beispiel #13
0
 public ulong?GetReminderChannelForType(ulong guildId, ReminderTypes reminderType)
 {
     return(_repo.GetReminderChannelForType(_model.GuildId, reminderType).Result);
 }
Beispiel #14
0
 public ulong?GetReminderChannelForType(ReminderTypes reminderType)
 {
     return(GetReminderChannelForType(_model.GuildId, reminderType));
 }
Beispiel #15
0
 protected internal virtual List <EventTaskAssignmentModel> GetListOfAssignments(ReminderTypes type)
 {
     return(new EventTaskAssignmentApi().GetAllAssignmentsByType(type));
 }