private void ChangePointsNow() { try { using (MyServiceClient c = new MyServiceClient(generalData.ServerIP)) { if ((DateTime.Now - nudTeam1Points.ChangePointsDate).TotalMilliseconds > 1000) { c.ChangePointsAsync(generalData.GameName, lblTeam1.Text, generalData.UserName, (int)nudTeam1Points.Value). ContinueWith(x => FinishChangePoints(nudTeam1Points)); } if ((DateTime.Now - nudTeam2Points.ChangePointsDate).TotalMilliseconds > 1000) { c.ChangePointsAsync(generalData.GameName, lblTeam2.Text, generalData.UserName, (int)nudTeam2Points.Value). ContinueWith(x => FinishChangePoints(nudTeam2Points)); } if ((DateTime.Now - gamePointsTeam1.ChangePointsDate).TotalMilliseconds > 1000) { c.ChangeGamePointsAsync(generalData.GameName, lblTeam1.Text, generalData.UserName, gamePointsTeam1.GamesWin ?? 0). ContinueWith(x => FinishChangePoints(gamePointsTeam1)); } if ((DateTime.Now - gamePointsTeam2.ChangePointsDate).TotalMilliseconds > 1000) { c.ChangeGamePointsAsync(generalData.GameName, lblTeam2.Text, generalData.UserName, gamePointsTeam2.GamesWin ?? 0). ContinueWith(x => FinishChangePoints(gamePointsTeam2)); } } } catch (Exception ex) { lblError.Text = "Error al cambiar puntos: " + ex.Message; } }
private void Try_To_Create_New_Client() { try { NetTcpBinding binding = new NetTcpBinding(SecurityMode.Transport); binding.Security.Message.ClientCredentialType = MessageCredentialType.Windows; binding.Security.Transport.ClientCredentialType = TcpClientCredentialType.Windows; binding.Security.Transport.ProtectionLevel = System.Net.Security.ProtectionLevel.EncryptAndSign; string uri = "net.tcp://localhost:9002/MyService"; EndpointAddress endpoint = new EndpointAddress(new Uri(uri)); client = new MyServiceClient(binding, endpoint); //client.ClientCredentials.Windows.ClientCredential.Domain = ""; //client.ClientCredentials.Windows.ClientCredential.UserName = "******"; //client.ClientCredentials.Windows.ClientCredential.Password = "******"; } catch (Exception ex) { MessageBox.Show(ex.ToString()); MessageBox.Show(ex.InnerException.ToString()); client = null; } }
static void Main(string[] args) { IMyService ms = new MyServiceClient("BasicHttpBinding_IMyService"); Console.WriteLine(ms.RetSomeValue()); Console.ReadLine(); }
Program () { client = ServiceClientHelper.CreateServiceClient (); asyncEvent = new AutoResetEvent (false); client.TestOutCompleted += TestOutCompleted; client.TestByRefCompleted += TestByRefCompleted; }
private void timerRefresh_Tick(object sender, EventArgs e) { if (this.Visible && DateTime.Now - lastTimeTimer >= TimeSpan.FromMilliseconds(timerRefresh.Interval - 10)) { lastTimeTimer = DateTime.Now; try { ChangePointsNow(); using (MyServiceClient c = new MyServiceClient(generalData.ServerIP)) { c.GetMusDataAsync(generalData.GameName, generalData.TeamName, generalData.UserName). ContinueWith(req => { RefreshMusPointsData(req.Result as MusData); if (musData.SpecialMessage != MusSpecialMessages.None) { PlayMessage(musData.SpecialMessage); } }); c.GetTracesAsync(generalData.GameName). ContinueWith(req => RefreshMusTraces(req.Result as string[])); } } catch (Exception ex) { lblError.Text = "ERROR EN EL TIMER: " + ex.Message; } } }
static void Main(string[] args) { MyServiceClient client = new MyServiceClient(); var st = client.GetMessage(); Console.Read(); }
protected void Page_Load(object sender, EventArgs e) { client = new MyServiceClient(); roles = client.SelectAllRoles(); // הגדרת עמודות columns = new GridViewColumnDefinitions(); columns.Add(new GridViewColumnDefinition( "Name", "שם תפקיד", ColumnType.STRING_COLUMN, ColumnAligment.CENTER ) ); if (!IsPostBack) { // גריד עם אפשרויות עריכה GridViewUtilities.SetColumns <Role>( // Grid-הטיפוס המוצג ב grdCities, // Grid-שם ה roles, // רשימת הישובים columns, // רשימת העמודות 20, // Grid-רוחב ה true // לכלול עמודת עריכה ); } }
private void Form2_Load(object sender, EventArgs e) { MyServiceClient client = new MyServiceClient(); MessageBox.Show(client.GetData(125)); MessageBox.Show(client.Endpoint.Address.Uri.AbsolutePath); }
//This is the Delete button. //I clear the message field every click. //Initialize a MyServiceClient. //Get the deleteName from the deleteContact field and saved it in the variable. //Message field will equals with the deleteContact method returned value. private void button2_Click(object sender, EventArgs e) { message.Text = ""; MyServiceClient client = new MyServiceClient(); string deleteName = deleteContact.Text; message.Text = client.deleteContact(deleteName); }
static void Main(string[] args) { using (var client = new MyServiceClient()) { var airlines = client.GetAllAirline(); client.ConvertToString(10); } }
bool GoToNextround() { using (MyServiceClient c = new MyServiceClient(generalData.ServerIP)) { c.NextRound(generalData.GameName, generalData.TeamName, generalData.UserName, round); } return(true); }
bool RequestShowCards() { using (MyServiceClient c = new MyServiceClient(generalData.ServerIP)) { c.RequestShowCards(generalData.GameName, generalData.TeamName, generalData.UserName, round); } return(true); }
public void ProcessRequest(HttpContext context) { MyServiceClient tcpClient = new MyServiceClient(); Image img = Image.FromStream(tcpClient.GetMyStream(30, 100)); img.Save(context.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg) img.Dispose() }
//This is the Delete button. //I clear the message field every click. //Initialize a MyServiceClient. //Get the deleteName from the deleteContact field and the deleteNumber from the deleteContactNumber field and saved it in 2 variable. //Message field will equals with the deleteContact method returned value. private void deleteContactButton_Click(object sender, EventArgs e) { message.Text = ""; MyServiceClient client = new MyServiceClient(); string deleteName = deleteContact.Text; string deleteNumber = deleteContactNumber.Text; message.Text = client.deleteContact(deleteName, deleteNumber); }
public void InvokeServiceOperation() { using (MyServiceClient proxy = new MyServiceClient()) { Product[] Prods = proxy.GetAllProducts(); Assert.IsNotNull(Prods); } }
//This is the Add button. //I clear the message field every click. //Initialize a MyServiceClient. //Get the contactName and contactNumber from the addContactName field and addContactNumber field and saved it in 2 variable. //Message field will equals with the addContact method returned value. private void button1_Click(object sender, EventArgs e) { message.Text = ""; MyServiceClient client = new MyServiceClient(); string contactName = addContactName.Text; string contactNumber = addContactNumber.Text; message.Text = client.addContact(contactName, contactNumber); }
bool GetCards() { using (MyServiceClient c = new MyServiceClient(generalData.ServerIP)) { var cards = c.GetCards(generalData.GameName, generalData.TeamName, generalData.UserName); playerControl1.Cards = cards.ToList(); } return(true); }
static void Main(string[] args) { MyServiceClient ms = new MyServiceClient("BasicHttpBinding_IMyService"); Console.WriteLine(ms.sum(2, 2)); MyService2Client ms2 = new MyService2Client("NetTcpBinding_IMyService2"); Console.WriteLine(ms2.pro(2, 2)); Console.ReadLine(); }
private static async Task Run() { using (var svc = new MyServiceClient()) { var result = await svc.SumAsync(1, 2); Console.WriteLine("Result: " + result); } Console.ReadLine(); }
protected void Page_Load(object sender, EventArgs e) { var client = new MyServiceClient(); var countries = client.GetAllCountries(); DropDownList1.DataSource = countries; DropDownList1.DataValueField = "CountryId"; DropDownList1.DataTextField = "CountryName"; DropDownList1.DataBind(); }
//When this window is loaded: //-I create a new MyServiceClient instance. //-Call the showContact method and the returned value I save it in a new string[]. //-Iterate over the string[]. //-In the iterate, I append each contact to the ContactNames fields. private void AllContact_Load(object sender, EventArgs e) { MyServiceClient client = new MyServiceClient(); string[] contacts = client.showContact(); for (int i = 0; i < contacts.Length; i++) { ContactNames.Text += contacts.ElementAt(i) + "\n"; } }
protected void Page_Load(object sender, EventArgs e) { MyServiceClient svcClient = new MyServiceClient(); DropDownList1.DataSource = svcClient.GetAllCountries(); DropDownList1.DataValueField = "CountryId"; DropDownList1.DataTextField = "CountryName"; DropDownList1.DataBind(); }
//This is the Log Out button. //Initialize a MyServiceClient. //Call the LogOut method with the Form1 static variable. //Hide this window. //Create a new Form1 instance, and show it. private void button4_Click(object sender, EventArgs e) { MyServiceClient client = new MyServiceClient(); client.Logout(Form1.Username); this.Hide(); Form1 form1 = new Form1(); form1.Show(); }
static void Main(string[] args) { var msg = "Your SMS Message"; var serviceProviderId = 42; // Use the constructor overloads for ServiceClient to configure how to connect var service = new MyServiceClient(); service.smsSend(serviceProviderId, msg); }
private void AllContact_Load(object sender, EventArgs e) { MyServiceClient client = new MyServiceClient(); Dictionary <string, string> contacts = client.showContact(); for (int i = 0; i < contacts.Count; i++) { ContactNames.Text += contacts.Keys.ElementAt(i) + "\n"; ContactNumbers.Text += contacts.Values.ElementAt(i) + "\n"; } }
static void Main(string[] args) { Console.Write("Skriv meddelande (max 50 tecken): "); var service = new MyServiceClient(); string message = Console.ReadLine(); Console.WriteLine(service.AddMessage(message)); Console.WriteLine("Tryck på valfri tangent för att avsluta."); Console.ReadKey(); }
bool Discard() { var discards = playerControl1.Discards; using (MyServiceClient c = new MyServiceClient(generalData.ServerIP)) { var newCards = c.ChangeCards(generalData.GameName, generalData.TeamName, generalData.UserName, discards.ToArray()); playerControl1.ChangeDiscards(newCards); } return(true); }
private void cmbHandUser_SelectedIndexChanged(object sender, EventArgs e) { if (changeUser) { using (MyServiceClient c = new MyServiceClient(generalData.ServerIP)) { string newHand = cmbHandUser.SelectedItem.ToString(); c.ChangeHand(generalData.GameName, generalData.UserName, newHand); HandUser = newHand; } } }
public static string Check(string version) { using (var client = new MyServiceClient(new BasicHttpBinding(), new EndpointAddress("http://87.106.9.183:23651"))) { var response = client.Execute(); if (response.Equals(version)) { return("ok"); } //else return(response); } }
private void btn_Close_Click(object sender, EventArgs e) { if (client != null) { Print("Closing a client ..."); client.Close(); client = null; } else { Print("Error! Client does not exist!"); } this.Close(); }
public ActionResult Details(int id) { Opera opera = contextDB.Operas.Find(id); if (opera != null) { string location = new MyServiceClient().GetLocation("Copenhagen"); opera.GeoLocation = location; return(View("Details", opera)); } else { return(HttpNotFound()); } }
public static void Main (string[] args) { Console.WriteLine ("WCF Client\n"); string name = ""; var binding = new BasicHttpBinding (); var address = new EndpointAddress ("http://localhost:8080"); var client = new MyServiceClient (binding, address); while (true) { Console.Write("\nEnter name: "); name = Console.ReadLine (); Console.WriteLine ("Service response: " + client.Greet (name)); } }
/// <summary> /// WcfTcpHost.ClientWindow クラスの新しいインスタンスを作成します。 /// </summary> public ClientWindow() { InitializeComponent(); // 双方向通信を行う場合、サービス側にコールバックの実装を教える必要がある。 var context = new InstanceContext(this); var proxy = new MyServiceClient(context); var info = new ClientInfo(); info.IpAddress = "192.168.150.1"; info.Port = 8000; proxy.Initialize(info); this.FProxy = proxy; this.AddLog("Hello"); this.Execute("StartCallback"); }
/// <summary> /// Creates the new client. /// </summary> private void Create_New_Client() { if (client == null) { try { Try_To_Create_New_Client(); } catch (Exception ex) { Print(ex); Print(ex.InnerException); client = null; } } else { Print("Cannot create a new client. The current Client is active."); } }
private static void SVInvoke() { //var sv = new ServiceReference1.Service1Client(); //sv.DoWork(); MyServiceClient client = new MyServiceClient(); client.DoWork(); client.Close(); //MyService2Client client = new MyService2Client(); //client.DoWork(); //var channelFactory = new ChannelFactory<IMyService>("WSHttpBinding_IMyService"); //var client1 = channelFactory.CreateChannel(); //var os = proxy.MyTransparentProxy.Create<IMyService>(client1); //os.DoWork(); }
static void Main(string[] args) { // Create activity to contain the other activities var ts = new TraceSource("MyServiceTraceSource"); Guid mainActivityId = Guid.NewGuid(); Trace.CorrelationManager.ActivityId = mainActivityId; ts.TraceEvent(TraceEventType.Start, 0, "Main Activity"); // Create new activity and transfer to it Guid newActivityId = Guid.NewGuid(); ts.TraceTransfer(0, "Transferring...", newActivityId); Trace.CorrelationManager.ActivityId = newActivityId; ts.TraceEvent(TraceEventType.Start, 0, "GetHeader Activity"); // Call operation using (MyServiceClient proxy = new MyServiceClient("WSHttpBinding_MyService")) { try { Console.WriteLine(proxy.GetHeader("MyHeader", "http://tempuri.org")); ts.TraceEvent(TraceEventType.Information, 0, "GetHeader succeeded!"); } catch (FaultException<string> ex) { Console.WriteLine(ex.Reason); Console.WriteLine(ex.Detail); ts.TraceEvent(TraceEventType.Error, 0, "GetHeader failed.\nReason:{0}\nDetail{1}", ex.Reason, ex.Detail); } } // Transfer back to main activity ts.TraceTransfer(666, "Transferring...", mainActivityId); ts.TraceEvent(TraceEventType.Stop, 0, "GetHeader Activity"); Trace.CorrelationManager.ActivityId = mainActivityId; // Stop the main activity ts.TraceEvent(TraceEventType.Stop, 0, "Main Activity"); Console.ReadKey(); }
public MainWindow() { InitializeComponent(); this.client = new ServiceReference1.MyServiceClient(); }
protected void Page_Load(object sender, EventArgs e) { MyServiceClient c = new MyServiceClient(); GridView1.DataSource = c.GetAllEmployees(); GridView1.DataBind(); }
static void Main(string[] args) { MyServiceClient client = new MyServiceClient(); var st=client.GetMessage(); Console.Read(); }
static void TestService() { var client = new MyServiceClient(); var hello = client.Hello(); Console.WriteLine(hello); client.Close(); }