public static List <MachineState> EnumUsed() { List <MachineState> res = new List <MachineState>(); using (var db = new BST_STATISTICSEntities()) { foreach (var m in db.PCS.Where(b => !b.UNUSED)) { res.Add(new MachineState(m)); } } return(res); }
public static void OnlineHost(int id) { using (var db = new BST_STATISTICSEntities()) { var result = db.HOSTS.SingleOrDefault(b => b.id == id); if (result != null) { Log.FeedLog(string.Format("Host '{0}' has set online", result.name)); result.inactive = null; db.SaveChanges(); } } CacheCleaner.ResetCache(); }
public MachineState(int id) { List <MachineState> res = new List <MachineState>(); using (var db = new BST_STATISTICSEntities()) { foreach (var m in db.PCS.Where(b => b.ID == id)) { Init(m); return; } } throw new Exception("Machine not found."); }
public static List <MachineState> EnumUsed() { lock (_Lock) { if (_used == null || DateTime.Now.Subtract(_used.Value).Seconds > 10) { _machines.Clear(); using (var db = new BST_STATISTICSEntities()) { foreach (var m in db.PCS.Where(b => !b.UNUSED)) { _machines.Add(new MachineState(m)); } } } return(_machines.ConvertAll(mach => (MachineState)mach.MemberwiseClone())); } }
public static void FeedLog(string message) { message.Trim(); if (string.IsNullOrEmpty(message)) { return; } using (var db = new BST_STATISTICSEntities()) { BSTLOG bl = new BSTLOG() { TEXT = message, USERID = CurrentContext.UserID }; db.BSTLOGs.Add(bl); db.SaveChanges(); } }
public static List <HostState> EnumUsed() { lock (_Lock) { if (_used == null || DateTime.Now.Subtract(_used.Value).Seconds > 10) { _hosts.Clear(); using (var db = new BST_STATISTICSEntities()) { foreach (var h in db.HOSTS.Where(host => host.inactive == null)) { _hosts.Add(new HostState(h)); } } _used = DateTime.Now; } return(_hosts.ConvertAll(host => (HostState)host.MemberwiseClone())); } }
public void UpdateMachineStatus(MachineStatus status) { int iStatus = ACTIONFLAG; MachineStatus ActionFlag = (MachineStatus)iStatus; if ((ActionFlag & status) == 0) { ActionFlag |= status; using (var db = new BST_STATISTICSEntities()) { db.SCHEDULEs.RemoveRange(db.SCHEDULEs.Where(x => x.LOCKEDBY == ID)); db.PCS.First(p => p.PCNAME == NAME).ACTIONFLAG = (int)ActionFlag; db.SaveChanges(); } } Log.FeedLog(string.Format("Machine {0} has been changed: {1}. By {2}", NAME, status.ToString(), CurrentContext.UserName())); ResetCache(); }
public static void PauseOnOff(int id, int idusr) { using (var db = new BST_STATISTICSEntities()) { var result = db.PCS.SingleOrDefault(b => b.ID == id); if (result != null) { if (result.PAUSEDBY == null) { result.PAUSEDBY = idusr; CbstHelper.FeedLog(string.Format("Machine '{0}' has been paused", result.PCNAME)); } else { result.PAUSEDBY = null; CbstHelper.FeedLog(string.Format("Machine '{0}' has been resumed", result.PCNAME)); } db.SaveChanges(); } } }
public static List <OfflineHost> Enum() { lock (_Lock) { if (_used == null || DateTime.Now.Subtract(_used.Value).Seconds > 10) { _hosts.Clear(); using (var db = new BST_STATISTICSEntities()) { foreach (var h in db.HOSTS.Where(host => host.inactive == true)) { _hosts.Add(new OfflineHost() { ID = h.id, NAME = h.name }); } } _used = DateTime.Now; } return(_hosts.ConvertAll(host => (OfflineHost)host.MemberwiseClone())); } }
public static void StartStopHost(int id, bool start) { using (var db = new BST_STATISTICSEntities()) { var result = db.HOSTS.SingleOrDefault(b => b.id == id); if (result != null) { if (start) { Log.FeedLog(string.Format("Host '{0}' has been started", result.name)); result.poweron = true; } else { Log.FeedLog(string.Format("Host '{0}' has been stopped", result.name)); result.poweroff = true; } db.SaveChanges(); } } CacheCleaner.ResetCache(); }