Exemplo n.º 1
0
 /// <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();
             }
         }
     }
 }
Exemplo n.º 2
0
    //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);
            }
        }
    }
Exemplo n.º 3
0
        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);
            }));
        }
Exemplo n.º 4
0
 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--;
 }
Exemplo n.º 5
0
 /// <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));
 }
Exemplo n.º 6
0
 /// <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)));
 }
Exemplo n.º 7
0
        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.");
        }
Exemplo n.º 8
0
        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.");
        }