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

推荐订阅源

WordPress大学
WordPress大学
Microsoft Security Blog
Microsoft Security Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
V
Visual Studio Blog
宝玉的分享
宝玉的分享
IT之家
IT之家
人人都是产品经理
人人都是产品经理
T
The Blog of Author Tim Ferriss
I
InfoQ
B
Blog RSS Feed
T
Threatpost
博客园_首页
M
MIT News - Artificial intelligence
Spread Privacy
Spread Privacy
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Know Your Adversary
Know Your Adversary
U
Unit 42
Engineering at Meta
Engineering at Meta
C
Cyber Attacks, Cyber Crime and Cyber Security
月光博客
月光博客
Scott Helme
Scott Helme
T
Tor Project blog
有赞技术团队
有赞技术团队
AWS News Blog
AWS News Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Last Week in AI
Last Week in AI
S
Schneier on Security
Vercel News
Vercel News
博客园 - Franky
C
Cybersecurity and Infrastructure Security Agency CISA
L
LINUX DO - 热门话题
NISL@THU
NISL@THU
L
LangChain Blog
爱范儿
爱范儿
Google DeepMind News
Google DeepMind News
The GitHub Blog
The GitHub Blog
雷峰网
雷峰网
Latest news
Latest news
C
CXSECURITY Database RSS Feed - CXSecurity.com
Hugging Face - Blog
Hugging Face - Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
www.infosecurity-magazine.com
www.infosecurity-magazine.com
G
GRAHAM CLULEY
S
Security Affairs
A
About on SuperTechFans
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
大猫的无限游戏
大猫的无限游戏
W
WeLiveSecurity
Cisco Talos Blog
Cisco Talos Blog
罗磊的独立博客

博客园 - 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;
                }
            }
        }