Ejemplo n.º 1
0
        public static void Load()
        {
            lock (DataContainer.Instance())
            {
                var filename = System.Web.Hosting.HostingEnvironment.MapPath("/App_Data/TAManager.xml");
                if (System.IO.File.Exists(filename))
                {
                    using (var stream = System.IO.File.OpenText(filename))
                    {
                        XmlSerializer xml = new XmlSerializer(typeof(DataContainer));
                        c = (DataContainer)xml.Deserialize(stream);
                        stream.Close();
                    }
                }
                else
                {
                    var cdata = TAManager.Data.DataContainer.Instance();
                    cdata.HiringPeriods.Add(new HiringPeriod()
                    {
                        Open = DateTime.Now,
                        Close = DateTime.Now.AddMonths(1),
                        Type = "HTA",
                        Name = "2012Fall HTA"
                    });
                    cdata.HiringPeriods.Add(new HiringPeriod()
                    {
                        Open = DateTime.Now,
                        Close = DateTime.Now.AddMonths(1),
                        Type = "HTA",
                        Name = "2012Fall UTA"
                    });
                    cdata.HiringPeriods.Add(new HiringPeriod()
                    {
                        Open = DateTime.Now,
                        Close = DateTime.Now.AddMonths(1),
                        Type = "HTA",
                        Name = "2012S UTA"
                    });
                    cdata.HiringPeriods.Add(new HiringPeriod()
                    {
                        Open = DateTime.Now,
                        Close = DateTime.Now.AddMonths(1),
                        Type = "HTA",
                        Name = "2011F UTA"
                    });
                    cdata.HiringPeriods.Add(new HiringPeriod()
                    {
                        Open = DateTime.Now,
                        Close = DateTime.Now.AddMonths(1),
                        Type = "HTA",
                        Name = "2011S UTA"
                    });

                    cdata.Courses.Add(new Course() { BannerName = "CS15", HTAs = new List<string> { "bherila" } });
                    cdata.Courses.Add(new Course() { BannerName = "CS16" });
                    cdata.Courses.Add(new Course() { BannerName = "CS32" });
                    cdata.Courses.Add(new Course() { BannerName = "CS123" });

                    cdata.Users.Add(new User()
                    {
                        FirstName = "Tom",
                        LastName = "Doeppner",
                        IsAdmin = true,
                        Login = "******",
                        Password = "******".hashPassword()
                    });

                    cdata.Save();
                }
            }
        }
Ejemplo n.º 2
0
 public static DataContainer Instance()
 {
     if (c == null) c = new DataContainer();
     return c;
 }