private async Task <LoadMoreItemsResult> InnerLoadMoreItemsAsync(uint expectedCount) { _buzy = true; var actualCount = 0; List <Duan> list = null; try { DataLoading?.Invoke(); list = await _api.GetDuan(DataShareManager.Current.DuanItemPage++); } catch (Exception) { HasMoreItems = false; } if (list != null && list.Any()) { actualCount = list.Count; list.ForEach((t) => { //if (DataShareManager.Current.ReadedList.Contains(t.ID)) //{ // t.Readed = true; //} bool isPassedUnWel = true; if (!DataShareManager.Current.IsShowUnwelcome) { int oo = t.VotePositive; int xx = t.VoteNegative; if ((oo + xx) >= 50 && ((double)oo / (double)xx) < 0.618) { t.Content += "\n\nUnwelcome"; isPassedUnWel = false; } } if (isPassedUnWel) { Add(t); } }); HasMoreItems = true; } else { HasMoreItems = false; --DataShareManager.Current.DuanItemPage; } DataLoaded?.Invoke(); _buzy = false; return(new LoadMoreItemsResult { Count = (uint)actualCount }); }
public static async Task RunThreeSumBruteForceSolveAsync(string filePathName) { var ints = await DataLoading.GetIntArrayFromFileAsync(filePathName); await ConsoleLogAsync($"Starting {ThreeSumBruteForce}..."); var sw = Stopwatch.StartNew(); var solutionCount = ThreeSum.BruteForceSolve(input: ints, targetSum: ThreeSumBruteForceTargetSum); sw.Stop(); await ConsoleLogAsMicrosecondsAsync($"{ThreeSumBruteForce} found {solutionCount} solutions for target sum {ThreeSumBruteForceTargetSum} in", sw); }
protected virtual IEnumerable <SortModel> GetSortModels(DataLoading dataLoading, int recordRequestNumber) { if (dataLoading == DataLoading.BatchLoad) { foreach (var batch in BatchHelper.GetSortModels(recordRequestNumber)) { yield return(batch); } } else { yield return(new SortModel(recordRequestNumber, int.MaxValue)); } }
//public List<> // Use this for initialization void Start() { backButton.SetActive(false); startWidth = panelImageRT[0].sizeDelta.x; dataLoading = GameObject.Find("DataLoading").GetComponent <DataLoading>(); panelWidth = 2; arrow0.SetActive(false); arrow1.SetActive(false); showGallery(false); }
public ActionResult <string> Get() { try { _logger.LogInformation("Loading and parsing data from disk."); dataObject = new DataLoading("./Data/departments.csv"); } catch (Exception e) { string msg = $"\nERROR! Data parsing failed with message: {e.Message}"; _logger.LogError(msg); return(BadRequest(msg)); } return(JsonConvert.SerializeObject(dataObject.outputList)); }
private async Task <LoadMoreItemsResult> InnerLoadMoreItemsAsync(uint expectedCount) { _buzy = true; var actualCount = 0; List <Fresh> list = null; try { DataLoading?.Invoke(); list = await _api.GetFresh(DataShareManager.Current.FreshNewsPage++); } catch (Exception) { HasMoreItems = false; } if (list != null && list.Any()) { actualCount = list.Count; list.ForEach((t) => { //if (DataShareManager.Current.ReadedList.Contains(t.ID)) //{ // t.Readed = true; //} if (DataShareManager.Current.isNoImageMode) { t.Thumb_c = "ms-appx:///Assets/No_Image_150.png"; } Add(t); }); HasMoreItems = true; } else { HasMoreItems = false; --DataShareManager.Current.FreshNewsPage; } DataLoaded?.Invoke(); _buzy = false; return(new LoadMoreItemsResult { Count = (uint)actualCount }); }
private async Task <LoadMoreItemsResult> InnerLoadMoreItemsAsync(uint expectedCount) { _buzy = true; var actualCount = 0; List <BoringPic> list = null; try { DataLoading?.Invoke(); list = await _api.GetMeiziPics(DataShareManager.Current.MeiziItemPage++); } catch (Exception) { HasMoreItems = false; } if (list != null && list.Any()) { actualCount = list.Count; list.ForEach((t) => { //if (DataShareManager.Current.ReadedList.Contains(t.ID)) //{ // t.Readed = true; //} Add(t); }); HasMoreItems = true; } else { HasMoreItems = false; --DataShareManager.Current.MeiziItemPage; } if (DataLoaded != null) { DataLoaded(); } _buzy = false; return(new LoadMoreItemsResult { Count = (uint)actualCount }); }
public void DoWork(string name, int age) { Queries queries = new Queries(); // queries.Start(); Projections projections = new Projections(); //projections.Start(); ChangeTracking changeTracking = new ChangeTracking(); //changeTracking.ContextLifeCycle(); DataLoading dataLoading = new DataLoading(); //dataLoading.Load(); ConnectedContext connected = new ConnectedContext(); //connected.CRUD_AutoDetectChanges(); connected.CRUD_DisableProxy(); }
public async Task LoadAsync(DataLoading dataLoading, TModel model) { var filter = GetFilter(model); var filterKey = filter.Key; switch (dataLoading) { case DataLoading.Load: case DataLoading.BatchLoad: await LoadModels(model, filter, dataLoading).ConfigureAwait(false); break; case DataLoading.Preload: await LoadModels(model, filter, dataLoading).ConfigureAwait(false); break; case DataLoading.Refresh: var collection = GetCollectionsLoadContainer(filterKey).GetCollection(); OnCollectionFetched(collection); if (GetCollectionsLoadContainer(filterKey).GetEndOfCollectionWithNoRunningTasks()) { OnEndOfCollection(filterKey); } else if (!GetCollectionsLoadContainer(filterKey).GetEndOfCollection()) { await LoadModels(model, filter, dataLoading).ConfigureAwait(false); } break; case DataLoading.Reset: Reset(); await LoadModels(model, filter, dataLoading).ConfigureAwait(false); break; default: throw new ArgumentOutOfRangeException(nameof(dataLoading), dataLoading, null); } }
public async Task LoadMoreHistory() { if (!HasMore) { return; } lock (o) { loading = true; } DataLoading?.Invoke(); CurrentPage++; List <Parameters> param = new List <Parameters>(); param.Add(new Parameters("to", ToUid)); param.Add(new Parameters("type", "getdetail")); param.Add(new Parameters("page", CurrentPage.ToString())); param.Add(new Parameters("token", Constants.token)); Parameters result = await WebConnection.Connect(Constants.domain + "/pkuhelper/../services/msg.php?api_version=2", param); if (result.name != "200") { Util.DealWithDisconnect(result); } else { JsonObject temp_json = JsonObject.Parse(result.value); int code = (int)temp_json.GetNamedNumber("code"); if (code != 0) { Constants.BoxPage.ShowMessage("获取聊天记录失败"); } else { AddHistory(result.value); } } DataLoaded?.Invoke(); lock (o) { loading = false; } }
protected async Task LoadModels(TModel model, FilterModel filter, DataLoading dataLoading) { var filterKey = filter.Key; var tasks = new List <Task <List <TViewModel> > >(); var recordRequestNumber = GetCollectionsLoadContainer(filterKey).GetRecordRequestNumber(); if (recordRequestNumber == int.MaxValue || GetCollectionsLoadContainer(filterKey).GetEndOfCollection() || GetCollectionsLoadContainer(filterKey).RunningTaskCount() > 0) { return; } var singleRequest = false; foreach (var batch in GetSortModels(dataLoading, recordRequestNumber)) { singleRequest = batch.RecordRequestNumber == int.MaxValue; if (batch.RecordRequestNumber > GetCollectionsLoadContainer(filterKey).GetRecordRequestNumber()) { GetCollectionsLoadContainer(filterKey).AddRecordRequestNumber(batch.Take); lock (_filterLock) { filter.Sort.Skip = batch.Skip; filter.Sort.Take = batch.Take; tasks.Add(GetTask(model, filter)); GetCollectionsLoadContainer(filterKey).AddRunningTask(); } } } while (tasks.Any()) { var completedTask = await Task.WhenAny(tasks).ConfigureAwait(false); GetCollectionsLoadContainer(filterKey).RemoveRunningTask(); PopToList(filterKey, completedTask.Result, dataLoading, singleRequest); tasks.Remove(completedTask); } }
protected void PopToList(string filterKey, List <TViewModel> collection, DataLoading dataLoading, bool singleRequest) { if (collection.Any()) { GetCollectionsLoadContainer(filterKey).AddCollection(collection); if (!dataLoading.In(DataLoading.Preload)) { OnCollectionFetched(collection); } } if (singleRequest || !collection.Any()) { GetCollectionsLoadContainer(filterKey).SetEndOfCollection(); } if (!dataLoading.In(DataLoading.Preload) && GetCollectionsLoadContainer(filterKey).GetEndOfCollectionWithNoRunningTasksAndEndOfCollectionNotThrown()) { OnEndOfCollection(filterKey); } }
private void OnFlush() { try { this.GuiSync(() => DataLoading.SafeInvoke()); while (true) { Query query; lock (_syncObject) { _isChanged = false; if (_query == null) { this.GuiAsync(() => DataLoaded.SafeInvoke()); _isFlushing = false; break; } query = _query; _query = null; } Process(query.Item1, query.Item2, query.Item3, query.Item4); } } catch (Exception ex) { this.GuiAsync(() => { DataLoaded.SafeInvoke(); throw new InvalidOperationException(LocalizedStrings.Str1538, ex); }); } }
public void Load(DataLoading dataLoading, TModel model) { Task.Run(() => LoadAsync(dataLoading, model).ConfigureAwait(false)); }
public static string vPQ(string code) { DataLoading DL = new DataLoading(); return(DL.NameReturn("PQUYEN", "[USER]", "CODE = '" + code + "'")); }
public static string vCheckPass(string code) { DataLoading DL = new DataLoading(); return(DL.NameReturn("CHECK_PASS", "[USER]", "CODE = '" + code + "'")); }
public static string vName(string MaNV, string MaDV) { DataLoading DL = new DataLoading(); return(DL.NameReturn("TEN_NHAN_VIEN", "TB_NHAN_VIEN", "MA_NHAN_VIEN = '" + MaNV + "' and MA_DVI = '" + MaDV + "'")); }
public static string vMaDV(string Code) { DataLoading DL = new DataLoading(); return(DL.NameReturn("MA_DVI", "[USER]", "CODE = '" + Code + "'")); }
private async Task <LoadMoreItemsResult> InnerLoadMoreItemsAsync(uint expectedCount) { _buzy = true; var actualCount = 0; List <BoringPic> list = null; try { DataLoading?.Invoke(); list = await _api.GetBoringPics(DataShareManager.Current.BoringItemPage++); } catch (Exception) { HasMoreItems = false; } if (list != null && list.Any()) { actualCount = list.Count; list.ForEach((t) => { //if (DataShareManager.Current.ReadedList.Contains(t.ID)) //{ // t.Readed = true; //} if (DataShareManager.Current.isNoImageMode) { t.Urls = t.Thumb; } var comment = t.Content.Replace("\n", "").Replace("\r", ""); t.Content = comment; bool isPassedNSFW = true, isPassedUnWel = true; if (!DataShareManager.Current.IsShowNSFW && t.Content.Contains("NSFW")) { isPassedNSFW = false; } if (!DataShareManager.Current.IsShowUnwelcome) { int oo = t.VotePositive; int xx = t.VoteNegative; if ((oo + xx) >= 50 && ((double)oo / (double)xx) < 0.618) { t.Content += "\n\nUnwelcome"; isPassedUnWel = false; } } if (isPassedNSFW && isPassedUnWel) { Add(t); } }); HasMoreItems = true; } else { HasMoreItems = false; --DataShareManager.Current.BoringItemPage; } DataLoaded?.Invoke(); _buzy = false; return(new LoadMoreItemsResult { Count = (uint)actualCount }); }