Example #1
0
        /// <summary>
        /// 立即转换
        /// </summary>
        public void Convert()
        {
            //============================读取旧的
            fr2.BeginToStepRead();

            while (true)
            {
                var cache = fr2.ReadNext();

                if (cache.stopName == "")
                {
                    break;
                }

                oldSubway.Add(cache.stopName);
                oldSubwayExit.Add(cache.stopExit);
            }

            fr2.StopStepReading();

            //============================获取新的
            fr.BeginToStepRead();

            while (true)
            {
                var cache2 = fr.ReadNext();

                if (cache2.lineName == "")
                {
                    break;
                }
                if (cache2.lineType == enumLineType.Bus)
                {
                    continue;
                }

                foreach (string item in cache2.lineUpStop.ToStringGroup())
                {
                    var index = subwayStop.IndexOf(item);
                    if (index == -1)
                    {
                        //没写过
                        subwayStop.Add(item);
                    }
                    else
                    {
                        //写了
                        //不管
                    }
                }
                foreach (string item in cache2.lineDownStop.ToStringGroup())
                {
                    var index = subwayStop.IndexOf(item);
                    if (index == -1)
                    {
                        //没写过
                        subwayStop.Add(item);
                    }
                    else
                    {
                        //写了
                        //不管
                    }
                }
            }

            fr.StopStepReading();

            //============================写入

            fw.BeginToWrite();

            for (int a = 0; a < subwayStop.Count; a++)
            {
                int index  = oldSubway.IndexOf(subwayStop.Item(a));
                var cache3 = new SubwayFileBlockStruct();
                cache3.stopName = subwayStop.Item(a).ToString();

                if (index == -1)
                {
                    //没有以前的数据
                    var cache4 = new List <StringGroup>();
                    cache4.Add(new StringGroup("示例出口#通向遥远的地方", "#"));
                    cache3.stopExit = cache4;
                }
                else
                {
                    //有数据,直接写
                    cache3.stopExit = (List <StringGroup>)oldSubwayExit.Item(index);
                }

                fw.WriteNext(cache3);
            }

            fw.StopWriting();
        }
Example #2
0
        /// <summary>
        /// 立即转换
        /// </summary>
        public void Convert()
        {
            //===========================读取每条线路所有站台内容

            fr.BeginToStepRead();

            while (true)
            {
                var cache = fr.ReadNext();
                if (cache.lineName == "")
                {
                    break;
                }                                       //没有了

                foreach (string item in cache.lineUpStop.ToStringGroup())
                {
                    var index = busStop.IndexOf(item);
                    if (index == -1)
                    {
                        //没写过
                        busStop.Add(item);
                        busLine.Add(cache.lineName + ",");
                    }
                    else
                    {
                        //写了
                        if (CheckWordHaveBus(busLine.Item(index).ToString(), cache.lineName) == false)
                        {
                            busLine.Replace(index, busLine.Item(index).ToString() + cache.lineName + ",");
                        }
                    }
                }
                foreach (string item in cache.lineDownStop.ToStringGroup())
                {
                    var index = busStop.IndexOf(item);
                    if (index == -1)
                    {
                        //没写过
                        busStop.Add(item);
                        busLine.Add(cache.lineName + ",");
                    }
                    else
                    {
                        //写了
                        if (CheckWordHaveBus(busLine.Item(index).ToString(), cache.lineName) == false)
                        {
                            busLine.Replace(index, busLine.Item(index).ToString() + cache.lineName + ",");
                        }
                    }
                }
            }
            fr.StopStepReading();

            //===========================写入
            fw.BeginToWrite();
            for (int a = 0; a < busStop.Count; a++)
            {
                var cache = new StopFileBlockStruct();
                cache.stopName = busStop.Item(a).ToString();
                string cache2 = busLine.Item(a).ToString();
                cache.stopCrossLine = new StringGroup(cache2.Substring(0, cache2.Length - 1), ",");

                fw.WriteNext(cache);
            }

            fw.StopWriting();
        }