コード例 #1
0
ファイル: WebServiceData.cs プロジェクト: rvelhote/university
        public bool loadTour(ref Tour tour)
        {
            bool loaded = false;
            WebService.Tour wsTour = this.Ws.TourForTourist(AppState.Instance.Username, AppState.Instance.Password, AppState.Instance.TourID);

            if (wsTour.authenticated)
            {
                loaded = true;

                tour.cityID = wsTour.cityID;
                tour.begin = wsTour.begin;

                foreach (WebService.ToVisit t in wsTour.toVisit)
                {
                    tour.toVisit.Add(new ToVisit(t.id, t.visited, t.ordering, t.beginVisit, t.endVisit));
                }
            }
            else
            {
                throw new Exception(AppState.Instance.ResourceManager.GetString("AuthenticationFailedException"));
            }

            return loaded;
        }
コード例 #2
0
ファイル: WebServiceData.cs プロジェクト: rvelhote/university
        /// <summary>
        /// 
        /// </summary>
        /// <param name="tour"></param>
        /// <param name="cartography"></param>
        public void save(ref Tour tour, ref Cartography cartography)
        {
            if (tour.toVisit.Count > 0)
            {
                bool saved = false;

                PointOfInterest poi;
                EasyTourismServices webService = new EasyTourismServices();

                List<WebService.ToVisit> tv = new List<WebService.ToVisit>();
                WebService.ToVisit[] tvArray;

                WebService.ToVisit t;
                
                /// TODO: Chuta logo para o Array[]!
                foreach (ToVisit toVisit in tour.toVisit)
                {
                    poi = cartography.getPointOfInterestWithID(toVisit.attractionID);
                    
                    if (poi.ToVisit && poi.Visited)
                    {
                        t = new WebService.ToVisit();

                        t.id = poi.ID;
                        t.visited = poi.Visited;

                        tv.Add(t);
                    }
                }

                tvArray = new WebService.ToVisit[tv.Count];
                tv.CopyTo(tvArray);

                saved = webService.SaveTour(AppState.Instance.Username, AppState.Instance.Password, AppState.Instance.TourID, tvArray);

                if (!saved)
                {
                    throw new Exception(AppState.Instance.ResourceManager.GetString("TourNotSavedException"));
                }
            }
        }