public static List <string> GetServersWithServerRoleInSite(string serverName, ServerRole serverRole)
        {
            IADToplogyConfigurationSession iadtoplogyConfigurationSession = ADSessionFactory.CreateIgnoreInvalidRootOrgSession(true);
            IADServer iadserver = null;

            if (!string.IsNullOrEmpty(serverName))
            {
                if (!SharedHelper.StringIEquals(serverName, "localhost"))
                {
                    goto IL_2F;
                }
            }
            try
            {
                iadserver = iadtoplogyConfigurationSession.FindServerByName(Environment.MachineName);
                goto IL_5A;
            }
            catch (LocalServerNotFoundException)
            {
                goto IL_5A;
            }
IL_2F:
            string nodeNameFromFqdn = MachineName.GetNodeNameFromFqdn(serverName);

            iadserver = iadtoplogyConfigurationSession.FindServerByName(nodeNameFromFqdn);
            string arg = "FindServerByName";

            if (iadserver == null)
            {
                ExTraceGlobals.ReplayConfigurationTracer.TraceDebug <string, string>(0L, "GetServersWithServerRoleInSite: {0} didn't find any server for {1}", arg, serverName);
            }
IL_5A:
            return(ReplayConfiguration.GetServersWithServerRoleInSiteByServer(iadserver, serverRole));
        }
        public TADWrapperObject FindServerByFqdnWithException(string fqdn, out Exception ex)
        {
            ex = null;
            string nodeNameFromFqdn = MachineName.GetNodeNameFromFqdn(fqdn);

            return(SimpleAdObjectLookup <TADWrapperObject> .FindAdObjectByServerNameStatic(this.AdSession, nodeNameFromFqdn, out ex));
        }
 public override int GetHashCode()
 {
     unchecked
     {
         return(((MachineName != null ? MachineName.GetHashCode() : 0) * 397) ^ Thread);
     }
 }
Exemple #4
0
        /// <summary>
        /// Log custom info message
        /// </summary>
        /// <param name="source">Where the message originated</param>
        /// <param name="message">The messsage to log</param>
        public static void LogCritial(string source, string message, bool ignoreRemote = false)
        {
            try
            {
                ThreadPool.QueueUserWorkItem(delegate
                {
                    var log = new Log
                    {
                        Event      = DateTime.Now,
                        LogTypeId  = LogTypeEnum.Critical,
                        Source     = source.Ellipse(200 - 5),
                        Message    = message.Ellipse(1500 - 5),
                        StackTrace = null,
                        Machine    = MachineName.Ellipse(210),
                        Version    = VersionHelper.GetVersionFull()
                    };

                    Task.Run(async() => await LogsRepo.Add(log));
                    if (SendLogToSource & !ignoreRemote)
                    {
                        log.Machine += $"@{ExternalIp}";
                        LogsRepo.RemoteAdd(log);
                    }
                });
            }
            catch { }
        }
 /// <summary>
 ///     Determines whether [is message originator].
 /// </summary>
 /// <returns></returns>
 public bool IsMessageOriginator( )
 {
     return
         (MachineName.Equals(Identity.MachineName, StringComparison.InvariantCultureIgnoreCase) &&
          ProcessId.Equals(Identity.ProcessId) &&
          AppDomainId.Equals(Identity.AppDomainId));
 }
Exemple #6
0
        /// <summary>
        /// Log error from exception with error severity
        /// </summary>
        /// <param name="e">Exception to log</param>
        public static void Log(Exception e, string additionalMessage, LogTypeEnum logType, bool ignoreRemote = false)
        {
            try
            {
                ThreadPool.QueueUserWorkItem(delegate
                {
                    var log = new Log
                    {
                        Event      = DateTime.Now,
                        LogTypeId  = logType,
                        Source     = GetExceptionSource(e).Ellipse(200 - 5),
                        Message    = (additionalMessage + ": " + GetExceptionMessage(e)).Ellipse(1500 - 5),
                        StackTrace = GetExceptionStackTrace(e).Ellipse(4000 - 5),
                        Machine    = MachineName.Ellipse(210),
                        Version    = VersionHelper.GetVersionFull()
                    };

                    Task.Run(async() => await LogsRepo.Add(log));
                    if (SendLogToSource && !ignoreRemote)
                    {
                        log.Machine += $"@{ExternalIp}";
                        LogsRepo.RemoteAdd(log);
                    }
                });
            }
            catch { }
        }
