コード例 #1
0
        /// <summary>
        /// 输出xml
        /// </summary>
        /// <param name="stting"></param>
        /// <returns></returns>
        private string ConvertToXml(MoveWebAppSetting model)
        {
            //TODO:转换成xml结构的算法
            //创建一个xml对象
            XmlDocument xmlDoc = new XmlDocument();
            //创建开头
            XmlDeclaration dec = xmlDoc.CreateXmlDeclaration("1.0", "utf-8", null);

            xmlDoc.AppendChild(dec);
            //创建根节点
            XmlElement root = xmlDoc.CreateElement("Root");

            root.SetAttribute("IsCanDcodeCheckTime", ConfigConvert.ConvertToString(model.IsCanDcodeCheckTime));
            root.SetAttribute("IsCanDcodeComeBack", ConfigConvert.ConvertToString(model.IsCanDcodeComeBack));
            root.SetAttribute("IsCanDcodeContinueTime", ConfigConvert.ConvertToString(model.IsCanDcodeContinueTime));
            root.SetAttribute("IsCanDcodeLeave", ConfigConvert.ConvertToString(model.IsCanDcodeLeave));
            root.SetAttribute("IsCanDcodeReselectSeat", ConfigConvert.ConvertToString(model.IsCanDcodeReselectSeat));
            root.SetAttribute("IsCanDcodeSelectSeat", ConfigConvert.ConvertToString(model.IsCanDcodeSelectSeat));
            root.SetAttribute("IsCanDcodeShortLeave", ConfigConvert.ConvertToString(model.IsCanDcodeShortLeave));
            root.SetAttribute("IsCanDcodeWaitSeat", ConfigConvert.ConvertToString(model.IsCanDcodeWaitSeat));
            root.SetAttribute("IsCanLeave", ConfigConvert.ConvertToString(model.IsCanLeave));
            root.SetAttribute("IsCanShortLeave", ConfigConvert.ConvertToString(model.IsCanShortLeave));
            root.SetAttribute("IsUseBespeak", ConfigConvert.ConvertToString(model.IsUseBespeak));
            root.SetAttribute("IsUseNextDayBespeak", ConfigConvert.ConvertToString(model.IsUseNextDayBespeak));
            root.SetAttribute("IsUseNowDayBespeak", ConfigConvert.ConvertToString(model.IsUseNowDayBespeak));
            root.SetAttribute("IsUseDcode", ConfigConvert.ConvertToString(model.IsUseDcode));
            //添加根节点
            xmlDoc.AppendChild(root);
            return(xmlDoc.OuterXml);
        }
コード例 #2
0
        /// <summary>
        /// 输出xml
        /// </summary>
        /// <param name="stting"></param>
        /// <returns></returns>
        private string ConvertToXml(PecketBookWebSetting model)
        {
            //TODO:转换成xml结构的算法
            //创建一个xml对象
            XmlDocument xmlDoc = new XmlDocument();
            //创建开头
            XmlDeclaration dec = xmlDoc.CreateXmlDeclaration("1.0", "utf-8", null);

            xmlDoc.AppendChild(dec);
            //创建根节点
            XmlElement root = xmlDoc.CreateElement("Root");

            root.SetAttribute("UseBookComfirm", ConfigConvert.ConvertToString(model.UseBookComfirm));
            root.SetAttribute("UseBookNextDaySeat", ConfigConvert.ConvertToString(model.UseBookNextDaySeat));
            root.SetAttribute("UseBookNowDaySeat", ConfigConvert.ConvertToString(model.UseBookNowDaySeat));
            root.SetAttribute("UseBookSeat", ConfigConvert.ConvertToString(model.UseBookSeat));
            root.SetAttribute("UseCancelBook", ConfigConvert.ConvertToString(model.UseCancelBook));
            root.SetAttribute("UseCancelWait", ConfigConvert.ConvertToString(model.UseCancelWait));
            root.SetAttribute("UseCanLeave", ConfigConvert.ConvertToString(model.UseCanLeave));
            root.SetAttribute("UseComeBack", ConfigConvert.ConvertToString(model.UseComeBack));
            root.SetAttribute("UseContinue", ConfigConvert.ConvertToString(model.UseContinue));
            root.SetAttribute("UseShortLeave", ConfigConvert.ConvertToString(model.UseShortLeave));
            root.SetAttribute("UseWaitSeat", ConfigConvert.ConvertToString(model.UseWaitSeat));
            root.SetAttribute("UseSelectSeat", ConfigConvert.ConvertToString(model.UseSelectSeat));
            root.SetAttribute("UseChangeSeat", ConfigConvert.ConvertToString(model.UseChangeSeat));
            //添加根节点
            xmlDoc.AppendChild(root);
            return(xmlDoc.OuterXml);
        }
