public async void postXMLData1()
        {
            string uri  = "http://111.93.131.112/biws/buswebservice"; // some xml string
            Uri    _url = new Uri(uri, UriKind.RelativeOrAbsolute);
            //string stringXml = "<soapenv:Envelope xmlns:com=\"com.busindia.webservices\" xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"><soapenv:Header /><soapenv:Body><com:GetPlaceList xmls =\"\"><arg0><franchUserID>?</franchUserID><password>biteam</password><userID>474</userID><userKey>?</userKey><userName>[email protected]</userName><userRole>?</userRole><userStatus>?</userStatus><userType>101</userType></arg0></com:GetPlaceList></soapenv:Body></soapenv:Envelope>";
            string franchUserID = "?";
            string password     = "******";
            int    userID       = 474;
            string userKey      = "?";
            string username     = "******";
            string userRole     = "?";
            string userStatus   = "?";
            int    usertype     = 101;

            WebServiceClassLiberary.Class1 listings = new WebServiceClassLiberary.Class1();
            XDocument element    = listings.getList(franchUserID, password, userID, userKey, username, userRole, userStatus, usertype);
            string    file       = element.ToString();
            var       httpClient = new Windows.Web.Http.HttpClient();
            var       info       = "biwstest:biwstest";
            var       token      = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(info));

            httpClient.DefaultRequestHeaders.Authorization = new Windows.Web.Http.Headers.HttpCredentialsHeaderValue("Basic", token);
            httpClient.DefaultRequestHeaders.Add("SOAPAction", "");
            Windows.Web.Http.HttpRequestMessage httpRequestMessage = new Windows.Web.Http.HttpRequestMessage(Windows.Web.Http.HttpMethod.Post, _url);
            httpRequestMessage.Headers.UserAgent.TryParseAdd("Mozilla/4.0");
            IHttpContent content = new HttpStringContent(file, Windows.Storage.Streams.UnicodeEncoding.Utf8);

            httpRequestMessage.Content = content;
            Windows.Web.Http.HttpResponseMessage httpResponseMessage = await httpClient.SendRequestAsync(httpRequestMessage);

            string strXmlReturned = await httpResponseMessage.Content.ReadAsStringAsync();

            XmlDocument xDoc = new XmlDocument();

            xDoc.LoadXml(strXmlReturned);
            XDocument loadedData = XDocument.Parse(strXmlReturned);
            var       sdata      = loadedData.Descendants("PlaceList").
                                   Select(x => new PlaceList
            {
                PlaceID   = x.Element("placeID").Value,
                PlaceCode = x.Element("placeCode").Value,
                PlaceName = x.Element("placeName").Value
            });

            foreach (var item in sdata)
            {
                PlaceList pl = new PlaceList();
                pl.PlaceID   = item.PlaceID;
                pl.PlaceName = item.PlaceName;
                pl.PlaceCode = item.PlaceCode;
                CityList.Add(pl);
            }
            ListMenuItems.ItemsSource = sdata;
        }
        private void ListMenuItems_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (ListMenuItems.SelectedItem != null)
            {
                PlaceList myobject = ListMenuItems.SelectedItem as PlaceList;

                myobject.Label = parameter;

                Frame.Navigate(typeof(BusSearch), myobject);
            }
        }
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {

            HomeModel homeModel = new HomeModel();
            CommonModel.bgImage = homeModel.bgImage;
            imgBack.Source = homeModel.bgImage;
            PlaceList m = new PlaceList();
            if (e.Parameter != null)
            {
                parameter = e.Parameter.ToString();
                if (parameter == "fromlocation" || parameter == "fromlocationsearchreturn")
                {
                    txtBTitle.Text = "Departure City";
                }
                if (parameter == "tolocation" || parameter == "tolocationsearchreturn")
                {
                    txtBTitle.Text = "Arrival City";
                }
                switch (parameter)
                {
                    case "fromlocation":
                        parameter = "fromlocation";
                        break;
                    case "tolocation":
                        parameter = "tolocation";
                        break;
                    case "fromlocationsearchreturn":
                        parameter = "fromlocationsearchreturn";
                        break;
                    case "tolocationsearchreturn":
                        parameter = "tolocationsearchreturn";
                        break;
                }
            }
            postXMLData1();

        }
