Example #1
0
        public async Task <string> GetPSDate()
        {
            try
            {
                ICommand commandI = null;

                //string bodyText = await this.Request.Content.ReadAsStringAsync();
                //var data = JsonConvert.DeserializeObject<Dictionary<string, object>>(JsonConvert.DeserializeObject(bodyText).ToString());
                commandI = new ScriptCommand(AWSCommandResource.getProcessNew, new[] { "Id" });
                Dictionary <string, object> commandData = new Dictionary <string, object>();
                commandData.Add("Id", "temp");
                commandI.Init(commandData);
                commandI.Execute();
                if (commandI.Result != null)
                {
                    return(JsonConvert.SerializeObject(commandI.Result, Formatting.Indented));
                }
                else
                {
                    return(string.Empty);
                }
            }
            catch (Exception ex)
            {
                //ErrorHelper.WriteErrorToEventLog(ex.Message);
                ErrorHelper.SendExcepToDB(ex, "ProcessCommand", "GetDate");
                throw ex;
            }
        }
Example #2
0
        public async Task <List <Server> > GetServer(string deploymentName, string collectionName)
        {
            string pslgetcollectionserver = ConfigurationManager.AppSettings["psl_layer"].ToString() + "/getcollectionserver.ps1";
            string psl_Script             = "";

            using (WebClient client = new WebClient())
            {
                psl_Script = client.DownloadString(pslgetcollectionserver);
            }
            var command = new ScriptCommand(psl_Script, new[] { "ConnectionBroker", "CollectionName" },
                                            (psObject, scriptCommand) =>
            {
                if (scriptCommand.Result == null)
                {
                    scriptCommand.Result = new List <Server>();
                }
                var server = new Server {
                    Name = psObject.SessionHost
                };
                var servers = (List <Server>)scriptCommand.Result;
                servers.Add(server);
            });
            var data = new Dictionary <string, object> {
                { "ConnectionBroker", deploymentName }, { "CollectionName", collectionName }
            };

            command.Init(data);
            command.Execute();
            return((List <Server>)command.Result ?? new List <Server>());
        }
        private void GetUserProfileDiskSettings()
        {
            string pslgetUserProfileDiskSettings = ConfigurationManager.AppSettings["psl_layer"].ToString() + "/getUserProfileDiskSettings.ps1";
            string psl_Script = "";

            using (WebClient client = new WebClient())
            {
                psl_Script = client.DownloadString(pslgetUserProfileDiskSettings);
            }
            var command = new ScriptCommand(psl_Script,
                                            new[] { Param1, Param2 }, (psObject, scriptCommand) =>
            {
                var settings = new CollectionDashboardConfig
                {
                    EnableUserProfileDisk = psObject.EnableUserProfileDisk,
                    DiskPath = psObject.DiskPath,
                    MaxUserProfileDiskSizeGB = psObject.MaxUserProfileDiskSizeGB
                };
                scriptCommand.Result = settings;
            });

            command.Init(Data);
            command.Execute();

            var result = (CollectionDashboardConfig)command.Result;

            this.Result.EnableUserProfileDisk = result.EnableUserProfileDisk;
            this.Result.DiskPath = result.DiskPath;
            this.Result.MaxUserProfileDiskSizeGB = result.MaxUserProfileDiskSizeGB;
        }
