예제 #1
0
        public long sendComputerDetails()
        {
            SendComputerDetailsRequest request         = new SendComputerDetailsRequest();
            ComputerDetails            computerDetails = new ComputerDetails();
            RegistryKey key = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\isecurity");

            if (key.ValueCount != 0)
            {
                //computerDetails.serverId = long.Parse(key.GetValue("serverId").ToString());
                computerDetails.localId = long.Parse(key.GetValue("localId").ToString());
                key.Close();
            }
            else
            {
                computerDetails.localId = DateTime.Now.Ticks / 1000;
            }
            computerDetails.localUserName = Environment.UserName;
            computerDetails.computerName  = Environment.MachineName;
            string hostName = Dns.GetHostName();
            string myIP     = Dns.GetHostByName(hostName).AddressList[0].ToString();

            computerDetails.ip      = myIP;
            request.ComputerDetails = computerDetails;
            SendComputerDetailsResponse response;

            try
            {
                response = client.SendComputerDetails(request);
                key      = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\isecurity");
                key.SetValue("serverId", response.ComputerDetails.serverId);
                key.SetValue("localId", response.ComputerDetails.localId);
                key.Close();
            }
            catch (Exception ex)
            {
                return(0);
            }
            return(response.ComputerDetails.serverId);
        }