Ejemplo n.º 1
0
        private ServerAggregatingCruiseManagerWrapper InitialiseServerWrapper(MockRepository mocks,
                                                                              Action <CruiseServerClientBase> additionalSetup)
        {
            IRemoteServicesConfiguration configuration        = mocks.DynamicMock <IRemoteServicesConfiguration>();
            ICruiseServerClientFactory   cruiseManagerFactory = mocks.DynamicMock <ICruiseServerClientFactory>();
            CruiseServerClientBase       cruiseManager        = mocks.DynamicMock <CruiseServerClientBase>();

            ServerLocation[] servers = new ServerLocation[] { serverLocation, otherServerLocation };
            SetupResult.For(configuration.Servers)
            .Return(servers);
            SetupResult.For(cruiseManagerFactory.GenerateClient("http://myurl", new ClientStartUpSettings()))
            .IgnoreArguments()
            .Return(cruiseManager);

            ServerAggregatingCruiseManagerWrapper serverWrapper = new ServerAggregatingCruiseManagerWrapper(
                configuration,
                cruiseManagerFactory);

            if (additionalSetup != null)
            {
                additionalSetup(cruiseManager);
            }

            return(serverWrapper);
        }
        public void ReturnedXmlValidatesAgainstSchema()
        {
            ProjectStatus  projectStatus   = CreateProjectStatus();
            ServerLocation ServerSpecifier = new ServerLocation();

            ServerSpecifier.ServerName = "localhost";


            ProjectStatusOnServer projectStatusOnServer = new ProjectStatusOnServer(projectStatus, ServerSpecifier);

            mockFarmService.ExpectAndReturn("GetProjectStatusListAndCaptureExceptions",
                                            new ProjectStatusListAndExceptions(
                                                new ProjectStatusOnServer[] { projectStatusOnServer }, new CruiseServerException[0]),
                                            (string)null);

            XmlFragmentResponse response = (XmlFragmentResponse)reportAction.Execute(null);
            string xml = response.ResponseFragment;

            XmlReaderSettings xmlReaderSettings = new XmlReaderSettings();

            xmlReaderSettings.Schemas.Add(ReadSchemaFromResources("XmlReportActionSchema.xsd"));
            XmlReader rdr = XmlReader.Create(new StringReader(xml), xmlReaderSettings);

            while (rdr.Read())
            {
            }

            mockFarmService.Verify();
        }
        public void WhenOneProjectStatusIsReturnedThisIsContainedInTheReturnedXml()
        {
            ProjectStatus  projectStatus   = CreateProjectStatus();
            ServerLocation ServerSpecifier = new ServerLocation();

            ServerSpecifier.ServerName = "localhost";

            ProjectStatusOnServer projectStatusOnServer = new ProjectStatusOnServer(projectStatus, ServerSpecifier);

            mockFarmService.ExpectAndReturn("GetProjectStatusListAndCaptureExceptions",
                                            new ProjectStatusListAndExceptions(
                                                new ProjectStatusOnServer[] { projectStatusOnServer }, new CruiseServerException[0]),
                                            (string)null);

            XmlFragmentResponse response = (XmlFragmentResponse)reportAction.Execute(null);
            string      xml = response.ResponseFragment;
            XmlDocument doc = XPathAssert.LoadAsDocument(xml);

            XPathAssert.Matches(doc, "/Projects/Project/@name", "HelloWorld");
            XPathAssert.Matches(doc, "/Projects/Project/@activity", "Sleeping");
            XPathAssert.Matches(doc, "/Projects/Project/@lastBuildStatus", "Success");
            XPathAssert.Matches(doc, "/Projects/Project/@lastBuildLabel", "build_7");
            XPathAssert.Matches(doc, "/Projects/Project/@lastBuildTime", LastBuildTime);
            XPathAssert.Matches(doc, "/Projects/Project/@nextBuildTime", NextBuildTime);
            XPathAssert.Matches(doc, "/Projects/Project/@webUrl", "http://blah");
            XPathAssert.Matches(doc, "/Projects/Project/@category", "category");

            mockFarmService.Verify();
        }
