Beispiel #1
0
        public static object StateChangeServer()
        {
            bool result    = false;
            var  dbContext = new Naboo.DataAccess.Model.OSAgnosticContext(ConnectionHandler.ConnectionString());

            try
            {
                var hostsDb = (from itemDb in  dbContext.Host select itemDb).ToList();
                if (hostsDb != null)
                {
                    foreach (var item in hostsDb)
                    {
                        if (item.UpdateDate < DateTime.Now.AddSeconds(-30) && item.State == true)
                        {
                            item.State = false;
                        }
                    }
                    dbContext.SaveChanges();
                    result = true;
                }
            }
            catch (Exception ex)
            {
            }
            return(result);
        }
Beispiel #2
0
        public static Host Add(Host item)
        {
            Host result    = new Host();
            var  dbContext = new Naboo.DataAccess.Model.OSAgnosticContext(ConnectionHandler.ConnectionString());

            Naboo.DataAccess.Model.Host hostDb = item.Convert();
            dbContext.Host.Add(hostDb);
            dbContext.SaveChanges();
            result = hostDb.Convert();
            return(result);
        }
Beispiel #3
0
        public static Entities.Job Add(Entities.Job item)
        {
            Entities.Job result    = new Entities.Job();
            var          dbContext = new Naboo.DataAccess.Model.OSAgnosticContext(ConnectionHandler.ConnectionString());

            Naboo.DataAccess.Model.Job jobDb = item.Convert();
            dbContext.Job.Add(jobDb);
            dbContext.SaveChanges();
            result = jobDb.Convert();
            return(result);
        }
Beispiel #4
0
        public static object StateChange(int id, bool state)
        {
            bool result    = false;
            var  dbContext = new Naboo.DataAccess.Model.OSAgnosticContext(ConnectionHandler.ConnectionString());

            try
            {
                var hostDb = dbContext.Host.Where(c => c.Id == id).FirstOrDefault();
                if (hostDb != null)
                {
                    hostDb.State = state;
                    dbContext.SaveChanges();
                    result = true;
                }
            }
            catch (Exception ex)
            {
            }
            return(result);
        }