Ejemplo n.º 1
0
        public void ProcessRequest(HttpContext context)
        {
            Log();
            state    = string.Empty;
            deviceId = null;

            //   StringBuilder builder = new StringBuilder();
            // builder.AppendFormat("status={0}&key={1}", "pending", "234324sd+=1@3%2~4");

            //TextWriter writer = new StringWriter(builder);

            //context.Response.Write(builder);
            //context.Response.Status = "OK";
            // context.Response.StatusCode = 200;
            NameValueCollection query = context.Request.QueryString;

            if (query.Count > 0)
            {
                deviceId = query["code"];
            }


            string queryString = CreateQueryString();

            SendRequest(queryString);

            string responseString = "";

            if (query["v"] == "2" || query["v"] == "3")
            {
                string appId = context.Request.QueryString["appId"];
                if (string.IsNullOrEmpty(appId))
                {
                    appId = Constants.DefaultAppId;
                }

                responseString = V2Handler.ConstructResponse(deviceId, state, appId);
            }

            context.Response.Write(responseString);
            context.Response.StatusCode = 200;
            context.Response.Cache.SetCacheability(HttpCacheability.NoCache);
            context.Response.Cache.SetExpires(DateTime.UtcNow);

            // string logMessage = string.Format("url={0}, UA={1}, response={2}"
            //                           , context.Request.RawUrl
            //                         , context.Request.UserAgent
            //                       , responseString);
            //Log(logMessage);
            try
            {
                //AddElement(context, responseString);
            }
            catch (Exception)
            {
            }
        }
Ejemplo n.º 2
0
        public string GetResponseString(string appId, string deviceId
                                        , string locale, bool debug, out TransactionStatus transactionStatus)
        {
            transactionStatus = TransactionStatus.Failed;
            string queryString    = CreateQueryString(deviceId);
            bool   isSuccess      = false;
            string responseString = SendRequest(deviceId, queryString, locale, debug, out isSuccess);

            if (!isSuccess)
            {
                if (queryLocalStore)
                {
                    responseString = V2Handler.ConstructResponse(deviceId, string.Empty, appId, locale, debug, out transactionStatus);
                }
            }
            else
            {
                transactionStatus = TransactionStatus.Completed;
            }

            return(responseString);
        }