Example #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    result    = 0;
            int    count     = 0;
            int    count_err = 0;

            //OracleCommand cmd = ebankDataAccess.AddProcedureParameterToEBankGW();           l

            foreach (DataRow row in table.Rows)
            {
                result = 0;

                message = CreateSMSMessage(row.ItemArray[5].ToString(), row.ItemArray[1].ToString(), row.ItemArray[3].ToString(),
                                           row.ItemArray[2].ToString(), row.ItemArray[4].ToString(), row.ItemArray[11].ToString(), row.ItemArray[12].ToString());
                if (string.IsNullOrEmpty(message) == false)
                {
                    //string mobile = classUtilities.GetMobileFromCardNoOfSpecialList(row.ItemArray[10].ToString(), row.ItemArray[7].ToString());
                    string count_act = _dataAccess.Get_First_Activate(row.ItemArray[10].ToString());
                    string count_rep = _dataAccess.Get_Reply_Card(row.ItemArray[10].ToString());
                    if (count_act == "1" && count_rep == "0" && row.ItemArray[13].ToString() == row.ItemArray[3].ToString())//count_rep=0: the chua thay the, count_act=1: active lan dau, ngay active=ngay thu phi
                    {
                        classAnnual_FeeLogWriter.WriteLog("khong gui sms cho lan thu phi dau: card=" + row.ItemArray[10].ToString());
                    }
                    else
                    {
                        if (row.ItemArray[7].ToString() == "khong co")
                        {
                            result = ebankDataAccess.InsertSMSMessateToEBankGW_2(//classDataAccess.IDALERT
                                row.ItemArray[9].ToString()
                                //, mobile
                                , row.ItemArray[7].ToString()
                                , message
                                , 'Y'                                               //Y se ko gui tin nhan, N se gui tin nhan
                                , SMS_TYPE);
                        }
                        else
                        {
                            result = ebankDataAccess.InsertSMSMessateToEBankGW_2(//classDataAccess.IDALERT
                                row.ItemArray[9].ToString()
                                //, mobile
                                , row.ItemArray[7].ToString()
                                , message
                                , 'N'                                                //Y se ko gui tin nhan, N se gui tin nhan
                                , SMS_TYPE);
                        }
                        if (result == 1)
                        {
                            if (row.ItemArray[10].ToString() == "khong co")
                            {
                                count += dwDataAccess.InsertAnnualFeeSMSToDW(
                                    SMS_TYPE
                                    , message
                                    //, mobile//    ,long.Parse(row.ItemArray[10].ToString())
                                    , row.ItemArray[7].ToString()
                                    , DateTime.Parse(row.ItemArray[0].ToString())
                                    //, row.ItemArray[4].ToString()
                                    , row.ItemArray[10].ToString()
                                    , row.ItemArray[5].ToString()
                                    , row.ItemArray[6].ToString()
                                    , row.ItemArray[3].ToString()                                //    , long.Parse(row.ItemArray[5].ToString())
                                    , row.ItemArray[2].ToString()                                //    , long.Parse(row.ItemArray[6].ToString())
                                    , double.Parse(row.ItemArray[4].ToString())                  //    , long.Parse(row.ItemArray[7].ToString())
                                    , row.ItemArray[8].ToString()                                //    , int.Parse(row.ItemArray[8].ToString())
                                    , "Y"
                                    );
                            }
                            else
                            {
                                count += dwDataAccess.InsertAnnualFeeSMSToDW(
                                    SMS_TYPE
                                    , message
                                    //, mobile//    ,long.Parse(row.ItemArray[10].ToString())
                                    , row.ItemArray[7].ToString()
                                    , DateTime.Parse(row.ItemArray[0].ToString())
                                    //, row.ItemArray[4].ToString()
                                    , row.ItemArray[10].ToString()
                                    , row.ItemArray[5].ToString()
                                    , row.ItemArray[6].ToString()
                                    , row.ItemArray[3].ToString()                                //    , long.Parse(row.ItemArray[5].ToString())
                                    , row.ItemArray[2].ToString()                                //    , long.Parse(row.ItemArray[6].ToString())
                                    , double.Parse(row.ItemArray[4].ToString())                  //    , long.Parse(row.ItemArray[7].ToString())
                                    , row.ItemArray[8].ToString()                                //    , int.Parse(row.ItemArray[8].ToString())
                                    , "N"
                                    );
                            }
                        }
                        else
                        {
                            count_err += dwDataAccess.InsertAnnualFeeSMSToDW(
                                SMS_TYPE
                                , message
                                //, mobile//    ,long.Parse(row.ItemArray[10].ToString())
                                , row.ItemArray[7].ToString()
                                , DateTime.Parse(row.ItemArray[0].ToString())
                                //, row.ItemArray[4].ToString()
                                , row.ItemArray[10].ToString()
                                , row.ItemArray[5].ToString()
                                , row.ItemArray[6].ToString()
                                , row.ItemArray[3].ToString()                                    //    , long.Parse(row.ItemArray[5].ToString())
                                , row.ItemArray[2].ToString()                                    //    , long.Parse(row.ItemArray[6].ToString())
                                , double.Parse(row.ItemArray[4].ToString())                      //    , long.Parse(row.ItemArray[7].ToString())
                                , row.ItemArray[8].ToString()                                    //    , int.Parse(row.ItemArray[8].ToString())
                                , "E"
                                );
                        }
                    }
                }
            }
            ebankDataAccess.CloseConnection();
            dwDataAccess.CloseConnection();
            classAnnual_FeeLogWriter.WriteLog("Message da duoc Insert vao EbankGW thanh cong: " + count);
            classAnnual_FeeLogWriter.WriteLog("Message loi khong Insert vao EbankGW: " + count_err);
            return;
        }