Esempio n. 1
0
 private void btnketnoi_Click(object sender, EventArgs e)
 {
     try
     {
         if (cbbkieukn.SelectedIndex == 0)
         {
             EndpointAddress address = new EndpointAddress(new Uri("http://localhost:8888/BasicHttpBinding/Test1"));
             ChannelFactory<IService1> factory = new ChannelFactory<IService1>(new BasicHttpBinding(), address);
             service = factory.CreateChannel();
             rtxtthongtin.Text = service.GetAuthors();
         }
         if (cbbkieukn.SelectedIndex == 1)
         {
             EndpointAddress address = new EndpointAddress(new Uri("http://localhost:8888/WSHttpBinding/Test2"));
             ChannelFactory<IService1> factory = new ChannelFactory<IService1>(new WSHttpBinding(), address);
             service = factory.CreateChannel();
             rtxtthongtin.Text = service.GetAuthors();
         }
         if (cbbkieukn.SelectedIndex == 2)
         {
             EndpointAddress address = new EndpointAddress(new Uri("net.tcp://localhost:8888/NetTcpBinding/Test3"));
             ChannelFactory<IService1> factory = new ChannelFactory<IService1>(new NetTcpBinding(), address);
             service = factory.CreateChannel();
             rtxtthongtin.Text = service.GetAuthors();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Không kết nối được!!!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
         rtxtthongtin.Text = "";
     }
 }
 public RootClass(IService1 service1, IService2 service2, string stringProperty, int intProperty)
 {
     this.service1 = service1;
     this.service2 = service2;
     StringProperty = stringProperty;
     IntProperty = intProperty;
 }
Esempio n. 3
0
        /// <summary>
        /// Constructor - takes in implementation of IService1
        /// </summary>
        /// <param name="service">The IService1 implementation</param>
        public Service1(IService1 service)
        {
            if (service == null)
                throw new ArgumentNullException(nameof(service));

            this._service = service;
        }
Esempio n. 4
0
 private void btnngatkn_Click(object sender, EventArgs e)
 {
     service = null;
     txttinhtrang.Text = "Ngắt kết nối!";
     grbkieukn.Enabled = true;
     btnketnoi.Enabled = true;
     btnngatkn.Enabled = false;
 }
Esempio n. 5
0
 public Form1()
 {
     InitializeComponent();
     serv = new Service1Client();
     string[] cus = serv.readTable("Customer");
     listBox1.Items.Clear();
     foreach (string c in cus)
         listBox1.Items.Add(c);
 }
 public MainForm()
 {
     InitializeComponent();
     InstanceContext m_CallBackContext;
     m_CallBackContext = new InstanceContext(this);
     DuplexChannelFactory<IService1> m_ChannelFactory;
     NetTcpBinding binding = new NetTcpBinding();
     Uri baseAddress = new Uri("net.tcp://localhost:10086/WCFHostServer/Service1");
     m_ChannelFactory = new DuplexChannelFactory<IService1>(m_CallBackContext, binding, new EndpointAddress(baseAddress));
     m_Innerclient = m_ChannelFactory.CreateChannel();
 }
Esempio n. 7
0
        public Form2(IService1 serv, string cid)
        {
            InitializeComponent();
            this.serv = serv;
            this.cid = cid;
            string[] prd = serv.readTable("Product");
            listBox1.Items.Clear();
            foreach (string p in prd)
                listBox1.Items.Add(p);

            mesg= new Queue<string>();
            mesg.Enqueue(listBox1.Items[0].ToString() + "\t Quantity");
        }
Esempio n. 8
0
    protected void Page_Load(object sender, EventArgs e)
    {
        address = new EndpointAddress("http://localhost:6000/service");
        binding = new WSHttpBinding();
        factory = new ChannelFactory <IService1>(binding, address);
        proxy   = factory.CreateChannel();

        DataTable ntable = new DataTable();

        ntable.Columns.Add("ID");
        ntable.Columns.Add("NodeID");

        ntable.Columns["ID"].AutoIncrement     = true;
        ntable.Columns["ID"].AutoIncrementSeed = 1;
        ntable.Columns["ID"].AutoIncrementStep = 1;

        DataColumn[] nkeys = new DataColumn[1];
        nkeys[0]          = ntable.Columns["ID"];
        ntable.PrimaryKey = nkeys;

        ViewState["NTable"] = ntable;
    }
Esempio n. 9
0
 private void btnketnoi_Click(object sender, EventArgs e)
 {
     try
     {
         if (rdbasic.Checked == true)
         {
             address = new EndpointAddress(new Uri("http://localhost:8888/BasicHttpBinding"));
             factory = new ChannelFactory<IService1>(new System.ServiceModel.BasicHttpBinding(), address);
             service = factory.CreateChannel();
             checkConnect = service.checkServer();
         }
         else if (rdws.Checked == true)
         {
             address = new EndpointAddress(new Uri("http://localhost:8888/WSHttpBinding"));
             factory = new ChannelFactory<IService1>(new WSHttpBinding(), address);
             service = factory.CreateChannel();
             checkConnect = service.checkServer();
         }
         else if (rdnet.Checked == true)
         {
             address = new EndpointAddress(new Uri("net.tcp://localhost:8888/NetTcpBinding"));
             factory = new ChannelFactory<IService1>(new NetTcpBinding(), address);
             service = factory.CreateChannel();
             checkConnect = service.checkServer();
         }
         if(checkConnect = service.checkServer())
         {
             txttinhtrang.Text = "Đã kết nối với Server!";
             btnngatkn.Focus();
             grbkieukn.Enabled = false;
             btnketnoi.Enabled = false;
             btnngatkn.Enabled = true;
         }
     }
     catch (Exception ex)
     {
         txttinhtrang.Text = "Lỗi kết nối!";
     }
 }
Esempio n. 10
0
    public static void Test()
    {
        string      baseAddress = "http://" + Environment.MachineName + ":8000/Service";
        ServiceHost host        = new ServiceHost(typeof(Service1), new Uri(baseAddress));

        host.AddServiceEndpoint(typeof(IService1), new BasicHttpBinding(), "");
        host.Description.Behaviors.Add(new ServiceMetadataBehavior {
            HttpGetEnabled = true
        });
        host.Open();
        Console.WriteLine("Host opened");
        ChannelFactory <IService1> factory = new ChannelFactory <IService1>(new BasicHttpBinding(), new EndpointAddress(baseAddress));
        IService1 proxy = factory.CreateChannel();

        Console.WriteLine(proxy.GetData(new MyRequest {
            name = "hello"
        }));
        ((IClientChannel)proxy).Close();
        factory.Close();
        Console.Write("Press ENTER to close the host");
        Console.ReadLine();
        host.Close();
    }
Esempio n. 11
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            try
            {
                if (Page.IsValid)
                {
                    wfc.NewRec(Convert.ToInt32(DropDownList1.SelectedValue), Convert.ToInt32(DropDownList2.SelectedValue),
                               Convert.ToInt32(TextBox1.Text), Convert.ToDateTime(DateO.Text));

                    ChannelFactory <IService1> factory = new ChannelFactory <IService1>(binding, endpoint);
                    IService1 channel = factory.CreateChannel();
                    channel.CountOfDBRows((GridView1.Rows.Count + 1).ToString());
                    factory.Close();

                    GridView1.DataSource = wfc.GetData();
                    GridView1.DataBind();
                }
            }
            catch (Exception exc)
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Host closed!')", true);
            }
        }
