/// <summary> /// Send reports /// </summary> public void SendReports() { lock (_sendLock) { while (_storage.HasReports()) { using (StorageElement element = _storage.GetFirst()) { if (element == null) { // something went wrong with getting next element - try wait a little longer break; } try { if (!_settings.Sender.Send(element.Stream, element.Name, element.Report)) { Logger.WarnFormat("Error report {0} ({1}) failed to send", element.Name, element.Report); } } catch (Exception ex) { // protection from sender exceptions Logger.Error("Error sending error report", ex); } element.Remove(); } } } }
//deposits item into current room //methods //deposits item into current room public void depositItem() { if (toCarry.GetType() == typeof(Foods)) { StorageElement toStore = new StorageElement((Foods)toCarry, position); if (World.w.GetBlock(position).navNode.room.GetType() == typeof(FoodStorage)) { path = PathFind.getPathToNeighbors(World.w.GetBlock(position).navNode, AntJob.location); } } }
public Task Write(DateTime timestamp, ServiceDef serviceDef, CheckResult r) { return(Task.Run(() => { StorageElement sEl = new StorageElement() { Id = Guid.NewGuid().ToString(), ServiceName = serviceDef.Name, Timestamp = timestamp, Status = r.Status, LastError = r.LastError == null? null : r.LastError.Message }; File.AppendAllText(_strFileFullPath, JsonConvert.SerializeObject(sEl) + Environment.NewLine); })); }
public void addFood(StorageElement store) //this code adds a food element at the first empty position??? it should add it at the exact coordinates given, why else would a storageElement be the input?? { if (freeSpaces == 0) { Debug.LogError("No Place Left In Foodstorage"); return; } for (int i = 0; i < totalSpace; i++) { if (foodStored[i].getPosition() == store.getPosition()) // Fixed it so it now adds the food at the position that is given by StorageElement store if (foodStored[i].foodExist()) { foodStored[i].addFood(store.getFood()); break; } } freeSpaces--; }
/// <summary> /// Returns a path relative to the specified element's path. /// </summary> /// <param name="pathProvider"> /// A function which, by receiving the specified element's path, builds and returns the /// path to be returned. /// </param> public static StoragePath GetPath(this StorageElement element, PathProvider pathProvider) { return(pathProvider.Invoke(element.Path.FullPath)); }
/// <summary> /// Returns a path relative to the specified element's path. /// </summary> /// <param name="pathSegments"> /// An array of path segments which get joined with the specified element's path, thus /// forming the path to be returned. /// </param> public static StoragePath GetPath(this StorageElement element, params string[] pathSegments) { return(element.GetPath(basePath => SegmentsToPath(basePath, pathSegments))); }
public static async Task ShouldExistAsync(this StorageElement element) { var exists = await element.ExistsAsync(); exists.ShouldBeTrue($"The element at {element.Path} should exist, but doesn't."); }
public static async Task ShouldNotExistAsync(this StorageElement element) { var exists = await element.ExistsAsync(); exists.ShouldBeFalse($"The element at {element.Path} should not exist, but does."); }