Exemplo n.º 1
0
 private async Task CollectAsync(Server server, string type)
 {
     try
     {
         OutputTextBox.AppendText(string.Format("Coletando Logs de {0}...\n", server.Host));
         string             collectCommand = string.Format("racadm techsupreport collect -t {0}", type);
         IdracSshController idrac          = new IdracSshController(server);
         string             result         = idrac.RunCommand(collectCommand);
         string             jobLine        = result.Split('\n').FirstOrDefault();
         string             jobId          = jobLine.Split('=')[1].Trim();
         IdracJob           job            = await new JobController(server).GetJobAsync(jobId);
         var load = new LoadWindow(server, job)
         {
             Title = server.Host
         };
         load.Closed += (object sender, EventArgs e) =>
         {
             var window = (LoadWindow)sender;
             job = window.Job;
             if (job.JobState.Contains("Completed"))
             {
                 ExportTsr(server);
             }
         };
         load.Show();
     }
     catch (Exception ex)
     {
         OutputTextBox.AppendText(string.Format("Falha ao coletar TSR de {0}, {1}\n", server.Host, ex.Message));
     }
 }
Exemplo n.º 2
0
 private async Task RunScriptAsync(string path)
 {
     foreach (Server server in ServersListBox.Items)
     {
         if (!await NetworkHelper.CheckConnectionAsync(server.Host))
         {
             OutputTextBox.AppendText(string.Format("Servidor {0} inacessivel.\n", server.Host));
             continue;
         }
         try
         {
             OutputTextBox.AppendText(string.Format("Aplicando script para {0}\n", server.Host));
             var      idrac  = new IdracSshController(server);
             string[] script = File.ReadAllLines(path);
             foreach (var command in script)
             {
                 idrac.RunCommand(command);
             }
         }
         catch (Exception ex)
         {
             OutputTextBox.AppendText(string.Format("Falha ao executar o script para {0} : {1}\n", server.Host, ex.Message));
         }
     }
     ApplyButton.IsEnabled = true;
     ClearButton.IsEnabled = true;
 }
Exemplo n.º 3
0
        private async Task UpdateJobsAsync()
        {
            timer.Stop();
            foreach (ServerJob job in currentJobs.Values)
            {
                try
                {
                    var idrac      = new JobController(job.Server);
                    var updatedJob = await idrac.GetJobAsync(job.Job.Id);

                    currentJobs.AddOrUpdate(job.Job.Id, new ServerJob()
                    {
                        Server = job.Server, Job = updatedJob, SerialNumber = job.SerialNumber
                    },
                                            (key, existingVal) =>
                    {
                        existingVal.Job.Message         = updatedJob.Message;
                        existingVal.Job.PercentComplete = updatedJob.PercentComplete;
                        existingVal.Job.JobState        = updatedJob.JobState;
                        return(existingVal);
                    });
                }
                catch
                {
                    OutputTextBox.AppendText("Falha ao atualizar status dos Jobs\n");
                    timer.Start();
                    return;
                }
            }
            JobsDataGrid.ItemsSource = currentJobs.Values;
            timer.Start();
        }
Exemplo n.º 4
0
        public void WriteLine(string line, params object[] arguments)
        {
            //Check if the application is shutting down to prevent timed invokes on the output text from piling up
            if (ShuttingDown)
            {
                return;
            }

            line = string.Format(line, arguments);
            line = string.Format("{0} {1}", Nil.Time.Timestamp(), line);
            if (IsFirstLine)
            {
                IsFirstLine = false;
            }
            else
            {
                line = "\n" + line;
            }

            var action = (Action) delegate
            {
                lock (OutputTextBox)
                {
                    OutputTextBox.AppendText(line);
                    OutputTextBox.ScrollToEnd();
                }
            };

            OutputTextBox.Dispatcher.Invoke(action);
        }
Exemplo n.º 5
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(fileTxtName.Text))
            {
                OutputTextBox.AppendText("<REPORTER>: The txt path box is empty.");
                OutputTextBox.AppendText("<REPORTER>: Please add the txt path.");
            }

            else if (String.IsNullOrEmpty(fileCfgName.Text))
            {
                OutputTextBox.AppendText("<REPORTER>: The cfg path box is empty.");
                OutputTextBox.AppendText("<REPORTER>: Please add the cfg path.");
            }

            else if (String.IsNullOrEmpty(fileTxtName.Text) && String.IsNullOrEmpty(fileCfgName.Text))
            {
                OutputTextBox.AppendText("<REPORTER>: The txt and cfg path boxes are empty.");
                OutputTextBox.AppendText("<REPORTER>: Please add both paths.");
            }

            else
            {
                CH_Generate();
            }
        }
Exemplo n.º 6
0
        private async Task UpdateJobsAsync()
        {
            timer.Stop();
            foreach (var job in currentJobs.Values)
            {
                try
                {
                    var idrac      = new JobController(job.Server);
                    var updatedJob = await idrac.GetJobAsync(job.Job.Id);

                    currentJobs.AddOrUpdate(job.Job.Id, new ServerJob()
                    {
                        Server = job.Server, Job = updatedJob, SerialNumber = job.SerialNumber
                    },
                                            (key, existingVal) =>
                    {
                        existingVal.Job.Message         = updatedJob.Message;
                        existingVal.Job.PercentComplete = updatedJob.PercentComplete;
                        existingVal.Job.JobState        = updatedJob.JobState;
                        return(existingVal);
                    });
                }
                catch (Exception ex)
                {
                    OutputTextBox.AppendText(string.Format("Falha ao obter dados de {0} {1}\n", job.Server, ex.Message));
                    timer.Start();
                    return;
                }
            }
            JobsDataGrid.ItemsSource = currentJobs.Values;
            timer.Start();
        }
Exemplo n.º 7
0
        private void ExportTsr(Server server)
        {
            string exportCommand = string.Format(@"racadm -r {0} -u {1} -p {2} techsupreport export -f {3}\{4}.zip",
                                                 server.Host, server.User, server.Password, KnownFolders.Downloads.Path, server.Host);

            System.Diagnostics.ProcessStartInfo info = new System.Diagnostics.ProcessStartInfo()
            {
                WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden,
                FileName    = "cmd.exe",
                Arguments   = string.Format(@"/C {0}", exportCommand)
            };

            System.Diagnostics.Process process = new System.Diagnostics.Process()
            {
                StartInfo = info
            };
            process.Start();
            process.WaitForExit();

            if (process.ExitCode == 0)
            {
                OutputTextBox.AppendText(string.Format("Logs de {0} coletados com sucesso ! salvo em {1}\n", server.Host, KnownFolders.Downloads.Path));
            }
            else
            {
                OutputTextBox.AppendText(string.Format("Falha ao coletar os Logs de {0}\n", server.Host));
            }
        }
Exemplo n.º 8
0
        private async Task ImportScpAsync(string path, string target, string shutdown)
        {
            foreach (Server server in ServersListBox.Items)
            {
                if (!await NetworkHelper.CheckConnectionAsync(server.Host))
                {
                    OutputTextBox.AppendText(string.Format("Servidor {0} inacessivel, verifique a conexão e tente novamente.\n", server.Host));
                    continue;
                }
                try
                {
                    OutputTextBox.AppendText(string.Format("Importando configurações para {0}...\n", server.Host));
                    ScpController idrac = new ScpController(server);
                    IdracJob      job   = await idrac.ImportScpFileAsync(path, target, shutdown, "On");

                    OutputTextBox.AppendText(string.Format("Job {0} criado para servidor {1}\n", job.Id, server));
                    var chassisIdrac = new ChassisController(server);
                    var chassis      = await chassisIdrac.GetChassisAsync();

                    currentJobs.TryAdd(job.Id, new ServerJob()
                    {
                        Job = job, SerialNumber = chassis.SKU, Server = server
                    });
                }
                catch (Exception ex)
                {
                    OutputTextBox.AppendText(string.Format("Falha ao importar arquivo para {0} {1}\n", server.Host, ex.Message));
                }
            }
            ImportButton.IsEnabled = true;
        }
Exemplo n.º 9
0
        private void mDoScriptAnalyzis()
        {
            logLabel.Text = "Running analysis...";
            OutputTextBox.Clear();
            using (var templateAccessor = new TemplateListAccessor())
            {
                if (templateAccessor.ExecuteTemplate(scriptFilePathTextBox.Text) == true)
                {
                    logLabel.Text = "Script complies with an expected predef.lua script";
                    List <Template> templateList = templateAccessor.GetAllTemplates();

                    foreach (Template template in templateList)
                    {
                        string s = "id = " + template.ID.ToString() + " - " +
                                   "classid = " + template.Class.ToString() + "\n";
                        OutputTextBox.AppendText(s);
                    }
                }
                else
                {
                    OutputTextBox.AppendText(templateAccessor.GetLastExecutionError());
                    logLabel.Text = "Script DOES NOT comply with an expected predef.lua script";
                }
            }
        }
Exemplo n.º 10
0
 //Update any user input into Argument textbox into Argument property of selected tool.
 private void Run_Click(object sender, EventArgs e)
 {
     if (MultiHostCheckBox.Checked == true)
     {
         try
         {
             string[] inputIps = File.ReadAllLines(HostsTextBox.Text);
             foreach (string ip in inputIps)
             {
                 tools[(string)ToolsListBox.SelectedItem].Client = ClientTextBox.Text;
                 tools[(string)ToolsListBox.SelectedItem].DeployString = SyntaxTextBox.Text.Replace("x.x.x.x", ip);
                 tools[(string)ToolsListBox.SelectedItem].AutoLog = AutoLoggingcheckBox.Checked;
                 OutputTextBox.AppendText(tools[(string)ToolsListBox.SelectedItem].Deploy(ip, UsernameTextBox.Text, PasswordTextBox.Text));
             }
         }
         catch (Exception)
         {
             MessageBox.Show("Error: Cannot deploy tool.");
         }
     }
     else
     {
         tools[(string)ToolsListBox.SelectedItem].Client = ClientTextBox.Text;
         tools[(string)ToolsListBox.SelectedItem].DeployString = SyntaxTextBox.Text;
         tools[(string)ToolsListBox.SelectedItem].AutoLog = AutoLoggingcheckBox.Checked;
         OutputTextBox.AppendText(tools[(string)ToolsListBox.SelectedItem].Deploy(IPTextBox.Text, UsernameTextBox.Text, PasswordTextBox.Text));
     }
 }