Ejemplo n.º 4
0
        public void Accept()
        {
            ServerAE       = ServerAE.Trim();
            ServerName     = ServerName.Trim();
            ServerLocation = ServerLocation.Trim();
            ServerHost     = ServerHost.Trim();

            if (base.HasValidationErrors)
            {
                this.ShowValidation(true);
            }
            else
            {
                var current          = _serverTree.CurrentNode;
                var allButCurrent    = _serverTree.RootServerGroup.GetAllServers().Where(s => s != current).Cast <IServerTreeDicomServer>();
                var sameAETitleCount = allButCurrent.Count(s => s.AETitle == _serverAE);
                if (sameAETitleCount > 0)
                {
                    var message = sameAETitleCount == 1
                                      ? SR.ConfirmAETitleConflict_OneServer
                                      : String.Format(SR.ConfirmAETitleConflict_MultipleServers, sameAETitleCount);

                    if (DialogBoxAction.No == Host.DesktopWindow.ShowMessageBox(message, MessageBoxActions.YesNo))
                    {
                        return;
                    }
                }

                var newServer = new ServerTreeDicomServer(
                    _serverName,
                    _serverLocation,
                    _serverHost,
                    _serverAE,
                    _serverPort,
                    _isStreaming,
                    _headerServicePort,
                    _wadoServicePort);

                // edit current server
                if (_serverTree.CurrentNode.IsServer)
                {
                    _serverTree.ReplaceDicomServerInCurrentGroup(newServer);
                }
                // add new server
                else if (_serverTree.CurrentNode.IsServerGroup)
                {
                    ((IServerTreeGroup)_serverTree.CurrentNode).AddChild(newServer);
                    _serverTree.CurrentNode = newServer;
                }

                _serverTree.Save();

                SetServerNodeMetaProperties(_serverName, _isPriorsServer);

                _serverTree.FireServerTreeUpdatedEvent();

                this.ExitCode = ApplicationComponentExitCode.Accepted;
                Host.Exit();
            }
        }
        public void Setup()
        {
            ProjectStatusOnServer server = new ProjectStatusOnServer(new ProjectStatus("myProject", IntegrationStatus.Success, DateTime.Now),
                                                                     new DefaultServerSpecifier("myServer"));
            ProjectStatusListAndExceptions statusList = new ProjectStatusListAndExceptions(
                new ProjectStatusOnServer[] {
                server
            }, new CruiseServerException[] {
            });

            farmServiceMock = new DynamicMock(typeof(IFarmService));
            farmServiceMock.SetupResult("GetProjectStatusListAndCaptureExceptions", statusList, typeof(IServerSpecifier), typeof(string));
            viewGeneratorMock = new DynamicMock(typeof(IVelocityViewGenerator));
            linkFactoryMock   = new DynamicMock(typeof(ILinkFactory));
            ServerLocation serverConfig = new ServerLocation();

            serverConfig.ServerName = "myServer";
            configuration.Servers   = new ServerLocation[] {
                serverConfig
            };
            var urlBuilderMock = new DynamicMock(typeof(ICruiseUrlBuilder));

            urlBuilderMock.SetupResult("BuildProjectUrl", string.Empty, typeof(string), typeof(IProjectSpecifier));

            plugin = new ProjectReportProjectPlugin((IFarmService)farmServiceMock.MockInstance,
                                                    (IVelocityViewGenerator)viewGeneratorMock.MockInstance,
                                                    (ILinkFactory)linkFactoryMock.MockInstance,
                                                    configuration,
                                                    (ICruiseUrlBuilder)urlBuilderMock.MockInstance);

            cruiseRequestMock = new DynamicMock(typeof(ICruiseRequest));
            cruiseRequest     = (ICruiseRequest )cruiseRequestMock.MockInstance;
        }
        public void Setup()
        {
            ProjectStatusOnServer server = new ProjectStatusOnServer(new ProjectStatus("myProject", IntegrationStatus.Success, DateTime.Now),
                                                                     new DefaultServerSpecifier("myServer"));
            ProjectStatusListAndExceptions statusList = new ProjectStatusListAndExceptions(
                new ProjectStatusOnServer[] {
                server
            }, new CruiseServerException[] {
            });

            farmServiceMock = new Mock <IFarmService>();
            farmServiceMock.Setup(service => service.GetProjectStatusListAndCaptureExceptions(It.IsAny <IServerSpecifier>(), It.IsAny <string>())).Returns(statusList);
            viewGeneratorMock = new Mock <IVelocityViewGenerator>();
            linkFactoryMock   = new Mock <ILinkFactory>();
            ServerLocation serverConfig = new ServerLocation();

            serverConfig.ServerName = "myServer";
            configuration.Servers   = new ServerLocation[] {
                serverConfig
            };
            var urlBuilderMock = new Mock <ICruiseUrlBuilder>();

            urlBuilderMock.Setup(builder => builder.BuildProjectUrl(It.IsAny <string>(), It.IsAny <IProjectSpecifier>())).Returns(string.Empty);

            plugin = new ProjectReportProjectPlugin((IFarmService)farmServiceMock.Object,
                                                    (IVelocityViewGenerator)viewGeneratorMock.Object,
                                                    (ILinkFactory)linkFactoryMock.Object,
                                                    configuration,
                                                    (ICruiseUrlBuilder)urlBuilderMock.Object);

            cruiseRequestMock = new Mock <ICruiseRequest>();
            cruiseRequest     = (ICruiseRequest )cruiseRequestMock.Object;
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Generates a server endpoint address.
        /// </summary>
        /// <param name="processID">Process identifier for the server on the host machine.</param>
        /// <param name="serverLoc">Location type of the server.</param>
        /// <param name="hostName">Name of the machine the server is located on.</param>
        /// <param name="portNumber">Port on which the server is listening.</param>
        /// <returns>String representing the endpoint address.</returns>
        public static string GetServerAddress(string processID, ServerLocation serverLoc = ServerLocation.LOCAL, string hostName = "localhost",int portNumber=-1)
        {
            var transport = serverLoc == ServerLocation.LOCAL ? "net.pipe" : "net.tcp";
            var serverHostName = hostName;
            if (serverLoc == ServerLocation.REMOTE)
                serverHostName = $"{hostName}:{portNumber}";

            return $"{transport}://{serverHostName}/Design_Time_Addresses/Codex/{processID}/IPCService";
        }
Ejemplo n.º 8
0
        public ConnectionTarget(ServerLocation server, DestinationPort port, List <DestinationPort> portsToReconnect, IPAddress currentManualDns, string username, string password, ProxyOptions proxyOptions, string wireguardInternalClientIp, string wireguardPrivateKey)
            : this(server, port, portsToReconnect, currentManualDns)
        {
            // TODO: necessary to think how to divide implementation for OpenVPN and Wireguard

            OpenVpnUsername           = username;
            OpenVpnPassword           = password;
            OpenVpnProxyOptions       = proxyOptions;
            WireGuardInternalClientIp = wireguardInternalClientIp;
            WireGuardLocalPrivateKey  = wireguardPrivateKey;
        }
        public void ReturnsServerNames()
        {
            ServerLocation[] servers = new ServerLocation[] { serverLocation, otherServerLocation };

            configurationMock.SetupGet(_configuration => _configuration.Servers).Returns(servers).Verifiable();
            IServerSpecifier[] serverSpecifiers = managerWrapper.GetServerSpecifiers();
            Assert.AreEqual(2, serverSpecifiers.Length);
            Assert.AreEqual("myserver", serverSpecifiers[0].ServerName);
            Assert.AreEqual("myotherserver", serverSpecifiers[1].ServerName);

            VerifyAll();
        }
Ejemplo n.º 10
0
        public void ReturnsServerConfiguration()
        {
            ServerLocation[] servers = new ServerLocation[] { serverLocation, otherServerLocation };

            configurationMock.ExpectAndReturn("Servers", servers);

            IServerSpecifier specifier = managerWrapper.GetServerConfiguration("myserver");

            Assert.AreEqual(true, specifier.AllowForceBuild);

            VerifyAll();
        }
        public void ReturnsServerConfiguration()
        {
            ServerLocation[] servers = new ServerLocation[] { serverLocation, otherServerLocation };

            configurationMock.SetupGet(_configuration => _configuration.Servers).Returns(servers).Verifiable();

            IServerSpecifier specifier = managerWrapper.GetServerConfiguration("myserver");

            Assert.AreEqual(true, specifier.AllowForceBuild);

            VerifyAll();
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Deletes a server.
        /// </summary>
        /// <param name="request"></param>
        /// <param name="velocityContext"></param>
        private void DeleteServer(IRequest request, Hashtable velocityContext)
        {
            // Retrieve the details
            string serverName = request.GetText("ServerName");

            // Validate the details
            if (string.IsNullOrEmpty(serverName))
            {
                velocityContext["Error"] = this.translations.Translate("Server name has not been set");
                return;
            }

            // Find the server
            XmlDocument configFile = LoadConfig();
            XmlElement  serverEl   = configFile.SelectSingleNode(
                string.Format(
                    "/dashboard/remoteServices/servers/server[@name='{0}']",
                    serverName)) as XmlElement;
            ServerLocation location = null;

            if (serverEl != null)
            {
                // Get and remove the existing server config
                foreach (ServerLocation locationToCheck in servicesConfiguration.Servers)
                {
                    if (locationToCheck.Name == serverName)
                    {
                        location = locationToCheck;
                        break;
                    }
                }
                if (location != null)
                {
                    List <ServerLocation> locations = new List <ServerLocation>(servicesConfiguration.Servers);
                    locations.Remove(location);
                    servicesConfiguration.Servers = locations.ToArray();
                }

                // Remove it from the config file
                serverEl.ParentNode.RemoveChild(serverEl);
                SaveConfig(configFile);

                velocityContext["Result"] = this.translations.Translate("Server has been deleted");
                CachingDashboardConfigurationLoader.ClearCache();
            }
            else
            {
                velocityContext["Error"] = this.translations.Translate("Unable to find server");
                return;
            }
        }
Ejemplo n.º 13
0
        public void ServerLocationSelected(ServerLocation serverLocation)
        {
            if (__MainWindowController.ServerListViewModel.ServerSelectionType == ServerSelectionType.ExitServer)
            {
                __MainWindowController.MainViewModel.SelectedExitServer = serverLocation;
            }
            else
            {
                __MainWindowController.MainViewModel.SelectedServer = serverLocation;
            }

            NavigateToMainPage(NavigationAnimation.FadeToRight);
            CurrentPage = NavigationTarget.MainPage;
        }
Ejemplo n.º 14
0
        private ConnectionTarget(ServerLocation server, DestinationPort port, List <DestinationPort> portsToReconnect, IPAddress currentManualDns)
        {
            Server           = server;
            Port             = port;
            CurrentManualDns = currentManualDns;

            if (portsToReconnect != null && portsToReconnect.Count > 0)
            {
                if (!portsToReconnect.Contains(port))
                {
                    throw new ArgumentOutOfRangeException(nameof(portsToReconnect), "Preffered ports list does not caontain Port which is defined as first");
                }

                PortsToReconnect.AddRange(portsToReconnect);
            }
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Loads servers from either the local machine or remotely
        /// </summary>
        /// <param name="loc">ServerLocation enum, indicates to load local or remote</param>
        void LoadServers(ServerLocation loc)
        {
            Cursor crs = Cursor.Current;

            Cursor.Current        = Cursors.WaitCursor;
            cboServers.DataSource = null;
            if (loc == ServerLocation.Local)
            {
                GetLocalServers(ref servers);
            }
            else
            {
                GetNetWorkedServers(ref servers);
            }

            cboServers.DataSource = servers;
            Cursor.Current        = crs;
        }
Ejemplo n.º 16
0
        public void SetSelectedServer(ServerLocation server, ServerSelectionType serverSelectionType)
        {
            foreach (var s in Service.Servers.ServersList)
            {
                s.IsSelected = false;
            }

            if (server != null)
            {
                var serverToSelect = Service.Servers.ServersList.FirstOrDefault(s => s.VpnServer.GatewayId == server.VpnServer.GatewayId);
                if (serverToSelect != null)
                {
                    serverToSelect.IsSelected = true;
                }
            }

            ServerSelectionType       = serverSelectionType;
            IsAutomaticServerSelected = false;
        }
Ejemplo n.º 17
0
        public Action Disconnect()
        {
            return(new Action(() => {
                if (Xfer != null)
                {
                    Xfer.Destroy();
                    Xfer.Dispose();
                }

                if (AcqDevice != null)
                {
                    AcqDevice.Destroy();
                    AcqDevice.Dispose();
                }

                if (Acquisition != null)
                {
                    Acquisition.Destroy();
                    Acquisition.Dispose();
                }

                if (Buffers != null)
                {
                    Buffers.Destroy();
                    Buffers.Dispose();
                }

                if (View != null)
                {
                    View.Destroy();
                    View.Dispose();
                }
                if (ServerLocation != null)
                {
                    ServerLocation.Dispose();
                }
            }));
        }
        private void AddNewLocation(ViewStacker stacker, ServerLocation location)
        {
            var btn = new ServerSelectionButton(location);

            // Implementation of 'Config' button (will be in use after implementation configuration for each server)
            //btn.IsConfigMode = IsConfigMode;

            if (location.CountryCode == __ViewModel.DisallowedCountryCode)
            {
                btn.DisabledForSelection = true;
            }

            btn.Activated += (object sender, EventArgs e) =>
            {
                __ViewModel.SelectServerCommand.Execute(((ServerSelectionButton)sender).ServerLocation);
            };
            btn.OnConfigButtonPressed += (object sender, EventArgs e) =>
            {
            };

            __ServerButtons.Add(btn);
            stacker.Add(btn);
        }
Ejemplo n.º 19
0
        public void Disconnect( )
        {
            try
            {
                if (Xfer != null)
                {
                    Xfer.Destroy();
                    Xfer.Dispose();
                }

                if (AcqDevice != null)
                {
                    AcqDevice.Destroy();
                    AcqDevice.Dispose();
                }

                if (Acquisition != null)
                {
                    Acquisition.Destroy();
                    Acquisition.Dispose();
                }

                if (Buffers != null)
                {
                    Buffers.Destroy();
                    Buffers.Dispose();
                }
                if (ServerLocation != null)
                {
                    ServerLocation.Dispose();
                }
            }
            catch (Exception)
            {
            }
        }
        private ServerAggregatingCruiseManagerWrapper InitialiseServerWrapper(MockRepository mocks,
                                                                              Action <CruiseServerClientBase> additionalSetup)
        {
            IRemoteServicesConfiguration configuration        = mocks.Create <IRemoteServicesConfiguration>().Object;
            ICruiseServerClientFactory   cruiseManagerFactory = mocks.Create <ICruiseServerClientFactory>().Object;
            CruiseServerClientBase       cruiseManager        = mocks.Create <CruiseServerClientBase>().Object;

            ServerLocation[] servers = new ServerLocation[] { serverLocation, otherServerLocation };
            Mock.Get(configuration).SetupGet(_configuration => _configuration.Servers)
            .Returns(servers);
            Mock.Get(cruiseManagerFactory).Setup(_cruiseManagerFactory => _cruiseManagerFactory.GenerateClient(It.IsAny <string>(), It.IsAny <ClientStartUpSettings>()))
            .Returns(cruiseManager);

            ServerAggregatingCruiseManagerWrapper serverWrapper = new ServerAggregatingCruiseManagerWrapper(
                configuration,
                cruiseManagerFactory);

            if (additionalSetup != null)
            {
                additionalSetup(cruiseManager);
            }

            return(serverWrapper);
        }
        public void Setup()
        {
            configurationMock              = new Mock <IRemoteServicesConfiguration>();
            cruiseManagerFactoryMock       = new Mock <ICruiseServerClientFactory>();
            cruiseManagerMock              = new Mock <ICruiseServerClient>();
            serverSpecifier                = new DefaultServerSpecifier("myserver");
            projectSpecifier               = new DefaultProjectSpecifier(serverSpecifier, "myproject");
            buildSpecifier                 = new DefaultBuildSpecifier(projectSpecifier, "mybuild");
            buildSpecifierForUnknownServer = new DefaultBuildSpecifier(new DefaultProjectSpecifier(new DefaultServerSpecifier("unknownServer"), "myProject"), "myBuild");

            managerWrapper = new ServerAggregatingCruiseManagerWrapper(
                (IRemoteServicesConfiguration)configurationMock.Object,
                (ICruiseServerClientFactory)cruiseManagerFactoryMock.Object
                );

            serverLocation                 = new ServerLocation();
            serverLocation.Name            = "myserver";
            serverLocation.Url             = "http://myurl";
            serverLocation.AllowForceBuild = true;

            otherServerLocation      = new ServerLocation();
            otherServerLocation.Name = "myotherserver";
            otherServerLocation.Url  = "http://myotherurl";
        }
Ejemplo n.º 22
0
        private static FiOSRole getRole(XElement serverElem, ServerLocation location)
        {
            switch (location)
            {
            case ServerLocation.VHE:
            {
                if (serverElem.Ancestors().Any(x => x.Name.LocalName.ToUpper().Equals("AES")))
                {
                    return(FiOSRole.AES);
                }
                if (serverElem.Ancestors().Any(x => x.Name.LocalName.ToUpper().Equals("ADMINCONSOLE")))
                {
                    return(FiOSRole.AdminConsole);
                }
                if (serverElem.Ancestors().Any(x => x.Name.LocalName.ToUpper().Equals("AUTOPROVISIONING")))
                {
                    return(FiOSRole.AutoProvisioning);
                }
                if (serverElem.Ancestors().Any(x => x.Name.LocalName.ToUpper().Equals("DOMAINCONTROLLERS")))
                {
                    return(FiOSRole.DomainController);
                }
                if (serverElem.Ancestors().Any(x => x.Name.LocalName.ToUpper().Equals("FIOSADVANCED")))
                {
                    if (serverElem.Parent.Name.LocalName.ToUpper().Equals("AIM"))
                    {
                        return(FiOSRole.FiOSAdvancedAIM);
                    }
                    else if (serverElem.Parent.Name.LocalName.ToUpper().Equals("BANNER"))
                    {
                        return(FiOSRole.FiOSAdvancedBanner);
                    }
                }
                if (serverElem.Ancestors().Any(x => x.Name.LocalName.ToUpper().Equals("FOTG")))
                {
                    return(FiOSRole.FiOSOnTheGo);
                }
                if (serverElem.Ancestors().Any(x => x.Name.LocalName.ToUpper().Equals("HYDRA")))
                {
                    return(FiOSRole.Hydra);
                }
                if (serverElem.Ancestors().Any(x => x.Name.LocalName.ToUpper().Equals("KMS-MDT")))
                {
                    return(FiOSRole.KMSorMDT);
                }
                if (serverElem.Ancestors().Any(x => x.Name.LocalName.ToUpper().Equals("MEDIAMGR")))
                {
                    return(FiOSRole.MediaManager);
                }
                if (serverElem.Ancestors().Any(x => x.Name.LocalName.ToUpper().Equals("MSV")))
                {
                    return(FiOSRole.MSV);
                }
                if (serverElem.Ancestors().Any(x => x.Name.LocalName.ToUpper().Equals("NSP")))
                {
                    return(FiOSRole.NSP);
                }
                if (serverElem.Ancestors().Any(x => x.Name.LocalName.ToUpper().Equals("PLAYREADY")))
                {
                    return(FiOSRole.Playready);
                }
                if (serverElem.Ancestors().Any(x => x.Name.LocalName.ToUpper().Equals("RATINGSRECOM")))
                {
                    return(FiOSRole.RatingsAndRecomm);
                }
                if (serverElem.Ancestors().Any(x => x.Name.LocalName.ToUpper().Equals("SCCM")))
                {
                    return(FiOSRole.SCCM);
                }
                if (serverElem.Ancestors().Any(x => x.Name.LocalName.ToUpper().Equals("SCOM")))
                {
                    return(FiOSRole.SCOM);
                }
                if (serverElem.Ancestors().Any(x => x.Name.LocalName.ToUpper().Equals("SEARCH")))
                {
                    return(FiOSRole.Search);
                }
                if (serverElem.Ancestors().Any(x => x.Name.LocalName.ToUpper().Equals("SFTP")))
                {
                    return(FiOSRole.SFTP);
                }
                if (serverElem.Ancestors().Any(x => x.Name.LocalName.ToUpper().Equals("VODENCRYPTION")))
                {
                    return(FiOSRole.VOD);
                }
                if (serverElem.Ancestors().Any(x => x.Name.LocalName.ToUpper().Equals("STBLOGGING")))
                {
                    return(FiOSRole.Logging);
                }
                break;
            }

            case ServerLocation.VHO:
            {
                if (serverElem.Ancestors().Any(x => x.Name.LocalName.ToUpper().Equals("DOMAINCONTROLLERS")))
                {
                    return(FiOSRole.DomainController);
                }
                if (serverElem.Ancestors().Any(x => x.Name.LocalName.ToUpper().Equals("GATEWAY")))
                {
                    return(FiOSRole.Gateway);
                }
                if (serverElem.Ancestors().Any(x => x.Name.LocalName.ToUpper().Equals("IMG")))
                {
                    return(FiOSRole.IMG);
                }
                if (serverElem.Ancestors().Any(x => x.Name.LocalName.ToUpper().Equals("MES")))
                {
                    return(FiOSRole.MES);
                }
                if (serverElem.Ancestors().Any(x => x.Name.LocalName.ToUpper().Equals("MGS")))
                {
                    return(FiOSRole.MGS);
                }
                if (serverElem.Ancestors().Any(x => x.Name.LocalName.ToUpper().Equals("THUMBNAIL")))
                {
                    return(FiOSRole.Thumbnail);
                }
                break;
            }
            }
            return(FiOSRole.Unknown);
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Loads servers from either the local machine or remotely
        /// </summary>
        /// <param name="loc">ServerLocation enum, indicates to load local or remote</param>
        void LoadServers(ServerLocation loc)
        {
            Cursor crs = Cursor.Current;
              Cursor.Current = Cursors.WaitCursor;
              cboServers.DataSource = null;
              if (loc == ServerLocation.Local)
            GetLocalServers(ref servers);
              else
            GetNetWorkedServers(ref servers);

              cboServers.DataSource = servers;
              Cursor.Current = crs;
        }
Ejemplo n.º 24
0
        /// <summary>
        /// Save the server details
        /// </summary>
        /// <param name="request"></param>
        /// <param name="velocityContext"></param>
        private void SaveServer(IRequest request, Hashtable velocityContext)
        {
            // Retrieve the details
            string newName             = request.GetText("newName");
            string oldName             = request.GetText("oldName");
            string serverUri           = request.GetText("serverUri");
            bool   serverForceBuild    = request.GetChecked("serverForceBuild");
            bool   serverStartStop     = request.GetChecked("serverStartStop");
            bool   backwardsCompatible = request.GetChecked("serverBackwardsCompatible");

            // Validate the details
            if (string.IsNullOrEmpty(newName))
            {
                velocityContext["Error"] = this.translations.Translate("Name is a compulsory value");
                return;
            }
            if (string.IsNullOrEmpty(serverUri))
            {
                velocityContext["Error"] = this.translations.Translate("URI is a compulsory value");
                return;
            }

            // Find the server
            XmlDocument configFile = LoadConfig();
            XmlElement  serverEl   = configFile.SelectSingleNode(
                string.Format(
                    "/dashboard/remoteServices/servers/server[@name='{0}']",
                    oldName)) as XmlElement;
            ServerLocation location = null;

            if (serverEl == null)
            {
                // If the element wasn't found, start a new one
                serverEl = configFile.CreateElement("server");
                configFile.SelectSingleNode("/dashboard/remoteServices/servers")
                .AppendChild(serverEl);

                // Add the new server
                location = new ServerLocation();
                ServerLocation[] locations = new ServerLocation[servicesConfiguration.Servers.Length + 1];
                servicesConfiguration.Servers.CopyTo(locations, 0);
                locations[servicesConfiguration.Servers.Length] = location;
                servicesConfiguration.Servers = locations;
            }
            else
            {
                // Get the existing server config
                foreach (ServerLocation locationToCheck in servicesConfiguration.Servers)
                {
                    if (locationToCheck.Name == oldName)
                    {
                        location = locationToCheck;
                        break;
                    }
                }
            }

            // Set all the properties
            serverEl.SetAttribute("name", newName);
            serverEl.SetAttribute("url", serverUri);
            serverEl.SetAttribute("allowForceBuild", serverForceBuild ? "true" : "false");
            serverEl.SetAttribute("allowStartStopBuild", serverStartStop ? "true" : "false");
            serverEl.SetAttribute("backwardsCompatible", backwardsCompatible ? "true" : "false");
            SaveConfig(configFile);
            if (location != null)
            {
                location.Name                = newName;
                location.Url                 = serverUri;
                location.AllowForceBuild     = serverForceBuild;
                location.AllowStartStopBuild = serverStartStop;
                location.BackwardCompatible  = backwardsCompatible;
            }

            velocityContext["Result"] = this.translations.Translate("Server has been saved");
            CachingDashboardConfigurationLoader.ClearCache();
        }
Ejemplo n.º 25
0
 public ServerPingResult(ServerLocation server, bool isServerReachable, int pingTimeMs = 0)
 {
     Server            = server;
     IsServerReachable = isServerReachable;
     PingTimeMs        = pingTimeMs;
 }
Ejemplo n.º 26
0
 public ConnectionTarget(ServerLocation server, string openVpnMultihopExitSrvId, DestinationPort port, List <DestinationPort> portsToReconnect, IPAddress currentManualDns, ProxyOptions proxyOptions)
     : this(server, openVpnMultihopExitSrvId, port, portsToReconnect, currentManualDns)
 {
     // TODO: necessary to think how to divide implementation for OpenVPN and Wireguard
     OpenVpnProxyOptions = proxyOptions;
 }
Ejemplo n.º 27
0
        public ServerSelectionButton(ServerLocation serverLocation) : base()
        {
            ServerLocation = serverLocation;

            const int constButtonHeight = 61;
            const int constFlagHeight   = 24;

            Bordered = false;
            Title    = "";
            Frame    = new CGRect(0, 0, 320, constButtonHeight);

            // flag icon
            var flagView = new NSImageView();

            flagView.Frame = new CGRect(20, (constButtonHeight - constFlagHeight) / 2, constFlagHeight, constFlagHeight);
            flagView.Image = GuiHelpers.CountryCodeToImage.GetCountryFlag(serverLocation.CountryCode);
            AddSubview(flagView);

            // server name
            __ServerName       = UIUtils.NewLabel(serverLocation.Name);
            __ServerName.Frame = new CGRect(49, flagView.Frame.Y + 1, 200, 18);
            __ServerName.Font  = UIUtils.GetSystemFontOfSize(14.0f, NSFontWeight.Semibold);
            __ServerName.SizeToFit();
            AddSubview(__ServerName);

            // check if server name is too long
            const int maxXforSelectedIcon    = 218;
            nfloat    serverNameOverlapWidth = (__ServerName.Frame.X + __ServerName.Frame.Width) - maxXforSelectedIcon;

            if (serverNameOverlapWidth > 0)
            {
                CGRect oldFrame = __ServerName.Frame;
                __ServerName.Frame = new CGRect(oldFrame.X, oldFrame.Y, oldFrame.Width - serverNameOverlapWidth, oldFrame.Height);
            }

            // selected server image
            __selectedServerImage        = new NSImageView();
            __selectedServerImage.Frame  = new CGRect(__ServerName.Frame.X + __ServerName.Frame.Width, flagView.Frame.Y - 2, 25, 25);
            __selectedServerImage.Image  = NSImage.ImageNamed("iconSelected");
            __selectedServerImage.Hidden = !ServerLocation.IsSelected;
            AddSubview(__selectedServerImage);

            // ping status image
            __pingStatusImage        = new NSImageView();
            __pingStatusImage.Frame  = new CGRect(238, flagView.Frame.Y, 24, 24);
            __pingStatusImage.Hidden = true;
            AddSubview(__pingStatusImage);
            UpdatePingStatusImage();

            // ping timeout info
            __PingView           = UIUtils.NewLabel(GetPingTimeString(ServerLocation.PingTime));
            __PingView.Alignment = NSTextAlignment.Left;
            __PingView.Font      = UIUtils.GetSystemFontOfSize(12.0f);
            __PingView.Frame     = new CGRect(260, flagView.Frame.Y + 4, 60, 18);
            __PingView.TextColor = NSColor.FromRgb(180, 193, 204);
            if (ServerLocation.PingTime == 0)
            {
                __PingView.Hidden = true;
            }
            __PingView.SizeToFit();
            AddSubview(__PingView);

            // "disabled layer" visible only if button is disabled
            __DisabledLayer       = new ColorView();
            __DisabledLayer.Frame = new CGRect(Frame.X, Frame.Y, Frame.Width, Frame.Height - 1);
            var bgClr = Colors.WindowBackground;

            __DisabledLayer.BackgroundColor = Colors.IsDarkMode ? new CGColor(bgClr.RedComponent, bgClr.GreenComponent, bgClr.BlueComponent, 0.6f) : new CGColor(1.0f, 0.6f);
            __DisabledLayer.Hidden          = true;
            AddSubview(__DisabledLayer);
        }
Ejemplo n.º 28
0
 MasterSession(ServerLocation masterServer)
 {
     //the parameter specifies which master server to connect
 }
Ejemplo n.º 29
0
 private static void SetServerLocation(ServerInstance instance, ServerLocation location)
 {
     instance.Url  = location.Url;
     instance.Port = location.Port;
 }
Ejemplo n.º 30
0
 /// <summary>
 /// Gets a duplex client
 /// </summary>
 /// <param name="processID">Process identifier for the server on the host machine.</param>
 /// <param name="serverLoc">Location type of the server.</param>
 /// <param name="hostName">Name of the machine the server is located on.</param>
 /// <param name="portNumber">Port on which the server is listening.</param>
 /// <returns>Client object.</returns>
 public static IPCDuplexClient GetDuplexClient(InstanceContext context, string processID, ServerLocation serverLoc = ServerLocation.LOCAL, string hostName = "localhost", int portNumber = -1)
 {
     var endpointName = serverLoc == ServerLocation.LOCAL ? "NamedPipeBinding_IIPCDuplex" : "TCPBinding_IIPCDuplex";
    return new IPCDuplexClient(context, endpointName, GetServerAddress(processID,serverLoc,hostName,portNumber));
 }
Ejemplo n.º 31
0
 private static bool IsServerLocationDefined(ServerLocation serverLocation)
 {
     return(serverLocation != ServerLocation.NoPreference && serverLocation != ServerLocation.Unknown);
 }