Пример #1
0
 public void GetIpTest()
 {
     var helper = new IpHelper("");
     var ip = helper.GetIp();
     Assert.IsNotEmpty(ip);
     Assert.IsTrue(helper.IpChanged);
 }
Пример #2
0
 protected override TaskResult Work()
 {
     var rst = new TaskResult();
     var helper = new IpHelper(oldIp);
     var ip = helper.GetIp();
     if (helper.IpChanged)
     {
         var sw = new Stopwatch();
         sw.Start();
         var ok = BatchVast(ip);
         sw.Stop();
         if (ok)
         {
             rst.Result = TaskResultType.Succeed;
             rst.Message = $"已将所有泛解析更新了IP地址指向[effecteds:<{_ups}>,change: <{oldIp}> -> <{ip}>][elapsed:<{sw.Elapsed}>]";
             oldIp = ip;
         }
         else
         {
             rst.Result = TaskResultType.Failed;
             rst.Message = $"更新IP地址失败[change: <{oldIp}> -> <{ip}>][elapsed:<{sw.Elapsed}>]";
             Log.Warn($"更新地址失败[change: <{oldIp}> -> <{ip}>][elapsed:<{sw.Elapsed}>]");
         }
     }
     else
     {
         rst.Result = TaskResultType.Unknow;
         rst.Message = "IP地址未变,不用更新。";
     }
     return rst;
 }