示例#1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            try
            {
                // Create a request for the URL.
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(
                    "http://www.ticketmaster.com/json/search/event/local?aid=1577176");

                request.CookieContainer = cookieJar;
                // If required by the server, set the credentials.
                request.Credentials = CredentialCache.DefaultCredentials;
                // Get the response.
                WebResponse response = request.GetResponse();
                // Display the status.
                Console.WriteLine(((HttpWebResponse)response).StatusDescription);
                // Get the stream containing content returned by the server.
                Stream dataStream = response.GetResponseStream();
                // Open the stream using a StreamReader for easy access.
                StreamReader reader = new StreamReader(dataStream);
                // Read the content.
                string responseFromServer = reader.ReadToEnd();
                // Display the content.
                //Console.WriteLine(responseFromServer);
                //richTextBox1.Text = responseFromServer;
                // Clean up the streams and the response.
                reader.Close();
                response.Close();

                //StreamReader reader = new StreamReader( Application.StartupPath + "\\response.txt");
                //string responseFromServer = reader.ReadToEnd();

                TktMaster.clstMaster.RootObject obj             = JsonConvert.DeserializeObject <TktMaster.clstMaster.RootObject>(responseFromServer);
                Dictionary <string, Avsdetail>  objAvsdetailnew = new Dictionary <string, Avsdetail>();
                foreach (var item in obj.response.docs)
                {
                    Avsdetail     objAvsdetail = new Avsdetail();
                    List <string> AttractionId = new List <string>();
                    AttractionId.Add(item.AttractionId[0].ToString());
                    objAvsdetail.AttractionId           = AttractionId;//.Add("sa");// .Add( .Add(AttractionId);
                    objAvsdetail.AttractionOrganization = new List <object>();
                    objAvsdetail.Country           = item.VenueCountry.ToString();
                    objAvsdetail.Host              = item.Host.ToString();
                    objAvsdetail.VenueId           = item.VenueId.ToString();
                    objAvsdetail.VenueOrganization = new List <object>();
                    objAvsdetailnew.Add(item.EventId.ToString(), objAvsdetail);
                }
                Dictionary <string, Dictionary <string, Avsdetail> > objAvsdetailnew1 = new Dictionary <string, Dictionary <string, Avsdetail> >();
                objAvsdetailnew1.Add("avs_request", objAvsdetailnew);
                string AvsstrRequest = JsonConvert.SerializeObject(objAvsdetailnew1);

                requestAVS(AvsstrRequest);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error");
            }
        }
示例#2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            try
            {
                // Create a request for the URL.
                HttpWebRequest request = (HttpWebRequest) WebRequest.Create(
                  "http://www.ticketmaster.com/json/search/event/local?aid=1577176");

                request.CookieContainer = cookieJar;
                // If required by the server, set the credentials.
                request.Credentials = CredentialCache.DefaultCredentials;
                // Get the response.
                WebResponse response = request.GetResponse();
                // Display the status.
                Console.WriteLine(((HttpWebResponse)response).StatusDescription);
                // Get the stream containing content returned by the server.
                Stream dataStream = response.GetResponseStream();
                // Open the stream using a StreamReader for easy access.
                StreamReader reader = new StreamReader(dataStream);
                // Read the content.
                string responseFromServer = reader.ReadToEnd();
                // Display the content.
                //Console.WriteLine(responseFromServer);
                //richTextBox1.Text = responseFromServer;
                // Clean up the streams and the response.
                reader.Close();
                response.Close();

                //StreamReader reader = new StreamReader( Application.StartupPath + "\\response.txt");
                //string responseFromServer = reader.ReadToEnd();

                TktMaster.clstMaster.RootObject obj = JsonConvert.DeserializeObject<TktMaster.clstMaster.RootObject>(responseFromServer);
                Dictionary<string, Avsdetail> objAvsdetailnew = new Dictionary<string, Avsdetail>();
                foreach (var item in obj.response.docs)
                {
                    Avsdetail objAvsdetail = new Avsdetail();
                    List<string> AttractionId = new List<string>();
                    AttractionId.Add(item.AttractionId[0].ToString());
                    objAvsdetail.AttractionId = AttractionId;//.Add("sa");// .Add( .Add(AttractionId);
                    objAvsdetail.AttractionOrganization = new List<object>();
                    objAvsdetail.Country = item.VenueCountry.ToString();
                    objAvsdetail.Host = item.Host.ToString();
                    objAvsdetail.VenueId = item.VenueId.ToString();
                    objAvsdetail.VenueOrganization= new List<object>();
                    objAvsdetailnew.Add(item.EventId.ToString(), objAvsdetail);
                 }
                Dictionary<string, Dictionary<string, Avsdetail>> objAvsdetailnew1 = new Dictionary<string, Dictionary<string, Avsdetail>>();
                objAvsdetailnew1.Add("avs_request", objAvsdetailnew);
                string AvsstrRequest = JsonConvert.SerializeObject(objAvsdetailnew1);

                requestAVS(AvsstrRequest);

            }
            catch (Exception ex)
            {
                MessageBox.Show("Error");
            }
        }