public JobParameters GetJobParameters(NameValueCollection props)
{
if (props == null || props.Count == 0)
{
return new JobParameters();
}
JobParametersBuilder propertiesBuilder = new JobParametersBuilder();
foreach (string pkey in props.Keys)
{
string key = pkey;
string value = props[pkey];
bool identifying = IsIdentifyingKey(key);
if (!identifying)
{
key = StringUtils.ReplaceFirst(key, NonIdentifyingFlag, "");
}
else if (key.StartsWith(IdentifyingFlag))
{
key = StringUtils.ReplaceFirst(key, IdentifyingFlag, "");
}
if (key.EndsWith(DateType))
{
DateTime? date;
try
{
date = DateTime.ParseExact(value, _dateFormat, CultureInfo.InvariantCulture);
}
catch (FormatException)
{
throw new ArgumentException(string.Format("Date Format is invalid :[{0}] {1}" ,value, _dateFormat));
}
propertiesBuilder.AddDate(key.Replace(DateType, string.Empty), date, identifying);
}
else if (key.EndsWith(LongType))
{
long result = ParseLong(value);
propertiesBuilder.AddLong(key.Replace(LongType, string.Empty), result, identifying);
}
else if (key.EndsWith(DoubleType))
{
double result = ParseDouble(value);
propertiesBuilder.AddDouble(key.Replace(DoubleType, string.Empty), result, identifying);
}
else if (StringUtils.EndsWithIgnoreCase(key, StringType))
{
propertiesBuilder.AddString(key.Replace(StringType, string.Empty), value, identifying);
}
else
{
propertiesBuilder.AddString(key, value, identifying);
}
}
return propertiesBuilder.ToJobParameters();
}