Example #1
0
 static void p_Exited(Object sender, EventArgs e)
 {
     Process p = (Process)sender;
     using(RoBlockWar.Models.RoBlockWarDBContext context = new Models.RoBlockWarDBContext())
     {
         RoBlockWar.Models.Battle b = context.Battles.Find(ProcessBattle[p.Id]);
         b.EndDate = DateTime.Now;
         b.BattleStatusCode = 3;
         context.SaveChanges();
     }
 }
Example #2
0
 static void Main(String[] args)
 {
     using (RoBlockWar.Models.RoBlockWarDBContext context = new Models.RoBlockWarDBContext())
     {
         var battles = context.Battles.Where(t => t.BattleStatusCode == 1 && t.StartDate < DateTime.Now);
         foreach (RoBlockWar.Models.Battle b in battles)
         {
             String Command = @"/C C:\phantomjs\bin\phantomjs.exe recordBattle.js " + b.BattleID
                            + " | C:\ffmpeg\bin\ffmpeg.exe -y -c:v png -f image2pipe -r 25 -t 10  -i - -c:v libx264 -pix_fmt yuv420p -movflags +faststart "
                            + " Battle" + b.BattleID + ".mp4";
             Process p = new Process();
             p.StartInfo.FileName = "cmd";
             p.StartInfo.Arguments = Command;
             p.Exited += p_Exited;
             p.Start();
             ProcessBattle.Add(p.Id, b.BattleID);
         }
     }
     Thread.Sleep(10000);
 }