public async Task <IActionResult> Add(SleepInformation sleepInformation) { var userinformation = ClaimHelper.GetClaim(User.Identity as ClaimsIdentity); sleepInformation.UserId = userinformation.UserId.ToString(); var result = await _sleepInformationService .Add(sleepInformation) .ConfigureAwait(false); return(Ok(result)); }
public List <GetSleepThread> UnCheckLog(int unChechkID, string towerName, int deviceID, int towerID, string LogMap, List <GetSleepThread> getThread) { GetSleepThread uncheckMapLog = new GetSleepThread(); var LogMapCheck = getData.MapLogExistence(towerName, deviceID, towerID, unChechkID); if (LogMap == "Log" || LogMap == "Map") { if (LogMapCheck != null) { SleepInformation sleepget = new SleepInformation(); if (getThread.Count == 0) { getThread = sleepget.SleepGetInformation(false); } getData.DeleteSleepThead(towerName, deviceID, towerID, unChechkID); getData.UpdateSleepTheadLog(towerName, deviceID, towerID, unChechkID); var removeLog = getThread.Where(g => g.TowerName == towerName && g.DeviceID == deviceID && g.CheckID == unChechkID && g.TowerID == towerID).FirstOrDefault(); removeLog.thread.Abort(); getThread.Remove(removeLog); } else { getData.UpdateSleepTheadLog(towerName, deviceID, towerID, unChechkID); } } else { if (LogMapCheck != null && LogMapCheck.LogID != 1) { getData.DeleteSleepThead(towerName, deviceID, towerID, unChechkID); getData.UpdateSleepTheadMap(towerName, deviceID, towerID, unChechkID); var removeLog = getThread.Where(g => g.TowerName == towerName && g.DeviceID == deviceID && g.CheckID == unChechkID && g.TowerID == towerID).FirstOrDefault(); removeLog.thread.Abort(); getThread.Remove(removeLog); } else { getData.UpdateSleepTheadMap(towerName, deviceID, towerID, unChechkID); } } return(getThread); }
public bool TheadDevicePlayStop(List <GetSleepThread> getThread, SleepInformation returnedThreadList, string towerName, int deviceID, int towerID, DeviceContext db, GetThread getThreadPreset) { var gt = getThread = HangfireBootstrapper.Instance.GetThreadStart(); if (gt.Count != 0) { getThread.AddRange(gt); } var oofDevice = getData.SleepTheadList(towerName, deviceID); if (oofDevice.Count != 0) { getData.SleepTheadDelete(towerName, deviceID); var th = getThread.Where(t => t.TowerName == towerName && t.DeviceID == deviceID).ToList(); th.ForEach(t => { t.thread.Abort(); getThread.Remove(t); }); var toweroff = getData.TheadDefineOffOn(towerID); if (toweroff != null) { return(true); } else { return(false); } } else { List <WalkTowerDevice> Log = getData.SelectedLogList(towerName, deviceID); List <WalkTowerDevice> Map = getData.SelectedMapList(towerName, deviceID); LogSelectThead(Log, getThreadPreset, towerID, getThread, db); MapSelectThead(Log, getThreadPreset, towerID, getThread, db); if (Log.Count == 0 && Map.Count == 0) { return(false); } } return(true); }
public void StopThreadList(List <GetSleepThread> getThread, SleepInformation returnedThreadList, string towerName, List <int> stopGet) { var gt = HangfireBootstrapper.Instance.GetThreadStart(); if (gt.Count != 0) { getThread.AddRange(gt); } stopGet.ForEach(deviceID => { var oofDevice = getData.SleepTheadList(towerName, deviceID); if (oofDevice.Count != 0) { getData.SleepTheadDelete(towerName, deviceID); var thb = getThread.Where(t => t.TowerName == towerName && t.DeviceID == deviceID).ToList(); thb.ForEach(t => { t.thread.Abort(); getThread.Remove(t); }); } }); }
public void Start() { lock (_lockObject) { if (_started) { return; } _started = true; HostingEnvironment.RegisterObject(this); GlobalConfiguration.Configuration.UseSqlServerStorage("DeviceConnection"); Thread thread = new Thread(() => new TrapListen()); thread.Start(); SleepInformation sleepget = new SleepInformation(); getThread = sleepget.SleepGetInformation(true); _backgroundJobServer = new BackgroundJobServer(); } }
public List <int> PlayThreadList(bool treadListInd, List <GetSleepThread> getThread, SleepInformation returnedThreadList, List <int> playGet, string towerName, int towerID, DeviceContext db, GetThread getThreadPreset) { List <int> palayStop = new List <int>(); playGet.ForEach(deviceID => { List <WalkTowerDevice> Log = getData.SelectedLogList(towerName, deviceID); List <WalkTowerDevice> Map = getData.SelectedMapList(towerName, deviceID); LogSelectThead(Log, getThreadPreset, towerID, getThread, db); MapSelectThead(Log, getThreadPreset, towerID, getThread, db); if (Log.Count == 0 && Map.Count == 0) { palayStop.Add(deviceID); } }); return(palayStop); }
public async Task Update(SleepInformation sleepInformation) { await _mongoUnitOfWork.UpdateAsync(collectionName, x => x.Id == sleepInformation.Id, sleepInformation).ConfigureAwait(false); }
public async Task <SleepInformation> Add(SleepInformation sleepInformation) { sleepInformation.SleepTime = DateTime.Now.ToUniversalTime(); return(await _mongoUnitOfWork.CreateAsync(collectionName, sleepInformation).ConfigureAwait(false)); }
public void StopThread(List <GetSleepThread> getThread, SleepInformation returnedThreadList, string towerName, List <int> stopGet) { getLogic.StopThreadList(getThread, returnedThreadList, towerName, stopGet); }
public List <int> PlayTheadDevice(bool treadListInd, List <GetSleepThread> getThread, SleepInformation returnedThreadList, List <int> playGet, string towerName, int towerID, DeviceContext db, GetThread getThreadPreset) { return(getLogic.PlayThreadList(treadListInd, getThread, returnedThreadList, playGet, towerName, towerID, db, getThreadPreset)); }
public bool DeviceTheadOnOff(List <GetSleepThread> getThread, SleepInformation returnedThreadList, string towerName, int deviceID, int towerID, DeviceContext db, GetThread getThreadPreset) { return(getLogic.TheadDevicePlayStop(getThread, returnedThreadList, towerName, deviceID, towerID, db, getThreadPreset)); }