protected void BindPopupApps()
		{
            RdsCollection collection = ES.Services.RDS.GetRdsCollection(PanelRequest.CollectionID);
            List<StartMenuApp> apps = ES.Services.RDS.GetAvailableRemoteApplications(PanelRequest.ItemID, collection.Name).ToList();
            var sessionHosts = ES.Services.RDS.GetRdsCollectionSessionHosts(PanelRequest.CollectionID);            

            var addedApplications = GetApps();
            var aliases = addedApplications.Select(p => p.Alias);
            apps = apps.Where(x => !aliases.Contains(x.Alias)).ToList();          

            if (Direction == SortDirection.Ascending)
            {
                apps = apps.OrderBy(a => a.DisplayName).ToList();
                Direction = SortDirection.Descending;
            }
            else
            {
                apps = apps.OrderByDescending(a => a.DisplayName).ToList();
                Direction = SortDirection.Ascending;
            }

            var requiredParams = addedApplications.Select(a => a.RequiredCommandLine.ToLower());

            foreach (var host in sessionHosts)
            {
                if (!requiredParams.Contains(string.Format("/v:{0}", host.ToLower())))
                {                    
                    var fullRemote = new StartMenuApp
                    {
                        DisplayName = string.Format("Full Desktop - {0}", host.ToLower()),
                        FilePath = "c:\\windows\\system32\\mstsc.exe",                        
                        RequiredCommandLine = string.Format("/v:{0}", host.ToLower())
                    };

                    var sessionHost = collection.Servers.Where(s => s.FqdName.Equals(host, StringComparison.CurrentCultureIgnoreCase)).First();

                    if (sessionHost != null)
                    {
                        fullRemote.DisplayName = string.Format("Full Desktop - {0}", sessionHost.Name.ToLower());
                    }

                    fullRemote.Alias = fullRemote.DisplayName.Replace(" ", "");

                    if (apps.Count > 0)
                    {
                        apps.Insert(0, fullRemote);
                    }
                    else
                    {
                        apps.Add(fullRemote);
                    }
                }
            }

            gvPopupApps.DataSource = apps;
            gvPopupApps.DataBind();
		}
 protected static int CompareAccount(StartMenuApp app1, StartMenuApp app2)
 {
     return string.Compare(app1.DisplayName, app2.DisplayName);
 }
Ejemplo n.º 3
0
        private StartMenuApp CreateStartMenuAppFromPsObject(PSObject psObject)
        {
            var remoteApp = new StartMenuApp
            {
                DisplayName = Convert.ToString(GetPSObjectProperty(psObject, "DisplayName")),
                FilePath = Convert.ToString(GetPSObjectProperty(psObject, "FilePath")),
                FileVirtualPath = Convert.ToString(GetPSObjectProperty(psObject, "FileVirtualPath"))
            };

            remoteApp.Alias = remoteApp.DisplayName;

            return remoteApp;
        }