Ejemplo n.º 1
0
        /// <summary>
        /// returns the directory which is used by the OpenVPN server.
        /// </summary>
        /// <returns>the directory or an empty string on errors</returns>
        public static string LocateOpenVPNServiceDir()
        {
            string dir;
            string ret;

            RegistryKey k = Registry.LocalMachine.OpenSubKey(
                @"SOFTWARE\OpenVPN", false);

            if (k == null)
            {
                k = Registry.LocalMachine.OpenSubKey(
                    @"SOFTWARE\Wow6432Node\OpenVPN", false);
            }
            ret = (string)k.GetValue("config_dir", "");
            k.Close();

            if (!ComputerAdapter.ContainsFileExt(new DirectoryInfo(ret), ".ovpn"))
            {
                foreach (string user in ComputerAdapter.GetComputerUsers())
                {
                    dir = @"C:\Users\" + user + @"\OpenVPN\config\";
                    if (Directory.Exists(dir))
                    {
                        DirectoryInfo confDir = new DirectoryInfo(dir);
                        if (ComputerAdapter.ContainsFileExt(confDir, ".ovpn"))
                        {
                            ret = dir;
                            break;
                        }
                    }
                }
            }
            return(ret);
        }
Ejemplo n.º 2
0
        private void ScannerOnVlcHostFound(object sender, string s)
        {
            if (ComputerAdapter.Computers.Any(i => i.Ip == s))
            {
                return;
            }

            IpAddresses.Add(new ComputerModel(s));
            RunOnUiThread(() => ComputerAdapter.NotifyDataSetChanged());
        }
Ejemplo n.º 3
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.scan);
            var x = new LinearLayoutManager(this);

            IpAddresses.AddRange(Globals.ComputerModels);
            ComputerList    = FindViewById <RecyclerView>(Resource.Id.computerList);
            ComputerAdapter = new ComputerAdapter(IpAddresses);
            ComputerList.SetAdapter(ComputerAdapter);
            ComputerList.SetLayoutManager(x);
            ComputerAdapter.ConnectClick += ComputerAdapterOnConnectClick;
            ComputerAdapter.RemoveClick  += ComputerAdapterOnRemoveClick;
            ComputerAdapter.PinClick     += ComputerAdapterOnPinClick;

            AddComputerButton        = FindViewById <FloatingActionButton>(Resource.Id.addComputerButton);
            AddComputerButton.Click += AddComputerButtonOnClick;

            Scanner.VlcHostFound += ScannerOnVlcHostFound;
            Scanner.Start();
        }
Ejemplo n.º 4
0
 public UpgradeRecommend(Computer computer, IRecommendationStrategy <IDiskDevice> diskStrategy = null, IRecommendationStrategy <IMemoryDevice> memoryStrategy = null)
 {
     _computer       = new ComputerAdapter(computer);
     _diskStrategy   = diskStrategy ?? new SimpleDiskStrategy();
     _memoryStrategy = memoryStrategy ?? new SimpleMemoryStrategy();
 }
Ejemplo n.º 5
0
 private void ComputerAdapterOnRemoveClick(object sender, int i1)
 {
     IpAddresses.Remove(IpAddresses[i1]);
     ComputerAdapter.NotifyDataSetChanged();
 }
        public void AddInfra(string type, string name = null, string url = null)
        {
            if (string.IsNullOrEmpty(type))
            {
                return;
            }
            InfraAdapter ia = null;

            switch (type.ToLower())
            {
            case "server":
                ia = new ComputerAdapter(this);
                break;

            case "sonarqube":
                ia = new SonarAdapter(this);
                break;

            case "sql":
                ia = new SqlAdapter(this);
                break;

            //case "vpn":
            //    ia = _openvpnAdapter;
            //    break;
            //case "docker":
            //    ia = _dockerAdapter;
            //    break;
            case "team city":
                ia = new TeamCityAdapter(this);
                break;

            case "bitbucket":
                ia = new BitbucketAdapter(this);
                break;

            case "postgresql":
                ia = new PostGreAdapter(this);
                break;

            case "syncany":
                ia = new SyncanyAdapter(this);
                break;

            default:
                break;
            }

            if (ia != null)
            {
                try
                {
                    ia.Name = name != null ? name : ia.GetType().ToString().Split('.')[ia.GetType().ToString().Split('.').Length - 1].Replace("Adapter", string.Empty);
                    ia.Url  = url;
                    InfraFarm.Add(ia);
                    //GoAction("Infra_Save");
                }
                catch (Exception e)
                {
                }
            }
        }
Ejemplo n.º 7
0
        private void BuildMonitorHtml()
        {
            string _htmlMonitor = @"<!doctype html>
                <html>
                    <head>
		                <link rel='stylesheet' href='css/app.css'>
                        <script src='js/jsplumb.js'></script>
                        <script src='js/app.js'></script>
                    </head>
                    <body>
		                {0}
                    </body>
                </html>";

            Point[] positions = new Point[]
            {
                new Point(20, 40),
                new Point(50, 30),
                new Point(30, 20),
                new Point(55, 50),
                new Point(50, 70),
                new Point(30, 80),
                new Point(5, 75),
                new Point(4, 65),
                new Point(4, 50),
                new Point(5, 26),
                new Point(5, 38),
                new Point(5, 25),
                new Point(4, 37),
                new Point(5, 30),
                new Point(5, 30),
                new Point(5, 30),
                new Point(5, 30),
                new Point(5, 30),
                new Point(5, 30)
            };

            int    id             = 0;
            string _htmlComponent = string.Empty;
            string component;

            foreach (InfraAdapter item in _intInfra.InfraFarm.Adapters.OrderBy(a => a.Domain))
            {
                component       = item.MonitoringPanel.Replace("id123", "targetWindow" + id);
                component       = component.Replace("styleposition", string.Format("position: absolute; top:{0}%; left:{1}%;", positions[id].X, positions[id].Y));
                _htmlComponent += component;
                id++;
            }

            if (!ComputerAdapter.IsFileLocked(Path.Combine(_intInfra.WorkingDirectory, "Web", "app.html")))
            {
                if (File.Exists(Path.Combine(_intInfra.WorkingDirectory, "Web", "app.html")))
                {
                    File.WriteAllText(Path.Combine(_intInfra.WorkingDirectory, "Web", "app_new.html"), string.Format(_htmlMonitor, _htmlComponent));
                    File.Replace(Path.Combine(_intInfra.WorkingDirectory, "Web", "app_new.html"), Path.Combine(_intInfra.WorkingDirectory, "Web", "app.html"), Path.Combine(_intInfra.WorkingDirectory, "Web", "app.backup"));
                }
                else
                {
                    File.WriteAllText(Path.Combine(_intInfra.WorkingDirectory, "Web", "app.html"), string.Format(_htmlMonitor, _htmlComponent));
                }
            }
        }