コード例 #1
0
        //
        // GET: /Logs/
        public ActionResult Index()
        {           
            OSMLogsContext context = new OSMLogsContext();

            DeleteYesterday(context);

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

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

            var tempLog = context.LogsItem.ToList();

            tempLog.ForEach(item => context.LogsItem.Remove(item));
            context.SaveChanges();
        }
コード例 #4
0
        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();
        }
コード例 #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 { }
        }
コード例 #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 { }
        }