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); } } } }
void SetAutoImport() { upload_auto.Visible = true; upload_manually.Visible = false; if (VWAImportDAL.GetClientFilePath(_category, source).Trim() == String.Empty) { lbl_clientfile.Text = ""; } else { lbl_clientfile.Text = VWAImportDAL.GetClientFilePath(_category, source) + "\\" + VWA.GetInputFileName(ddlYrmo.SelectedItem.Value, source); } cbx_autoImport.Checked = false; }
protected void btn_autoImport_Click(object sender, EventArgs e) { Impersonation _imp = new Impersonation(); string yrmo = ddlYrmo.SelectedItem.Text; string clientfilename1, clientfilename2, clientfilename3, clientfilename4, clientfilename5; string clientfile1, clientfile2, clientfile3, clientfile4, clientfile5; string serverfile1, serverfile2, serverfile3, serverfile4, serverfile5; List <string> filepaths = new List <string>(); List <string> sources = new List <string>(); string wiredt = tbx_autoWiredt.Text; ErrMsgDiv1.Visible = false; ErrMsgDiv2.Visible = false; if (Page.IsValid) { if (txtPrevYRMO.Visible) { lbl_error1.Text = "Enter YRMO in format 'yyyymm'"; return; } serverfile1 = ""; serverfile2 = ""; serverfile3 = ""; serverfile4 = ""; serverfile5 = ""; try { clientfilename1 = VWA.GetInputFileName(yrmo, source_OC); clientfilename2 = VWA.GetInputFileName(yrmo, source_Cigna); clientfilename3 = VWA.GetInputFileName(yrmo, source_UHC); clientfilename4 = VWA.GetInputFileName(yrmo, source_Disab); clientfilename5 = VWA.GetInputFileName(yrmo, source_Anth); serverfile1 = Server.MapPath("~/uploads/") + clientfilename1; serverfile2 = Server.MapPath("~/uploads/") + clientfilename2; serverfile3 = Server.MapPath("~/uploads/") + clientfilename3; serverfile4 = Server.MapPath("~/uploads/") + clientfilename4; serverfile5 = Server.MapPath("~/uploads/") + clientfilename5; if (_imp.impersonateValidUser(Session["uid"].ToString(), "CORP", EncryptDecrypt.Decrypt(Session["pwd"].ToString()))) { clientfile1 = VWAImportDAL.GetClientFilePath(_category, source) + "\\" + clientfilename1; clientfile2 = VWAImportDAL.GetClientFilePath(_category, source) + "\\" + clientfilename2; clientfile3 = VWAImportDAL.GetClientFilePath(_category, source) + "\\" + clientfilename3; clientfile4 = VWAImportDAL.GetClientFilePath(_category, source) + "\\" + clientfilename4; clientfile5 = VWAImportDAL.GetClientFilePath(_category, source) + "\\" + clientfilename5; if (File.Exists(clientfile1) || File.Exists(clientfile2) || File.Exists(clientfile3) || File.Exists(clientfile4) || File.Exists(clientfile5) || wiredt != String.Empty) { if (File.Exists(clientfile1)) { File.Copy(clientfile1, serverfile1); filepaths.Add(serverfile1); sources.Add(source_OC); } if (File.Exists(clientfile2)) { File.Copy(clientfile2, serverfile2); filepaths.Add(serverfile2); sources.Add(source_Cigna); } if (File.Exists(clientfile3)) { File.Copy(clientfile3, serverfile3); filepaths.Add(serverfile3); sources.Add(source_UHC); } if (File.Exists(clientfile4)) { File.Copy(clientfile4, serverfile4); filepaths.Add(serverfile4); sources.Add(source_Disab); } if (File.Exists(clientfile5)) { File.Copy(clientfile5, serverfile5); filepaths.Add(serverfile5); sources.Add(source_Anth); } _imp.undoImpersonation(); } else { throw new Exception("Error in accessing network location"); } if (ImportFile(filepaths, sources, wiredt)) { View_Result(); } else { throw new Exception("Unable to parse reports.<br/>Please check reports type and format."); } } } catch (Exception ex) { resultdiv.Visible = false; VWAImportDAL.DeleteRemit(yrmo); ErrMsgDiv1.Visible = true; lbl_error1.Text = "Error - " + ex.Message; } finally { if (File.Exists(serverfile1)) { File.Delete(serverfile1); } ; if (File.Exists(serverfile2)) { File.Delete(serverfile2); } ; if (File.Exists(serverfile3)) { File.Delete(serverfile3); } ; if (File.Exists(serverfile4)) { File.Delete(serverfile4); } ; if (File.Exists(serverfile5)) { File.Delete(serverfile5); } ; } } }