コード例 #3
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);
        }
コード例 #4
0
        public static XmlElement ToXmlNode(OftenSeat oftenSeat)
        {
            XmlDocument doc     = new XmlDocument();
            XmlElement  secNode = doc.CreateElement("OftenSeat");

            secNode.InnerText = ConfigConvert.ConvertToString(oftenSeat.Used);
            secNode.SetAttribute("LengthTime", oftenSeat.LengthDays.ToString());
            secNode.SetAttribute("SeatCount", oftenSeat.SeatCount.ToString());
            return(secNode);
        }
コード例 #5
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);
        }
コード例 #6
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);
        }
コード例 #7
0
        public static XmlElement ToXmlNode(POSRestrict set, XmlDocument doc)
        {
            XmlElement secNode = doc.CreateElement("POSRestrict");

            if (set == null)
            {
                set = new POSRestrict()
                {
                    Minutes = 10, Times = 3, IsUsed = true
                };
            }
            secNode.SetAttribute("IsUsed", ConfigConvert.ConvertToString(set.IsUsed));
            secNode.SetAttribute("Minutes", set.Minutes.ToString());
            secNode.SetAttribute("Times", set.Times.ToString());
            return(secNode);
        }
コード例 #8
0
        private static XmlElement ConvertBlacklistSet(BlacklistSetting blacklist)
        {
            XmlElement element = doc.CreateElement("blacklist");

            element.SetAttribute("used", ConfigConvert.ConvertToString(blacklist.Used));
            element.SetAttribute("violateTimes", blacklist.ViolateTimes.ToString());
            element.SetAttribute("limitDays", blacklist.LimitDays.ToString());
            element.SetAttribute("leaveBlacklist", ((int)blacklist.LeaveBlacklist).ToString());
            element.SetAttribute("ViolateFailDays", blacklist.ViolateFailDays.ToString());
            foreach (ViolationRecordsType violateType in blacklist.ViolateRoule.Keys)
            {
                XmlElement child = doc.CreateElement("violateType");
                child.SetAttribute("used", ConfigConvert.ConvertToString(blacklist.ViolateRoule[violateType]));
                child.SetAttribute("typeValue", ((int)violateType).ToString());
                element.AppendChild(child);
            }
            return(element);
        }
コード例 #9
0
        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);
        }
コード例 #10
0
        /// <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);
        }
