ics classes done

This commit is contained in:
Christian Fiedler
2013-09-04 17:28:30 +02:00
parent f73d722555
commit 4fba48225b
3 changed files with 911 additions and 87 deletions

View File

@@ -859,7 +859,7 @@ namespace CampusAppWP8.Utility
{
string retValue = string.Empty;
retValue += Name + ":" + string.Format("{0:yyyyMMdd}T{0:HHmmss}Z", this.value.ToUniversalTime());
retValue += Name + ":" + DateTimeToString(this.value);
return retValue;
}
@@ -974,14 +974,7 @@ namespace CampusAppWP8.Utility
isDate = true;
}
if (isDate)
{
retValue += string.Format("{0:yyyyMMdd}", this.value.ToUniversalTime());
}
else
{
retValue += string.Format("{0:yyyyMMdd}T{0:HHmmss}Z", this.value.ToUniversalTime());
}
retValue += DateTimeToString(this.value, isDate);
return retValue;
}
@@ -1105,7 +1098,13 @@ namespace CampusAppWP8.Utility
{
throw new NotSupportedException("params are not supported in (" + Name + ")");
}
if (valueStr[0].Equals('-') || valueStr[0].Equals('+'))
{
this.isNegative = valueStr[0].Equals('-');
valueStr = valueStr.Remove(0, 1);
}
this.value = StringToTimeSpan(valueStr);
}
@@ -1158,11 +1157,11 @@ namespace CampusAppWP8.Utility
});
private string freebusyType = string.Empty;
private List<Tuple<DateTime, TimeSpan, DateTime>> valueList = null;
private List<Tuple<DateTime, TimeSpan, DateTime, bool>> valueList = null;
public FreeBusyTime()
{
this.valueList = new List<Tuple<DateTime, TimeSpan, DateTime>>();
this.valueList = new List<Tuple<DateTime, TimeSpan, DateTime, bool>>();
}
public override void Set(string valueStr, string[] paramStrList = null)
@@ -1212,6 +1211,7 @@ namespace CampusAppWP8.Utility
DateTime partDTStart = UTCStringToDateTime(subSplit[0]);
TimeSpan partTSDur = TimeSpan.Zero;
DateTime partDTEnd = DateTime.MinValue;
bool partTSDurNegative = false;
if ((subSplit[1][subSplit[1].Length - 1].Equals('Z'))
|| (subSplit[1][subSplit[1].Length - 1] >= '0' && subSplit[1][subSplit[1].Length - 1] <= '9'))
@@ -1220,10 +1220,15 @@ namespace CampusAppWP8.Utility
}
else
{
if (subSplit[1][0].Equals('-') || subSplit[1][0].Equals('+'))
{
partTSDurNegative = subSplit[1][0].Equals('-');
subSplit[1] = subSplit[1].Remove(0, 1);
}
partTSDur = StringToTimeSpan(subSplit[1]);
}
this.valueList.Add(new Tuple<DateTime, TimeSpan, DateTime>(partDTStart, partTSDur, partDTEnd));
this.valueList.Add(new Tuple<DateTime, TimeSpan, DateTime, bool>(partDTStart, partTSDur, partDTEnd, partTSDurNegative));
}
}
@@ -1247,22 +1252,22 @@ namespace CampusAppWP8.Utility
retValue += ",";
}
retValue += string.Format("{0:yyyyMMdd}T{0:HHmmss}Z", this.valueList[i].Item1.ToUniversalTime()) + "/";
retValue += DateTimeToString(this.valueList[i].Item1) + "/";
if (this.valueList[i].Item2.Equals(TimeSpan.Zero))
{
retValue += string.Format("{0:yyyyMMdd}T{0:HHmmss}Z", this.valueList[i].Item3.ToUniversalTime());
retValue += DateTimeToString(this.valueList[i].Item3);
}
else
{
retValue += TimeSpanToString(this.valueList[i].Item2);
retValue += TimeSpanToString(this.valueList[i].Item2, this.valueList[i].Item4);
}
}
return retValue;
}
public List<Tuple<DateTime, TimeSpan, DateTime>> ValueList
public List<Tuple<DateTime, TimeSpan, DateTime, bool>> ValueList
{
get
{
@@ -1293,14 +1298,14 @@ namespace CampusAppWP8.Utility
}
}
public void AddValue(DateTime dtStart, TimeSpan tsDur)
public void AddValue(DateTime dtStart, TimeSpan tsDur, bool isNegative = false)
{
this.valueList.Add(new Tuple<DateTime, TimeSpan, DateTime>(dtStart, tsDur, DateTime.MinValue));
this.valueList.Add(new Tuple<DateTime, TimeSpan, DateTime, bool>(dtStart, tsDur, DateTime.MinValue, isNegative));
}
public void AddValue(DateTime dtStart, DateTime dtEnd)
{
this.ValueList.Add(new Tuple<DateTime, TimeSpan, DateTime>(dtStart, TimeSpan.Zero, dtEnd));
this.ValueList.Add(new Tuple<DateTime, TimeSpan, DateTime, bool>(dtStart, TimeSpan.Zero, dtEnd, false));
}
}
@@ -1982,12 +1987,792 @@ namespace CampusAppWP8.Utility
new Tuple<string, string[]>(ICSParam.TIME_ZONE_ID, null)
});
private List<Tuple<DateTime, DateTime, TimeSpan, bool>> values = null;
private List<Tuple<string, string>> paramList = null;
public DTRecurrence()
{
// CONTINUE
this.values = new List<Tuple<DateTime, DateTime, TimeSpan, bool>>();
this.paramList = new List<Tuple<string, string>>();
}
public override void Set(string valueStr, string[] paramStrList = null)
{
if (paramStrList != null && paramStrList.Count() > 0)
{
if (paramStrList.Count() > 1)
{
throw new NotSupportedException("there is only 1 param supported");
}
else
{
string[] pSplit = paramStrList[0].Split('=');
if (pSplit.Count() != 2)
{
throw new FormatException("unsupported param format (" + paramStrList + ") in (" + Name + ")");
}
if (CheckParamAndParamValue(pSplit[0], pSplit[1], PParams.ToArray()))
{
this.paramList.Add(new Tuple<string, string>(pSplit[0], pSplit[1]));
}
else
{
throw new NotSupportedException("unsupported param (" + paramStrList[0] + ") in (" + Name + ")");
}
}
}
string[] valSplit = valueStr.Split(',');
int pos = CheckParam(ICSParam.VALUE_TYPE, this.paramList.ToArray());
if ((pos < 0)
|| (this.paramList[pos].Item2.Equals(ICSParamValue.DATE_TIME))
|| (this.paramList[pos].Item2.Equals(ICSParamValue.DATE)))
{
for (int i = 0; i < valSplit.Count(); i++)
{
this.values.Add(new Tuple<DateTime, DateTime, TimeSpan, bool>(UTCStringToDateTime(valSplit[i]), DateTime.MinValue, TimeSpan.Zero, false));
}
}
else if (this.paramList[pos].Item2.Equals(ICSParamValue.PERIOD))
{
for (int i = 0; i < valSplit.Count(); i++)
{
string[] subVal = valSplit[i].Split('/');
if (subVal.Count() != 2)
{
throw new FormatException("unsupported format in (" + valSplit[i] + ")");
}
bool isNegative = false;
if (subVal[1][0].Equals('-') || subVal[1][0].Equals('+'))
{
isNegative = subVal[1][0].Equals('-');
subVal[1] = subVal[1].Remove(0, 1);
}
this.values.Add(
new Tuple<DateTime, DateTime, TimeSpan, bool>(
UTCStringToDateTime(subVal[0]),
((subVal[1][0].Equals('P') == false) ? UTCStringToDateTime(subVal[1]) : DateTime.MinValue),
((subVal[1][0].Equals('P') == true) ? StringToTimeSpan(subVal[1]) : TimeSpan.Zero),
isNegative));
}
}
else
{
throw new NotImplementedException("unhandled value type");
}
}
public override string GetString()
{
string retValue = string.Empty;
retValue += Name;
for(int i = 0; i < this.paramList.Count(); i++)
{
retValue += ";" + this.paramList[i].Item1 + "=" + this.paramList[i].Item2;
}
retValue += ":";
int pos = CheckParam(ICSParam.VALUE_TYPE, this.paramList.ToArray());
for (int i = 0; i < this.values.Count(); i++)
{
if (i > 0)
{
retValue += ',';
}
if((pos < 0) || (this.paramList[pos].Item2.Equals(ICSParamValue.DATE_TIME)))
{
retValue += DateTimeToString(this.values[i].Item1);
}
else if(this.paramList[pos].Item2.Equals(ICSParamValue.DATE))
{
retValue += DateTimeToString(this.values[i].Item1, true);
}
else if(this.paramList[pos].Item2.Equals(ICSParamValue.PERIOD))
{
retValue += DateTimeToString(this.values[i].Item1) + "/";
if(this.values[i].Item3.Equals(TimeSpan.Zero))
{
retValue += DateTimeToString(this.values[i].Item2);
}
else
{
retValue += TimeSpanToString(this.values[i].Item3, this.values[i].Item4);
}
}
else
{
throw new NotSupportedException("value type is not supported");
}
}
return retValue;
}
public List<Tuple<DateTime, DateTime, TimeSpan, bool>> Value
{
get
{
return this.values;
}
set
{
this.values = value;
}
}
public string ValueType
{
get
{
int pos = CheckParam(ICSParam.VALUE_TYPE, this.paramList.ToArray());
if (pos < 0)
{
return string.Empty;
}
else
{
return this.paramList[pos].Item2;
}
}
set
{
if (CheckParamAndParamValue(ICSParam.VALUE_TYPE, value, PParams.ToArray()))
{
int pos = CheckParam(ICSParam.VALUE_TYPE, this.paramList.ToArray());
if (pos < 0)
{
this.paramList.Add(new Tuple<string, string>(ICSParam.VALUE_TYPE, value));
}
else
{
this.paramList[pos] = new Tuple<string, string>(ICSParam.VALUE_TYPE, value);
}
}
else
{
throw new NotSupportedException("param value (" + value + ") is not supported");
}
}
}
}
public class RecurrenceRule : Interface
{
// 3.8.5.3.
public static readonly string Name = ICSTag.RRULE;
public static readonly List<Tuple<string, string[]>> PParams
= new List<Tuple<string, string[]>>();
public static readonly List<Tuple<string, string[]>> PValues
= new List<Tuple<string, string[]>>(new Tuple<string, string[]>[] {
new Tuple<string, string[]>(ICSValue.FREQ, new string[] {
ICSValueValue.SECONDLY,
ICSValueValue.MINUTELY,
ICSValueValue.HOURLY,
ICSValueValue.DAILY,
ICSValueValue.WEEKLY,
ICSValueValue.MONTHLY,
ICSValueValue.YEARLY
}),
new Tuple<string, string[]>(ICSValue.UNTIL, new string[] {
ICSValueValue.DATE,
ICSValueValue.DATE_TIME
}),
new Tuple<string, string[]>(ICSValue.COUNT, null),
new Tuple<string, string[]>(ICSValue.INTERVAL, null),
new Tuple<string, string[]>(ICSValue.BY_SECOND, null),
new Tuple<string, string[]>(ICSValue.BY_MINUTE, null),
new Tuple<string, string[]>(ICSValue.BY_HOUR, null),
new Tuple<string, string[]>(ICSValue.BY_DAY, null),
new Tuple<string, string[]>(ICSValue.BY_MONTH_DAY, null),
new Tuple<string, string[]>(ICSValue.BY_YEAR_DAY, null),
new Tuple<string, string[]>(ICSValue.BY_WEEK_NO, null),
new Tuple<string, string[]>(ICSValue.BY_MONTH, null),
new Tuple<string, string[]>(ICSValue.BY_SET_POS, null),
new Tuple<string, string[]>(ICSValue.WKST, new string[] {
ICSValueValue.DAY_SU,
ICSValueValue.DAY_MO,
ICSValueValue.DAY_TU,
ICSValueValue.DAY_WE,
ICSValueValue.DAY_TH,
ICSValueValue.DAY_FR,
ICSValueValue.DAY_SA
})
});
private List<Tuple<string, List<string>>> values = null;
public RecurrenceRule()
{
this.values = new List<Tuple<string, List<string>>>();
}
public override void Set(string valueStr, string[] paramStrList = null)
{
if (paramStrList != null && paramStrList.Count() > 0)
{
throw new NotSupportedException("there is no param supported");
}
string[] valSplit = valueStr.Split(';');
for (int i = 0; i < valSplit.Count(); i++)
{
string[] subVal = valSplit[i].Split('=');
if(subVal.Count() != 2)
{
throw new FormatException("unsupported format (" + valSplit[i] + ")");
}
string[] subValVal = subVal[1].Split(',');
if (CheckParamAndParamValue(subVal[0], subValVal, PValues.ToArray()))
{
this.values.Add(new Tuple<string, List<string>>(subVal[0], new List<string>(subValVal)));
}
else
{
throw new NotSupportedException("unsupported value (" + valSplit[i] + ")");
}
}
}
public override string GetString()
{
string retValue = string.Empty;
retValue += Name + ":";
for (int i = 0; i < this.values.Count(); i++)
{
if (i > 0)
{
retValue += ';';
}
retValue += this.values[i].Item1 + "=";
for (int k = 0; k < this.values[i].Item2.Count(); k++)
{
if(k > 0)
{
retValue += ",";
}
retValue += this.values[i].Item2[k];
}
}
return retValue;
}
public List<Tuple<string, List<string>>> Value
{
get
{
return this.values;
}
set
{
this.values = value;
}
}
}
public class Action : Interface
{
// 3.8.6.1.
public static readonly string Name = ICSTag.ACTION;
public static readonly List<Tuple<string, string[]>> PParams
= new List<Tuple<string, string[]>>();
public static readonly List<string> PValues
= new List<string>(new string[] {
ICSValue.AUDIO,
ICSValue.DISP,
ICSValue.EMAIL
});
private string value = string.Empty;
public Action()
{
}
public override void Set(string valueStr, string[] paramStrList = null)
{
if (paramStrList != null && paramStrList.Count() > 0)
{
throw new NotSupportedException("there is no param supported");
}
int pos = PValues.IndexOf(valueStr);
if (pos >= 0)
{
this.value = valueStr;
}
else
{
throw new NotSupportedException("unsuported value (" + valueStr + ")");
}
}
public override string GetString()
{
string retValue = string.Empty;
retValue += Name + ":" + this.value;
return retValue;
}
public string Value
{
get
{
return this.value;
}
set
{
if (PValues.IndexOf(value) >= 0)
{
this.value = value;
}
else
{
throw new NotSupportedException("unsupported value");
}
}
}
}
public class RepeatCount : Interface
{
// 3.8.6.2.
public static readonly string Name = ICSTag.REPEAT;
public static readonly List<Tuple<string, string[]>> PParams
= new List<Tuple<string, string[]>>();
private int value;
public RepeatCount()
{
}
public override void Set(string valueStr, string[] paramStrList = null)
{
if (paramStrList != null && paramStrList.Count() > 0)
{
throw new NotSupportedException("there is no param supported");
}
this.value = int.Parse(valueStr);
}
public override string GetString()
{
string retValue = string.Empty;
retValue += Name + ":" + this.value.ToString();
return retValue;
}
public int Value
{
get
{
return this.value;
}
set
{
if (value < 0)
{
value = 0;
}
this.value = value;
}
}
}
public class Trigger : Interface
{
// 3.8.6.3.
public static readonly string Name = ICSTag.TRIGGER;
public static readonly List<Tuple<string, string[]>> PParams
= new List<Tuple<string, string[]>>(new Tuple<string, string[]>[] {
new Tuple<string, string[]>(ICSParam.VALUE_TYPE, new string[] {
ICSParamValue.DURATION,
ICSParamValue.DATE_TIME
}),
new Tuple<string, string[]>(ICSParam.ALARM_TRIGGER_RELATIONSHIP, new string[] {
ICSParamValue.START,
ICSParamValue.END
})
});
private List<Tuple<string, string>> paramList = null;
private DateTime valueDT = DateTime.MinValue;
private TimeSpan valueTS = TimeSpan.Zero;
private bool valueTSNegative = false;
public Trigger()
{
this.paramList = new List<Tuple<string, string>>();
}
public override void Set(string valueStr, string[] paramStrList = null)
{
if (paramStrList != null && paramStrList.Count() > 0)
{
for (int i = 0; i < paramStrList.Count(); i++)
{
string[] pSplit = paramStrList[i].Split('=');
if(pSplit.Count() != 2)
{
throw new FormatException("unsupported param format (" + paramStrList[i] + ")");
}
if (CheckParamAndParamValue(pSplit[0], pSplit[1], PParams.ToArray()))
{
this.paramList.Add(new Tuple<string, string>(pSplit[0], pSplit[1]));
}
else
{
throw new NotSupportedException("unsupported param (" + paramStrList[i] + ")");
}
}
}
int pos = CheckParam(ICSParam.VALUE_TYPE, this.paramList.ToArray());
if((pos < 0) || (this.paramList[pos].Item2.Equals(ICSParamValue.DURATION)))
{
if (valueStr[0].Equals('-') || valueStr[0].Equals('+'))
{
this.valueTSNegative = valueStr[0].Equals('-');
valueStr = valueStr.Remove(0, 1);
}
this.valueTS = StringToTimeSpan(valueStr);
}
else if (this.paramList[pos].Item2.Equals(ICSParamValue.DATE_TIME))
{
this.valueDT = UTCStringToDateTime(valueStr);
}
else
{
throw new NotSupportedException("unsupported value format");
}
}
public override string GetString()
{
string retValue = string.Empty;
retValue += Name;
for (int i = 0; i < this.paramList.Count(); i++)
{
retValue += ";" + this.paramList[i].Item1 + "=" + this.paramList[i].Item2;
}
retValue += ":";
int pos = CheckParam(ICSParam.VALUE_TYPE, this.paramList.ToArray());
if ((pos < 0) || (this.paramList[pos].Item2.Equals(ICSParamValue.DURATION)))
{
retValue += TimeSpanToString(this.valueTS, this.valueTSNegative);
}
else if (this.paramList[pos].Item2.Equals(ICSParamValue.DATE_TIME))
{
retValue += DateTimeToString(this.valueDT);
}
else
{
throw new NotSupportedException("unsupported value format");
}
return retValue;
}
public DateTime ValueDT
{
get
{
return this.valueDT;
}
set
{
this.valueDT = value;
}
}
public TimeSpan ValeTS
{
get
{
return this.valueTS;
}
set
{
this.valueTS = value;
}
}
public List<Tuple<string, string>> Params
{
get
{
return this.paramList;
}
set
{
for (int i = 0; i < value.Count(); i++)
{
if (!CheckParamAndParamValue(value[i].Item1, value[i].Item2, PParams.ToArray()))
{
throw new NotSupportedException("unsupported param (" + value[i].Item1 + ") with value (" + value[i].Item2 + ")");
}
}
this.paramList = value;
}
}
}
public class DTCreated : Interface
{
// 3.8.7.1.
public static readonly string Name = ICSTag.DT_CREATED;
public static readonly List<Tuple<string, string[]>> PParams
= new List<Tuple<string, string[]>>();
private DateTime value = DateTime.MinValue;
public DTCreated()
{
}
public override void Set(string valueStr, string[] paramStrList = null)
{
if (paramStrList != null && paramStrList.Count() > 0)
{
throw new NotSupportedException("there are no params supported");
}
this.value = UTCStringToDateTime(valueStr);
}
public override string GetString()
{
string retValue = string.Empty;
retValue += Name + ":" + DateTimeToString(this.value);
return retValue;
}
public DateTime Value
{
get
{
return this.value;
}
set
{
this.value = value;
}
}
}
public class DTStamp : DTCreated // because has same structure
{
// 3.8.7.2.
public static readonly string Name = ICSTag.DT_STAMP;
public DTStamp()
: base()
{
}
}
public class LastModified : DTCreated // because has same structure
{
// 3.8.7.3.
public static readonly string Name = ICSTag.DT_MODIFIED;
public LastModified()
: base()
{
}
}
public class SequenceNumber : RepeatCount
{
// 3.8.7.4.
public static readonly string Name = ICSTag.SEQUENCE;
public SequenceNumber() : base()
{
}
}
public class IANAPropertie
{
// 3.8.8.1.
// TODO
}
public class NonStandardPropertie
{
// 3.8.8.2.
// TODO
}
public class RequestStatus : Interface
{
// 3.8.8.3.
public static readonly string Name = ICSTag.RSTATUS;
public static readonly List<Tuple<string, string[]>> PParams
= new List<Tuple<string, string[]>>(new Tuple<string, string[]>[] {
new Tuple<string, string[]>(ICSParam.LANGUAGE, null)
});
private List<Tuple<string, string>> paramList = null;
private float valueCode = 0.0f;
private List<string> valueList = null;
public RequestStatus()
{
this.paramList = new List<Tuple<string, string>>();
this.valueList = new List<string>();
}
public override void Set(string valueStr, string[] paramStrList = null)
{
if (paramStrList != null && paramStrList.Count() > 0)
{
if (paramStrList.Count() > 1)
{
throw new NotSupportedException("there is only 1 param supported");
}
string[] p = paramStrList[0].Split('=');
if (CheckParamAndParamValue(p[0], p[1], PParams.ToArray()))
{
this.paramList.Add(new Tuple<string, string>(p[0], p[1]));
}
else
{
throw new NotSupportedException("param (" + paramStrList[0] + ") is not supported");
}
}
string[] v = valueStr.Split(';');
if (v.Count() < 2)
{
throw new FormatException("not enought values");
}
for (int i = 0; i < v.Count(); i++)
{
if (i == 0)
{
this.valueCode = float.Parse(v[i]);
}
else
{
this.valueList.Add(v[i]);
}
}
}
public override string GetString()
{
string retValue = string.Empty;
retValue += Name;
for (int i = 0; i < this.paramList.Count(); i++)
{
retValue += ";" + this.paramList[i].Item1 + "=" + this.paramList[i].Item2;
}
retValue += ":" + string.Format("{0:0.0}", this.valueCode);
for (int i = 0; i < this.valueList.Count(); i++)
{
retValue += ";" + this.valueList[i];
}
return retValue;
}
public List<string> Value
{
get
{
return this.valueList;
}
set
{
if (value.Count() >= 1)
{
this.valueList = value;
}
else
{
throw new NotSupportedException("not enougth params");
}
}
}
public float Code
{
get
{
return this.valueCode;
}
set
{
if (value < 5.0)
{
this.valueCode = value;
}
else
{
throw new NotSupportedException("code value has to be lower then 5.0");
}
}
}
}
// functions
private static int CheckParam(string paramStr, Tuple<string, string>[] list)
@@ -2047,6 +2832,21 @@ namespace CampusAppWP8.Utility
return retValue;
}
private static bool CheckParamAndParamValue(string paramStr, string[] paramValueStr, Tuple<string, string[]>[] list)
{
bool retValue = true;
for (int i = 0; i < paramValueStr.Count(); i++)
{
if (!CheckParamAndParamValue(paramStr, paramValueStr[i], list))
{
retValue = false;
}
}
return retValue;
}
private static DateTime UTCStringToDateTime(string timeStr)
{
@@ -2163,5 +2963,21 @@ namespace CampusAppWP8.Utility
return retValue;
}
private static string DateTimeToString(DateTime val, bool isDate = false)
{
string retValue = string.Empty;
if (isDate)
{
retValue += string.Format("{0:yyyyMMdd}", val.ToUniversalTime());
}
else
{
retValue += string.Format("{0:yyyyMMdd}T{0:HHmmss}Z", val.ToUniversalTime());
}
return retValue;
}
}
}

