private TimeEntryGroup GetSuitableEntryGroupFor(DateGroup dateGroup, TimeEntryData dataObject, out bool isNewEntryGroup) { isNewEntryGroup = false; foreach (var grp in dateGroup.TimeEntryGroupList) { if (grp.CanContain(dataObject)) { return(grp); } } var entryGroup = new TimeEntryGroup(dataObject); dateGroup.Add(entryGroup); isNewEntryGroup = true; return(entryGroup); }
private TimeEntryGroup GetExistingEntryGroupFor(DateGroup dateGroup, TimeEntryData dataObject, out bool isNewEntryGroup) { isNewEntryGroup = false; foreach (var grp in dateGroup.TimeEntryGroupList) { TimeEntryData entryData; if (grp.Contains(dataObject, out entryData)) { return(grp); } } var entryGroup = new TimeEntryGroup(dataObject); dateGroup.Add(entryGroup); isNewEntryGroup = true; return(entryGroup); }
protected async override Task AddTimeEntryHolderAsync(TimeEntryHolder holder) { var entryGroup = new TimeEntryGroup(holder.TimeEntryDataList); bool isNewGroup; DateGroup grp = GetDateGroupFor(entryGroup.Data, out isNewGroup); grp.Add(entryGroup); Sort(); // Update Date group. var groupIndex = GetDateGroupIndex(grp); var groupAction = isNewGroup ? NotifyCollectionChangedAction.Add : NotifyCollectionChangedAction.Replace; await UpdateCollectionAsync(grp, groupAction, groupIndex); // Add time entry group. var newIndex = GetEntryGroupIndex(entryGroup); await UpdateCollectionAsync(entryGroup, NotifyCollectionChangedAction.Add, newIndex); }
void LoadTransactions(int offset) { try { isLoading = true; string transactionsInfo = ""; transactions.Amount = _amount; transactions.DeviceKey = MobileStaticVariables.UserInfo.MobileDeviceKey; transactions.Offset = offset; transactionsInfo = MobileStaticVariables.WebUtils.SendCardRequest("TransactionsSeller", Convert.ToBase64String(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(transactions)))); Logger.WriteLine("transactionsInfo : " + transactionsInfo); if (transactionsInfo == "") { throw new Exception("Pustaya stroka"); } transactions = JsonConvert.DeserializeObject <SellerTransactionInfo>(transactionsInfo); if (transactions.ResultState == RequestResult.Results.Success) { if (offset == 0 && transactions.Transactions.Count == 0) { Device.BeginInvokeOnMainThread(() => { HideList(); }); } } else { Device.BeginInvokeOnMainThread(async() => { if (IsVisible) { await DisplayAlert("Внимание", transactions.TranslateResult(transactions.ResultState), "Продолжить"); HideList(); } }); } Device.BeginInvokeOnMainThread(() => { foreach (var item in transactions.Transactions) { var transactionCellView = new CellModel(item); var group = Transactions.FirstOrDefault(x => (x.ComleteDate.Year == item.CompleteDatetime.Year) && (x.ComleteDate.DayOfYear == item.CompleteDatetime.DayOfYear)); if (group != null) { group.Add(transactionCellView); } else { var isFirstGroup = Transactions.Count == 0; group = new DateGroup(item.CompleteDatetime, _upFrame, isFirstGroup); group.Add(transactionCellView); Transactions.Add(group); } } needToLoad = transactions.Transactions.Count == _amount; if (IsVisible) { listTransaction.ItemsSource = null; listTransaction.ItemsSource = Transactions; } }); } catch (Exception ex) { Logger.WriteError(ex); Device.BeginInvokeOnMainThread(() => { if (IsVisible) { HideList(); noConnectionLayout.IsVisible = true; Device.StartTimer(new TimeSpan(0, 0, 1), WaitInternetConnection); } }); } finally { Device.BeginInvokeOnMainThread(() => { EndLoading(); }); isLoading = false; } }
private TimeEntryGroup GetSuitableEntryGroupFor (DateGroup dateGroup, TimeEntryData dataObject, out bool isNewEntryGroup) { isNewEntryGroup = false; foreach (var grp in dateGroup.TimeEntryGroupList) { if (grp.CanContain (dataObject)) { return grp; } } var entryGroup = new TimeEntryGroup (dataObject); dateGroup.Add (entryGroup); isNewEntryGroup = true; return entryGroup; }
private TimeEntryGroup GetExistingEntryGroupFor (DateGroup dateGroup, TimeEntryData dataObject, out bool isNewEntryGroup) { isNewEntryGroup = false; foreach (var grp in dateGroup.TimeEntryGroupList) { TimeEntryData entryData; if (grp.Contains (dataObject, out entryData)) { return grp; } } var entryGroup = new TimeEntryGroup (dataObject); dateGroup.Add (entryGroup); isNewEntryGroup = true; return entryGroup; }