Ejemplo n.º 1
0
        public static void analyse(System.Windows.Forms.DataVisualization.Charting.Chart chart1, System.Windows.Forms.DataVisualization.Charting.Series series1, DataGridView dataGridView1, CheckBox optimize, CheckBox optimizemft, CheckBox uncompress, Label label4, string settingsfile)
        {
            PCS pcs = new PCS();

            log.WriteLog("Maintainer DiskDefrag analysis start");
            DiskDefragger.read_defragsettings(dataGridView1, optimize, optimizemft, uncompress, settingsfile, true);
            for (int i = 0; i < dataGridView1.Rows.Count; i++)
            {
                string driveselection = dataGridView1[0, i].Value.ToString();

                if (driveselection == "True")
                {
                    string path = dataGridView1[1, i].Value.ToString().Substring(0, 2);
                    PCS.process("cmd", "/C set UD_TIME_LIMIT=0h 30m && set UD_LOG_FILE_PATH=ud\\" + i.ToString() + ".log && ud\\udefrag.exe -a " + path, true);
                    string fragmentedpercent = pcs.findword("ud\\" + i + ".log", "fragmentation is above the threshold:", 61);
                    System.Threading.Thread.Sleep(1000);
                    Global.fragmentedp[i] = fragmentedpercent.Substring(0, 5);
                }
            }
            string fragmentedf = pcs.findword("ud\\0.log", "fragmented files", 41);
            string fragmentedp = pcs.findword("ud\\0.log", "fragmentation is above the threshold:", 61);

            string compf             = pcs.findword("ud\\0.log", "compressed files:", 41);
            string totalf            = pcs.findword("ud\\0.log", "files total:", 41);
            double defragmentedfiles = Convert.ToDouble(totalf) - Convert.ToDouble(compf) + Convert.ToDouble(fragmentedf);

            label4.Text = "Fragmentation: " + fragmentedp.Substring(0, 7);


            series1.BackGradientStyle = System.Windows.Forms.DataVisualization.Charting.GradientStyle.DiagonalLeft;
            series1.ChartArea         = "ChartArea1";
            series1.ChartType         = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Pie;
            series1.Legend            = "Legend1";
            series1.Name = "Series1";
            series1.Points.AddXY("Defragmented Files: " + defragmentedfiles, defragmentedfiles);
            series1.Points.AddXY("Fragmented Files: " + fragmentedf, Convert.ToDouble(fragmentedf));
            series1.Points.AddXY("Compressed Files: " + compf, Convert.ToDouble(compf));
            double fs  = Convert.ToDouble(dataGridView1[3, 0].Value);
            double rs  = 100 - fs;
            double fsp = Math.Round((fs * Convert.ToDouble(totalf)) / rs, 0);

            series1.Points.AddXY("Free Space: " + fs + "%", fsp);


            chart1.Series.Add(series1);
            chart1.Series[0]["PieLabelStyle"] = "Disabled";
        }
Ejemplo n.º 2
0
        public static void repair()
        {
            PCS pcs = new PCS();

            log.WriteLog("Maintainer Registry Cleaner repair start");
            PCS.process("lrc\\lrc.exe", " /repair", true);
            if (File.Exists("settings\\reglog.txt"))
            {
                Global.registry = pcs.findword("settings\\reglog.txt", "Total problems found", 21);
            }
            log.WriteLog("Maintainer Registry Cleaner repair end");
        }
Ejemplo n.º 3
0
        public static void drive_selection_changed(System.Windows.Forms.DataVisualization.Charting.Chart chart1, System.Windows.Forms.DataVisualization.Charting.Series series1, DataGridView dataGridView1, Label label4, GroupBox groupBox1)
        {
            string logf = dataGridView1.CurrentCell.RowIndex.ToString();

            if (File.Exists("ud\\" + logf + ".log"))
            {
                PCS    pcs               = new PCS();
                string fragmentedf       = pcs.findword("ud\\" + logf + ".log", "fragmented files", 41);
                string fragmentedp       = pcs.findword("ud\\" + logf + ".log", "fragmentation is above the threshold:", 61);
                string compf             = pcs.findword("ud\\" + logf + ".log", "compressed files:", 41);
                string totalf            = pcs.findword("ud\\" + logf + ".log", "files total:", 41);
                double defragmentedfiles = Convert.ToDouble(totalf) - Convert.ToDouble(compf) + Convert.ToDouble(fragmentedf);

                label4.Text    = "Fragmentation: " + fragmentedp.Substring(0, 7);
                groupBox1.Text = dataGridView1[1, dataGridView1.CurrentCell.RowIndex].Value.ToString().Substring(0, 2);
                series1.Points.Clear();
                series1.BackGradientStyle = System.Windows.Forms.DataVisualization.Charting.GradientStyle.DiagonalLeft;
                series1.ChartArea         = "ChartArea1";
                series1.ChartType         = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Pie;
                series1.Legend            = "Legend1";
                series1.Name = "Series1";
                series1.Points.AddXY("Defragmented Files: " + defragmentedfiles, defragmentedfiles);
                series1.Points.AddXY("Fragmented Files: " + fragmentedf, Convert.ToDouble(fragmentedf));
                series1.Points.AddXY("Compressed Files: " + compf, Convert.ToDouble(compf));
                double fs  = Convert.ToDouble(dataGridView1[3, dataGridView1.CurrentCell.RowIndex].Value);
                double rs  = 100 - fs;
                double fsp = Math.Round((fs * Convert.ToDouble(totalf)) / rs, 0);
                series1.Points.AddXY("Free Space: " + fs + "%", fsp);
            }
            else
            {
                label4.Text    = "Drive Not Analysed";
                groupBox1.Text = dataGridView1[1, dataGridView1.CurrentCell.RowIndex].Value.ToString().Substring(0, 2);
                series1.Points.Clear();
            }
        }