Esempio n. 12
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text != "")
            {
                endPointAddr = "net.tcp://" + textBox2.Text + ":8000/MyService";
                NetTcpBinding tcpBinding = new NetTcpBinding();
                tcpBinding.TransactionFlow = false;
                tcpBinding.Security.Transport.ProtectionLevel      = System.Net.Security.ProtectionLevel.EncryptAndSign;
                tcpBinding.Security.Transport.ClientCredentialType = TcpClientCredentialType.Windows;
                tcpBinding.Security.Mode = SecurityMode.None;

                EndpointAddress endpointAddress = new EndpointAddress(endPointAddr);

                Append("Attempt to connect to: " + endPointAddr);

                IService1 proxy = ChannelFactory <IService1> .CreateChannel(tcpBinding, endpointAddress);

                using (proxy as IDisposable)
                {
                    Append("Message from server: " + (proxy.HelloWorld(textBox1.Text) + " back to you :)"));
                }
            }
        }
Esempio n. 13
0
        /// <summary>
        /// Entry point
        /// </summary>
        /// <param name="args">Head node to contact</param>
        public static void Main(string[] args)
        {
            if (args.Length != 1)
            {
                Console.WriteLine("Usage:");
                Console.WriteLine("\tClusterWebHttp.exe <headNode>");
                Console.WriteLine("Example:");
                Console.WriteLine("\tClusterWebHttp.exe myHeadNode");
                return;
            }

            string           headNode = args[0];
            string           service  = "WebHttpDemo";
            SessionStartInfo ssi      = new SessionStartInfo(headNode, service);

            ssi.SessionResourceUnitType = SessionUnitType.Core;
            ssi.MaximumUnits            = 1;
            ssi.MinimumUnits            = 1;
            ssi.Secure = false;

            Session session = Session.CreateSession(ssi);

            ChannelFactory <IService1> factory = new ChannelFactory <IService1>(new WebHttpBinding(WebHttpSecurityMode.None), session.EndpointReference);

            factory.Endpoint.Behaviors.Add(new WebHttpBehavior());

            IService1 proxy = factory.CreateChannel();

            for (int i = 0; i < 5; ++i)
            {
                Console.WriteLine(proxy.Echo("hello" + i));
            }
            ((IClientChannel)proxy).Close();
            factory.Close();
            session.Close();
        }