Exemplo n.º 11
0
        private async Task ExportScpFileAsync(Server server, string target, string exportUse)
        {
            if (!await NetworkHelper.CheckConnectionAsync(server.Host))
            {
                MessageBox.Show("Servidor inacessivel", "Erro", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            try
            {
                ScpController idrac = new ScpController(server);
                ExportButton.IsEnabled = false;
                OutputTextBox.AppendText(string.Format("Exportando configurações de {0}...\n", server.Host));
                IdracJob job = await idrac.ExportScpFileAsync(target, exportUse);

                var load = new LoadWindow(server, job)
                {
                    Title = server.Host
                };
                load.Closed += async(object sender, EventArgs e) =>
                {
                    var window = (LoadWindow)sender;
                    job = window.Job;
                    if (job.JobState.Contains("Completed"))
                    {
                        await SaveFileAsync(server, job);
                    }
                };
                load.Show();
            }
            catch (Exception ex)
            {
                OutputTextBox.AppendText(string.Format("Falha ao exportar arquivo: {0}\n", ex.Message));
                ExportButton.IsEnabled = true;
            }
        }
Exemplo n.º 12
0
        private void RevertButton_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;

            var dialogResult = MessageBox.Show(
                "Do you really want to revert all changes?",
                "Are you sure?",
                MessageBoxButtons.YesNo,
                MessageBoxIcon.Question,
                MessageBoxDefaultButton.Button2);

            if (dialogResult != DialogResult.Yes)
            {
                return;
            }

            Cursor.Current = Cursors.WaitCursor;

            _hostsFileAccess.RemoveUrls();
            _spotifyUpdateDirectoryAccess.Allow();

            if (CleanupCheckBox.Checked)
            {
                var uninstaller = new Uninstaller(OutputTextBox);
                uninstaller.UninstallSpotify();
            }

            SetUiAndConfig(false);

            OutputTextBox.AppendText("\r\nAll changes successfully reverted!", Color.Green);
            OutputTextBox.AppendText(_textBoxSeparator);

            SystemSounds.Asterisk.Play();
        }
        private void InitializeQuestionnaire(FileInfo qlFile)
        {
            try
            {
                var form   = ParseQLFile(qlFile);
                var report = ValidateQuestionForm(form);

                OutputTextBox.AppendText(report.ToString());

                if (report.NrOfErrors == 0)
                {
                    var ui = BuildUI(form);
                    SplitPanel.Panel1.Controls.Add(ui);
                }
                else
                {
                    MessageBox.Show("Validation errors in the questionnaire AST. See Output Window for details."
                                    , "Validation errors", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    SplitPanel.Panel2Collapsed = false;
                }
            }
            catch (Exception ex)
            {
                Output.WriteLine("ERROR - {0}", ex.ToString());
                MessageBox.Show("Exception occured. See Output Window for details.", "Unhandled exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 14
0
        private void TransferButton_Click(object sender, EventArgs e)
        {
            var count = InputTextBox.Text.Count(Char.IsDigit);

            string[] TextToTransfer = new string[count];

            OutputTextBox.Clear();

            using (StringReader reader = new StringReader(InputTextBox.Text))
            {
                string line;
                while ((line = reader.ReadLine()) != null)
                {
                    // Do something with the line
                    line = _defaultPhrase + SpacesPhrase + line;

                    if (!string.IsNullOrWhiteSpace(OutputTextBox.Text))
                    {
                        OutputTextBox.AppendText("\r\n" + line);
                    }
                    else
                    {
                        OutputTextBox.AppendText(line);
                    }
                    OutputTextBox.ScrollToCaret();
                }
            }
        }
Exemplo n.º 15
0
        private void SubmitInputButton_Click(object sender, EventArgs e)
        {
            try
            {
                string RusKey = "Ё!\"№;%:?*()_+ЙЦУКЕНГШЩЗХЪ/ФЫВАПРОЛДЖЭЯЧСМИТЬБЮ,ё1234567890-=йцукенгшщзхъ\\фывапролджэячсмитьбю. ";
                string EngKey = "~!@#$%^&*()_+QWERTYUIOP{}|ASDFGHJKL:\"ZXCVBNM<>?`1234567890-=qwertyuiop[]\\asdfghjkl;'zxcvbnm,./ ";


                string Text       = InputTextBox.Text;
                string OutputText = "";

                for (int i = 0; i < Text.Length; i++)
                {
                    try
                    {
                        OutputText += EngKey.Substring(RusKey.IndexOf(Text[i]), 1);
                    }
                    catch
                    {
                        OutputText += RusKey.Substring(EngKey.IndexOf(Text[i]), 1);
                    }
                }


                OutputTextBox.Clear();
                OutputTextBox.AppendText(OutputText);
                MessageBox.Show("Успешно переведено                                                  ");
            }
            catch
            {
                MessageBox.Show("Что-то пошло не так                                                      ");
            }
        }
        public SyncPlaylistsWindow(MusicBeeApiInterface mbApiInterface)
        {
            InitializeComponent();

            OutputTextBox.AppendText(Environment.NewLine);

            _mbApiInterface = mbApiInterface;
            ApplyMusicBeeTheme();
        }
Exemplo n.º 17
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            // Prevent windows from sleeping when program is running
            NativeMethods.SetThreadExecutionState(NativeMethods.ES_CONTINUOUS | NativeMethods.ES_SYSTEM_REQUIRED);

            armed        = false;
            shuttingDown = false;
            OutputTextBox.AppendText("Hello and welcome!");
        }
Exemplo n.º 18
0
 private void Client_OnMessageSent(object sender, TwitchLib.Events.Client.OnMessageSentArgs e)
 {
     OutputTextBox.Invoke((MethodInvoker) delegate
     {
         OutputTextBox.AppendText($"[{e.SentMessage.UserType}] {USER}: {e.SentMessage.Message}\n");
     });
     ChatTextBox.Invoke((MethodInvoker) delegate
     {
         ChatTextBox.AppendText($"[{e.SentMessage.UserType}] {USER}: {e.SentMessage.Message}\n");
     });
 }
Exemplo n.º 19
0
 private void Client_OnMessageReceived(object sender, TwitchLib.Events.Client.OnMessageReceivedArgs e)
 {
     OutputTextBox.Invoke((MethodInvoker) delegate
     {
         OutputTextBox.AppendText($"[{e.ChatMessage.UserType}] {e.ChatMessage.DisplayName}: {e.ChatMessage.Message}\n");
     });
     ChatTextBox.Invoke((MethodInvoker) delegate
     {
         OutputTextBox.AppendText($"[{e.ChatMessage.UserType}] {e.ChatMessage.DisplayName}: {e.ChatMessage.Message}\n");
     });
 }
Exemplo n.º 20
0
 public void AppendTextBox(string value)
 {
     //if this is called from a different thread, an invoke will be required to access the form's control
     //for the rich text box.
     if (InvokeRequired)
     {
         this.Invoke(new Action <string>(AppendTextBox), new object[] { value });
         return;
     }
     OutputTextBox.AppendText("\n" + value);
 }
Exemplo n.º 21
0
 private void WriteOutput(string outShell)
 {
     if (!outShell.EndsWith("\n"))
     {
         outShell += "\n";
     }
     Dispatcher.Invoke(() =>
     {
         OutputTextBox.AppendText(outShell);
         OutputTextBox.ScrollToEnd();
     });
 }
Exemplo n.º 22
0
        private async void OutputCounters()
        {
            foreach (var counter in CounterList)
            {
                await Task.Run(() => {
                    counter.Count((x) => OutputTextBox.AppendText($"{x}"));
                });

                //counterx.Count((x) => OutputTextBox.AppendText($"{x}"));
                OutputTextBox.AppendText("\r\n");
            }
        }
Exemplo n.º 23
0
        public MainWindow()
        {
            InitializeComponent();
            OutputTextBox.AppendText("Please wait while I gather the items off of the web page................\r\n");
            products = new Dictionary <string, Product>();

            /* Provides a way to call an asychronous method from a main function without any complaints from the compiler.
             * Normally, you would make the calling function an asynchronous method, but I can't do that here, because
             * it's a main function. Note that await capability isn't available here.
             */
            ParseHtmlAsync().ContinueWith(task => { }, TaskScheduler.FromCurrentSynchronizationContext());
        }
Exemplo n.º 24
0
        private void InputButton_Click(object sender, EventArgs e)
        {
            OutputTextBox.Clear();
            try
            {
                if (prolog == null)
                {
                    labelError.Text = "Please Select Theory";
                    return;
                }
                if (prolog is Perm)
                {
                    Term      goal = new Struct("perm", Term.createTerm(InputTextBox.Text), new Var("R"));
                    SolveInfo SI   = prolog.solve(goal);

                    if (!SI.isSuccess())
                    {
                        OutputTextBox.AppendText("no");
                    }

                    while (SI.isSuccess())
                    {
                        OutputTextBox.AppendText(SI.getTerm("R").toString() + "\n");
                        if (prolog.hasOpenAlternatives())
                        {
                            SI = prolog.solveNext();
                        }
                        else
                        {
                            break;
                        }
                    }
                }
                else if (prolog is PrologDerivate)
                {
                    Term      goal = new Struct("dExpr", Term.createTerm(InputTextBox.Text), new Var("DT"));
                    SolveInfo SI   = prolog.solve(goal);

                    if (!SI.isSuccess())
                    {
                        OutputTextBox.AppendText("no");
                    }
                    else
                    {
                        OutputTextBox.AppendText(SI.getTerm("DT").toString() + "\n");
                    }
                }
            }
            catch (MalformedGoalException ex) {
                OutputTextBox.AppendText("Malformed Goal\n");
            }
        }
Exemplo n.º 25
0
 private void SearchButton_Click(object sender, EventArgs e)
 {
     OutputTextBox.Text = "";
     try
     {
         if (DirectionChecker.Checked)
         {
             OutputTextBox.Lines =
                 Client.GetTraceDateDirection(FromTownText.Text, DateTimeFrom.Value, ToTownText.Text, DateTimeTo.Value);
         }
         else
         {
             var traces =
                 Client.GetTraceDateInDirection(FromTownText.Text, DateTimeFrom.Value, ToTownText.Text, DateTimeTo.Value).ToList();
             for (int i = 0; i < traces.Count; i++)
             {
                 OutputTextBox.AppendText(" " + (i + 1).ToString() + ": ");
                 for (int j = 0; j < traces[i].Length; j++)
                 {
                     OutputTextBox.AppendText(traces[i][j]);
                     OutputTextBox.AppendText(" \t ");
                 }
                 OutputTextBox.AppendText("\n");
             }
         }
         if (OutputTextBox.Text.Equals(""))
         {
             MessageBox.Show("Brak Takich połączeń");
         }
     }
     catch (FaultException faultMsg)
     {
         MessageBox.Show(faultMsg.Message);
     }
     catch (EndpointNotFoundException)
     {
         MessageBox.Show("Server nie odpowiada, prawdopodobnie jest wyłączony");
     }
     catch (CommunicationObjectFaultedException)
     {
         MessageBox.Show("Server nie odpowiada, prawdopodobnie jest wyłączony");
     }
     catch (Exception exc)
     {
         OutputTextBox.Text = "";
         MessageBox.Show(exc.Message);
     }
     finally
     {
         Client = new Service1Client();
     }
 }
Exemplo n.º 26
0
 public void Task_OutputDataRecieved(object sender, DataReceivedEventArgs args)
 {
     if (!this.IsDisposed)
     {
         this.Invoke(new MethodInvoker(delegate {
             if (!String.IsNullOrEmpty(args.Data))
             {
                 OutputTextBox.AppendText(args.Data + Environment.NewLine);
                 OutputTextBox.ScrollToCaret();
             }
         }));
     }
 }
Exemplo n.º 27
0
        public TextOutputForm(StringCollection strings)
        {
            InitializeComponent();

            if (strings != null)
            {
                foreach (string str in strings)
                {
                    OutputTextBox.AppendText(str + Environment.NewLine);
                }

                OutputTextBox.ScrollToCaret();
            }
        }
Exemplo n.º 28
0
 private void AppendText(string text)
 {
     if (OutputTextBox.InvokeRequired)
     {
         SetTextCallback d = new SetTextCallback(AppendText);
         OutputTextBox.BeginInvoke(d, new object[] { text });
     }
     else
     {
         OutputTextBox.AppendText(text);
         OutputTextBox.ScrollToCaret();
         //Application.DoEvents();
     }
 }
Exemplo n.º 29
0
        private async Task RunAsync(string type)
        {
            List <Task> tasks = new List <Task>();

            foreach (Server server in ServersListBox.Items)
            {
                if (!await NetworkHelper.CheckConnectionAsync(server.Host))
                {
                    OutputTextBox.AppendText(string.Format("Servidor {0} inacessivel.\n", server.Host));
                    continue;
                }
                tasks.Add(CollectAsync(server, type));
            }
            await Task.WhenAll(tasks);
        }
Exemplo n.º 30
0
 private void exportHistoryToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (Directory.Exists(@"C:\Tools\CrowesNest\History\") != true)
     {
         Directory.CreateDirectory(@"C:\Tools\CrowesNest\History\");
     }
     string fileLocation = String.Format(@"C:\Tools\CrowesNest\History\cn_history.txt");
     FileInfo exportFileInfo = new FileInfo(fileLocation);
     using (StreamWriter swFile = new StreamWriter(exportFileInfo.FullName))
     {
         swFile.WriteLine($"CrowesNest History exported on {DateTime.Now}\n\n");
         swFile.WriteLine(OutputTextBox.Text);
     }
     OutputTextBox.AppendText($"Exported History to C:\\Tools\\CrowesNest\\History\\cn_history.txt\nTime: {DateTime.Now}\n\n");
 }