Exemplo n.º 1
0
        /// <summary>
        /// 转换为mode
        /// </summary>
        /// <param name="xml"></param>
        /// <returns></returns>
        public MoveWebAppSetting ToModel(string xml)
        {
            if (string.IsNullOrEmpty(xml))
            {
                return(null);
            }
            XmlDocument xmlDoc = new XmlDocument();

            try
            {
                xmlDoc.LoadXml(xml);
                //查找根节点
                XmlNode node = xmlDoc.SelectSingleNode("//Root");
                this.IsCanDcodeCheckTime    = ConfigConvert.ConvertToBool(node.Attributes["IsCanDcodeCheckTime"].Value);
                this.IsCanDcodeComeBack     = ConfigConvert.ConvertToBool(node.Attributes["IsCanDcodeComeBack"].Value);
                this.IsCanDcodeContinueTime = ConfigConvert.ConvertToBool(node.Attributes["IsCanDcodeContinueTime"].Value);
                this.IsCanDcodeLeave        = ConfigConvert.ConvertToBool(node.Attributes["IsCanDcodeLeave"].Value);
                this.IsCanDcodeReselectSeat = ConfigConvert.ConvertToBool(node.Attributes["IsCanDcodeReselectSeat"].Value);
                this.IsCanDcodeSelectSeat   = ConfigConvert.ConvertToBool(node.Attributes["IsCanDcodeSelectSeat"].Value);
                this.IsCanDcodeShortLeave   = ConfigConvert.ConvertToBool(node.Attributes["IsCanDcodeShortLeave"].Value);
                this.IsCanDcodeWaitSeat     = ConfigConvert.ConvertToBool(node.Attributes["IsCanDcodeWaitSeat"].Value);
                this.IsCanLeave             = ConfigConvert.ConvertToBool(node.Attributes["IsCanLeave"].Value);
                this.IsCanShortLeave        = ConfigConvert.ConvertToBool(node.Attributes["IsCanShortLeave"].Value);
                this.IsUseBespeak           = ConfigConvert.ConvertToBool(node.Attributes["IsUseBespeak"].Value);
                this.IsUseNextDayBespeak    = ConfigConvert.ConvertToBool(node.Attributes["IsUseNextDayBespeak"].Value);
                this.IsUseNowDayBespeak     = ConfigConvert.ConvertToBool(node.Attributes["IsUseNowDayBespeak"].Value);
                this.IsUseDcode             = ConfigConvert.ConvertToBool(node.Attributes["IsUseDcode"].Value);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(this);
        }
Exemplo n.º 2
0
        public static OftenSeat ToObject(XmlNode node)
        {
            OftenSeat oftenSeat = new OftenSeat();

            if (node != null)
            {
                oftenSeat.Used       = ConfigConvert.ConvertToBool(node.InnerText);
                oftenSeat.LengthDays = int.Parse(node.Attributes["LengthTime"].Value);
                oftenSeat.SeatCount  = int.Parse(node.Attributes["SeatCount"].Value);
            }
            return(oftenSeat);
        }
Exemplo n.º 3
0
        public static POSRestrict ToObject(XmlNode node)
        {
            POSRestrict set = new POSRestrict();

            if (node != null)
            {
                set.Minutes = int.Parse(node.Attributes["Minutes"].Value);
                set.Times   = int.Parse(node.Attributes["Times"].Value);
                if (node.Attributes["IsUsed"] != null)
                {
                    set.IsUsed = ConfigConvert.ConvertToBool(node.Attributes["IsUsed"].Value);
                }
            }
            return(set);
        }
        private static BlacklistSetting ConvertBlacklistSet(XmlNode node)
        {
            //node = doc.SelectSingleNode("//blacklist");
            BlacklistSetting set = new BlacklistSetting();

            set.LeaveBlacklist  = (LeaveBlacklistMode)int.Parse(node.Attributes["leaveBlacklist"].Value);
            set.LimitDays       = int.Parse(node.Attributes["limitDays"].Value);
            set.Used            = ConfigConvert.ConvertToBool(node.Attributes["used"].Value);
            set.ViolateTimes    = int.Parse(node.Attributes["violateTimes"].Value);
            set.ViolateFailDays = int.Parse(node.Attributes["ViolateFailDays"].Value);
            XmlNodeList nodes = node.ChildNodes;// SelectNodes("//blacklist/violateType");

            foreach (XmlNode element in nodes)
            {
                set.ViolateRoule[(ViolationRecordsType)int.Parse(element.Attributes["typeValue"].Value)] = ConfigConvert.ConvertToBool(element.Attributes["used"].Value);
            }
            return(set);
        }
        /// <summary>
        /// 转换为mode
        /// </summary>
        /// <param name="xml"></param>
        /// <returns></returns>
        public PecketBookWebSetting ToModel(string xml)
        {
            if (string.IsNullOrEmpty(xml))
            {
                return(null);
            }
            XmlDocument xmlDoc = new XmlDocument();

            try
            {
                xmlDoc.LoadXml(xml);
                //查找根节点
                XmlNode node = xmlDoc.SelectSingleNode("//Root");
                this.UseBookComfirm     = ConfigConvert.ConvertToBool(node.Attributes["UseBookComfirm"].Value);
                this.UseBookNextDaySeat = ConfigConvert.ConvertToBool(node.Attributes["UseBookNextDaySeat"].Value);
                this.UseBookNowDaySeat  = ConfigConvert.ConvertToBool(node.Attributes["UseBookNowDaySeat"].Value);
                this.UseBookSeat        = ConfigConvert.ConvertToBool(node.Attributes["UseBookSeat"].Value);
                this.UseCancelBook      = ConfigConvert.ConvertToBool(node.Attributes["UseCancelBook"].Value);
                this.UseCancelWait      = ConfigConvert.ConvertToBool(node.Attributes["UseCancelWait"].Value);
                this.UseCanLeave        = ConfigConvert.ConvertToBool(node.Attributes["UseCanLeave"].Value);
                this.UseComeBack        = ConfigConvert.ConvertToBool(node.Attributes["UseComeBack"].Value);
                this.UseContinue        = ConfigConvert.ConvertToBool(node.Attributes["UseContinue"].Value);
                this.UseShortLeave      = ConfigConvert.ConvertToBool(node.Attributes["UseShortLeave"].Value);
                this.UseWaitSeat        = ConfigConvert.ConvertToBool(node.Attributes["UseWaitSeat"].Value);
                if (node.Attributes["UseSelectSeat"] != null)
                {
                    this.UseSelectSeat = ConfigConvert.ConvertToBool(node.Attributes["UseSelectSeat"].Value);
                }
                if (node.Attributes["UseChangeSeat"] != null)
                {
                    this.UseChangeSeat = ConfigConvert.ConvertToBool(node.Attributes["UseChangeSeat"].Value);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(this);
        }
Exemplo n.º 6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="xmlClientConfig"></param>
        /// <returns></returns>
        public static ClientConfig Convert(string xmlClientConfig)
        {
            XmlDocument doc = new XmlDocument();

            try
            {
                doc.LoadXml(xmlClientConfig);
                ClientConfig config = new ClientConfig();
                XmlNode      node   = doc.SelectSingleNode("//RootNote/ClientNo");
                if (node != null)
                {
                    config.ClientNo = node.InnerText;
                }
                node = doc.SelectSingleNode("//RootNote/ChooseSeatMothed");
                if (node != null)
                {
                    config.SelectMethod = (SelectSeatMode)int.Parse(node.InnerText);
                }
                node = doc.SelectSingleNode("//RootNote/Nokeyboard");
                if (node != null)
                {
                    config.UsingEnterNoForSeat = ConfigConvert.ConvertToBool(node.InnerText);
                }
                node = doc.SelectSingleNode("//RootNote/IsShowInitPOS");
                if (node != null)
                {
                    config.IsShowInitPOS = ConfigConvert.ConvertToBool(node.InnerText);
                }
                node = doc.SelectSingleNode("//RootNote/IsShowClosedRoom");
                if (node != null)
                {
                    config._IsShowClosedRoom = ConfigConvert.ConvertToBool(node.InnerText);
                }
                node = doc.SelectSingleNode("//RootNote/OftenSeat");
                if (node != null)
                {
                    config.UsingOftenUsedSeat.Used       = ConfigConvert.ConvertToBool(node.InnerText);
                    config.UsingOftenUsedSeat.LengthDays = int.Parse(node.Attributes["LengthTime"].Value);
                    config.UsingOftenUsedSeat.SeatCount  = int.Parse(node.Attributes["SeatCount"].Value);
                }
                node = doc.SelectSingleNode("//RootNote/isPrint");
                if (node != null)
                {
                    config.UsingPrintSlip = ConfigConvert.ConvertToBool(node.InnerText);
                }
                node = doc.SelectSingleNode("//RootNote/Activation");
                if (node != null)
                {
                    config.UsingActiveBespeakSeat = ConfigConvert.ConvertToBool(node.InnerText);
                }
                node = doc.SelectSingleNode("//RootNote/POSRestrict");
                if (node != null)
                {
                    config.PosTimes.Minutes = int.Parse(node.Attributes["Minutes"].Value);
                    config.PosTimes.Times   = int.Parse(node.Attributes["Times"].Value);
                    if (node.Attributes["IsUsed"] != null)
                    {
                        config.PosTimes.IsUsed = ConfigConvert.ConvertToBool(node.Attributes["IsUsed"].Value);
                    }
                }
                XmlNodeList nodes = doc.SelectNodes("//RootNote/AddReadingRoom/ReadRoomID");
                foreach (XmlNode element in nodes)
                {
                    config.Rooms.Add(element.InnerText);
                }
                nodes = doc.SelectNodes("//RootNote/img/backgroundimg");
                foreach (XmlNode element in nodes)
                {
                    config.BackImgage[element.Attributes["id"].Value] = element.InnerText;
                }
                node = doc.SelectSingleNode("//RootNote/Resolution/FormSet/size");

                config.SystemResoultion.WindowSize.Size.X = int.Parse(node.Attributes["x"].Value);
                config.SystemResoultion.WindowSize.Size.Y = int.Parse(node.Attributes["y"].Value);
                node = doc.SelectSingleNode("//RootNote/Resolution/FormSet/location");
                config.SystemResoultion.WindowSize.Location.X = int.Parse(node.Attributes["x"].Value);
                config.SystemResoultion.WindowSize.Location.Y = int.Parse(node.Attributes["y"].Value);
                node = doc.SelectSingleNode("//RootNote/Resolution/TooltipSet/size");
                config.SystemResoultion.TooltipSize.Size.X = int.Parse(node.Attributes["x"].Value);
                config.SystemResoultion.TooltipSize.Size.Y = int.Parse(node.Attributes["y"].Value);
                node = doc.SelectSingleNode("//RootNote/Resolution/TooltipSet/location");
                config.SystemResoultion.TooltipSize.Location.X = int.Parse(node.Attributes["x"].Value);
                config.SystemResoultion.TooltipSize.Location.Y = int.Parse(node.Attributes["y"].Value);
                return(config);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        /// <summary>
        /// 解析座位配置
        /// </summary>
        /// <param name="seatXml"></param>
        /// <returns></returns>
        private static SeatLayout getSeats(string seatXml)
        {
            XmlDocument doc = new XmlDocument();

            doc.LoadXml(seatXml);
            SeatLayout seats = new SeatLayout();
            //查找行数和列数
            XmlNode node = doc.SelectSingleNode("//seatroot/seatinfo/rowscount");

            seats.SeatRow = int.Parse(node.InnerText);
            node          = doc.SelectSingleNode("//seatroot/seatinfo/columscount");
            seats.SeatCol = int.Parse(node.InnerText);
            //查找方位
            node = doc.SelectSingleNode("//seatroot/seatinfo/position");
            if (node != null)
            {
                seats.Position = node.InnerText;
            }
            node = doc.SelectSingleNode("//seatroot/seatinfo/IsUpdate");
            if (node != null)
            {
                seats.IsUpdate = bool.Parse(node.InnerText);
            }
            //查找座位
            XmlNodeList nodes = doc.SelectNodes("//seatroot/seatdetail/objseat");
            Dictionary <string, Seat> seatList = new Dictionary <string, Seat>();

            foreach (XmlNode element in nodes)
            {
                try
                {
                    Seat seat = new Seat();
                    seat.ShortSeatNo  = element.Attributes["seatno"].Value.Substring(6, 3);
                    seat.SeatNo       = element.Attributes["seatno"].Value;
                    seat.PositionY    = double.Parse(element.Attributes["rownum"].Value);
                    seat.PositionX    = double.Parse(element.Attributes["colnum"].Value);
                    seat.HavePower    = ConfigConvert.ConvertToBool(element.Attributes["haspower"].Value);
                    seat.CanBeBespeak = getCanBeBook(element.Attributes["booktype"].Value);
                    if (element.Attributes["centerx"] != null)
                    {
                        seat.RotationCenterX = int.Parse(element.Attributes["centerx"].Value);
                    }
                    if (element.Attributes["centery"] != null)
                    {
                        seat.RotationCenterY = int.Parse(element.Attributes["centery"].Value);
                    }
                    if (element.Attributes["angle"] != null)
                    {
                        seat.RotationAngle = int.Parse(element.Attributes["angle"].Value);
                    }
                    if (element.Attributes["isstop"] != null)
                    {
                        seat.IsSuspended = ConfigConvert.ConvertToBool(element.Attributes["isstop"].Value);
                    }
                    seatList.Add(seat.SeatNo, seat);
                }
                catch (Exception ex)
                {
                    throw new Exception(string.Format("解析失败座位失败:{0};座位编号:{1}", ex.Message, element.Attributes["seatno"].Value));
                }
            }

            Seat temp = new Seat();//交换变量

            //排序
            seatList = (from entry in seatList
                        orderby entry.Value.SeatNo ascending
                        select entry).ToDictionary(pair => pair.Key, pair => pair.Value);

            seats.Seats = seatList;
            return(seats);
        }