View File

@@ -64,13 +64,6 @@ namespace CampusAppWP8.Utility
public void ImportFromICS(string icsData)
{
string t1 = ICSClasses.Attachment.Name;
string t2 = ICSClasses.Categories.Name;
ICSClasses.Attachment o1 = new ICSClasses.Attachment();
ICSClasses.Categories o2 = new ICSClasses.Categories();
List<Tuple<string, string[]>> l1 = ICSClasses.Attachment.PParams;
List<Tuple<string, string[]>> l2 = ICSClasses.Categories.PParams;
string[] elems = Regex.Split(this.Unfold(icsData), "\r\n");
List<ICSDict.ICSValueDesc> parentList = new List<ICSDict.ICSValueDesc>();
@@ -120,58 +113,6 @@ namespace CampusAppWP8.Utility
}
}
/*
switch (obj.name)
{
case ICSTag.BEGIN:
break;
case ICSTag.DT_CREATED:
//this.data.vevent.created = this.ParseUTC(parts[1]);
break;
case ICSTag.USER_ID:
//this.data.vevent.uid = parts[1];
break;
case "LAST-MODIFIED":
//this.data.vevent.lastModified = this.ParseUTC(parts[1]);
break;
case "DTSTAMP":
//this.data.vevent.stamp = this.ParseUTC(parts[1]);
break;
case "SUMMARY":
//this.data.vevent.summary = parts[1];
break;
case "DTSTART":
//this.data.vevent.start = this.ParseUTC(parts[1]);
break;
case "DTEND":
//this.data.vevent.end = this.ParseUTC(parts[1]);
break;
case "CLASS":
//this.data.vevent.accessClass = parts[1];
break;
case "LOCATION":
//this.data.vevent.location = parts[1];
break;
case "DESCRIPTION":
//this.data.vevent.description = parts[1];
break;
case "CATEGORIES":
//this.data.vevent.categories = parts[1];
break;
case "END":
break;
case "VERSION":
//this.data.version = parts[1];
break;
case "PRODID":
break;
case "X-WR-CALNAME":
break;
//default:
// throw new NotImplementedException("unknown tag in ics: " + parts[0]);
}
*/
}
}
@@ -210,6 +151,34 @@ namespace CampusAppWP8.Utility
return icsData.Replace("\r\n ", "").Replace("\r\n\x09", "");
}
private string Fold(string data)
{
string retValue = string.Empty;
string[] lines = Regex.Split(data, "\r\n");
for (int i = 0; i < lines.Count(); i++)
{
for (int k = 0; k < lines[i].Length; )
{
if (k == 0)
{
retValue += lines[i].Substring(k, (((lines[i].Length - k - 75) >= 0) ? 75 : (lines[i].Length - k)));
k += 75;
}
else
{
retValue += " " + lines[i].Substring(k, (((lines[i].Length - k - 74) >= 0) ? 74 : (lines[i].Length - k)));
k += 74;
}
retValue += "\r\n";
}
}
return retValue;
}
private string[] SplitParam(string paramStr)
{
return paramStr.Split('=');

View File

@@ -230,7 +230,7 @@ namespace CampusAppWP8.Utility
new ICSElemDesc(ICSTag.BEGIN, null, new ICSValueDesc[] {
new ICSValueDesc(ICSTag.VEVENT, new ICSElemDesc[] {
new ICSElemDesc(ICSTag.DT_STAMP, null, null),
new ICSElemDesc(ICSTag.USER_ID, null, null),
new ICSElemDesc(ICSTag.UNIQUE_ID, null, null),
new ICSElemDesc(ICSTag.DT_START, null, null),
new ICSElemDesc(ICSTag.ACCESS_CLASS, null, null),
new ICSElemDesc(ICSTag.DT_CREATED, null, null),
@@ -284,7 +284,7 @@ namespace CampusAppWP8.Utility
}),
new ICSValueDesc(ICSTag.VTODO, new ICSElemDesc[] {
new ICSElemDesc(ICSTag.DT_STAMP, null, null),
new ICSElemDesc(ICSTag.USER_ID, null, null),
new ICSElemDesc(ICSTag.UNIQUE_ID, null, null),
new ICSElemDesc(ICSTag.ACCESS_CLASS, null, null),
new ICSElemDesc(ICSTag.COMPLETED, null, null),
new ICSElemDesc(ICSTag.DT_CREATED, null, null),
@@ -339,7 +339,7 @@ namespace CampusAppWP8.Utility
}),
new ICSValueDesc(ICSTag.VJOURNAL, new ICSElemDesc[] {
new ICSElemDesc(ICSTag.DT_STAMP, null, null),
new ICSElemDesc(ICSTag.USER_ID, null, null),
new ICSElemDesc(ICSTag.UNIQUE_ID, null, null),
new ICSElemDesc(ICSTag.ACCESS_CLASS, null, null),
new ICSElemDesc(ICSTag.DT_CREATED, null, null),
new ICSElemDesc(ICSTag.DT_START, null, null),
@@ -367,7 +367,7 @@ namespace CampusAppWP8.Utility
}),
new ICSValueDesc(ICSTag.VFREEBUSY, new ICSElemDesc[] {
new ICSElemDesc(ICSTag.DT_STAMP, null, null),
new ICSElemDesc(ICSTag.USER_ID, null, null),
new ICSElemDesc(ICSTag.UNIQUE_ID, null, null),
new ICSElemDesc(ICSTag.CONTACT, null, null),
new ICSElemDesc(ICSTag.DT_START, null, null),
new ICSElemDesc(ICSTag.DT_END, null, null),
@@ -472,7 +472,7 @@ namespace CampusAppWP8.Utility
public const string COMMENT = "COMMENT";
public const string CONTACT = "CONTACT";
public const string EXDATE = "EXDATE";
public const string RSTATUS = "RSTATUS";
public const string RSTATUS = "REQUEST-STATUS";
public const string RELATED = "RELATED";
public const string RESOURCES = "RESOURCES";
public const string RDATE = "RDATE";
@@ -554,7 +554,7 @@ namespace CampusAppWP8.Utility
// ???
// public const string RELATED_TO = "RELATED-TO";
public const string SEQUENCE = "SEQUENCE";
}
public class ICSParam
@@ -613,6 +613,21 @@ namespace CampusAppWP8.Utility
// TRANSP
public const string OPAQUE = "OPAQUE";
public const string TRANSPARENT = "TRANSPARENT";
// recur
public const string FREQ = "FREQ";
public const string UNTIL = "UNTIL";
public const string COUNT = "COUNT";
public const string INTERVAL = "INTERVAL";
public const string BY_SECOND = "BYSECOND";
public const string BY_MINUTE = "BYMINUTE";
public const string BY_HOUR = "BYHOUR";
public const string BY_DAY = "BYDAY";
public const string BY_MONTH_DAY = "BYMONTHDAY";
public const string BY_YEAR_DAY = "BYYEARDAY";
public const string BY_WEEK_NO = "BYWEEKNO";
public const string BY_MONTH = "BYMONTH";
public const string BY_SET_POS = "BYSETPOS";
public const string WKST = "WKST";
}
public class ICSParamValue
@@ -674,4 +689,28 @@ namespace CampusAppWP8.Utility
// PARTSTAT
public const string IN_PROCESS = "IN-PROCESS";
}
public class ICSValueValue
{
// recur (3.3.10.)
// freq
public const string SECONDLY = "SECONDLY";
public const string MINUTELY = "MINUTELY";
public const string HOURLY = "HOURLY";
public const string DAILY = "DAILY";
public const string WEEKLY = "WEEKLY";
public const string MONTHLY = "MONTHLY";
public const string YEARLY = "YEARLY";
// until
public const string DATE = "DATE";
public const string DATE_TIME = "DATE-TIME";
// ...
public const string DAY_SU = "SU";
public const string DAY_MO = "MO";
public const string DAY_TU = "TU";
public const string DAY_WE = "WE";
public const string DAY_TH = "TH";
public const string DAY_FR = "FR";
public const string DAY_SA = "SA";
}
}