public IEnumerable <SQLServerState> GetServerStatus(string AccountType, string AccountID) { string filePath = ""; if (AccountType == "Azure") { filePath = HttpContext.Current.Server.MapPath("~/DB_Csv_files/AzureAccountCreds.csv"); } else if (AccountType == "AWS") { filePath = HttpContext.Current.Server.MapPath("~/DB_Csv_files/AWSAccountCreds.csv"); } PowerShellExecutor <SQLServerState> executor; string key = ""; if (!SQLServerStateController.executors.TryGetValue(key, out executor)) { executor = new PowerShellExecutor <SQLServerState>(); executor.CmdName = ""; executor.NewFunc = this.NewFunc; executor.Configure = (engine) => { PowerShellJob.AddVariable(engine, "CredFile", filePath); PowerShellJob.AddVariable(engine, "AccountID", AccountID); engine.AddScript(AzureCommandResource.Azure_SQLServerState_PS); }; executor = SQLServerStateController.executors.GetOrAdd(key, executor); } var list = executor.GetList(); return(list); }
public IEnumerable <Processes> GetLocalProcess(int Id) { PowerShellExecutor <Processes> executor; string key = Id.ToString(); if (!GetLocalProcessesController.executors.TryGetValue(key, out executor)) { executor = new PowerShellExecutor <Processes>(); executor.CmdName = ""; executor.NewFunc = this.NewFunc; executor.Configure = (engine) => { PowerShellJob.AddVariable(engine, "Id", Id.ToString()); engine.AddScript(AWSCommandResource.getSpecificProcess); }; executor = GetLocalProcessesController.executors.GetOrAdd(key, executor); } var list = executor.GetList(); return(list); }
public IEnumerable <Processes> GetLocalProcesses() { PowerShellExecutor <Processes> executor; string key = ""; if (!GetLocalProcessesController.executors.TryGetValue(key, out executor)) { executor = new PowerShellExecutor <Processes>(); executor.CmdName = ""; executor.NewFunc = this.NewFunc; executor.Configure = (engine) => { engine.AddScript(AzureCommandResource.getLocalProcesses); }; executor = GetLocalProcessesController.executors.GetOrAdd(key, executor); } var list = executor.GetList(); return(list); }
public IEnumerable <VMDetails> GetAzureVMDetails() { //Connect to DB and get the Creds string stm = @"Select SubscriptionId, Username, Password from kloudLoginDetails"; DataTable dt = DBHelper.ExecuteAndGetDataTable(stm); string SubscriptionId = ""; string Username = ""; string Password = ""; if (dt.Rows.Count == 1) { SubscriptionId = dt.Rows[0]["SubscriptionId"] as string; Username = dt.Rows[0]["Username"] as string; Password = dt.Rows[0]["Password"] as string; } PowerShellExecutor <VMDetails> executor; string key = ""; if (!VMDetailsController.executors.TryGetValue(key, out executor)) { executor = new PowerShellExecutor <VMDetails>(); executor.CmdName = ""; executor.NewFunc = this.NewFunc; executor.Configure = (engine) => { PowerShellJob.AddVariable(engine, "SubscriptionId", SubscriptionId); PowerShellJob.AddVariable(engine, "Username", Username); PowerShellJob.AddVariable(engine, "Password", Password); engine.AddScript(AzureCommandResource.getAzureVMDetails); }; executor = VMDetailsController.executors.GetOrAdd(key, executor); } var list = executor.GetList(); return(list); }