Advertisement
Guest User

Untitled

a guest
Jul 16th, 2019
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. using Docker_Panel.Models;
  2. using Docker_Panel.Models.Db.Hosting;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8.  
  9. namespace IPSyncTool
  10. {
  11. class Program
  12. {
  13. static void Main(string[] args)
  14. {
  15. using (var db = new ApplicationDbContext())
  16. {
  17. IEnumerable<DedicatedIPAddresses> address = db.DedicatedIPAddresses.ToList();
  18. try
  19. {
  20. foreach (var item in address)
  21. {
  22. Console.WriteLine("Processing " + item.IPAddress);
  23. Containers container = db.Containers.First(x => x.ContainerId == item.AssignedToContainer);
  24.  
  25. db.IPPorts.Add(new IPPorts
  26. {
  27. IPAddress = container.IPAddress,
  28. Port = container.UsingPort,
  29. ContainerId = container.ContainerId,
  30. IssuedAt = DateTime.Now,
  31. ExpectedRelease = container.Expires,
  32. IsInUse = true
  33. });
  34. db.SaveChanges();
  35. }
  36. }
  37. catch (Exception ex)
  38. {
  39.  
  40. }
  41. }
  42. }
  43. }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement