示例#1
0
    public bool process(string fileSeparate)
    {
        try
        {
            DataTable fileData = new DataTable();
            UploadLog(ddlCompanyCode.SelectedValue, ViewState["fileName"].ToString(), Session["UserId"].ToString(), "Get data from file Start", DateTime.Now.ToString());
            Get_data(ViewState["filepath"].ToString(), fileSeparate);
            UploadLog(ddlCompanyCode.SelectedValue, ViewState["fileName"].ToString(), Session["UserId"].ToString(), "Get data from file and records length " + dt.Rows.Count.ToString() + " End", DateTime.Now.ToString());

            string sp_name = "";
            if (dt.Rows.Count > 0)
            {
                string retvalue = "";
                DBUniversalUploadProcess Upload = new DBUniversalUploadProcess();
                retvalue = Upload.UploadProcess(dt.Rows.Count, dt, ddlCompanyCode.SelectedValue, ddlConfigID.SelectedValue, ViewState["fileName"].ToString());
                //sp_name = retvalue.Split(';').GetValue(1).ToString();
                sp_name = retvalue.IndexOf(';') > 0 ? retvalue.Split(';').GetValue(1).ToString() : retvalue;
                if (retvalue.StartsWith("0") == true)
                {
                    lbl_Message.Text           = retvalue.Split(';').GetValue(1).ToString();
                    lblA2A.Text                = "";
                    lblPRI.Text                = "";
                    lblCOC.Text                = "";
                    lblDD.Text                 = "";
                    lblDuplicateRecords.Text   = "";
                    lblInvalidIBANRecords.Text = "";
                    lblTotalRecord.Text        = "";
                    lblTotalAmount.Text        = "";

                    lblA2ATOT.Text  = "";
                    lblPRITOT.Text  = "";
                    lblCOCTOT.Text  = "";
                    lblDDTOT.Text   = "";
                    lblDUPTOT.Text  = "";
                    lblIBANTOT.Text = "";

                    if (File.Exists(ViewState["filepath"].ToString()) == true)
                    {
                        File.Delete(ViewState["filepath"].ToString());
                    }
                    UploadLog(ddlCompanyCode.SelectedValue, ViewState["fileName"].ToString(), Session["UserId"].ToString(), "Error on SP_RAW_DATALOAD : " + retvalue + " and file deleted at local path", DateTime.Now.ToString());
                    return(false);
                }
                else
                {
                    string TransType = (chTransDD.Checked == true) ? "Y" : "N";
                    UploadLog(ddlCompanyCode.SelectedValue, ViewState["fileName"].ToString(), Session["UserId"].ToString(), "Call SP_RAW_DATALOAD1 Start", DateTime.Now.ToString());
                    retvalue = Upload.MianProcess(ddlCompanyCode.SelectedValue, ddlConfigID.SelectedValue, ViewState["fileName"].ToString(), TransType, sp_name);
                    UploadLog(ddlCompanyCode.SelectedValue, ViewState["fileName"].ToString(), Session["UserId"].ToString(), "Call SP_RAW_DATALOAD1 and return value " + retvalue + " End", DateTime.Now.ToString());

                    lbl_Message.Text = retvalue.IndexOf(';') > 0 ? retvalue.Split(';').GetValue(1).ToString() : retvalue;
                    //retvalue.Split(';').GetValue(1).ToString();
                    DataSet ds1 = new DataSet();
                    if (retvalue.StartsWith("1") == true)
                    {
                        DBProcess spProcess = new DBProcess();
                        spProcess.RecordInputStart();
                        spProcess.Get_Company_Code  = ddlCompanyCode.SelectedValue;
                        spProcess.Get_Conf_ID       = ddlConfigID.SelectedValue;
                        spProcess.Get_FileName      = ViewState["fileName"].ToString();
                        spProcess.Get_UserID        = Session["UserId"].ToString();
                        spProcess.Get_TOTAL_RECORDS = dt.Rows.Count.ToString();
                        spProcess.RecordInputCommit();
                        spProcess.AddNewGroup();


                        #region Summary and Duplication
                        UploadLog(ddlCompanyCode.SelectedValue, ViewState["fileName"].ToString(), Session["UserId"].ToString(), "Get data for file summary Start", DateTime.Now.ToString());
                        ds1 = lov.GetFileSummary(ddlCompanyCode.SelectedValue, ViewState["fileName"].ToString());
                        UploadLog(ddlCompanyCode.SelectedValue, ViewState["fileName"].ToString(), Session["UserId"].ToString(), "Get data for file summary End", DateTime.Now.ToString());

                        lblIBFT.Text               = ds1.Tables[0].Rows[0]["IBFT"].ToString();
                        lblA2A.Text                = ds1.Tables[0].Rows[0]["A2A"].ToString();
                        lblPRI.Text                = ds1.Tables[0].Rows[0]["PRI"].ToString();
                        lblCOC.Text                = ds1.Tables[0].Rows[0]["COC"].ToString();
                        lblDD.Text                 = ds1.Tables[0].Rows[0]["DD"].ToString();
                        lblDuplicateRecords.Text   = ds1.Tables[1].Rows[0]["DuplicateRecords"].ToString();
                        lblInvalidIBANRecords.Text = ds1.Tables[1].Rows[0]["InvalidIBANRecords"].ToString();

                        /*filerecodsSp = Convert.ToInt32(ds1.Tables[0].Rows[0]["total_records"])
                         +Convert.ToInt32(ds1.Tables[1].Rows[0]["DuplicateRecords"]);*/

                        lblIBFTTOT.Text = ds1.Tables[0].Rows[0]["IBFTTOT"].ToString();
                        lblA2ATOT.Text  = ds1.Tables[0].Rows[0]["A2ATOT"].ToString();
                        lblPRITOT.Text  = ds1.Tables[0].Rows[0]["PRITOT"].ToString();
                        lblCOCTOT.Text  = ds1.Tables[0].Rows[0]["COCTOT"].ToString();
                        lblDDTOT.Text   = ds1.Tables[0].Rows[0]["DDTOT"].ToString();
                        lblDUPTOT.Text  = ds1.Tables[1].Rows[0]["DUPTOT"].ToString();
                        lblIBANTOT.Text = ds1.Tables[1].Rows[0]["IBANTOT"].ToString();

                        lblTotalAmount.Text = Convert.ToString(Convert.ToDecimal(ds1.Tables[0].Rows[0]["TotalAmount"]) + Convert.ToDecimal(ds1.Tables[1].Rows[0]["DUPTOT"]) + Convert.ToDecimal(ds1.Tables[1].Rows[0]["IBANTOT"]));
                        int count = Convert.ToInt32(ds1.Tables[0].Rows[0]["IBFT"]) +
                                    Convert.ToInt32(ds1.Tables[0].Rows[0]["A2A"]) +
                                    Convert.ToInt32(ds1.Tables[0].Rows[0]["PRI"]) +
                                    Convert.ToInt32(ds1.Tables[0].Rows[0]["COC"]) +
                                    Convert.ToInt32(ds1.Tables[0].Rows[0]["DD"]);
                        lblTotalRecord.Text = Convert.ToString(count + Convert.ToInt64(lblDuplicateRecords.Text) + Convert.ToInt64(lblInvalidIBANRecords.Text));

                        lbIBFT.Attributes.Add("style", "visibility:visible;");
                        lbA2A.Attributes.Add("style", "visibility:visible;");
                        lbPRI.Attributes.Add("style", "visibility:visible;");
                        lbCOC.Attributes.Add("style", "visibility:visible;");
                        lbDD.Attributes.Add("style", "visibility:visible;");
                        lbDuplicateRecords.Attributes.Add("style", "visibility:visible;");
                        lbIBANRecords.Attributes.Add("style", "visibility:visible;");
                        lbTotalTransaction.Attributes.Add("style", "visibility:visible;");
                        lbTotalAmount.Attributes.Add("style", "visibility:visible;");

                        if (Convert.ToInt32(lblDuplicateRecords.Text) > 0)
                        {
                            //lbDuplicateRecords
                            lbDuplicateRecords.Attributes["onmouseover"] = "javascript:setMouseOverColor(this);";
                            lbDuplicateRecords.Attributes["onmouseout"]  = "javascript:setMouseOutColor(this);";
                            string company_code = ddlCompanyCode.SelectedValue;
                            string file_name    = ViewState["fileName"].ToString();
                            lbDuplicateRecords.Attributes.Add("onclick", "var str='MCB';wid=window.open('duplicateRecord.aspx?company_code=" + company_code + "&file_name=" + file_name + "', 'CS', 'left=550,top=165,height=650, width= 450 ,menubar=no,location=no,toolbar=no,scrollbars=yes,resizable=yes');return false;");
                        }
                        else
                        {
                            lbDuplicateRecords.Attributes["onmouseover"] = "javascript:NODuplicate(this);";
                            lbDuplicateRecords.Attributes.Add("onclick", "return false");
                        }
                        if (Convert.ToInt32(lblInvalidIBANRecords.Text) > 0)
                        {
                            //lbDuplicateRecords
                            lbIBANRecords.Attributes["onmouseover"] = "javascript:setMouseOverColor(this);";
                            lbIBANRecords.Attributes["onmouseout"]  = "javascript:setMouseOutColor(this);";
                            string company_code = ddlCompanyCode.SelectedValue;
                            string file_name    = ViewState["fileName"].ToString();
                            lbIBANRecords.Attributes.Add("onclick", "var str='MCB';wid=window.open('IBANInvalidRecord.aspx?company_code=" + company_code + "&file_name=" + file_name + "', 'CS', 'left=550,top=165,height=650, width= 450 ,menubar=no,location=no,toolbar=no,scrollbars=yes,resizable=yes');return false;");
                        }
                        else
                        {
                            lbIBANRecords.Attributes["onmouseover"] = "javascript:NODuplicate(this);";
                            lbIBANRecords.Attributes.Add("onclick", "return false");
                        }


                        lblSummary.Visible = true;
                        lblrecord.Visible  = true;
                        lblamount.Visible  = true;
                        dt = lov.GetContactNoforSMS(ddlCompanyCode.SelectedValue, ViewState["fileName"].ToString(), "01").Tables[0];
                        if (dt.Rows.Count > 0)
                        {
                            int y = 0;
                            for (int i = 0; i < dt.Rows.Count; i++)
                            {
                                if (GenerateSMS(dt.Rows[i]["contactnumber"].ToString(), dt.Rows[i]["msg"].ToString()) == true)
                                {
                                    y = 1;
                                }
                            }
                            if (y == 1)
                            {
                                lbl_Message.Text += " and SMS has been sent to Beneficiary.";
                            }
                        }
                        #endregion
                    }
                }
            }
        }
        catch (Exception ex)
        {
            lbl_Message.Text = ex.Message;
        }

        UploadLog(ddlCompanyCode.SelectedValue, ViewState["fileName"].ToString(), Session["UserId"].ToString(), "In process method file delete at local path Start", DateTime.Now.ToString());
        if (File.Exists(ViewState["filepath"].ToString()) == true)
        {
            File.Delete(ViewState["filepath"].ToString());
        }
        UploadLog(ddlCompanyCode.SelectedValue, ViewState["fileName"].ToString(), Session["UserId"].ToString(), "In process method file delete at local path End", DateTime.Now.ToString());
        return(true);
    }