Esempio n. 1
0
    public int Execute(int jobID)
    {
        //var webServiceCharging3G = new WebServiceCharging3g();
        //string userName = "******";
        //string userPass = "******";
        //string cpId = "1928";
        string price = "0";

        DataTable dtUser = VoteRegisterController.Mo949GetUserForReCharged();

        if (dtUser != null && dtUser.Rows.Count > 0)
        {
            string userId;
            string commandCode;
            string requestId;
            string serviceId;

            string msg;

            foreach (DataRow dr in dtUser.Rows)
            {
                userId      = dr["User_ID"].ToString();
                commandCode = dr["Command_Code"].ToString().ToUpper();
                requestId   = dr["Request_ID"].ToString();
                serviceId   = dr["Service_ID"].ToString();

                if (commandCode == "GAMEHOT" || commandCode == "NCHAY")
                {
                    price = "10000";
                }
                else if (commandCode == "VIDEOHAY")
                {
                    price = "2000";
                }
                else if (commandCode == "TRUYENHOT")
                {
                    price = "5000";
                }
                string   msgReturn = PaymentVnmWapChargingOptimize(price, userId, commandCode);
                string[] msgResult = msgReturn.Split('|');
                msg   = msgResult[0].Trim();
                price = msgResult[1].Trim();

                #region Log Doanh Thu

                var e = new VoteChargedUserLogInfo();
                e.ID           = ConvertUtility.ToInt32(dr["ID"].ToString());
                e.User_ID      = userId;
                e.Request_ID   = requestId;
                e.Service_ID   = serviceId;
                e.Command_Code = commandCode;
                e.Service_Type = 0;

                e.RegisteredTime       = DateTime.Now;
                e.Registration_Channel = "SMS";
                e.Operator             = dr["Operator"].ToString();

                e.Reason = msg == "1" ? "Succ" : msg;
                e.Price  = ConvertUtility.ToInt32(price);

                VoteRegisterController.Mo949ChargedUserLogInsertForSub(e);

                #endregion

                if (msg == "1")
                {
                    string url = string.Empty;
                    string messageContent;

                    if (commandCode == "GAMEHOT")
                    {
                        #region GAME

                        DataTable dtGame = VoteRegisterController.Mo949GetRandomGame();
                        url = "";
                        if (dtGame != null && dtGame.Rows.Count > 0)
                        {
                            try
                            {
                                var urlservice = new VMGGame.MOReceiver();
                                url = urlservice.VMG_ReturnUrlForGame(ConvertUtility.ToString(dtGame.Rows[0]["GID"]), 0, userId, ConvertUtility.ToInt32(dtGame.Rows[0]["Partner_ID"]), "XZONE", "WAP", "vnmobile", "WAP.XZONE.VN", "", "");
                                int indexofhttp = url.IndexOf("http://");
                                if (indexofhttp == -1)
                                {
                                    url = "http://" + url;
                                }
                                else
                                {
                                    url = url.Substring(indexofhttp);
                                }
                            }
                            catch (Exception ex) { url = ""; }
                        }

                        messageContent = "Ban da mua GAME thanh cong. Click vao link sau de tai ve may " + url;
                        SendMtMo949(userId, messageContent, serviceId, commandCode, requestId);

                        #endregion
                    }
                    else if (commandCode == "NCHAY")
                    {
                        #region MUSIC

                        DataTable dtMusic = VoteRegisterController.Mo949GetRandomMusic();
                        if (dtMusic != null && dtMusic.Rows.Count > 0)
                        {
                            url = GetVnmDownloadItem(GetTelco(userId), "22", dtMusic.Rows[0]["W_MItemID"].ToString(), AppEnv.MD5Encrypt(dtMusic.Rows[0]["W_MItemID"].ToString()));
                        }

                        messageContent = "Ban da mua Nhac Chuong thanh cong. Click vao link sau de tai ve may " + url;
                        SendMtMo949(userId, messageContent, serviceId, commandCode, requestId);

                        #endregion
                    }
                    else if (commandCode == "VIDEOHAY")
                    {
                        #region VIDEO

                        DataTable dtVideo = VoteRegisterController.Mo949GetRandomVideo();
                        if (dtVideo != null && dtVideo.Rows.Count > 0)
                        {
                            url = GetDownloadItem(GetTelco(userId), "5", dtVideo.Rows[0]["W_VItemID"].ToString(), AppEnv.MD5Encrypt(dtVideo.Rows[0]["W_VItemID"].ToString()));
                        }

                        messageContent = "Ban da mua Video hot thanh cong. Click vao link sau de tai ve may " + url;
                        SendMtMo949(userId, messageContent, serviceId, commandCode, requestId);

                        #endregion
                    }
                    else if (commandCode == "TRUYENHOT")
                    {
                        #region TRUYEN HOT

                        string    key      = DateTime.Now.ToString("yyyyMMdd");
                        string    en       = AppEnv.MD5Encrypt(key);
                        DataTable dtTruyen = VoteRegisterController.Mo949GetRandomVideo();
                        if (dtTruyen != null && dtTruyen.Rows.Count > 0)
                        {
                            url = "http://wap.vietnamobile.com.vn/thugian/truyenmoi.aspx?k=" + en;
                        }

                        messageContent = "Ban da mua Truyen Hot thanh cong. Click vao link sau de doc truyen " + url;
                        SendMtMo949(userId, messageContent, serviceId, commandCode, requestId);

                        #endregion
                    }
                }
            }
        }

        //{"List":[{"Type":"text","Content":"noi dung text 1"},{"Type":"wappush","Content":"http://xzone.vn"}]}

        return(1);
    }