Example #1
0
 public frmMain(DesktopClient client, frmFirst ff)
 {
     InitializeComponent();
     this.client           = client;
     client.RcvImageEvent += Client_RcvImageEvent;
     this.ff = ff;
 }
Example #2
0
        // GET: /Action/Launch
        public ActionResult Launch(
            string name,
            string args,
            string title,
            string detach)
        {
            Security.ClearSavedProfile();

            if (String.IsNullOrEmpty(Running.RunningProgram))
            {
                DesktopClient.SendSpecialkey("ClearDesktop");
            }

            if (!string.IsNullOrEmpty(name))
            {
                if (!string.IsNullOrEmpty(args))
                {
                    args = HttpUtility.UrlDecode(args);
                }
                if (!string.IsNullOrEmpty(detach))
                {
                    Running.LaunchNewProgram(name, args);
                }
                else
                {
                    Running.LaunchProgram(name, args);
                }
            }

            return(Content("OK"));
        }
Example #3
0
        public async Task <string> GenerateToken(DesktopClient i, int userId, string type)
        {
            var tokenClaims = new List <Claim> {
            };

            tokenClaims.Add(new Claim("Desktopid", i.Id.ToString()));
            tokenClaims.Add(new Claim("Name", i.ClientName));
            tokenClaims.Add(new Claim("Type", i.ClientType));
            tokenClaims.Add(new Claim("macAddr", i.ClientMacAddress));
            tokenClaims.Add(new Claim("UserId", userId.ToString()));
            tokenClaims.Add(new Claim(ClaimTypes.Role, type));

            var keyByte = Encoding.UTF8.GetBytes(_config.GetSection("LoginSettings:Key").Value);

            var key         = new SymmetricSecurityKey(keyByte);
            var credentials = new SigningCredentials(key, SecurityAlgorithms.HmacSha512Signature);

            var tokenDescriptor = new SecurityTokenDescriptor
            {
                Subject            = new ClaimsIdentity(tokenClaims),
                SigningCredentials = credentials,
                Expires            = DateTime.Now.AddMonths(1),
            };
            var tokenHandler = new JwtSecurityTokenHandler();

            var token       = tokenHandler.CreateToken(tokenDescriptor);
            var tokenString = tokenHandler.WriteToken(token);


            return(tokenString);
        }
Example #4
0
 /// <summary>
 ///
 /// </summary>
 private static void StopSky()
 {
     if (runningProgram == "Sky")
     {
         DesktopClient.SendIR(IRCodes.Codes["Sky.PowerSTB"], "Sky.PowerSTB");
     }
 }
Example #5
0
    /// <summary>
    /// Load the profile anew from the XML file, selecting the appropriate "current" schedule to be used
    /// </summary>
    /// <param name="id"></param>
    /// <param name="isReload"></param>
    /// <returns></returns>
    static bool LoadProfile(
        int id,
        XElement profile,
        bool isReload = false)
    {
        CurrentProfileSchedules  = LoadSchedulesForToday(profile.Elements("Schedule"));
        CurrentSecurityProfileId = id;
        CurrentProfileIsDefault  = profile.Attribute("default") != null;
        DateLoaded = DateTime.Now.Date;

        if (!isReload)
        {
            InitSchedule();

            if (profile.Attribute("nonpersistent") == null)
            {
                DesktopClient.PersistStringInRegistry("SecurityProfile", id.ToString());
            }
        }

        Tick(DateTime.Now);

        logger.Info("Loaded profile {0}", profile.Attribute("name").Value);
        return(true);
    }
Example #6
0
 // GET: /Action/MouseMove
 public ActionResult MouseMove(
     string dx,
     string dy)
 {
     DesktopClient.MouseMoveRelative(Convert.ToInt32(dx), Convert.ToInt32((dy)));
     return(Content(""));
 }
