Boolean ImportFile(List <string> filepaths, List <string> sources, string wiredt) { string _yrmo = ddlYrmo.SelectedItem.Text; bool importStat = false; VWA_ExcelImport tObj = new VWA_ExcelImport(); DataSet ds = new DataSet(); ds.Clear(); int _totalcounter = 0; for (int i = 0; i < filepaths.Count; i++) { VWAImportDAL.Rollback(sources[i], _yrmo); ds = tObj.importRemittance(filepaths[i], sources[i]); _counter = tObj.parseRemittance(ds, _yrmo, sources[i]); VWAImportDAL.insertImportStatus(_yrmo, sources[i]); SetImportStatus(sources[i]); _totalcounter += _counter; } VWAImportDAL.updateRemitWireDt(wiredt, _yrmo); VWA_Results.SavePrintFiles(source, _yrmo); Session["taskId"] = Convert.ToInt32(Session["taskId"]) + 1; Audit.auditUserTaskI(Session.SessionID, Session["mid"].ToString(), Session["taskId"].ToString(), "VWA", "VWA Imports", "VWA_remit", "Remittance Reports", _yrmo, _totalcounter); importStat = true; return(importStat); }
protected void btn_manImport_Click(object sender, EventArgs e) { string yrmo = ddlYrmo.SelectedItem.Text; lbl_error.Text = ""; lblError1.Text = ""; if (Page.IsValid) { if (txtPrevYRMO.Visible) { lbl_error.Text = "Enter YRMO in format 'yyyymm'"; return; } string strFilePath1 = ""; if (FileUpload1.GotFile) { try { string fn = System.IO.Path.GetFileName(FileUpload1.FilePost.FileName); strFilePath1 = Server.MapPath("~/uploads/") + fn; if (File.Exists(strFilePath1)) { File.Delete(strFilePath1); } FileUpload1.FilePost.SaveAs(strFilePath1); if (ImportFile(strFilePath1)) { bindResults(); VWA_Results.SavePrintFiles(source, yrmo); MultiView1.SetActiveView(view_result); lbl_result.Text = "Import completed successfully -- " + _counter + " records imported"; } } catch (Exception ex) { resultDiv.Visible = false; VWAImportDAL.Rollback(source, yrmo); lbl_error.Text = "Error - " + ex.Message; } finally { if (File.Exists(strFilePath1)) { File.Delete(strFilePath1); } FileUpload1.FilePost.InputStream.Flush(); FileUpload1.FilePost.InputStream.Close(); FileUpload1.FilePost.InputStream.Dispose(); } } } }
Boolean ImportFile(string strFilePath1) { string _yrmo = ddlYrmo.SelectedItem.Text; bool importStat = false; VWAImport vobj = new VWAImport(); VWAImportDAL.Rollback("BankStat", _yrmo); _counter = vobj.importBOA_VWA(_yrmo, strFilePath1); VWAImportDAL.insertImportStatus(_yrmo, source); Session["taskId"] = Convert.ToInt32(Session["taskId"]) + 1; Audit.auditUserTaskI(Session.SessionID, Session["mid"].ToString(), Session["taskId"].ToString(), "VWA", "VWA Imports", "VWA_Bank", "Bank Statement", _yrmo, _counter); importStat = true; return(importStat); }
protected void btn_autoImport_Click(object sender, EventArgs e) { Impersonation _imp = new Impersonation(); string yrmo = ddlYrmo.SelectedItem.Text; string clientfilename, clientfile, serverPath; string serverfile = ""; lbl_error.Text = ""; lblError1.Text = ""; if (Page.IsValid) { if (txtPrevYRMO.Visible) { lbl_error.Text = "Enter YRMO in format 'yyyymm'"; return; } try { serverPath = Server.MapPath("~/uploads/"); clientfilename = VWA.GetInputFileName(yrmo, source); serverfile = serverPath + clientfilename; if (_imp.impersonateValidUser(Session["uid"].ToString(), "CORP", EncryptDecrypt.Decrypt(Session["pwd"].ToString()))) { clientfile = VWAImportDAL.GetClientFilePath(_category, source) + "\\" + clientfilename; File.Copy(clientfile, serverfile); _imp.undoImpersonation(); } else { throw new Exception("Error in accessing network location"); } if (!(File.Exists(serverfile))) { throw new Exception("Unable to import file from specified location.<br/>Please check if file exists and you are logged in to the network."); } if (ImportFile(serverfile)) { bindResults(); VWA_Results.SavePrintFiles(source, yrmo); MultiView1.SetActiveView(view_result); lbl_result.Text = "Import completed successfully -- " + _counter + " records imported"; } else { throw new Exception("Unable to parse file.<br/>Please check file type and format."); } } catch (Exception ex) { resultDiv.Visible = false; VWAImportDAL.Rollback(source, yrmo); lbl_error.Text = "Error - " + ex.Message; } finally { if (File.Exists(serverfile)) { File.Delete(serverfile); } } } }