Esempio n. 1
0
        /// <summary>开始</summary>
        /// <returns></returns>
        public virtual Boolean Start()
        {
            if (Active)
            {
                return(true);
            }

            // 获取阿里云ONS的名称服务器地址
            var addr = Server;

            if (!addr.IsNullOrEmpty() && addr.StartsWithIgnoreCase("http"))
            {
                var http = new HttpClient();
                var html = http.GetStringAsync(addr).Result;
                if (!html.IsNullOrWhiteSpace())
                {
                    NameServerAddress = html.Trim();
                }
            }

            var client = new NameClient(ClientId, this);

            client.Start();

            var rs = client.GetRouteInfo(Topic);

            foreach (var item in rs)
            {
                XTrace.WriteLine("发现Broker[{0}]: {1}", item.Name, item.Addresses.Join());
            }

            _NameServer = client;

            return(Active = true);
        }
Esempio n. 2
0
 public ConstructorInjection(NameClient client)
 {
     if (client == null)
     {
         throw new ArgumentNullException("client");
     }
 }
Esempio n. 3
0
 private void ClearClient_Click(object sender, EventArgs e)
 {
     Document.Clear();
     NameClient.Clear();
     PhoneClient.Clear();
     Email.Clear();
     AddresClient.Clear();
 }
Esempio n. 4
0
        public ActionResult Save(AddAlternateSpelling alternateSpelling)
        {
            NameClient client = new NameClient();

            client.AddSpelling(alternateSpelling.CommonName, alternateSpelling.VariationName);
            client.Close();

            return(RedirectToAction("All"));
        }
Esempio n. 5
0
 public void TestNameServerMultipleRequestsTwoClients()
 {
     using (var server = new NameServer(0))
     {
         var nameClient  = new NameClient(server.LocalEndpoint);
         var nameClient2 = new NameClient(server.LocalEndpoint);
         nameClient.Register("1", new IPEndPoint(IPAddress.Any, 8080));
         nameClient2.Lookup("1");
     }
 }
Esempio n. 6
0
        //public ActionResult Save(AddNickName nickName)
        public ActionResult Save(string FullName, string NickName)
        {
            NameClient client = new NameClient();

            //client.AddNickName(nickName.FullName, nickName.NickName);
            client.AddNickName(FullName, NickName);
            client.Close();

            return(RedirectToAction("All"));
        }
Esempio n. 7
0
 public void TestNameServerMultipleRequestsTwoClients()
 {
    using (var server = BuildNameServer())
    {
        var nameClient = new NameClient(server.LocalEndpoint);
        var nameClient2 = new NameClient(server.LocalEndpoint);
        nameClient.Register("1", new IPEndPoint(IPAddress.Any, 8080));
        nameClient2.Lookup("1");
    }
 }
Esempio n. 8
0
        public async Task <ActionResult> Search(string origin = null, string gender = "Any")
        {
            SearchModel model = new SearchModel();

            NameClient nameClient = new NameClient(_connectionOptions);

            NameResponse[] names = (await nameClient.GetDetailedNames(origin, gender)).ToArray();
            model.Names = names.Select(response => ConvertNameResponseToModel(response)).ToArray();

            return(View("_Search", model));
        }
Esempio n. 9
0
 private void SaveClient_Click(object sender, EventArgs e)
 {
     CL.AgregarCliente(Document.Text, NameClient.Text, AddresClient.Text, PhoneClient.Text, Email.Text);
     Document.Clear();
     NameClient.Clear();
     AddresClient.Clear();
     PhoneClient.Clear();
     Email.Clear();
     Document.Focus();
     CL.MostrarClientes(dataGridView2);
 }
Esempio n. 10
0
        public ActionResult Save([ModelBinder(typeof(MultipleNameDetailsBinder))] EditNameDetail[] edits, int pageIndex, int rowsPerPage)
        {
            NameClient client = new NameClient();

            client.EditNameDetails(edits.Select(edit => new EditNameDetailRequest()
            {
                NameDetailId = edit.NameDetailId,
                Origin       = edit.Origin,
                Meaning      = edit.Meaning,
                IsDeleted    = edit.IsDeleted
            }).ToArray());
            client.Close();

            return(RedirectToAction("Index", new { pageIndex = pageIndex, rowsPerPage = rowsPerPage }));
        }
Esempio n. 11
0
        public ActionResult All()
        {
            NameClient client = new NameClient();

            NickNameModel[] models = client.GetNickNames().Select(response => new NickNameModel()
            {
                FullNameId = response.FullNameId,
                FullName   = response.FullName,
                NickNameId = response.NickNameId,
                NickName   = response.NickName
            }).ToArray();
            client.Close();

            return(View("All", models));
        }
Esempio n. 12
0
        public ActionResult All()
        {
            NameClient client = new NameClient();

            SpellingModel[] models = client.GetSpellings().Select(response => new SpellingModel()
            {
                CommonNameId    = response.CommonNameId,
                CommonName      = response.CommonName,
                VariationNameId = response.VariationNameId,
                VariationName   = response.VariationName
            }).ToArray();
            client.Close();

            return(View("All", models));
        }
Esempio n. 13
0
        public async Task <ActionResult> Index(string origin = null, string gender = "Any")
        {
            IndexModel model      = new IndexModel(origin, gender);
            NameClient nameClient = new NameClient(_connectionOptions);

            CategoryResponse[] categories = (await nameClient.GetCategories()).ToArray();
            model.Categories = categories.Select(response => ConvertCategoryResponseToModel(response)).ToArray();
            if (!String.IsNullOrEmpty(origin))
            {
                model.Search = new SearchModel();
                NameResponse[] names = (await nameClient.GetDetailedNames(origin, gender)).ToArray();
                model.Search.Names = names.Select(response => ConvertNameResponseToModel(response)).ToArray();
            }

            return(View("Index", model));
        }
Esempio n. 14
0
        public NetworkService(
            [Parameter(typeof(NetworkServiceOptions.NetworkServicePort))] int nsPort,
            [Parameter(typeof(NamingConfigurationOptions.NameServerAddress))] string nameServerAddr,
            [Parameter(typeof(NamingConfigurationOptions.NameServerPort))] int nameServerPort,
            IObserver <NsMessage <T> > messageHandler,
            IIdentifierFactory idFactory,
            ICodec <T> codec)
        {
            _codec = new NsMessageCodec <T>(codec, idFactory);

            IPAddress localAddress = NetworkUtils.LocalIPAddress;

            _remoteManager  = new DefaultRemoteManager <NsMessage <T> >(localAddress, nsPort, _codec);
            _messageHandler = messageHandler;

            NamingClient   = new NameClient(nameServerAddr, nameServerPort);
            _connectionMap = new Dictionary <IIdentifier, IConnection <T> >();

            LOGGER.Log(Level.Info, "Started network service");
        }
Esempio n. 15
0
        public ActionResult Index(int pageIndex = 0, int rowsPerPage = 50)
        {
            IndexModel model = new IndexModel()
            {
                PageIndex = pageIndex, RowsPerPage = rowsPerPage
            };

            NameClient client = new NameClient();

            model.NameDetails = client.GetPagedNames(pageIndex, rowsPerPage).Select(response => new NameDetail()
            {
                NameId       = response.NameId,
                Name         = response.Name,
                NameDetailId = response.NameDetailId,
                Origin       = response.Origin,
                Meaning      = response.Meaning
            }).ToArray();
            client.Close();

            return(View("Index", model));
        }
 public ConstructorInjection(NameClient client)
 {
     if (client == null)
     {
         throw new ArgumentNullException("client");
     }
 }