edit
This commit is contained in:
@@ -20,6 +20,7 @@ namespace XLAB2
|
||||
private string _documentNumberEditor;
|
||||
private string _documentStatusText;
|
||||
private string _detailTableCountText;
|
||||
private string _groupFilterText;
|
||||
private string _groupDetailFilterText;
|
||||
private string _headerDepartmentName;
|
||||
private int _headerInstrumentCount;
|
||||
@@ -50,6 +51,9 @@ namespace XLAB2
|
||||
DocumentsView = CollectionViewSource.GetDefaultView(Documents);
|
||||
DocumentsView.Filter = FilterDocuments;
|
||||
|
||||
DocumentGroupsView = CollectionViewSource.GetDefaultView(DocumentGroupSummaries);
|
||||
DocumentGroupsView.Filter = FilterDocumentGroups;
|
||||
|
||||
DocumentLinesView = CollectionViewSource.GetDefaultView(DocumentLines);
|
||||
DocumentLinesView.Filter = FilterDocumentLines;
|
||||
|
||||
@@ -132,6 +136,8 @@ namespace XLAB2
|
||||
|
||||
public ObservableCollection<PsvDocumentGroupSummary> DocumentGroupSummaries { get; private set; }
|
||||
|
||||
public ICollectionView DocumentGroupsView { get; private set; }
|
||||
|
||||
public string DocumentStatusText
|
||||
{
|
||||
get { return _documentStatusText; }
|
||||
@@ -154,6 +160,18 @@ namespace XLAB2
|
||||
|
||||
public ICommand DeleteSelectedGroupsCommand { get; private set; }
|
||||
|
||||
public string GroupFilterText
|
||||
{
|
||||
get { return _groupFilterText; }
|
||||
set
|
||||
{
|
||||
if (SetProperty(ref _groupFilterText, value))
|
||||
{
|
||||
RefreshDocumentGroupsView();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string GroupDetailFilterText
|
||||
{
|
||||
get { return _groupDetailFilterText; }
|
||||
@@ -466,6 +484,23 @@ namespace XLAB2
|
||||
return document != null && document.IssuedOn.HasValue;
|
||||
}
|
||||
|
||||
private static string BuildSerialNumbersText(IEnumerable<PsvDocumentLine> lines)
|
||||
{
|
||||
var serialNumbers = (lines ?? Enumerable.Empty<PsvDocumentLine>())
|
||||
.Select(delegate(PsvDocumentLine line)
|
||||
{
|
||||
return line == null || string.IsNullOrWhiteSpace(line.SerialNumber)
|
||||
? null
|
||||
: line.SerialNumber.Trim();
|
||||
})
|
||||
.Where(delegate(string serialNumber) { return !string.IsNullOrWhiteSpace(serialNumber); })
|
||||
.Distinct(StringComparer.OrdinalIgnoreCase)
|
||||
.OrderBy(delegate(string serialNumber) { return serialNumber; }, StringComparer.OrdinalIgnoreCase)
|
||||
.ToList();
|
||||
|
||||
return serialNumbers.Count == 0 ? string.Empty : string.Join(", ", serialNumbers.ToArray());
|
||||
}
|
||||
|
||||
private static bool HasVerificationData(PsvDocumentLine line)
|
||||
{
|
||||
return line != null
|
||||
@@ -1662,6 +1697,7 @@ namespace XLAB2
|
||||
document.PassedCount = materializedLines.Count(delegate(PsvDocumentLine line) { return line.IsPassed == true; });
|
||||
document.FailedCount = materializedLines.Count(delegate(PsvDocumentLine line) { return line.IsPassed == false; });
|
||||
document.IssuedCount = materializedLines.Count(delegate(PsvDocumentLine line) { return line.IssuedOn.HasValue; });
|
||||
document.SerialNumbersText = BuildSerialNumbersText(materializedLines);
|
||||
}
|
||||
|
||||
private async Task ExecuteBusyOperationAsync(Func<Task> operation)
|
||||
@@ -1701,7 +1737,8 @@ namespace XLAB2
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(DocumentFilterText)
|
||||
&& !Contains(document.DocumentNumber, DocumentFilterText)
|
||||
&& !Contains(document.CustomerName, DocumentFilterText))
|
||||
&& !Contains(document.CustomerName, DocumentFilterText)
|
||||
&& !Contains(document.SerialNumbersText, DocumentFilterText))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -1709,6 +1746,25 @@ namespace XLAB2
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool FilterDocumentGroups(object item)
|
||||
{
|
||||
var group = item as PsvDocumentGroupSummary;
|
||||
if (group == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(GroupFilterText))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return Contains(group.InstrumentType, GroupFilterText)
|
||||
|| Contains(group.RangeText, GroupFilterText)
|
||||
|| Contains(group.RegistryNumber, GroupFilterText)
|
||||
|| Contains(group.SerialNumbersText, GroupFilterText);
|
||||
}
|
||||
|
||||
private string BuildDocumentStatusText(int count)
|
||||
{
|
||||
if (ShowClosedDocuments)
|
||||
@@ -1753,6 +1809,26 @@ namespace XLAB2
|
||||
});
|
||||
}
|
||||
|
||||
private PsvDocumentGroupSummary FindMatchingVisibleGroup(PsvDocumentGroupSummary group)
|
||||
{
|
||||
if (group == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return GetVisibleDocumentGroups().FirstOrDefault(delegate(PsvDocumentGroupSummary current)
|
||||
{
|
||||
return AreSameGroup(current, group);
|
||||
});
|
||||
}
|
||||
|
||||
private List<PsvDocumentGroupSummary> GetVisibleDocumentGroups()
|
||||
{
|
||||
return DocumentGroupsView == null
|
||||
? new List<PsvDocumentGroupSummary>()
|
||||
: DocumentGroupsView.Cast<object>().OfType<PsvDocumentGroupSummary>().ToList();
|
||||
}
|
||||
|
||||
private static bool AreSameGroup(PsvDocumentGroupSummary left, PsvDocumentGroupSummary right)
|
||||
{
|
||||
return left != null
|
||||
@@ -2068,7 +2144,7 @@ namespace XLAB2
|
||||
|
||||
if (SelectedDocument.IsDraft)
|
||||
{
|
||||
SelectedDocument.ItemCount = pendingLines.Count;
|
||||
UpdateDocumentSummaryFromLines(SelectedDocument, pendingLines);
|
||||
}
|
||||
|
||||
LoadSelectedDocumentAsync();
|
||||
@@ -2176,7 +2252,7 @@ namespace XLAB2
|
||||
|
||||
if (SelectedDocument.IsDraft)
|
||||
{
|
||||
SelectedDocument.ItemCount = pendingLines.Count;
|
||||
UpdateDocumentSummaryFromLines(SelectedDocument, pendingLines);
|
||||
}
|
||||
|
||||
LoadSelectedDocumentAsync();
|
||||
@@ -2196,7 +2272,8 @@ namespace XLAB2
|
||||
}
|
||||
|
||||
RebuildDocumentGroupSummaries(DocumentLines);
|
||||
SelectedDocumentGroup = FindMatchingGroup(previousGroup) ?? DocumentGroupSummaries.FirstOrDefault();
|
||||
SelectedDocumentGroup = FindMatchingVisibleGroup(previousGroup)
|
||||
?? GetVisibleDocumentGroups().FirstOrDefault();
|
||||
SelectedDocumentLine = previousLine == null
|
||||
? null
|
||||
: DocumentLines.FirstOrDefault(delegate(PsvDocumentLine line)
|
||||
@@ -2211,6 +2288,7 @@ namespace XLAB2
|
||||
&& string.Equals(line.DuplicateKey, previousLine.DuplicateKey, StringComparison.OrdinalIgnoreCase);
|
||||
});
|
||||
HeaderInstrumentCount = DocumentLines.Count;
|
||||
RefreshDocumentGroupsView();
|
||||
RefreshDocumentLinesView();
|
||||
RaiseCommandStates();
|
||||
}
|
||||
@@ -2255,6 +2333,7 @@ namespace XLAB2
|
||||
InstrumentType = group.Key.InstrumentType,
|
||||
RangeText = group.Key.RangeText,
|
||||
RegistryNumber = group.Key.RegistryNumber,
|
||||
SerialNumbersText = BuildSerialNumbersText(group),
|
||||
IsBatchSelected = checkedGroups.Any(delegate(PsvDocumentGroupSummary previous)
|
||||
{
|
||||
return string.Equals(previous.InstrumentType ?? string.Empty, group.Key.InstrumentType, StringComparison.OrdinalIgnoreCase)
|
||||
@@ -2274,6 +2353,36 @@ namespace XLAB2
|
||||
}
|
||||
}
|
||||
|
||||
private void RefreshDocumentGroupsView()
|
||||
{
|
||||
if (DocumentGroupsView != null)
|
||||
{
|
||||
DocumentGroupsView.Refresh();
|
||||
}
|
||||
|
||||
var selectedVisibleGroup = FindMatchingVisibleGroup(SelectedDocumentGroup);
|
||||
if (selectedVisibleGroup != null)
|
||||
{
|
||||
if (!ReferenceEquals(SelectedDocumentGroup, selectedVisibleGroup))
|
||||
{
|
||||
SelectedDocumentGroup = selectedVisibleGroup;
|
||||
return;
|
||||
}
|
||||
|
||||
RefreshDocumentLinesView();
|
||||
return;
|
||||
}
|
||||
|
||||
var firstVisibleGroup = GetVisibleDocumentGroups().FirstOrDefault();
|
||||
if (!ReferenceEquals(SelectedDocumentGroup, firstVisibleGroup))
|
||||
{
|
||||
SelectedDocumentGroup = firstVisibleGroup;
|
||||
return;
|
||||
}
|
||||
|
||||
RefreshDocumentLinesView();
|
||||
}
|
||||
|
||||
private void RefreshDocumentLinesView()
|
||||
{
|
||||
DocumentLinesView.Refresh();
|
||||
@@ -2456,6 +2565,8 @@ namespace XLAB2
|
||||
|
||||
private void UpdateLineStatus()
|
||||
{
|
||||
var visibleGroupCount = GetVisibleDocumentGroups().Count;
|
||||
|
||||
if (SelectedDocument == null)
|
||||
{
|
||||
DetailTableCountText = "Приборов в таблице: 0.";
|
||||
@@ -2472,10 +2583,19 @@ namespace XLAB2
|
||||
return;
|
||||
}
|
||||
|
||||
if (visibleGroupCount == 0)
|
||||
{
|
||||
DetailTableCountText = "Приборов в таблице: 0.";
|
||||
LineStatusText = string.IsNullOrWhiteSpace(GroupFilterText)
|
||||
? "Выберите группу."
|
||||
: string.Format("Группы по фильтру \"{0}\" не найдены.", GroupFilterText.Trim());
|
||||
return;
|
||||
}
|
||||
|
||||
if (SelectedDocumentGroup == null)
|
||||
{
|
||||
DetailTableCountText = "Приборов в таблице: 0.";
|
||||
LineStatusText = string.Format("Групп: {0}. Выберите группу.", DocumentGroupSummaries.Count);
|
||||
LineStatusText = string.Format("Групп: {0}/{1}. Выберите группу.", visibleGroupCount, DocumentGroupSummaries.Count);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2489,7 +2609,8 @@ namespace XLAB2
|
||||
DetailTableCountText = string.Format("Приборов в таблице: {0}.", filteredCount);
|
||||
|
||||
LineStatusText = string.Format(
|
||||
"Групп: {0}. Приборов в выбранной группе: {1}. Отображено по фильтру: {2}. Не сохранено строк: {3}.",
|
||||
"Групп: {0}/{1}. Приборов в выбранной группе: {2}. Отображено по фильтру: {3}. Не сохранено строк: {4}.",
|
||||
visibleGroupCount,
|
||||
DocumentGroupSummaries.Count,
|
||||
groupLineCount,
|
||||
filteredCount,
|
||||
|
||||
Reference in New Issue
Block a user