Ejemplo n.º 1
0
		private StringBuilder ComposeFieldReminder(Property dtStart, Reminder reminder) {
			StringBuilder result = new StringBuilder(60); // Estimate 60 is needed
			result.Append("AALARM");

			string typeParam = reminder.PropertyType;
			if (typeParam != null) {
				result.Append(";TYPE=");
				result.Append(typeParam);
			}
			
			string valueParam = reminder.Value;
			if (valueParam != null) {
				result.Append(";VALUE=");
				result.Append(valueParam);
			}
			
			AddXParams(result, reminder);

			DateTime dateStart;

			string dtStartVal = dtStart.Value;
			dtStartVal = HandleLocalDateConversion(dtStartVal, TimeZone);

			try {
				dateStart = DateTime.ParseExact(dtStartVal, TimeUtils.getDateFormat(dtStartVal), CultureInfo.InvariantCulture);
			} catch (FormatException) {
				//is not possible
				//TODO: what to do now?
				dateStart = DateTime.Now;
			}

			DateTime dtAlarm = dateStart.AddMinutes(-reminder.Minutes);
			String dtAlarmVal = dtAlarm.ToString("yyyyMMdd'T'HHmmss'Z'");

			result.Append(":");
			result.Append(dtAlarmVal);
			result.Append(";");
			
			if (reminder.Interval != 0)
				result.Append(TimeUtils.getIso8601Duration(reminder.Interval.ToString()));
			
			result.Append(";");
			result.Append(reminder.RepeatCount);

			result.Append(";");
			if (reminder.SoundFile != null)
				result.Append(reminder.SoundFile);
			
			result.Append("\r\n");

			return result;
		}