Esempio n. 1
0
 public void RemoveAllFromIndex()
 {
     using (WCFRepositorySoapServiceReferenceAzure.Service1Client client = new WCFRepositorySoapServiceReferenceAzure.Service1Client("BasicHttpBinding_IService11"))
     //using (WCFRepositorySoapServiceReference.Service1Client client = new WCFRepositorySoapServiceReference.Service1Client())
     {
         int howMany = client.RemoveAll(ServerIpAddress.ToString(), ServerPort);
         Trace.WriteLine("Files registred: " + howMany);
     }
 }
Esempio n. 2
0
 public void GetFile(string downloadFolder, string fileName)
 {
     Trace.WriteLine($"Trying to find locations for '{fileName}'");
     using (WCFRepositorySoapServiceReferenceAzure.Service1Client client = new WCFRepositorySoapServiceReferenceAzure.Service1Client("BasicHttpBinding_IService11"))
     //using (WCFRepositorySoapServiceReference.Service1Client client = new WCFRepositorySoapServiceReference.Service1Client())
     {
         try
         {
             Task.Run(() => // to make the GUi more responsive
             {
                 WCFRepositorySoapServiceReferenceAzure.Destination[] destinations = client.Get(fileName);
                 Trace.WriteLine("We have some locations " + destinations.Length);
                 if (destinations.Length == 0)
                 {
                     Trace.WriteLine("No locations");
                     return;
                 }
                 foreach (WCFRepositorySoapServiceReferenceAzure.Destination destination in destinations)
                 {
                     Trace.WriteLine(destination.Host + " " + destination.Port);
                 }
                 WCFRepositorySoapServiceReferenceAzure.Destination location = destinations[0];
                 Trace.WriteLine("Chosen location " + location.Host + " " + location.Port);
                 //string substring = location.Host.Substring(0, location.Host.Length - 2);
                 //Trace.WriteLine(substring);
                 using (TcpClient tcpClient = new TcpClient(location.Host, location.Port))
                 {
                     Stream stream       = tcpClient.GetStream();
                     StreamWriter writer = new StreamWriter(stream);
                     writer.WriteLine(fileName);
                     writer.Flush();
                     //writer.Close();
                     FileStream fileStream = new FileStream(downloadFolder + "copy" + fileName, FileMode.Create);
                     stream.CopyTo(fileStream);
                 }
             });
         }
         catch (Exception ex)
         {
             Trace.WriteLine(ex.Message);
         }
     }
 }
Esempio n. 3
0
 private void RegisterFiles(string sharedFolder, IPAddress serverIpAddress, int serverPort)
 {
     string[] files = Directory.GetFiles(sharedFolder);
     Trace.WriteLine($"Looking for files to add in {sharedFolder}");
     for (int i = 0; i < files.Length; i++)
     {
         files[i] = GetFileName(files[i]);
     }
     Trace.WriteLine($"Files found in shared folder: {files.ToList().Count.ToString()}");
     Trace.WriteLine("Trying to registrar:\n* " + string.Join("\n* ", files));
     using (WCFRepositorySoapServiceReferenceAzure.Service1Client client = new WCFRepositorySoapServiceReferenceAzure.Service1Client("BasicHttpBinding_IService11"))
     //using (WCFRepositorySoapServiceReference.Service1Client client = new WCFRepositorySoapServiceReference.Service1Client())
     {
         // Todo alternative: Use localHostName
         //string serverIp = ServerIpAddress.ToString();
         int howMany = client.AddAll(files, ServerIpAddress.ToString(), serverPort);
         Trace.WriteLine("Files registred: " + howMany);
     }
 }