Exemple #7
0
        /// <summary>
        /// Uninstalls the target application on the target device.
        /// </summary>
        /// <param name="packageFamilyName"></param>
        /// <param name="targetDevice"></param>
        /// <param name="showDialog"></param>
        /// <returns>True, if uninstall was a success.</returns>
        public static bool UninstallApp(string packageFamilyName, ConnectInfo targetDevice, bool showDialog = true)
        {
            AppDetails appDetails = QueryAppDetails(packageFamilyName, targetDevice);

            if (appDetails == null)
            {
                Debug.Log(string.Format("Application '{0}' not found", packageFamilyName));
                return(false);
            }

            string query = string.Format("{0}?package={1}",
                                         string.Format(API_InstallQuery, FinalizeUrl(targetDevice.IP)),
                                         WWW.EscapeURL(appDetails.PackageFullName));

            bool        success       = WebRequestDelete(query, GetBasicAuthHeader(targetDevice), showDialog);
            MachineName targetMachine = GetMachineName(targetDevice);

            if (success)
            {
                Debug.LogFormat("Successfully uninstalled {0} on {1}.", packageFamilyName, targetMachine.ComputerName);
            }
            else
            {
                Debug.LogErrorFormat("Failed to uninstall {0} on {1}", packageFamilyName, targetMachine.ComputerName);
            }

            return(success);
        }
        private bool OnReceive(WhatsTheMachine message)
        {
            var name = new MachineName {
                Name = Environment.MachineName
            };

            Sender.Tell(name);
            return(true);
        }
 /// <summary>
 /// This object is passed to NodeInitializer if you want to create a node inside the virtual network. Communications in the virtual network do not take place via the internet, but through a pipeline, simulating the Internet protocol.
 /// </summary>
 public VirtualDevice()
 {
     Id          = _lastId + 1;
     _lastId     = Id;
     MachineName = Environment.MachineName;
     Domain      = Id + "." + MachineName.ToLower();
     Address     = "vd://" + Domain;
     Ip          = (uint)Domain.GetHashCode();
 }
