private static void SendReminders()
{
SqlConnection newOpenConnection = DBUtils.GetNewOpenConnection();
try
{
IEnumerable<object> source = newOpenConnection.Query("SELECT crmTasks.TaskID, crmTasks.DueDate, crmTasks.TaskText, crmUsers.email, crmUsers.InstanceID, crmUsers_1.email as AssignedToEmail, (case when FLOOR(CAST(GETDATE() AS FLOAT))> FLOOR(CAST(crmTasks.DueDate AS FLOAT)) then 1 when FLOOR(CAST(GETDATE() AS FLOAT))= FLOOR(CAST(crmTasks.DueDate AS FLOAT)) then 0 end) as Overdue\r\n\t\t\t\t\t\t\t\tFROM crmTasks \r\n\t\t\t\t\t\t\t\tINNER JOIN crmUsers ON crmTasks.UserID = crmUsers.UserID\r\n\t\t\t\t\t\t\t\tLEFT JOIN crmUsers crmUsers_1 ON crmTasks.AssignedToUserID = crmUsers_1.UserID\r\n\t\t\t\t\t\t\t\tWHERE crmTasks.SendReminder=1\r\n\t\t\t\t\t\t\t\tAND crmTasks.IsCompleted=0\r\n\t\t\t\t\t\t\t\tAND FLOOR(CAST(GETDATE() AS FLOAT))>= FLOOR(CAST(crmTasks.DueDate AS FLOAT))", null, null, true, null, null);
newOpenConnection.Close();
IEnumerable<string> first = from x in source select (string) ((dynamic) x).email;
IEnumerable<string> second = from x in source select (string) ((dynamic) x).AssignedToEmail;
using (IEnumerator<string> enumerator = first.Union<string>(second).Distinct<string>().GetEnumerator())
{
Func<object, bool> predicate = null;
string email;
while (enumerator.MoveNext())
{
email = enumerator.Current;
if (predicate == null)
{
predicate = delegate ([Dynamic] object x) {
object obj2 = ((dynamic) x).email == email;
if (<SendReminders>o__SiteContainer8.<>p__Site10 == null)
{
<SendReminders>o__SiteContainer8.<>p__Site10 = CallSite<System.Func<CallSite, object, bool>>.Create(Binder.UnaryOperation(CSharpBinderFlags.None, ExpressionType.IsTrue, typeof(Tasks), new CSharpArgumentInfo[] { CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null) }));
}
if (!<SendReminders>o__SiteContainer8.<>p__Site10.Target(<SendReminders>o__SiteContainer8.<>p__Site10, obj2) && (<SendReminders>o__SiteContainer8.<>p__Site11 == null))
{
<SendReminders>o__SiteContainer8.<>p__Site11 = CallSite<Func<CallSite, object, object, object>>.Create(Binder.BinaryOperation(CSharpBinderFlags.BinaryOperationLogical, ExpressionType.Or, typeof(Tasks), new CSharpArgumentInfo[] { CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null), CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null) }));
}
return (<SendReminders>o__SiteContainer8.<>p__Site13 != null) ? ((bool) obj2) : ((bool) <SendReminders>o__SiteContainer8.<>p__Site11.Target(<SendReminders>o__SiteContainer8.<>p__Site11, obj2, ((dynamic) <SendReminders>o__SiteContainer8.<>p__Site13.Target(<SendReminders>o__SiteContainer8.<>p__Site13, x)) == email));
};
}
IEnumerable<object> enumerable5 = source.Where<object>(predicate).Distinct<object>();
IEnumerable<object> enumerable6 = from x in enumerable5
where (bool) (((dynamic) x).Overdue == false)
select x;
IOrderedEnumerable<object> enumerable7 = from x in enumerable5
where (bool) (((dynamic) x).Overdue == true)
orderby ((dynamic) x).DueDate
select x;
if (enumerable5.Any<object>())
{
dynamic obj2 = enumerable5.FirstOrDefault<object>();
int instanceId = (int) obj2.InstanceID;
DateTime currTime = VariousUtils.GetCurrTime(instanceId);
if (currTime.Hour == 7)
{
string str = "";
string str2 = VariousUtils.GetApplicationURL(instanceId) + "?Tasks=1#";
if (enumerable6.Count<object>() > 0)
{
str = "This is a reminder about tasks which are due today:\r\n\r\n";
foreach (dynamic obj3 in enumerable6)
{
if (((DateTime) obj3.DueDate.Date) == currTime.Date)
{
if (<SendReminders>o__SiteContainer8.<>p__Site21 == null)
{
<SendReminders>o__SiteContainer8.<>p__Site21 = CallSite<Func<CallSite, string, object, object>>.Create(Binder.BinaryOperation(CSharpBinderFlags.None, ExpressionType.AddAssign, typeof(Tasks), new CSharpArgumentInfo[] { CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType, null), CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null) }));
}
str = (string) <SendReminders>o__SiteContainer8.<>p__Site21.Target(<SendReminders>o__SiteContainer8.<>p__Site21, str, string.Format("{0}\r\n{1}\r\n\r\n", obj3.TaskText, str2 + obj3.TaskID));
}
}
}
else
{
str = "You have no tasks which are due today.";
}
if (enumerable7.Count<object>() > 0)
{
str = str + "\r\n\r\nThese tasks are overdue:\r\n\r\n";
foreach (dynamic obj4 in enumerable7)
{
if (<SendReminders>o__SiteContainer8.<>p__Site27 == null)
{
<SendReminders>o__SiteContainer8.<>p__Site27 = CallSite<Func<CallSite, string, object, object>>.Create(Binder.BinaryOperation(CSharpBinderFlags.None, ExpressionType.AddAssign, typeof(Tasks), new CSharpArgumentInfo[] { CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType, null), CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null) }));
}
TimeSpan span = (TimeSpan) (currTime.Date - ((DateTime) obj4.DueDate.Date));
str = (string) <SendReminders>o__SiteContainer8.<>p__Site27.Target(<SendReminders>o__SiteContainer8.<>p__Site27, str, string.Format("{0} ({1} days overdue)\r\n{2}\r\n\r\n", obj4.TaskText, span.TotalDays, str2 + obj4.TaskID));
}
}
else
{
str = str + "\r\n\r\nYou have no overdue tasks.";
}
SendMail.Send(new string[] { email }, "CRM task reminder", str, null, null, new int?(instanceId), false, null, false);
}
}
}
}
}
catch
{
}
}
{
Tasks.<SendReminders>o__SiteContainer8.<>p__Site29 = CallSite<Func<CallSite, object, object>>.Create(Binder.GetMember(CSharpBinderFlags.None, "TaskText", typeof(Tasks), new CSharpArgumentInfo[]
{
CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null)
}));
}
object arg_89D_4 = Tasks.<SendReminders>o__SiteContainer8.<>p__Site29.Target(Tasks.<SendReminders>o__SiteContainer8.<>p__Site29, current2);
System.DateTime arg_7E6_0 = currTime.Date;
if (Tasks.<SendReminders>o__SiteContainer8.<>p__Site2a == null)
{
Tasks.<SendReminders>o__SiteContainer8.<>p__Site2a = CallSite<Func<CallSite, object, System.DateTime>>.Create(Binder.Convert(CSharpBinderFlags.ConvertExplicit, typeof(System.DateTime), typeof(Tasks)));
}
Func<CallSite, object, System.DateTime> arg_7E1_0 = Tasks.<SendReminders>o__SiteContainer8.<>p__Site2a.Target;
CallSite arg_7E1_1 = Tasks.<SendReminders>o__SiteContainer8.<>p__Site2a;
if (Tasks.<SendReminders>o__SiteContainer8.<>p__Site2b == null)
{
Tasks.<SendReminders>o__SiteContainer8.<>p__Site2b = CallSite<Func<CallSite, object, object>>.Create(Binder.GetMember(CSharpBinderFlags.None, "Date", typeof(Tasks), new CSharpArgumentInfo[]
{
CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null)
}));
}
Func<CallSite, object, object> arg_7DC_0 = Tasks.<SendReminders>o__SiteContainer8.<>p__Site2b.Target;
CallSite arg_7DC_1 = Tasks.<SendReminders>o__SiteContainer8.<>p__Site2b;
if (Tasks.<SendReminders>o__SiteContainer8.<>p__Site2c == null)
{
Tasks.<SendReminders>o__SiteContainer8.<>p__Site2c = CallSite<Func<CallSite, object, object>>.Create(Binder.GetMember(CSharpBinderFlags.None, "DueDate", typeof(Tasks), new CSharpArgumentInfo[]
{
CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null)
}));
}
有高手还原下源代码?谢谢!