Free cookie consent management tool by TermsFeed Policy Generator

Changeset 2011


Ignore:
Timestamp:
06/04/09 18:04:01 (15 years ago)
Author:
kgrading
Message:

added uptimemanager (#669)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Hive.Client.Core/3.2/ConfigurationManager/UptimeManager.cs

    r2010 r2011  
    44using System.Text;
    55using Calendar;
     6using System.Xml.Serialization;
     7using System.IO;
    68
    79namespace HeuristicLab.Hive.Client.Core.ConfigurationManager {
     
    911
    1012    public List<Appointment> Appointments { get; set; }
     13    private static String path = System.IO.Directory.GetCurrentDirectory()+"\\plugins\\Hive.Client.Jobs\\";
    1114
    1215    private static UptimeManager instance = null;
     
    2023    }
    2124
    22    
     25    private void PersistToHDD() {
     26      XmlSerializer s = new XmlSerializer(typeof(List<Appointment>));
     27      using (TextWriter w = new StreamWriter(path + "calendar.xml")) {
     28        s.Serialize(w, Appointments); 
     29      }
     30    }
     31
     32    private void RestoreFromHDD() {
     33      XmlSerializer s = new XmlSerializer(typeof(List<Appointment>));
     34      using (TextReader r = new StreamReader(path + "calendar.xml")) {
     35        Appointments = (List<Appointment>)s.Deserialize(r);       
     36      }           
     37    }
     38
     39    public bool isOnline(DateTime time) {
     40      foreach (Appointment app in Appointments)
     41        if ((time >= app.StartDate) &&
     42            (time <= app.EndDate))
     43          return true;
     44      return false;
     45    }
    2346  }
    2447}
Note: See TracChangeset for help on using the changeset viewer.