Exemplo n.º 1
0
        private void ExportOperationsLogFile(string outputFilePath, bool showCompletedPopup)
        {
            string logToExport = string.Empty;
            dgvOutputOperations.ClearSelection();
            DataSet set = new DataSet("Customizations Log Set");

            DataTable table = new DataTable("Checked Operations Log");
            table.Columns.Add("Step");
            table.Columns.Add("Comment");
            table.Columns.Add("Operation");

            DataTable tableOriginal = new DataTable("Original Operations Log");
            tableOriginal.Columns.Add("Step");
            tableOriginal.Columns.Add("Comment");
            tableOriginal.Columns.Add("Operation");

            DataTable tableLinkedFiles = new DataTable("Linked File List");
            tableLinkedFiles.Columns.Add("FileLink");
            tableLinkedFiles.Columns.Add("RelativePath");

            for (int i = 0; i < dgvOutputOperations.Rows.Count; i++) {
                if ((bool)dgvOutputOperations.Rows[i].Cells["CommentUsage"].Value == true) {
                    if (!string.Equals(dgvOutputOperations.Rows[i].Cells["Comment"].Value, "")) {
                        table.Rows.Add(new object[] { dgvOutputOperations.Rows[i].Cells["Steps"].Value,
                                                      dgvOutputOperations.Rows[i].Cells["Comment"].Value,
                                                      dgvOutputOperations.Rows[i].Cells["Operations"].Value});
                    }
                }
                tableOriginal.Rows.Add(new object[] { dgvOutputOperations.Rows[i].Cells["Steps"].Value,
                                                      dgvOutputOperations.Rows[i].Cells["Comment"].Value,
                                                      dgvOutputOperations.Rows[i].Cells["Operations"].Value});
            }

            for (int j = 0; j < dgvFilesToImport.Rows.Count; j++) {
                tableLinkedFiles.Rows.Add(new object[] {dgvFilesToImport.Rows[j].Cells["fileLink"].Value,
                                                        dgvFilesToImport.Rows[j].Cells["relativePath"].Value});
            }

            set.Tables.Add(tableLinkedFiles);
            set.Tables.Add(table);
            set.Tables.Add(tableOriginal);
            ExportExcelObject exportExcelObject = new ExportExcelObject();
            exportExcelObject.exportDataSet = set;
            exportExcelObject.outputFilePath = outputFilePath;
            exportExcelObject.showCompletedPopup = showCompletedPopup;
            bwExcelExporter.RunWorkerAsync(exportExcelObject);
            //FastExportingMethod.ExportToExcel(set, outputFilePath);
        }
Exemplo n.º 2
0
        public void StartComparison(string filename1, string filename2)
        {
            //  List<string> file1_sheets = GetExcelSheets(filename1);
              //  List<string> file2_sheets = GetExcelSheets(filename2);
            List<DataTable> tableImportedFile1= Import(filename1);
            List<DataTable> tableImportedFile2 = Import(filename2);

            //// Create connection string variable. Modify the "Data Source"
            //// parameter as appropriate for your environment.
            //String sConnectionString1 = "Provider=Microsoft.ACE.OLEDB.12.0;" +
            //"Data Source=" + filename1 + ";" +
            //"Extended Properties=Excel 12.0;";

            //String sConnectionString2 = "Provider=Microsoft.ACE.OLEDB.12.0;" +
            //"Data Source=" + filename2 + ";" +
            //"Extended Properties=Excel 12.0;";

            //// Create connection object by using the preceding connection string.
            //OleDbConnection objConnfileOne = new OleDbConnection(sConnectionString1);
            //OleDbConnection objConnFileTwo = new OleDbConnection(sConnectionString2);

            //// Open connection with the database.
            //objConnfileOne.Open();
            //objConnFileTwo.Open();
            // The code to follow uses a SQL SELECT command to display the data from the worksheet.
            DataSet set = new DataSet("Changes Set");
            DataTable dtResult = new DataTable();

            foreach (DataTable table in tableImportedFile1) {

                foreach (DataTable table2 in tableImportedFile2) {
                    if (string.Equals(table.TableName, table2.TableName) && !table.TableName.Contains("Sheet")) {
                        table.TableName = table.TableName ;
                        table2.TableName = table2.TableName + "-in-SheetTwo";
                        dtResult = getDifferentRecords(table, table2);
                        dtResult.TableName = table.TableName+"-Diff";
                        set.Tables.Add(dtResult);
                    }
                }

            }

            //for (int i = 0; i < file1_sheets.Count; i++) {
            //    if (file2_sheets.Contains(file1_sheets[i])) {
            //        DataTable sheetToDataTableOne = GetDataTableFromSheet(file1_sheets[i], objConnfileOne);
            //        sheetToDataTableOne.TableName = file1_sheets[i] + "-in-SheetOne";
            //        DataTable sheetToDataTableTwo = GetDataTableFromSheet(file1_sheets[i], objConnFileTwo);
            //        sheetToDataTableOne.Merge(sheetToDataTableTwo);
            //        DataTable table3 = sheetToDataTableOne.GetChanges();

            //        sheetToDataTableTwo.TableName = file2_sheets[i] + "-in-SheetTwo";
            //        dtResult = getDifferentRecords(sheetToDataTableOne, sheetToDataTableTwo);
            //        dtResult.TableName = file1_sheets[i] + "-Results";
            //        set.Tables.Add(dtResult);
            //    }
            //}

            //// Clean up objects.
            //objConnfileOne.Close();
            //objConnFileTwo.Close();

            SaveFileDialog dialog = new SaveFileDialog();
            dialog.Title = "Enter file name to save comparison results";
            dialog.DefaultExt = ".xls";
            dialog.Filter = "Execl files (*.xls)|*.xls";
            DialogResult dialogResult = dialog.ShowDialog();

            if (dialogResult == DialogResult.OK) {
                if (!string.IsNullOrEmpty(dialog.FileName)) {
                    ExportExcelObject exportExcelObject = new ExportExcelObject();
                    exportExcelObject.exportDataSet = set;
                    exportExcelObject.outputFilePath = dialog.FileName;
                    exportExcelObject.showCompletedPopup = true;
                    bwExcelExporter.RunWorkerAsync(exportExcelObject);
                    //FastExportingMethod.ExportToExcel(set, dialog.FileName);
                    //FrontendUtils.ShowInformation("Results generation completed!", false);
                } else {
                    FrontendUtils.ShowInformation("Please select a file name!", true);
                }
            }
        }