private async Task SyncData() { var result = Base.ShowDialog(MessageBoxButtons.YesNo, "Data Download", "Do you want to proceed with data download?"); if (result == DialogResult.Yes) { if (GetRemoteServerConnectionState()) { var syncRepo = new SyncRepo(); var s = await syncRepo.SyncAllData(); if (s == string.Empty) { Base.ShowSuccess("Success", "Data synchronization successful"); } else { Base.ShowError("Error", s); } } else { Base.ShowError("Connection Failed", "Cannot connect to the remote server. Check your connection settings"); var frm = new FrmConnection(); frm.ShowDialog(); } } }
private void btnSave_Click(object sender, EventArgs e) { var validate = ValidateForm(); if (validate == string.Empty) { // var saveItem = Helper.SaveConnectionStringInSettings(txtServer.Text.Trim(), txtUsername.Text.Trim(), txtPassword.Text.Trim()); var saveItem = _repo.SaveConnectionString(txtServer.Text.Trim(), Helper.DatabaseName, txtUsername.Text.Trim(), txtPassword.Text.Trim()); if (saveItem == string.Empty) { var saveRemote = new SyncRepo().UploadConnectionStringToRemote(); if (saveRemote == string.Empty) { Base.ShowSuccess("Success", "Connection String saved successfully"); this.Close(); } else { Base.ShowError("Failed", saveRemote); } } else { Base.ShowError("Failed", "An error occured"); } } else { Base.ShowInfo("Validation Failed", validate); } }
private async void btnReport_Click(object sender, EventArgs e) { if (GetRemoteServerConnectionState()) { Helper.MigrateAndSeedRemoteDb(); // var syncRepo = new SyncRepo(); var s = await syncRepo.UploadAttendanceToRemote(); if (s == string.Empty) { syncRepo.SaveSync(new AppSync { Id = Guid.NewGuid().ToString(), StaffId = LoggedInUser.UserId, SystemId = Helper.GetMacAddress(), SyncDate = DateTime.Now }); ShowPage(new PgReport()); SetActiveMenu(btnReport); } else { Base.ShowError("Error", s); } } else { Base.ShowError("Connection Failed", "You can only view reports from the remote server. Check your connection settings"); } }
private async void FrmLogin_KeyDown(object sender, KeyEventArgs e) { //if (e.KeyCode == Keys.CapsLock) //{ // txtPassword //} // if (e.Modifiers == Keys.Control && e.KeyCode == Keys.Alt && e.KeyCode == Keys.D) if (e.Control && e.Alt && e.KeyCode == Keys.D) { var result = Base.ShowDialog(MessageBoxButtons.YesNo, "Data Download", "Do you want to proceed with data download?"); if (result == DialogResult.Yes) { if (Helper.CheckRemoteServerConnection()) { Helper.MigrateAndSeedRemoteDb(); //seed remote if there's no data var syncRepo = new SyncRepo(); var s = await syncRepo.SyncAllData(); if (s == string.Empty) { Base.ShowSuccess("Success", "Data synchronization successful"); } else { Base.ShowError("Error", s); } } else { Base.ShowError("Connection Failed", "Cannot connect to the remote server. Check your connection settings"); var frm = new FrmConnection(); frm.BringToFront(); frm.ShowDialog(); } } } if (e.Control && e.Alt && e.KeyCode == Keys.O) //open connection string { var frm = new FrmConnection(); frm.BringToFront(); frm.ShowDialog(); GetRemoteServerConnectionState(); } }