private void btnUploadDocs_Click(object sender, EventArgs e) { if (!File.Exists(txtUploadDocs.Text.Trim())) { MessageBox.Show("Please select ATS results file"); return; } FileInfo payRollfileInfo = new FileInfo(txtUploadDocs.Text.Trim()); var payRollFileStatus = IsFileLocked(payRollfileInfo); if (!payRollFileStatus) { MessageBox.Show("Sorry, ATS Results file is already in use Please close all open instances."); return; } if (txtUserName.Text.Trim().Length <= 3) { MessageBox.Show("Please enter user name"); return; } else if (txtPassword.Text.Trim().Length <= 3) { MessageBox.Show("Please enter password"); return; } ShowProgressingDialog(); extract programObj = new extract(); try { var ATSResults = programObj.ReadExcelSpecificRowsFile(txtUploadDocs.Text.Trim(), Convert.ToInt32(txtRecordsFrom.Text) - 1, Convert.ToInt32(txtRecordsTo.Text) - 1); List <LaserFischeDto> laserFischeDtoList = new List <LaserFischeDto>(); var filePath = Path.GetDirectoryName(txtUploadDocs.Text.Trim()); foreach (DataRow row in ATSResults.Rows) { LaserFischeDto laserFischeDto = new LaserFischeDto(); laserFischeDto.UniqueId = row["candidateassesmentdocuploadid"].ToString(); laserFischeDto.UploadPath = "\\Assessments\\"; laserFischeDto.FileName = row["AssesmentFileName"].ToString(); Byte[] bytes = File.ReadAllBytes(filePath + "\\" + laserFischeDto.FileName); String file = Convert.ToBase64String(bytes); laserFischeDto.Base64Content = file; laserFischeDtoList.Add(laserFischeDto); } var laserFischeList = UploadDocuments(laserFischeDtoList); ATSResults.Columns.Add("DocEntryId"); int i = 0; foreach (var item in laserFischeList) { ATSResults.Rows[i]["DocEntryId"] = item.DocEntryId; if (item.DocEntryId > 0) { ATSResults.Rows[i]["UploadedToLaserFische"] = "Yes"; } i++; } string[] columnNames = (from dc in ATSResults.Columns.Cast <DataColumn>() select dc.ColumnName).ToArray(); programObj.SaveFileInSpecifiedPathXLSX(ATSResults, columnNames, filePath + "\\ATSResultsFile_" + txtRecordsFrom.Text + "_" + txtRecordsTo.Text + ".xlsx"); Assessments AssessmentsObj = new Assessments(txtUserName.Text.Trim(), "Santhosh Komarraju"); AssessmentsObj.UpdateCandidateInfo(ATSResults); HideProgressingDialog(); MessageBox.Show("UploadDocuments Completed"); } catch (Exception ex) { HideProgressingDialog(); logger.Error(ex.Message); MessageBox.Show("UploadDocuments Faild " + ex.Message); } }
private void btnLogin_Click(object sender, EventArgs e) { if (!File.Exists(txtTab3ResultFile.Text.Trim())) { MessageBox.Show("Please select result file"); return; } FileInfo payRollfileInfo = new FileInfo(txtTab3ResultFile.Text.Trim()); var payRollFileStatus = IsFileLocked(payRollfileInfo); if (!payRollFileStatus) { MessageBox.Show("Sorry, Results file is already in use Please close all open instances."); return; } try { ShowProgressingDialog(); extract programObj = new extract(); if (mergedResultSet == null) { mergedResultSet = programObj.ReadExcelFile(txtTab3ResultFile.Text.Trim()); } Assessments AssessmentsObj = new Assessments(txtUserName.Text.Trim(), "Santhosh Komarraju"); mergedResultSet = mergedResultSet.AsEnumerable() .Where(r => r.Field <string>("EmployeeNo") != "") .CopyToDataTable(); //CreatedByName can get after we loged in DataSet resultTables = AssessmentsObj.SaveCandidateInfo(mergedResultSet); if (resultTables.Tables.Count >= 1) { if (resultTables.Tables[0].Rows.Count >= 1) { string[] columnNames = (from dc in resultTables.Tables[0].Columns.Cast <DataColumn>() select dc.ColumnName).ToArray(); var filePath = Path.GetDirectoryName(txtTab3ResultFile.Text.Trim()) + "\\ATSResultsFile.xlsx"; programObj.SaveFileInSpecifiedPathXLSX(resultTables.Tables[0], columnNames, filePath); HideProgressingDialog(); MessageBox.Show("Assessment Meta Data to ATS is Completed"); tabControl1.SelectedIndex = 2; txtUploadDocs.Text = filePath; } } else { HideProgressingDialog(); MessageBox.Show("Assessment Meta Data to ATS is failed"); } } catch (Exception ex) { HideProgressingDialog(); logger.Error(ex.Message); MessageBox.Show("Assessment Meta Data to ATS is " + ex.Message); } }