Exemplo n.º 1
0
    public int Execute(int jobID)
    {
        try
        {
            var webServiceCharging3G = new WebServiceCharging3g();

            //string userName = AppEnv.GetSetting("userName_3g_WapVnm");
            //string userPass = AppEnv.GetSetting("password_3g_WapVnm");
            //string cpId = AppEnv.GetSetting("cpId_3g_WapVnm");

            string userName = AppEnv.GetSetting("userName_3g_visport");
            string userPass = AppEnv.GetSetting("password_3g_visport");
            string cpId     = AppEnv.GetSetting("cpId_3g_visport");

            string price;

            string notEnoughMoney = AppEnv.GetSetting("NotEnoughMoney");

            const string serviceType = "Charged Sub World Cup VTV";
            const string serviceName = "World_Cup_VTV";

            DataTable dtUsers = ViSport_S2_Registered_UsersController.WorldCupGetRegisterUserForChargedVtv();
            if (dtUsers != null && dtUsers.Rows.Count > 0)
            {
                foreach (DataRow dr in dtUsers.Rows)
                {
                    string userId = dr["User_ID"].ToString();

                    //price = "3000";
                    //string returnValue = webServiceCharging3G.PaymentVnmWithAccount(userId, price, serviceType, serviceName, userName, userPass, cpId);

                    price = "3000";
                    string returnValue = webServiceCharging3G.PaymentVnmWithAccount(userId, price, serviceType, serviceName, userName, userPass, cpId);
                    if (returnValue.Trim() == notEnoughMoney)
                    {
                        price       = "2000";
                        returnValue = webServiceCharging3G.PaymentVnmWithAccount(userId, price, serviceType, serviceName, userName, userPass, cpId);
                        if (returnValue.Trim() == notEnoughMoney)
                        {
                            price       = "1000";
                            returnValue = webServiceCharging3G.PaymentVnmWithAccount(userId, price, serviceType, serviceName, userName, userPass, cpId);
                        }
                    }

                    _log.Debug(" ");
                    _log.Debug(" ");
                    _log.Debug("UserId : " + userId);
                    _log.Debug("Price : " + price);
                    _log.Debug("ReturnValue : " + returnValue);
                    _log.Debug("UserName : "******" | UserPass : "******" | CpId : " + cpId);
                    _log.Debug(" ");
                    _log.Debug(" ");

                    if (returnValue == "1")//CHARGED THANH_CONG
                    {
                        #region GOI API sang VTV

                        string url = "http://worldcup.visport.vn/TelcoApi/service.php?action=VMGgiahan&msisdn=" + userId + "&price=" + price;

                        var post = new PostSubmitter();
                        post.Url  = url;
                        post.Type = PostSubmitter.PostTypeEnum.Get;
                        string message = post.Post();

                        _log.Debug(" ");
                        _log.Debug(" ");
                        _log.Debug("API Call : " + url);
                        _log.Debug("UserId : " + userId);
                        _log.Debug("Content From VTV : " + message);
                        _log.Debug(" ");
                        _log.Debug(" ");

                        //SendMtWorldCup(userId, message, dr["Service_ID"].ToString(), dr["Command_Code"].ToString(),dr["User_ID"].ToString());

                        #endregion

                        #region LOG DOANH THU

                        const string reasonLog = "Succ";

                        var logInfo = new SportGameHeroChargedUserLogInfo();

                        logInfo.ID           = ConvertUtility.ToInt32(dr["ID"].ToString());
                        logInfo.User_ID      = dr["User_ID"].ToString();
                        logInfo.Request_ID   = dr["Request_ID"].ToString();
                        logInfo.Service_ID   = dr["Service_ID"].ToString();
                        logInfo.Command_Code = dr["Command_Code"].ToString();

                        logInfo.Service_Type       = ConvertUtility.ToInt32(dr["Service_Type"].ToString());
                        logInfo.Charging_Count     = ConvertUtility.ToInt32(dr["Charging_Count"].ToString());
                        logInfo.FailedChargingTime = ConvertUtility.ToInt32(dr["FailedChargingTimes"].ToString());

                        logInfo.RegisteredTime = ConvertUtility.ToDateTime(dr["RegisteredTime"].ToString());
                        logInfo.ExpiredTime    = DateTime.Now.AddDays(1);

                        logInfo.Registration_Channel = dr["Registration_Channel"].ToString();
                        logInfo.Status   = ConvertUtility.ToInt32(dr["Status"].ToString());
                        logInfo.Operator = dr["Operator"].ToString();
                        logInfo.Price    = ConvertUtility.ToInt32(price);
                        logInfo.Reason   = reasonLog;

                        ViSport_S2_Registered_UsersController.WorldCupChargedUserLogForSubVtv6(logInfo);

                        #endregion
                    }
                }
            }
        }
        catch (Exception ex)
        {
            _log.Error("WC Loi lay Tap User VTV : " + ex);
            return(0);
        }
        return(1);
    }
