コード例 #1
0
        public List <SchoolInfo> GetSchoolsList(string city, string school)
        {
            List <SchoolInfo>    _schoolslist     = new List <SchoolInfo>();
            SchoolTB             _schoolTb        = new SchoolTB();
            CitySchoolsInfo_list _cityschoolsinfo = _schoolTb.GetCitySchoolsInfo(city, school);


            StringBuilder sb     = new StringBuilder();
            StringWriter  stream = new StringWriter(sb);
            XmlSerializer x      = new System.Xml.Serialization.XmlSerializer(_cityschoolsinfo.GetType());

            x.Serialize(stream, _cityschoolsinfo);


            foreach (School_Info _temp in _cityschoolsinfo.School_info)
            {
                SchoolInfo _schoolinfo = new SchoolInfo();

                _schoolinfo.ID   = _temp.School_id;
                _schoolinfo.Name = _temp.School_name;
                _schoolslist.Add(_schoolinfo);
            }

            return(_schoolslist);
        }
コード例 #2
0
        private static void SendSchoolList(Socket handler, String data)
        {
            string _value = "";

            using (XmlReader reader = XmlReader.Create(new StringReader(data)))
            {
                while (reader.Read())
                {
                    switch (reader.NodeType)
                    {
                    case XmlNodeType.Element:
                        Console.WriteLine(reader.Name);
                        break;

                    case XmlNodeType.Text:
                        Console.WriteLine(reader.Value);
                        _value = reader.Value;
                        break;

                    case XmlNodeType.XmlDeclaration:
                    case XmlNodeType.ProcessingInstruction:
                        Console.WriteLine(reader.Name + reader.Value);
                        break;

                    case XmlNodeType.Comment:
                        Console.WriteLine(reader.Value);
                        break;

                    case XmlNodeType.EndElement:
                        Console.WriteLine(reader.Name);
                        break;
                    }
                }
            }


            SchoolTB         _schoolTb = new SchoolTB();
            CitySchools_list _schools  = _schoolTb.GetSchoolsInCity(_value);


            StringBuilder sb     = new StringBuilder();
            StringWriter  stream = new StringWriter(sb);
            XmlSerializer x      = new System.Xml.Serialization.XmlSerializer(_schools.GetType());

            x.Serialize(stream, _schools);



            byte[] byteData = Encoding.ASCII.GetBytes(stream.ToString());


            // Begin sending the data to the remote device.
            handler.BeginSend(byteData, 0, byteData.Length, 0,
                              new AsyncCallback(SendCallback), handler);
        }
コード例 #3
0
ファイル: UnitTest1.cs プロジェクト: SayeedAlquiaty/DiaryApp
        public static void GetSchoolIdTest()
        {
            List <School_row> Schools;
            SchoolTB          schooltable = new SchoolTB();
            string            _schoolName = "MSCreative";
            string            _cityName   = "HYD";

            Schools = schooltable.GetSchools(_schoolName, _cityName);
            foreach (School_row sc in Schools)
            {
                System.Console.WriteLine(sc.School_name + sc.School_cityname);
            }
        }
コード例 #4
0
        //public string GetData(string value)
        //{
        //  return string.Format("You entered: {0}", value);
        //}

        public List <string> GetSchools(string city)
        {
            SchoolTB         _schoolTb = new SchoolTB();
            CitySchools_list _schools  = _schoolTb.GetSchoolsInCity(city);


            StringBuilder sb     = new StringBuilder();
            StringWriter  stream = new StringWriter(sb);
            XmlSerializer x      = new System.Xml.Serialization.XmlSerializer(_schools.GetType());

            x.Serialize(stream, _schools);
            return(_schools.School_name);
            //return stream.ToString();
        }
コード例 #5
0
        public List <School_row> GetSchools(string _schoolname, string _cityname)
        {
            SchoolTB _schoolTb = new SchoolTB();

            return(_schoolTb.GetSchools(_schoolname, _cityname));;
        }
コード例 #6
0
        private static void Send(Socket handler, String data)
        {
            List <string> _values = new List <string>();

            using (XmlReader reader = XmlReader.Create(new StringReader(data)))
            {
                while (reader.Read())
                {
                    switch (reader.NodeType)
                    {
                    case XmlNodeType.Element:
                        Console.WriteLine(reader.Name);
                        break;

                    case XmlNodeType.Text:
                        Console.WriteLine(reader.Value);
                        _values.Add(reader.Value);
                        break;

                    case XmlNodeType.XmlDeclaration:
                    case XmlNodeType.ProcessingInstruction:
                        Console.WriteLine(reader.Name + reader.Value);
                        break;

                    case XmlNodeType.Comment:
                        Console.WriteLine(reader.Value);
                        break;

                    case XmlNodeType.EndElement:
                        Console.WriteLine(reader.Name);
                        break;
                    }
                }
            }


            SchoolTB          _schoolTb = new SchoolTB();
            List <School_row> _schools  = _schoolTb.GetSchools(_values[0], _values[1]);


            StringBuilder sb     = new StringBuilder();
            StringWriter  stream = new StringWriter(sb);

            foreach (School_row sr in _schools)
            {
                XmlSerializer x = new System.Xml.Serialization.XmlSerializer(sr.GetType());
                x.Serialize(stream, sr);

                StringReader streamreader = new StringReader(sb.ToString());
                object       deserialized = x.Deserialize(streamreader);
                School_row   sr1          = (School_row)deserialized;
                //Console.WriteLine();
            }

            //try
            //{
            //    using (StringWriter stream = new StringWriter(sb))
            //    {
            //        BinaryFormatter bin = new BinaryFormatter();
            //        bin.Serialize(stream, _schools);
            //    }

            //}
            //catch (IOException)
            //{
            //}


            data = String.Format("<Classroom Id=1  Grade=10  Section=A  >" +
                                 "<Student Id=1  Firstname=Ali  Surname=AlQuiaty  />" +
                                 "<Student Id=2  Firstname=Sayeed  Surname=AlQuiaty  />" +
                                 "<Student Id=3  Firstname=Salam  Surname=AlQuiaty  />" +
                                 "<Student Id=4  Firstname=Minhaj  Surname=Ahmed  />" +
                                 "<Student Id=5  Firstname=Parvez  Surname=Shaik  />" +
                                 "</Classroom >");
            // Convert the string data to byte data using ASCII encoding.
            byte[] byteData = Encoding.ASCII.GetBytes(stream.ToString());


            // Begin sending the data to the remote device.
            handler.BeginSend(byteData, 0, byteData.Length, 0,
                              new AsyncCallback(SendCallback), handler);
        }