protected void Page_Load(object sender, EventArgs e)
    {
        var hd3 = new HD3.HD3(Request);

        Response.Write("<b>Vendor List</b><br/>");
        if (hd3.deviceVendors()) {
            string rawreply = hd3.getRawReply();
            Response.Write("JSON object dump "+rawreply + "<br/>");
        } else {
            Response.Write(hd3.getError() + "<br/>");
            Response.Write(hd3.getLog());
        }
        hd3.cleanUp();

        Response.Write("<b>All Nokia Models</b><br/>");
        if (hd3.deviceModels("Nokia")) {
            string rawreply = hd3.getRawReply();
            Response.Write("JSON object dump " + rawreply + "<br/>");
        } else {
            Response.Write(hd3.getError() + "<br/>");
            Response.Write(hd3.getLog());
        }
        hd3.cleanUp();

        Response.Write("<b>Nokia N95 device properties</b><br/>");
        if (hd3.deviceView("Nokia","N95")) {
            string rawreply = hd3.getRawReply();
            Response.Write("JSON object dump " + rawreply + "<br/>");
            object reply = hd3.getReply();
            Response.Write(hd3.getLog());
           /*
            Response.Write("Vendor " + reply["hd_specs"]["general_vendor"] + "<br/>");
            Response.Write("Model " + reply["hd_specs"]["general_model"] + "<br/>");
            Response.Write("Browser " + reply["hd_specs"]["general_browser"] + "<br/>");
            Response.Write("Platform " + reply["hd_specs"]["general_platform"] + "<br/>");
            * */
        } else {
            Response.Write(hd3.getError() + "<br/>");
            Response.Write(hd3.getLog());
        }
        hd3.cleanUp();

        //===========================================================
        Response.Write("<b>Handsets with Network CDMA</b><br/>");
        hd3.ReadTimeout = 600;    // Increse the read timeout on long running requests
        if (hd3.deviceWhatHas("network","cdma")) {
            string rawreply = hd3.getRawReply();
            Response.Write("JSON object dump " + rawreply + "<br/>");
            object reply = hd3.getReply();
        } else {
            Response.Write(hd3.getError() + "<br/>");
            Response.Write(hd3.getLog());
        }
        hd3.cleanUp();
    }
コード例 #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string log = "";
        string file = Request.PhysicalApplicationPath + "\\normal.txt";
        string[] lines = System.IO.File.ReadAllLines(file);
        char[] separator = new char[] { '|' };
        var hd3 = new HD3.HD3(Request);
        int i=0;
        /*
        // Display the file contents by using a foreach loop.
        Response.Write("Testing normal device http headers. Expect all normal agents to return 301 - Test begins.<br/>");
        foreach (string line in lines) {
            if (i++ > 30) break ;
            string[] strSplitArr = line.Split(separator);
            if (strSplitArr.Length > 1) {
                hd3.setDetectVar("user-agent", strSplitArr[0]);
                hd3.setDetectVar("x-wap-profile", strSplitArr[1]);
            } else {
                hd3.setDetectVar("user-agent", strSplitArr[0]);
            }
            hd3.setDetectVar("x-test-header", null);

            log = hd3.getLog();
            if (log != "") {
                Response.Write(log);
                Response.Write("<br/>");
            }
            hd3.cleanUp();
        }
        Response.Write("Test complete.<br/>");
        */
        string file2 = Request.PhysicalApplicationPath + "\\mobile.txt";
        string[] lines2 = System.IO.File.ReadAllLines(file2);
        i = 0;

        Response.Write("<b> Start " + DateTime.Now +"<br/>");
        // Prime the cache
        hd3.setDetectVar("user-agent", "android SGH-9000");
        hd3.siteDetect();
        hd3.cleanUp();

        // Display the file contents by using a foreach loop.
        Response.Write("Expect all mobile agents to return JSON and display some device info.<br/>");
        Stopwatch stopwatch = new Stopwatch();
        stopwatch.Start();

        foreach (string line in lines2) {
           // if (i++ > 30) break;

            string[] strSplitArr = line.Split(separator);
            if (strSplitArr.Length > 1) {
                hd3.setDetectVar("user-agent", strSplitArr[0]);
                hd3.setDetectVar("x-wap-profile", strSplitArr[1]);
            } else {
                hd3.setDetectVar("user-agent", strSplitArr[0]);
            }
            //hd3.setDetectVar("x-test-header", null);

            if (hd3.siteDetect()) {
                string rawreply = hd3.getRawReply();
                var reply = (IDictionary)hd3.getReply();
                Response.Write("<b>" + DateTime.Now + " " + " Vendor " + ((IDictionary)reply["hd_specs"])["general_vendor"]);
                Response.Write(",Model " + ((IDictionary)reply["hd_specs"])["general_model"]);
                Response.Write(",Browser " + ((IDictionary)reply["hd_specs"])["general_browser"]);
                Response.Write(",Platform " + ((IDictionary)reply["hd_specs"])["general_platform"] + "</b><br/>");
                Response.Write("JSON object dump " + rawreply + "<br/>");
            } else {
                string rawreply = hd3.getRawReply();
                Response.Write(i.ToString() + "<b>FAIL</b>" + rawreply + "<br/>");
            }
            Response.Write(hd3.getLog());
            hd3.cleanUp();
        }
        stopwatch.Stop();
        Response.Write("Detections "+i.ToString() + " Time " +stopwatch.Elapsed.ToString());
        Response.Write("<br/>");
        Response.Write(hd3.getLog());
        Response.Write("<br/>");
        Response.Write("Test complete.<br/>");
    }
