internal List <notes> GetNotes() { // Note - at one point, notes were linked to calls and not claims // There might be some old architecture to reflect this // Aaron J December 2010 List <notes> toReturn = new List <notes>(); List <call> claimCalls = GetPastCalls(false); foreach (call call in claimCalls) { List <notes> callNotes = call.GetNotes(); foreach (notes note in callNotes) { if (note.claim_id == 0) { toReturn.Add(note); } } } DataTable linkedNotes = Search("SELECT * FROM notes WHERE claim_id = " + id + " ORDER BY created_on asc"); foreach (DataRow aNote in linkedNotes.Rows) { notes n = new notes(); n.Load(aNote); toReturn.Insert(0, n); } return(toReturn); }
private void lblEditNote_Click(object sender, EventArgs e) { if (dgvNotes.SelectedRows.Count == 1) { editNote = GetNoteFromGrid(dgvNotes.SelectedRows[0].Index); rtbNote.Text = editNote.Note; Mode = NotesGridMode.Editor; rtbNote.Focus(); } }
private string CreateNoteAdditionalText(notes note) { if (note.created_on == null) { return(" (" + note.operatorId + " Unknown time)"); } else { return(" (" + note.operatorId + " " + note.created_on.Value.ToShortDateString() + " " + note.created_on.Value.ToShortTimeString() + ")"); } }
private void lblAddNote_Click(object sender, EventArgs e) { editNote = new notes(); rtbNote.Text = ""; Mode = NotesGridMode.Editor; rtbNote.Focus(); if (NewNotes != null) { NewNotes(this, new EventArgs()); } }
public void SaveNote() { if ((editNote != null) && (rtbNote.Text != "")) { bool isNew = (!editNote.created_on.HasValue); editNote.Note = rtbNote.Text.Trim(); if ((editNote.CallId == 0) && (CurrentCall != null)) { editNote.CallId = CurrentCall.id; } else { editNote.CallId = 0; } if ((editNote.claim_id == 0) && (CurrentClaim != null)) { editNote.claim_id = CurrentClaim.id; } else { editNote.claim_id = 0; } editNote.operatorId = ActiveUser.UserObject.username; if (!editNote.created_on.HasValue) { editNote.created_on = DateTime.Now; } editNote.updated_on = DateTime.Now; ActiveUser.LogAction(ActiveUser.ActionTypes.CreateNote, editNote.claim_id, editNote.CallId, ""); editNote.Save(); if (isNew) { editNote.Note += CreateNoteAdditionalText(editNote); Notes.Insert(0, editNote); } editNote = null; rtbNote.Text = ""; Mode = NotesGridMode.GridView; bsNotes.ResetBindings(false); } else { CancelNote(); } }
//================================================================== public JsonResult delete_note(int noteId) { try { notes nt = DB.notes.Where(n => n.id == noteId).Single(); DB.notes.Remove(nt); DB.SaveChanges(); return(Json(new { msg = "تم حذف الملاحظه بنجاح" })); } catch { return(Json(new { msg = "لم تتم عمليه الحذف حاول مره اخري" })); } }
/// <summary> /// Returns a list of all questions that were answered on this call (use only on calls that have been saved) /// </summary> public List <notes> GetNotes() { List <notes> toReturn = new List <notes>(); DataTable linkedNotes = Search("SELECT * FROM notes WHERE call_id = " + id + " ORDER BY created_on desc"); foreach (DataRow aNote in linkedNotes.Rows) { notes n = new notes(); n.Load(aNote); toReturn.Add(n); } // toReturn.Sort(); return(toReturn); }
//================================================================== public JsonResult add_note(int cId, string note) { try { notes nt = new notes(); nt.clientId = cId; nt.note = note; nt.date = DateTime.Now.ToString("dd/MM/yyyy"); DB.notes.Add(nt); DB.SaveChanges(); return(Json(new { msg = "تم اضافه الملاحظه بنجاح" })); }catch { return(Json(new { msg = "لم تتم الاضافه حاول مره اخري" })); } }
private void button5_Click(object sender, EventArgs e) //rechercher { // Afficher dans Grid just la ligne de la matière séléctionnée string matière = comboBox1.Text; if (matière == "") { MessageBox.Show("Entrez une matière pour rechercher"); return; } notes N = new notes(); N.codeElev = E.codeElev; N.codeMat = matière; N.note = 0; List <notes> n = _Gnotes.ListerUneNote(N); dataGridView1.DataSource = n; }
protected void add_att(notes ob, int task_id, string file_name, byte[] content = null) { synch s = ob.get_synch(); // salvo il file DataRow dr = ob.get_task_info(task_id); if (db_provider.int_val(dr["file_id"]) > 0) { throw new Exception("il task non può contenere allegati!"); } string folder = Path.Combine(db_provider.str_val(dr["synch_local_path"]), db_provider.str_val(dr["folder_path"]).Substring(1)) , file_path = Path.Combine(folder, file_name); if (content != null) { File.WriteAllBytes(file_path, content); } else { File.WriteAllText(file_path, ""); } // aggiorno il db string tp; int cc; long nid = s.set_file_db(db_provider.int_val(dr["synch_folder_id"]), db_provider.int_val(dr["folder_id"]), file_name, Path.GetExtension(file_name) , DateTime.Now, DateTime.Now, out tp, out cc); if (s.is_type_file(Path.GetExtension(file_name)) != null) { s.set_file_content_db((int)nid, Path.GetExtension(file_name).ToLower() , content != null ? System.Text.Encoding.UTF8.GetString(content) : "", DateTime.Now, DateTime.Now); } if (s.is_info_file(file_name) != null && db_provider.int_val(dr["file_notes_id"]) <= 0) { s.init_task_notes_db(task_id, (int)nid, content != null ? System.Text.Encoding.UTF8.GetString(content) : ""); } }
private void button2_Click(object sender, EventArgs e) // Ajouter une note { string matière = comboBox1.Text; double Note = -1; if (matière == "") { MessageBox.Show("Entrez la matière "); return; } if (Note == -1 && textBox1.Text == "") { MessageBox.Show("Entrez la note"); return; } Note = Convert.ToDouble(textBox1.Text); if (Note < 0 || Note > 20) { MessageBox.Show("La note doit être entre 0 et 20"); return; } notes N = new notes(); N.codeElev = E.codeElev; N.codeMat = matière; N.note = Note; // on doit premièrement voir si cette matière à déjà une note , dans ce cas on peut seulement la modifier, Boolean noteExistedeja = _Gnotes.NoteExiste(N); if (noteExistedeja) { MessageBox.Show("la note de cette matière existe déjà , vous pouvez seulement la modifier!"); return; } _Gnotes.AjouterNote(N); MessageBox.Show("Note ajoutée"); InitialiserGrid(); }
private void button4_Click(object sender, EventArgs e) //supprimer { DataGridViewRow drg1 = dataGridView1.CurrentRow; string codeE = drg1.Cells[0].Value.ToString(); string codeM = drg1.Cells[1].Value.ToString(); //message de confirmation var selectedoption = MessageBox.Show("Etes vous sure de vouloir supprimer cette note ?", "Confirmation", MessageBoxButtons.YesNo); if (selectedoption == DialogResult.No) { return; } notes N = new notes(); N.codeElev = codeE; N.codeMat = codeM; N.note = 0; _Gnotes.SupprimerNote(N); InitialiserGrid(); MessageBox.Show("Note supprimée"); }
private void button3_Click(object sender, EventArgs e) // modifier { DataGridViewRow drg1 = dataGridView1.CurrentRow; double Note = -1; string codeE = drg1.Cells[0].Value.ToString(); string codeM = drg1.Cells[1].Value.ToString(); if (Note == -1 && textBox1.Text == "") { MessageBox.Show("Entrez la note pour modifier"); return; } Note = Convert.ToDouble(textBox1.Text); if (Note < 0 || Note > 20) { MessageBox.Show("La note doit être entre 0 et 20"); return; } //message de confirmation var selectedoption = MessageBox.Show("Etes vous sure de vouloir modifer la note de la matière " + codeM + " ?", "Confirmation", MessageBoxButtons.YesNo); if (selectedoption == DialogResult.No) { return; } notes N = new notes(); N.codeElev = codeE; N.codeMat = codeM; N.note = Note; _Gnotes.UpdateN(N); InitialiserGrid(); MessageBox.Show("Note modifié"); }
protected override void OnInit(EventArgs e) { base.OnInit(e); // inizializzazione _cmd = master.check_cmd(qry_val("cmd")); // elab requests & cmds if (this.IsPostBack) { return; } try { notes ob = new notes(); // upload file if (json_request.there_file(this)) { json_result res = new json_result(json_result.type_result.ok); try { if (Request.Files.Count > 0) { HttpFileCollection files = Request.Files; foreach (string key in files) { HttpPostedFile file = files[key]; string tp_file = key.Split(new char[] { '_' })[0]; if (tp_file == "task-file") { int task_id = int.Parse(key.Split(new char[] { '_' })[2]); byte[] content; using (var streamReader = new MemoryStream()) { file.InputStream.CopyTo(streamReader); content = streamReader.ToArray(); } add_att(ob, task_id, Path.GetFileName(file.FileName), content); } else { throw new Exception("tipo file upload '" + tp_file + "' non supportato!"); } } } else { throw new Exception("nessun file da caricare!"); } } catch (Exception ex) { log.log_err(ex); res = new json_result(json_result.type_result.error, ex.Message); } write_response(res); return; } // js request if (json_request.there_request(this)) { json_result res = new json_result(json_result.type_result.ok); try { json_request jr = new json_request(this); // base if (base_elab_action(jr, res)) { // fatta } // add_att else if (jr.action == "add_att") { add_att(ob, jr.val_int("task_id"), jr.val_str("name")); } // task_state else if (jr.action == "task_state") { List <free_label> fl = ob.load_free_labels(); string folder_path; ob.update_task(jr.val_int("id"), out folder_path, fl, stato: jr.val_str("stato")); List <task_stato> stati = db_conn.dt_table(core.parse_query("menu-states")).Rows.Cast <DataRow>() .Select(r => new task_stato(db_provider.str_val(r["stato"]), 0, "", "" , db_provider.str_val(r["title_singolare"]))).ToList(); res.html_element = parse_task(ob.load_task(jr.val_int("id")), folder_path, stati); } // set_filter_id else if (jr.action == "set_filter_id") { set_cache_var("active-task-filter", jr.val_str("filter_id")); } // remove_task else if (jr.action == "remove_task") { ob.remove_task(jr.val_int("id")); } // update_task else if (jr.action == "update_task") { List <free_label> fl = ob.load_free_labels(); if (!nome_valido(jr.val_str("title"))) { throw new Exception("nome '" + jr.val_str("title") + "' non valido!"); } string folder_path; ob.update_task(jr.val_int("id"), out folder_path, fl, title: jr.val_str("title"), assegna: jr.val_str("assegna") , priorita: jr.val_str("priorita"), stima: jr.val_str("stima"), tipo: jr.val_str("tipo")); List <task_stato> stati = db_conn.dt_table(core.parse_query("menu-states")).Rows.Cast <DataRow>() .Select(r => new task_stato(db_provider.str_val(r["stato"]), 0, "", "" , db_provider.str_val(r["title_singolare"]))).ToList(); res.html_element = parse_task(ob.load_task(jr.val_int("id")), folder_path, stati); } // ren_task else if (jr.action == "ren_task") { if (!nome_valido(jr.val_str("title"))) { throw new Exception("nome '" + jr.val_str("title") + "' non valido!"); } ob.ren_task(jr.val_int("id"), jr.val_str("title")); } // add_task else if (jr.action == "add_task") { if (!nome_valido(jr.val_str("title"))) { throw new Exception("nome '" + jr.val_str("title") + "' non valido!"); } ob.add_task(jr.val_int("synch_folder_id"), jr.val_int("folder_id"), jr.val_int_null("search_id"), jr.val_str("stato") , jr.val_str("title"), jr.val_str("assegna"), jr.val_str("priorita"), jr.val_str("tipo"), jr.val_str("stima")); } // remove_att else if (jr.action == "remove_att") { ob.remove_att(jr.val_int("id")); } // ren_att else if (jr.action == "ren_att") { ob.ren_file(jr.val_int("file_id"), jr.val_str("name")); } // add_folder else if (jr.action == "add_folder") { if (!nome_valido(jr.val_str("title"))) { throw new Exception("nome '" + jr.val_str("title") + "' non valido!"); } ob.add_folder(jr.val_int("synch_folder_id"), jr.val_int("folder_id"), jr.val_str("title")); } // ren_folder else if (jr.action == "ren_folder") { if (!nome_valido(jr.val_str("title"))) { throw new Exception("nome '" + jr.val_str("title") + "' non valido!"); } ob.ren_folder(jr.val_int("synch_folder_id"), jr.val_int("folder_id"), jr.val_str("title")); } // del_folder else if (jr.action == "del_folder") { ob.del_folder(jr.val_int("synch_folder_id"), jr.val_int("folder_id")); res.contents = master.url_cmd("tasks"); } // cut_element else if (jr.action == "cut_element") { int f_id = jr.val_int("element_id"), sf_id = jr.val_int("synch_folder_id"); string tp = jr.val_str("tp_element"); bool?added = null; if (tp == "folder" || tp == "synch-folder") { if (sf_id > 0 && tp == "synch-folder") { foreach (int id in ob.ids_childs_folders(sf_id)) { added = set_element_cut(id, element_cut.element_cut_type.folder, jr.val_bool("copy")); res.list.Add(id.ToString()); } } else { added = set_element_cut(f_id, element_cut.element_cut_type.folder, jr.val_bool("copy")); res.list.Add(f_id.ToString()); } } else if (tp == "task") { added = set_element_cut(f_id, element_cut.element_cut_type.task, jr.val_bool("copy")); } else if (tp == "att") { added = set_element_cut(f_id, element_cut.element_cut_type.attachment, jr.val_bool("copy")); } res.set_var("added", added.HasValue ? (added.Value ? "true" : "false") : "none"); } // paste_elements else if (jr.action == "paste_elements") { string tp_paste = jr.val_str("tp"); int f_id = jr.val_int("folder_id"), sf_id = jr.val_int("synch_folder_id"); bool paste = false; if (elements_cut.Count > 0) { string err = ""; List <element_cut> ecs = new List <element_cut>(); if (tp_paste == "task") { DataRow dr = ob.get_task_info(f_id); if (db_provider.int_val(dr["file_id"]) > 0) { throw new Exception("questo task non può contenere un allegato!"); } string path_task = Path.Combine(db_provider.str_val(dr["synch_local_path"]) , db_provider.str_val(dr["folder_path"]).Length > 0 ? db_provider.str_val(dr["folder_path"]).Substring(1) : ""); foreach (element_cut ec in elements_cut) { try { if (ec.tp == element_cut.element_cut_type.attachment) { paste = true; if (!ec.copy) { ob.move_file(ec.id, db_provider.int_val(dr["folder_id"]), db_provider.int_val(dr["synch_folder_id"]), path_task); } else { ob.copy_file(ec.id, db_provider.int_val(dr["folder_id"]), db_provider.int_val(dr["synch_folder_id"]), path_task); } } } catch (Exception ex) { ecs.Add(ec); if (err == "") { err = ex.Message; } } } } else { if (sf_id <= 0) { sf_id = ob.get_synch_folder_id(f_id); } foreach (element_cut ec in elements_cut) { try { if (ec.tp == element_cut.element_cut_type.folder) { ob.move_folder(ec.id, sf_id, f_id > 0 ? f_id : (int?)null); paste = true; } else if (ec.tp == element_cut.element_cut_type.task) { ob.move_task(ec.id, sf_id, f_id > 0 ? f_id : (int?)null); paste = true; } } catch (Exception ex) { ecs.Add(ec); if (err == "") { err = ex.Message; } } } } res.message = err; elements_cut.Clear(); foreach (element_cut ec2 in ecs) { elements_cut.Add(ec2); } } if (!paste) { throw new Exception("non è stato incollato nessun elemento!"); } } // get_notes else if (jr.action == "get_details") { res.contents = ob.get_task_notes(jr.val_int("task_id")); string html_allegati = ""; foreach (DataRow dr in ob.get_task_allegati(jr.val_int("task_id"), jr.val_int_null("search_id")).Rows) { bool cut = there_element_cut(db_provider.int_val(dr["file_id"]), element_cut.element_cut_type.attachment) , found = db_provider.int_val(dr["found_file"]) > 0, file_task = db_provider.int_val(dr["file_task"]) > 0; string style = cut ? "badge-warning" : (found ? "badge-danger" : (file_task ? "badge-primary" : "badge-light")); html_allegati += master.client_key == "" ? core.parse_html_block("task-allegato", new string[, ] { { "file-id", db_provider.str_val(dr["file_id"]) } , { "http-path", db_provider.str_val(dr["http_path"]) }, { "file-name", db_provider.str_val(dr["file_name"]) }, { "style", style }, { "tp_att", style } }) : core.parse_html_block("task-allegato-client", new string[, ] { { "file-id", db_provider.str_val(dr["file_id"]) }, { "file-name", db_provider.str_val(dr["file_name"]) }, { "style", style }, { "tp_att", style } , { "user-id", ob.user_id.ToString() }, { "user-name", ob.user_name } }); } res.html_element = html_allegati != "" ? core.parse_html_block("task-allegati", new string[, ] { { "html-allegati", html_allegati } }) : ""; } // save_task_notes else if (jr.action == "save_task_notes") { synch s = ob.get_synch(jr.val_int("user_id"), jr.val_str("user_name")); s.save_task_notes(jr.val_int("task_id"), jr.val_str("text")); } else if (jr.action == "synch_folders") { synch s = ob.get_synch(jr.val_int("user_id"), jr.val_str("user_name")); s.synch_event += s_synch_event; synch_results rf = s.reload_folders(force: true); res.data = rf; res.contents = _synch_events; } } catch (Exception ex) { log.log_err(ex); res = new json_result(json_result.type_result.error, ex.Message); } write_response(res); return; } // synch if (_cmd != null && _cmd.action == "synch") { content.InnerHtml = "<p>sincronizzazione cartelle...</p>"; ClientScript.RegisterStartupScript(GetType(), "__action" , "var __action_page = '" + _cmd.action + "';\r\n" + "var __user_id = " + this.user.id + ";\r\n" + "var __user_name = '" + this.user.name + "';\r\n", true); } // tasks else if (_cmd != null && ((_cmd.action == "view" && _cmd.obj == "tasks") || (_cmd.action == "search" && _cmd.obj == "task"))) { int?fi = qry_val("idt") != "" ? qry_int("idt") : (qry_val("id") != "" ? qry_int("id") : (int?)null) , sfi = qry_val("sft") != "" ? qry_int("sft") : (qry_val("sf") != "" ? qry_int("sf") : (int?)null); string search = _cmd.action == "search" ? _cmd.sub_obj() : ""; // ricerca testo int search_cc = 0; int?search_id = search != "" ? ob.search_task(search, this.Session.SessionID, out search_cc) : (int?)null; search_id_active.Value = search_id.HasValue ? search_id.Value.ToString() : ""; // filtro attivo List <task_filter> tfs = db_conn.dt_table(core.parse_query("filters-tasks")).Rows .Cast <DataRow>().Select(r => new task_filter(db_provider.int_val(r["task_filter_id"]) , db_provider.str_val(r["filter_title"]), db_provider.str_val(r["filter_notes"]) , db_provider.str_val(r["filter_def"]), db_provider.str_val(r["filter_class"]))).ToList(); task_filter tf = tfs.FirstOrDefault(x => x.id == int.Parse(get_cache_var("active-task-filter", "1"))); if (tf == null || search_id.HasValue) { tf = new task_filter(0, "elenco completo delle attività", "", "", ""); } ob.load_objects(fi, sfi, tf, search_id); menu.InnerHtml = parse_menu(ob.synch_folders, sfi.HasValue || fi.HasValue, qry_val("cmd"), search_id); folder_id.Value = qry_val("id"); folder f = fi.HasValue ? ob.find_folder(fi.Value) : null; synch_folder sf = sfi.HasValue ? ob.find_synch_folder(sfi.Value) : null; string title = f != null ? f.folder_name : (sf != null ? sf.title : ""); List <task_stato> stati = db_conn.dt_table(core.parse_query("menu-states")).Rows.Cast <DataRow>() .Select(r => new task_stato(db_provider.str_val(r["stato"]), 0, "", "", db_provider.str_val(r["title_singolare"]))).ToList(); content.InnerHtml = "<div style='display:none'>virtuale</div>" + parse_tasks(ob, stati, tf, title, f != null ? ob.find_synch_folder(f.synch_folder_id).title + f.path : "", tfs, search: search_id.HasValue ? search : ""); ClientScript.RegisterStartupScript(GetType(), "__task_states" , "var __action_page = '';\r\n" + "var __task_priorita = " + JsonConvert.SerializeObject(db_conn.dt_table(core.parse_query("task-priorita"))) + ";\r\n" + "var __task_stime = " + JsonConvert.SerializeObject(db_conn.dt_table(core.parse_query("task-stime"))) + ";\r\n" + "var __task_tipi = " + JsonConvert.SerializeObject(db_conn.dt_table(core.parse_query("task-tipi"))) + ";\r\n" + "var __task_assegna = " + JsonConvert.SerializeObject(db_conn.dt_table(core.parse_query("task-assegna"))) + ";\r\n" + "var __user_id = " + this.user.id + ";\r\n" + "var __user_name = '" + this.user.name + "';\r\n", true); } else { throw new Exception("COMANDO NON RICONOSCIUTO!"); } } catch (Exception ex) { log.log_err(ex); if (!json_request.there_request(this)) { master.err_txt(ex.Message); } } }
private void CancelNote() { editNote = null; rtbNote.Text = ""; Mode = NotesGridMode.GridView; }
protected string parse_tasks(notes n, List <task_stato> stati, task_filter tf = null, string title_folder = "", string path_folder = "" , List <task_filter> tfs = null, string search = "") { StringBuilder sb = new StringBuilder(); sb.Append(core.parse_html_block(search != "" ? (title_folder == "" ? "title-attivita-search" : "title-attivita-folder-search") : (title_folder == "" ? "title-attivita" : "title-attivita-folder") , new string[, ] { { "title-folder", title_folder }, { "path-folder", path_folder } , { "filter-title", search != "" ? "ricerca attività" : (tf != null ? tf.title : "") } , { "filter-des", (search != "" ? "ricerca attività che contengono '" + search + "'" : "") + (tf != null ? tf.notes + " ordinate per data decrescente" : "") } , { "conteggio", n.tasks != null && n.tasks.Count > 0 ? "per un totale di: " + n.tasks.Count.ToString() + " attività" : "non è stata trovata nessuna attività" } , { "html-filters", tfs != null ? string.Join("", tfs.Select(x => string.Format("<a class='dropdown-item {2}' href='javascript:change_filter({1})'>{0}</a>", x.title, x.id, x.class_css != "" ? "text-" + x.class_css : ""))) : "" } })); List <int> orders = n.tasks.Select(x => x.stato.order).Distinct().ToList(); orders.Sort(); foreach (int order in orders) { bool first = true; List <task> sub_tasks = n.tasks.Where(x => x.stato.order == order).OrderByDescending(xx => xx.dt_ref).ToList(); foreach (task t in sub_tasks) { // title if (first) { string sub_title = sub_tasks.Count == 1 ? t.stato.title_singolare : t.stato.title_plurale; sb.Append(core.parse_html_block("open-title-sub-attivita", new string[, ] { { "count", sub_tasks.Count.ToString() }, { "cls", t.stato.cls } , { "title", sub_title != "" ? sub_title : (sub_tasks.Count == 1 ? "GENERICA" : "GENERICHE") } })); first = false; } // task string folder_path = ""; if (t.file_id.HasValue) { folder f = t.folder_id.HasValue ? n.synch_folders.FirstOrDefault(x => x.id == t.synch_folder_id).get_folder(t.folder_id.Value) : null; folder_path = f != null ? f.path : ""; } else { synch_folder sf = n.synch_folders.FirstOrDefault(x => x.id == t.synch_folder_id); folder f = sf.get_folder(t.folder_id.Value) , fp = f.parent_id.HasValue ? sf.get_folder(f.parent_id.Value) : null; folder_path = fp != null ? fp.path : ""; } sb.Append(parse_task(t, n.find_synch_folder(t.synch_folder_id).title + folder_path, stati)); } if (!first) { sb.Append(core.parse_html_block("close-title-sub-attivita")); } } return(sb.ToString()); }
public static void GoImport() { claim workingClaim = new claim(); DataTable importData = new DataTable(); DataTable importDataSecondaries = new DataTable(); DataTable importDataPredeterms = new DataTable(); DataTable importDataSecondaryPredeterms = new DataTable(); system_options.SetImportFlag(true); primaryClaimCount = 0; secondaryClaimCount = 0; predetermClaimCount = 0; secondaryPredetermClaimCount = 0; closedClaimCount = 0; OleDbConnection oConnect; //UpdateProgressBar(50, "Initiating Remote Connection..."); #region Initiate Connection, Get Data try { oConnect = new OleDbConnection(dms.GetConnectionString(true)); } catch (Exception err) { CreateLogFile(err.ToString()); Updateimporterror(true); DeleteDirectoryFromTemp(); //LoggingHelper.Log("An error occurred getting the connection string for a new connection in frmImportData.Import", LogSeverity.Error, err, false); //e.Cancel = true; CancelImport(); return; } OleDbDataAdapter oAdapter; // Use Connection object for the DataAdapter to retrieve all tables from selected Database try { oConnect.Open(); } catch (Exception err) { CreateLogFile(err.ToString()); Updateimporterror(true); DeleteDirectoryFromTemp(); //LoggingHelper.Log("Could not connect to the database in frmImportdata.Import", LogSeverity.Error, err, false); //e.Cancel = true; CancelImport(); return; } try { //UpdateProgressBar(50, "Querying remote database (Standard)..."); // ************* Standard Claims oAdapter = new OleDbDataAdapter(PrepareSQL(dms.sqlstatement, changesOnly), oConnect); oAdapter.SelectCommand.CommandTimeout = System.Convert.ToInt32(dataTimeout); oAdapter.Fill(importData); //UpdateProgressBar(10, "Querying remote database (Secondary)..."); // ************** Secondaries if (dms.sqlstatementsecondaries != "") { oAdapter = new OleDbDataAdapter(PrepareSQL(dms.sqlstatementsecondaries, changesOnly), oConnect); oAdapter.SelectCommand.CommandTimeout = System.Convert.ToInt32(dataTimeout); oAdapter.Fill(importDataSecondaries); } //UpdateProgressBar(10, "Querying remote database (Predeterms)..."); // *************** Predeterms if (dms.sqlstatementpredeterms != "") { oAdapter = new OleDbDataAdapter(PrepareSQL(dms.sqlstatementpredeterms, changesOnly), oConnect); oAdapter.SelectCommand.CommandTimeout = System.Convert.ToInt32(dataTimeout); oAdapter.Fill(importDataPredeterms); } //UpdateProgressBar(10, "Querying remote database (Secondary Predeterms)..."); // *************** Predeterms if (dms.sqlstatementsecondarypredeterms != "") { oAdapter = new OleDbDataAdapter(PrepareSQL(dms.sqlstatementsecondarypredeterms, changesOnly), oConnect); oAdapter.SelectCommand.CommandTimeout = System.Convert.ToInt32(dataTimeout); oAdapter.Fill(importDataSecondaryPredeterms); } } catch (Exception err) { CreateLogFile(err.ToString()); Updateimporterror(true); DeleteDirectoryFromTemp(); //LoggingHelper.Log("Error with SQL statement or connection in frmImportData.Import", LogSeverity.Error, err); //MessageBox.Show(this, "There was an error with your SQL statement or with your connection.\n\n" + err.Message, // "Error retrieving data"); CancelImport(); return; } #endregion data_mapping_schema_data dmsd = new data_mapping_schema_data(); dmsd.schema_id = dms.id; DataTable dataForSchema = dmsd.Search(); // Generate our list of objects one time, and then use them for each iteration of rows List <data_mapping_schema_data> allMappedSchemaData = new List <data_mapping_schema_data>(); foreach (DataRow aMapping in dataForSchema.Rows) { // For every row, need to get the data for every field dmsd = new data_mapping_schema_data(); dmsd.Load(aMapping); allMappedSchemaData.Add(dmsd); } // UpdateProgressBar(100, "Importing data..."); if (okToZap) { company cmp = new company(); cmp.Zap(); workingClaim.Zap(); call aCall = new call(); aCall.Zap(); company_contact_info info = new company_contact_info(); info.Zap(); procedure p = new procedure(); p.Zap(); choice c = new choice(); c.Zap(); notes n = new notes(); n.Zap(); claim_batch cb = new claim_batch(); cb.Zap(); batch_claim_list bcl = new batch_claim_list(); bcl.Zap(); } else { if (!changesOnly) { workingClaim.MarkAllImportsUpdated(false); } } // Apply incremental updates to progress bar int currentRow = 0; totalRows = importData.Rows.Count + importDataSecondaries.Rows.Count + importDataPredeterms.Rows.Count + importDataSecondaryPredeterms.Rows.Count; decimal exactIncrementAmount; if (totalRows > 0) { exactIncrementAmount = 500m / totalRows; } else { exactIncrementAmount = 500m; } decimal incrementCounter = 0; int increment; if (exactIncrementAmount < 1) { increment = 1; } else { increment = Convert.ToInt32(Math.Truncate(exactIncrementAmount)); } string lastClaimID = ""; claim aClaim = new claim(); company aCompany = new company(); company_contact_info anInfo = new company_contact_info(); procedure aProcedure = new procedure(); for (int p = 0; p < 4; p++) { claim.ClaimTypes ct; DataTable thisImport; switch (p) { case 0: thisImport = importData; ct = claim.ClaimTypes.Primary; //UpdateLabels(0); break; case 1: thisImport = importDataSecondaries; ct = claim.ClaimTypes.Secondary; //UpdateLabels(1); break; case 2: thisImport = importDataPredeterms; ct = claim.ClaimTypes.Predeterm; //UpdateLabels(2); break; default: thisImport = importDataSecondaryPredeterms; //UpdateLabels(3); ct = claim.ClaimTypes.SecondaryPredeterm; break; } // Have data at this point, need to tie them to the internal mapping schema data foreach (DataRow anImportRow in thisImport.Rows) { string newID = anImportRow[dms.claim_id_column].ToString(); string newDB = anImportRow[dms.claim_db_column].ToString(); bool isOnlyProcedureData; if (newID == lastClaimID) { // We're only dealing with the import of "some" data isOnlyProcedureData = true; } else { if (ct == claim.ClaimTypes.Primary) { primaryClaimCount++; } else if (ct == claim.ClaimTypes.Secondary) { secondaryClaimCount++; } else if (ct == claim.ClaimTypes.Predeterm) { predetermClaimCount++; } else { secondaryPredetermClaimCount++; } //UpdateTypeCount(); aClaim = FindClaim(anImportRow, ct); aCompany = FindCompany(anImportRow[dms.company_namecolumn].ToString()); anInfo = FindContactInfo(anImportRow["Ins_Co_Street1"].ToString(), aCompany.id, anImportRow["Ins_Co_Phone"].ToString()); lastClaimID = newID; aClaim.ClearClaimProcedures(); isOnlyProcedureData = false; // Check for "X" in provider field try { if (aClaim.doctor_provider_id.StartsWith("X")) { AddStatus(string.Format("The claim for patient {0} on {1} uses an X provider ({2})", aClaim.PatientName, aClaim.DatesOfServiceString(), aClaim.doctor_provider_id), true, true); } } catch (Exception err) { CreateLogFile(err.ToString()); Updateimporterror(true); DeleteDirectoryFromTemp(); //LoggingHelper.Log(err, false); } } aProcedure = FindProcedure(anImportRow["PROC_LOGID"].ToString()); if (CommonFunctions.DBNullToString(anImportRow["DATERECEIVED"]) == "") { aClaim.open = 1; } else if (((DateTime)anImportRow["DATERECEIVED"]).Year == 1753) { aClaim.open = 1; } else { aClaim.open = 0; UpdateStatusHistory(aClaim); } foreach (data_mapping_schema_data aMappedData in allMappedSchemaData) { // We do a check for is only procedure data to speed up processing // It makes the code a little messier. if (isOnlyProcedureData) { // If we're only importing the procedure data, none of the other information is important if ((aMappedData.LinkedField.table_name == "claims") || (aMappedData.LinkedField.table_name == "companies") || (aMappedData.LinkedField.table_name == "company_contact_info")) { // Ignore } else if (aMappedData.LinkedField.table_name == "procedures") { if (aMappedData.LinkedField.field_name == "surf_string") { aProcedure[aMappedData.LinkedField.field_name] = CommonFunctions.RemoveNonPrintableCharacters(anImportRow[aMappedData.mapped_to_text].ToString()); } else if (aMappedData.LinkedField.field_name == "claim_id") { aProcedure["claim_id"] = lastClaimID; } else { aProcedure[aMappedData.LinkedField.field_name] = anImportRow[aMappedData.mapped_to_text]; } } else { //LoggingHelper.Log("Uninitialized table name in frmImportData.Import", LogSeverity.Critical, // new Exception("Uninitialized table name in import procedure."), true); } } else { // This is a new claim - we need to get the data for every field if (aMappedData.LinkedField.table_name == "claims") { aClaim[aMappedData.LinkedField.field_name] = anImportRow[aMappedData.mapped_to_text]; } else if (aMappedData.LinkedField.table_name == "companies") { if (aMappedData.mapped_to_text != dms.company_namecolumn) { aCompany[aMappedData.LinkedField.field_name] = anImportRow[aMappedData.mapped_to_text]; } } else if (aMappedData.LinkedField.table_name == "company_contact_info") { anInfo[aMappedData.LinkedField.field_name] = anImportRow[aMappedData.mapped_to_text]; } else if (aMappedData.LinkedField.table_name == "procedures") { if (aMappedData.LinkedField.field_name == "surf_string") { aProcedure[aMappedData.LinkedField.field_name] = CommonFunctions.RemoveNonPrintableCharacters(anImportRow[aMappedData.mapped_to_text].ToString()); } else { aProcedure[aMappedData.LinkedField.field_name] = anImportRow[aMappedData.mapped_to_text]; } } else { //LoggingHelper.Log("Uninitialized table name in frmImport.Import", LogSeverity.Critical); //throw new Exception("Uninitialized table name in import procedure."); } } } aCompany.Save(); anInfo.company_id = aCompany.id; if (CommonFunctions.DBNullToZero(anInfo["order_id"]) == 0) { anInfo.order_id = anInfo.GetNextOrderID(); } anInfo.Save(); aClaim.company_id = aCompany.id; aClaim.company_address_id = anInfo.order_id; aClaim["import_update_flag"] = true; aClaim.Save(); if (p == 0 || p == 2 || p == 3) // Only update the id if this is the primary claim or a predeterm { aProcedure.claim_id = aClaim.id; } aProcedure.Save(); currentRow++; if (Math.Truncate(incrementCounter + exactIncrementAmount) != Math.Truncate(incrementCounter)) { //UpdateProgressBar(increment, string.Format("{0} / {1} procedures completed...", currentRow, totalRows), false); } incrementCounter += exactIncrementAmount; } } if (changesOnly) { // Grab all the deleted claims and mark them as closed here // Add a note that they have been deleted, I guess string deletedClaimsSQL = "SELECT CLAIMID, CLAIMDB " + "FROM AUDIT_DDB_CLAIM " + "WHERE N_CLAIMID is null " + "AND CLAIMID is not null AND CLAIMDB is not null " + "AND date_changed >= '" + lastWrite.ToString("G") + "'"; DataTable deletedClaims = new DataTable(); OleDbCommand cmd = new OleDbCommand(deletedClaimsSQL, oConnect); cmd.CommandTimeout = 90; oAdapter = new OleDbDataAdapter(cmd); oAdapter.Fill(deletedClaims); //UpdateProgressBar(5, "Updating Local Status for Deleted Claims..."); foreach (DataRow aDeletedClaim in deletedClaims.Rows) { // Close the claims DataTable matches = aClaim.Search("SELECT * FROM claims WHERE claimidnum = '" + aDeletedClaim["claimid"] + "' and claimdb = '" + aDeletedClaim["claimdb"] + "'"); if (matches.Rows.Count > 0) { // This should honestly not load every claim aClaim = new claim(); aClaim.Load(matches.Rows[0]); aClaim.open = 0; aClaim.Save(); UpdateStatusHistory(aClaim); closedClaimCount++; } } } else { closedClaimCount = workingClaim.CloseClaimsWithoutUpdate(); } //UpdateLabels(4); workingClaim.FixRevisitDateAfterImport(); system_options.SetLastImportDate(DateTime.Now); ShowLastImportDate(); AddStatus("The import completed successfully! " + totalRows + " rows were imported."); AddReportMessage(string.Format("The import completed successfully!\nPrimary: {0}\nSecondary: {1}\n" + "Predeterm: {2}\nSecondary Predeterm: {3}\nTotal Open Claims: {4}", primaryClaimCount, secondaryClaimCount, predetermClaimCount, secondaryPredetermClaimCount, primaryClaimCount + secondaryClaimCount + predetermClaimCount + secondaryPredetermClaimCount)); try { string importFileName = Application.StartupPath + "\\Imports\\" + DateTime.Now.ToString("yyyy-MM-dd hh-mm-ss") + " import.rtf"; //Directory.CreateDirectory(Path.GetDirectoryName(importFileName)); //rtxtReport.SaveFile(importFileName); saveFileFromTemp(); DeleteDirectoryFromTemp(); CreateLogFile("Import Successfully."); Updateimporterror(false); } catch (Exception ex) { CreateLogFile(ex.ToString()); Updateimporterror(true); DeleteDirectoryFromTemp(); //LoggingHelper.Log("Error creating import report file.", LogSeverity.Error, ex, false); } }
static extern bool Beep(notes dwFreq, tempo dwDuration);