Пример #1
0
        void TestHTTP()
        {
            /* Test HTTP GET Code */
            String testString = LoadResourceText.GetNetwork("http://introtoapps.com/datastore.php?action=list&appid=12345678", "GET");

            DisplayAlert("Alert", "Test get: " + testString, "OK");
        }
Пример #2
0
        void TestUserLoad()
        {
            /* Test User Loading Code: */
            String      userJson = LoadResourceText.GetLocal("DGDGConnect.user_sample_harry.json");
            UserProfile test     = JsonParser.ParseToUser(userJson);

            DisplayAlert("Alert", "Loaded user password: "******"OK");
        }
Пример #3
0
        public static String GetResult(String p_action, String p_objectid, String p_serialized_json, String p_http_method = "GET")
        {
            String postResult;
            String URI;

            // The following switch allows the programmer to define an action in lamence terms and still function
            switch (p_action)
            {
            case ("save"):
                p_action = save_action;
                break;

            case ("load"):
                p_action = load_action;
                break;

            case ("list"):
                p_action = list_action;
                break;

            default:
                break;
            }

            //Define the full URI
            if (p_serialized_json == "")
            {
                URI = URL + p_action + AND + APPID + AND + OBJID + p_objectid;
            }
            else
            {
                URI = URL + p_action + AND + APPID + AND + OBJID + p_objectid + AND + "data=" + p_serialized_json;
            }

            //Do the HTTP POST request and get the result
            try
            {
                //Attempt to do the HTTP request
                postResult = LoadResourceText.GetNetwork(URI, p_http_method);
            }
            catch (Exception ex)
            {
                //Request failed (likely bad parameters)
                postResult = "Web request failed.";
            }
            return(postResult);
        }
Пример #4
0
        public static int LoadSampleQuiz()
        {
            /* Method:      LoadSampleQuiz
             *  Description: Loads the locally stored sample quiz array into memory
             */
            List <Quiz> t_quizList;

            String data = LoadResourceText.GetLocal("DGDGConnect.quizzes_sample_xamarin.json");

            if (data != "File not found." && data != "Unknown exception.")
            {
                t_quizList = JsonParser.ParseToQuizList(data);

                instance = t_quizList;
                return(1);
            }
            else
            {
                return(0);
            }
        }