Exemplo n.º 2
0
    public int Execute(int jobId)
    {
        WebServiceCharging3g webServiceCharging3G = new WebServiceCharging3g();
        string userName = "******";
        string userPass = "******";
        string cpId     = "1930";
        string price;

        try
        {
            DataTable dtUsers = ViSport_S2_Registered_UsersController.GetSportGameHeroUserInfo("841864925596");
            if (dtUsers != null && dtUsers.Rows.Count > 0)
            {
                string message        = string.Empty;
                string returnValue    = string.Empty;
                string notEnoughMoney = AppEnv.GetSetting("NotEnoughMoney");

                string serviceType = "Charge Hero";
                string serviceName = "ViSport_Hero";
                string reasonLog   = string.Empty;

                for (int i = 0; i < dtUsers.Rows.Count; i++)
                {
                    try
                    {
                        #region TIEN HANH CHARGED

                        price       = "5000";
                        returnValue = webServiceCharging3G.PaymentVnmWithAccount(dtUsers.Rows[i]["User_ID"].ToString(), price, "Charged Sub Anh Tai", "Anh_Tai_Sub", userName, userPass, cpId);
                        if (returnValue == "1")
                        {
                            #region LOG DOANH THU

                            var logInfo = new SportGameHeroChargedUserLogInfo();

                            logInfo.ID           = ConvertUtility.ToInt32(dtUsers.Rows[i]["ID"].ToString());
                            logInfo.User_ID      = dtUsers.Rows[i]["User_ID"].ToString();
                            logInfo.Request_ID   = dtUsers.Rows[i]["Request_ID"].ToString();
                            logInfo.Service_ID   = dtUsers.Rows[i]["Service_ID"].ToString();
                            logInfo.Command_Code = dtUsers.Rows[i]["Command_Code"].ToString();

                            logInfo.Service_Type       = ConvertUtility.ToInt32(dtUsers.Rows[i]["Service_Type"].ToString());
                            logInfo.Charging_Count     = ConvertUtility.ToInt32(dtUsers.Rows[i]["Charging_Count"].ToString());
                            logInfo.FailedChargingTime = ConvertUtility.ToInt32(dtUsers.Rows[i]["FailedChargingTimes"].ToString());

                            logInfo.RegisteredTime = ConvertUtility.ToDateTime(dtUsers.Rows[i]["RegisteredTime"].ToString());
                            logInfo.ExpiredTime    = DateTime.Now.AddDays(1);

                            logInfo.Registration_Channel = dtUsers.Rows[i]["Registration_Channel"].ToString();
                            logInfo.Status   = ConvertUtility.ToInt32(dtUsers.Rows[i]["Status"].ToString());
                            logInfo.Operator = dtUsers.Rows[i]["Operator"].ToString();
                            logInfo.Price    = ConvertUtility.ToInt32(price);
                            logInfo.Reason   = "Succ";

                            ViSport_S2_Registered_UsersController.InsertSportGameHeroChargedUserLogForSub(logInfo);

                            #endregion

                            returnValue = webServiceCharging3G.PaymentVnmWithAccount(dtUsers.Rows[i]["User_ID"].ToString(), price, "Charged Sub Anh Tai", "Anh_Tai_Sub", userName, userPass, cpId);

                            if (returnValue == "1")
                            {
                                #region LOG DOANH THU

                                var logInfo1 = new SportGameHeroChargedUserLogInfo();

                                logInfo1.ID           = ConvertUtility.ToInt32(dtUsers.Rows[i]["ID"].ToString());
                                logInfo1.User_ID      = dtUsers.Rows[i]["User_ID"].ToString();
                                logInfo1.Request_ID   = dtUsers.Rows[i]["Request_ID"].ToString();
                                logInfo1.Service_ID   = dtUsers.Rows[i]["Service_ID"].ToString();
                                logInfo1.Command_Code = dtUsers.Rows[i]["Command_Code"].ToString();

                                logInfo1.Service_Type       = ConvertUtility.ToInt32(dtUsers.Rows[i]["Service_Type"].ToString());
                                logInfo1.Charging_Count     = ConvertUtility.ToInt32(dtUsers.Rows[i]["Charging_Count"].ToString());
                                logInfo1.FailedChargingTime = ConvertUtility.ToInt32(dtUsers.Rows[i]["FailedChargingTimes"].ToString());

                                logInfo1.RegisteredTime = ConvertUtility.ToDateTime(dtUsers.Rows[i]["RegisteredTime"].ToString());
                                logInfo1.ExpiredTime    = DateTime.Now.AddDays(1);

                                logInfo1.Registration_Channel = dtUsers.Rows[i]["Registration_Channel"].ToString();
                                logInfo1.Status   = ConvertUtility.ToInt32(dtUsers.Rows[i]["Status"].ToString());
                                logInfo1.Operator = dtUsers.Rows[i]["Operator"].ToString();
                                logInfo1.Price    = ConvertUtility.ToInt32(price);
                                logInfo1.Reason   = "Succ";

                                ViSport_S2_Registered_UsersController.InsertSportGameHeroChargedUserLogForSub(logInfo1);

                                #endregion

                                returnValue = webServiceCharging3G.PaymentVnmWithAccount(dtUsers.Rows[i]["User_ID"].ToString(), price, "Charged Sub Anh Tai", "Anh_Tai_Sub", userName, userPass, cpId);

                                if (returnValue == "1")
                                {
                                    #region LOG DOANH THU

                                    var logInfo2 = new SportGameHeroChargedUserLogInfo();

                                    logInfo2.ID           = ConvertUtility.ToInt32(dtUsers.Rows[i]["ID"].ToString());
                                    logInfo2.User_ID      = dtUsers.Rows[i]["User_ID"].ToString();
                                    logInfo2.Request_ID   = dtUsers.Rows[i]["Request_ID"].ToString();
                                    logInfo2.Service_ID   = dtUsers.Rows[i]["Service_ID"].ToString();
                                    logInfo2.Command_Code = dtUsers.Rows[i]["Command_Code"].ToString();

                                    logInfo2.Service_Type       = ConvertUtility.ToInt32(dtUsers.Rows[i]["Service_Type"].ToString());
                                    logInfo2.Charging_Count     = ConvertUtility.ToInt32(dtUsers.Rows[i]["Charging_Count"].ToString());
                                    logInfo2.FailedChargingTime = ConvertUtility.ToInt32(dtUsers.Rows[i]["FailedChargingTimes"].ToString());

                                    logInfo2.RegisteredTime = ConvertUtility.ToDateTime(dtUsers.Rows[i]["RegisteredTime"].ToString());
                                    logInfo2.ExpiredTime    = DateTime.Now.AddDays(1);

                                    logInfo2.Registration_Channel = dtUsers.Rows[i]["Registration_Channel"].ToString();
                                    logInfo2.Status   = ConvertUtility.ToInt32(dtUsers.Rows[i]["Status"].ToString());
                                    logInfo2.Operator = dtUsers.Rows[i]["Operator"].ToString();
                                    logInfo2.Price    = ConvertUtility.ToInt32(price);
                                    logInfo2.Reason   = "Succ";

                                    ViSport_S2_Registered_UsersController.InsertSportGameHeroChargedUserLogForSub(logInfo2);

                                    #endregion
                                }
                            }
                        }


                        if (returnValue != "1")
                        {
                            #region LOG DOANH THU

                            var logInfo = new SportGameHeroChargedUserLogInfo();

                            logInfo.ID           = ConvertUtility.ToInt32(dtUsers.Rows[i]["ID"].ToString());
                            logInfo.User_ID      = dtUsers.Rows[i]["User_ID"].ToString();
                            logInfo.Request_ID   = dtUsers.Rows[i]["Request_ID"].ToString();
                            logInfo.Service_ID   = dtUsers.Rows[i]["Service_ID"].ToString();
                            logInfo.Command_Code = dtUsers.Rows[i]["Command_Code"].ToString();

                            logInfo.Service_Type       = ConvertUtility.ToInt32(dtUsers.Rows[i]["Service_Type"].ToString());
                            logInfo.Charging_Count     = ConvertUtility.ToInt32(dtUsers.Rows[i]["Charging_Count"].ToString());
                            logInfo.FailedChargingTime = ConvertUtility.ToInt32(dtUsers.Rows[i]["FailedChargingTimes"].ToString());

                            logInfo.RegisteredTime = ConvertUtility.ToDateTime(dtUsers.Rows[i]["RegisteredTime"].ToString());
                            logInfo.ExpiredTime    = DateTime.Now.AddDays(1);

                            logInfo.Registration_Channel = dtUsers.Rows[i]["Registration_Channel"].ToString();
                            logInfo.Status   = ConvertUtility.ToInt32(dtUsers.Rows[i]["Status"].ToString());
                            logInfo.Operator = dtUsers.Rows[i]["Operator"].ToString();
                            logInfo.Price    = ConvertUtility.ToInt32(price);
                            logInfo.Reason   = returnValue;

                            ViSport_S2_Registered_UsersController.InsertSportGameHeroChargedUserLogForSub(logInfo);

                            #endregion
                        }

                        if (returnValue == "1")//CHARGED THANH CONG
                        {
                            //reasonLog = "Succ";

                            //SEND MT CHO KHACH HANG

                            //DataTable dtQuestion = ViSport_S2_Registered_UsersController.GetQuestionInfoSportGameHero();
                            //if (dtQuestion != null && dtQuestion.Rows.Count > 0)
                            //{
                            message = "Ban da duoc cong 960 diem cho game show Anh tai bong da.Soan DIEM gui 979 de xem so diem hien tai.";



                            string serviceId   = dtUsers.Rows[i]["Service_ID"].ToString();
                            string commandCode = dtUsers.Rows[i]["Command_Code"].ToString();
                            string requestId   = dtUsers.Rows[i]["Request_ID"].ToString();


                            SendMtSportGame(dtUsers.Rows[i]["User_ID"].ToString(), message, serviceId, commandCode, requestId);

                            //}

                            //END SEND MT CHO KHACH HANG
                        }
                        //else
                        //{
                        //    reasonLog = returnValue;
                        //}


                        #endregion
                    }
                    catch (Exception ex)
                    {
                        log.Error("Anh tai bong da Loi charged : " + ex);
                        continue;
                    }
                    //DataTable dt = new DataTable();
                    //dt = ViSport_S2_Registered_UsersController.SportGameHeroCheckUserChargedByDay(dtUsers.Rows[i]["User_ID"].ToString());
                    //if (dt.Rows[0]["RETURN_ID"].ToString().Trim() == "0")
                    //{

                    //}
                }
            }

            return(1);
        }
        catch (Exception ex)
        {
            log.Error("Anh tai bong da Loi lay tap User : " + ex);
            return(0);
        }
    }
