public DataLinker(GitDBSettings settings, DataReader reader, DataSaver saver, DataUpdater updater, DataChecker checker, EntityLinker linker) { Settings = settings; Linker = linker; Reader = reader; Saver = saver; Updater = updater; Checker = checker; }
public IActionResult UpdateALL() { try { foreach (var a in CodeHelper.CodeDic) { DataUpdater.UpdateData(a.Key); } ViewBag.result = "success"; } catch (Exception e) { ViewBag.result = e.Message; } return(View()); }
public async Task PullRequestReview(DateTimeOffset eventDate, PullRequestReviewPayload payload) { // GitHub sends pending reviews that they shouldn't. We don't want them. if (payload.Review.State.Equals("pending", StringComparison.OrdinalIgnoreCase)) { this.Info($"Dropping pending review. {payload.Repository.FullName}#{payload.Review.Id}"); return; } var updater = new DataUpdater(_contextFactory, _mapper); await updater.UpdateRepositories(eventDate, new[] { payload.Repository }); await updater.UpdatePullRequests(payload.Repository.Id, eventDate, new[] { payload.PullRequest }); switch (payload.Action) { case "submitted": case "edited": // We need the issueId // TODO: Modify BulkUpdate to work with PR/Issue Number instead? long?issueId; using (var context = _contextFactory.CreateInstance()) { issueId = await context.Issues .AsNoTracking() .Where(x => x.RepositoryId == payload.Repository.Id && x.Number == payload.PullRequest.Number) .Select(x => (long?)x.Id) .SingleOrDefaultAsync(); } if (issueId != null) { await updater.UpdateReviews(payload.Repository.Id, issueId.Value, eventDate, new[] { payload.Review }); } break; case "dismissed": await updater.DeleteReview(payload.Review.Id); break; default: throw new NotImplementedException($"Action '{payload.Action}' is not valid for event {nameof(PullRequestReview)}."); } await updater.Changes.Submit(_queueClient); }
private async Task SyncTimerCallback(object state = null) { if (DateTimeOffset.UtcNow.Subtract(_lastSyncInterest) > SyncIdle) { DeactivateOnIdle(); return; } var metaDataMeaningfullyChanged = false; var updater = new DataUpdater(_contextFactory, _mapper); try { // Issue Mentions if (_mentionMetadata.IsExpired()) { var mentions = await _github.IssueMentions(_mentionSince, MentionNibblePages, _mentionMetadata, RequestPriority.Background); if (mentions.IsOk && mentions.Result.Any()) { metaDataMeaningfullyChanged = true; await updater.UpdateIssueMentions(_userId, mentions.Result); var maxSince = mentions.Result.Max(x => x.UpdatedAt).AddSeconds(-5); if (maxSince != _mentionSince) { await updater.UpdateAccountMentionSince(_userId, maxSince); _mentionSince = maxSince; } } // Don't update until saved. _mentionMetadata = GitHubMetadata.FromResponse(mentions); } } catch (GitHubRateException) { // nothing to do } await updater.Changes.Submit(_queueClient); // Save changes if (metaDataMeaningfullyChanged) { await Save(); } }
public async Task PullRequestReviewComment(DateTimeOffset eventDate, PullRequestReviewCommentPayload payload) { var updater = new DataUpdater(_contextFactory, _mapper); await updater.UpdateRepositories(eventDate, new[] { payload.Repository }); await updater.UpdatePullRequests(payload.Repository.Id, eventDate, new[] { payload.PullRequest }); switch (payload.Action) { case "created": // We need the issueId // TODO: Modify BulkUpdate to work with PR/Issue Number instead? long?issueId; using (var context = _contextFactory.CreateInstance()) { issueId = await context.Issues .AsNoTracking() .Where(x => x.RepositoryId == payload.Repository.Id && x.Number == payload.PullRequest.Number) .Select(x => (long?)x.Id) .SingleOrDefaultAsync(); } if (issueId != null) { await updater.UpdatePullRequestComments(payload.Repository.Id, issueId.Value, eventDate, new[] { payload.Comment }, dropWithMissingReview : true); } break; case "edited": // GitHub doesn't send the new comment body. We have to look it up ourselves. var repoActor = _grainFactory.GetGrain <IRepositoryActor>(payload.Repository.Id); await repoActor.RefreshPullRequestReviewComment(payload.Comment.Id); break; case "deleted": await updater.DeletePullRequestComment(payload.Comment.Id, null); break; default: throw new NotImplementedException($"Action '{payload.Action}' is not valid for event {nameof(PullRequestReviewComment)}."); } await updater.Changes.Submit(_queueClient); }
private async Task UpdateAdmins(DataUpdater updater, IGitHubPoolable github) { if (_adminMetadata.IsExpired()) { var admins = await github.OrganizationMembers(_login, role : "admin", cacheOptions : _adminMetadata); if (admins.IsOk) { await updater.SetOrganizationAdmins(_orgId, admins.Date, admins.Result); } else if (!admins.Succeeded) { throw new Exception($"Unexpected response: [{admins?.Request?.Uri}] {admins?.Status}"); } _adminMetadata = GitHubMetadata.FromResponse(admins); } }
public async void DeliverOrder(OrderBill order) { //TEST INTERNET CONNECTTION var httpClient = new HttpClient(); string x = ""; try { var testInternet = await httpClient.GetStringAsync(ServerDatabase.localhost + "store/getstorebyid/test"); x = testInternet; } catch (Exception ex) { await App.Current.MainPage.DisplayAlert("Error", "Action fail, check your internet connection and try again!", "OK"); return; } using (UserDialogs.Instance.Loading("Delivering order")) { order.State = OrderState.Delivering; //Update database local DataUpdater.UpdateStateOrderbill(order); //Reload views foreach (OrderBill orderItem in Orders) { if (orderItem.IDOrderBill == order.IDOrderBill) { orderItem.State = OrderState.Delivering; break; } } LoadKindsOfOrders(); //api update database server await httpClient.PostAsJsonAsync(ServerDatabase.localhost + "orderbill/update", order); } MessageService.Show("Delivered order successfully", 0); //PUSH NOTI string datas = PushNotificationService.ConvertDataDeliverOrder(order); PushNotificationService.Push(NotiNumber.DeliverOrderForCustomer, datas, false); PushNotificationService.Push(NotiNumber.DeliverOrderForOther, datas, true); }
void Awake() { ChangeLanguageBySystemLanguage(); if (dataSet == null) { var formatter = new BinaryFormatter(); DataUpdater.DeleteAllCaches(); using (var s = DataUpdater.GetBuiltInBalloonDataStream()) { dataSet = (DataSet)formatter.Deserialize(s); s.Close(); } PrebuildDependentDataSet(dataSet); } }
public async void Delete(BanKiemKe deletedBKK) { //Update data ở LocalData DataUpdater.RemoveKiemKeByBKK(deletedBKK); // Update data ở UI LoadData(); //Update data xuống file DataUpdater.UpdateDataToFile(); DependencyService.Get <IMessage>().Shorttime("Xóa thành công"); //Nếu không còn item nào thì thoát if (BanKiemKes.Count == 0) { await App.Current.MainPage.Navigation.PopAsync(); } }
private async Task UpdateDetails(DataUpdater updater, IGitHubPoolable github) { if (_metadata.IsExpired()) { var org = await github.Organization(_orgId, _metadata); if (org.IsOk) { await updater.UpdateAccounts(org.Date, new[] { org.Result }); // Update login For the rest of sync. _login = org.Result.Login; // Safest to just start over. DeactivateOnIdle(); } _metadata = GitHubMetadata.FromResponse(org); } }
public async void RestoreProduct(ProductItem productItem) { Product restoredProduct = null; using (UserDialogs.Instance.Loading("Restoring..")) { restoredProduct = DataUpdater.RestoreProductInStore(productItem.Product); //update product ở database server await httpClient.PostAsJsonAsync(ServerDatabase.localhost + "product/update", restoredProduct); LoadProducts(false); } MessageService.Show("Restore product successfully", 0); //PUSH NOTI string datas = PushNotificationService.ConvertDataUpdateProduct(restoredProduct); PushNotificationService.Push(NotiNumber.UpdateProduct, datas, true); }
public async Task InternalSync() { // It's gross that this exists. oh well. var metaDataMeaningfullyChanged = false; var updater = new DataUpdater(_contextFactory, _mapper); try { metaDataMeaningfullyChanged = await InternalSync(updater); } catch (GitHubRateException) { // nothing to do } await updater.Changes.Submit(_queueClient, urgent : true); // Save changes if (metaDataMeaningfullyChanged) { await Save(); } }
public static void ReturnProductCartAction(string data) { List <Product> products = JsonConvert.DeserializeObject <List <Product> >(data); DataUpdater.UpdateProduct(products[0]); products.RemoveAt(0); DataUpdater.DeleteProducts(products); //Load lại data cho các user đang ở trong cửa hàng đó var ShowStoreVM = ShowStoreView.GetInstance().BindingContext as ShowStoreViewModel; if (ShowStoreVM != null && ShowStoreVM.IDStore == products[0].IDStore) { ShowStoreVM.LoadData(true); } //Load lại list product cho cửa hàng đó if (products[0].IDStore == Infor.IDStore) { (TabbarStoreManager.GetInstance().Children.ElementAt(1).BindingContext as ProductManagerViewModel).LoadData(true); } }
public async void SendReview() { //TEST INTERNET CONNECTTION var httpClient = new HttpClient(); string x = ""; try { var testInternet = await httpClient.GetStringAsync(ServerDatabase.localhost + "store/getstorebyid/test"); x = testInternet; } catch (Exception ex) { await App.Current.MainPage.DisplayAlert("Error", "Action fail, check your internet connection and try again!", "OK"); return; } using (UserDialogs.Instance.Loading("Receiving order")) { order.Rating = GetRating(); order.Review = Review; DataUpdater.ReceiveOder(order); order.State = OrderState.Received; //call api update orderbill await httpClient.PostAsJsonAsync(ServerDatabase.localhost + "orderbill/update", order); //reload list orders view (TabBarCustomer.GetInstance().Children.ElementAt(3).BindingContext as ListOrdersViewModel).LoadData(); await PopupNavigation.Instance.PopAllAsync(); } MessageService.Show("Received successfully", 0); //PUSH NOTI string datas = PushNotificationService.ConvertDataReceiveOrder(order); PushNotificationService.Push(NotiNumber.ReceiveOrderForStore, datas, false); PushNotificationService.Push(NotiNumber.ReceiveOrderForOther, datas, true); }
private void InitializeUpdatableStuff() { DataUpdater.Initialize(); DataUpdater.Instance.Updated += OnDataUpdated; if (AcRootDirectory.Instance.IsFirstRun) { AppUpdater.OnFirstRun(); } AppUpdater.Initialize(); AppUpdater.Instance.Updated += OnAppUpdated; if (LocaleHelper.JustUpdated) { Toast.Show(AppStrings.App_LocaleUpdated, string.Format(AppStrings.App_DataUpdated_Details, LocaleHelper.LoadedVersion)); } LocaleUpdater.Initialize(LocaleHelper.LoadedVersion); LocaleUpdater.Instance.Updated += OnLocaleUpdated; }
public async Task Status(DateTimeOffset eventDate, StatusPayload payload) { var updater = new DataUpdater(_contextFactory, _mapper); await updater.UpdateRepositories(eventDate, new[] { payload.Repository }); // Since we only do this here there's no need to add a mapping var status = new CommitStatus() { Context = payload.Context, CreatedAt = payload.CreatedAt, Description = payload.Description, Id = payload.Id, State = payload.State, TargetUrl = payload.TargetUrl, UpdatedAt = payload.UpdatedAt, }; await updater.UpdateCommitStatuses(payload.Repository.Id, payload.Sha, new[] { status }); await updater.Changes.Submit(_queueClient); }
private void UpdateDataFromOptions(Updater updater, DataTable table, AuthenticationService.User user) { DataUpdater update = new DataUpdater(); if (updater.UpdaterOption == UpdaterOptions.UpdateSummary) { update.UpdateSummary(table, user.UserName); } else if (updater.UpdaterOption == UpdaterOptions.UpdateAccountables) { update.UpdateAccountables(table, user.UserName); } else if (updater.UpdaterOption == UpdaterOptions.UpdateProjects) { update.UpdateProjects(table, user.UserName); } else if (updater.UpdaterOption == UpdaterOptions.UpdateItems) { update.UpdateItems(table, user.UserName); } }
protected override async void OnAppearing() { UserDialogs.Instance.ShowLoading(""); var preferences = TinyIoCContainer.Current.Resolve <IPreferences>(); await DataUpdater.UpdateDataIfNeeded(DependencyService.Get <IFileAccess>(), preferences); await RefreshData(); UserDialogs.Instance.HideLoading(); int row = 0, col = 0; int maxCol = grid.ColumnDefinitions.Count; grid.Children.Clear(); foreach (var busService in _viewModel.Routes) { var item = new RouteView(busService); item.OnServiceClicked += OnBusServiceSelected; grid.Children.Add(item, col, row); col++; row = col == maxCol ? row + 1 : row; col %= maxCol; } if (DateTime.TryParse(preferences.Get("rate_popup_last_shown", DateTime.MinValue.ToString()), out var ratePopupLastShown)) { if (!preferences.IsFirstLaunch && preferences.Get("rated", "0") != "1" && (DateTime.Today - ratePopupLastShown).TotalDays >= 5) { await Navigation.PushPopupAsync(new RatePopup(preferences)); } } else { preferences.Set("rate_popup_last_shown", DateTime.Today.ToString()); } await FavoritesView.RefreshView(); base.OnAppearing(); }
public async void Reset() { if (!CheckValidNewPassword()) { return; } ShowError = false; user.Password = MD5Service.EncodeToMD5(NewPassword); try { using (UserDialogs.Instance.Loading("Reseting..")) { //update user ở database server var httpClient = new HttpClient(); await httpClient.PostAsJsonAsync(ServerDatabase.localhost + "user/update", user); //update user ở database local DataUpdater.UpdateUser(user); } } catch { await App.Current.MainPage.DisplayAlert("Error", "Action fail, check your internet connection and try again!", "OK"); return; } MessageService.Show("Update infor successfully", 0); //PUSH NOTI string datas = PushNotificationService.ConvertDataUpdateUser(user); PushNotificationService.Push(NotiNumber.UpdateUser, datas, true); await App.Current.MainPage.Navigation.PopToRootAsync(); }
protected int Add <U>(DataUpdater <U> inserter, U value, int index = -1) { bool reused; if (index == -1) { index = indices.AssignNextFreeIndex(out reused); } else { reused = indices.AssignIndex(index); } if (buffer == null) { buffer = new T[128]; inserter(buffer, 0, value); Size += Dimension; changedSinceLastCreation = true; } else { buffer = EnsureBufferSize(buffer, (index + 1) * Dimension, out bool changed); if (!reused) { Size += Dimension; changed = true; } int bufferIndex = index * Dimension; if (inserter(buffer, bufferIndex, value) || changed) { changedSinceLastCreation = true; } } return(index); }
public async void CancelOrder(OrderBill orderBill) { using (UserDialogs.Instance.Loading("Canceling order")) { var httpClient = new HttpClient(); List <Product> productInOrder = dataProvider.GetProductsInBillByIDBill(orderBill.IDOrderBill); //update quantityinventory ở local List <Product> sourceProducts = DataUpdater.ReturnListProductToSource(productInOrder); //api update quantityinventory ở server foreach (Product product in sourceProducts) { await httpClient.PostAsJsonAsync(ServerDatabase.localhost + "product/update", product); } //api delete products trong order bị xóa (ở server) await httpClient.PostAsJsonAsync(ServerDatabase.localhost + "product/deletebyidorderbill/" + orderBill.IDOrderBill, new { }); //delete product ở local DataUpdater.DeleteProducts(productInOrder); //delete orderbill server await httpClient.PostAsJsonAsync(ServerDatabase.localhost + "orderbill/deleteorderbillbyid/" + orderBill.IDOrderBill, new { }); //delete orderbill local DataUpdater.DeleteOrderBillByID(orderBill.IDOrderBill); //Reload data OrderManager LoadData(); //Reload data ProductManager (TabbarStoreManager.GetInstance().Children.ElementAt(1).BindingContext as ProductManagerViewModel).LoadData(true); } MessageService.Show("Cancel order successfully", 0); //PUSH NOTI string datas = PushNotificationService.ConvertDataCancelOrder(orderBill); PushNotificationService.Push(NotiNumber.CancelOrderForCustomer, datas, false); PushNotificationService.Push(NotiNumber.CancelOrderForOther, datas, true); }
protected override void OnStartup(StartupEventArgs e) { WpfSingleInstance.Make(); base.OnStartup(e); InitializeOffline(); dataUpdater = new DataUpdater(new ProjectRepository(), new ActivityRepository(), queueManager.ConnectionMonitor, new Base64EncryptorEx()); dataUpdater.ShowError += ShowError; if (dataUpdater.IsConnected) { dataUpdater.Update(); dataUpdater.StartTimer(); } MainWindow = new MainWindow(); SetWindowSettings(); MainWindow.ShowDialog(); }
public async void UpdateProduct(Product updatedProduct) { foreach (ProductItem item in _saveProducts) { if (item.Product.IDProduct == updatedProduct.IDProduct) { item.Product = updatedProduct; break; } } //Update database local DataUpdater.UpdateProduct(updatedProduct); //Update database server await httpClient.PostAsJsonAsync(ServerDatabase.localhost + "product/update", updatedProduct); LoadProducts(false); //PUSH NOTI string datas = PushNotificationService.ConvertDataUpdateProduct(updatedProduct); PushNotificationService.Push(NotiNumber.UpdateProduct, datas, true); }
public TestContext() { DataClient = new MockRedisClientWrapper (); Settings = new DataManagerSettings (); Settings.IsVerbose = true; Keys = new DataKeys (Settings); IdManager = new DataIdManager (Keys, DataClient); TypeManager = new DataTypeManager (Keys, DataClient); EntityLinker = new EntityLinker (); var preparer = new DataPreparer (DataClient); Preparer = preparer; var reader = new DataReader (TypeManager, IdManager, Keys, DataClient); Reader = reader; var checker = new DataChecker (reader, Settings); Checker = checker; var saver = new DataSaver (Settings, TypeManager, IdManager, Keys, preparer, null, checker, DataClient); // The linker argument is null because it needs to be set after it's created below Saver = saver; var updater = new DataUpdater (Settings, Keys, null, preparer, checker, DataClient); // The linker argument is null because it needs to be set after it's created below Updater = updater; var linker = new DataLinker (Settings, reader, saver, updater, checker, EntityLinker); Linker = linker; // TODO: Is there a way to avoid this messy hack? // Make sure the linker is set to the saver and updater saver.Linker = linker; updater.Linker = linker; }
public async Task <HttpResponseMessage> PullRequestReviewCommentEdit(HttpRequestMessage request, CancellationToken cancellationToken, long commentId) { // https://developer.github.com/v3/pulls/comments/#edit-a-comment var response = await ProxyRequest(request, cancellationToken); if (response.IsSuccessStatusCode) { var user = RequestContext.Principal as ShipHubPrincipal; try { await response.Content.LoadIntoBufferAsync(); var comment = await response.Content.ReadAsAsync <PullRequestComment>(GitHubSerialization.MediaTypeFormatters, cancellationToken); using (var context = new dm.ShipHubContext()) { var updater = new DataUpdater(context, _mapper); var ids = await context.PullRequestComments .AsNoTracking() .Where(x => x.Id == commentId) .Select(x => new { IssueId = x.IssueId, RepositoryId = x.RepositoryId }) .SingleOrDefaultAsync(); if (ids != null) { await updater.UpdatePullRequestComments(ids.RepositoryId, ids.IssueId, response.Headers.Date ?? DateTimeOffset.UtcNow, new[] { comment }); await updater.Changes.Submit(_queueClient); } } } catch (Exception e) { // swallow db exceptions, since if we're here github has created the resource. // we'll probably get it fixed in our db sooner or later, but for now we need to give the client its data. e.Report($"request: {request.RequestUri} response: {response} user: {user.DebugIdentifier}", user.DebugIdentifier); } } return(response); }
private async Task SyncIssueTimeline(IGitHubActor ghc, long forUserId, DataUpdater updater) { // Always refresh the issue when viewed await UpdateIssueDetails(ghc, updater); ISet <long> issueCommentIds; ISet <long> commitCommentIds; ISet <long> prCommentIds = null; // If it's a PR we need that data too. if (_isPullRequest) { await UpdatePullRequestDetails(ghc, forUserId, updater); // Reviews have to come before comments, since PR comments reference reviews await UpdatePullRequestReviews(ghc, forUserId, updater); prCommentIds = await UpdatePullRequestComments(ghc, updater); await UpdatePullRequestCommitStatuses(ghc, updater); } // This does many things, including retrieving referenced comments, commits, etc. (issueCommentIds, commitCommentIds) = await UpdateIssueTimeline(ghc, forUserId, updater); // So many reactions await UpdateIssueReactions(ghc, updater); await UpdateIssueCommentReactions(ghc, updater, issueCommentIds); await UpdateCommitCommentReactions(ghc, updater, commitCommentIds); if (_isPullRequest) { // Can't roll this up into other PR code because it must come after timeline await UpdatePullRequestCommentReactions(ghc, updater, prCommentIds); } }
internal SessionStateUpdater(DataUpdater updater) : base(updater) { }
internal UpdaterModule(DataUpdater updater) { Updater = updater; }
internal SessionInfoParser(DataUpdater updater) { _updater = updater; }
private async void Confirm_Clicked(object sender, EventArgs e) { var httpClient = new HttpClient(); using (Acr.UserDialogs.UserDialogs.Instance.Loading("Updating..")) { if (AppValue.KKType == 1) //ONLINE { BanKiemKe banKiemKe = AppValue.banKiemKe; try { HttpResponseMessage response; if (!string.IsNullOrEmpty(thietBi.TB_ID)) { response = await httpClient.PostAsJsonAsync(Definitions.Localhost + "api/ChiTietBanKiemKe/CTBKK_XacNhanKK?dv_QL=" + banKiemKe.KK_MADONVI + "&bkk_ID=" + banKiemKe.KK_CODE + "&ngay_TAO=" + banKiemKe.KK_NGAYTAO.ToString("yyyy-MM-dd") + "&ma_TB=" + this.thietBi.TB_ID + "&tt_SAU=" + State_Picker.SelectedItem.ToString(), new { }); } else { response = await httpClient.PostAsJsonAsync(Definitions.Localhost + "api/ChiTietBanKiemKe/CTBKK_XacNhanKK_Ten?dv_QL=" + banKiemKe.KK_MADONVI + "&bkk_ID=" + banKiemKe.KK_CODE + "&ngay_TAO=" + banKiemKe.KK_NGAYTAO.ToString("yyyy-MM-dd") + "&ten_TB=" + this.thietBi.TB_TEN + "&tt_SAU=" + State_Picker.SelectedItem.ToString(), new { }); } var content = await response.Content.ReadAsStringAsync(); JObject rss = JObject.Parse(content); var resultAPI = rss["result"]; string validStr = (resultAPI as JArray).First["result"].ToString(); if (validStr == "Lỗi" || validStr == "Bản kiểm kê ko tồn tại") { await DisplayAlert("Lỗi", "Kiểm kê thất bại, kiểm tra lại thông tin kiểm kê!", "OK"); return; } } catch { await DisplayAlert("Lỗi", "Kết nối server bị lỗi, kiểm tra lại đường dẫn!", "OK"); return; } } else //OFFLINE { using (UserDialogs.Instance.Loading("Updating..")) { //tạo record mới ChiTietBanKiemKe chiTietBanKiemKe = new ChiTietBanKiemKe { CTBKK_MA_TB = thietBi.TB_ID, CTBKK_TEN_TB = thietBi.TB_TEN, CTBKK_TT_SAU = State_Picker.SelectedItem.ToString(), CTBKK_THOI_GIAN = DateTime.Now }; //thêm record vào list (trên source) appvalue DataUpdater.AddNewRecordToKiemKe(chiTietBanKiemKe); //update record vào LocalData(trên source) DataUpdater.UpdateKiemKeInLocalData(); //update data xuống file DataUpdater.UpdateDataToFile(); } } var scanPage = ScannerView.GetInstance(); scanPage.popupIsOpen = false; await App.Current.MainPage.Navigation.PopAsync(); } var message = "Kiểm kê thành công"; DependencyService.Get <IMessage>().Shorttime(message); }
internal SessionTimeUpdater(DataUpdater updater) : base(updater) { }
internal RadioUpdater(DataUpdater updater) : base(updater) { }
public MockDataLinker(DataManagerSettings settings, DataReader reader, DataSaver saver, DataUpdater updater, DataChecker checker, EntityLinker entityLinker) : base(settings, reader, saver, updater, checker, entityLinker) { }