示例#1
0
    public int Execute(int jobID)
    {
        WebServiceCharging3g webServiceCharging3G = new WebServiceCharging3g();
        string userName = "******";
        string userPass = "******";
        string cpId     = "1928";
        string price    = "5000";

        try
        {
            DataTable dtUsers = VoteRegisterController.SecretGetUserByType(false);
            if (dtUsers != null && dtUsers.Rows.Count > 0)
            {
                string message        = string.Empty;
                string returnValue    = string.Empty;
                string notEnoughMoney = "Result:12,Detail:Not enough money.";

                string serviceType = "BiMat_HotGirl";
                string serviceName = "BiMat_HotGirl";
                string reasonLog   = string.Empty;
                foreach (DataRow dr in dtUsers.Rows)
                {
                    string userId = dr["User_ID"].ToString();

                    returnValue = webServiceCharging3G.PaymentVnmWithAccount(userId, price, serviceType, serviceName, userName, userPass, cpId);
                    if (returnValue.Trim() == notEnoughMoney)
                    {
                        price       = "3000";
                        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);
                            }
                        }
                    }

                    if (returnValue.Trim() == "1")//CHARGED THANH CONG
                    {
                        reasonLog = "Succ";
                    }
                    else
                    {
                        reasonLog = returnValue;
                    }

                    #region LOG DOANH THU

                    VoteChargedUserLogInfo logInfo = new VoteChargedUserLogInfo();

                    logInfo.ID                   = ConvertUtility.ToInt32(dr["ID"].ToString());
                    logInfo.User_ID              = userId;
                    logInfo.Request_ID           = dr["Request_ID"].ToString();
                    logInfo.Service_ID           = dr["Service_ID"].ToString();
                    logInfo.Command_Code         = dr["Command_Code"].ToString();
                    logInfo.Service_Type         = 0;//Charged Sub Service_Type
                    logInfo.Charging_Count       = ConvertUtility.ToInt32(dr["Charging_Count"].ToString());
                    logInfo.FailedChargingTime   = ConvertUtility.ToInt32(dr["FailedChargingTimes"].ToString());
                    logInfo.RegisteredTime       = DateTime.Now;
                    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.Vote_PersonId        = 1;
                    logInfo.Reason               = reasonLog;

                    VoteRegisterController.SecretChargedUserLogInsertForSub(logInfo);

                    #endregion

                    #region GUI SMS CHO KHACH_HANG

                    if (returnValue.Trim() == "1")
                    {
                        string serviceId   = dr["Service_ID"].ToString();
                        string commandCode = dr["Command_Code"].ToString();
                        string requestId   = dr["Request_ID"].ToString();

                        DataTable dt = VoteRegisterController.SecretGetCountByPersonId(userId, 1);
                        message = "So luot Dat gach cua ban: " + dt.Rows[0]["Count"] + ". Ban dang thuoc top " + dt.Rows[0]["Top"] + " nhung nguoi dat gach nhieu nhat. Dat gach cang nhieu ban cang co nhieu co hoi gap mat de biet BI MAT DONG TROI cua hot girl Mai Tho. De tiep tuc dat gach, Soan Gach gui 8379 hoac su dung 3G truy cap http://wap.vietnamobile.com.vn. HT: 19001255";

                        SendMtSecret(userId, serviceId, commandCode, message, requestId);

                        //GUI THEM TIN TUC BI_MAT_MAI_THO
                        DataTable dtSecretContent = VoteRegisterController.SecretGetRandomContent();
                        if (dtSecretContent != null && dtSecretContent.Rows.Count > 0)
                        {
                            message = dtSecretContent.Rows[0]["MT1"].ToString();
                            SendMtSecret(userId, serviceId, commandCode, message, requestId);
                        }
                    }

                    #endregion
                }
            }
            return(1);
        }
        catch (Exception ex)
        {
            log.Error(ex.ToString());
            return(0);
        }
    }