Esempio n. 14
0
        static void GetToDoListByName(string Name)
        {
            using (ChannelFactory <IService1> cf = new ChannelFactory <IService1>(new WebHttpBinding(), "http://localhost:8000/Index"))
            {
                cf.Endpoint.Behaviors.Add(new WebHttpBehavior());
                IService1 channel = cf.CreateChannel();

                List <ToDo> GTodoByID = new List <ToDo>();
                Console.WriteLine("Vems Todos Vill du se ");
                String TName = Console.ReadLine();

                GTodoByID = channel.GetToDoListByName(TName);

                foreach (var g in GTodoByID)
                {
                    Console.WriteLine(g.Id);
                    Console.WriteLine(g.Description);
                    Console.WriteLine(g.Name);
                    Console.WriteLine(g.DeadLine);
                    Console.WriteLine(g.EstimationTime);
                }
                Console.ReadLine();
            }
        }
Esempio n. 15
0
        /* The client that sits on the field where watson is located */
        public string StartClient(string ipAddress, int port)
        {
            try
            {
                string endPointAddr = "";
                endPointAddr = "net.tcp://" + ipAddress + ":" + port + "/MyService";
                NetTcpBinding tcpBinding = new NetTcpBinding();
                tcpBinding.TransactionFlow = false;
                //tcpBinding.Security.Transport.ProtectionLevel = System.Net.Security.ProtectionLevel.EncryptAndSign;
                //tcpBinding.Security.Transport.ClientCredentialType = TcpClientCredentialType.Windows;
                tcpBinding.Security.Transport.ProtectionLevel      = System.Net.Security.ProtectionLevel.None;
                tcpBinding.Security.Transport.ClientCredentialType = TcpClientCredentialType.None;
                tcpBinding.Security.Mode = SecurityMode.None;
                EndpointAddress endpointAddress = new EndpointAddress(endPointAddr);
                m_proxy = ChannelFactory <IService1> .CreateChannel(tcpBinding, endpointAddress);

                string res = m_proxy.HelloWorld("test");
                return(res);
            }
            catch (Exception err)
            {
                return(err.Message);
            }
        }
