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); } ; } } }
protected void btn_manImport_Click(object sender, EventArgs e) { ErrMsgDiv1.Visible = false; ErrMsgDiv2.Visible = false; string yrmo = ddlYrmo.SelectedItem.Text; string fn1, fn2, fn3, fn4, fn5; string strFilePath1, strFilePath2, strFilePath3, strFilePath4, strFilePath5; List <string> filepaths = new List <string>(); List <string> sources = new List <string>(); string wiredt = tbx_manWiredt.Text; if (Page.IsValid) { if (txtPrevYRMO.Visible) { lbl_error1.Text = "Enter YRMO in format 'yyyymm'"; return; } if (yrmo.Length == 0 || yrmo.Length != 6) { Alert.Show("Please Enter YRMO in format yyyymm"); return; } if (tbx_manWiredt.Text == "" || tbx_manWiredt.Text.Length == 0) { Alert.Show("Please Enter Wire Date in the format yyyymm"); return; } strFilePath1 = ""; strFilePath2 = ""; strFilePath3 = ""; strFilePath4 = ""; strFilePath5 = ""; if (FileUpload1_OC.GotFile || FileUpload1_Cigna.GotFile || FileUpload1_UHC.GotFile || FileUpload1_Disab.GotFile || FileUpload1_Anth.GotFile || wiredt != String.Empty) { try { if (FileUpload1_OC.GotFile) { fn1 = System.IO.Path.GetFileName(FileUpload1_OC.FilePost.FileName); strFilePath1 = Server.MapPath("~/uploads/") + fn1; if (File.Exists(strFilePath1)) { File.Delete(strFilePath1); } FileUpload1_OC.FilePost.SaveAs(strFilePath1); filepaths.Add(strFilePath1); sources.Add(source_OC); } if (FileUpload1_Cigna.GotFile) { fn2 = System.IO.Path.GetFileName(FileUpload1_Cigna.FilePost.FileName); strFilePath2 = Server.MapPath("~/uploads/") + fn2; if (File.Exists(strFilePath2)) { File.Delete(strFilePath2); } FileUpload1_Cigna.FilePost.SaveAs(strFilePath2); filepaths.Add(strFilePath2); sources.Add(source_Cigna); } if (FileUpload1_UHC.GotFile) { fn3 = System.IO.Path.GetFileName(FileUpload1_UHC.FilePost.FileName); strFilePath3 = Server.MapPath("~/uploads/") + fn3; if (File.Exists(strFilePath3)) { File.Delete(strFilePath3); } FileUpload1_UHC.FilePost.SaveAs(strFilePath3); filepaths.Add(strFilePath3); sources.Add(source_UHC); } if (FileUpload1_Disab.GotFile) { fn4 = System.IO.Path.GetFileName(FileUpload1_Disab.FilePost.FileName); strFilePath4 = Server.MapPath("~/uploads/") + fn4; if (File.Exists(strFilePath4)) { File.Delete(strFilePath4); } FileUpload1_Disab.FilePost.SaveAs(strFilePath4); filepaths.Add(strFilePath4); sources.Add(source_Disab); } if (FileUpload1_Anth.GotFile) { fn5 = System.IO.Path.GetFileName(FileUpload1_Anth.FilePost.FileName); strFilePath5 = Server.MapPath("~/uploads/") + fn5; if (File.Exists(strFilePath5)) { File.Delete(strFilePath5); } ; FileUpload1_Anth.FilePost.SaveAs(strFilePath5); filepaths.Add(strFilePath5); sources.Add(source_Anth); } if (ImportFile(filepaths, sources, wiredt)) { View_Result(); } } catch (Exception ex) { resultdiv.Visible = false; VWAImportDAL.DeleteRemit(yrmo); ErrMsgDiv1.Visible = true; lbl_error1.Text = "Error - " + ex.Message; } finally { if (File.Exists(strFilePath1)) { File.Delete(strFilePath1); FileUpload1_OC.FilePost.InputStream.Flush(); FileUpload1_OC.FilePost.InputStream.Close(); FileUpload1_OC.FilePost.InputStream.Dispose(); } if (File.Exists(strFilePath2)) { File.Delete(strFilePath2); FileUpload1_Cigna.FilePost.InputStream.Flush(); FileUpload1_Cigna.FilePost.InputStream.Close(); FileUpload1_Cigna.FilePost.InputStream.Dispose(); } if (File.Exists(strFilePath3)) { File.Delete(strFilePath3); FileUpload1_UHC.FilePost.InputStream.Flush(); FileUpload1_UHC.FilePost.InputStream.Close(); FileUpload1_UHC.FilePost.InputStream.Dispose(); } if (File.Exists(strFilePath4)) { File.Delete(strFilePath4); FileUpload1_Disab.FilePost.InputStream.Flush(); FileUpload1_Disab.FilePost.InputStream.Close(); FileUpload1_Disab.FilePost.InputStream.Dispose(); } if (File.Exists(strFilePath5)) { File.Delete(strFilePath5); FileUpload1_Anth.FilePost.InputStream.Flush(); FileUpload1_Anth.FilePost.InputStream.Close(); FileUpload1_Anth.FilePost.InputStream.Dispose(); } } } } }