Ejemplo n.º 4
0
        public static void defrag(DataGridView dataGridView1, string settingsfile)
        {
            PCS pcs = new PCS();

            log.WriteLog("Maintainer DiskDefrag defrag start");
            string series = " ";

            for (int i = 0; i < dataGridView1.Rows.Count; i++)
            {
                string driveselection = dataGridView1[0, i].Value.ToString();

                if (driveselection == "True")
                {
                    series = series + dataGridView1[1, i].Value.ToString().Substring(0, 2) + " ";
                }
            }
            string argoptions = " ";
            string optimize   = PCS.IniReadValue(settingsfile, "main", "optimize");

            log.WriteLog("Maintainer DiskDefrag defrag optimize: " + optimize);
            if (optimize == "True")
            {
                argoptions = argoptions + "-o ";
            }


            string uncompress = PCS.IniReadValue(settingsfile, "main", "uncompress");

            log.WriteLog("Maintainer DiskDefrag defrag uncompress: " + uncompress);
            if (uncompress == "True")
            {
                log.WriteLog("Maintainer DiskDefrag defrag uncompress start");
                Global.compactstatus = true;
                try
                {
                    ProcessStartInfo startInfo1 = new ProcessStartInfo("compact.exe");

                    startInfo1.UseShellExecute        = false;
                    startInfo1.RedirectStandardInput  = true;
                    startInfo1.RedirectStandardOutput = true;
                    startInfo1.Arguments        = "/u /s /a /q /i *.*";
                    startInfo1.WorkingDirectory = "c:\\";
                    startInfo1.CreateNoWindow   = true;
                    startInfo1.WindowStyle      = ProcessWindowStyle.Hidden;

                    Process process1 = new Process();
                    process1.StartInfo = startInfo1;
                    process1.Start();


                    string lineVal = process1.StandardOutput.ReadLine();
                    while (lineVal != null)
                    {
                        if (lineVal != "")
                        {
                            Global.compactprocess = lineVal;
                        }
                        Application.DoEvents();
                        lineVal = process1.StandardOutput.ReadLine();
                    }
                    log.WriteLog("Maintainer DiskDefrag defrag uncompress end");
                }
                catch
                {
                }
            }
            Global.compactstatus = false;

            PCS.process("cmd", "/C set UD_TIME_LIMIT=1h 30m && set UD_LOG_FILE_PATH=ud\\d.log && ud\\udefrag.exe -a C:", true);
            Global.defragmented = pcs.findword("ud\\d.log", "fragmented files", 41);
            try
            {
                ProcessStartInfo startInfo2 = new ProcessStartInfo("ud\\udefrag.exe");
                startInfo2.UseShellExecute        = false;
                startInfo2.RedirectStandardInput  = true;
                startInfo2.RedirectStandardOutput = true;
                startInfo2.Arguments      = argoptions + series;
                startInfo2.CreateNoWindow = true;
                startInfo2.WindowStyle    = ProcessWindowStyle.Hidden;

                Process process2 = new Process();
                process2.StartInfo = startInfo2;
                process2.Start();


                string lineVal2 = process2.StandardOutput.ReadLine();
                while (lineVal2 != null)
                {
                    if (lineVal2.Length > 14)
                    {
                        string checkanalyse = lineVal2.Substring(3, 8);
                        if (checkanalyse != "analyse:")
                        {
                            Global.diskdefragdrive    = lineVal2.Substring(0, 2);
                            Global.diskdefragprogress = lineVal2.Substring(14, 2);
                        }
                    }
                    Application.DoEvents();
                    lineVal2 = process2.StandardOutput.ReadLine();
                }
                log.WriteLog("Maintainer DiskDefrag defrag uncompress end");
            }
            catch
            {
            }

            string optimizemft = PCS.IniReadValue(settingsfile, "main", "optimizemft");

            log.WriteLog("Maintainer DiskDefrag defrag optimizemft: " + optimizemft);
            if (optimizemft == "True")
            {
                log.WriteLog("Maintainer DiskDefrag defrag optimizemft start");
                try
                {
                    ProcessStartInfo startInfo3 = new ProcessStartInfo("ud\\udefrag.exe");
                    startInfo3.UseShellExecute        = false;
                    startInfo3.RedirectStandardInput  = true;
                    startInfo3.RedirectStandardOutput = true;
                    startInfo3.Arguments      = " --optimize-mft " + series;
                    startInfo3.CreateNoWindow = true;
                    startInfo3.WindowStyle    = ProcessWindowStyle.Hidden;

                    Process process3 = new Process();
                    process3.StartInfo = startInfo3;
                    process3.Start();


                    string lineVal1 = process3.StandardOutput.ReadLine();
                    while (lineVal1 != null)
                    {
                        if (lineVal1.Length > 14)
                        {
                            string checkanalyse = lineVal1.Substring(3, 8);
                            if (checkanalyse != "analyse:")
                            {
                                Global.diskdefragdrive    = lineVal1.Substring(0, 2);
                                Global.diskdefragprogress = lineVal1.Substring(14, 2);
                            }
                        }
                        Application.DoEvents();
                        lineVal1 = process3.StandardOutput.ReadLine();
                    }
                }
                catch
                {
                }
                log.WriteLog("Maintainer DiskDefrag defrag optimizemft end");
            }
        }