Esempio n. 16
0
        /* The client that sits on the field where watson is located */
        public string StartClient(string ipAddress, int port)
        {
            try
            {
                NetTcpBinding tcpBinding = new NetTcpBinding();
                tcpBinding.OpenTimeout    = TimeSpan.FromSeconds(15);
                tcpBinding.ReceiveTimeout = TimeSpan.FromSeconds(10);
                tcpBinding.SendTimeout    = TimeSpan.FromSeconds(10);
                tcpBinding.CloseTimeout   = TimeSpan.FromSeconds(10);

                tcpBinding.TransactionFlow = false;
                tcpBinding.Security.Transport.ProtectionLevel      = System.Net.Security.ProtectionLevel.EncryptAndSign;
                tcpBinding.Security.Transport.ClientCredentialType = TcpClientCredentialType.Windows;
                tcpBinding.Security.Mode = SecurityMode.Transport;

                string endPointAddr = "";
                endPointAddr = "net.tcp://" + ipAddress + ":" + port + "/MyService";

                pipeFactory =
                    new DuplexChannelFactory <IService1>(
                        new InstanceContext(this),
                        tcpBinding,
                        new EndpointAddress(endPointAddr));

                m_proxy = pipeFactory.CreateChannel();

                string res = m_proxy.HelloWorld("test");


                return(res);
            }
            catch (Exception err)
            {
                return(err.Message);
            }
        }
 public WithDefaultAndSingleParameter(IService1 service1) { }
Esempio n. 18
0
 public With3Parameters(IService1 service1, IService2 service2)
 {
 }
Esempio n. 19
0
 public H(IService1 s1)
 {
     _s1 = s1;
 }
Esempio n. 20
0
 private void button1_Click(object sender, EventArgs e)
 {
     var productAddress = new EndpointAddress("net.tcp://localhost:9010/ProductService");
     _productChannel = ChannelFactory<IService1>.CreateChannel(new NetTcpBinding(), productAddress);
 }
Esempio n. 21
0
 public Database(IService1 one, IService2 two)
 {
 }
 public ExampleTwoWithSeparateArgument2(IService1 s1)
 {
     _s1 = s1;
 }
Esempio n. 23
0
 public ServerStatusRepository(IService1 service)
 {
     _webservice = service;
 }
Esempio n. 24
0
 internal WithServiceInternal(IService1 service)
 {
     Service = service;
 }
 public RootClass(IService1 service1, IService2 service2) : this(service1, service2, "DEFAULT", 1976)
 {
 }
Esempio n. 26
0
 public Service3DependsOnService1And2(IService1 s1, IService2 s2)
 {
 }
Esempio n. 27
0
 public SharedParamFixtureTest(IService service, IService1 service1, [Column(123, 456)] int parameter)
 {
     this.service = service;
     this.service1 = service1;
     this.parameter = parameter;
 }
 public ExampleTwoWithOneArgument(IService1 s1)
 {
     _s1 = s1;
 }
 private ExampleTwoArgumentsPrivate(IService1 s1, IService2 s2)
 {
     _s1 = s1;
       _s2 = s2;
 }
 public ExampleTwoArguments(IService1 s1, IService2 s2)
 {
     _s1 = s1;
       _s2 = s2;
 }
Esempio n. 31
0
 public Runner(IService1 service1, IService2 service2, IConfig config, IControl control)
 {
 }
Esempio n. 32
0
 public HomeController(IService1 service)
 {
     _Service1 = service;
 }
Esempio n. 33
0
 public DefaultService2(IService1 service1)
 {
     this.service1 = service1;
 }
 public With3Parameters(IService1 service1, IService2 service2) { }
