Esempio n. 1
0
 public LoginPageViewModel(INavigationService navigationService) :
     base(navigationService)
 {
     _navigationService = navigationService;
     remoteServices     = new RemoteServices();
     IsBusy             = true;
 }
Esempio n. 2
0
        /// <summary>
        /// 远程获取所有的服务
        /// </summary>
        /// <returns></returns>
        public async Task <RemoteServices> GetAllRemoteServices()
        {
            var result = new RemoteServices()
            {
                Success = true
            };

            var list = await this.Entity.Where(r => r.IsActive).ToListAsync();

            result.Domains = list.GroupBy(r => r.Domain, y => y).Select(r => new Domain()
            {
                Name     = r.Key,
                Services = AutoMapperUtil.MapperToList <Service, ServiceRemote>(r.ToList())
            }).ToList();
            return(result);
        }
        /// <summary>
        /// Se desconecta a un cliente que este asociado a nuestro servidor
        /// </summary>
        /// <param name="user">Usuario que se desea desconectar</param>
        public void Disconnect(string user)
        {
            if (!ServerData.ClientesConectados.ContainsKey(user))
            {
                throw new Exception("El usuario que desea eliminar no esta conectado a nuestro servidor.");
            }
            string uri = ServerData.ClientesConectados[user];

            RemoteServices client = (RemoteServices)Activator.GetObject(typeof(RemoteServices), uri);

            try
            {
                client.Disconnect(ServerUri);
                ServerData.ClientesConectados.Remove(user);
            }
            catch (Exception)
            {
                throw new Exception("El cliente que se desea desconectar no esta en línea actualmente. Pruebe más tarde.");
            }
        }
Esempio n. 4
0
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            if (!String.IsNullOrWhiteSpace(this.txtUsername.Text))
            {
                string CurrentMachineName = Environment.MachineName;

                RemoteServices clipRemoteServices = new RemoteServices();

                if (clipRemoteServices.authenticateDevice(txtUsername.Text, txtPassw.Text, CurrentMachineName) == true)
                {
                    //good to go.
                }
                //App.clipRemoteProxy.Invoke("authenticateDevice", txtUsername.Text, txtPassw.Text, CurrentMachineName);

                // Print the message when it comes in
                //App.clipRemoteProxy.On<string>("authenticated", (x) =>
                //{
                //    UpdateAuthKey(x);
                //});
            }
        }
        /// <summary>
        /// Conexión a un servidor específico
        /// </summary>
        /// <param name="ip">IP del servidor al que me quiero conectar</param>
        /// <param name="port">Puerto en el cual se encuentra levantado el servidor al que se va a realizar la conexión</param>
        /// <param name="output">Consola de texto para mostrar la salida</param>
        public void NewSender(string ip, string port, RichTextBox output)
        {
            string uri = "tcp://" + ip + ":" + port + "/Chat";

            if (uri == ServerUri)
            {
                throw new Exception("No se puede conectar a su propio servidor.");
            }

            //Se inicia el acceso remoto
            RemoteServices sender = (RemoteServices)Activator.GetObject(typeof(RemoteServices), uri);

            if (Senders.ContainsKey(uri))
            {
                throw new Exception("La conexión a: " + uri + " ya se encuentra activa.");
            }

            bool conexionExitosa = false;

            try
            {
                conexionExitosa = sender.Connect(ServerData.User, ServerUri);
            }
            catch (Exception)
            {
                throw new Exception("El servidor " + uri + " no se encuentra activo");
            }

            //Se verifica si se logro realizar la conexión con el servidor en cuestión
            if (!conexionExitosa)
            {
                throw new Exception("No se puede realizar la conexión a: " + uri + ", el usuario " + ServerData.User + " ya se encuentra en ese servidor");
            }

            Senders.Add(uri, sender);
            output.AppendText(Utilidades.MensajeExito("Conexión exitosa a: " + uri));
        }
        // GET: RemoteServices
        public ActionResult Index(string ServerName, string ServiceName, string Start, string Stop, string Restart)
        {
            List <string> Services = new List <string>();

            //SET Service
            if (Start != null | Stop != null | Restart != null)
            {
                ViewBag.Message = null;

                using (WindowsIdentity.GetCurrent().Impersonate())
                {
                    ServiceController ServiceControl = new ServiceController(ServiceName, ServerName);

                    if (!string.IsNullOrEmpty(Start) & ServiceControl.Status != ServiceControllerStatus.Running)
                    {
                        ServiceControl.Start();
                        ServiceControl.WaitForStatus(ServiceControllerStatus.Running);
                        ViewBag.Message = ServiceStatuses.Service_Is_Now_Running.ToString().Replace("_", " ");
                    }
                    else
                    {
                        ViewBag.Message = ServiceStatuses.Service_Has_Already_Started.ToString().Replace("_", " ");
                    }

                    if (!string.IsNullOrEmpty(Stop) & ServiceControl.Status != ServiceControllerStatus.Stopped)
                    {
                        ServiceControl.Stop();
                        ServiceControl.WaitForStatus(ServiceControllerStatus.Stopped);
                        ViewBag.Message = ServiceStatuses.Service_Has_Been_Stopped.ToString().Replace("_", " ");
                    }
                    else if (!string.IsNullOrEmpty(Stop))
                    {
                        ViewBag.Message = ServiceStatuses.Service_Is_Already_Stopped.ToString().Replace("_", " ");
                    }

                    if (!string.IsNullOrEmpty(Restart))
                    {
                        try
                        {
                            ServiceControl.Stop();
                            ServiceControl.WaitForStatus(ServiceControllerStatus.Stopped);
                            ServiceControl.Start();
                        }
                        catch
                        {
                            ServiceControl.Start();
                        }
                        finally
                        {
                            ServiceControl.WaitForStatus(ServiceControllerStatus.Running);
                            ViewBag.Message = ServiceStatuses.Service_Has_Been_Restarted.ToString().Replace("_", " ");
                        }
                    }
                }
            }

            ViewBag.SelectedServerName = ServerName;
            ViewBag.ServiceDetails     = null;

            if (!string.IsNullOrEmpty(ServerName))
            {
                ServiceController[] services = ServiceController.GetServices(ServerName);
                foreach (ServiceController service in services)
                {
                    Services.Add(service.DisplayName);
                }
                Services.Sort();
            }

            if (!string.IsNullOrEmpty(ServiceName))
            {
                ServiceController sc             = new ServiceController(ServiceName, ServerName);
                RemoteServices    ServiceDetails = new RemoteServices();

                ServiceDetails.DisplayName = sc.DisplayName;
                ServiceDetails.ServiceName = sc.ServiceName;
                ServiceDetails.ServiceType = sc.ServiceType.ToString();
                ServiceDetails.StartupType = sc.StartType.ToString();
                ServiceDetails.Status      = sc.Status.ToString();

                ViewBag.ServiceDetails = ServiceDetails;
            }
            ViewBag.ServerList = new SelectList(sdb.Servers.OrderBy(x => x.ServerName), "ServerName", "ServerName");
            ViewBag.Services   = Services;

            return(View());
        }
Esempio n. 7
0
 public SignupPageViewModel(INavigationService navigationService) :
     base(navigationService)
 {
     remoteServices = new RemoteServices();
     IsBusy         = true;
 }