Esempio n. 1
0
        //public static void UpdateCities(int iIndex)
        //{
        //    DAOCity.GetCities();
        //}

        public static DTOCity ChangeCityTo(int iIndex,
                                           bool bForceUpdateSite)
        {
            if (Gloval.Database.Account.Cities == null)
            {
                DAOCity.GetCities();
            }

            if (0 <= iIndex && iIndex < Gloval.Database.Account.Cities.Count())
            {
                if (Gloval.Database.CurrentCity == iIndex)
                {
                    if (bForceUpdateSite)
                    {
                        DAOCity.ChangeCity(iIndex);
                    }
                }
                else
                {
                    DAOCity.ChangeCity(iIndex);
                }

                return(Gloval.Database.Account.Cities[Gloval.Database.CurrentCity]);
            }

            //thong bao loi~
            return(null);
        }
Esempio n. 2
0
        public static int GetCurrentCity()
        {
            if (Gloval.Database.Account.Cities == null)
            {
                DAOCity.GetCities();
            }

            return(Gloval.Database.CurrentCity);
        }
Esempio n. 3
0
        public static int Count()
        {
            if (Gloval.Database.Account.Cities == null)
            {
                return(DAOCity.GetCities().Count());
            }

            return(Gloval.Database.Account.Cities.Count());
        }
Esempio n. 4
0
        public static DTOCity GetCity(int iIndex)
        {
            //tu dong cap nhat danh sach neu chua co
            if (Gloval.Database.Account.Cities == null)
            {
                DAOCity.GetCities();
            }

            if (0 <= iIndex && iIndex < Gloval.Database.Account.Cities.Count())
            {
                return(Gloval.Database.Account.Cities[iIndex]);
            }

            //thong bao loi~
            return(null);
        }
        public static void ForceUpdate(int iIndexCity)
        {
            if (Gloval.Database.Account.Cities == null)
            {
                DAOCity.GetCities();
            }

            if (0 <= iIndexCity && iIndexCity < Gloval.Database.Account.Cities.Count())
            {
                BUSCity.ChangeCityTo(iIndexCity);
                if (Gloval.Database.CurrentView != Data.SITE_VIEW.CITY)
                {
                    DAOCity.GoToCity();
                }
                //cap nhat thoi gian update tu ika server
                Gloval.Database.Account.Cities[iIndexCity].DTBuilding = DateTime.Now;
                DAOBuilding.GetBuildingCity(iIndexCity);
            }
        }
Esempio n. 6
0
        //--------------------------------------------------------
        //ships
        public static int CountShips(int iIndexCity)
        {
            if (Gloval.Database.Account.Cities == null)
            {
                DAOCity.GetCities();
            }

            if (0 <= iIndexCity && iIndexCity < Gloval.Database.Account.Cities.Count())
            {
                if (Gloval.Database.Account.Cities[iIndexCity].ListTroopsShips == null)
                {
                    ForceUpdateShips(iIndexCity);
                }

                return(Gloval.Database.Account.Cities[iIndexCity].ListTroopsShips.Count());
            }

            return(-1);
        }
Esempio n. 7
0
        public static DTOCity GetTownHallInfomationInCity(int iIndexCity,
                                                          bool bForceUpdate)
        {
            if (Gloval.Database.Account.Cities == null)
            {
                DAOCity.GetCities();
                bForceUpdate = true;
            }

            if (0 <= iIndexCity && iIndexCity < Gloval.Database.Account.Cities.Count())
            {
                if (bForceUpdate)
                {
                    ForceUpdateTownHall(iIndexCity);
                }
                return(Gloval.Database.Account.Cities[iIndexCity]);
            }

            //thong bao loi~
            return(null);
        }
Esempio n. 8
0
        //nếu = true thì cập nhật lại site rùi mới lấy thông tin
        public static DTOCity GetResourceCity(int iIndex, bool bForceUpdateSite)
        {
            if (Gloval.Database.Account.Cities == null)
            {
                DAOCity.GetCities();
            }

            if (0 <= iIndex && iIndex < Gloval.Database.Account.Cities.Count())
            {
                //dung them 1 bien bool dat trogn lop de kiem tra,
                //neu da update roi thi ko update nua
                //tru khi dung bien forceupdate
                if (!Gloval.Database.Account.Cities[iIndex].IsUpdatedResource)
                {
                    if (Gloval.Database.CurrentCity == iIndex)
                    {//chưa update, nhưng đang ở viewhiện tại nên lấy res ko request
                        DAOCity.UpdateResourceCity(iIndex);
                        Gloval.Database.Account.Cities[iIndex].DTResourceCity = DateTime.Now;
                        return(Gloval.Database.Account.Cities[iIndex]);
                    }
                    //chưa update --> buôc request
                    Gloval.Database.Account.Cities[iIndex].IsUpdatedResource = true;
                    bForceUpdateSite = true;
                }

                if (bForceUpdateSite)
                {//buộc request
                    ChangeCityTo(iIndex, bForceUpdateSite);
                    Gloval.Database.Account.Cities[iIndex].DTResourceCity = DateTime.Now;
                    DAOCity.UpdateResourceCity(iIndex);
                }

                return(Gloval.Database.Account.Cities[iIndex]);
            }

            //thong bao loi~
            return(null);
        }
        public static int Count(int iIndexCity)
        {
            if (Gloval.Database.Account.Cities == null)
            {
                DAOCity.GetCities();
            }

            if (0 <= iIndexCity && iIndexCity < Gloval.Database.Account.Cities.Count())
            {
                if (Gloval.Database.Account.Cities[iIndexCity].ListBuilding == null)
                {
                    BUSCity.ChangeCityTo(iIndexCity);
                    if (Gloval.Database.CurrentView != Data.SITE_VIEW.CITY)
                    {
                        DAOCity.GoToCity();
                    }
                    DAOBuilding.GetBuildingCity(iIndexCity);
                }

                return(Gloval.Database.Account.Cities[iIndexCity].ListBuilding.Count());
            }

            return(-1);
        }
Esempio n. 10
0
        public static DTOTroops GetUnitsInCity(int iIndexCity,
                                               int iIndexTroops)
        {
            if (Gloval.Database.Account.Cities == null)
            {
                DAOCity.GetCities();
            }

            if (0 <= iIndexCity && iIndexCity < Gloval.Database.Account.Cities.Count())
            {
                if (Gloval.Database.Account.Cities[iIndexCity].ListTroopsUnits == null)
                {
                    ForceUpdateUnits(iIndexCity);
                }

                if (0 <= iIndexTroops && iIndexTroops < Gloval.Database.Account.Cities[iIndexCity].ListTroopsUnits.Count())
                {
                    return(Gloval.Database.Account.Cities[iIndexCity].ListTroopsUnits[iIndexTroops]);
                }
            }

            //thong bao loi~
            return(null);
        }