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);
     }
 }
Exemple #2
0
 public static void AdError(ChangingFile error)
 {
     lock (_lockObj)
     {
         if (_errors.Any(x => x.FullPath == error.FullPath))
         {
             return;
         }
         _errors.Add(error);
     }
 }
Exemple #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);
     }
 }