Esempio n. 1
0
        private static void Insert_SMSMessage(DataTable table)
        {
            classDataAccess ebankDataAccess = new classDataAccess();
            classDataAccess dwDataAccess    = new classDataAccess();
            classDataAccess IMDataAccess    = new classDataAccess();

            ebankDataAccess.OpenConnection("EBANK_GW");
            dwDataAccess.OpenConnection("CW_DW");
            IMDataAccess.OpenConnection("CW_IM");
            string link_km        = classUtilities.GetStringValueFromConfig("SCB_KM");
            string link_HDSD      = classUtilities.GetStringValueFromConfig("SCB_HDSD");
            string message        = "";
            string message_encode = "";
            int    result         = 0;
            int    count          = 0;
            int    count_err      = 0;

            foreach (DataRow row in table.Rows)
            {
                string card_no = classUtilities.GetCardFromSMS_Pin_List(row.ItemArray[9].ToString());
                if (card_no == "")//nhan pin giay
                {
                    string count_act = IMDataAccess.Get_First_Activate(row.ItemArray[9].ToString());
                    if (count_act == "1")//1: active lan dau
                    {
                        string count_rep = IMDataAccess.Get_Reply_Card(row.ItemArray[9].ToString());
                        if (count_rep == "0")//0: the chua thay the
                        {
                            message = CreateSMSMessage_act_first(row.ItemArray[2].ToString(), row.ItemArray[4].ToString(), row.ItemArray[5].ToString(), row.ItemArray[6].ToString(), row.ItemArray[12].ToString(), row.ItemArray[13].ToString(), link_km, link_HDSD);
                        }
                        else
                        {
                            message = CreateSMSMessage(row.ItemArray[2].ToString(), row.ItemArray[4].ToString(), row.ItemArray[5].ToString(), row.ItemArray[6].ToString(), row.ItemArray[12].ToString(), row.ItemArray[13].ToString(), link_km);
                        }
                    }
                    else
                    {
                        message = CreateSMSMessage(row.ItemArray[2].ToString(), row.ItemArray[4].ToString(), row.ItemArray[5].ToString(), row.ItemArray[6].ToString(), row.ItemArray[12].ToString(), row.ItemArray[13].ToString(), link_km);
                    }

                    //message = CreateSMSMessage(row.ItemArray[2].ToString(), row.ItemArray[4].ToString(), row.ItemArray[5].ToString(), row.ItemArray[6].ToString(), row.ItemArray[12].ToString(), row.ItemArray[13].ToString(), link_km);
                    if (string.IsNullOrEmpty(message) == false)
                    {
                        string mobile = row.ItemArray[7].ToString();
                        if (row.ItemArray[7].ToString() == "khong co")
                        {
                            result = ebankDataAccess.InsertSMSMessateToEBankGW(//classDataAccess.IDALERT
                                row.ItemArray[8].ToString()
                                , mobile
                                , message
                                , 'Y'                                               //Y se ko gui tin nhan, N se gui tin nhan
                                , SMS_TYPE);
                        }
                        else
                        {
                            result = ebankDataAccess.InsertSMSMessateToEBankGW(//classDataAccess.IDALERT
                                row.ItemArray[8].ToString()
                                , mobile
                                , message
                                , 'N'                                               //Y se ko gui tin nhan, N se gui tin nhan
                                , SMS_TYPE);
                        }
                        if (result == 1)
                        {
                            if (row.ItemArray[7].ToString() == "khong co")
                            {
                                count += dwDataAccess.InsertKichHoatTheSMSToDW(
                                    SMS_TYPE
                                    , message
                                    , mobile
                                    , DateTime.Parse(row.ItemArray[0].ToString())
                                    //, row.ItemArray[4].ToString()
                                    , row.ItemArray[9].ToString()
                                    , row.ItemArray[2].ToString()
                                    , row.ItemArray[3].ToString()
                                    , row.ItemArray[5].ToString()
                                    , row.ItemArray[6].ToString()
                                    , row.ItemArray[1].ToString()
                                    , "Y"
                                    );
                            }
                            else
                            {
                                count += dwDataAccess.InsertKichHoatTheSMSToDW(
                                    SMS_TYPE
                                    , message
                                    , mobile
                                    , DateTime.Parse(row.ItemArray[0].ToString())
                                    //, row.ItemArray[4].ToString()
                                    , row.ItemArray[9].ToString()
                                    , row.ItemArray[2].ToString()
                                    , row.ItemArray[3].ToString()
                                    , row.ItemArray[5].ToString()
                                    , row.ItemArray[6].ToString()
                                    , row.ItemArray[1].ToString()
                                    , "N"
                                    );
                            }
                        }
                        else
                        {
                            count_err += dwDataAccess.InsertKichHoatTheSMSToDW(
                                SMS_TYPE
                                , message
                                , mobile
                                , DateTime.Parse(row.ItemArray[0].ToString())
                                //, row.ItemArray[4].ToString()
                                , row.ItemArray[9].ToString()
                                , row.ItemArray[2].ToString()
                                , row.ItemArray[3].ToString()
                                , row.ItemArray[5].ToString()
                                , row.ItemArray[6].ToString()
                                , row.ItemArray[1].ToString()
                                , "E"
                                );
                        }
                    }
                    else //gen mess loi
                    {
                        classKichHoatTheLogWriter.WriteLog("err when create mess: " + row.ItemArray[9].ToString());
                    }
                }
                else //nhan pin sms
                {
                    result = 0;
                    string loc_pan = row.ItemArray[10].ToString() + row.ItemArray[4].ToString().Substring(12, 4);

                    //if (row.ItemArray[11].ToString() == "P")//P: the chinh
                    //{
                    //    string count_act = IMDataAccess.Get_First_Activate(row.ItemArray[9].ToString());
                    //    if (row.ItemArray[14].ToString() == "")//the ko thuoc CBNV
                    //    {
                    //        if (count_act == "1")//1: active lan dau
                    //        {
                    //            string count_rep = IMDataAccess.Get_Reply_Card(row.ItemArray[9].ToString());
                    //            if (count_rep == "0")//0: the chua thay the
                    //            {
                    //                message = CreateSMSMessage_phi(row.ItemArray[2].ToString(), row.ItemArray[4].ToString(), row.ItemArray[5].ToString(), row.ItemArray[6].ToString(), row.ItemArray[12].ToString(), row.ItemArray[13].ToString(), row.ItemArray[7].ToString(), loc_pan);
                    //            }
                    //            else
                    //                message = CreateSMSMessage_QC(row.ItemArray[2].ToString(), row.ItemArray[4].ToString(), row.ItemArray[5].ToString(), row.ItemArray[6].ToString(), row.ItemArray[12].ToString(), row.ItemArray[13].ToString(), link_km, row.ItemArray[7].ToString(), loc_pan);
                    //        }
                    //        else
                    //        {
                    //            message = CreateSMSMessage_QC(row.ItemArray[2].ToString(), row.ItemArray[4].ToString(), row.ItemArray[5].ToString(), row.ItemArray[6].ToString(), row.ItemArray[12].ToString(), row.ItemArray[13].ToString(), link_km, row.ItemArray[7].ToString(), loc_pan);
                    //        }
                    //    }
                    //    else
                    //        message = CreateSMSMessage_QC(row.ItemArray[2].ToString(), row.ItemArray[4].ToString(), row.ItemArray[5].ToString(), row.ItemArray[6].ToString(), row.ItemArray[12].ToString(), row.ItemArray[13].ToString(), link_km, row.ItemArray[7].ToString(), loc_pan);
                    //}
                    //else//the phu
                    //{
                    //    //message = CreateSMSMessage(row.ItemArray[2].ToString(), row.ItemArray[4].ToString(), row.ItemArray[5].ToString(), row.ItemArray[6].ToString(), row.ItemArray[12].ToString(),row.ItemArray[13].ToString());
                    //    message = CreateSMSMessage_QC(row.ItemArray[2].ToString(), row.ItemArray[4].ToString(), row.ItemArray[5].ToString(), row.ItemArray[6].ToString(), row.ItemArray[12].ToString(), row.ItemArray[13].ToString(), link_km, row.ItemArray[7].ToString(), loc_pan);
                    //}
                    string pin = Gen_PIN(row.ItemArray[7].ToString(), loc_pan);
                    if (pin != null)
                    {
                        message        = CreateSMSMessage_QC(row.ItemArray[2].ToString(), row.ItemArray[4].ToString(), row.ItemArray[5].ToString(), row.ItemArray[6].ToString(), row.ItemArray[12].ToString(), row.ItemArray[13].ToString(), link_km, row.ItemArray[7].ToString(), loc_pan, pin);
                        message_encode = CreateSMSMessage_EC(row.ItemArray[2].ToString(), row.ItemArray[4].ToString(), row.ItemArray[5].ToString(), row.ItemArray[6].ToString(), row.ItemArray[12].ToString(), row.ItemArray[13].ToString(), link_km, row.ItemArray[7].ToString(), loc_pan, pin);
                    }
                    else //gen PIN Loi
                    {
                        classKichHoatTheLogWriter.WriteLog("gen PIN loi for LOC: " + row.ItemArray[10].ToString());
                    }
                    if (string.IsNullOrEmpty(message) == false)
                    {
                        string mobile = row.ItemArray[7].ToString();
                        if (row.ItemArray[7].ToString() == "khong co")
                        {
                            result = ebankDataAccess.InsertSMSMessateToEBankGW(//classDataAccess.IDALERT
                                row.ItemArray[8].ToString()
                                , mobile
                                , message
                                , 'Y'                                               //Y se ko gui tin nhan, N se gui tin nhan
                                , SMS_TYPE);
                        }
                        else
                        {
                            result = ebankDataAccess.InsertSMSMessateToEBankGW(//classDataAccess.IDALERT
                                row.ItemArray[8].ToString()
                                , mobile
                                , message
                                , 'N'                                               //Y se ko gui tin nhan, N se gui tin nhan
                                , SMS_TYPE);
                        }
                        if (result == 1)
                        {
                            if (row.ItemArray[7].ToString() == "khong co")
                            {
                                count += dwDataAccess.InsertKichHoatTheSMSToDW(
                                    SMS_TYPE
                                    , message_encode
                                    , mobile
                                    , DateTime.Parse(row.ItemArray[0].ToString())
                                    //, row.ItemArray[4].ToString()
                                    , row.ItemArray[9].ToString()
                                    , row.ItemArray[2].ToString()
                                    , row.ItemArray[3].ToString()
                                    , row.ItemArray[5].ToString()
                                    , row.ItemArray[6].ToString()
                                    , row.ItemArray[1].ToString()
                                    , "Y"
                                    );
                            }
                            else
                            {
                                count += dwDataAccess.InsertKichHoatTheSMSToDW(
                                    SMS_TYPE
                                    , message_encode
                                    , mobile
                                    , DateTime.Parse(row.ItemArray[0].ToString())
                                    //, row.ItemArray[4].ToString()
                                    , row.ItemArray[9].ToString()
                                    , row.ItemArray[2].ToString()
                                    , row.ItemArray[3].ToString()
                                    , row.ItemArray[5].ToString()
                                    , row.ItemArray[6].ToString()
                                    , row.ItemArray[1].ToString()
                                    , "N"
                                    );
                            }
                        }
                        else
                        {
                            count_err += dwDataAccess.InsertKichHoatTheSMSToDW(
                                SMS_TYPE
                                , message_encode
                                , mobile
                                , DateTime.Parse(row.ItemArray[0].ToString())
                                //, row.ItemArray[4].ToString()
                                , row.ItemArray[9].ToString()
                                , row.ItemArray[2].ToString()
                                , row.ItemArray[3].ToString()
                                , row.ItemArray[5].ToString()
                                , row.ItemArray[6].ToString()
                                , row.ItemArray[1].ToString()
                                , "E"
                                );
                        }
                    }
                }
            }
            ebankDataAccess.CloseConnection();
            dwDataAccess.CloseConnection();
            classKichHoatTheLogWriter.WriteLog("Message da duoc Insert vao EbankGW thanh cong: " + count);
            classKichHoatTheLogWriter.WriteLog("Message loi khong Insert vao EbankGW: " + count_err);
        }
Esempio n. 2
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;
        }