コード例 #11
0
        public static string Convert(ClientConfigV2 config)
        {
            XmlDocument    doc = new XmlDocument();
            XmlDeclaration dec = doc.CreateXmlDeclaration("1.0", "utf-8", null);

            doc.AppendChild(dec);
            XmlElement root     = doc.CreateElement("RootNote");
            XmlElement secNode1 = doc.CreateElement("ClientNo");

            secNode1.InnerText = config.ClientNo;
            root.AppendChild(secNode1);
            XmlElement secNode2 = doc.CreateElement("ChooseSeatMothed");

            secNode2.InnerText = ((int)config.SelectMethod).ToString();
            root.AppendChild(secNode2);
            XmlElement secNode3 = doc.CreateElement("Nokeyboard");

            secNode3.InnerText = ConfigConvert.ConvertToString(config.UsingEnterNoForSeat);
            root.AppendChild(secNode3);

            XmlElement secNode4 = doc.CreateElement("OftenSeat");

            secNode4.InnerText = ConfigConvert.ConvertToString(config.UsingOftenUsedSeat.Used);
            secNode4.SetAttribute("LengthTime", config.UsingOftenUsedSeat.LengthDays.ToString());
            secNode4.SetAttribute("SeatCount", config.UsingOftenUsedSeat.SeatCount.ToString());
            root.AppendChild(secNode4);
            XmlElement secNode5 = doc.CreateElement("isPrint");

            secNode5.InnerText = ((int)config.UsingPrintSlip).ToString();
            root.AppendChild(secNode5);
            XmlElement nodeShowClosedRoom = doc.CreateElement("IsShowClosedRoom");

            nodeShowClosedRoom.InnerText = ConfigConvert.ConvertToString(config.IsShowClosedRoom);
            root.AppendChild(nodeShowClosedRoom);
            XmlElement secNode6 = doc.CreateElement("Activation");

            secNode6.InnerText = ConfigConvert.ConvertToString(config.UsingActiveBespeakSeat);
            root.AppendChild(secNode6);

            XmlElement secNode11 = doc.CreateElement("IsShowInitPOS");

            secNode11.InnerText = ConfigConvert.ConvertToString(config.IsShowInitPOS);
            root.AppendChild(secNode11);

            XmlElement secNode7 = doc.CreateElement("POSRestrict");

            secNode7.SetAttribute("Minutes", config.PosTimes.Minutes.ToString());
            secNode7.SetAttribute("Times", config.PosTimes.Times.ToString());
            secNode7.SetAttribute("IsUsed", config.PosTimes.IsUsed.ToString());
            root.AppendChild(secNode7);
            XmlElement secNode8 = doc.CreateElement("AddReadingRoom");

            foreach (string roomNo in config.Rooms)
            {
                XmlElement thirdNode = doc.CreateElement("ReadRoomID");
                thirdNode.InnerText = roomNo;
                secNode8.AppendChild(thirdNode);
            }
            root.AppendChild(secNode8);

            XmlElement secNode9 = doc.CreateElement("img");

            foreach (string elementName in config.BackImgage.Keys)
            {
                XmlElement thirdNode = doc.CreateElement("backgroundimg");
                thirdNode.InnerText = config.BackImgage[elementName];
                thirdNode.SetAttribute("id", elementName);
                secNode9.AppendChild(thirdNode);
            }
            root.AppendChild(secNode9);

            XmlElement secNode10   = doc.CreateElement("Resolution");
            XmlElement thirdNode1  = doc.CreateElement("FormSet");
            XmlElement fourthNode1 = doc.CreateElement("size");

            fourthNode1.SetAttribute("x", config.SystemResoultion.WindowSize.Size.X.ToString());
            fourthNode1.SetAttribute("y", config.SystemResoultion.WindowSize.Size.Y.ToString());
            thirdNode1.AppendChild(fourthNode1);
            XmlElement fourthNode2 = doc.CreateElement("location");

            fourthNode2.SetAttribute("x", config.SystemResoultion.WindowSize.Location.X.ToString());
            fourthNode2.SetAttribute("y", config.SystemResoultion.WindowSize.Location.Y.ToString());
            thirdNode1.AppendChild(fourthNode2);

            secNode10.AppendChild(thirdNode1);
            XmlElement thirdNode2  = doc.CreateElement("TooltipSet");
            XmlElement fourthNode3 = doc.CreateElement("size");

            fourthNode3.SetAttribute("x", config.SystemResoultion.TooltipSize.Size.X.ToString());
            fourthNode3.SetAttribute("y", config.SystemResoultion.TooltipSize.Size.Y.ToString());
            thirdNode2.AppendChild(fourthNode3);
            XmlElement fourthNode4 = doc.CreateElement("location");

            fourthNode4.SetAttribute("x", config.SystemResoultion.TooltipSize.Location.X.ToString());
            fourthNode4.SetAttribute("y", config.SystemResoultion.TooltipSize.Location.Y.ToString());
            thirdNode2.AppendChild(fourthNode4);
            secNode10.AppendChild(thirdNode2);
            root.AppendChild(secNode10);

            XmlElement secNode12 = doc.CreateElement("WinCountDown");

            secNode12.SetAttribute("AccessActive", config.WinCountDown.AccessActive.ToString());
            secNode12.SetAttribute("LastSeatWindow", config.WinCountDown.LastSeatWindow.ToString());
            secNode12.SetAttribute("LeaveWindow", config.WinCountDown.LeaveWindow.ToString());
            secNode12.SetAttribute("LogSerachWindow", config.WinCountDown.LogSerachWindow.ToString());
            secNode12.SetAttribute("MessageWindow", config.WinCountDown.MessageWindow.ToString());
            secNode12.SetAttribute("RoomWindow", config.WinCountDown.RoomWindow.ToString());
            secNode12.SetAttribute("SeatWindow", config.WinCountDown.SeatWindow.ToString());
            secNode12.SetAttribute("KeyboardWindow", config.WinCountDown.KeyboardWindow.ToString());
            secNode12.SetAttribute("ReaderNoticeWindow", config.WinCountDown.ReaderNoticeWindow.ToString());
            secNode12.SetAttribute("UsuallySeatWindow", config.WinCountDown.UsuallySeatWindow.ToString());
            root.AppendChild(secNode12);

            doc.AppendChild(root);
            return(doc.OuterXml);
        }