Exemplo n.º 3
0
    public string NotifyChargingInfo(string registeredId, string userId, string requestId, string serviceId, string serviceType, string chargingValue, string chargingAccount, string chargingTime, string chargingResponse)
    {
        log.Info(" ");
        log.Info("***** LOG TRIEU_PHU_BONG_DA CHARGED NOTIFICATION From ANDY *****");

        log.Info("User_ID : " + userId);
        log.Info("chargingValue : " + chargingValue);
        log.Info("chargingAccount : " + chargingAccount);
        log.Info("chargingTime : " + chargingTime);
        log.Info("chargingResponse : " + chargingResponse);

        log.Info("****************************************");
        log.Info(" ");

        if (chargingResponse.Trim() == "1")//CHARGED THANH CONG
        {
            #region Sinh MDT

            string code1 = RandomActiveCode.Generate(8);
            string code2 = RandomActiveCode.Generate(8);
            ViSport_S2_Registered_UsersController.SportGameHeroLotteryCodeInsert(userId, code1);
            ViSport_S2_Registered_UsersController.SportGameHeroLotteryCodeInsert(userId, code2);

            #endregion

            #region LOG DOANH THU

            var logInfo = new SportGameHeroChargedUserLogInfo();

            logInfo.ID           = ConvertUtility.ToInt32(registeredId);
            logInfo.User_ID      = userId;
            logInfo.Request_ID   = requestId;
            logInfo.Service_ID   = serviceId;
            logInfo.Command_Code = "TP";

            logInfo.Service_Type       = ConvertUtility.ToInt32(serviceType);
            logInfo.Charging_Count     = 0;
            logInfo.FailedChargingTime = 0;

            logInfo.RegisteredTime = DateTime.Now;
            logInfo.ExpiredTime    = DateTime.Now.AddDays(1);

            logInfo.Registration_Channel = "SMS";
            logInfo.Status   = 1;
            logInfo.Operator = "vnmobile";
            logInfo.Price    = ConvertUtility.ToInt32(chargingValue);
            logInfo.Reason   = "Succ";

            ViSport_S2_Registered_UsersController.InsertSportGameHeroChargedUserLogForSub(logInfo);

            ViSport_S2_Registered_UsersController.Update_SportGameHeroChargedValue(userId, ConvertUtility.ToInt32(chargingValue));

            #endregion
        }
        else //CHARGED THAT BAI
        {
            #region LOG DOANH THU

            var logInfo = new SportGameHeroChargedUserLogInfo();

            logInfo.ID           = ConvertUtility.ToInt32(registeredId);
            logInfo.User_ID      = userId;
            logInfo.Request_ID   = requestId;
            logInfo.Service_ID   = serviceId;
            logInfo.Command_Code = "TP";

            logInfo.Service_Type       = ConvertUtility.ToInt32(serviceType);
            logInfo.Charging_Count     = 0;
            logInfo.FailedChargingTime = 0;

            logInfo.RegisteredTime = DateTime.Now;
            logInfo.ExpiredTime    = DateTime.Now.AddDays(1);

            logInfo.Registration_Channel = "SMS";
            logInfo.Status   = 1;
            logInfo.Operator = "vnmobile";
            logInfo.Price    = ConvertUtility.ToInt32(chargingValue);
            logInfo.Reason   = chargingResponse;

            ViSport_S2_Registered_UsersController.InsertSportGameHeroChargedUserLogForSub(logInfo);

            #endregion
        }

        if (chargingResponse.Trim() == "1")
        {
            #region TRA MT

            string       today       = DateTime.Now.DayOfWeek.ToString();
            const string commandCode = "TP";

            //if (CheckDayOfWeek(today)) //Tra MT vao cac ngay 3,5,7
            //{

            //    #region SEND MT THONG_TIN_TRAN_DAU

            //        DataTable dtMtFootball = ViSport_S2_Registered_UsersController.SportGameHeroMatchGetByDay();
            //        if (dtMtFootball != null && dtMtFootball.Rows.Count > 0)
            //        {

            //            string teamA = UnicodeUtility.UnicodeToKoDau(dtMtFootball.Rows[0]["Team_A_Name"].ToString());
            //            string teamB = UnicodeUtility.UnicodeToKoDau(dtMtFootball.Rows[0]["Team_B_Name"].ToString());

            //            string message1 = "Tran dau du doan ngay hom nay la: " + teamA + " va " + teamB + ". De du doan " + teamA + " thang soan KQ 1, du doan " + teamB + " thang soan KQ 3, du doan 2 doi hoa soan KQ 2 gui 979";
            //            SendMtSportGame(userId, message1, serviceId, commandCode, requestId); //MT1

            //            string message2 = "De du doan tong so ban thang soan BT G gui 979 (voi G la tong so ban thang 2 doi ghi trong thoi gian thi dau chinh thuc)";
            //            SendMtSportGame(userId, message2, serviceId, commandCode, requestId); //MT2

            //            string message3 = "De du doan ti so trong thoi gian chinh thuc soan TS A B gui 979 trong do A la so ban thang doi " + teamA + " ghi duoc, B la so ban thang doi " + teamB + " ghi duoc.";
            //            SendMtSportGame(userId, message3, serviceId, commandCode, requestId); //MT3

            //            string message4 = "De du doan " + teamA + " co ti le giu bong nhieu hon soan GB 1, du doan " + teamB + " co ti le giu bong nhieu hon soan GB 3, hai doi co ti le giu bong ngang nhau soan GB 2 gui 979";
            //            SendMtSportGame(userId, message4, serviceId, commandCode, requestId); //MT4

            //            string message5 = "De du doan tong so the vang soan TV C gui 979 trong do C la tong so the vang trong tai rut ra cho 2 doi trong thoi gian thi dau chinh thuc ";
            //            SendMtSportGame(userId, message5, serviceId, commandCode, requestId); //MT5

            //         }


            //    #endregion

            //}
            //else //Tra Cau hoi vao cac ngay 2,4,6,CN
            //{

            #region SEND MT CAU_HOI_BONG_DA

            //SEND MT CHO KHACH HANG

            //DataTable dtQuestion = ViSport_S2_Registered_UsersController.GetQuestionInfoSportGameHero();
            //if (dtQuestion != null && dtQuestion.Rows.Count > 0)
            //{

            //    string message = dtQuestion.Rows[0]["Question"].ToString();
            //    message = message.Replace("P1", "1").Replace("P2", "2");

            //    int questionIdnew = ConvertUtility.ToInt32(dtQuestion.Rows[0]["Id"].ToString());
            //    string answer = dtQuestion.Rows[0]["Answer"].ToString();
            //    answer = answer.Replace("P1", "1").Replace("P2", "2");

            //    ViSport_S2_Registered_UsersController.InsertSportGameHeroAnswerLog(userId, questionIdnew, message, answer, DateTime.Now, 0); // LUU LOG Question
            //    SendMtSportGame(userId, message, serviceId, commandCode, requestId);

            //}

            //END SEND MT CHO KHACH HANG

            #endregion

            //}

            #endregion
        }

        return("1");
    }
