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();
                }
            }
        }
    }
Example #3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["mid"] == null || Int32.Parse(Session["mid"].ToString()) == 0)
     {
         Response.Redirect("~/Home.aspx");
     }
     if (!Page.IsPostBack)
     {
         string uname = HttpContext.Current.User.Identity.Name.ToString();
         AdminBLL.InRole(uname, "M400", "M405");
         Session["yrmo"] = "";
         bindData();
         VWA_Results.SavePrintFiles(_category, Page.Request.QueryString["id"]);
     }
 }
Example #4
0
    protected void lnk_genRpts_OnClick(object sender, EventArgs e)
    {
        string yrmo = ddlYrmo.SelectedItem.Text;

        lbl_err.Text      = "";
        lbl_error.Visible = false;

        Session["VWAAgingDays"] = "";
        try
        {
            SetNoRecsMsg(yrmo);
            Session["VWAAgingDays"] = tbx_agedDays.Text.ToString();
            VWA_Results.SavePrintFiles(_category, yrmo);
            Session["taskId"] = Convert.ToInt32(Session["taskId"]) + 1;
            Audit.auditUserTaskR(Session.SessionID, Session["mid"].ToString(), Session["taskId"].ToString(), "VWA", "Transactions", "Create VWA Transaction Reports", DateTime.Today.ToString("yyyyMMdd"));
            resultdiv.Visible = true;
        }
        catch (Exception ex)
        {
            lbl_err.Text = "Error in generation reports<br />" + ex.Message;
        }
    }
    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);
                }
            }
        }
    }