惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

L
LINUX DO - 热门话题
Stack Overflow Blog
Stack Overflow Blog
B
Blog
WordPress大学
WordPress大学
Project Zero
Project Zero
P
Palo Alto Networks Blog
阮一峰的网络日志
阮一峰的网络日志
博客园 - 司徒正美
有赞技术团队
有赞技术团队
S
SegmentFault 最新的问题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
小众软件
小众软件
T
Tailwind CSS Blog
Forbes - Security
Forbes - Security
F
Full Disclosure
SecWiki News
SecWiki News
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Hacker News: Ask HN
Hacker News: Ask HN
C
Check Point Blog
Microsoft Security Blog
Microsoft Security Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
F
Fortinet All Blogs
Cisco Talos Blog
Cisco Talos Blog
G
Google Developers Blog
J
Java Code Geeks
Google DeepMind News
Google DeepMind News
人人都是产品经理
人人都是产品经理
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Recorded Future
Recorded Future
O
OpenAI News
Spread Privacy
Spread Privacy
MongoDB | Blog
MongoDB | Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
C
Cybersecurity and Infrastructure Security Agency CISA
S
Securelist
V
Vulnerabilities – Threatpost
Y
Y Combinator Blog
IT之家
IT之家
U
Unit 42
腾讯CDC
S
Security Affairs
C
Cisco Blogs
Schneier on Security
Schneier on Security
The Last Watchdog
The Last Watchdog
B
Blog RSS Feed
宝玉的分享
宝玉的分享
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
S
Security @ Cisco Blogs
Cyberwarzone
Cyberwarzone
T
The Blog of Author Tim Ferriss

博客园 - newr2006

Android adb.exe 开发模试安装 HttpWebRequest 模拟浏览器访问网站 jquery check box Fiddler Post Debug symbol MC 3090 upgrade to symbol MC 3190 ALTER TABLE unable to add host to SCVMM 2008R2 Cannot generate SSPI context ASP.NET代码对页面输出进行清理 - newr2006 - 博客园 线程 Thread 传参数 好的博客 Login failed for user 'NT AUTHORITY\NETWORK SERVICE'. 解决办法 - newr2006 Hashtable(HashSet),ListDictionary,HybridDictionary 和 NameValueCollection Pocket pc 与 Smartphone 开发的区别 XMl 文件属性的读取 USA 的网站终于把中国的名字排上去了. Menu 控件弹出窗口(popupwindow) 删除一些难删除的程序 Page_ClientValidate 用法
提前两天发邮件
newr2006 · 2009-05-04 · via 博客园 - newr2006

提前两天发邮件,

public static void SendMail(object sender, ElapsedEventArgs e)
        {          
            foreach (KeyValuePair<string, System.Timers.Timer> keyValuePair in Globals.TimerLists)
            {
                if (keyValuePair.Value == sender)
                {
                    string machineId = keyValuePair.Key;
                    using (Database accessor = new Database())
                    {
                        CheckOutInfo info = accessor.SelectCheckoutRecord(machineId);
                        if(info == null)
                        {
                            return;
                        }
                        //info.DueDate is expriation day
                        TimeSpan diff = DateTime.Now.Subtract(info.DueDate) + new TimeSpan(2, 0, 0, 0, 0);
                        diff = diff.Add(new TimeSpan(1, 0, 0)); // Add 1 hour to ignore the short time elapsed during processing.

                        // reSet the interval to let timer trigger next day.
                        if (diff.TotalDays < 0)
                        {
                            Debug.WriteLine("diff.Seconds< 0");
                            System.Timers.Timer reminderTimer = (System.Timers.Timer)sender;
                            reminderTimer.Interval = GetNextTriggerInterval(info.DueDate);
                            Debug.WriteLine(reminderTimer.Interval.ToString());
                            reminderTimer.AutoReset = false;
                            reminderTimer.Enabled = true;
                            break;
                        }
                        //Email reminder should be sent from 2 days before expiration;
                        else if (diff.TotalDays <= 2.0 && diff.TotalDays>=0.0)
                        {
                            VM vm = ShareFactory.GetVMByID(new Guid(machineId));
                            if (vm != null)
                            {
                                System.Timers.Timer reminderTimer = (System.Timers.Timer)sender;
                                reminderTimer.Interval = GetNextTriggerInterval(info.DueDate);
                                Debug.WriteLine(reminderTimer.Interval.ToString());
                                reminderTimer.AutoReset = false;
                                reminderTimer.Enabled = true;

                                string  Language = accessor.GetMachineLanguage(machineId);
                                ReservePolicy reservePolicy = ConfigurationFactory.GetReservePolicy(info.ReserveType);
                                if (info.ExtendTimes < reservePolicy.ExtendTimes)
                                {
                                    Debug.WriteLine("SendExpireEmail");                                 
                                }
                                else
                                {
                                    Debug.WriteLine("SendCheckinEmail");
                                 
                                }
                            }
                            else
                            {
                                // Machine does not exist. Just delete the records.
                               Debug.WriteLine("Machine does not exist. Just delete the records.");                             
                                Globals.TimerLists.Remove(machineId);
                            }

                        }
                        else
                        {
                             Debug.WriteLine("CheckIn");                           
                        }
                    }

                    break;
                }
            }
        }