Example #7
0
        private bool viewImageByDesktop(DesktopClient config, string patientId, string accNo)
        {
            config.param.PatientID       = patientId;
            config.param.AccessionNumber = accNo;

            var paramJson      = JsonConvert.SerializeObject(config.param);
            var plainTextBytes = System.Text.Encoding.UTF8.GetBytes(paramJson);
            var base64String   = System.Convert.ToBase64String(plainTextBytes);

            config.args.Add(base64String);

            config.args.ForEach(a => a = "\"" + a + "\"");
            var finalArgs = config.args.Select(a => "\"" + a + "\"");
            var args      = string.Join(" ", finalArgs);

            var path = Path.Combine(Directory.GetCurrentDirectory(), config.path);

            if (!File.Exists(path))
            {
                return(false);
            }

            var pro = Process.Start(path, args);

            pro.Dispose();

            return(true);
        }
        public async Task ConnectAlarm(Uri uri, int accountId)
        {
            accountUser = accountId;
            //Console.WriteLine(uri);
            //string p = uri.AbsoluteUri.Replace(uri.LocalPath, string.Empty);
            string test = uri.AbsoluteUri + "OperatorHub";

            Console.WriteLine(test);
            connection = new HubConnectionBuilder()
                         .WithUrl(test, options =>
            {
                options.Cookies = RestService.Instance.Cookies;
            })
                         .Build();

            await connection.StartAsync();

            Console.WriteLine(connection.State);

            client = new DesktopClient(connection);
            var list = await client.GetEventTypeList();

            //EventLog log = new EventLog
            //{
            //    Type = list.Where(i => i.Name == "CaptureWebcam").FirstOrDefault()
            //};

            //SubsystemEvent subsystemEvent = new SubsystemEvent
            //{
            //    Name
            //}

            //Console.WriteLine(JsonConvert.SerializeObject(log));

            Watcher = new GeoCoordinateWatcher();
            Watcher.StatusChanged += Watcher_StatusChanged;
            Watcher.Start();

            while (true)
            {
                await Task.Delay(100);

                if (webcamImage != null)
                {
                    var img = new Media
                    {
                        Type = "png",
                        Data = ImageToByte(webcamImage)
                    };
                    var frameImage = await client.CreateMedia(img);

                    var testresult = await client.GetEventFromSubsystemAsync(1, 0, accountUser, "CaptureWebcam", frameImage.Id.ToString());

                    Console.WriteLine(testresult);
                }
            }
        }
Example #9
0
 // GET: /Action/GoPrime
 public ActionResult GoPrime()
 {
     Screen.EnsureScreenOn();
     Running.StartStream("Prime");
     Receiver.SelectComputerInput();
     Receiver.SelectTVOutput();
     DesktopClient.LaunchProgram("Prime", null);
     return(Content(""));
 }
Example #10
0
 /// <summary>
 ///
 /// </summary>
 public static void StopZoom()
 {
     if (runningProgram == "Video" && zoomRunning)
     {
         Zoom.Stop();
         DesktopClient.ExitProgram("Video");
     }
     zoomRunning = false;
 }
Example #11
0
 // GET: /Action/VisualOn
 public ActionResult VisualOn()
 {
     Screen.SetScreenDisplayMode(Running.RunningProgram == "Music" ? 2 : 1);
     if (Running.RunningProgram == "Spotify")
     {
         DesktopClient.LaunchProgram("GForce", "");
     }
     return(Content(""));
 }
Example #12
0
    /// <summary>
    /// Is the screen really on (irrespective of our state)?
    /// </summary>
    /// <returns></returns>
    static bool TestScreenOn()
    {
        //  If we are watching an external source, it does not matter if the screen is on
        if (Receiver.SelectedInput != "Computer")
        {
            return(isOn);
        }

        return(DesktopClient.TvScreenIsOn());
    }
Example #13
0
    /// <summary>
    /// Turn the screen off by issuing the appropriate HDMI-CEC command to device 0 (which is always the TV screen).
    /// </summary>
    static void TurnOff()
    {
        // if we've just turned the screen on, wait for the transition
        if (isOn)
        {
            WaitForScreenOn();
        }

        DesktopClient.TvScreenOff();
        isOn = false;
    }
Example #14
0
 // GET: /Action/GoLogFire
 public ActionResult GoLogFire()
 {
     Screen.EnsureScreenOn();
     if (Running.RunningProgram != "Music" && Running.RunningProgram != "Spotify")
     {
         Running.StartStream("LogFire");
     }
     Receiver.SelectComputerInput();
     DesktopClient.LaunchProgram("LogFire", null);
     return(Content(""));
 }
Example #15
0
        // GET: /Web/PlayBBC
        public ContentResult PlayBBC(
            string pid)
        {
            if (String.IsNullOrEmpty(Running.RunningProgram))
            {
                DesktopClient.SendSpecialkey("ClearDesktop");
            }

            Running.LaunchProgram("Web", "-k -nomerge " + BBC.GetTvPlayerUrl(pid));

            return(Content("OK"));
        }
Example #16
0
        // GET: /Action/StartSky
        public ActionResult StartSky(
            string mode)
        {
            bool isAlreadyRunningSky = Running.RunningProgram == "Sky";

            if (mode != "radio")
            {
                Screen.EnsureScreenOn();
            }
            else if (!isAlreadyRunningSky)
            {
                Screen.SetScreenDisplayMode(0);
            }

            Running.StartSky();

            Receiver.SelectSkyInput();
            if (mode == "radio")
            {
                Receiver.SelectRoomsOutput();
            }
            else
            {
                Receiver.SelectTVOutput(null, false);
            }

            if (!isAlreadyRunningSky)
            {
                Receiver.SetMute(true);
            }

            DesktopClient.SendIR(IRCodes.Codes["Sky.Watch"], "Sky.Watch");

            if (!isAlreadyRunningSky)
            {
                System.Threading.Thread.Sleep(2000);
                SkyData.Sky.ChangeChannel(0);
            }

            switch (mode)
            {
            case "planner":
                return(Content("/Sky/Recordings"));

            case "live":
                return(Content("/Sky/Live"));

            case "radio":
                return(Content("/Sky/Radio"));
            }
            return(Content("/Sky/Watch"));
        }
Example #17
0
        public Form1()
        {
            InitializeComponent();

            //We define our test class to pokein to let server side call the methods from this class
            test = new DesktopTest123(this);
            client = new DesktopClient(test, "http://localhost:7777/host.PokeIn", "");

            //DesktopClient events
            client.OnClientConnected += new OnConnection(client_OnClientConnected);
            client.OnClientDisconnected += new OnConnection(client_OnClientDisconnected);
            client.OnErrorReceived += new OnError(client_OnErrorReceived);
        }
Example #18
0
        public Form1()
        {
            InitializeComponent();

            //We define our test class to pokein to let server side call the methods from this class
            test   = new DesktopTest(this);
            client = new DesktopClient(test, "http://localhost:7777/host.PokeIn", "");

            //DesktopClient events
            client.OnClientConnected    += new OnConnection(client_OnClientConnected);
            client.OnClientDisconnected += new OnConnection(client_OnClientDisconnected);
            client.OnErrorReceived      += new OnError(client_OnErrorReceived);
        }
        public async Task ConnectAlarm(Uri uri, int accountId)
        {
            accountUser = accountId;
            //Console.WriteLine(uri);
            //string p = uri.AbsoluteUri.Replace(uri.LocalPath, string.Empty);
            string test = uri.AbsoluteUri + "OperatorHub";

            Console.WriteLine(test);
            connection = new HubConnectionBuilder()
                         .WithUrl(test, options =>
            {
                options.Cookies = RestService.Instance.Cookies;
            })
                         .Build();

            await connection.StartAsync();

            Console.WriteLine(connection.State);

            client = new DesktopClient(connection);
            //var list = await client.GetEventTypeList();


            imageList.Add(new BitmapImage(new Uri("pack://application:,,/;Component/Images/01.jpg")));
            imageList.Add(new BitmapImage(new Uri("pack://application:,,/;Component/Images/02.jpg")));
            imageList.Add(new BitmapImage(new Uri("pack://application:,,/;Component/Images/03.jpg")));
            imageList.Add(new BitmapImage(new Uri("pack://application:,,/;Component/Images/04.jpg")));
            imageList.Add(new BitmapImage(new Uri("pack://application:,,/;Component/Images/05.jpg")));
            imageList.Add(new BitmapImage(new Uri("pack://application:,,/;Component/Images/06.jpg")));
            imageList.Add(new BitmapImage(new Uri("pack://application:,,/;Component/Images/07.png")));
            imageList.Add(new BitmapImage(new Uri("pack://application:,,/;Component/Images/08.jpg")));
            imageList.Add(new BitmapImage(new Uri("pack://application:,,/;Component/Images/09.jpg")));
            imageList.Add(new BitmapImage(new Uri("pack://application:,,/;Component/Images/10.jpg")));
            imageList.Add(new BitmapImage(new Uri("pack://application:,,/;Component/Images/11.jpg")));
            imageList.Add(new BitmapImage(new Uri("pack://application:,,/;Component/Images/12.jpg")));
            imageList.Add(new BitmapImage(new Uri("pack://application:,,/;Component/Images/13.jpg")));
            int    idIndex = 3;
            Random random  = new Random();

            while (true)
            {
                await Task.Delay(1000);

                AddMedia(idIndex, imageList[random.Next(imageList.Count)]);
                idIndex++;
                if (idIndex == 22)
                {
                    idIndex = 3;
                }
            }
        }
Example #20
0
        public async Task <DesktopClient> CreateDesktopClientAsync(DesktopCreateModel d)
        {
            var newD = new DesktopClient()
            {
                ClientName       = d.ClientName,
                ClientMacAddress = d.ClientMacAddress,
                ClientType       = d.ClientType,
            };
            var newDc = await _context.DesktopClients.AddAsync(newD);

            await _context.SaveChangesAsync();

            var result = newDc.Entity;

            return(result);
        }
Example #21
0
        public frmFirst()
        {
            InitializeComponent();
            string CaCertPath = ConfigurationManager.AppSettings["CaCertPath"];
            string ServerIP   = ConfigurationManager.AppSettings["ServerIP"];
            string ServerPort = ConfigurationManager.AppSettings["ServerPort"];
            string ServerEui  = ConfigurationManager.AppSettings["ServerEui"];

            Client = new DesktopClient(CaCertPath, ReaderPc.GetCpuID(), ServerEui, ServerIP, ServerPort);
            Client.Start();
            Client.SelectServerEvent += Client_SelectServerEvent;
            Client.Conn1Event        += Client_Conn1Event;
            Client.Conn2Event        += Client_Conn2Event;
            Client.RcvKeyEvent       += Client_RcvKeyEvent;
            Client.MouseMoveEvent    += Client_MouseMoveEvent;
        }
Example #22
0
    /// <summary>
    /// Exit all running programmes
    /// </summary>
    /// <param name="keepScreen"></param>
    /// <returns></returns>
    public static bool ExitAllPrograms(
        bool keepScreen = false)
    {
        logger.Info("ExitAllPrograms");

        lastActive = DateTime.UtcNow;

        if (spotifyRunning)
        {
            Spotify.ExitPlayer();
            spotifyRunning = false;
        }

        if (runningProgram == "Music" || runningProgram == "Photo")
        {
            ExitJRMC();
        }

        if (runningProgram == "Sky")
        {
            DesktopClient.SendIR(IRCodes.Codes["Sky.PowerSTB"], "Sky.PowerSTB");
            Receiver.SelectComputerInput();
        }

        if (runningProgram == "Roku")
        {
            Roku.KeyPress("Home");
            Receiver.SelectComputerInput();
        }

        if (!keepScreen)
        {
            Receiver.TurnOff();
            Screen.SetScreenDisplayMode(0);
        }
        else
        {
            Screen.EnsureScreenOn();
            Receiver.SelectTVOutput();
        }

        bool ok = DesktopClient.ExitAllPrograms();

        NothingRunning();

        return(ok);
    }
Example #23
0
 static void Main(string[] args)
 {
     for (int i = 0; i < 100; i++)
     {
         var thread = new Thread(delegate()
          {
              var clientInstance = new ClientInstance();
              var client = new DesktopClient(clientInstance, "http://localhost:8006/host.PokeIn", "");
              client.Connect();
          });
         thread.Start();
         Thread.Sleep(1000);
         Console.WriteLine("");
     }
     Console.WriteLine();
     Console.ReadKey();
 }
Example #24
0
        // GET: /Action/AllOff
        public ActionResult AllOff(
            string keep)
        {
            try
            {
                Security.ClearSavedProfile();

                Running.ExitAllPrograms(!string.IsNullOrEmpty(keep));
                DesktopClient.SendSpecialkey("ClearDesktop");
                return(Content(Receiver.VolumeDisplay));
            }
            catch (System.Exception ex)
            {
                logger.Error(ex, "Error in AllOff: {0}", ex.Message);
                return(Content("Error"));
            }
        }
Example #25
0
    /// <summary>
    /// Apply any initial on/off settings in the current schedule, recording the current state for each device
    /// </summary>
    static void InitSchedule()
    {
        if (CurrentProfileSchedules.radioSchedule != null)
        {
            if (CurrentProfileSchedules.radioSchedule.initiallyOn || CurrentProfileSchedules.radioSchedule.initiallyOff || CurrentProfileSchedules.radioSchedule.onPeriods.Any())
            {
                Running.ExitAllPrograms();
                DesktopClient.SendSpecialkey("ClearDesktop");
            }

            if (CurrentProfileSchedules.radioSchedule.initiallyOn)
            {
                Receiver.Security();
                RadioState = "on";
            }

            if (CurrentProfileSchedules.radioSchedule.initiallyOff)
            {
                RadioState = "off";
            }
        }

        foreach (var zoneKV in CurrentProfileSchedules.zoneSchedules)
        {
            if (zoneKV.Value.initiallyOn && Zones.ContainsKey(zoneKV.Key))
            {
                foreach (Device d in Zones[zoneKV.Key])
                {
                    TP_Link.TurnOn(d.ipAddress, d.name, d.isSocket);
                }
                ZoneStates[zoneKV.Key] = "on";
            }
            if (zoneKV.Value.initiallyOff && Zones.ContainsKey(zoneKV.Key))
            {
                foreach (Device d in Zones[zoneKV.Key])
                {
                    TP_Link.TurnOff(d.ipAddress, d.name, d.isSocket);
                }
                ZoneStates[zoneKV.Key] = "off";
            }
        }
    }
Example #26
0
    /// <summary>
    /// Launch the player applictaion (which will only be the Photo viewer) leaving any JRMC music still playing
    /// </summary>
    /// <param name="name"></param>
    /// <param name="args"></param>
    /// <returns></returns>
    public static bool LaunchNewProgram(
        string name,
        string args)
    {
        logger.Info("LaunchNewProgram {0} -> {1}", runningProgram, name);

        lastActive = DateTime.UtcNow;

        runningArgs = "";

        if (name == "Photo")
        {
            if (runningProgram == "Photo")
            {
                ExitJRMC();
                Thread.Sleep(500);
            }

            Zoom.Stop();
            DvbViewer.Stop();
            if (spotifyRunning)
            {
                Spotify.Stop();
            }
            DesktopClient.ExitAllPrograms();
            Receiver.SelectComputerInput();
            Receiver.ReselectInput();
            Screen.EnsureScreenOn();
            Receiver.SelectRoomsOutput();
            Screen.WaitForScreenOn();
            runningProgram = "Photo";

            if (DesktopClient.LaunchNewProgram(name, args))
            {
                JRMC.SetDisplay(JRMC.DisplayMode.Display, maximize: true);
                logger.Info("LaunchProgram OK {0}", runningProgram);
                return(true);
            }
        }

        return(false);
    }
Example #27
0
    /// <summary>
    /// Note that we are starting streaming, and so stop all media PC player applications
    /// </summary>
    /// <returns></returns>
    public static bool StartStream(
        string streamSource)
    {
        logger.Info("StartStream: " + streamSource);

        if (runningProgram != streamSource)
        {
            if (runningProgram == "Music" || runningProgram == "Photo")
            {
                ExitJRMC();
            }
            StopSky();
            StopRoku();
            DesktopClient.ExitAllPrograms();
            DesktopClient.SendSpecialkey("ClearDesktop");
            NothingRunning();
        }

        runningProgram = streamSource;
        return(true);
    }
Example #28
0
        protected void Application_Start()
        {
            logger.Info("Avid 4 Started");
            AreaRegistration.RegisterAllAreas();

            GlobalConfiguration.Configure(WebApiConfig.Register);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            JRMC.LoadAndIndexAllAlbums(new string[] { "1", "2" }, DateTime.Now.Hour < 5);   //  Reload album data from JRMC when restarting between midnight and five (i.e. in the overnight restart)
            DesktopClient.Initialize();
            Receiver.Initialize();
            Running.Initialize();
            Spotify.Initialize();
            DvbViewer.Initialize();
            Security.Initialize();

#if USE_SKY_STB
            SkyData.Initialize(Config.SkyFavourites, Config.SkyRadio, Config.SkyPackages, Config.SkyCapacityGB);
            var sky = SkyData.Sky;
#endif
        }
Example #29
0
        private void OnCreateOrder(CustomersEnum customerEnumType)
        {
            BtnIsEnable = false;
            var wherePath = OrderTransportUI.GetETSOrderDirectory().FullName;

            if (orderFile == null)
            {
                orderFile = customerEnumType == CustomersEnum.Vostok ? OrderTransportUI.GetVostokOrder().FullName : customerEnumType == CustomersEnum.Inkay ? OrderTransportUI.GetInkayOrder().FullName : null;
                if (string.IsNullOrEmpty(orderFile))
                {
                    return;
                }
            }

            if (customerEnumType == CustomersEnum.Vostok)
            {
                if (treatyFile == null)
                {
                    treatyFile = OrderTransportUI.GetTreatyDraft().FullName;
                    if (string.IsNullOrEmpty(treatyFile))
                    {
                        return;
                    }
                }

                Order.Title = RequisitesVM.Title;
            }

            Order = OrderBP.GenerateOrder(customerEnumType, orderFile, treatyFile, Order, wherePath, "");

            DesktopClient.Send("EventsPipe", Order);

            BtnIsEnable = true;

            Process.Start("explorer", wherePath);
        }
Example #30
0
    /// <summary>
    /// Note that we are starting the Sky box, and so stop all media PC player applications
    /// </summary>
    /// <returns></returns>
    public static bool StartSky()
    {
        logger.Info("StartSky");

        if (runningProgram != "Sky")
        {
            if (runningProgram == "Music" || runningProgram == "Photo")
            {
                ExitJRMC();
            }

            DesktopClient.ExitAllPrograms();
            DesktopClient.SendSpecialkey("ClearDesktop");
            Zoom.Stop();
            DvbViewer.Stop();
            if (spotifyRunning)
            {
                Spotify.Stop();
            }
        }

        runningProgram = "Sky";
        return(true);
    }
Example #31
0
        public override void Start()
        {
            AppJournal.Write("Pipe server lictening stating.");

            DesktopClient.StartListening("EventsPipe", ClientRequest);
        }
Example #32
0
 static void client_OnErrorReceived(DesktopClient c, string errorMessage)
 {
     MessageBox.Show(errorMessage);
 }
Example #33
0
 void client_OnClientDisconnected(DesktopClient c)
 {
     //we call invoke to made change on Window due to cross-thread issues
     this.Invoke(new DConnectionChanged(ConnectionChanged), false); 
 }
Example #34
0
 public void Setup()
 {
     _desktopMessageHandler = new DesktopClient();
 }
Example #35
0
 void client_OnClientConnected(DesktopClient c)
 {
     this.Invoke(new DConnectionChanged(ConnectionChanged), true); 
 }
Example #36
0
 public frmPwd(DesktopClient client)
 {
     InitializeComponent();
     this.client        = client;
     client.Conn2Event += Client_Conn2Event;
 }