예제 #1
0
 private bool Equals(DeviceInfo other)
 {
     return
         (string.Equals(MacAddressString, other.MacAddressString) &&
          IpAddress.Equals(other.IpAddress) &&
          string.Equals(MachineName, other.MachineName));
 }
예제 #2
0
        /// <summary>
        /// Determines whether [is valid address].
        /// </summary>
        /// <returns>
        ///     <c>true</c> if [is valid address]; otherwise, <c>false</c>.
        /// </returns>
        public bool IsValidAddress()
        {
            if (IpAddress.Equals("0.0.0.0") ||
                IpAddress.Equals("255.255.255.255"))
            {
                return(false);
            }

            return(true);
        }
예제 #3
0
        public override bool Equals(object obj)
        {
            if (obj is Peer)
            {
                Peer peer = (Peer)obj;
                return(IpAddress.Equals(peer.IpAddress) && Port.Equals(peer.Port));
            }

            return(base.Equals(obj));
        }
예제 #4
0
        public override bool Equals(object obj)
        {
            if (obj == null || !GetType().Equals(obj.GetType()))
            {
                return(false);
            }
            CClientInfo clientInfo = (CClientInfo)obj;

            return(string.Equals(ComputerName, clientInfo.ComputerName, StringComparison.OrdinalIgnoreCase) &&
                   IpAddress.Equals(clientInfo.IpAddress));
        }
예제 #5
0
        private void SyncButton_Click()
        {
            if (IpAddress.Equals(string.Empty) || siteId.Equals(string.Empty) || deviceId.Equals(string.Empty))
            {
                Toast.MakeText(this, "Something went wrong..", ToastLength.Short).Show();
                //StartActivity(typeof(ConfigActivity));
                return;
            }
            RunOnUiThread(() =>
            {
                Toast.MakeText(this, "Please wait..", ToastLength.Short).Show();
                mainHolder.Alpha  = 0.5f;
                loader.Visibility = Android.Views.ViewStates.Visible;
                Window.SetFlags(Android.Views.WindowManagerFlags.NotTouchable, Android.Views.WindowManagerFlags.NotTouchable);
            });

            var thread = new Thread(new ThreadStart(delegate
            {
                var resposeString = WebService.PostDeviceAndSiteIDToWebService("GetVD", deviceId, siteId);
                //var fuelStockRes = WebService.GetDataFromWebService("LoadFStock");
                try
                {
                    var VehicleList = JsonConvert.DeserializeObject <List <VehicleDetails> >(resposeString);
                    //var fuelStoc = JsonConvert.DeserializeObject<List<Fuel>>(fuelStockRes);
                    //Console.WriteLine(fuelStoc);
                    CreateDatabaseOrModifyDatabase(VehicleList);
                }
                catch (Exception ec)
                {
                    Console.WriteLine(ec.Message);
                    RunOnUiThread(() =>
                    {
                        Toast.MakeText(this, "Something wrong ...Check connectivity..", ToastLength.Short).Show();
                        AppPreferences.SaveBool(this, Utilities.IsDownloaded, false);
                        return;
                    });
                }
                RunOnUiThread(() =>
                {
                    loader.Visibility = Android.Views.ViewStates.Gone;
                    mainHolder.Alpha  = 1f;
                    Window.ClearFlags(Android.Views.WindowManagerFlags.NotTouchable);
                    Toast.MakeText(this, "success..", ToastLength.Short).Show();
                    btnDownloadData.Clickable = false;
                    AppPreferences.SaveBool(this, Utilities.IsDownloaded, true);
                });
            }));

            thread.Start();
        }
예제 #6
0
        public ContainsResult Contains(Host host)
        {
            if (host.Format != HostFormat.DomainName && host.Format != HostFormat.IPv4 && host.Format != HostFormat.IPv6)
            {
                throw new ArgumentException($"Format must be {HostFormat.DomainName}, {HostFormat.IPv4}, or {HostFormat.IPv6}.");
            }

            switch (host.Format)
            {
            case HostFormat.DomainName:
                switch (Format)
                {
                case HostFormat.DomainName:
                    return(DomainName.Equals(host.DomainName, StringComparison.OrdinalIgnoreCase) ? ContainsResult.Yes : ContainsResult.No);

                case HostFormat.DomainNameSuffix:
                    return(host.DomainName.EndsWith(DomainName, StringComparison.OrdinalIgnoreCase) ? ContainsResult.Yes : ContainsResult.No);
                }
                break;

            case HostFormat.IPv4:
                switch (Format)
                {
                case HostFormat.IPv4:
                    return(IpAddress.Equals(host.IpAddress) ? ContainsResult.Yes : ContainsResult.No);

                case HostFormat.IPv4Cidr:
                    // ReSharper disable once PossibleInvalidOperationException
                    return(CidrMatches(IpAddress, host.IpAddress, MaskBits.Value, 32) ? ContainsResult.Yes : ContainsResult.No);
                }
                break;

            case HostFormat.IPv6:
                switch (Format)
                {
                case HostFormat.IPv6:
                    return(IpAddress.Equals(host.IpAddress) ? ContainsResult.Yes : ContainsResult.No);

                case HostFormat.IPv6Cidr:
                    // ReSharper disable once PossibleInvalidOperationException
                    return(CidrMatches(IpAddress, host.IpAddress, MaskBits.Value, 128) ? ContainsResult.Yes : ContainsResult.No);
                }
                break;
            }

            return(ContainsResult.Inapplicable);
        }
예제 #7
0
        private void SyncButton_Click()
        {
            if (IpAddress.Equals(string.Empty) || siteId.Equals(string.Empty) || deviceId.Equals(string.Empty))
            {
                Toast.MakeText(this, "Configure the device first", ToastLength.Short).Show();
                return;
            }
            RunOnUiThread(() =>
            {
                Toast.MakeText(this, "Please wait..", ToastLength.Short).Show();
                mainHolder.Alpha  = 0.5f;
                loader.Visibility = Android.Views.ViewStates.Visible;
                Window.SetFlags(Android.Views.WindowManagerFlags.NotTouchable, Android.Views.WindowManagerFlags.NotTouchable);
            });

            var thread = new Thread(new ThreadStart(delegate
            {
                var resposeString = WebService.PostDeviceAndSiteIDToWebService("GetVD", deviceId, siteId);
                try
                {
                    var VehicleList = JsonConvert.DeserializeObject <List <VehicleDetails> >(resposeString);
                    CreateDatabaseOrModifyDatabase(VehicleList);
                }
                catch (Exception ec)
                {
                    RunOnUiThread(() =>
                    {
                        Toast.MakeText(this, "Check connectivity", ToastLength.Short).Show();
                        loader.Visibility = Android.Views.ViewStates.Gone;
                        mainHolder.Alpha  = 1f;
                        Window.ClearFlags(Android.Views.WindowManagerFlags.NotTouchable);
                        AppPreferences.SaveBool(this, Utilities.IsDownloaded, false);
                    });
                    ExceptionLog.LogDetails(this, "GetVd Error in fuel Activity " + ec.Message);
                    return;
                }
            }));

            thread.Start();
        }
예제 #8
0
 protected bool Equals(Binding other)
 {
     return(IpAddress.Equals(other.IpAddress) && Port == other.Port);
 }