Ejemplo n.º 1
0
        private static void Insert_SMSMessage(DataTable table, string crd_brn)
        {
            classDataAccess ebankDataAccess = new classDataAccess();
            classDataAccess dwDataAccess    = new classDataAccess();

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

            string message = "";
            int    result  = 0;
            int    count   = 0;

            foreach (DataRow row in table.Rows)
            {
                result  = 0;
                message = CreateSMSMessage(row.ItemArray[4].ToString(), row.ItemArray[2].ToString(), row.ItemArray[5].ToString(),
                                           row.ItemArray[6].ToString(), row.ItemArray[7].ToString(), row.ItemArray[8].ToString(), row.ItemArray[10].ToString(), crd_brn, row.ItemArray[11].ToString(), row.ItemArray[12].ToString());
                if (string.IsNullOrEmpty(message) == false)
                {
                    //mobile = classUtilities.GetMobileFromCardN oOfSpecialList(row.ItemArray[2].ToString(), row.ItemArray[1].ToString());
                    double ipp = 0;
                    if (row.ItemArray[10].ToString() != "")
                    {
                        ipp = double.Parse(row.ItemArray[10].ToString());
                    }
                    if (double.Parse(row.ItemArray[6].ToString()) >= 0 || double.Parse(row.ItemArray[6].ToString()) <= -100000 || ipp > 0)
                    {
                        if (row.ItemArray[1].ToString() == "khong co")
                        {
                            result = ebankDataAccess.InsertSMSMessateToEBankGW_2(classDataAccess.IDALERT
                                                                                 , row.ItemArray[1].ToString() //classDataAccess.MYPHONE
                                                                                 , message
                                                                                 , 'Y'                         // Y: se ko gui tin nhan, D: ko gui, N: gui, E:Error
                                                                                 , SMS_TYPE);
                        }
                        else
                        {
                            result = ebankDataAccess.InsertSMSMessateToEBankGW_2(classDataAccess.IDALERT
                                                                                 , row.ItemArray[1].ToString() //classDataAccess.MYPHONE
                                                                                 , message
                                                                                 , 'N'                         // hhhh Y: se ko gui tin nhan, D: ko gui, N: gui, E:Error
                                                                                 , SMS_TYPE);
                        }
                    }
                    else // 0 > closing > -100000 and don't have IPP, don't send
                    {
                        count += dwDataAccess.InsertReminderPayment_1SMSToDW(SMS_TYPE, message
                                                                             , row.ItemArray[1].ToString()//    ,long.Parse(row.ItemArray[10].ToString())
                                                                             , DateTime.Parse(row.ItemArray[0].ToString())
                                                                             , row.ItemArray[9].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())
                                                                             , double.Parse(row.ItemArray[7].ToString()) //    , long.Parse(row.ItemArray[7].ToString())
                                                                             , row.ItemArray[8].ToString()               //    , int.Parse(row.ItemArray[8].ToString())
                                                                             , "Y"
                                                                             );
                    }
                    if (result == 1)
                    {
                        if (row.ItemArray[1].ToString() == "khong co")
                        {
                            count += dwDataAccess.InsertReminderPayment_1SMSToDW(SMS_TYPE, message
                                                                                 , row.ItemArray[1].ToString()//    ,long.Parse(row.ItemArray[10].ToString())
                                                                                 , DateTime.Parse(row.ItemArray[0].ToString())
                                                                                 , row.ItemArray[9].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())
                                                                                 , double.Parse(row.ItemArray[7].ToString()) //    , long.Parse(row.ItemArray[7].ToString())
                                                                                 , row.ItemArray[8].ToString()               //    , int.Parse(row.ItemArray[8].ToString())
                                                                                 , "Y"
                                                                                 );
                        }
                        else
                        {
                            count += dwDataAccess.InsertReminderPayment_1SMSToDW(SMS_TYPE, message
                                                                                 , row.ItemArray[1].ToString()//    ,long.Parse(row.ItemArray[10].ToString())
                                                                                 , DateTime.Parse(row.ItemArray[0].ToString())
                                                                                 , row.ItemArray[9].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())
                                                                                 , double.Parse(row.ItemArray[7].ToString()) //    , long.Parse(row.ItemArray[7].ToString())
                                                                                 , row.ItemArray[8].ToString()               //    , int.Parse(row.ItemArray[8].ToString())
                                                                                 , "N"                                       //hhhh Y: se ko gui tin nhan, D: ko gui, N: gui, E:Error
                                                                                 );
                        }
                    }
                }
            }
            ebankDataAccess.CloseConnection();
            dwDataAccess.CloseConnection();
            classReminderPayment1LogWriter.WriteLog("So luong message da duoc Insert vao EbankGW thanh cong: " + count);
            return;
        }