Exemplo n.º 4
0
    public int Execute(int jobID)
    {
        var    webServiceCharging3G = new WebServiceCharging3g();
        string userName             = "******";
        string userPass             = "******";
        string cpId = "1930";
        string price;

        try
        {
            DataTable dtUsers = ViSport_S2_Registered_UsersController.GetSportGameUserByTypeBonus();
            if (dtUsers != null && dtUsers.Rows.Count > 0)
            {
                for (int i = 0; i < dtUsers.Rows.Count; i++)
                {
                    try
                    {
                        #region TIEN HANH CHARGED

                        price = "1000";
                        string returnValue = webServiceCharging3G.PaymentVnmWithAccount(dtUsers.Rows[i]["User_ID"].ToString(), price, "Charged Sub Anh Tai", "Anh_Tai_Sub", userName, userPass, cpId);

                        if (returnValue == "1")
                        {
                            #region LOG DOANH THU

                            var logInfo = new SportGameHeroChargedUserLogInfo();

                            logInfo.ID           = ConvertUtility.ToInt32(dtUsers.Rows[i]["ID"].ToString());
                            logInfo.User_ID      = dtUsers.Rows[i]["User_ID"].ToString();
                            logInfo.Request_ID   = dtUsers.Rows[i]["Request_ID"].ToString();
                            logInfo.Service_ID   = dtUsers.Rows[i]["Service_ID"].ToString();
                            logInfo.Command_Code = dtUsers.Rows[i]["Command_Code"].ToString();

                            logInfo.Service_Type       = ConvertUtility.ToInt32(dtUsers.Rows[i]["Service_Type"].ToString());
                            logInfo.Charging_Count     = ConvertUtility.ToInt32(dtUsers.Rows[i]["Charging_Count"].ToString());
                            logInfo.FailedChargingTime = ConvertUtility.ToInt32(dtUsers.Rows[i]["FailedChargingTimes"].ToString());

                            logInfo.RegisteredTime = ConvertUtility.ToDateTime(dtUsers.Rows[i]["RegisteredTime"].ToString());
                            logInfo.ExpiredTime    = DateTime.Now.AddDays(1);

                            logInfo.Registration_Channel = dtUsers.Rows[i]["Registration_Channel"].ToString();
                            logInfo.Status   = ConvertUtility.ToInt32(dtUsers.Rows[i]["Status"].ToString());
                            logInfo.Operator = dtUsers.Rows[i]["Operator"].ToString();
                            logInfo.Price    = ConvertUtility.ToInt32(price);
                            logInfo.Reason   = "Succ";

                            ViSport_S2_Registered_UsersController.InsertSportGameHeroChargedUserLogForSubBonus(logInfo);

                            #endregion
                        }
                        else
                        {
                            #region LOG DOANH THU

                            var logInfo = new SportGameHeroChargedUserLogInfo();

                            logInfo.ID           = ConvertUtility.ToInt32(dtUsers.Rows[i]["ID"].ToString());
                            logInfo.User_ID      = dtUsers.Rows[i]["User_ID"].ToString();
                            logInfo.Request_ID   = dtUsers.Rows[i]["Request_ID"].ToString();
                            logInfo.Service_ID   = dtUsers.Rows[i]["Service_ID"].ToString();
                            logInfo.Command_Code = dtUsers.Rows[i]["Command_Code"].ToString();

                            logInfo.Service_Type       = ConvertUtility.ToInt32(dtUsers.Rows[i]["Service_Type"].ToString());
                            logInfo.Charging_Count     = ConvertUtility.ToInt32(dtUsers.Rows[i]["Charging_Count"].ToString());
                            logInfo.FailedChargingTime = ConvertUtility.ToInt32(dtUsers.Rows[i]["FailedChargingTimes"].ToString());

                            logInfo.RegisteredTime = ConvertUtility.ToDateTime(dtUsers.Rows[i]["RegisteredTime"].ToString());
                            logInfo.ExpiredTime    = DateTime.Now.AddDays(1);

                            logInfo.Registration_Channel = dtUsers.Rows[i]["Registration_Channel"].ToString();
                            logInfo.Status   = ConvertUtility.ToInt32(dtUsers.Rows[i]["Status"].ToString());
                            logInfo.Operator = dtUsers.Rows[i]["Operator"].ToString();
                            logInfo.Price    = ConvertUtility.ToInt32(price);
                            logInfo.Reason   = returnValue;

                            ViSport_S2_Registered_UsersController.InsertSportGameHeroChargedUserLogForSubBonus(logInfo);

                            #endregion
                        }

                        #endregion
                    }
                    catch (Exception ex)
                    {
                        log.Error("Anh tai bong da Loi charged : " + ex);
                    }
                }
            }

            return(1);
        }
        catch (Exception ex)
        {
            log.Error("Anh tai bong da Loi lay tap User : " + ex);
            return(0);
        }
    }
    public int Execute(int jobID)
    {
        WebServiceCharging3g webServiceCharging3G = new WebServiceCharging3g();
        string userName = "******";
        string userPass = "******";
        string cpId     = "1930";
        string price;

        try
        {
            DataTable dtUsers = ViSport_S2_Registered_UsersController.GetSportGameUserByTypeTp(false);
            if (dtUsers != null && dtUsers.Rows.Count > 0)
            {
                string message        = string.Empty;
                string returnValue    = string.Empty;
                string notEnoughMoney = AppEnv.GetSetting("NotEnoughMoney");

                string serviceType = "Charge Hero";
                string serviceName = "ViSport_Hero";
                string reasonLog   = string.Empty;

                int count = 0;

                for (int i = 0; i < dtUsers.Rows.Count; i++)
                {
                    if (count >= 3)
                    {
                        Thread.Sleep(1000);
                        count = 0;
                    }

                    try
                    {
                        string msisdn = dtUsers.Rows[i]["User_ID"].ToString();

                        #region TIEN HANH CHARGED

                        price       = "5000";
                        returnValue = webServiceCharging3G.PaymentVnmWithAccount(dtUsers.Rows[i]["User_ID"].ToString(), price, "Charged Sub Trieu phu bong da ", "Trieuphu_Sub", userName, userPass, cpId);
                        if (returnValue.Trim() == notEnoughMoney)
                        {
                            price       = "3000";
                            returnValue = webServiceCharging3G.PaymentVnmWithAccount(dtUsers.Rows[i]["User_ID"].ToString(), price, "Charged Sub Trieu phu bong da", "Trieuphu_Sub", userName, userPass, cpId);
                            if (returnValue.Trim() == notEnoughMoney)
                            {
                                price       = "2000";
                                returnValue = webServiceCharging3G.PaymentVnmWithAccount(dtUsers.Rows[i]["User_ID"].ToString(), price, "Charged Sub Trieu phu bong da", "Trieuphu_Sub", userName, userPass, cpId);
                                if (returnValue.Trim() == notEnoughMoney)
                                {
                                    price       = "1000";
                                    returnValue = webServiceCharging3G.PaymentVnmWithAccount(dtUsers.Rows[i]["User_ID"].ToString(), price, "Charged Sub Trieu phu bong da", "Trieuphu_Sub", userName, userPass, cpId);
                                }
                            }
                        }

                        if (returnValue == "1")
                        {
                            #region Sinh MDT

                            string code1 = RandomActiveCode.Generate(8);
                            string code2 = RandomActiveCode.Generate(8);
                            ViSport_S2_Registered_UsersController.SportGameHeroLotteryCodeInsert(msisdn, code1);
                            ViSport_S2_Registered_UsersController.SportGameHeroLotteryCodeInsert(msisdn, code2);

                            #endregion

                            #region LOG DOANH THU

                            var logInfo = new SportGameHeroChargedUserLogInfo();

                            logInfo.ID           = ConvertUtility.ToInt32(dtUsers.Rows[i]["ID"].ToString());
                            logInfo.User_ID      = dtUsers.Rows[i]["User_ID"].ToString();
                            logInfo.Request_ID   = dtUsers.Rows[i]["Request_ID"].ToString();
                            logInfo.Service_ID   = dtUsers.Rows[i]["Service_ID"].ToString();
                            logInfo.Command_Code = dtUsers.Rows[i]["Command_Code"].ToString();

                            logInfo.Service_Type       = ConvertUtility.ToInt32(dtUsers.Rows[i]["Service_Type"].ToString());
                            logInfo.Charging_Count     = ConvertUtility.ToInt32(dtUsers.Rows[i]["Charging_Count"].ToString());
                            logInfo.FailedChargingTime = ConvertUtility.ToInt32(dtUsers.Rows[i]["FailedChargingTimes"].ToString());

                            logInfo.RegisteredTime = ConvertUtility.ToDateTime(dtUsers.Rows[i]["RegisteredTime"].ToString());
                            logInfo.ExpiredTime    = DateTime.Now.AddDays(1);

                            logInfo.Registration_Channel = dtUsers.Rows[i]["Registration_Channel"].ToString();
                            logInfo.Status   = ConvertUtility.ToInt32(dtUsers.Rows[i]["Status"].ToString());
                            logInfo.Operator = dtUsers.Rows[i]["Operator"].ToString();
                            logInfo.Price    = ConvertUtility.ToInt32(price);
                            logInfo.Reason   = "Succ";

                            ViSport_S2_Registered_UsersController.InsertSportGameHeroChargedUserLogForSub(logInfo);

                            #endregion
                        }
                        else
                        {
                            #region LOG DOANH THU

                            var logInfo = new SportGameHeroChargedUserLogInfo();

                            logInfo.ID           = ConvertUtility.ToInt32(dtUsers.Rows[i]["ID"].ToString());
                            logInfo.User_ID      = dtUsers.Rows[i]["User_ID"].ToString();
                            logInfo.Request_ID   = dtUsers.Rows[i]["Request_ID"].ToString();
                            logInfo.Service_ID   = dtUsers.Rows[i]["Service_ID"].ToString();
                            logInfo.Command_Code = dtUsers.Rows[i]["Command_Code"].ToString();

                            logInfo.Service_Type       = ConvertUtility.ToInt32(dtUsers.Rows[i]["Service_Type"].ToString());
                            logInfo.Charging_Count     = ConvertUtility.ToInt32(dtUsers.Rows[i]["Charging_Count"].ToString());
                            logInfo.FailedChargingTime = ConvertUtility.ToInt32(dtUsers.Rows[i]["FailedChargingTimes"].ToString());

                            logInfo.RegisteredTime = ConvertUtility.ToDateTime(dtUsers.Rows[i]["RegisteredTime"].ToString());
                            logInfo.ExpiredTime    = DateTime.Now.AddDays(1);

                            logInfo.Registration_Channel = dtUsers.Rows[i]["Registration_Channel"].ToString();
                            logInfo.Status   = ConvertUtility.ToInt32(dtUsers.Rows[i]["Status"].ToString());
                            logInfo.Operator = dtUsers.Rows[i]["Operator"].ToString();
                            logInfo.Price    = ConvertUtility.ToInt32(price);
                            logInfo.Reason   = returnValue;

                            ViSport_S2_Registered_UsersController.InsertSportGameHeroChargedUserLogForSub(logInfo);

                            #endregion
                        }

                        if (returnValue == "1")//CHARGED THANH CONG
                        {
                            string today = DateTime.Now.DayOfWeek.ToString();

                            string serviceId   = dtUsers.Rows[i]["Service_ID"].ToString();
                            string commandCode = dtUsers.Rows[i]["Command_Code"].ToString();
                            string requestId   = dtUsers.Rows[i]["Request_ID"].ToString();

                            if (CheckDayOfWeek(today)) //Tra MT vao cac ngay 3,5,7
                            {
                                #region SEND MT THONG_TIN_TRAN_DAU

                                DataTable dtMtFootball = ViSport_S2_Registered_UsersController.SportGameHeroMatchGetByDay();
                                if (dtMtFootball != null && dtMtFootball.Rows.Count > 0)
                                {
                                    string teamA = UnicodeUtility.UnicodeToKoDau(dtMtFootball.Rows[0]["Team_A_Name"].ToString());
                                    string teamB = UnicodeUtility.UnicodeToKoDau(dtMtFootball.Rows[0]["Team_B_Name"].ToString());

                                    string message1 = "Tran dau du doan ngay hom nay la: " + teamA + " va " + teamB + ". De du doan " + teamA + " thang soan KQ 1, du doan " + teamB + " thang soan KQ 3, du doan 2 doi hoa soan KQ 2 gui 979";
                                    SendMtSportGame(dtUsers.Rows[i]["User_ID"].ToString(), message1, serviceId, commandCode, requestId); //MT1

                                    string message2 = "De du doan tong so ban thang soan BT G gui 979 (voi G la tong so ban thang 2 doi ghi trong thoi gian thi dau chinh thuc)";
                                    SendMtSportGame(dtUsers.Rows[i]["User_ID"].ToString(), message2, serviceId, commandCode, requestId); //MT2

                                    string message3 = "De du doan ti so trong thoi gian chinh thuc soan TS A B gui 979 trong do A la so ban thang doi " + teamA + " ghi duoc, B la so ban thang doi " + teamB + " ghi duoc.";
                                    SendMtSportGame(dtUsers.Rows[i]["User_ID"].ToString(), message3, serviceId, commandCode, requestId); //MT3

                                    string message4 = "De du doan " + teamA + " co ti le giu bong nhieu hon soan GB 1, du doan " + teamB + " co ti le giu bong nhieu hon soan GB 3, hai doi co ti le giu bong ngang nhau soan GB 2 gui 979";
                                    SendMtSportGame(dtUsers.Rows[i]["User_ID"].ToString(), message4, serviceId, commandCode, requestId); //MT4

                                    string message5 = "De du doan tong so the vang soan TV C gui 979 trong do C la tong so the vang trong tai rut ra cho 2 doi trong thoi gian thi dau chinh thuc ";
                                    SendMtSportGame(dtUsers.Rows[i]["User_ID"].ToString(), message5, serviceId, commandCode, requestId); //MT5
                                }


                                #endregion
                            }
                            else //Tra Cau hoi vao cac ngay 2,4,6,CN
                            {
                                #region SEND MT CAU_HOI_BONG_DA

                                //SEND MT CHO KHACH HANG

                                DataTable dtQuestion = ViSport_S2_Registered_UsersController.GetQuestionInfoSportGameHero();
                                if (dtQuestion != null && dtQuestion.Rows.Count > 0)
                                {
                                    message = dtQuestion.Rows[0]["Question"].ToString();
                                    message = message.Replace("P1", "1").Replace("P2", "2");

                                    int    questionIdnew = ConvertUtility.ToInt32(dtQuestion.Rows[0]["Id"].ToString());
                                    string answer        = dtQuestion.Rows[0]["Answer"].ToString();
                                    answer = answer.Replace("P1", "1").Replace("P2", "2");

                                    ViSport_S2_Registered_UsersController.InsertSportGameHeroAnswerLog(dtUsers.Rows[i]["User_ID"].ToString(), questionIdnew, message, answer, DateTime.Now, 0); // LUU LOG Question
                                    SendMtSportGame(dtUsers.Rows[i]["User_ID"].ToString(), message, serviceId, commandCode, requestId);
                                }

                                //END SEND MT CHO KHACH HANG

                                #endregion
                            }
                        }

                        #endregion

                        count = count + 1;
                    }
                    catch (Exception ex)
                    {
                        log.Error("Trieu phu bong da Loi charged : " + ex);
                    }
                }
            }

            return(1);
        }
        catch (Exception ex)
        {
            log.Error("Trieu phu bong da Loi lay tap User : " + ex);
            return(0);
        }
    }
    public string NotifyChargingInfo(string registeredId, string userId, string requestId, string serviceId, string serviceType, string chargingValue, string chargingAccount, string chargingTime, string chargingResponse)
    {
        log.Info(" ");
        log.Info("***** LOG Thethao222_Notification CHARGED NOTIFICATION From Tung *****");

        log.Info("User_ID : " + userId);
        log.Info("chargingValue : " + chargingValue);
        log.Info("chargingAccount : " + chargingAccount);
        log.Info("chargingTime : " + chargingTime);
        log.Info("chargingResponse : " + chargingResponse);
        log.Info("****************************************");
        log.Info(" ");

        if (chargingResponse.Trim() == "1")//CHARGED THANH CONG
        {
            #region LOG DOANH THU

            var logInfo = new SportGameHeroChargedUserLogInfo();

            logInfo.ID           = ConvertUtility.ToInt32(registeredId);
            logInfo.User_ID      = userId;
            logInfo.Request_ID   = requestId;
            logInfo.Service_ID   = serviceId;
            logInfo.Command_Code = "TP";

            logInfo.Service_Type       = 2;
            logInfo.Charging_Count     = 0;
            logInfo.FailedChargingTime = 0;

            logInfo.RegisteredTime = DateTime.Now;
            logInfo.ExpiredTime    = DateTime.Now.AddDays(1);

            logInfo.Registration_Channel = "SMS";
            logInfo.Status   = 1;
            logInfo.Operator = "vnmobile";
            logInfo.Price    = ConvertUtility.ToInt32(chargingValue);
            logInfo.Reason   = "Succ";

            ViSport_S2_Registered_UsersController.Visport_Thethao222_ChargedUserLogForSub(logInfo);

            #endregion
        }
        else //CHARGED THAT BAI
        {
            #region LOG DOANH THU

            var logInfo = new SportGameHeroChargedUserLogInfo();

            logInfo.ID           = ConvertUtility.ToInt32(registeredId);
            logInfo.User_ID      = userId;
            logInfo.Request_ID   = requestId;
            logInfo.Service_ID   = serviceId;
            logInfo.Command_Code = "DK PZSP";

            logInfo.Service_Type       = 2;
            logInfo.Charging_Count     = 0;
            logInfo.FailedChargingTime = 0;

            logInfo.RegisteredTime = DateTime.Now;
            logInfo.ExpiredTime    = DateTime.Now.AddDays(1);

            logInfo.Registration_Channel = "SMS";
            logInfo.Status   = 1;
            logInfo.Operator = "vnmobile";
            logInfo.Price    = ConvertUtility.ToInt32(chargingValue);
            logInfo.Reason   = chargingResponse;

            ViSport_S2_Registered_UsersController.Visport_Thethao222_ChargedUserLogForSub(logInfo);

            #endregion
        }


        return("1");
    }