コード例 #3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        var hd3 = new HD3.HD3(Request);

        Response.Write("<b>Simple Detection - Using web browser standard headers (expect NotFound)</b><br/>");
        if (hd3.siteDetect()) {
            string rawreply = hd3.getRawReply();
            Response.Write(rawreply + "<br/>");
        } else {
            Response.Write(hd3.getError() + "<br/>");
            Response.Write(hd3.getLog());
        }
        hd3.cleanUp();

        Response.Write("<b>Simple Detection - Setting Headers for an N95</b><br/>");
        hd3.setDetectVar("user-agent", "Mozilla/5.0 (SymbianOS/9.2; U; Series60/3.1 NokiaN95-3/20.2.011 Profile/MIDP-2.0 Configuration/CLDC-1.1 ) AppleWebKit/413");
        hd3.setDetectVar("x-wap-profile", "http://nds1.nds.nokia.com/uaprof/NN95-1r100.xml");
        if (hd3.siteDetect()) {
            string rawreply = hd3.getRawReply();
            Response.Write("JSON object dump "+rawreply + "<br/>");
            var reply = (IDictionary) hd3.getReply();
            Response.Write("Vendor " + ((IDictionary)reply["hd_specs"])["general_vendor"] + "<br/>");
            Response.Write("Model " + ((IDictionary)reply["hd_specs"])["general_model"] + "<br/>");
            Response.Write("Browser " + ((IDictionary)reply["hd_specs"])["general_browser"] + "<br/>");
            Response.Write("Platform " + ((IDictionary)reply["hd_specs"])["general_platform"] + "<br/>");
            Response.Write(hd3.getLog());
        } else {
            Response.Write(hd3.getError() + "<br/>");
            Response.Write(hd3.getLog());
        }
        hd3.cleanUp();

        Response.Write("<b>Simple Detection - Passing a different ip address (only works against web service)</b><br/>");
        // Query for some other information (remember the N95 headers are still set).
        // Add detection options to query for additional reply information such as geoip information
        // Note : We use the ipaddress to get the geoip location.
        hd3.setDetectVar("ipaddress", "64.34.165.180");
        hd3.setDetectVar("user-agent", "Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_3_3 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8J2 Safari/6533.18.5");
        hd3.setDetectVar("x-wap-profile", "http://nds1.nds.nokia.com/uaprof/NN95-1r100.xml");
        if (hd3.siteDetect("hd_specs, geoip")) {
            string rawreply = hd3.getRawReply();
            Response.Write("JSON object dump " + rawreply + "<br/>");
            var reply = (IDictionary)hd3.getReply();
            Response.Write("Vendor " + ((IDictionary)reply["hd_specs"])["general_vendor"] + "<br/>");
            Response.Write("Model " + ((IDictionary)reply["hd_specs"])["general_model"] + "<br/>");
            Response.Write("Browser " + ((IDictionary)reply["hd_specs"])["general_browser"] + "<br/>");
            Response.Write("Platform " + ((IDictionary)reply["hd_specs"])["general_platform"] + "<br/>");
            Response.Write(hd3.getLog());
        } else {
            Response.Write(hd3.getError() + "<br/>");
            Response.Write(hd3.getLog());
        }
        hd3.cleanUp();

        //===========================================================
        Response.Write("<b>All Detection Information</b><br/>");
        hd3.ReadTimeout = 600;    // Increse the read timeout on long running requests
        if (hd3.siteFetchArchive()) {
            string rawreply = hd3.getRawReply();
            Response.Write("Size returned : "+ rawreply.Length + "<br/>");
        } else {
            Response.Write(hd3.getError() + "<br/>");
            Response.Write(hd3.getLog());
        }
        hd3.cleanUp();

        //=========================================
        Response.Write("<b>All Handset Information</b><br/>");
        hd3.ReadTimeout = 600;    // Increse the read timeout on long running requests
        if (hd3.siteFetchArchive()) {
            string rawreply = hd3.getRawReply();
            Response.Write("Size returned : " + rawreply.Length + "<br/>");
        } else {
            Response.Write(hd3.getError() + "<br/>");
            Response.Write(hd3.getLog());
        }
        hd3.cleanUp();
    }
