Example #1
0
        public static List <MemberCardModel> GetEmergencyWorkers()
        {
            WebClient client = new CookiesWebClient();
            string    page   = client.DownloadString("https://intertraxserver.com/resourcemgrweb/login.aspx");

            var    match     = Regex.Match(page, "id=\"__VIEWSTATE\" value=\"([^\"]+)\"");
            string viewstate = match.Groups[1].Value;

            match = Regex.Match(page, "id=\"__EVENTVALIDATION\" value=\"([^\"]+)\"");
            string validation = match.Groups[1].Value;

            string foo = "__LASTFOCUS=&__EVENTTARGET=ctl00%24ContentPlaceHolder1%24btnSubmitLink&__EVENTARGUMENT=&__VIEWSTATE="
                         + HttpUtility.UrlEncode(viewstate)
                         + "&__EVENTVALIDATION="
                         + HttpUtility.UrlEncode(validation)
                         + "&ctl00%24ContentPlaceHolder1%24txtUsername="******"carddataUser"] ?? "")
                         + "&ctl00%24ContentPlaceHolder1%24txtPassword="******"carddataPassword"] ?? "");

            client.Headers.Add(HttpRequestHeader.ContentType, "application/x-www-form-urlencoded");
            page = client.UploadString("https://intertraxserver.com/resourcemgrweb/Login.aspx", foo
                                       );

            match = Regex.Match(page, "TokenID: '([^']+)'");
            string token = match.Groups[1].Value;

            client.Headers.Add(HttpRequestHeader.Accept, "application/json, text/javascript, */*; q=0.01");
            client.Headers.Add(HttpRequestHeader.ContentType, "application/json");
            page = client.UploadString("https://intertraxserver.com/resourceMgrSvc/Responder/List", "{\"TokenID\":\"" + token + "\",\"Item\":{\"Columns\":[\"FirstName\",\"IdentityCode\",\"LastName\",\"OrganizationName\",\"Rank\"],\"Filter\":[],\"Sort\":[],\"RecordsPerPage\":1,\"Page\":1}}");

            match = Regex.Match(page, "\"total\":(\\d+)");
            string count = match.Groups[1].Value;

            client.Headers.Add(HttpRequestHeader.Accept, "application/json, text/javascript, */*; q=0.01");
            client.Headers.Add(HttpRequestHeader.ContentType, "application/json");
            page = client.UploadString("https://intertraxserver.com/resourceMgrSvc/Responder/List", "{\"TokenID\":\"" + token + "\",\"Item\":{\"Columns\":[\"FirstName\",\"IdentityCode\",\"LastName\",\"OrganizationName\",\"Rank\"],"
                                       + "\"Filter\":[],"
                                       + "\"Sort\":[{\"Field\":\"LastName\",\"DescendingOrder\":false},{\"Field\":\"FirstName\",\"DescendingOrder\":false}],"
                                       + "\"RecordsPerPage\":" + count + ",\"Page\":1}}");
            JavaScriptSerializer ser = new JavaScriptSerializer();

            return(ser.Deserialize <ListModel>(page).Data);
        }
        public static List<MemberCardModel> GetEmergencyWorkers()
        {
            WebClient client = new CookiesWebClient();
            string page = client.DownloadString("https://intertraxserver.com/resourcemgrweb/login.aspx");

            var match = Regex.Match(page, "id=\"__VIEWSTATE\" value=\"([^\"]+)\"");
            string viewstate = match.Groups[1].Value;

            match = Regex.Match(page, "id=\"__EVENTVALIDATION\" value=\"([^\"]+)\"");
            string validation = match.Groups[1].Value;

            string foo = "__LASTFOCUS=&__EVENTTARGET=ctl00%24ContentPlaceHolder1%24btnSubmitLink&__EVENTARGUMENT=&__VIEWSTATE="
                + HttpUtility.UrlEncode(viewstate)
                + "&__EVENTVALIDATION="
                + HttpUtility.UrlEncode(validation)
                + "&ctl00%24ContentPlaceHolder1%24txtUsername="******"carddataUser"] ?? "")
                + "&ctl00%24ContentPlaceHolder1%24txtPassword="******"carddataPassword"] ?? "");

            client.Headers.Add(HttpRequestHeader.ContentType, "application/x-www-form-urlencoded");
            page = client.UploadString("https://intertraxserver.com/resourcemgrweb/Login.aspx",foo
                );

            match = Regex.Match(page, "TokenID: '([^']+)'");
            string token = match.Groups[1].Value;

            client.Headers.Add(HttpRequestHeader.Accept, "application/json, text/javascript, */*; q=0.01");
            client.Headers.Add(HttpRequestHeader.ContentType, "application/json");
            page = client.UploadString("https://intertraxserver.com/resourceMgrSvc/Responder/List", "{\"TokenID\":\"" + token + "\",\"Item\":{\"Columns\":[\"FirstName\",\"IdentityCode\",\"LastName\",\"OrganizationName\",\"Rank\"],\"Filter\":[],\"Sort\":[],\"RecordsPerPage\":1,\"Page\":1}}");

            match = Regex.Match(page, "\"total\":(\\d+)");
            string count = match.Groups[1].Value;

            client.Headers.Add(HttpRequestHeader.Accept, "application/json, text/javascript, */*; q=0.01");
            client.Headers.Add(HttpRequestHeader.ContentType, "application/json");
            page = client.UploadString("https://intertraxserver.com/resourceMgrSvc/Responder/List", "{\"TokenID\":\"" + token + "\",\"Item\":{\"Columns\":[\"FirstName\",\"IdentityCode\",\"LastName\",\"OrganizationName\",\"Rank\"],"
                + "\"Filter\":[],"
                + "\"Sort\":[{\"Field\":\"LastName\",\"DescendingOrder\":false},{\"Field\":\"FirstName\",\"DescendingOrder\":false}],"
                + "\"RecordsPerPage\":" + count + ",\"Page\":1}}");
            JavaScriptSerializer ser = new JavaScriptSerializer();
            return ser.Deserialize<ListModel>(page).Data;
        }