Exemplo n.º 7
0
    public string NotifyChargingInfo(string registeredId, string userId, string requestId, string serviceId, string serviceType, string chargingValue, string chargingAccount, string chargingTime, string chargingResponse)
    {
        log.Info(" ");
        log.Info("***** LOG VTV CHARGED NOTIFICATION From ANDY *****");

        log.Info("User_ID : " + userId);
        log.Info("chargingValue : " + chargingValue);
        log.Info("chargingAccount : " + chargingAccount);
        log.Info("chargingTime : " + chargingTime);
        log.Info("chargingResponse : " + chargingResponse);

        log.Info("****************************************");
        log.Info(" ");

        if (chargingResponse.Trim() == "1")//CHARGED THANH CONG
        {
            #region GOI API sang VTV

            //string url = "http://worldcup.visport.vn/TelcoApi/service.php?action=VMGgiahan&msisdn=" + userId + "&price=" + chargingValue;

            //var post = new PostSubmitter();
            //post.Url = url;
            //post.Type = PostSubmitter.PostTypeEnum.Get;
            //string message = post.Post();

            //log.Debug(" ");
            //log.Debug(" ");
            //log.Debug("API Call : " + url);
            //log.Debug("UserId : " + userId);
            //log.Debug("Content From VTV : " + message);
            //log.Debug(" ");
            //log.Debug(" ");

            //SendMtWorldCup(userId, message, dr["Service_ID"].ToString(), dr["Command_Code"].ToString(),dr["User_ID"].ToString());

            #endregion

            #region LOG DOANH THU

            const string reasonLog = "Succ";

            var logInfo = new SportGameHeroChargedUserLogInfo();

            logInfo.ID           = ConvertUtility.ToInt32(registeredId);
            logInfo.User_ID      = userId;
            logInfo.Request_ID   = requestId;
            logInfo.Service_ID   = serviceId;
            logInfo.Command_Code = "VTV";

            logInfo.Service_Type       = ConvertUtility.ToInt32(0);
            logInfo.Charging_Count     = ConvertUtility.ToInt32(0);
            logInfo.FailedChargingTime = ConvertUtility.ToInt32(0);

            logInfo.RegisteredTime = ConvertUtility.ToDateTime(chargingTime);
            logInfo.ExpiredTime    = DateTime.Now.AddDays(1);

            logInfo.Registration_Channel = "VTV";
            logInfo.Status   = ConvertUtility.ToInt32(1);
            logInfo.Operator = "vnmobile";
            logInfo.Price    = ConvertUtility.ToInt32(chargingValue);
            logInfo.Reason   = reasonLog;

            ViSport_S2_Registered_UsersController.WorldCupChargedUserLogForSubVtv6(logInfo);

            #endregion
        }
        else //CHARGED THAT BAI
        {
            #region LOG DOANH THU

            var logInfo = new SportGameHeroChargedUserLogInfo();

            logInfo.ID           = ConvertUtility.ToInt32(registeredId);
            logInfo.User_ID      = userId;
            logInfo.Request_ID   = requestId;
            logInfo.Service_ID   = serviceId;
            logInfo.Command_Code = "VTV";

            logInfo.Service_Type       = ConvertUtility.ToInt32(0);
            logInfo.Charging_Count     = ConvertUtility.ToInt32(0);
            logInfo.FailedChargingTime = ConvertUtility.ToInt32(0);

            logInfo.RegisteredTime = ConvertUtility.ToDateTime(chargingTime);
            logInfo.ExpiredTime    = DateTime.Now.AddDays(1);

            logInfo.Registration_Channel = "VTV";
            logInfo.Status   = ConvertUtility.ToInt32(1);
            logInfo.Operator = "vnmobile";
            logInfo.Price    = ConvertUtility.ToInt32(chargingValue);
            logInfo.Reason   = chargingResponse.Trim();

            ViSport_S2_Registered_UsersController.WorldCupChargedUserLogForSubVtv6(logInfo);

            #endregion
        }

        return("1");
    }
    public string NotifyChargingInfo(string registeredId, string userId, string requestId, string serviceId, string serviceType, string chargingValue, string chargingAccount, string chargingTime, string chargingResponse)
    {
        log.Info(" ");
        log.Info("***** LOG Euro NOTIFICATION From Tung *****");

        log.Info("User_ID : " + userId);
        log.Info("chargingValue : " + chargingValue);
        log.Info("chargingAccount : " + chargingAccount);
        log.Info("chargingTime : " + chargingTime);
        log.Info("chargingResponse : " + chargingResponse);

        log.Info("****************************************");
        log.Info(" ");

        if (chargingResponse.Trim() == "1")//CHARGED THANH CONG
        {
            #region Sinh mã dự thưởng
            int price = ConvertUtility.ToInt32(chargingValue);
            if (price == 5000)
            {
                #region Sinh 5 mã dự thưởng
                for (int i = 1; i <= 5; i++)
                {
                    string code = RandomActiveCode.Generate(8);
                    ViSport_S2_Registered_UsersController.SportGameHeroLotteryCodeInsert(userId, code);
                }
                #endregion
            }
            else if (price == 3000)
            {
                #region Sinh 5 mã dự thưởng
                for (int i = 1; i <= 3; i++)
                {
                    string code = RandomActiveCode.Generate(8);
                    ViSport_S2_Registered_UsersController.SportGameHeroLotteryCodeInsert(userId, code);
                }
                #endregion
            }
            else if (price == 2000)
            {
                #region Sinh 5 mã dự thưởng
                for (int i = 1; i <= 2; i++)
                {
                    string code = RandomActiveCode.Generate(8);
                    ViSport_S2_Registered_UsersController.SportGameHeroLotteryCodeInsert(userId, code);
                }
                #endregion
            }
            else if (price == 1000)
            {
                string code = RandomActiveCode.Generate(8);
                ViSport_S2_Registered_UsersController.SportGameHeroLotteryCodeInsert(userId, code);
            }
            #endregion

            #region LOG DOANH THU

            var logInfo = new SportGameHeroChargedUserLogInfo();

            logInfo.ID           = ConvertUtility.ToInt32(registeredId);
            logInfo.User_ID      = userId;
            logInfo.Request_ID   = requestId;
            logInfo.Service_ID   = serviceId;
            logInfo.Command_Code = "EU";

            logInfo.Service_Type       = ConvertUtility.ToInt32(serviceType);
            logInfo.Charging_Count     = 0;
            logInfo.FailedChargingTime = 0;

            logInfo.RegisteredTime = DateTime.Now;
            logInfo.ExpiredTime    = DateTime.Now.AddDays(1);

            logInfo.Registration_Channel = "SMS";
            logInfo.Status   = 1;
            logInfo.Operator = "vnmobile";
            logInfo.Price    = ConvertUtility.ToInt32(chargingValue);
            logInfo.Reason   = "Succ";

            ViSport_S2_Registered_UsersController.InsertEuroChargedUserLogForSub(logInfo);

            //ViSport_S2_Registered_UsersController.Update_SportGameHeroChargedValue(userId, ConvertUtility.ToInt32(chargingValue));

            //if (DateTime.Now > Convert.ToDateTime(AppEnv.GetSetting("StartKM")) && DateTime.Now < Convert.ToDateTime(AppEnv.GetSetting("EndKM")))
            //{
            //    ViSport_S2_Registered_UsersController.Update_ChargedValueCTKMvmgame_visport(userId, ConvertUtility.ToInt32(chargingValue));
            //}
            #endregion
        }
        else //CHARGED THAT BAI
        {
            #region LOG DOANH THU

            var logInfo = new SportGameHeroChargedUserLogInfo();

            logInfo.ID           = ConvertUtility.ToInt32(registeredId);
            logInfo.User_ID      = userId;
            logInfo.Request_ID   = requestId;
            logInfo.Service_ID   = serviceId;
            logInfo.Command_Code = "EU";

            logInfo.Service_Type       = ConvertUtility.ToInt32(serviceType);
            logInfo.Charging_Count     = 0;
            logInfo.FailedChargingTime = 0;

            logInfo.RegisteredTime = DateTime.Now;
            logInfo.ExpiredTime    = DateTime.Now.AddDays(1);

            logInfo.Registration_Channel = "SMS";
            logInfo.Status   = 1;
            logInfo.Operator = "vnmobile";
            logInfo.Price    = ConvertUtility.ToInt32(chargingValue);
            logInfo.Reason   = chargingResponse;

            ViSport_S2_Registered_UsersController.InsertEuroChargedUserLogForSub(logInfo);

            #endregion
        }

        if (chargingResponse.Trim() == "1")
        {
            #region TRA MT

            string       today       = DateTime.Now.DayOfWeek.ToString();
            const string commandCode = "EU";


            if (AppEnv.GetSetting("CTKM_Flag") == "0")
            {
                #region SEND MT CAU_HOI_BONG_DA

                //SEND MT CHO KHACH HANG

                DataTable dtQuestion = ViSport_S2_Registered_UsersController.GetQuestionInfoEuro();
                if (dtQuestion != null && dtQuestion.Rows.Count > 0)
                {
                    string message = dtQuestion.Rows[0]["Question"].ToString();
                    message = message.Replace("P1", "1").Replace("P2", "2");

                    int    questionIdnew = ConvertUtility.ToInt32(dtQuestion.Rows[0]["Id"].ToString());
                    string answer        = dtQuestion.Rows[0]["Answer"].ToString();
                    answer = answer.Replace("P1", "1").Replace("P2", "2");

                    ViSport_S2_Registered_UsersController.InsertSportGameHeroAnswerLog(userId, questionIdnew, message, answer, DateTime.Now, 0); // LUU LOG Question
                    SendMtSportGame(userId, message, serviceId, commandCode, requestId);
                }

                //END SEND MT CHO KHACH HANG

                #endregion
            }



            //}

            #endregion
        }

        return("1");
    }
