Пример #1
0
        private static void Insert_SMSMessage(DataTable table)
        {
            classDataAccess ebankDataAccess = new classDataAccess();
            classDataAccess dwDataAccess    = new classDataAccess();

            ebankDataAccess.OpenConnection("EBANK_GW");
            dwDataAccess.OpenConnection("CW_DW");

            string message      = "";
            int    count_succ   = 0;
            int    count_err_dw = 0;
            int    count_err_eb = 0;
            string mobile       = classUtilities.GetStringValueFromConfig("MyPhone1");
            string mobile2      = classUtilities.GetStringValueFromConfig("MyPhone2");
            string mobile3      = classUtilities.GetStringValueFromConfig("MyPhone3");
            string mobile4      = classUtilities.GetStringValueFromConfig("MyPhone4");
            string mobile7      = classUtilities.GetStringValueFromConfig("MyPhone7");

            foreach (DataRow row in table.Rows)
            {
                string available = "";
                if (double.Parse(row.ItemArray[12].ToString()) < double.Parse(row.ItemArray[13].ToString()))
                {
                    available = row.ItemArray[12].ToString();
                }
                else
                {
                    available = row.ItemArray[13].ToString();
                }

                if (row.ItemArray[15].ToString() == "ThanhToan")//hhhh
                //message = CreateSMSMessageThuNo(row.ItemArray[4].ToString(), row.ItemArray[2].ToString(), row.ItemArray[5].ToString(),
                //                                row.ItemArray[6].ToString(), row.ItemArray[7].ToString(), available, row.ItemArray[17].ToString(), row.ItemArray[14].ToString(), row.ItemArray[19].ToString());
                {
                    message = CreateSMSMessageThuNo_160(row.ItemArray[4].ToString(), row.ItemArray[2].ToString(), row.ItemArray[5].ToString(),
                                                        row.ItemArray[6].ToString(), row.ItemArray[7].ToString(), available, row.ItemArray[17].ToString(), row.ItemArray[14].ToString(), row.ItemArray[19].ToString());
                }
                else
                {
                    message = CreateSMSMessageTatToan(row.ItemArray[4].ToString(), row.ItemArray[2].ToString(), row.ItemArray[5].ToString(),
                                                      row.ItemArray[6].ToString(), row.ItemArray[18].ToString(), available, row.ItemArray[17].ToString(), row.ItemArray[14].ToString(), row.ItemArray[19].ToString());
                }
                if (string.IsNullOrEmpty(message) == false)
                {
                    int flag_fpt = 0;
                    int flag_eb  = 0;
                    if (row.ItemArray[1].ToString() == "khong co")
                    {
                        flag_fpt = dwDataAccess.InsertThuNoTatToanIPPSMSToDW(SMS_TYPE, message
                                                                             , row.ItemArray[1].ToString() //    ,long.Parse(row.ItemArray[10].ToString())
                                                                             , DateTime.Parse(row.ItemArray[0].ToString())
                                                                                                           //, row.ItemArray[2].ToString()
                                                                             , row.ItemArray[11].ToString()
                                                                             , row.ItemArray[4].ToString()
                                                                             , row.ItemArray[3].ToString()
                                                                             , row.ItemArray[5].ToString()               //    , long.Parse(row.ItemArray[5].ToString())
                                                                             , row.ItemArray[6].ToString()               //    , long.Parse(row.ItemArray[6].ToString())
                                                                             , row.ItemArray[8].ToString()               //    , long.Parse(row.ItemArray[7].ToString())
                                                                             , double.Parse(row.ItemArray[7].ToString()) //    , int.Parse(row.ItemArray[8].ToString())
                                                                             , row.ItemArray[9].ToString()
                                                                             , "Y"
                                                                             , row.ItemArray[16].ToString()
                                                                             );
                    }
                    else
                    {
                        flag_fpt = dwDataAccess.InsertThuNoTatToanIPPSMSToDW(SMS_TYPE, message
                                                                             , row.ItemArray[1].ToString() //    ,long.Parse(row.ItemArray[10].ToString())
                                                                             , DateTime.Parse(row.ItemArray[0].ToString())
                                                                                                           //, row.ItemArray[2].ToString()
                                                                             , row.ItemArray[11].ToString()
                                                                             , row.ItemArray[4].ToString()
                                                                             , row.ItemArray[3].ToString()
                                                                             , row.ItemArray[5].ToString()               //    , long.Parse(row.ItemArray[5].ToString())
                                                                             , row.ItemArray[6].ToString()               //    , long.Parse(row.ItemArray[6].ToString())
                                                                             , row.ItemArray[8].ToString()               //    , long.Parse(row.ItemArray[7].ToString())
                                                                             , double.Parse(row.ItemArray[7].ToString()) //    , int.Parse(row.ItemArray[8].ToString())
                                                                             , row.ItemArray[9].ToString()
                                                                             , "N"
                                                                             , row.ItemArray[16].ToString()
                                                                             );
                    }
                    if (flag_fpt == 0)
                    {
                        classThuNoTatToanIPPLogWriter.WriteLog("card no " + row.ItemArray[11].ToString() + " can't insert DB DW");
                        count_err_dw++;
                    }
                    else
                    {
                        //mobile = classUtilities.GetMobileFromCardNoOfSpecialList(row.ItemArray[2].ToString(), row.ItemArray[1].ToString());
                        if (row.ItemArray[1].ToString() == "khong co")
                        {
                            flag_eb = ebankDataAccess.InsertSMSMessateToEBankGW( //classDataAccess.IDALERT
                                row.ItemArray[10].ToString()
                                , row.ItemArray[1].ToString()                    //classUtilities.GetRandomMobile()
                                , message
                                , 'Y'                                            //Y: se ko gui tin nhan),//N: se gui tin nhan
                                , SMS_TYPE);
                        }
                        else
                        {
                            string mobile_spe = classUtilities.GetMobileFromCardNoOfSpecialList2(row.ItemArray[11].ToString());
                            if (mobile_spe == "000")                                 // the phu khong thuoc ds dac biet
                            {
                                flag_eb = ebankDataAccess.InsertSMSMessateToEBankGW( //classDataAccess.IDALERT
                                    row.ItemArray[10].ToString()
                                    , row.ItemArray[1].ToString()                    //classUtilities.GetRandomMobile()
                                    , message
                                    , 'N'                                            //Y: se ko gui tin nhan),//N: se gui tin nhan
                                    , SMS_TYPE);
                            }
                            else //the phu thuoc ds dac biet
                            {
                                flag_eb = ebankDataAccess.InsertSMSMessateToEBankGW(//classDataAccess.IDALERT
                                    row.ItemArray[10].ToString()
                                    , mobile_spe
                                    , message
                                    , 'N'                          //Y: se ko gui tin nhan),//N: se gui tin nhan
                                    , SMS_TYPE);
                            }
                        }

                        if (flag_eb == 0)
                        {
                            classThuNoTatToanIPPLogWriter.WriteLog("mobi no " + row.ItemArray[1].ToString() + " can't insert DB EB");
                            classThuNoTatToanIPPLogWriter.WriteLog("card no " + row.ItemArray[11].ToString() + " can't insert DB EB");
                            dwDataAccess.Update_Status_SMS(//update status sms ve loi ko gui qua EW
                                row.ItemArray[11].ToString(),
                                row.ItemArray[5].ToString(),
                                row.ItemArray[16].ToString(),
                                "E"
                                );
                            count_err_eb++;
                        }
                        else
                        {
                            count_succ++;
                        }
                    }
                }
            }
            ebankDataAccess.CloseConnection();
            dwDataAccess.CloseConnection();
            if (count_err_dw > 0)
            {
                SendSMSForDW_FPT(mobile, count_err_dw);
                SendSMSForDW_FPT(mobile2, count_err_dw);
                SendSMSForDW_FPT(mobile3, count_err_dw);
                SendSMSForDW_FPT(mobile4, count_err_dw);
                SendSMSForDW_FPT(mobile7, count_err_dw);
            }
            if (count_err_eb > 0)
            {
                SendSMSForGW_EB(mobile, count_err_eb);
                SendSMSForGW_EB(mobile2, count_err_eb);
                SendSMSForGW_EB(mobile3, count_err_eb);
                SendSMSForGW_EB(mobile4, count_err_eb);
                SendSMSForGW_EB(mobile7, count_err_eb);
            }

            classThuNoTatToanIPPLogWriter.WriteLog("Message da duoc Insert vao EbankGW thanh cong: " + count_succ);
            classThuNoTatToanIPPLogWriter.WriteLog("Message loi khong duoc Insert vao EbankGW: " + count_err_eb);
            classThuNoTatToanIPPLogWriter.WriteLog("Message loi khong duoc Insert vao DW: " + count_err_dw);
            return;
        }