private bool fetchCase() { bool result = false; txtZaaknaam.Text = string.Empty; txtZaakEigenaar.Text = string.Empty; dpCase.DisplayDate = DateTime.MinValue; dpCase.Text = DateTime.MinValue.ToString(); if (CasesDB.Exists(txtZaaknummer.Text)) { Case = CasesDB.GetCase(txtZaaknummer.Text); txtZaaknaam.Text = Case.Name; txtZaakEigenaar.Text = Case.Owner; dpCase.DisplayDate = Case.Date; dpCase.Text = Case.Date.ToString(); btnNext.IsEnabled = true; result = true; } else { Case = null; btnNext.IsEnabled = false; result = false; MessageBox.Show($"Zaak {txtZaaknummer.Text} niet gevonden", "Niet gevonden", MessageBoxButton.OK, MessageBoxImage.Exclamation); } return(result); }
public PageSelectFiles(CaseInfo theCase) { InitializeComponent(); this.Case = theCase; //fileSelection = new ObservableCollection<FileSelection>(this.Case.Files); dgSelectedFiles.ItemsSource = this.Case.Files; }
//public static void AddTransferedFilesToCaseDB(CaseInfo theCase) //{ // foreach (var fileSelection in theCase.Files) // { // if (fileSelection.State == Util.FileState.TRANSFERRED) // { // AddTransferredFileToCaseDB(fileSelection, theCase); // } // } //} public static CaseInfo GetCase(string caseNumber) { string qry = $"SELECT Number, Name, Owner, Date FROM {TABLE_CASE} WHERE Number = '{caseNumber}'"; CaseInfo retVal; using (SQLiteConnection connection = new SQLiteConnection(ConnectionString)) { connection.Open(); SQLiteCommand command = new SQLiteCommand(qry, connection); SQLiteDataReader reader = command.ExecuteReader(); if (reader.Read()) { retVal = new CaseInfo() { Number = reader["Number"] as string, Name = reader["Name"] as string, Owner = reader["Owner"] as string, Date = DateTime.Parse(reader["Date"] as string), IsNew = false, }; } else { retVal = null; } reader.Close(); connection.Close(); } return(retVal); }
public PageSummaryBefore(CaseInfo theCase) { InitializeComponent(); this.Case = theCase; populateFields(); }
public static CaseInfo GetCase(string caseNumber) { //string qry = $"SELECT number, name, owner, create_date, last_modify_date FROM {TABLE_CASE} WHERE number = '{MySqlHelper.EscapeString(caseNumber)}'"; CaseInfo retVal; string prc = "prc_case_get"; MySqlCommand cmd = new MySqlCommand(prc, connection) { CommandType = CommandType.StoredProcedure, }; cmd.Parameters.AddWithValue("@number", caseNumber); MySqlDataReader reader = cmd.ExecuteReader(); if (reader.Read()) { retVal = new CaseInfo() { Number = reader[0] as string, Name = reader[1] as string, Owner = reader[2] as string, Date = (DateTime)reader[3], IsNew = false, }; } else { retVal = null; } reader.Close(); return(retVal); }
private void doTransfer(object sender, DoWorkEventArgs e) { BackgroundWorker worker = sender as BackgroundWorker; CaseInfo workerCase = (CaseInfo)e.Argument; Util.CreateDirectory(workerCase.CaseDirectory); Util.ProgressInfo pi = new Util.ProgressInfo(); List <Util.FileSelection> transferList = new List <Util.FileSelection>(); // DEBUG //System.Threading.Thread.Sleep(60000); foreach (Util.FileSelection fileSelection in workerCase.Files) { if (worker.CancellationPending) { e.Cancel = true; break; } pi.CurrentFileSrc = fileSelection.Path; pi.CurrentFileDst = Case.CaseDirectory; worker.ReportProgress(Util.ProgressInfo.PercentageDone, pi); bool copyResult = false; switch (fileSelection.Type) { case Util.FileSelectionType.DIRECTORY: List <Util.FileSelection> fileList = Util.DirectoryCopy(fileSelection.Path, Case.CaseDirectory, recursive: true, overwrite: Case.OverwriteExistingFiles); lock (pi.TransferredFiles) { pi.TransferredFiles = fileList; } transferList.AddRange(fileList); break; case Util.FileSelectionType.FILE: Util.FileSelection file = Util.FileCopy(fileSelection.Path, Case.CaseDirectory, overwrite: Case.OverwriteExistingFiles); lock (pi.TransferredFiles) { pi.TransferredFiles = new List <Util.FileSelection>(1); pi.TransferredFiles.Add(file); } transferList.Add(file); break; } fileSelection.State = Util.FileState.TRANSFERRED; } pi.TransferredFiles = transferList; e.Result = pi; }
public static void ModifyCase(CaseInfo theCase) { string prc = "prc_case_modify"; MySqlCommand cmd = new MySqlCommand(prc, connection) { CommandType = CommandType.StoredProcedure, }; cmd.Parameters.AddWithValue("@number", theCase.Number); cmd.Parameters.AddWithValue("@name", theCase.Name); cmd.Parameters.AddWithValue("@owner", theCase.Owner); cmd.Parameters.AddWithValue("@create_date", theCase.Date); cmd.ExecuteNonQuery(); }
public static void ModifyCase(CaseInfo theCase) { string qry = $"UPDATE {TABLE_CASE} SET Number = '{theCase.Number}', Name='{theCase.Name}', Owner='{theCase.Owner}', Date='{theCase.Date.ToString(DATE_FORMAT)}' WHERE Number='{theCase.Number}'"; using (SQLiteConnection connection = new SQLiteConnection(ConnectionString)) { SQLiteCommand command = new SQLiteCommand(qry, connection); connection.Open(); command.ExecuteNonQuery(); connection.Close(); } }
public static void AddCase(CaseInfo theCase) { string qry = $"INSERT INTO {TABLE_CASE}(Number, Name, Owner, Date) VALUES('{theCase.Number}','{theCase.Name}', '{theCase.Owner}', '{theCase.Date.ToString(DATE_FORMAT)}')"; using (SQLiteConnection connection = new SQLiteConnection(ConnectionString)) { connection.Open(); SQLiteCommand command = new SQLiteCommand(qry, connection); command.ExecuteNonQuery(); connection.Close(); } }
public PageTransfer(CaseInfo theCase) { InitializeComponent(); Case = theCase; bgWorker.WorkerReportsProgress = true; bgWorker.WorkerSupportsCancellation = true; bgWorker.DoWork += doTransfer; bgWorker.ProgressChanged += transfer_ProgressChanged; bgWorker.RunWorkerCompleted += transfer_Completed; // update progressbar thread --> timer.Interval = new TimeSpan(0, 0, 1); timer.Tick += Timer_Tick; timer.Start(); }
CaseInfo fetchAndValidateInput() { CaseInfo result = null; string validateResult = validate(); if (validateResult != string.Empty) { string[] errors = validateResult.Split('|'); string errMessage = string.Empty; foreach (var error in errors) { switch (error) { case "": break; case "DPCASEDATE": errMessage += "Kies een datum\r\n"; break; case "TXTZAAKNUMMER": errMessage += "Vul zaaknummer in\r\n"; break; case "TXTZAAKNAAM": errMessage += "Vul zaaknaam in\r\n"; break; case "TXTZAAKEIGENAAR": errMessage += "Vul zaak eigenaar in\r\n"; break; } } MessageBox.Show(errMessage, "Corrigeer Fout(en)", MessageBoxButton.OK, MessageBoxImage.Error); } else { result = new CaseInfo(); result.Name = txtZaaknaam.Text; result.Number = txtZaaknummer.Text; result.Owner = txtZaakEigenaar.Text; result.Date = dpCase.SelectedDate.Value; } return(result); }
private void btnNext_OnClick(object sender, RoutedEventArgs e) { //if (Case == null) //{ // if (MessageBox.Show("Zaak details ophalen?", "Ophalen gegevens", MessageBoxButton.YesNo, // MessageBoxImage.Question) == MessageBoxResult.Yes) // { // fetchCase(); // } // else // { // return; // } //} bool caseDatabaseRowExists = CasesDB.Exists(Case.Number); bool caseDirectoryExists = Util.DirectoryExistst(Case.CaseDirectory); if (caseDirectoryExists && caseDatabaseRowExists) { Case = CasesDB.GetCase(Case.Number); PageSelectFiles pageSelectFiles = new PageSelectFiles(Case); this.NavigationService.Navigate(pageSelectFiles); } else if (caseDirectoryExists && !caseDatabaseRowExists) { MessageBox.Show("Zaak bestaat op opslag maar niet in database. Waarschuw beheerder", "Inconsistentie gedetecteerd", MessageBoxButton.YesNo, MessageBoxImage.Warning); } else if (caseDatabaseRowExists && !caseDirectoryExists) { MessageBox.Show("Zaak bestaat in database maar niet in opslag. Waarschuw beheerder", "Inconsistentie gedetecteerd", MessageBoxButton.YesNo, MessageBoxImage.Warning); } else { if (MessageBox.Show("Zaak niet gevonden. Nieuwe zaak toevoegen in plaats van bestaande wijzigen?", "Zaak niet gevonden", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) { NavigationService.Navigate(new PageNewData()); } } }
public static void WriteCaseFileToOutput(CaseInfo theCase) { string p = theCase.CaseDirectory; string filename = $"_zaak_overzicht_{DateTime.Now.ToString("yyyy-MM-ddTHHmmss")}.txt"; string text = $"zaak:\t{theCase.Name}\r\n" + $"nummer:\t{theCase.Number}\r\n" + $"eigenaar:\t{theCase.Owner}\r\n" + $"datum:\t{theCase.Date.ToString("yyyy-MM-dd")}\r\n" + $"datum laatst bijgewerkt:\t{DateTime.Now.ToString("yyyy-MM-dd")}\r\n" + $"folder:\t{theCase.CaseDirectory}\r\n" + $"aantal:\t{theCase.Files.Count}\r\n" + $"\r\n\r\n" ; foreach (var fileSelection in theCase.Files) { text += fileSelection.State + " - " + fileSelection.Path + System.Environment.NewLine; } File.WriteAllText(Path.Combine(p, filename), text); }
private void btnNext_OnClick(object sender, RoutedEventArgs e) { Case = fetchAndValidateInput(); if (Case != null) { bool caseDatabaseRowExists = CasesDB.Exists(Case.Number); bool caseDirectoryExists = Util.DirectoryExistst(Case.CaseDirectory); if (caseDirectoryExists || caseDatabaseRowExists) { // Verify consistency --> if (caseDirectoryExists && !caseDatabaseRowExists) { MessageBox.Show("Zaak bestaat op opslag maar niet in database. Waarschuw beheerder", "Inconsistentie gedetecteerd", MessageBoxButton.YesNo, MessageBoxImage.Warning); } else if (caseDatabaseRowExists && !caseDirectoryExists) { MessageBox.Show("Zaak bestaat in database maar niet in opslag. Waarschuw beheerder", "Inconsistentie gedetecteerd", MessageBoxButton.YesNo, MessageBoxImage.Warning); } else if (MessageBox.Show($"Zaak met nummer {Case.Number} bestaat al.\r\nToevoegen aan bestaande zaak?", "Zaaknummer bestaat al", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) { NavigationService.Navigate(new PageModifyExisting() { CaseNumber = Case.Number }); } } else { PageSelectFiles pageSelectFiles = new PageSelectFiles(this.Case); this.NavigationService.Navigate(pageSelectFiles); } } }
public static void AddTransferredFileToCaseDB(Util.FileSelection fileSelection, CaseInfo theCase) { string prc = "prc_content_add"; MySqlCommand cmd = new MySqlCommand(prc, connection) { CommandType = CommandType.StoredProcedure, }; cmd.Parameters.AddWithValue("@case_number", theCase.Number); cmd.Parameters.AddWithValue("@path", fileSelection.Path); cmd.Parameters.AddWithValue("@filetype", fileSelection.Type); //cmd.Parameters.AddWithValue("@archive_date", DateTime.Now); cmd.Parameters.AddWithValue("@archive_date", "2017-12-12"); cmd.ExecuteNonQuery(); }
public static void AddTransferedFilesToCaseDB(List <Util.FileSelection> fileSelections, CaseInfo theCase) { foreach (var fileSelection in fileSelections) { if (fileSelection.State == Util.FileState.TRANSFERRED) { AddTransferredFileToCaseDB(fileSelection, theCase); } } }
public static void AddTransferredFileToCaseDB(Util.FileSelection fileSelection, CaseInfo theCase) { string qry = $"INSERT OR REPLACE INTO {TABLE_CASE_CONTENT}(CaseNumber, Path, FileType, ArchiveDate) VALUES('{theCase.Number}', '{fileSelection.Path}', '{fileSelection.Type}', '{DateTime.Now.ToString(DATETIME_FORMAT)}')"; using (SQLiteConnection connection = new SQLiteConnection(ConnectionString)) { SQLiteCommand command = new SQLiteCommand(qry, connection); connection.Open(); command.ExecuteNonQuery(); connection.Close(); } }