Exemplo n.º 9
0
    public int Execute(int jobID)
    {
        WebServiceCharging3g webServiceCharging3G = new WebServiceCharging3g();
        string userName = "******";
        string userPass = "******";
        string cpId     = "1930";
        string price    = "4000";

        try
        {
            DataTable dtUsers = ViSport_S2_Registered_UsersController.GetSportGameUserByType(false);
            if (dtUsers != null && dtUsers.Rows.Count > 0)
            {
                string message        = string.Empty;
                string returnValue    = string.Empty;
                string notEnoughMoney = AppEnv.GetSetting("NotEnoughMoney");

                string serviceType = "Charge Hero";
                string serviceName = "ViSport_Hero";
                string reasonLog   = string.Empty;

                for (int i = 0; i < dtUsers.Rows.Count; i++)
                {
                    try
                    {
                        #region TIEN HANH CHARGED

                        price       = "5000";
                        returnValue = webServiceCharging3G.PaymentVnmWithAccount(dtUsers.Rows[i]["User_ID"].ToString(), price, "Charged Sub Anh Tai", "Anh_Tai_Sub", userName, userPass, cpId);
                        if (returnValue.Trim() == notEnoughMoney)
                        {
                            price       = "3000";
                            returnValue = webServiceCharging3G.PaymentVnmWithAccount(dtUsers.Rows[i]["User_ID"].ToString(), price, "Charged Sub Anh Tai", "Anh_Tai_Sub", userName, userPass, cpId);
                            if (returnValue.Trim() == notEnoughMoney)
                            {
                                price       = "2000";
                                returnValue = webServiceCharging3G.PaymentVnmWithAccount(dtUsers.Rows[i]["User_ID"].ToString(), price, "Charged Sub Anh Tai", "Anh_Tai_Sub", userName, userPass, cpId);
                                if (returnValue.Trim() == notEnoughMoney)
                                {
                                    price       = "1000";
                                    returnValue = webServiceCharging3G.PaymentVnmWithAccount(dtUsers.Rows[i]["User_ID"].ToString(), price, "Charged Sub Anh Tai", "Anh_Tai_Sub", userName, userPass, cpId);
                                }
                            }
                        }

                        if (returnValue == "1")
                        {
                            #region LOG DOANH THU

                            var logInfo = new SportGameHeroChargedUserLogInfo();

                            logInfo.ID           = ConvertUtility.ToInt32(dtUsers.Rows[i]["ID"].ToString());
                            logInfo.User_ID      = dtUsers.Rows[i]["User_ID"].ToString();
                            logInfo.Request_ID   = dtUsers.Rows[i]["Request_ID"].ToString();
                            logInfo.Service_ID   = dtUsers.Rows[i]["Service_ID"].ToString();
                            logInfo.Command_Code = dtUsers.Rows[i]["Command_Code"].ToString();

                            logInfo.Service_Type       = ConvertUtility.ToInt32(dtUsers.Rows[i]["Service_Type"].ToString());
                            logInfo.Charging_Count     = ConvertUtility.ToInt32(dtUsers.Rows[i]["Charging_Count"].ToString());
                            logInfo.FailedChargingTime = ConvertUtility.ToInt32(dtUsers.Rows[i]["FailedChargingTimes"].ToString());

                            logInfo.RegisteredTime = ConvertUtility.ToDateTime(dtUsers.Rows[i]["RegisteredTime"].ToString());
                            logInfo.ExpiredTime    = DateTime.Now.AddDays(1);

                            logInfo.Registration_Channel = dtUsers.Rows[i]["Registration_Channel"].ToString();
                            logInfo.Status   = ConvertUtility.ToInt32(dtUsers.Rows[i]["Status"].ToString());
                            logInfo.Operator = dtUsers.Rows[i]["Operator"].ToString();
                            logInfo.Price    = ConvertUtility.ToInt32(price);
                            logInfo.Reason   = "Succ";

                            ViSport_S2_Registered_UsersController.InsertSportGameHeroChargedUserLogForSub(logInfo);

                            #endregion
                        }
                        else
                        {
                            #region LOG DOANH THU

                            var logInfo = new SportGameHeroChargedUserLogInfo();

                            logInfo.ID           = ConvertUtility.ToInt32(dtUsers.Rows[i]["ID"].ToString());
                            logInfo.User_ID      = dtUsers.Rows[i]["User_ID"].ToString();
                            logInfo.Request_ID   = dtUsers.Rows[i]["Request_ID"].ToString();
                            logInfo.Service_ID   = dtUsers.Rows[i]["Service_ID"].ToString();
                            logInfo.Command_Code = dtUsers.Rows[i]["Command_Code"].ToString();

                            logInfo.Service_Type       = ConvertUtility.ToInt32(dtUsers.Rows[i]["Service_Type"].ToString());
                            logInfo.Charging_Count     = ConvertUtility.ToInt32(dtUsers.Rows[i]["Charging_Count"].ToString());
                            logInfo.FailedChargingTime = ConvertUtility.ToInt32(dtUsers.Rows[i]["FailedChargingTimes"].ToString());

                            logInfo.RegisteredTime = ConvertUtility.ToDateTime(dtUsers.Rows[i]["RegisteredTime"].ToString());
                            logInfo.ExpiredTime    = DateTime.Now.AddDays(1);

                            logInfo.Registration_Channel = dtUsers.Rows[i]["Registration_Channel"].ToString();
                            logInfo.Status   = ConvertUtility.ToInt32(dtUsers.Rows[i]["Status"].ToString());
                            logInfo.Operator = dtUsers.Rows[i]["Operator"].ToString();
                            logInfo.Price    = ConvertUtility.ToInt32(price);
                            logInfo.Reason   = returnValue;

                            ViSport_S2_Registered_UsersController.InsertSportGameHeroChargedUserLogForSub(logInfo);

                            #endregion
                        }

                        if (returnValue == "1")//CHARGED THANH CONG
                        {
                            #region SEND MT CHO USER

                            //SEND MT CHO KHACH HANG

                            DataTable dtQuestion = ViSport_S2_Registered_UsersController.GetQuestionInfoSportGameHero();
                            if (dtQuestion != null && dtQuestion.Rows.Count > 0)
                            {
                                message = dtQuestion.Rows[0]["Question"].ToString();

                                int    questionIdnew = ConvertUtility.ToInt32(dtQuestion.Rows[0]["Id"].ToString());
                                string answer        = dtQuestion.Rows[0]["Answer"].ToString();

                                string serviceId   = dtUsers.Rows[i]["Service_ID"].ToString();
                                string commandCode = dtUsers.Rows[i]["Command_Code"].ToString();
                                string requestId   = dtUsers.Rows[i]["Request_ID"].ToString();


                                ViSport_S2_Registered_UsersController.InsertSportGameHeroAnswerLog(dtUsers.Rows[i]["User_ID"].ToString(), questionIdnew, message, answer, DateTime.Now, 0); // LUU LOG Question
                                SendMtSportGame(dtUsers.Rows[i]["User_ID"].ToString(), message, serviceId, commandCode, requestId);
                            }

                            //END SEND MT CHO KHACH HANG

                            #endregion
                        }

                        #endregion
                    }
                    catch (Exception ex)
                    {
                        log.Error("Anh tai bong da Loi charged : " + ex);
                        continue;
                    }
                }
            }

            return(1);
        }
        catch (Exception ex)
        {
            log.Error("Anh tai bong da Loi lay tap User : " + ex);
            return(0);
        }
    }