コード例 #1
0
ファイル: XmlOperation.cs プロジェクト: IlanchezhianJ/Parker
        private int UpdateXml(string vehicleType, string floorName, int value)
        {
            string parkingNo  = string.Empty;
            bool   validFloor = false;

            string floorsPath = string.Format("/{0}/{1}/{2}/{3}"
                                              , Constants.XMLElements.FLOORS
                                              , Constants.XMLElements.FLOOR
                                              , Constants.XMLElements.VEHICLE_COUNT
                                              , vehicleType);

            var floors = StorageXmlDocument.SelectNodes(floorsPath);

            foreach (XmlNode vehicle in floors)
            {
                if (GetFloorNumber(vehicle.ParentNode.ParentNode) == floorName)
                {
                    parkingNo  = vehicle.InnerText = (Convert.ToInt32(vehicle.InnerText) + value).ToString(); //Increase the parking
                    validFloor = true;
                    break;
                }
            }

            // save the XmlDocument back to disk
            if (validFloor)
            {
                StorageXmlDocument.Save(XmlPath);
            }
            else
            {
                throw new InvalidFloorException(floorName);
            }

            return(Convert.ToInt32(parkingNo));
        }
コード例 #2
0
ファイル: XmlOperation.cs プロジェクト: IlanchezhianJ/Parker
        private XmlNodeList GetFloors()
        {
            string floorPath = string.Format("/{0}/{1}"
                                             , Constants.XMLElements.FLOORS
                                             , Constants.XMLElements.FLOOR);

            return(StorageXmlDocument.SelectNodes(floorPath));
        }
コード例 #3
0
ファイル: XmlOperation.cs プロジェクト: IlanchezhianJ/Parker
        /// <summary>
        /// Get the supported vehicles
        /// </summary>
        /// <returns></returns>
        public List <string> GetSupportedVehicles()
        {
            string vehicleMaxLimitPath = string.Format("/{0}/{1}/{2}"
                                                       , Constants.XMLElements.FLOORS
                                                       , Constants.XMLElements.FLOOR
                                                       , Constants.XMLElements.VEHICLE_MAX_LIMIT);

            var vehicleMaxLimits  = StorageXmlDocument.SelectNodes(vehicleMaxLimitPath);
            var supportedVehicles = new List <string>();

            foreach (XmlNode vehicleMaxLimit in vehicleMaxLimits)
            {
                foreach (XmlNode vehicle in vehicleMaxLimit.ChildNodes)
                {
                    supportedVehicles.Add(vehicle.Name.ToLower());
                }
            }

            return(supportedVehicles.Distinct().ToList());
        }
コード例 #4
0
ファイル: XmlOperation.cs プロジェクト: IlanchezhianJ/Parker
        public List <ParkingLevel> GetCurrentParkingLevels()
        {
            var currentParkingLevels = new List <ParkingLevel>();

            string floorPath = string.Format("/{0}/{1}"
                                             , Constants.XMLElements.FLOORS
                                             , Constants.XMLElements.FLOOR);

            var floors = StorageXmlDocument.SelectNodes(floorPath);

            foreach (XmlNode floor in floors)
            {
                currentParkingLevels.Add(new ParkingLevel()
                {
                    FloorNumber     = GetFloorNumber(floor),
                    VehicleCount    = GetVehicleCount(floor),
                    VehicleMaxLimit = GetVehicleMaxLimit(floor)
                });
            }

            return(currentParkingLevels);
        }
コード例 #5
0
ファイル: XmlOperation.cs プロジェクト: IlanchezhianJ/Parker
 private void LoadData()
 {
     StorageXmlDocument.Load(XmlPath);
 }