//
        // GET: /Logs/
        public ActionResult Index()
        {           
            OSMLogsContext context = new OSMLogsContext();

            DeleteYesterday(context);

            return View(context.LogsItem.ToList());
        }
Beispiel #2
0
        public void DeleteAll()
        {
            OSMLogsContext context = new OSMLogsContext();

            var tempLog = context.LogsItem.ToList();
            tempLog.ForEach(item => context.LogsItem.Remove(item));            
            context.SaveChanges();
        }
Beispiel #3
0
        public void DeleteAll()
        {
            OSMLogsContext context = new OSMLogsContext();

            var tempLog = context.LogsItem.ToList();

            tempLog.ForEach(item => context.LogsItem.Remove(item));
            context.SaveChanges();
        }
        public void DeleteYesterday(OSMLogsContext context)
        {
            DateTime dtNow = DateTime.Now.AddDays(-1);
            List<OSMLogs> items = (from c in context.LogsItem
                                   where c.When < dtNow
                                    select c).ToList();

            for (int i=0; i < items.Count; i++)
            {
                context.Entry(items[i]).State = System.Data.EntityState.Deleted;
            }

            context.SaveChanges();
        }
Beispiel #5
0
        public void AddLog(string sSectionName, string sDescription)
        {
            try
            {
                OSMLogsContext logs = new OSMLogsContext();

                OSMLogs item = new OSMLogs()
                {
                    Description = sDescription,
                    SectionName = sSectionName,
                    When        = DateTime.Now,
                    ID          = Guid.NewGuid().ToString()
                };

                logs.LogsItem.Add(item);
                logs.SaveChanges();
            }
            catch { }
        }
Beispiel #6
0
        public void AddLog(string sSectionName, string sDescription)
        {
            try
            {
                OSMLogsContext logs = new OSMLogsContext();

                OSMLogs item = new OSMLogs()
                {
                    Description = sDescription,
                    SectionName = sSectionName,
                    When = DateTime.Now,
                    ID = Guid.NewGuid().ToString()
                };

                logs.LogsItem.Add(item);
                logs.SaveChanges();
            }
            catch { }
        }