pgListLRP.xaml.cs 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading;
  6. using System.Threading.Tasks;
  7. using System.Windows;
  8. using System.Windows.Controls;
  9. using System.Windows.Data;
  10. using System.Windows.Documents;
  11. using System.Windows.Input;
  12. using System.Windows.Media;
  13. using System.Windows.Media.Imaging;
  14. using System.Windows.Navigation;
  15. using System.Windows.Shapes;
  16. namespace RedmineOracle
  17. {
  18. /// <summary>
  19. /// Логика взаимодействия для pgListLRP.xaml
  20. /// </summary>
  21. public partial class pgListLRP : Page
  22. {
  23. OracleWork ow;
  24. Thread refreshTread;
  25. Thread refreshOpen;
  26. int maxDrp;
  27. int maxOpen;
  28. int countOpen;
  29. int countDrp;
  30. public pgListLRP()
  31. {
  32. InitializeComponent();
  33. ow = new OracleWork();
  34. lbLRP.ItemsSource = ow.dtLrp().DefaultView;
  35. lbLRPOpen.ItemsSource = ow.outputOpen().DefaultView;
  36. tbResrond.ItemsSource = ow.listUsers();
  37. maxDrp = ow.CheckMaxDrp();
  38. maxOpen = ow.CheckMaxOpen();
  39. countOpen = ow.CheckCountOpen();
  40. tbResrond.SelectedValuePath = "Id";
  41. tbResrond.DisplayMemberPath = "Name";
  42. refreshTread = new Thread(refreshListOther);
  43. refreshTread.Start();
  44. refreshOpen = new Thread(refreshListOpen);
  45. refreshOpen.Start();
  46. //cbStatus.ItemsSource = ow.getAllStatus();
  47. //cbStatus.SelectedValuePath = "idStatus";
  48. //cbStatus.DisplayMemberPath = "statusName";
  49. }
  50. async void refreshListOther()
  51. {
  52. while (true)
  53. {
  54. ow = new OracleWork();
  55. if (maxDrp != ow.CheckMaxDrp())
  56. {
  57. maxDrp = ow.CheckMaxDrp();
  58. Application.Current.Dispatcher.Invoke(() =>
  59. {
  60. if (tbResrond.SelectedIndex == -1)
  61. {
  62. lbLRP.ItemsSource = ow.dtLrp().DefaultView;
  63. }
  64. else
  65. {
  66. lbLRP.ItemsSource = ow.findRespondLRP(tbResrond.SelectedValue.ToString()).DefaultView;
  67. }
  68. });
  69. }
  70. await Task.Delay(10000);
  71. }
  72. }
  73. async void refreshListOpen()
  74. {
  75. while (true)
  76. {
  77. ow = new OracleWork();
  78. if (maxOpen != ow.CheckMaxOpen() || countOpen != ow.CheckCountOpen())
  79. {
  80. Application.Current.Dispatcher.Invoke(() =>
  81. {
  82. lbLRPOpen.ItemsSource = ow.outputOpen().DefaultView;
  83. });
  84. maxOpen = ow.CheckMaxOpen();
  85. countOpen = ow.CheckCountOpen();
  86. }
  87. await Task.Delay(10000);
  88. }
  89. }
  90. private void TextBlock_MouseDown(object sender, MouseButtonEventArgs e)
  91. {
  92. TextBlock tb = (TextBlock)sender;
  93. MessageBox.Show(lbLRP.Items.Count.ToString());
  94. LoadPages.forumFrame.Navigate(new pgLRP(Convert.ToInt32(tb.Text)));
  95. }
  96. private void btnFind_Click(object sender, RoutedEventArgs e)
  97. {
  98. if (ow.findLRP(tbIdLRP.Text) == 1)
  99. {
  100. LoadPages.forumFrame.Navigate(new pgLRP(Convert.ToInt32(tbIdLRP.Text)));
  101. }
  102. else
  103. MessageBox.Show("ЛРП с таким номером не существует!");
  104. }
  105. private void tbResrond_TextChanged(object sender, TextChangedEventArgs e)
  106. {
  107. if (tbResrond.Text != "")
  108. {
  109. tbResrond.ItemsSource = ow.listUsers().Where(x => x.Name.Contains(tbResrond.Text));
  110. }
  111. else
  112. {
  113. tbResrond.ItemsSource = ow.listUsers();
  114. tbResrond.SelectedIndex = -1;
  115. }
  116. tbResrond.SelectedValuePath = "Id";
  117. tbResrond.DisplayMemberPath = "Name";
  118. }
  119. private void tbResrond_SelectionChanged(object sender, SelectionChangedEventArgs e)
  120. {
  121. //MessageBox.Show(tbResrond.SelectedValue.ToString());
  122. if (tbResrond.SelectedValue != null)
  123. lbLRP.ItemsSource = ow.findRespondLRP(tbResrond.SelectedValue.ToString()).DefaultView;
  124. }
  125. }
  126. }