Esempio n. 1
0
        async Task OnDownLoad(object obj)
        {
            //DateTime[] loadTimes = TimerHelper.GetUpLoadTimes();
            string str = "";
            //string realURL = url + "stations" + TimerHelper.GetUpLoadTime() + ".txt";
            string realURL = "http://oios713sb.bkt.clouddn.com/stations2017032916050.txt";

            str = await DownLoadService.DownLoadString(realURL);

            if (str != "Error")
            {
                var paraTotals        = str.Split('@');
                var gatherDatasTotal  = paraTotals[0];
                var stationCodesTotal = paraTotals[1];
                var gatherDatas       = gatherDatasTotal.Split('&');
                var stationCodes      = stationCodesTotal.Split('&');
                StationNums = stationCodes.Length - 1;

                for (int i = 0; i < StationNums; ++i)
                {
                    var paraStr = stationCodes[i].Split('|');
                    Items[i].StationName = paraStr[0];
                }
            }
            else
            {
                for (int i = 0; i < RealStationNum; ++i)
                {
                    Stations[i].SetAllParaNull();
                    Items[i].Description   = "dfsdf!";
                    Items[i].StationStatus = StationStatusEnum.Unkown;
                }
            }

            //MessagingCenter.Send(this, Utils.MessengerKeys.RenewData, 1);
        }
Esempio n. 2
0
        async Task OnDownLoad(object obj)
        {
            string str     = "";
            string realURL = url + "stations" + TimerHelper.GetUpLoadTime() + ".txt";

            //string realURL = "http://oios713sb.bkt.clouddn.com/stations2017033012540.txt";
            str = await DownLoadService.DownLoadString(realURL);

            if (str != "Error")
            {
                var paraTotals = str.Split('@');

                var gatherDatasTotal  = paraTotals[0];
                var stationCodesTotal = paraTotals[1];
                var gatherErrorsTotal = paraTotals[2];

                var gatherDatas  = gatherDatasTotal.Split('&');
                var stationCodes = stationCodesTotal.Split('&');
                var gatherErrors = gatherErrorsTotal.Split('&');

                StationNums = stationCodes.Length - 1;

                for (int i = 0; i < StationNums - Items.Count; ++i)
                {
                    await AddItemAsync(new Item()
                    {
                        StationName = "正在获取数据...",
                        Id          = (i + Items.Count).ToString()
                    });

                    GatherDatas.Add(new GatherData());
                    StationCodes.Add(new StationCode());
                    GatherErrors.Add(new GatherError());
                }
                var oldItems = new ObservableCollection <Item>();
                for (int i = 0; i < StationNums; ++i)
                {
                    oldItems.Add(new Item()
                    {
                        Id = i.ToString()
                    });
                }
                for (int i = 0; i < StationNums; ++i)
                {
                    var paraStrSC = stationCodes[i].Split('|');
                    StationCodes[i].Paras = paraStrSC;

                    var paraStrGD = gatherDatas[i].Split('|');
                    GatherDatas[i].Paras = paraStrGD;

                    var paraStrGE = gatherErrors[i].Split('|');
                    GatherErrors[i].Paras = paraStrGE;

                    oldItems[i].StationName = StationCodes[i].Dictionary["station"].Split(')')[1];
                    oldItems[i].DisplaySort = StationCodes[i].Dictionary["dispsort"];
                    SetStationStatus(oldItems[i],
                                     GatherDatas[i].Dictionary["alarmsign"],
                                     GatherDatas[i].Dictionary["errsign"]);
                    //IsInitialize = true;
                }
                ItemsSort(oldItems);
            }
            else
            {
                foreach (var item in Items)
                {
                    item.StationStatus = StationStatusEnum.Unkown;
                    item.IsError       = false;
                    item.IsAlarm       = false;
                    item.StationName   = TimerHelper.IsCheckNotNow == false ? "通信异常!" : "查询时间无数据";
                }
            }
        }