Exemple #1
0
 public static void AddJob(Base work)
 {
     lock (_PendingWork)
     {
         _PendingWork.Add(work.GetGuid());
         BinaryFormatter binaryFormatter = new BinaryFormatter();
         if (!Directory.Exists("Pending")) Directory.CreateDirectory("Pending");
         FileStream stream = File.Create("Pending/" + work.GetGuid() + ".dat");
         binaryFormatter.Serialize(stream, work);
         stream.Close();
     }
 }
Exemple #2
0
 public static void RegisterCompletedWork(Base completedWork)
 {
     lock (_CompleteWork)
     {
         lock (_WorkBeingProcessed)
         {
             if (_WorkBeingProcessed.Count(a => a.Item1.GetGuid() == completedWork.GetGuid()) <= 0) return;
             _CompleteWork.Add(completedWork.GetGuid());
             BinaryFormatter binaryFormatter = new BinaryFormatter();
             if (!Directory.Exists("Completed")) Directory.CreateDirectory("Completed");
             if (File.Exists("Pending/" + completedWork.GetGuid() + ".dat")) File.Delete("Pending/" + completedWork.GetGuid() + ".dat");
             FileStream stream = File.Create("Completed/" + completedWork.GetGuid() + ".dat");
             binaryFormatter.Serialize(stream, completedWork);
             stream.Close();
             _WorkBeingProcessed.RemoveAll(a => a.Item1.GetGuid() == completedWork.GetGuid());
             Console.WriteLine("Completed Job Registered " + completedWork.GetGuid());
         }
     }
 }
Exemple #3
0
 /// <summary>
 ///     adds a peice of work to the work completed list ready to be sent to the manager
 /// </summary>
 /// <param name="work"></param>
 public void AddToCompletedWork(Base work)
 {
     lock (_CompletedWork)
     {
         _CompletedWork.Add(work);
         if (!Directory.Exists(_Settings.CompletedWorkDirectory)) Directory.CreateDirectory(_Settings.CompletedWorkDirectory);
         work.SaveToDisk(_Settings.CompletedWorkDirectory + "/" + work.GetGuid());
     }
 }