//System.Threading.Thread CheckThread; private void btnCheck_Click(object sender, EventArgs e) { if (!CReg.CanRun()) { MessageBox.Show("Please register software!!", "Happy Code"); return; } if (string.IsNullOrEmpty(this.txtFolder.Text)) { MessageBox.Show("Folder is Empty!!!!!", "Happy Code"); return; } packageIds.Clear(); foreach (string var in this.txtPackages.Lines) { if (var.Trim() != string.Empty) { packageIds.Add(var); } } progPack.Value = 0; //CheckThread = new System.Threading.Thread(new ThreadStart(RunCheck)); //CheckThread.Start(); timer1.Start(); }
private void btnReport_Click(object sender, System.EventArgs e) { if (!CReg.CanRun()) { MessageBox.Show("Please register software!!", "Happy Code"); return; } if (dgResult.Rows.Count == 0) { MessageBox.Show("Check Result is Empty!!", "Happy Code"); return; } copyAlltoClipboard(); Microsoft.Office.Interop.Excel.Application xlApp; Microsoft.Office.Interop.Excel.Workbook xlWorkBook; Microsoft.Office.Interop.Excel.Worksheet xlWorkSheet; object misValue = System.Reflection.Missing.Value; xlApp = new Excel.Application(); if (xlApp == null) { MessageBox.Show("Excel is not properly installed!!", "Happy Code"); return; } //xlApp.Visible = true; CultureInfo ci = new CultureInfo("en-US"); xlWorkBook = (Excel.Workbook)xlApp.Workbooks.GetType().InvokeMember("Add", BindingFlags.InvokeMethod, null, xlApp.Workbooks, null, ci); xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1); Excel.Range CR = (Excel.Range)xlWorkSheet.Cells[2, 1]; CR.GetType().InvokeMember("Select", BindingFlags.InvokeMethod, null, CR, null, ci); var p = new object[] { CR, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, true }; xlWorkSheet.GetType().InvokeMember("PasteSpecial", BindingFlags.InvokeMethod, null, xlWorkSheet, p, ci); for (int i = 0; i < dgResult.ColumnCount; i++) { p = new object[] { dgResult.Columns[i].HeaderText }; CR = (Excel.Range)xlWorkSheet.Cells[1, i + 1]; CR.GetType().InvokeMember("Value", BindingFlags.SetProperty, null, CR, p, ci); } CR = xlWorkSheet.get_Range((Excel.Range)xlWorkSheet.Cells[1, 1], (Excel.Range)xlWorkSheet.Cells[1, dgResult.ColumnCount]); var interior = CR.GetType().InvokeMember("Interior", BindingFlags.GetProperty, null, CR, null, ci); interior.GetType().InvokeMember("ColorIndex", BindingFlags.SetProperty, null, interior, new object[] { 23 }, ci); var font = CR.GetType().InvokeMember("Font", BindingFlags.GetProperty, null, CR, null, ci); font.GetType().InvokeMember("Bold", BindingFlags.SetProperty, null, font, new object[] { true }, ci); font.GetType().InvokeMember("ColorIndex", BindingFlags.SetProperty, null, font, new object[] { 2 }, ci); font.GetType().InvokeMember("Size", BindingFlags.SetProperty, null, font, new object[] { 14 }, ci); CR = xlWorkSheet.get_Range((Excel.Range)xlWorkSheet.Cells[1, 1], (Excel.Range)xlWorkSheet.Cells[dgResult.RowCount, dgResult.ColumnCount]); CR.Columns.GetType().InvokeMember("AutoFit", BindingFlags.InvokeMethod, null, CR.Columns, null, ci); CR = (Excel.Range)xlWorkSheet.Cells[1, 1]; CR.GetType().InvokeMember("Select", BindingFlags.InvokeMethod, null, CR, null, ci); string tmpPath = System.Environment.GetEnvironmentVariable("TEMP"); string extname = ".xls"; string prefix = "MemoryLeakReport_"; string outputFilename = prefix + DateTime.Now.ToString("yyyyMMddHHmmss") + extname; string fullFilename = Path.Combine(tmpPath, outputFilename); p = new object[] { fullFilename, Excel.XlFileFormat.xlWorkbookNormal, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Excel.XlSaveAsAccessMode.xlExclusive, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing }; xlWorkBook.GetType().InvokeMember("SaveAs", BindingFlags.InvokeMethod, null, xlWorkBook, p, ci); p = new object[] { Type.Missing, Type.Missing }; xlWorkBook.GetType().InvokeMember("Close", BindingFlags.InvokeMethod, null, xlWorkBook, p, ci); xlApp.Quit(); if (CR != null) { releaseObject(CR); } if (xlWorkSheet != null) { releaseObject(xlWorkSheet); } if (xlWorkSheet != null) { releaseObject(xlWorkSheet); } if (xlWorkBook != null) { releaseObject(xlWorkBook); } if (xlApp != null) { releaseObject(xlApp); } System.Diagnostics.Process.Start(fullFilename); }