示例#1
0
        public async override Task InitializeAsync()
        {
            if (IsInitialize == true)
            {
                return;
            }
            await Task.Run(async() => {
                for (int i = 0; i < 50 - 7; ++i)
                {
                    await AddItemAsync(new Item()
                    {
                        StationName = "换热站",
                        Id          = i.ToString()
                    });
                    GatherDatas.Add(new GatherData());
                    StationCodes.Add(new StationCode());
                    GatherErrors.Add(new GatherError());
                }
            });

            IsInitialize = true;
        }
示例#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 ? "通信异常!" : "查询时间无数据";
                }
            }
        }