Пример #4
0
        public  void postXMLData1()
        {
            var task = Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async () =>
            {
            try
            {
            
                string uri = AppStatic.WebServiceBaseURL;  // some xml string
                Uri _url = new Uri(uri, UriKind.RelativeOrAbsolute);
                GetAvailableServicesRequest _objAGR = new GetAvailableServicesRequest();
                _objAGR.franchUserID = AppStatic.franchUserID;
                _objAGR.password = AppStatic.password;
                _objAGR.userID = AppStatic.userID;
                _objAGR.userKey = AppStatic.userKey;
                _objAGR.userName = AppStatic.userName;
                _objAGR.userRole = AppStatic.userRole;
                _objAGR.userStatus = AppStatic.userStatus;
                _objAGR.userType = AppStatic.userType;
                _objAGR.placeNameFrom = txtBFromLocationT.Text;
                _objAGR.placeNameTo = txtBToLocationT.Text;
                _objAGR.placeIDFrom = txtBFromID.Text;
                _objAGR.placeIDto = txtBToID.Text;
                _objAGR.placeCodeFrom = txtBFromCode.Text;
                _objAGR.placeCodeTo = txtBToCode.Text;
                string d = txtBDateTab.Text;
                System.DateTime dt = System.DateTime.ParseExact(d, "dd MMM yyyy", CultureInfo.InvariantCulture);
                string Date = dt.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture);
                _objAGR.journeyDate = Date;

                xmlUtility listings = new xmlUtility();
                XDocument element = listings.getservice(_objAGR);
                string stringXml = element.ToString();
                var httpClient = new Windows.Web.Http.HttpClient();
                var info = AppStatic.WebServiceAuthentication;
                var token = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(info));
                httpClient.DefaultRequestHeaders.Authorization = new Windows.Web.Http.Headers.HttpCredentialsHeaderValue("Basic", token);
                httpClient.DefaultRequestHeaders.Add("SOAPAction", "");
                Windows.Web.Http.HttpRequestMessage httpRequestMessage = new Windows.Web.Http.HttpRequestMessage(Windows.Web.Http.HttpMethod.Post, _url);
                httpRequestMessage.Headers.UserAgent.TryParseAdd("Mozilla/4.0");
                IHttpContent content = new HttpStringContent(stringXml, Windows.Storage.Streams.UnicodeEncoding.Utf8);
                httpRequestMessage.Content = content;
                Windows.Web.Http.HttpResponseMessage httpResponseMessage = await httpClient.SendRequestAsync(httpRequestMessage);
                string strXmlReturned = await httpResponseMessage.Content.ReadAsStringAsync();
                XmlDocument xDoc = new XmlDocument();
                XDocument loadedData = XDocument.Parse(strXmlReturned);
                XDocument element1 = listings.getAvailableServicelayout(_objAGR);
                string stringXml1 = element1.ToString();

                byte[] fileBytes = System.Text.Encoding.UTF8.GetBytes(stringXml1.ToString());
                StorageFile file = await Windows.Storage.ApplicationData.Current.LocalFolder.CreateFileAsync("HistoryTest1.xml", CreationCollisionOption.OpenIfExists);
                String historyTestContent = await FileIO.ReadTextAsync(file);
                using (var stream = await file.OpenStreamForWriteAsync())
                {
                    stream.Seek(0, SeekOrigin.End);
                    stream.Write(fileBytes, 0, fileBytes.Length);
                }

                List<XElement> _list = (from t1 in loadedData.Descendants("wsResponse") select t1).ToList();
                List<PlaceList> seatsList = new List<PlaceList>();
                string _msg = "";
                if (_list != null)
                {
                    foreach (XElement _elemet in _list)
                    {
                        PlaceList _obj = new PlaceList();
                        _obj.message = _elemet.Element("message").Value.ToString();
                        seatsList.Add(_obj);
                    }
                    _msg = seatsList.FirstOrDefault().message.ToString();
                }                
                if (_msg != "FAILURE")
                {
                    var sdata = loadedData.Descendants("service").
                    Select(x => new GetAvailableService
                    {
                        arrivalDate = x.Element("arrivalDate").Value,
                        arrivalTime = x.Element("arrivalTime").Value,
                        classID = x.Element("classID").Value,
                        classLayoutID = x.Element("classLayoutID").Value,
                        className = x.Element("className").Value,
                        corpCode = x.Element("corpCode").Value,
                        departureTime = x.Element("departureTime").Value,
                        destination = x.Element("destination").Value,
                        fare = x.Element("fare").Value,
                        journeyDate = x.Element("journeyDate").Value,
                        journeyHours = x.Element("journeyHours").Value,
                        maxSeatsAllowed = x.Element("maxSeatsAllowed").Value,
                        origin = x.Element("origin").Value,
                        placeIDFrom = x.Element("biFromPlace").Element("placeID").Value,
                        placeIDto = x.Element("biToPlace").Element("placeID").Value,
                        refundStatus = x.Element("refundStatus").Value,
                        routeNo = x.Element("routeNo").Value,
                        seatsAvailable = x.Element("seatsAvailable").Value,
                        seatStatus = x.Element("seatStatus").Value,
                        serviceID = x.Element("serviceID").Value,
                        startPoint = x.Element("startPoint").Value,
                        studID = x.Element("stuID").Value,
                        tripCode = x.Element("tripCode").Value,
                        viaPlaces = x.Element("viaPlaces").Value
                    });
                    foreach (var item in sdata)
                    {
                        GetAvailableService gas = new GetAvailableService();
                        gas.arrivalDate = item.arrivalDate;
                        gas.arrivalTime = item.arrivalTime;
                        gas.classID = item.classID;
                        gas.classLayoutID = item.classLayoutID;
                        gas.className = item.className;
                        gas.corpCode = item.corpCode;
                        gas.departureTime = item.departureTime;
                        gas.destination = item.destination;
                        gas.fare = item.fare;
                        gas.journeyDate = item.journeyDate;
                        gas.journeyHours = item.journeyHours;
                        gas.maxSeatsAllowed = item.maxSeatsAllowed;
                        gas.origin = item.origin;
                        gas.placeIDFrom = item.placeIDFrom;
                        gas.placeIDto = item.placeIDto;
                        gas.refundStatus = item.refundStatus;
                        gas.routeNo = item.routeNo;
                        gas.seatsAvailable = item.seatsAvailable;
                        gas.seatStatus = item.seatStatus;
                        gas.serviceID = item.serviceID;
                        gas.startPoint = item.startPoint;
                        gas.studID = item.studID;
                        gas.tripCode = item.tripCode;
                        gas.viaPlaces = item.viaPlaces;
                        availableservice.Add(gas);
                    }
                    ListMenuItems.ItemsSource = sdata;

                    string MaxPriceresult = sdata.OrderByDescending(x => x.fare).Select(x => x.fare).FirstOrDefault().ToString();
                    if (MaxPriceresult != null)
                    {
                        txtBMaxPriceCurrent.Text = MaxPriceresult;
                        txtBMaxPrice.Text = MaxPriceresult;
                        maxPrice = Convert.ToInt32(MaxPriceresult);
                        MaxPrice = Convert.ToInt32(MaxPriceresult);
                        Thumb2PositionPrice = Convert.ToInt32(MaxPriceresult);
                    }

                    string MinPriceresult = sdata.OrderBy(x => x.fare).Select(x => x.fare).FirstOrDefault().ToString();
                    if (MinPriceresult != null)
                    {
                        txtBMinPrice.Text = MinPriceresult;
                        txtBMinPriceCurrent.Text = MinPriceresult;
                        minPrice = Convert.ToInt32(MinPriceresult);
                        MinPrice = Convert.ToInt32(MinPriceresult);
                        Thumb1PositionPrice = Convert.ToInt32(MinPriceresult);
                    }
                    ListMenuItemsFilterCorp.ItemsSource = sdata.Select(x => x.corpCode).Distinct().ToList();
                    ListMenuItemsFilterBusType.ItemsSource = sdata.Select(x => x.className).Distinct().ToList();

                    FilterFunVisible();
                }
                else
                {
                    FilterFunCollapsed();

                }
             
            }
            catch (Exception ex)
            {
                LoaderPop.Visibility = Visibility.Collapsed;
                ErrorpopUp.Visibility = Visibility.Visible;               
                ExceptionLog obj = new ExceptionLog();
                Error objError = new Error();
                objError.ErrorEx = ex.Message;
                obj.CreateLogFile(objError);
            }
            }).AsTask();
        }
        public async void postXMLData1()
        {
            try
            {               
                StorageFile sampleFile = await Windows.Storage.ApplicationData.Current.LocalFolder.GetFileAsync("PlaceNames.xml");
                String timestamp = await FileIO.ReadTextAsync(sampleFile);
                XDocument loadedData = XDocument.Parse(timestamp);              
                var PlaceList = loadedData.Descendants("PlaceList").
                Select(x => new PlaceList
                {
                    PlaceID = x.Element("placeID").Value,
                    PlaceCode = x.Element("placeCode").Value,
                    PlaceName = x.Element("placeName").Value
                });
                foreach (var item in PlaceList)
                {
                    PlaceList pl = new PlaceList();
                    pl.PlaceID = item.PlaceID;
                    pl.PlaceName = item.PlaceName;
                    pl.PlaceCode = item.PlaceCode;
                    CityList.Add(pl);
                }
                ListMenuItems.ItemsSource = PlaceList;
                LoderPopup.Visibility = Visibility.Collapsed;
            }
            catch (Exception ex)
            {

                PopupError.Visibility = Visibility.Visible;
                LoderPopup.Visibility = Visibility.Collapsed;
                ExceptionLog obj = new ExceptionLog();
                Error objError = new Error();
                objError.ErrorEx = ex.Message;
                obj.CreateLogFile(objError);
            }
        }
        public void postXMLData1()
        {
             var task = Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() =>
             {
            try
            {
                string uri = AppStatic.WebServiceBaseURL;  // some xml string
                Uri _url = new Uri(uri, UriKind.RelativeOrAbsolute);
                xmlUtility listings = new xmlUtility();
                getPlaceListRequest _objgetPlaceListRequest = listings.GetUserRequestParameters();
                XDocument element = listings.getList(_objgetPlaceListRequest);
                string file = element.ToString();
                var httpClient = new Windows.Web.Http.HttpClient();
                var info = AppStatic.WebServiceAuthentication;
                var token = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(info));
                httpClient.DefaultRequestHeaders.Authorization = new Windows.Web.Http.Headers.HttpCredentialsHeaderValue("Basic", token);
                httpClient.DefaultRequestHeaders.Add("SOAPAction", "");
                Windows.Web.Http.HttpRequestMessage httpRequestMessage = new Windows.Web.Http.HttpRequestMessage(Windows.Web.Http.HttpMethod.Post, _url);
                httpRequestMessage.Headers.UserAgent.TryParseAdd("Mozilla/4.0");
                IHttpContent content = new HttpStringContent(file, Windows.Storage.Streams.UnicodeEncoding.Utf8);
                httpRequestMessage.Content = content;
                Windows.Web.Http.HttpResponseMessage httpResponseMessage = await httpClient.SendRequestAsync(httpRequestMessage);
                string strXmlReturned = await httpResponseMessage.Content.ReadAsStringAsync();

                //StorageFile sampleFile = await Windows.Storage.ApplicationData.Current.LocalFolder.GetFileAsync("PlaceNames.xml");
                //String timestamp = await FileIO.ReadTextAsync(sampleFile);
                //XDocument loadedData = XDocument.Parse(timestamp);                 
                XDocument loadedData = XDocument.Parse(strXmlReturned);  
            
                var PlaceList = loadedData.Descendants("PlaceList").
                Select(x => new PlaceList
                {
                    PlaceID = x.Element("placeID").Value,
                    PlaceCode = x.Element("placeCode").Value,
                    PlaceName = x.Element("placeName").Value
                });
                foreach (var item in PlaceList)
                {
                    PlaceList pl = new PlaceList();
                    pl.PlaceID = item.PlaceID;
                    pl.PlaceName = item.PlaceName;
                    pl.PlaceCode = item.PlaceCode;
                    CityList.Add(pl);
                }
                ListMenuItems.ItemsSource = PlaceList;
                LoderPopup.Visibility = Visibility.Collapsed;
            }
            catch (Exception ex)
            {

                PopupError.Visibility = Visibility.Visible;
                LoderPopup.Visibility = Visibility.Collapsed;
                ExceptionLog obj = new ExceptionLog();
                Error objError = new Error();
                objError.ErrorEx = ex.Message;
                obj.CreateLogFile(objError);
            }
             }).AsTask();
        }