105040 Clean code
This commit is contained in:
parent
f2cd6c50b2
commit
ea543c8992
|
@ -176,133 +176,30 @@ public partial class MainViewModel : INotifyPropertyChanged
|
|||
);
|
||||
return Task.FromResult(reportDatas.ToList());
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void LoadReportData(IEnumerable<BaseReportEntry> data, List<ReportColumn> columns)
|
||||
{
|
||||
DataColumns = [];
|
||||
//foreach (var column in columns)
|
||||
//{
|
||||
// //Trace.WriteLine($"/// {column.Text}\r\n public string {column.ID} {{get;set;}} ");
|
||||
|
||||
// DataColumns.Add(new DataGridTextColumn()
|
||||
// {
|
||||
// Header = column.Text,
|
||||
// Binding = new System.Windows.Data.Binding(column.ID)
|
||||
// });
|
||||
//}
|
||||
|
||||
//DataColumns.Add(new DataGridTextColumn()
|
||||
//{
|
||||
// Header = "变色管信息",
|
||||
// Binding = new System.Windows.Data.Binding("DiscolorationDesc")
|
||||
//});
|
||||
|
||||
//Data = [];
|
||||
//var reportDatas = new ConcurrentBag<ReportModel>();
|
||||
////foreach (var entry in data)
|
||||
//data.AsParallel().WithDegreeOfParallelism(8).ForAll(entry =>
|
||||
// {
|
||||
// var obj = new ReportModel();
|
||||
// foreach (var column in columns)
|
||||
// {
|
||||
// if (!entry.Properties.ContainsKey(column.ColumnID)) continue;
|
||||
// var value = entry.Properties[column.ColumnID].GetDisplayValue();
|
||||
// var property = typeof(ReportModel).GetProperty(column.ID);
|
||||
// if (property != null)
|
||||
// {
|
||||
// property.SetValue(obj, value ?? "");
|
||||
// }
|
||||
// }
|
||||
// reportDatas.Add(obj);
|
||||
// }
|
||||
//);
|
||||
//if (reportDatas != null && reportDatas.Any())
|
||||
//{
|
||||
// reportDatas.ToList().ForEach(Data.Add);
|
||||
//}
|
||||
//UpdateDataGridColumns([.. DataColumns], DataGridType.Originial);
|
||||
//StuffedData = [];
|
||||
//StuffData().ForEach(item =>
|
||||
//{
|
||||
// if (item != null)
|
||||
// {
|
||||
// StuffedData.Add(item);
|
||||
// }
|
||||
//});
|
||||
//OnPropertyChanged(nameof(StuffedDatas));
|
||||
|
||||
}
|
||||
|
||||
public async Task<List<StuffedDataModel>> StuffData(List<ReportModel> data)
|
||||
{
|
||||
var datas = new ConcurrentBag<StuffedDataModel>();
|
||||
var isAllCe = true;
|
||||
var isL1 = false;
|
||||
var isL2 = false;
|
||||
var isL3 = false;
|
||||
var isPe = false;
|
||||
//var isAllCe = true;
|
||||
//var isL1 = false;
|
||||
//var isL2 = false;
|
||||
//var isL3 = false;
|
||||
//var isPe = false;
|
||||
//foreach (var item in Data)
|
||||
data.AsParallel().WithDegreeOfParallelism(8).ForAll(item =>
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
|
||||
if (item == null) return;
|
||||
//var data = item.MemoryClone<ReportModel>();
|
||||
//new ReportModel
|
||||
//{
|
||||
// Project = item.Project,
|
||||
// Document = item.Document,
|
||||
// CableName = item.CableName,
|
||||
// PartNumber = item.PartNumber,
|
||||
// ManufacturerCompany = item.ManufacturerCompany,
|
||||
// Imprint = item.Imprint,
|
||||
// Length = item.Length,
|
||||
// OutsideDiameter = item.OutsideDiameter,
|
||||
// CoreDiameter = item.CoreDiameter,
|
||||
// ERPNr = item.ERPNr,
|
||||
// DisplayColor = item.DisplayColor,
|
||||
// DisplayStripeColor = item.DisplayStripeColor,
|
||||
// WireName = item.WireName,
|
||||
// WireTwisted = item.WireTwisted,
|
||||
// ConnectorFrom = item.ConnectorFrom,
|
||||
// ConnectorFromERPNr = item.ConnectorFromERPNr,
|
||||
//};
|
||||
|
||||
var data = new StuffedDataModel();
|
||||
|
||||
if (!string.IsNullOrEmpty(item.PartNumber))
|
||||
{
|
||||
if (!item.PartNumber.Contains("-CE/"))
|
||||
{
|
||||
isAllCe = false;
|
||||
}
|
||||
}
|
||||
if (!string.IsNullOrEmpty(item.Imprint))
|
||||
{
|
||||
if (item.Imprint.StartsWith("L1"))
|
||||
{
|
||||
isL1 = true;
|
||||
}
|
||||
|
||||
if (item.Imprint.StartsWith("L2"))
|
||||
{
|
||||
isL2 = true;
|
||||
}
|
||||
|
||||
if (item.Imprint.StartsWith("L3"))
|
||||
{
|
||||
isL3 = true;
|
||||
}
|
||||
|
||||
if (item.Imprint.StartsWith("PE"))
|
||||
{
|
||||
isPe = true;
|
||||
}
|
||||
}
|
||||
//if (!string.IsNullOrEmpty(item.PartNumber))
|
||||
//{
|
||||
// if (!item.PartNumber.Contains("-CE/"))
|
||||
// {
|
||||
// isAllCe = false;
|
||||
// }
|
||||
//}
|
||||
if (!string.IsNullOrEmpty(item.Imprint) && item.Imprint.Contains("&"))
|
||||
{
|
||||
var splitImprint = item.Imprint.Split('&');
|
||||
|
@ -396,10 +293,10 @@ public partial class MainViewModel : INotifyPropertyChanged
|
|||
});
|
||||
|
||||
|
||||
IsRequireCe = isAllCe;
|
||||
IsUseDiscoloration = isL1 && isL2 && isL3 && isPe;
|
||||
Trace.WriteLine($"isAllCE: {isAllCe}");
|
||||
Trace.WriteLine($"isSDIProject: {isL1 && isL2 && isL3 && isPe}");
|
||||
//IsRequireCe = isAllCe;
|
||||
//IsUseDiscoloration = isL1 && isL2 && isL3 && isPe;
|
||||
//Trace.WriteLine($"isAllCE: {isAllCe}");
|
||||
//Trace.WriteLine($"isSDIProject: {isL1 && isL2 && isL3 && isPe}");
|
||||
return await Task.FromResult<List<StuffedDataModel>>([.. datas]);
|
||||
}
|
||||
/// <summary>
|
||||
|
|
Loading…
Reference in New Issue