private void button1_Click(object sender, RoutedEventArgs e) { if (txtemail.Text.Trim() != "" && txtname.Text.Trim() != "" && txtpassword.Password.Trim() != "") { string emailId = txtemail.Text.Trim().ToLower(); if (emailId == null || !EmailValidator.Validate(emailId)) { txtemail.Background = Colors.errorBackGround; txtemail.Foreground = Colors.errorForeGround; return; } string name = txtname.Text.Trim(); string password = txtpassword.Password.Trim(); try { AWSConnectionService db = AWSConnectionService.getInstance(); db.createRegistrationTableIfNotExists(); db.insertIntoRegistrationTableIfNotExist(emailId, password, name); new Login().Show(); this.Hide(); Console.WriteLine("To continue, press Enter"); Console.ReadLine(); } catch (AmazonDynamoDBException ex) { Console.WriteLine(ex.Message); } catch (AmazonServiceException ex) { Console.WriteLine(ex.Message); } } else { MessageBox.Show("Please fill all details"); } }
private void LoadList(string email) { AWSConnectionService db = AWSConnectionService.getInstance(); var files = db.ListPDFFilesforUser(email); Console.WriteLine("\nPrinting result....."); var gridView = new GridView(); this.listViewFiles.View = gridView; gridView.Columns.Add(new GridViewColumn { Header = "Book", DisplayMemberBinding = new Binding("KeyName") }); gridView.Columns.Add(new GridViewColumn { Header = "GeneratedKeyName", DisplayMemberBinding = new Binding("GeneratedKeyName") }); gridView.Columns.Add(new GridViewColumn { Header = "CurrentPageNumber", DisplayMemberBinding = new Binding("CurrentPageNumber") }); gridView.Columns.Add(new GridViewColumn { Header = "EmailId", DisplayMemberBinding = new Binding("EmailId") }); gridView.Columns[0].Width = 400; gridView.Columns[1].Width = 0; gridView.Columns[2].Width = 0; gridView.Columns[3].Width = 0; var dict = new Dictionary <FileModel, DateTime>(); foreach (var file in files) { listViewFiles.Items.Add(file); dict.Add(file, file.LastAccessedTime); } //using linq to find the latest accessed book try { dict.Values.Max(); var keyOfMaxValue = dict.Aggregate((x, y) => x.Value > y.Value ? x : y).Key; lblLatestBook.Text = keyOfMaxValue.KeyName; } catch (InvalidOperationException) { lblLatestBook.Text = "No books, recent books will appear here.."; } }
public void bookmark(int pagenumber) { AWSConnectionService instance = AWSConnectionService.getInstance(); AmazonDynamoDBClient client = new AmazonDynamoDBClient(instance.credentials, AWSConnectionService.dynamoDbRegion); DynamoDBContext context = new DynamoDBContext(client); FileModel pdfRecordRetrived = context.Load <FileModel>(emailId, key); Trace.WriteLine(pdfRecordRetrived.ToString()); pdfRecordRetrived.CurrentPageNumber = pagenumber; context.Save <FileModel>(pdfRecordRetrived); }
private void BtnUploadConfirmOnClick(object sender, RoutedEventArgs e) { try { if (filePath != null || filePath.Trim() != "") { AWSConnectionService.getInstance().insertIntoFileTableAndUpload(useremailId, AWSConnectionService.s3StorageBucketRegion, AWSConnectionService.s3StorageBucketName, filePath); } System.Threading.Thread.Sleep(2000); } catch (NullReferenceException) { MessageBox.Show("No file selected"); } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } }
void ListView_MouseDoubleClick(object sender, MouseButtonEventArgs e) { FileModel item = (FileModel)((FrameworkElement)e.OriginalSource).DataContext; if (item != null) { //MessageBox.Show("Item's Double Click handled!" + item.GKey); //new S3Service(AWSConnectionService.s3StorageBucketRegion, AWSConnectionService.s3StorageBucketName, item.GKey, null).downloadPDF(item.KeyName, item.GKey); string downloadPath = new S3Service(AWSConnectionService.s3StorageBucketRegion, AWSConnectionService.s3StorageBucketName, item.GeneratedKeyName, null).Download_FileAsync(useremailId); ViewBook viewBook = new ViewBook(downloadPath, item); AWSConnectionService instance = AWSConnectionService.getInstance(); AmazonDynamoDBClient client = new AmazonDynamoDBClient(instance.credentials, AWSConnectionService.dynamoDbRegion); DynamoDBContext context = new DynamoDBContext(client); FileModel pdfRecordRetrived = context.Load <FileModel>(item.EmailId, item.KeyName); Trace.WriteLine(pdfRecordRetrived.ToString()); pdfRecordRetrived.LastAccessedTime = DateTime.Now; context.Save <FileModel>(pdfRecordRetrived); viewBook.Show(); this.Hide(); } }
private void button1_Click(object sender, RoutedEventArgs e) { string emailId = txtemail.Text.ToLower(); if (emailId == null || !EmailValidator.Validate(emailId)) { txtemail.Background = _300983145_Sruthi__Lab2.Colors.errorBackGround; txtemail.Foreground = Colors.errorForeGround; return; } string password = txtpassword.Password; AWSConnectionService db = AWSConnectionService.getInstance(); try { bool loginsuccess = db.loginIntoApplication(emailId, password); if (loginsuccess) { db.createBucket(); db.createFileTableIfNotExists(AWSConnectionService.fileTableName); instance = new Welcome(emailId); instance.Show(); this.Hide(); } else { MessageBox.Show(this, "Login Failed", "Incorrect Email or Password"); } } catch (ResourceNotFoundException) { MessageBox.Show("Account doesn't exist"); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }