public ActionResult <String> Create(MemeInfo memeInfo) { var guid = Utils.MD5($"{memeInfo.CatText}{memeInfo.DrummerText}{memeInfo.DrumText}"); var tempMeme = _memeRepo.Get(new Guid(guid)); if (tempMeme != null) { return(Ok($"{tempMeme.Guid}:{tempMeme.MemeWork.Status}")); } var meme = new Meme(memeInfo); _memeRepo.Add(meme); return(Ok($"{meme.Guid}:{meme.MemeWork.Status}")); }
private static void DoWork(IWebSocketConnection socket, IMemeRepository memeRepo) { var id = socket.ConnectionInfo.Path.Substring(1); Meme resource = null; try { resource = memeRepo.Get(new Guid(id)); } catch (Exception e) {} if (resource == null) { socket.Send("NOTFOUND"); socket.Close(); return; } bool completed = false; int num = -1; WorkStatus status = resource.MemeWork.Status; while (!completed) { if (resource.MemeWork.Percentage == num) { continue; } if (resource.MemeWork.Status == WorkStatus.Done) { completed = true; } num = resource.MemeWork.Percentage; String response = $"{num:D2}\n"; socket.Send(response); if (resource.MemeWork.Percentage == 100) { while (Utils.IsFileLocked(new FileInfo(resource.FilePath))) { Thread.Sleep(200); } socket.Send("DONE\n"); } } socket.Close(); memeRepo.Next(); }