//to be called by a ui thread private async Task V2LE_UA_UserLookup_Refresh() { if (listBox5.SelectedIndex == -1) { return; } ulong selected_list = V2LE_ViewingLists.ElementAt(listBox5.SelectedIndex).Key; string filter = textBox2.Text.Trim(); await Task.Run(async() => { await V2LE_UA_UserLookup_Refresh(selected_list, filter); }); }
private async Task V2LE_RefreshListEntryEditor() { int lb5_index = listBox5.SelectedIndex; int lb3_index = listBox3.SelectedIndex; ResetListEntryEditor(); if (lb3_index > -1 && V2LE_UsersInCurrentList != null && V2LE_UsersInCurrentList.Count() > 0) { UInt64 selected_list_id = V2LE_ViewingLists.ElementAt(lb5_index).Key; UInt64 selected_user_id = V2LE_UsersInCurrentList.ElementAt(lb3_index).Key; List <Object> list_row = await DatabaseUtilities.GetV2ListEntry(selected_list_id, selected_user_id); if (list_row == null) { return; } string tb6_text = ""; if (ListEntryUtilities.TryParseV2EntryDays((string)list_row[0])) { tb6_text = ListEntryUtilities.ConvertBoolToDOWString(ListEntryUtilities.ConvertDOWStringToBools((string)list_row[0])); } else { tb6_text = "Sunday - Saturday"; } Invoke((MethodInvoker)(() => { textBox5.Text = selected_user_id.ToString(); textBox5.Enabled = true; checkBox2.Checked = (byte)list_row[2] == 0 ? false : true; checkBox2.Enabled = true; textBox6.Text = tb6_text; textBox6.Enabled = true; checkedListBox1.Enabled = true; textBox7.Text = ListEntryUtilities.TryParseV2EntryTime((string)list_row[1]) ? (string)list_row[1] : "00:00 - 23:59"; textBox7.Enabled = true; dateTimePicker1.Enabled = true; dateTimePicker2.Enabled = true; Refresh(); })); } }
//call from a ui thread private async Task V2LE_RefreshUserAssignment() { V2LE_RefreshUserAssignment_Busy = true; //change edit button states if (listBox5.SelectedIndex > -1) { button15.Enabled = true; button16.Enabled = true; } else { button15.Enabled = false; button16.Enabled = false; //everything should be invalidated here } ulong selected_list_uid = V2LE_ViewingLists.ElementAt(listBox5.SelectedIndex).Key; string selected_list_name = V2LE_ViewingLists.ElementAt(listBox5.SelectedIndex).Value; string list_user_filter = textBox2.Text.Trim(); string user_assignment_filter = textBox2.Text.Trim(); label7.Text = "Users In: " + selected_list_name; var tasks = new Task[] { new Task(async() => { await V2LE_UA_ListUsers_Refresh(selected_list_uid, list_user_filter); }), new Task(async() => { await V2LE_UA_UserLookup_Refresh(selected_list_uid, user_assignment_filter); }) }; foreach (Task t in tasks) { t.Start(); } await Task.WhenAll(tasks); V2LE_RefreshUserAssignment_Busy = false; }
//to be called from a non ui thread //refreshes the displayed access control lists private async Task V2LE_RefreshListSelection(string filter) { V2LE_ListRefreshActive = true; string tb8_text = ""; //list filter await Task.Run(async() => { //use all lists in the search var sqlconn = await ARDBConnectionManager.default_manager.CheckOut(); V2LE_ViewingLists = await DatabaseUtilities.GetDictionaryUniqueShortListDescriptionWithLimiter(sqlconn.Connection, tb8_text, 0); ARDBConnectionManager.default_manager.CheckIn(sqlconn); //V2LE_ViewingLists = (Dictionary<ulong, string>)V2LE_ViewingLists.OrderBy(x => x.Value).ToDictionary(); lock (ui_access_lock) Invoke((MethodInvoker)(() => { if (V2LE_ViewingLists.Count() == 0) { listBox5.DataSource = null; listBox5.Enabled = false; V2LE_ResetUserAssignment(); ResetListEntryEditor(); } else { listBox5.DataSource = V2LE_ViewingLists.Values.ToList(); listBox5.Enabled = true; } Refresh(); })); }); V2LE_ListRefreshActive = false; }