コード例 #12
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="xmlClientConfig"></param>
        /// <returns></returns>
        public static ClientConfigV2 Convert(string xmlClientConfig)
        {
            XmlDocument doc = new XmlDocument();

            try
            {
                doc.LoadXml(xmlClientConfig);
                ClientConfigV2 config = new ClientConfigV2();
                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 = (PrintSlipMode)int.Parse(node.InnerText);
                }
                node = doc.SelectSingleNode("//RootNote/Activation");
                if (node != null)
                {
                    config.UsingActiveBespeakSeat = ConfigConvert.ConvertToBool(node.InnerText);
                }
                node = doc.SelectSingleNode("//RootNote/POSRestrict");
                if (node != null)
                {
                    if (node.Attributes["IsUsed"] != null)
                    {
                        config.PosTimes.IsUsed = bool.Parse(node.Attributes["IsUsed"].Value);
                    }
                    config.PosTimes.Minutes = int.Parse(node.Attributes["Minutes"].Value);
                    config.PosTimes.Times   = int.Parse(node.Attributes["Times"].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);

                node = doc.SelectSingleNode("//RootNote/WinCountDown");
                if (node != null)
                {
                    config.WinCountDown.AccessActive    = int.Parse(node.Attributes["AccessActive"].Value);
                    config.WinCountDown.LastSeatWindow  = int.Parse(node.Attributes["LastSeatWindow"].Value);
                    config.WinCountDown.LeaveWindow     = int.Parse(node.Attributes["LeaveWindow"].Value);
                    config.WinCountDown.LogSerachWindow = int.Parse(node.Attributes["LogSerachWindow"].Value);
                    config.WinCountDown.MessageWindow   = int.Parse(node.Attributes["MessageWindow"].Value);
                    if (node.Attributes["RoomWindow"] != null)
                    {
                        config.WinCountDown.RoomWindow = int.Parse(node.Attributes["RoomWindow"].Value);
                    }
                    if (node.Attributes["SeatWindow"] != null)
                    {
                        config.WinCountDown.SeatWindow = int.Parse(node.Attributes["SeatWindow"].Value);
                    }
                    if (node.Attributes["UsuallySeatWindow"] != null)
                    {
                        config.WinCountDown.UsuallySeatWindow = int.Parse(node.Attributes["UsuallySeatWindow"].Value);
                    }
                    if (node.Attributes["ReaderNoticeWindow"] != null)
                    {
                        config.WinCountDown.ReaderNoticeWindow = int.Parse(node.Attributes["ReaderNoticeWindow"].Value);
                    }
                    if (node.Attributes["KeyboardWindow"] != null)
                    {
                        config.WinCountDown.KeyboardWindow = int.Parse(node.Attributes["KeyboardWindow"].Value);
                    }
                }

                return(config);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #13
0
        /// <summary>
        /// 通过座位布局创建Xml
        /// </summary>
        /// <returns></returns>
        public static string CreadSeatXml(SeatLayout seatLayout)
        {
            XmlDocument doc = new XmlDocument();

            try
            {
                //创建开头
                XmlDeclaration dec = doc.CreateXmlDeclaration("1.0", "utf-8", null);
                doc.AppendChild(dec);
                XmlElement Rootelement = doc.CreateElement("seatroot");//最后添加到Doc

                XmlElement SecNode1 = doc.CreateElement("seatinfo");
                //行
                XmlElement ThirdNode1 = doc.CreateElement("rowscount");
                ThirdNode1.InnerText = seatLayout.SeatRow.ToString();
                //列
                XmlElement ThirdNode2 = doc.CreateElement("columscount");
                ThirdNode2.InnerText = seatLayout.SeatCol.ToString();

                //方位
                XmlElement ThirdNode3 = doc.CreateElement("position");
                ThirdNode3.InnerText = seatLayout.Position.ToString();

                XmlElement ThirdNode4 = doc.CreateElement("IsUpdate");
                ThirdNode4.InnerText = seatLayout.IsUpdate.ToString();

                SecNode1.AppendChild(ThirdNode1);
                SecNode1.AppendChild(ThirdNode2);
                SecNode1.AppendChild(ThirdNode3);
                SecNode1.AppendChild(ThirdNode4);

                Rootelement.AppendChild(SecNode1);
                //创建座位节点
                XmlElement SecNode2 = doc.CreateElement("seatdetail");
                foreach (string seatNo in seatLayout.Seats.Keys)
                {
                    XmlElement seatNode = doc.CreateElement("objseat");
                    //   seatNode.SetAttribute("seatno", seatLayout.RoomNo + seatLayout.Seats[seatNo].ShortSeatNo);
                    seatNode.SetAttribute("seatno", seatLayout.Seats[seatNo].SeatNo);
                    seatNode.SetAttribute("haspower", ConfigConvert.ConvertToString(seatLayout.Seats[seatNo].HavePower));
                    seatNode.SetAttribute("isstop", ConfigConvert.ConvertToString(seatLayout.Seats[seatNo].IsSuspended));
                    seatNode.SetAttribute("rownum", seatLayout.Seats[seatNo].PositionY.ToString());
                    seatNode.SetAttribute("colnum", seatLayout.Seats[seatNo].PositionX.ToString());
                    seatNode.SetAttribute("booktype", Convert.ToInt32(seatLayout.Seats[seatNo].CanBeBespeak).ToString());
                    seatNode.SetAttribute("centerx", seatLayout.Seats[seatNo].RotationCenterX.ToString());
                    seatNode.SetAttribute("centery", seatLayout.Seats[seatNo].RotationCenterY.ToString());
                    seatNode.SetAttribute("angle", seatLayout.Seats[seatNo].RotationAngle.ToString());
                    SecNode2.AppendChild(seatNode);
                }
                Rootelement.AppendChild(SecNode2);
                //创建备注节点。。
                XmlElement seatNotes = doc.CreateElement("seatnotes");
                for (int i = 0; i < seatLayout.Notes.Count; i++)
                {
                    XmlElement node = doc.CreateElement("seatnote");
                    node.SetAttribute("strnote", seatLayout.Notes[i].Remark);
                    node.SetAttribute("rownum", seatLayout.Notes[i].PositionY.ToString());
                    node.SetAttribute("colnum", seatLayout.Notes[i].PositionX.ToString());
                    node.SetAttribute("centerx", seatLayout.Notes[i].RotationCenterX.ToString());
                    node.SetAttribute("centery", seatLayout.Notes[i].RotationCenterY.ToString());
                    node.SetAttribute("angle", seatLayout.Notes[i].RotationAngle.ToString());
                    node.SetAttribute("type", ((int)seatLayout.Notes[i].Type).ToString());
                    node.SetAttribute("baseHeight", seatLayout.Notes[i].BaseHeight.ToString());
                    node.SetAttribute("baseWidth", seatLayout.Notes[i].BaseWidth.ToString());
                    seatNotes.AppendChild(node);
                    // throw new Exception("老的构造方法");
                }
                Rootelement.AppendChild(seatNotes);
                doc.AppendChild(Rootelement);
                return(doc.OuterXml);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #14
0
        /// <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);
        }