private NSCalendarUnit GetRepeatInterval(RepeatInterval repeat) { switch (repeat) { case RepeatInterval.Year: return(NSCalendarUnit.Year); case RepeatInterval.Month: return(NSCalendarUnit.Month); case RepeatInterval.Day: return(NSCalendarUnit.Day); case RepeatInterval.Hour: return(NSCalendarUnit.Hour); case RepeatInterval.Minute: return(NSCalendarUnit.Minute); case RepeatInterval.Second: return(NSCalendarUnit.Second); default: return(NSCalendarUnit.Calendar); } }
public void Save(XmlTextWriter xml) { xml.WriteStartElement("input"); xml.WriteAttributeString("deviceId", DeviceId); xml.WriteAttributeString("index", Index.ToString()); xml.WriteAttributeString("id", ID); xml.WriteAttributeString("description", Description); xml.WriteAttributeString("repeat", Repeat.ToString()); xml.WriteAttributeString("repeatAfter", RepeatAfter.ToString()); xml.WriteAttributeString("repeatInterval", RepeatInterval.ToString()); xml.WriteEndElement(); }
public override int GetHashCode() { unchecked { var hashCode = TaskId.GetHashCode(); hashCode = (hashCode * 397) ^ Recipient.GetHashCode(); hashCode = (hashCode * 397) ^ Message.GetHashCode(); hashCode = (hashCode * 397) ^ TriggerDateUtc.GetHashCode(); hashCode = (hashCode * 397) ^ RepeatInterval.GetHashCode(); hashCode = (hashCode * 397) ^ (Ack != null ? Ack.GetHashCode() : 0); return(hashCode); } }
private void AssertAllUpdateArguments(DateTime startDate, DateTime?endDate, RepeatEndStrategy repeatEndStrategy, RepeatInterval repeatInterval, int repeatOccurrenceNumber, string cronExpressionOverride) { AssertArguments(startDate > DateTime.MinValue, "A valid start date must be provided"); AssertArguments(repeatEndStrategy != RepeatEndStrategy.OnEndDate || endDate >= startDate, "It makes no sense to have an EndDate that's before the StartDate"); AssertArguments(repeatEndStrategy.DoesNotHaveEndStrategy() || repeatInterval.IsRepeating(), $"a {nameof(RepeatEndStrategy)} with no {nameof(RepeatInterval)} doesn't make sense"); AssertArguments(repeatEndStrategy != RepeatEndStrategy.AfterOccurrenceNumber || repeatOccurrenceNumber > 0, $"{nameof(RepeatOccurrenceNumber)} must be > 0 if the {nameof(RepeatEndStrategy.AfterOccurrenceNumber)} {nameof(RepeatEndStrategy)} is being used"); }
/// <summary> /// Show a local notification at a specified time /// </summary> /// <param name="title">Title of the notification</param> /// <param name="body">Body or description of the notification</param> /// <param name="id">Id of the notification</param> /// <param name="notifyTime">Time to show notification</param> /// <param name="repeat">Set up repeat on notification</param> public void Show(string title, string body, int id, DateTime notifyTime, RepeatInterval repeat) { var notification = new NSUserNotification() { Title = title, InformativeText = body, Identifier = id.ToString(), DeliveryDate = (NSDate)notifyTime, DeliveryRepeatInterval = GetRepeatInterval(repeat) }; NSUserNotificationCenter.DefaultUserNotificationCenter.ScheduleNotification(notification); }
/// <summary> /// Возвращает условие повторного выполнения директивы в виде строки (Каждый параметр выводится в новой строке) /// </summary> /// <returns></returns> public string RepeatPerformanceToStrings() { StringBuilder stringBuilder = new StringBuilder(); if (!RepeatInterval.IsNullOrZero()) { stringBuilder.Append(RepeatInterval.ToStrings()); if (RepeatInterval.NotNullParamsCount() > 1) { stringBuilder.AppendLine(RepeatPerformanceConditionType == ThresholdConditionType.WhicheverFirst ? "W.O.F" : "W.O.L"); } } return(stringBuilder.ToString()); }
public void Update(string domainName, DateTime startDate, DateTime?endDate, RepeatEndStrategy repeatEndStrategy, RepeatInterval repeatInterval, int repeatOccurrenceNumber, string updatedBy, string cronExpressionOverride = null) { AssertAllUpdateArguments(startDate, endDate, repeatEndStrategy, repeatInterval, repeatOccurrenceNumber, cronExpressionOverride); StartAt = startDate; EndAt = endDate; RepeatEndStrategy = repeatEndStrategy; RepeatInterval = repeatInterval; RepeatOccurrenceNumber = repeatOccurrenceNumber; DomainName = domainName; CronExpressionOverride = cronExpressionOverride; SetUpdatedBy(updatedBy); }
public ReminderData(AppMode appMode, string id, DateTime fireDate, DateTime endDate, RepeatInterval repeatInterval, string title, string message = null, DayOfWeek[] daysOfWeek = null) { // unchangeable value registrationDate = DateTime.Now; this.appMode = appMode; this.id = id; this.fireDate = fireDate; this.repeatInterval = repeatInterval; this.title = title; this.message = message; this.daysOfWeek = daysOfWeek; }
/// <summary> /// Возвращает условие повторного выполнения директивы /// </summary> /// <returns></returns> private string RepeatPerformanceToString() { string res = "and then repeat every "; if (!RepeatInterval.IsNullOrZero()) { res = LifelengthToString(RepeatInterval, "r.p"); } if (!RepeatNotification.IsNullOrZero()) { res += LifelengthToString(RepeatNotification, "r.p.n"); } return(res.Trim()); }
/// <summary> /// Представляет объект Directive Treshold в виде массива байтов для хранения в базе данных /// </summary> /// <returns></returns> public byte[] ToBinary() { List <byte> data = new List <byte>(SerializedDataLength); data.AddRange(DbTypes.Int64ToByteArray(EffectiveDate.Ticks)); data.AddRange(FirstPerformanceSinceNew.ConvertToByteArray()); data.AddRange(FirstPerformanceSinceEffectiveDate.ConvertToByteArray()); data.AddRange(FirstNotification.ConvertToByteArray()); data.Add((byte)(FirstPerformanceConditionType == ThresholdConditionType.WhicheverLater ? 1 : 0)); data.Add((byte)(PerformRepeatedly ? 1 : 0)); data.AddRange(RepeatInterval.ConvertToByteArray()); data.AddRange(RepeatNotification.ConvertToByteArray()); data.Add((byte)(RepeatPerformanceConditionType == ThresholdConditionType.WhicheverLater ? 1 : 0)); return(data.ToArray()); }
public void CopyData(ReminderData targetData) { this.isActive = targetData.isActive; this.isDeleted = targetData.isDeleted; this.isDefault = targetData.isDefault; this.isDone = targetData.isDone; this.id = targetData.id; this.title = targetData.title; this.message = targetData.message; this.fireDate = targetData.fireDate; this.endDate = targetData.endDate; this.repeatInterval = targetData.repeatInterval; this.daysOfWeek = targetData.daysOfWeek; }
public void ToDelimitedString_WithAllProperties_ReturnsCorrectlySequencedFields() { IType hl7Type = new RepeatInterval { RepeatPattern = new CodedWithExceptions { Identifier = "1" }, ExplicitTimeInterval = "2" }; string expected = "1^2"; string actual = hl7Type.ToDelimitedString(); Assert.Equal(expected, actual); }
public void Write(XmlTextWriter xml) { xml.WriteStartElement("keys"); xml.WriteAttributeString("id", ID); xml.WriteAttributeString("description", Description); xml.WriteAttributeString("repeat", Repeat.ToString()); xml.WriteAttributeString("repeatAfter", RepeatAfter.ToString()); xml.WriteAttributeString("repeatInterval", RepeatInterval.ToString()); for (int i = 0; i < Keys.Length; i++) { xml.WriteStartElement("key"); xml.WriteAttributeString("value", Keys[i].ToString()); xml.WriteEndElement(); } xml.WriteEndElement(); }
public void ChangeRepeatInterval(RepeatInterval repeatInterval, DayOfWeek[] daysOfWeek = null) { this.repeatInterval = repeatInterval; this.daysOfWeek = daysOfWeek; if (repeatInterval != RepeatInterval.WEEK || repeatInterval != RepeatInterval.FORTNIGHT) { Debug.LogWarning( $"Can't set days of week while interval doesn't set to WEEK or FORTNIGHT. Now it's <{repeatInterval}>"); } // remove old notifications RemoveAllNotifications(); // set new, updated one SetupReminder(); }
public void FromDelimitedString_WithAllProperties_ReturnsCorrectlyInitializedFields() { IType expected = new RepeatInterval { RepeatPattern = new CodedWithExceptions { IsSubcomponent = true, Identifier = "1" }, ExplicitTimeInterval = "2" }; IType actual = new RepeatInterval(); actual.FromDelimitedString("1^2"); expected.Should().BeEquivalentTo(actual); }
private void AddEventHandler(Scheduler scheduler, IntervalType intervalType, RepeatInterval repeatInterval, int repeatIntervalValue) { switch (intervalType) { case IntervalType.Minutely: { scheduler.Timer.Elapsed += (sender, e) => HandleMinutelyEvent(scheduler.ParentName); break; } case IntervalType.Hourly: { scheduler.Timer.Elapsed += (sender, e) => HandleHourlyEvent(scheduler.ParentName, repeatInterval, repeatIntervalValue); break; } default: break; } }
/// <summary> /// Show a local notification at a specified time /// </summary> /// <param name="title">Title of the notification</param> /// <param name="body">Body or description of the notification</param> /// <param name="id">Id of the notification</param> /// <param name="notifyTime">Time to show notification</param> /// /// <param name="repeat">Set up repeat on notification</param> public void Show(string title, string body, int id, DateTime notifyTime, RepeatInterval repeat) { var xmlData = string.Format(_TOAST_TEXT02_TEMPLATE, title, body); var xmlDoc = new XmlDocument(); xmlDoc.LoadXml(xmlData); var correctedTime = notifyTime <= DateTime.Now ? DateTime.Now.AddMilliseconds(100) : notifyTime; var scheduledTileNotification = new ScheduledTileNotification(xmlDoc, correctedTime) { Id = id.ToString() }; TileUpdateManager.CreateTileUpdaterForApplication().AddToSchedule(scheduledTileNotification); }
/// <summary> /// Show a local notification at a specified time /// </summary> /// <param name="title">Title of the notification</param> /// <param name="body">Body or description of the notification</param> /// <param name="id">Id of the notification</param> /// <param name="notifyTime">Time to show notification</param> /// <param name="repeat">Set up repeat on notification</param> public void Show(string title, string body, int id, DateTime notifyTime, RepeatInterval repeat) { if (UIDevice.CurrentDevice.CheckSystemVersion(10, 0)) { var trigger = UNCalendarNotificationTrigger.CreateTrigger(GetNSDateComponentsFromDateTime(notifyTime), false); ShowUserNotification(title, body, id, trigger); } else { var notification = new UILocalNotification { FireDate = (NSDate)notifyTime, AlertTitle = title, AlertBody = body, UserInfo = NSDictionary.FromObjectAndKey(NSObject.FromObject(id), NSObject.FromObject(NotificationKey)), RepeatInterval = GetRepeatInterval(repeat) }; UIApplication.SharedApplication.ScheduleLocalNotification(notification); } }
private NSDateComponents GetRepeatInterval(RepeatInterval repeat) { if (repeat == RepeatInterval.No) { return(null); } NSDateComponents repeateTime = new NSDateComponents(); switch (repeat) { case RepeatInterval.Year: repeateTime.Year = 1; break; case RepeatInterval.Month: repeateTime.Month = 1; break; case RepeatInterval.Day: repeateTime.Day = 1; break; case RepeatInterval.Hour: repeateTime.Hour = 1; break; case RepeatInterval.Minute: repeateTime.Minute = 1; break; case RepeatInterval.Second: repeateTime.Second = 1; break; } return(repeateTime); }
/// <summary> /// Возвращает условие повторного выполнения директивы /// </summary> /// <returns></returns> private string RepeatPerformanceToString() { //if (!PerformRepeatedly) return "and then close"; //else if (PerformRepeatedly && (RepeatInterval == null || RepeatInterval.IsNullLifelength())) // return "repeat interval depends on first performance"; //else //{ string res = "and then repeat every "; // Lifelength repeat = new Lifelength(); if (!RepeatInterval.IsNullOrZero()) { res = LifelengthToString(RepeatInterval, "r.p"); } if (!RepeatNotification.IsNullOrZero()) { res += LifelengthToString(RepeatNotification, "r.p.n"); } return(res.Trim()); //} }
public static bool IsRepeating(this RepeatInterval repeatInterval) => repeatInterval != RepeatInterval.Never && repeatInterval != RepeatInterval.NotUsed;
/// <summary> /// Show a local notification at a specified time /// </summary> /// <param name="title">Title of the notification</param> /// <param name="body">Body or description of the notification</param> /// <param name="id">Id of the notification</param> /// <param name="notifyTime">Time to show notification</param> /// <param name="repeat">Set up repeat on notification</param> public void Show(string title, string body, int id, DateTime notifyTime, RepeatInterval repeat) { var intent = CreateIntent(id); var localNotification = new LocalNotification(); localNotification.Title = title; localNotification.Body = body; localNotification.Id = id; localNotification.NotifyTime = notifyTime; if (NotificationIconId != 0) { localNotification.IconId = NotificationIconId; } else { localNotification.IconId = Resource.Drawable.plugin_lc_smallicon; } var serializedNotification = SerializeNotification(localNotification); intent.PutExtra(ScheduledAlarmHandler.LocalNotificationKey, serializedNotification); var pendingIntent = PendingIntent.GetBroadcast(Application.Context, 0, intent, PendingIntentFlags.CancelCurrent); var triggerTime = NotifyTimeInMilliseconds(localNotification.NotifyTime); var alarmManager = GetAlarmManager(); if (repeat == RepeatInterval.No) { alarmManager.Set(AlarmType.RtcWakeup, triggerTime, pendingIntent); } else { long repeateDay = 0; switch (repeat) { case RepeatInterval.Year: repeateDay = 31557600000; break; case RepeatInterval.Month: repeateDay = 2629800000; break; case RepeatInterval.Day: repeateDay = 86400000; break; case RepeatInterval.Hour: repeateDay = 3600000; break; case RepeatInterval.Minute: repeateDay = 60000; break; case RepeatInterval.Second: repeateDay = 1000; break; } var totalMilliSeconds = (long)(notifyTime.ToUniversalTime() - _jan1st1970).TotalMilliseconds; if (totalMilliSeconds < JavaSystem.CurrentTimeMillis()) { totalMilliSeconds = totalMilliSeconds + repeateDay; } alarmManager.SetRepeating(AlarmType.RtcWakeup, totalMilliSeconds, repeateDay, pendingIntent); } }
public void HandleStartEvent(string schedulerName, SchedulerType schedulerType, IntervalType intervalType, int interval, RepeatInterval repeatInterval = RepeatInterval.None, int repeatIntervalValue = 0) { ProcessTask(schedulerName); var delay = TimerHelper.Getinterval(intervalType, interval); var scheduler = _schedulerFactory.New(schedulerName, delay); AddEventHandler(scheduler, intervalType, repeatInterval, repeatIntervalValue); }
public override string ToString() => $"Schedule(id:{TaskId}, receiver:{Recipient}, at:{TriggerDateUtc}, repeat:{RepeatInterval?.ToString() ?? "no"}, message:{Message})";
public bool Equals(Schedule other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(string.Equals(TaskId, other.TaskId) && Equals(Recipient, other.Recipient) && Equals(Message, other.Message) && TriggerDateUtc.Equals(other.TriggerDateUtc) && RepeatInterval.Equals(other.RepeatInterval) && Equals(Ack, other.Ack)); }
public void HandleHourlyEvent(string schedulerName, RepeatInterval repeatinterval, int repeatintervalValue, bool stopOnTimeOut = false, DateTime?timeOutTime = null) { throw new NotImplementedException(); }