コード例 #4
0
 public void Initialize()
 {
     hd3 = new HD3.HD3();
     secretConfig = new SecretConfig();
 }
コード例 #5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string file = Request.PhysicalApplicationPath + "\\normal.txt";
        string[] lines = System.IO.File.ReadAllLines(file);
        char[] separator = new char[] { '|' };
        Console.WriteLine(Request);
        var hd3 = new HD3.HD3(Request);
        int i=0;
        // Display the file contents by using a foreach loop.
        Response.Write("Expect all normal agents to return 301 - Test begins.<br/>");
        foreach (string line in lines) {
            if (i++ > 30) break ;
            string[] strSplitArr = line.Split(separator);
            if (strSplitArr.Length > 1) {
                hd3.setDetectVar("user-agent", strSplitArr[0]);
                hd3.setDetectVar("x-wap-profile", strSplitArr[1]);
            } else {
                hd3.setDetectVar("user-agent", strSplitArr[0]);
            }

            if (hd3.siteDetect()) {
                string rawreply = hd3.getRawReply();
                Response.Write("JSON object dump " + rawreply + "<br/>");
                dynamic reply = hd3.getReply();
                Response.Write("Vendor " + reply["hd_specs"]["general_vendor"] + "<br/>");
                Response.Write("Model " + reply["hd_specs"]["general_model"] + "<br/>");
                Response.Write("Browser " + reply["hd_specs"]["general_browser"] + "<br/>");
                Response.Write("Platform " + reply["hd_specs"]["general_platform"] + "<br/>");
                Response.Write(hd3.getLog());
            } else {
                dynamic reply = hd3.getReply();
                Response.Write("Count "+i+" got "+reply["status"]+" on "+line+"<br/>");
                //Response.Write(hd3.getLog());
            }
            hd3.cleanUp();
        }
        Response.Write("Test complete.<br/>");

        string file2 = Request.PhysicalApplicationPath + "\\mobile.txt";
        string[] lines2 = System.IO.File.ReadAllLines(file2);
        i = 0;
        // Display the file contents by using a foreach loop.
        Response.Write("Expect all mobile agents to return JSON and display some device info.<br/>");
        foreach (string line in lines2) {
            if (i++ > 30) break;
            string[] strSplitArr = line.Split(separator);
            if (strSplitArr.Length > 1) {
                hd3.setDetectVar("user-agent", strSplitArr[0]);
                hd3.setDetectVar("x-wap-profile", strSplitArr[1]);
            } else {
                hd3.setDetectVar("user-agent", strSplitArr[0]);
            }

            if (hd3.siteDetect()) {
                string rawreply = hd3.getRawReply();
                dynamic reply = hd3.getReply();
                Response.Write("<b>Vendor " + reply["hd_specs"]["general_vendor"]);
                Response.Write(",Model " + reply["hd_specs"]["general_model"]);
                Response.Write(",Browser " + reply["hd_specs"]["general_browser"]);
                Response.Write(",Platform " + reply["hd_specs"]["general_platform"] + "</b><br/>");
                Response.Write("JSON object dump " + rawreply + "<br/>");
                //Response.Write(hd3.getLog());
            } else {
                dynamic reply = hd3.getReply();
                Response.Write("<h2>FAIL</h2>");
                Response.Write(hd3.getLog());
                //Response.Write("Count " + i + " got " + reply["status"] + " on " + line + "<br/>");
            }
            hd3.cleanUp();
        }
        Response.Write("Test complete.<br/>");
    }