Esempio n. 35
0
        private void button1_Click(object sender, EventArgs e)
        {
            Ouvrage ouvrage = new Ouvrage();

            if (vide.Checked)
            {
                ouvrage.Type = null;
            }

            if (livre.Checked)
            {
                ouvrage.Type = "livre";
            }

            if (these.Checked)
            {
                ouvrage.Type = "these";
            }

            if (memoire.Checked)
            {
                ouvrage.Type = "memoire";
            }


            if (titre.Text == "")
            {
                ouvrage.Titre = null;
            }
            else
            {
                ouvrage.Titre = titre.Text;
            }
            if (theme.Text == "")
            {
                ouvrage.Theme = null;
            }
            else
            {
                ouvrage.Theme = theme.Text;
            }
            if (auteur.Text == "")
            {
                ouvrage.Auteur = null;
            }
            else
            {
                ouvrage.Auteur = auteur.Text;
            }

            ChannelFactory <IService1> channelFactory =
                new ChannelFactory <IService1>("BasicHttpBinding_IService1");
            IService1 operation   = channelFactory.CreateChannel();
            var       bindingList = new BindingList <Ouvrage>(operation.Recherche(ouvrage));

            Console.WriteLine(operation.Recherche(ouvrage).Count);
            var source = new BindingSource(bindingList, null);

            dataGridView1.Rows.Clear();
            dataGridView1.DataSource = source;
        }
Esempio n. 36
0
 public Service3DependsOnService1(IService1 s1)
 {
 }
 public MyService(IService1 service1, IService2 service2, IOptions <MyServiceOptions> serviceOptions)
 {
     var connectionString = serviceOptions.Value.ConnectionString;
     //...
 }
Esempio n. 38
0
 private void btnngat_Click(object sender, EventArgs e)
 {
     service = null;
     MessageBox.Show("Đã ngắt kết nối tới máy chủ...","Thông báo",MessageBoxButtons.OK,MessageBoxIcon.Information);
     rtxtthongtin.Text = "";
 }
 public Controller(IService1 s1, IService2 s2, IService3 s3)
 {
     this.S1 = s1;
     this.S2 = s2;
     this.S3 = s3;
 }
Esempio n. 40
0
 public Service3(IService1 service1, IService2 service2)
 {
     Service1 = service1;
     Service2 = service2;
 }
Esempio n. 41
0
#pragma warning disable CA1801  //Parameter  is never used. Remove the parameter or use it in the method body
        public With3Parameters(IService1 service1)
        {
        }
Esempio n. 42
0
 public MyFunction1(IService1 service1, ILogger logger)
 {
     this.service1 = service1;
     this.logger   = logger;
     logger.LogWarning($"Creating {this}");
 }
Esempio n. 43
0
 public Service3(IService1 service1, IService2 service2)
 {
     _service1 = service1;
     _service2 = service2;
 }
Esempio n. 44
0
 public RootClass(IService1 service1, IService2 service2) : this(service1, service2, "DEFAULT", 1976)
 {
 }
 public WithPrivateConstructor(IService1 service1)
 {
 }
 public ExampleOneArgument(IService1 s1)
 {
     _s1 = s1;
 }
 public Service3(IService1 svc)
 {
     Service1 = svc;
 }
 private WithPrivateConstructor(IService1 service1, IService2 service2)
 {
 }
 public Function1(IService1 service1, ILogger logger)
 {
     _service1 = service1;
     _logger   = logger;
     _logger.LogWarning($"Creating {this}");
 }
Esempio n. 50
0
 public SharedParamFixtureTest(IService service, IService1 service1, [Column(123, 456)] int parameter)
 {
     this.service   = service;
     this.service1  = service1;
     this.parameter = parameter;
 }
Esempio n. 51
0
 public ServiceRoot(IService1 service1, IService2 service21, IService2 service22, IService2 service23, IService3 service3)
 {
 }
 public With3Parameters(IService1 service1) { }
 public MultipleDiAnnotatedManager(IService1 service1)
 {
     Service1 = service1;
 }
Esempio n. 54
0
 public TargetService(IService1 svc1, Lazy <IService2> svc2)
 {
     _svc1 = svc1;
     _svc2 = svc2;
 }
 public WithDefaultAndSingleParameter(IService1 service1)
 {
 }
 public ExampleTwoWithSeparateArgument2(IService1 s1, IService2 s2)
 {
     _s1 = s1;
       _s2 = s2;
 }