Esempio n. 1
0
        public static void ReadDataFromFile()
        {
            using (var db = new PlanContext())
            {
                string       html = @"C:\Program Files (x86)\IIS Express\StartPage.html";
                HtmlDocument doc  = new HtmlDocument();

                StreamReader reader = new StreamReader(html, Encoding.UTF8);
                doc.Load(reader);

                var nodes = doc.DocumentNode.Descendants().Where(n => n.Name == "a").Select(n => new { Name = n.InnerText, value = n.Attributes[0].Value }).ToList();

                string tempLink;

                foreach (var item in nodes)
                {
                    tempLink = "http://plany.ath.bielsko.pl/" + item.value + "&winW=500&winH=300&loadBG=000000";

                    GetFile(tempLink, item.Name);

                    var t = new PlanModel
                    {
                        Name     = item.Name,
                        Link     = tempLink,
                        FileName = @"C:\ICSFiles\" + item.Name + ".ics"
                    };
                    db.PlanModel.Add(t);
                }
                db.SaveChanges();
            }
        }
Esempio n. 2
0
 public static void CreateDatabase()
 {
     using (var db = new PlanContext())
     {
         var f = db.PlanModel.ToList();
     }
 }
Esempio n. 3
0
        public ServiceCore()
        {
            PlanContext db = new PlanContext();

            _timer = new Timer(600000)
            {
                AutoReset = true
            };
            _timer.Elapsed += (sender, eventArgs) => Program.RunnAllFunction();



            Console.WriteLine("Database write successes !!!");
            Console.ReadKey();
        }