Ejemplo n.º 1
0
        /// <summary>
        /// 呼叫Gash Web Service 取得 玩家擁有gash+專用點數  //edit 2009/11/10
        /// </summary>
        /// <param name="tmpGash">Gash帳號</param>
        /// <returns>(成功:玩家的點數 失敗:-1)</returns>
        public static int GetUserGashPoint(string tmpGash, string str_Region)
        {
            string ServiceCode = (string)ConfigurationManager.AppSettings["PayServiceCode"]??"";
            string ServiceRegion = (string) ConfigurationManager.AppSettings["PayServiceRegion"] ?? "";
            string x = string.Empty;
            try
            {
                ServiceAccount Gash_sp = new ServiceAccount();
                MainAccount sp = new MainAccount();
                switch (str_Region.ToUpper())
                {
                    case "TW":
                        Gash_sp.Url = Convert.ToString(System.Configuration.ConfigurationManager.AppSettings["GASHv30FWS_ServiceAccount"] ?? "");
                        sp.Url = Convert.ToString(System.Configuration.ConfigurationManager.AppSettings["GASHv30FWS_MainAccount"] ?? "");
                        break;
                    case "HK":
                        Gash_sp.Url = Convert.ToString(System.Configuration.ConfigurationManager.AppSettings["GASHv30FWS_ServiceAccount_HK"] ?? "");
                        sp.Url = Convert.ToString(System.Configuration.ConfigurationManager.AppSettings["GASHv30FWS_MainAccount_HK"] ?? "");
                        ServiceRegion = (string) ConfigurationManager.AppSettings["PayServiceRegion_HK"] ?? "";
                        break;
                    default:
                        Gash_sp.Url = Convert.ToString(System.Configuration.ConfigurationManager.AppSettings["GASHv30FWS_ServiceAccount"] ?? "");
                        sp.Url = Convert.ToString(System.Configuration.ConfigurationManager.AppSettings["GASHv30FWS_MainAccount"] ?? "");
                        break;
                }

                if (tmpGash.Length <= 0)
                { return -1; }
                else
                {
                    string myresult = Gash_sp.ServiceAccount_GetRemainingPoints(ServiceCode, ServiceRegion, tmpGash);
                    Gash_sp.Dispose();

                    if (myresult.Length > 0)
                    {
                        if (myresult.Substring(0, 2).ToString() == "1;")
                        {
                            x = myresult.Substring(2, myresult.Length - 2);
                            return System.Int32.Parse(x);
                        }
                        else if (myresult == "-1;Check_ServiceAccount_Failed")
                        {

                            myresult = sp.MainAccount_GetRemainingPoints(tmpGash);
                            if (myresult.Length > 0)
                            {
                                if (myresult.Substring(0, 2).ToString() == "1;")
                                {
                                    x = myresult.Substring(2, myresult.Length - 2);
                                    return System.Int32.Parse(x);
                                }
                                else
                                    return -1;
                            }
                            else
                                return -1;

                        }
                        else
                            return -1;
                    }
                    else
                        return -1;
                }
            }
            catch
            {
                return -1;
            }
        }
        /// <summary>
        /// 取得玩家擁有gash點數+遊戲/服務專用點數;
        /// 需帶入專用點數所屬的線上服務代碼;
        /// 適用於已開啟此線上服務的服務帳號
        /// </summary>
        /// <param name="ServiceAccount"></param>
        /// <param name="ServiceCode"></param>
        /// <param name="ServiceRegion"></param>
        /// <param name="GashRegion"></param>
        /// <returns></returns>
        public int GetUserTotalPoint(string ServiceAccount,string ServiceCode,string ServiceRegion, string GashRegion)
        {
            int Result = 0;
            string wsResult = string.Empty;
            string[] aryResult;

            using (ServiceAccount ws = new ServiceAccount())
            {
                ws.Url = GetGashWSUrl("ServiceAccount", GashRegion.ToUpper());
                try
                {
                    //WS return: intResult;Outstring
                    //intResult: (1  Success)
                    //Outstring: will be RemainingPoints when intResult is 1
                    //未開啟此線上服務:"-1;Check_ServiceAccount_Failed"
                    wsResult = ws.ServiceAccount_GetRemainingPoints(ServiceCode, ServiceRegion, ServiceAccount);
                    aryResult = wsResult.Split(";".ToCharArray());
                    if (aryResult[0] == "1") int.TryParse(aryResult[1], out Result);
                    OutputResult = aryResult[0];
                }
                catch (Exception ex)
                {
                    Result = -1;
                    WSException = ex;
                    aryResult = new string[] { "" };
                }
            }

            OutputMsg = (aryResult != null && aryResult.Length > 1) ? aryResult[1] : wsResult;

            return Result;
        }