예제 #1
0
 public bool TryUpload(ChangingFile file)
 {
     if (!File.Exists(file.FullPath))
     {
         return(true);
     }
     try
     {
         using (var client = new WebClient())
         {
             var url = AppContext.Url + "?username=xxx&password=xxx&path=" + file.ServerPath;
             client.UploadFile(url, file.FullPath);
             Console.ForegroundColor = ConsoleColor.Green;
             Console.WriteLine("uploaded " + file.Name);
             Console.ResetColor();
             return(true);
         }
     }
     catch (Exception)
     {
         Console.ForegroundColor = ConsoleColor.Red;
         Console.WriteLine("error " + file.Name);
         Console.ResetColor();
         return(false);
     }
 }
예제 #2
0
 public static void AdError(ChangingFile error)
 {
     lock (_lockObj)
     {
         if (_errors.Any(x => x.FullPath == error.FullPath))
         {
             return;
         }
         _errors.Add(error);
     }
 }
예제 #3
0
 public static void AddFile(ChangingFile file)
 {
     lock (_lockObj)
     {
         if (_files.Any(x => x.FullPath == file.FullPath))
         {
             return;
         }
         _files.Add(file);
         Console.WriteLine(file.Name + " -> " + file.ChangeType);
     }
 }