public void SendWeatherDaily(Object threadContext) { downloadweather(); //Main._Main.Timer.Enabled = false; //Variables.MailMan.WaitOne(); foreach (string email in GetWeatherEmailList()) { int Who = NM.FromWho(email); if (Who == -1) { NM.sendEmailHTML(email, "Nobody", "", "", true, true, ""); } else { string petorfirstname; if (Variables.Contacts[Who].Closeness >= 75) { petorfirstname = Variables.Contacts[Who].PetName; } else { petorfirstname = Variables.Contacts[Who].FirstName; } NM.sendEmailHTML(Variables.Contacts[Who].Email, Variables.Contacts[Who].FirstName + " " + Variables.Contacts[Who].LastName, "", "", true, true, petorfirstname); } } _doneEvent.Set(); }
public void CheckDriveforSystemSpace(Object threadContext) { DriveInfo[] allDrives = DriveInfo.GetDrives(); foreach (DriveInfo d in allDrives) { //Console.WriteLine(d.Name.ToUpper().Trim()); //Console.WriteLine("BINGO"); if (d.IsReady == true) { //Console.WriteLine(d.TotalFreeSpace); //Console.WriteLine(d.TotalSize); double ratio = Convert.ToDouble(d.TotalFreeSpace) / Convert.ToDouble(d.TotalSize); //Console.WriteLine(ratio); if (ratio < Variables.DriveSpaceFreePercent - 0.02) //0.01 is a gap { //give us a warning... foreach (string email in GetEmailList()) { int Who = NM.FromWho(email); if (Who == -1) { string MSG; MSG = string.Format("{0}, the drive {1} is now {2} availabe space. You need at least {3}MB free space. Please remove some or transfer to another drive. {0}. I'll check it again tomorrow.", "Nobody!", "I dont Know", ratio.ToString("P", (CultureInfo.InvariantCulture)), (d.TotalSize * Variables.DriveSpaceFreePercent / 1000000000).ToString("F", CultureInfo.InvariantCulture)); NM.sendEmailHTML(email, "Nobody", "HD Free Space limit", MSG, true); } else { string MSG; if (Variables.Contacts[Who].Closeness >= 75) { MSG = string.Format("{0}, the drive {1} is now {2} availabe space. You need at least {3}MB free space. Please remove some or transfer to another drive. {0}. I'll check it again tomorrow.", Variables.Contacts[Who].PetName, d.Name.ToUpper().Trim(), ratio.ToString("P", (CultureInfo.InvariantCulture)), (d.TotalSize * Variables.DriveSpaceFreePercent / 1000000000).ToString("F", CultureInfo.InvariantCulture)); } else { MSG = string.Format("{0}, the drive {1} is now {2} availabe space. You need at least {3}MB free space. Please remove some or transfer to another drive. {0}. I'll check it again tomorrow.", Variables.Contacts[Who].FirstName, d.Name.ToUpper().Trim(), ratio.ToString("P", (CultureInfo.InvariantCulture)), (d.TotalSize * Variables.DriveSpaceFreePercent / 1000000000).ToString("F", CultureInfo.InvariantCulture)); } NM.sendEmailHTML(Variables.Contacts[Who].Email, Variables.Contacts[Who].FirstName + " " + Variables.Contacts[Who].LastName, "HD Free Space limit", MSG, true); } } } } _doneEvent.Set(); } }
public void checkContent(Object threadContext) { string token; try { token = service.Changes.GetStartPageToken().Execute().StartPageTokenValue; logger.Debug("Google Drive Current Token:{0}", token); } catch { return; } if (token != GDriveToken) { FilesResource.ListRequest listRequest = service.Files.List(); listRequest.PageSize = 10; listRequest.Fields = "nextPageToken, files(id, name)"; // List files. files = listRequest.Execute().Files; if (files != null && files.Count > 0) { foreach (var file in files) { logger.Debug("File: {0} {1}", file.Name, file.Id); switch (file.Name) { case (Variables.FilenameUpdateBios): //download & update Bios //download bios update //send an email to boss that recieved an update //extract the update //need to restart DownloadFile(file.Id, Variables.PathUpdateBios); logger.Trace("Got bios Update file."); string MSGbio = "Got the Bios Update " + Variables.Contacts[0].PetName + "!!!"; //<-- First contact is the BOSS! NM.sendEmailHTML(Variables.Contacts[0].Email, Variables.Contacts[0].FirstName + " " + Variables.Contacts[0].LastName, "New Bios Update", MSGbio, true); BIOSupdate(); Variables.NeedtoRestart = true; break; case (Variables.FilenameUpdatePepper): //download pepper update only //send an email to boss that recieved an update //need to restart DownloadFile(file.Id, Variables.PathUpdatePepper); logger.Trace("Got pepper update."); string MSG = "Got the New Dress " + Variables.Contacts[0].PetName + "!!!"; //<-- First contact is the BOSS! NM.sendEmailHTML(Variables.Contacts[0].Email, Variables.Contacts[0].FirstName + " " + Variables.Contacts[0].LastName, "New Pepper Update", MSG, true); Variables.NeedtoRestart = true; break; } } //delete everything. deleteAllfileinGD(); } else { logger.Debug("No files found."); } } GDriveToken = service.Changes.GetStartPageToken().Execute().StartPageTokenValue; _doneEvent.Set(); }