void UpdateWaitQue()
        {
            if (sWaitDownLoad.Count > 0 && sDownLoading.Count < MaxThread)
            {
                SortWaitQue();
                int tneed = MaxThread - sDownLoading.Count;
                for (int i = 0; i < tneed; i++)
                {
                    IDownLoad item = (IDownLoad)sWaitDownLoad[0];
                    if (!item.IsDone)
                    {
                        sWaitDownLoad.RemoveAt(0);
                        sDownLoading.Add(item);
                        item.StartAsync();
                    }
                    else
                    {
                        Remove(item.Key);
                    }

                    if (sWaitDownLoad.Count == 0)
                    {
                        break;
                    }
                }
            }
        }
 void UpdateDownLoading()
 {
     for (int i = sDownLoading.Count - 1; i >= 0; i--)
     {
         IDownLoad item = (IDownLoad)sDownLoading[i];
         item.Update();
         if (item.IsDone)
         {
             Remove(item.Key);
             item.CallComplete();
         }
     }
 }
Exemple #3
0
 public HomeViewListViewModel(string title) : base(title)
 {
     Title           = "大连金州智慧换热站";
     GatherDatas     = new List <GatherData>();
     StationCodes    = new List <StationCode>();
     GatherErrors    = new List <GatherError>();
     DownLoadService = DependencyService.Get <IDownLoad>();
     InitializeAsync();
     //Task.Run(async () =>
     //{
     //    while(true)
     //    {
     //        await OnDownLoad(null);
     //        await Task.Delay(DownLoadInterval * 1000);
     //    }
     //});
 }
Exemple #4
0
        public HomeViewViewModel()
        {
            Title            = "大连金州智慧换热站";
            Items            = new ObservableCollection <Item>();
            LoadItemsCommand = new Command(async() => await ExecuteLoadItemsCommand());
            DownLoadService  = DependencyService.Get <IDownLoad>();

            MessagingCenter.Subscribe <Pages.NewStationPage, Item>(this,
                                                                   Utils.MessengerKeys.NewStation, async(obj, item) =>
            {
                var _item = item as Item;
                AddNewItem(_item);
                await DataStore.AddItemAsync(_item);
            });

            #region 站类型定义
            Stations = new List <Station>
            {
                new Station()
                {
                    Name = "阿尔滨站"
                },
                new Station()
                {
                    Name = "金渤海景站"
                },
                new Station()
                {
                    Name = "南山站"
                },
                new Station()
                {
                    Name = "金山站"
                },
                new Station()
                {
                    Name = "政府站"
                },

                new Station()
                {
                    Name = "龙王站"
                },
                new Station()
                {
                    Name = "自来水站"
                },
                new Station()
                {
                    Name = "南棉站"
                },
                new Station()
                {
                    Name = "盐场站"
                },
                new Station()
                {
                    Name = "金海国际"
                },

                new Station()
                {
                    Name = "北京郡站"
                },
                new Station()
                {
                    Name = "光明西站"
                },
                new Station()
                {
                    Name = "金海国际站"
                },
                new Station()
                {
                    Name = "金连领地站"
                },
                new Station()
                {
                    Name = "金山名苑站"
                },

                new Station()
                {
                    Name = "欧美亚站"
                },
                new Station()
                {
                    Name = "铁路站"
                },
                new Station()
                {
                    Name = "五一站"
                },
                new Station()
                {
                    Name = "于家洼站"
                },
                new Station()
                {
                    Name = "环保站"
                },
                new Station()
                {
                    Name = "阿尔滨站"
                },
                new Station()
                {
                    Name = "金渤海景站"
                },
                new Station()
                {
                    Name = "南山站"
                },
                new Station()
                {
                    Name = "金山站"
                },
                new Station()
                {
                    Name = "政府站"
                },

                new Station()
                {
                    Name = "龙王站"
                },
                new Station()
                {
                    Name = "自来水站"
                },
                new Station()
                {
                    Name = "南棉站"
                },
                new Station()
                {
                    Name = "盐场站"
                },
                new Station()
                {
                    Name = "金海国际"
                },

                new Station()
                {
                    Name = "北京郡站"
                },
                new Station()
                {
                    Name = "光明西站"
                },
                new Station()
                {
                    Name = "金海国际站"
                },
                new Station()
                {
                    Name = "金连领地站"
                },
                new Station()
                {
                    Name = "金山名苑站"
                },

                new Station()
                {
                    Name = "欧美亚站"
                },
                new Station()
                {
                    Name = "铁路站"
                },
                new Station()
                {
                    Name = "五一站"
                },
                new Station()
                {
                    Name = "于家洼站"
                },
                new Station()
                {
                    Name = "环保站"
                },
            };
            RestoreState(Application.Current.Properties);
            #endregion

            OnDownLoad(null);
            Device.StartTimer(TimeSpan.FromSeconds(20), () =>
            {
                OnDownLoad(null);
                return(true);
            });

            ConnectServer();
        }