policycheck_state: traceing update, merge error fix
Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
This commit is contained in:
@@ -23,8 +23,8 @@ pub fn is_valid(policy_number: &usize, policy_list: &PolicyDataList,
|
||||
let dt_start: DateTime<Local> = Local::now();
|
||||
|
||||
trace!(target: "advotracker",
|
||||
process = ?res,
|
||||
state = ?state,
|
||||
process = ?"validation",
|
||||
state = ?"started",
|
||||
policy_number = ?policy_number,
|
||||
policy_list = ?policy_list.name,
|
||||
elements = ?policy_list.policy_data.len(),
|
||||
@@ -54,8 +54,8 @@ pub fn is_valid(policy_number: &usize, policy_list: &PolicyDataList,
|
||||
let dt_end: DateTime<Local> = Local::now();
|
||||
let duration = dt_end.signed_duration_since(dt_start);
|
||||
|
||||
trace!(target: "csv-test",
|
||||
process = "policy validation",
|
||||
trace!(target: "advotracker",
|
||||
process = "validation",
|
||||
state = "finished",
|
||||
date_stop = ?dt_end.to_string(),
|
||||
duration = ?duration);
|
||||
|
||||
@@ -5,14 +5,19 @@
|
||||
* SPDX-License-Identifier: (0BSD or MIT)
|
||||
*/
|
||||
|
||||
use tracing::{debug, trace};
|
||||
use dotenv::dotenv;
|
||||
use orbtk::prelude::*;
|
||||
use serde::Deserialize;
|
||||
use std::{env, process};
|
||||
use std::collections::HashMap;
|
||||
use tracing::{debug, error, info, trace};
|
||||
|
||||
use crate::services::imports::allianzdirectcall::import;
|
||||
use crate::callbacks::policy_check::is_valid;
|
||||
//use crate::callbacks::policy_check::is_valid;
|
||||
|
||||
use crate::{
|
||||
callbacks::global_state::GlobalState,
|
||||
data::structures::{PolicyCode, PolicyDataList, PolicyData, PolicyList},
|
||||
data::structures::{PolicyCheck, PolicyCode, PolicyDataList, PolicyList},
|
||||
data::keys::*,
|
||||
};
|
||||
|
||||
@@ -42,9 +47,11 @@ pub struct PolicyCheckState {
|
||||
label_result_text_block: Entity,
|
||||
last_focused: Option<Entity>,
|
||||
menu_button: Entity,
|
||||
policy_number_valid: bool,
|
||||
policy_number_count: usize,
|
||||
policy_numbers: HashMap<usize, PolicyCode>,
|
||||
//policy_check_clean_button: Entity,
|
||||
policy_check: PolicyCheck,
|
||||
policy_data_count: usize,
|
||||
//policy_number_text_box: Entity,
|
||||
policy_numbers: HashMap<usize, PolicyCode>
|
||||
}
|
||||
|
||||
impl GlobalState for PolicyCheckState {}
|
||||
@@ -78,8 +85,14 @@ impl PolicyCheckState {
|
||||
let mut policy_numbers : HashMap<usize, PolicyCode> = HashMap::new();
|
||||
|
||||
// Wip: use cli parameter stored in viperus ...
|
||||
self.policy_number_count = count;
|
||||
println!("Imported {:?} records", self.policy_number_count);
|
||||
//let mut csv_import_path = v.get::<String>("import_file").unwrap();
|
||||
let mut csv_import_path = String::from("POLLFNR_WOECHENTLICH.txt");
|
||||
println!("Importing from: {:?}", csv_import_path);
|
||||
match import(&mut csv_import_path, &mut policy_data,
|
||||
&mut policy_numbers, &lang) {
|
||||
Ok(count) => {
|
||||
self.policy_data_count = count;
|
||||
println!("Imported {:?} records", self.policy_data_count);
|
||||
}
|
||||
Err(err) => {
|
||||
println!("error running CSV-Import: {}", err);
|
||||
@@ -87,7 +100,6 @@ impl PolicyCheckState {
|
||||
}
|
||||
};
|
||||
|
||||
// move results to the golbal accessible instance
|
||||
self.policy_numbers = policy_numbers;
|
||||
Ok(())
|
||||
}
|
||||
@@ -107,7 +119,7 @@ impl PolicyCheckState {
|
||||
}
|
||||
|
||||
fn parse_entry(&mut self, policy_check_policy_number: Entity,
|
||||
ctx: &mut Context) {
|
||||
ctx: &mut Context<'_>) {
|
||||
let policy_string = ctx.get_widget(policy_check_policy_number).get::<String16>("text").as_string();
|
||||
let policy_number_length = policy_string.len();
|
||||
|
||||
@@ -120,31 +132,23 @@ impl PolicyCheckState {
|
||||
// needs to be an integer
|
||||
match policy_string.parse::<usize>() {
|
||||
Ok(p) => {
|
||||
trace!(target: "advotracker", policy_number = ?p);
|
||||
|
||||
// WIP: for now, only import once per session
|
||||
if self.policy_number_count == 0 {
|
||||
match self.create_hashmap() {
|
||||
Ok(()) => {
|
||||
println!("hashmap has: {:?} entries", self.policy_number_count);
|
||||
}
|
||||
_ => {
|
||||
println!("Creation of a hashmap failed!");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
println!("Already imported {} records.", self.policy_number_count);
|
||||
|
||||
|
||||
}
|
||||
println!(" ... verify policy Number {:?}", p);
|
||||
let mut label_wrapper : TextBlockCtx<'_> = text_block(ctx.child("policy_check_label_result"));
|
||||
let string_label = "Prüfungsergebnis:".to_string();
|
||||
label_wrapper.set_text(string_label);
|
||||
label_wrapper.set_visibility(Visibility::Visible);
|
||||
label_wrapper.set_enabled(true);
|
||||
let mut result_wrapper: TextBlockCtx<'_> = text_block(ctx.child("policy_check_result"));
|
||||
result_wrapper.set_text("Prüfung läuft ...");
|
||||
match self.policy_numbers.get(&p) {
|
||||
// check hashmaps value field
|
||||
// check hashmap value field
|
||||
Some(policy_code) => {
|
||||
//let res = t!("policy.validation.success", lang);
|
||||
//println!("{:?}", res);
|
||||
println!("policy_number: {} ({:?})",
|
||||
p, policy_code);
|
||||
trace!(target: "advotracker", state = "success",
|
||||
policy_number = ?p, policy_code = ?policy_code);
|
||||
result_wrapper.set_enabled(true);
|
||||
let string_result = format!("gütig! => vollständig: 1-{:?}-{}",
|
||||
policy_code, p);
|
||||
result_wrapper.set_text(string_result);
|
||||
}
|
||||
_ => {
|
||||
//let res = t!("policy.validation.failed", lang);
|
||||
@@ -191,7 +195,7 @@ impl PolicyCheckState {
|
||||
// ctx.get_widget(self.policy_check_clear_button).set("enabled", true);
|
||||
// }
|
||||
|
||||
// ctx.get_widget(self.text_box).update_theme_by_state(true);
|
||||
// ctx.get_widget(self.policy_check_policy_number).update_theme_by_state(true);
|
||||
// }
|
||||
|
||||
/// Change status of given text box to edit mode.
|
||||
@@ -233,7 +237,6 @@ impl PolicyCheckState {
|
||||
let data_list_count = ctx.widget().get::<PolicyDataList>(PROP_POLICY_DATA_LIST).len();
|
||||
ctx.widget().set(PROP_POLICY_DATA_COUNT, data_list_count);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// upported states for our view
|
||||
@@ -306,7 +309,6 @@ impl State for PolicyCheckState {
|
||||
Action::ClearEntry(policy_check_policy_number) => {
|
||||
ctx.get_widget(policy_check_policy_number).set("enabled", false);
|
||||
}
|
||||
|
||||
Action::InputTextChanged(entity) => {
|
||||
//println!("entry changed: {}", text_box(ctx.get_widget(entity)).text());
|
||||
//self.set_check_button(policy_check_label_policy_number, ctx);
|
||||
|
||||
Reference in New Issue
Block a user