Exemple #10
0
 public override int GetHashCode()
 {
     unchecked {
         int hashCode = UniqueID;
         hashCode = (hashCode * 397) ^ (Name != null ? Name.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (MachineName != null ? MachineName.GetHashCode() : 0);
         return(hashCode);
     }
 }
Exemple #11
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = AgentID;
         hashCode = (hashCode * 397) ^ (MachineID != null ? MachineID.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (DeviceGuid != null ? DeviceGuid.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ CustomerID;
         hashCode = (hashCode * 397) ^ (CustomerName != null ? CustomerName.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ FolderID.GetHashCode();
         hashCode = (hashCode * 397) ^ (AgentName != null ? AgentName.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (SystemName != null ? SystemName.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (MachineName != null ? MachineName.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (DomainName != null ? DomainName.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (CurrentLoggedUsers != null ? CurrentLoggedUsers.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (ComputerDescription != null ? ComputerDescription.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ Monitored.GetHashCode();
         hashCode = (hashCode * 397) ^ LastPatchManagementReceived.GetHashCode();
         hashCode = (hashCode * 397) ^ (AgentVersion != null ? AgentVersion.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ Favorite.GetHashCode();
         hashCode = (hashCode * 397) ^ ThresholdID.GetHashCode();
         hashCode = (hashCode * 397) ^ MonitoredAgentID.GetHashCode();
         hashCode = (hashCode * 397) ^ Created.GetHashCode();
         hashCode = (hashCode * 397) ^ Modified.GetHashCode();
         hashCode = (hashCode * 397) ^ Online.GetHashCode();
         hashCode = (hashCode * 397) ^ (ReportedFromIP != null ? ReportedFromIP.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (AppViewUrl != null ? AppViewUrl.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Motherboard != null ? Motherboard.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Processor != null ? Processor.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ Memory.GetHashCode();
         hashCode = (hashCode * 397) ^ (Display != null ? Display.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Sound != null ? Sound.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ ProcessorCoresCount.GetHashCode();
         hashCode = (hashCode * 397) ^ (SystemDrive != null ? SystemDrive.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (ProcessorClock != null ? ProcessorClock.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Vendor != null ? Vendor.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (VendorSerialNumber != null ? VendorSerialNumber.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (VendorBrandModel != null ? VendorBrandModel.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (ProductName != null ? ProductName.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (OS != null ? OS.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (OSType != null ? OSType.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (OSVersion != null ? OSVersion.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (OSBuild != null ? OSBuild.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (WindowsSerialNumber != null ? WindowsSerialNumber.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Office != null ? Office.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (OfficeSP != null ? OfficeSP.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ OfficeOEM.GetHashCode();
         hashCode = (hashCode * 397) ^ (OfficeSerialNumber != null ? OfficeSerialNumber.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (OfficeFullVersion != null ? OfficeFullVersion.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (LastLoginUser != null ? LastLoginUser.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (HardwareDisks?.Sum(x => x.GetHashCode()) ?? 0);
         hashCode = (hashCode * 397) ^ (MacAddresses?.Sum(x => x.GetHashCode()) ?? 0);
         hashCode = (hashCode * 397) ^ (IpAddresses?.Sum(x => x.GetHashCode()) ?? 0);
         return(hashCode);
     }
 }
    public override bool Equals(object obj)
    {
        var other = obj as PaintMachineLookup;

        if (other == null)
        {
            return(false);
        }
        return(MachineName.Equals(other.MachineName) && Pass.Equals(other.Pass));
    }
 public override int GetHashCode()
 {
     unchecked
     {
         int x = 27;
         x = x * 11 + MachineName.GetHashCode();
         x = x * 11 + Pass.GetHashCode();
         return(x);
     }
 }
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (TestRunDirectory != null ? TestRunDirectory.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (MachineName != null ? MachineName.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ RunningDateTime.GetHashCode();
         return(hashCode);
     }
 }
        public static void GetResolvedLocalhostName___Should_not_return_null_or_white_space___When_called()
        {
            // arrange

            // act
            var actual = MachineName.GetResolvedLocalhostName();

            // assert
            actual.Should().NotBeNullOrWhiteSpace();
        }
        public static void GetFullyQualifiedDomainName___Should_not_return_null_or_white_space___When_called()
        {
            // arrange

            // act
            var actual = MachineName.GetFullyQualifiedDomainName();

            // assert
            actual.Should().NotBeNullOrWhiteSpace();
        }
Exemple #17
0
 public object Clone()
 {
     return(new Node()
     {
         CustomData = CustomData.NotNull(s => (string)s.Clone()),
         Host = new IPAddress(Host.GetAddressBytes()),
         MachineName = MachineName.NotNull(s => (string)s.Clone()),
         Port = Port,
         TransportType = TransportType
     });
 }
Exemple #18
0
 public override int GetHashCode()
 {
     unchecked {
         int hashCode = base.GetHashCode();
         hashCode = (hashCode * 397) ^ (MacAddress?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (MachineName?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (IP?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (PCID?.GetHashCode() ?? 0);
         return(hashCode);
     }
 }
Exemple #19
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = AssetId.GetHashCode();
         hashCode = (hashCode * 397) ^ (MachineName != null ? MachineName.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ IsJohnDoe.GetHashCode();
         hashCode = (hashCode * 397) ^ AssetUid.GetHashCode();
         return(hashCode);
     }
 }
        public static void GetMachineNames___Should_not_return_a_machine_name_for_all_MachineNameKind_that_is_not_null_or_white_space___When_called()
        {
            // arrange
            var machineNameKinds = EnumExtensions.GetAllPossibleEnumValues <MachineNameKind>();

            // act
            var actual = MachineName.GetMachineNames();

            // assert
            actual.Keys.SymmetricDifference(machineNameKinds).Any().Should().BeFalse();
            actual.Values.Any(string.IsNullOrWhiteSpace).Should().BeFalse();
        }
        /// <summary>Builds rfc-3164 compatible message</summary>
        /// <param name="logEvent">The NLog.LogEventInfo</param>
        /// <param name="facility">Syslog Facility to transmit message from</param>
        /// <param name="severity">Syslog severity level</param>
        /// <param name="body">Message text</param>
        /// <returns>Byte array containing formatted syslog message</returns>
        private byte[] BuildSyslogMessage3164(LogEventInfo logEvent, SyslogFacility facility, SyslogSeverity severity, string body)
        {
            // Calculate PRI field
            var priority = CalculatePriorityValue(facility, severity).ToString(CultureInfo.InvariantCulture);
            var time     = logEvent.TimeStamp.ToLocalTime().ToString(TimestampFormat, _usCulture);
            // Get sender machine name
            var machine = MachineName.Render(logEvent);
            // Get sender
            var sender = Sender.Render(logEvent);

            return(Encoding.ASCII.GetBytes($"<{priority}>{time} {machine} {sender}: {body}{Environment.NewLine}"));
        }
Exemple #22
0
        // ReSharper disable once MemberCanBePrivate.Global
        public override int GetHashCode()
        {
            int hashCode = HashKey +
                           At.GetHashCode() +
                           MachineName.GetHashCode() +
                           ThreadName.GetHashCode() +
                           Type.GetHashCode() +
                           Level.Priority() +
                           Line.GetHashCode();

            return(hashCode);
        }
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = Duration.GetHashCode();
         hashCode = (hashCode * 397) ^ (ValidationExpression?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (Instance?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (Name?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (Category?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (MachineName?.GetHashCode() ?? 0);
         return(hashCode);
     }
 }
Exemple #24
0
        /// <summary>
        /// Gets the <see cref="MachineName"/> of the target device.
        /// </summary>
        /// <param name="targetDevice"></param>
        /// <returns><see cref="MachineName"/></returns>
        public static MachineName GetMachineName(ConnectInfo targetDevice)
        {
            MachineName machineName = null;
            string      query       = string.Format(API_GetMachineNameQuery, FinalizeUrl(targetDevice.IP));
            string      response    = WebRequestGet(query, GetBasicAuthHeader(targetDevice, true), false);

            if (!string.IsNullOrEmpty(response))
            {
                machineName = JsonUtility.FromJson <MachineName>(response);
            }

            return(machineName);
        }
Exemple #25
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (ServiceName != null ? ServiceName.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (MachineName != null ? MachineName.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (DisplayName != null ? DisplayName.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ Status.GetHashCode();
         hashCode = (hashCode * 397) ^ CanStart.GetHashCode();
         hashCode = (hashCode * 397) ^ CanPause.GetHashCode();
         hashCode = (hashCode * 397) ^ CanStop.GetHashCode();
         return(hashCode);
     }
 }
Exemple #26
0
 /// <summary>
 ///
 /// </summary>
 /// <returns></returns>
 public override int GetHashCode()
 {
     unchecked
     {
         int hash = 17;
         hash = hash * 31 + MachineName.GetHashCode();
         hash = hash * 31 + Url.GetHashCode();
         foreach (var ad in AudioDevices)
         {
             hash = hash * 31 + ad.GetHashCode();
         }
         return(hash);
     }
 }
		internal static NetworkPath InternalChooseDagNetworkPath(string targetName, string networkName, NetworkPath.ConnectionPurpose purpose)
		{
			string nodeNameFromFqdn = MachineName.GetNodeNameFromFqdn(targetName);
			NetworkManager manager = NetworkManager.GetManager();
			NetworkPath networkPath = null;
			DagNetConfig dagNetConfig = null;
			manager.TryWaitForInitialization();
			if (manager.m_netMap != null)
			{
				networkPath = manager.m_netMap.ChoosePath(nodeNameFromFqdn, networkName);
			}
			else
			{
				DagNetRoute dagNetRoute = null;
				DagNetRoute[] array = DagNetChooser.ProposeRoutes(targetName, out dagNetConfig);
				if (networkName != null)
				{
					foreach (DagNetRoute dagNetRoute2 in array)
					{
						if (StringUtil.IsEqualIgnoreCase(dagNetRoute2.NetworkName, networkName))
						{
							dagNetRoute = dagNetRoute2;
							break;
						}
					}
				}
				else if (array != null && array.Length > 0)
				{
					dagNetRoute = array[0];
				}
				if (dagNetRoute != null)
				{
					networkPath = new NetworkPath(targetName, dagNetRoute.TargetIPAddr, dagNetRoute.TargetPort, dagNetRoute.SourceIPAddr);
					networkPath.NetworkName = dagNetRoute.NetworkName;
					networkPath.CrossSubnet = dagNetRoute.IsCrossSubnet;
				}
			}
			if (networkPath == null)
			{
				networkPath = NetworkManager.BuildDnsNetworkPath(targetName, NetworkManager.GetReplicationPort());
			}
			networkPath.Purpose = purpose;
			if (dagNetConfig == null)
			{
				dagNetConfig = DagNetEnvironment.FetchNetConfig();
			}
			networkPath.ApplyNetworkPolicy(dagNetConfig);
			return networkPath;
		}
Exemple #28
0
        /// <summary>
        /// Gets a unique-enough hash of this error.  Stored as a quick comparison mehanism to rollup duplicate errors.
        /// </summary>
        /// <returns>"Unique" hash for this error</returns>
        private int?GetHash()
        {
            if (!Detail.HasValue())
            {
                return(null);
            }

            var result = Detail.GetHashCode();

            if (RollupPerServer && MachineName.HasValue())
            {
                result = (result * 397) ^ MachineName.GetHashCode();
            }

            return(result);
        }
Exemple #29
0
        public void TestCreateTableSourceInfoFromQualifiedName(DatabaseProviderTestCase tc)
        {
            var           databaseServices = tc.Services;
            IDatabaseInfo db = databaseServices.ObjectFactory.CreateDatabaseInfo(GetDatabaseIdentifier(databaseServices));
            IEnumerable <ITableSourceInfo> tableSources = databaseServices.IntrospectionService.ListTableSourcesWithoutFilter(db);

            foreach (var tableSource in tableSources)
            {
                if (tableSource.QualifiedName.ToLowerInvariant().EndsWith(MachineName.ToLowerInvariant()))
                {
                    ITableSourceInfo inferredTableSource = databaseServices.ObjectFactory.CreateTableSourceInfo(tableSource.QualifiedName);
                    bool             equals = tableSource.Equals(inferredTableSource);
                    Assert.IsTrue(equals, "The inferred ITableSourceInfo is not equal to the original ITableSourceInfo for table source with qualified name: " + tableSource.QualifiedName);
                }
            }
        }
        /// <summary>
        /// Gets a unique-enough hash of this error. Stored as a quick comparison mechanism to roll-up duplicate errors.
        /// </summary>
        /// <param name="includeMachine">Whether to include <see cref="MachineName"/> in the has calculation, creating per-machine roll-ups.</param>
        /// <returns>A "Unique" hash for this error.</returns>
        public int?GetHash(bool includeMachine)
        {
            if (!Detail.HasValue())
            {
                return(null);
            }

            var result = Detail.GetHashCode();

            if (includeMachine && MachineName.HasValue())
            {
                result = (result * 397) ^ MachineName.GetHashCode();
            }

            return(result);
        }