Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Docker_Panel.Models;
- using Docker_Panel.Models.Db.Hosting;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace IPSyncTool
- {
- class Program
- {
- static void Main(string[] args)
- {
- using (var db = new ApplicationDbContext())
- {
- IEnumerable<DedicatedIPAddresses> address = db.DedicatedIPAddresses.ToList();
- try
- {
- foreach (var item in address)
- {
- Console.WriteLine("Processing " + item.IPAddress);
- Containers container = db.Containers.First(x => x.ContainerId == item.AssignedToContainer);
- db.IPPorts.Add(new IPPorts
- {
- IPAddress = container.IPAddress,
- Port = container.UsingPort,
- ContainerId = container.ContainerId,
- IssuedAt = DateTime.Now,
- ExpectedRelease = container.Expires,
- IsInUse = true
- });
- db.SaveChanges();
- }
- }
- catch (Exception ex)
- {
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement