Ejemplo n.º 1
0
        public override void ExecuteCommand(string userId, string command)
        {
            ClientInputCommand visionData = deserialize.Deserialize <ClientInputCommand>(command);

            if (visionData == null)
            {
                return;
            }

            int result   = ServerVisionHelper.getInstance().LaunchVisionWindow(visionData.Attribute.InputId);
            int userDBid = ConnectedClientHelper.GetInstance().GetClientInfo(userId).DbUserId;

            Server.LaunchedSourcesHelper.GetInstance().AddLaunchedApp(userDBid, result, visionData.Attribute.InputId);
        }
Ejemplo n.º 2
0
        public void LaunchPresetExternal(int dbUserId, int presetDbId)
        {
            // get the rect from the preset table
            PresetData       preset     = Server.ServerDbHelper.GetInstance().GetPresetByUserId(dbUserId).First(PresetData => PresetData.Id == presetDbId);
            ClientAppCmdImpl clientImpl = new ClientAppCmdImpl();

            foreach (ApplicationData appData in preset.AppDataList)
            {
                int result = clientImpl.LaunchApplication(appData);
                LaunchedWndHelper.GetInstance().AddLaunchedApp(dbUserId, result, appData.id);
            }

            // start vnc
            foreach (RemoteVncData remoteData in preset.VncDataList)
            {
                int result = vncClient.StartClient(
                    remoteData.remoteIp,
                    remoteData.remotePort,
                    remoteData.rect.Left,
                    remoteData.rect.Top,
                    remoteData.rect.Right - remoteData.rect.Left,
                    remoteData.rect.Bottom - remoteData.rect.Top);

                // add to the connected client info
                LaunchedVncHelper.GetInstance().AddLaunchedApp(dbUserId, result, remoteData.id);
            }

            // start source input
            foreach (VisionData inputData in preset.InputDataList)
            {
                int result = ServerVisionHelper.getInstance().LaunchVisionWindow(
                    inputData.id,
                    inputData.rect.Left,
                    inputData.rect.Top,
                    inputData.rect.Right - inputData.rect.Left,
                    inputData.rect.Bottom - inputData.rect.Top);

                // add to the connected client info
                LaunchedSourcesHelper.GetInstance().AddLaunchedApp(dbUserId, result, inputData.id);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// launch input source base in db index
        /// </summary>
        /// <param name="command">
        /// command[0] = "command pattern"
        /// command[1] = "db index"
        /// command[2] = "username"
        /// command[3] = "password"
        /// </param>
        /// <returns></returns>
        public override string executeCommand(string[] command)
        {
            if (command.Count() != 4)
            {
                throw new Exception();
            }

            List <UserData> userDataList = new List <UserData>(Server.ServerDbHelper.GetInstance().GetAllUsers());
            UserData        userData     = userDataList.Find(user
                                                             =>
                                                             (user.username.CompareTo(command[2]) == 0 &&
                                                              user.password.CompareTo(command[3]) == 0));

            if (userData == null)
            {
                // no matched
                return("Credential verification failed. Please check login info.");
            }

            int dbIndex = 0;

            if (int.TryParse(command[1], out dbIndex) == false)
            {
                throw new Exception();
            }

            try
            {
                int result = ServerVisionHelper.getInstance().LaunchVisionWindow(dbIndex);
                Server.LaunchedSourcesHelper.GetInstance().AddLaunchedApp(userData.id, result, dbIndex);
            }
            catch (Exception e)
            {
                Trace.WriteLine(e.Message);
            }


            return("Input source launched successfully");
        }
Ejemplo n.º 4
0
        public override void ExecuteCommand(string userId, string command)
        {
            ClientPresetsCmd presetData = deserialize.Deserialize <ClientPresetsCmd>(command);

            if (presetData == null)
            {
                return;
            }

            bool broadcastChanges = false;

            switch (presetData.ControlType)
            {
            case ClientPresetsCmd.EControlType.Add:
                AddPreset(userId, clientId, presetData);
                broadcastChanges = true;
                break;

            case ClientPresetsCmd.EControlType.Delete:
                RemovePreset(presetData);
                broadcastChanges = true;
                break;

            case ClientPresetsCmd.EControlType.Launch:
                LaunchPreset(userId, clientId, presetData);
                break;

            case ClientPresetsCmd.EControlType.Modify:
                ModifyPreset(clientId, presetData);
                break;

            default:
                break;
            }

            if (broadcastChanges)
            {
                // TODO: broadcast changes to user who login using the owner's account
                // get user's preset list
                ServerPresetsStatus serverPresetStatus = new ServerPresetsStatus();
                serverPresetStatus.UserPresetList = new List <PresetsEntry>();
                foreach (PresetData data in Server.ServerDbHelper.GetInstance().GetPresetByUserId(clientId))
                {
                    List <ApplicationEntry> presetAppEntries = new List <ApplicationEntry>();
                    foreach (ApplicationData appData in data.AppDataList)
                    {
                        presetAppEntries.Add(new ApplicationEntry()
                        {
                            Identifier = appData.id,
                            Name       = appData.name
                        });
                    }

                    List <VncEntry> presetVncEntries = new List <VncEntry>();
                    foreach (RemoteVncData vncData in data.VncDataList)
                    {
                        presetVncEntries.Add(new VncEntry()
                        {
                            Identifier  = vncData.id,
                            DisplayName = vncData.name,
                            IpAddress   = vncData.remoteIp,
                            Port        = vncData.remotePort,
                        });
                    }

                    List <InputAttributes> presetInputEntries = new List <InputAttributes>();
                    foreach (VisionData inputData in data.InputDataList)
                    {
                        presetInputEntries.Add(
                            ServerVisionHelper.getInstance().GetAllVisionInputsAttributes().First(InputAttributes
                                                                                                  => InputAttributes.InputId == inputData.id));
                    }

                    serverPresetStatus.UserPresetList.Add(new PresetsEntry()
                    {
                        Identifier      = data.Id,
                        Name            = data.Name,
                        ApplicationList = presetAppEntries,
                        VncList         = presetVncEntries,
                        InputList       = presetInputEntries,
                    });
                }

                // should get all connected client with same login
                List <string> connectedClientSocketList;
                if (ConnectedClientHelper.GetInstance().GetConnectedUsersGroupByDB().TryGetValue(clientId, out connectedClientSocketList))
                {
                    server.GetConnectionMgr().SendData(
                        (int)CommandConst.MainCommandServer.UserPriviledge,
                        (int)CommandConst.SubCommandServer.PresetList,
                        serverPresetStatus,
                        connectedClientSocketList);
                }
                else
                {
                    // Should not happen, just in case
                    Trace.WriteLine("ERROR: cannot get connected user socket list by user db id: " + clientId);
                    server.GetConnectionMgr().SendData(
                        (int)CommandConst.MainCommandServer.UserPriviledge,
                        (int)CommandConst.SubCommandServer.PresetList,
                        serverPresetStatus,
                        new List <string>()
                    {
                        userId
                    });
                }
            }
        }
Ejemplo n.º 5
0
        static void Main()
        {
            if (mutex.WaitOne(TimeSpan.Zero, true) == false)
            {
                MessageBox.Show("Only one instance of Vistrol application allowed.");
                return;
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            formLicense = new FormLicense();

            LicenseChecker.LicenseChecker licenceChecker = null;
            DriveInfo[] allDrives = DriveInfo.GetDrives();
            foreach (DriveInfo drive in allDrives)
            {
                string filePath = drive.RootDirectory + LicenseChecker.LicenseChecker.LICENSE_FILE_NAME;
                if (Utils.Files.IsFileExists(filePath))
                {
                    licenceChecker = new LicenseChecker.LicenseChecker(filePath);
                    licenceChecker.EvtLicenseCheckStatus += licenceChecker_EvtLicenseCheckStatus;
                    break;
                }
            }

            if (licenceChecker == null)
            {
                MessageBox.Show("No license found. Please plug in dongle and retry.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);

                return;
            }

            // initialize database
            ConnectionManager connMgr = new ConnectionManager();

            formServer = new FormServer(connMgr);

            wcfCallback = new WcfCallbackHandler(connMgr, formServer);
            Server.ServerDbHelper.GetInstance().Initialize(wcfCallback);

            RGBERROR error   = 0;
            IntPtr   hRGBDLL = IntPtr.Zero;

            try
            {
                error = RGB.Load(out hRGBDLL);
                if (error == RGBERROR.NO_ERROR)
                {
                    ServerVisionHelper.getInstance().InitializeVisionDB();
                }
            }
            catch (Exception)
            {
            }

            licenceChecker.StartCheck();
            Application.Run(formServer);

            // clean up
            if (hRGBDLL != IntPtr.Zero)
            {
                RGB.Free(hRGBDLL);
            }

            licenceChecker.StopCheck();
        }