static void Main(string[] args) { //IMPORTANT: must using VS developer command promt and svcutil.exe for generating WSDL and decompiling proxy class //using decompiled class from wsdl file and Channels //ChannelFactory<IDiskInfo> objFactory = new ChannelFactory<IDiskInfo>("DefaultEndPoint"); //IDiskInfo objInfo = objFactory.CreateChannel(); //now using proxy class with manual generated file from svcutil.exe //IDiskInfo objInfo = new DiskInfoClient(new WSHttpBinding(), new EndpointAddress("http://localhost/DiskInfoService")); IDiskInfo objInfo = new DiskInfoClient("DefaultEndPoint"); Console.WriteLine("Enter the Disk Letter"); string strDiskName = Console.ReadLine(); long lTotalSpace = objInfo.GetTotalSpace(strDiskName); long lFreeSpace = objInfo.GetFreeSpace(strDiskName); if (lTotalSpace > -1 && lFreeSpace > -1) { Console.WriteLine($"Total space on {strDiskName} is {lTotalSpace}"); Console.WriteLine($"Free space on {strDiskName} is {lFreeSpace}"); } else { Console.WriteLine("Error"); } }
public void SendMessageToWcfService() { using (DiskInfoClient ClientProxy = new DiskInfoClient(MyResourses.Texts.EndPoint_1)) { lock (SafeProgramClosingGate) { try { ClientProxy.SaveDataInLog(ClientNameTextBox.Text); MessageBox.Show(MyResourses.Texts.MessageWasSent, MyResourses.Texts.Message, MessageBoxButton.OK, MessageBoxImage.Warning); } catch (FaultException CurrentException) { MessageBox.Show(CurrentException.Message, MyResourses.Texts.Error, MessageBoxButton.OK, MessageBoxImage.Error); ClientProxy.Abort(); } catch (CommunicationException CurrentException) { MessageBox.Show(CurrentException.Message, MyResourses.Texts.Error, MessageBoxButton.OK, MessageBoxImage.Error); ClientProxy.Abort(); } catch (TimeoutException CurrentException) { MessageBox.Show(CurrentException.Message, MyResourses.Texts.Error, MessageBoxButton.OK, MessageBoxImage.Error); ClientProxy.Abort(); } } } }
static void Main(string[] args) { DiskInfoClient dic = new DiskInfoClient(); dic.BeginDiskSpaces("d", new AsyncCallback(OnResult), dic); Console.ReadKey(); dic.Close(); }
static void Main(string[] args) { DiskInfoClient cl = new DiskInfoClient(); string freeC = cl.FreeSpace("c"); string totalC = cl.TotalSpace("c"); Console.WriteLine("Info about disk C:\n Total Space:{0}\n Free Space:{1}\n",freeC, totalC); Console.WriteLine("Push any key for exit"); Console.ReadKey(); cl.Close(); }
static void Main(string[] args) { DiskInfoClient cl = new DiskInfoClient(); string freeC = cl.FreeSpace("c"); string totalC = cl.TotalSpace("c"); Console.WriteLine("Info about disk C:\n Total Space:{0}\n Free Space:{1}\n", freeC, totalC); Console.WriteLine("Push any key for exit"); Console.ReadKey(); cl.Close(); }
static void Main(string[] args) { DiskInfoClient cl = new DiskInfoClient(); MyDiskInfo disk = cl.DiskSpaces("c"); Print(disk); MyDiskInfo disk2 = cl.DiskSpaces("d","disk"); Print(disk2); Console.WriteLine("Push any key for exit"); Console.ReadKey(); cl.Close(); }
static void Main(string[] args) { DiskInfoClient cl = new DiskInfoClient(); MyDiskInfo disk = cl.DiskSpaces("c"); Print(disk); MyDiskInfo disk2 = cl.DiskSpaces("d", "disk"); Print(disk2); Console.WriteLine("Push any key for exit"); Console.ReadKey(); cl.Close(); }
static void Main(string[] args) { DiskInfoClient cl = new DiskInfoClient(); MyDiskInfo disk = cl.DiskSpaces("c"); Console.WriteLine("Information about disk {0}:", disk.DiskName); Console.WriteLine("\tdisk type : {0}", disk.DiskType); Console.WriteLine("\ttotal space : {0}", disk.TotalSpace); Console.WriteLine("\tfree space {0}:", disk.FreeSpace); Console.WriteLine(); Console.WriteLine("Push any key for exit"); Console.ReadKey(); cl.Close(); }
static void Main(string[] args) { //IDiskInfo objInfo = new DiskInfoClient(new WSHttpBinding(), new EndpointAddress("http://localhost/DiskInfoService")); using(DiskInfoClient objInfo = new DiskInfoClient("DefaultEndPoint")) { Console.WriteLine("Enter the Disk Letter"); string strDiskName = Console.ReadLine(); long lTotalSpace = objInfo.GetTotalSpace(strDiskName); long lFreeSpace = objInfo.GetFreeSpace(strDiskName); if(lTotalSpace > -1 && lFreeSpace > -1) { Console.WriteLine($"Total space on {strDiskName} is {lTotalSpace}"); Console.WriteLine($"Free space on {strDiskName} is {lFreeSpace}"); } else { Console.WriteLine("Error"); } } }
static void Main(string[] args) { //IDiskInfo objInfo = new DiskInfoClient(new WSHttpBinding(), new EndpointAddress("http://localhost/DiskInfoService")); using (DiskInfoClient objInfo = new DiskInfoClient("DefaultEndPoint")) { Console.WriteLine("Enter the Disk Letter"); string strDiskName = Console.ReadLine(); long lTotalSpace = objInfo.GetTotalSpace(strDiskName); long lFreeSpace = objInfo.GetFreeSpace(strDiskName); if (lTotalSpace > -1 && lFreeSpace > -1) { Console.WriteLine($"Total space on {strDiskName} is {lTotalSpace}"); Console.WriteLine($"Free space on {strDiskName} is {lFreeSpace}"); } else { Console.WriteLine("Error"); } } }
static void Main(string[] args) { //IMPORTANT: must using VS developer command promt and svcutil.exe for generating WSDL and decompiling proxy class //using decompiled class from wsdl file and Channels //ChannelFactory<IDiskInfo> objFactory = new ChannelFactory<IDiskInfo>("DefaultEndPoint"); //IDiskInfo objInfo = objFactory.CreateChannel(); //now using proxy class with manual generated file from svcutil.exe //IDiskInfo objInfo = new DiskInfoClient(new WSHttpBinding(), new EndpointAddress("http://localhost/DiskInfoService")); IDiskInfo objInfo = new DiskInfoClient("DefaultEndPoint"); Console.WriteLine("Enter the Disk Letter"); string strDiskName = Console.ReadLine(); long lTotalSpace = objInfo.GetTotalSpace(strDiskName); long lFreeSpace = objInfo.GetFreeSpace(strDiskName); if(lTotalSpace > -1 && lFreeSpace > -1) { Console.WriteLine($"Total space on {strDiskName} is {lTotalSpace}"); Console.WriteLine($"Free space on {strDiskName} is {lFreeSpace}"); } else { Console.WriteLine("Error"); } }
public void GetDriveInfoFromService(string DriveName) { lock (SafeProgramClosingGate) { //Ниже использован рекомендуемый способ закрытия прокси клиента DiskInfoClient ClientProxy = new DiskInfoClient(MyResourses.Texts.EndPoint_1); try { MainDriveInfo CurrentDriveInfo = ClientProxy.GetOneDriveData(DriveName); if (CurrentDriveInfo != null) { Application.Current.Dispatcher.Invoke(new Action(() => DriveInfoLabel.Content = CurrentDriveInfo.Name + " " + MyResourses.Texts.Free + " " + CurrentDriveInfo.AvailableSpace + " " + MyResourses.Texts.GigaByte + " " + MyResourses.Texts.From + " " + CurrentDriveInfo.TotalSpace + " " + MyResourses.Texts.GigaByte)); } else { Application.Current.Dispatcher.Invoke(new Action(() => DriveInfoLabel.Content = MyResourses.Texts.CantFindDriveByName)); } ClientProxy.Close(); } catch (FaultException CurrentException) { MessageBox.Show(CurrentException.Message, MyResourses.Texts.Error, MessageBoxButton.OK, MessageBoxImage.Error); ClientProxy.Abort(); } catch (CommunicationException CurrentException) { MessageBox.Show(CurrentException.Message, MyResourses.Texts.Error, MessageBoxButton.OK, MessageBoxImage.Error); ClientProxy.Abort(); } catch (TimeoutException CurrentException) { MessageBox.Show(CurrentException.Message, MyResourses.Texts.Error, MessageBoxButton.OK, MessageBoxImage.Error); ClientProxy.Abort(); } finally { lock (StatusChangeGate) { if (!ShutDown) Application.Current.Dispatcher.Invoke(new Action(() => StatusLabel.Content = MyResourses.Texts.StatusFree)); ClientBusy = false; } } } }
public async void GetDiskInfoFromServiceAsync() { //Без прокси /*ChannelFactory<IDiskInfo> TestChannelFactory = new ChannelFactory<IDiskInfo>(new NetHttpBinding(), new EndpointAddress("http://localhost:8080/DiskInfoService/EndPoint_1")); IDiskInfo ChannelToService = TestChannelFactory.CreateChannel();*/ //С прокси DiskInfoClient ClientProxy = new DiskInfoClient(MyResourses.Texts.EndPoint_1); try { ConsoleTextBox.Text = await ClientProxy.GetDriversDataAsync(); ClientProxy.Close(); } catch (FaultException CurrentException) { MessageBox.Show(CurrentException.Message, MyResourses.Texts.Error, MessageBoxButton.OK, MessageBoxImage.Error); ClientProxy.Abort(); } catch (CommunicationException CurrentException) { MessageBox.Show(CurrentException.Message, MyResourses.Texts.Error, MessageBoxButton.OK, MessageBoxImage.Error); ClientProxy.Abort(); } catch (TimeoutException CurrentException) { MessageBox.Show(CurrentException.Message, MyResourses.Texts.Error, MessageBoxButton.OK, MessageBoxImage.Error); ClientProxy.Abort(); } finally { lock (StatusChangeGate) { if (!ShutDown) Application.Current.Dispatcher.Invoke(new Action(() => StatusLabel.Content = MyResourses.Texts.StatusFree)); ClientBusy = false; } } }
public MainForm() { proxy = new DiskInfoClient(); InitializeComponent(); }
public void GetDriversNames() { lock (SafeProgramClosingGate) { //Ниже использован рекомендуемый способ закрытия прокси клиента DiskInfoClient ClientProxy = new DiskInfoClient(MyResourses.Texts.EndPoint_1); try { List<string> CurrentDrivers = ClientProxy.GetDriversNames(); StringBuilder ListOfDrivers = new StringBuilder(); foreach (string DriveName in CurrentDrivers) { ListOfDrivers.Append(DriveName + " "); } Application.Current.Dispatcher.Invoke(new Action(() => DriversNamesLabel.Content = ListOfDrivers)); ClientProxy.Close(); } catch (FaultException CurrentException) { MessageBox.Show(CurrentException.Message, MyResourses.Texts.Error, MessageBoxButton.OK, MessageBoxImage.Error); ClientProxy.Abort(); } catch (CommunicationException CurrentException) { MessageBox.Show(CurrentException.Message, MyResourses.Texts.Error, MessageBoxButton.OK, MessageBoxImage.Error); ClientProxy.Abort(); } catch (TimeoutException CurrentException) { MessageBox.Show(CurrentException.Message, MyResourses.Texts.Error, MessageBoxButton.OK, MessageBoxImage.Error); ClientProxy.Abort(); } finally { lock (StatusChangeGate) { if (!ShutDown) Application.Current.Dispatcher.Invoke(new Action(() => StatusLabel.Content = MyResourses.Texts.StatusFree)); ClientBusy = false; } } } }