Example #4
0
        public async Task <string> AddServers(string subscriptionId)
        {
            string server = string.Empty;

            try
            {
                string psladdserver = ConfigurationManager.AppSettings["psl_layer"].ToString() + "/addserver.ps1";
                string psl_Script   = "";
                using (WebClient client = new WebClient())
                {
                    psl_Script = client.DownloadString(psladdserver);
                }
                List <string> list     = new List <string>();
                string        bodyText = await this.Request.Content.ReadAsStringAsync();

                var      data             = JsonConvert.DeserializeObject <Dictionary <string, object> >(JsonConvert.DeserializeObject(bodyText).ToString());
                var      commandData      = ((JObject)data["ServerDetails"]).ToObject <Dictionary <string, object> >();
                string   ConnectionBroker = commandData["ConnectionBroker"] as string;
                string   serverNames      = commandData["ServerNames"] as string;
                string[] ServerNames      = serverNames.Split(',');

                for (int i = 0; i < ServerNames.Length; i++)
                {
                    list.Add(ServerNames[i]);
                }
                string rawData = string.Empty;
                foreach (var servername in ServerNames)
                {
                    string key  = ConnectionBroker + ":" + servername;
                    var    dict = new Dictionary <string, object> {
                        { "ConnectionBroker", ConnectionBroker }, { "Server", servername }
                    };
                    var command = new ScriptCommand(psl_Script,
                                                    new[] { "ConnectionBroker", "Server" });
                    command.Init(dict);
                    server = AdminCommandsController.ProccessCommandSub(command);
                }
            }
            catch (Exception ex)
            {
                //ErrorHelper.WriteErrorToEventLog(ex.Message);
                ErrorHelper.SendExcepToDB(ex, " AddServers", subscriptionId);
                throw ex;
            }

            return(server);
        }
        public AdminCollection GetCollectionProperty(string deploymentName, string collectionName)
        {
            try
            {
                string pslgetCollection = ConfigurationManager.AppSettings["psl_layer"].ToString() + "/getCollection.ps1";
                string psl_Script       = "";
                using (WebClient client = new WebClient())
                {
                    psl_Script = client.DownloadString(pslgetCollection);
                }
                AdminCollection result = new AdminCollection();

                // Get Audit location
                result.AuditLocation = string.Empty;    // TODO: populate real data when this feature is ready

                // Get the description using powershell
                var command = new ScriptCommand(psl_Script,
                                                new[] { "CollectionName", "ConnectionBroker" }, (psObject, scriptCommand) =>
                {
                    result.Name           = psObject.CollectionName;
                    result.Size           = psObject.Size;
                    result.CollectionType = psObject.ResourceType;
                    result.Description    = psObject.CollectionDescription;
                });
                var data = new Dictionary <string, object> {
                    { "ConnectionBroker", deploymentName }, { "CollectionName", collectionName }
                };
                command.Init(data);

                command.Execute();
                return(result);
            }
            catch (Exception ex)
            {
                ErrorHelper.SendExcepToDB(ex, "GetCollectionProperty", deploymentName);
                throw ex;
            }
        }
Example #6
0
        /// <summary>
        /// Get a list of available Session Host Servers that are not a part of any collections under the given deployment name
        /// </summary>
        /// <param name="deploymentName">Deployment FQDN name</param>
        /// <returns>List of available Session Host Servers that are not a part of any collections under the given deployment name</returns>
        private List <RDServer> GetFreeSessionHostServers(string deploymentName)
        {
            try
            {
                string pslgetAvailableServers = ConfigurationManager.AppSettings["psl_layer"].ToString() + "/getAvailableServers.ps1";
                string psl_Script             = "";
                using (WebClient client = new WebClient())
                {
                    psl_Script = client.DownloadString(pslgetAvailableServers);
                }
                // Get the available Session Host Servers via ScriptCommand/Powershell
                var command = new ScriptCommand(psl_Script, new[] { "ConnectionBroker" }, (psObject, scriptCommand) =>
                {
                    if (scriptCommand.Result == null)
                    {
                        scriptCommand.Result = new List <RDServer>();
                    }
                    var server = new RDServer {
                        Name = psObject.Server, Type = psObject.Type + " RDSH"
                    };
                    var servers = (List <RDServer>)scriptCommand.Result;
                    servers.Add(server);
                });
                var data = new Dictionary <string, object> {
                    { "ConnectionBroker", deploymentName }
                };
                command.Init(data);
                command.Execute();

                return((List <RDServer>)command.Result ?? new List <RDServer>());
            }
            catch (Exception ex)
            {
                ErrorHelper.SendExcepToDB(ex, " GetFreeSessionHostServers", deploymentName);
                throw ex;
            }
        }