SHARE
TWEET

Untitled

a guest Jul 16th, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.                 foreach (var item in address)
  19.                 {
  20.                     Console.WriteLine("Processing " + item.IPAddress);
  21.                     try
  22.                     {
  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.                     }catch(Exception ex)
  36.                     {
  37.  
  38.                     }
  39.                 }
  40.             }
  41.         }
  42.     }
  43. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top