|
@@ -850,40 +850,15 @@ namespace PRSDesktop
|
|
|
if (IsEntityForm)
|
|
|
columns.Add("Processed");
|
|
|
if (!string.IsNullOrWhiteSpace(jobLink))
|
|
|
- columns.Add(jobLink + ".JobNumber");
|
|
|
+ columns.Add(jobLink + ".ID");
|
|
|
|
|
|
return new KeyedQueryDef<T>(filter, columns, sort);
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
- private void RefreshData<TForm>()
|
|
|
- where TForm : Entity, IRemotable, IPersistent, IDigitalFormInstance, new()
|
|
|
+ private void LoadDataIntoGrid(List<DigitalFormVariable> variables, List<QAQuestion> questions, CoreTable formData, List<string> additionalColumns, CoreTable? jobITPs)
|
|
|
{
|
|
|
- var formQuery = GetFormQuery<TForm>();
|
|
|
-
|
|
|
- var queries = new List<IKeyedQueryDef>()
|
|
|
- {
|
|
|
- new KeyedQueryDef<QAQuestion>(new Filter<QAQuestion>(x => x.Form.ID).IsEqualTo(Form!.ID)),
|
|
|
- new KeyedQueryDef<DigitalFormVariable>(
|
|
|
- new Filter<DigitalFormVariable>(x => x.Form.ID).IsEqualTo(Form.ID),
|
|
|
- null,
|
|
|
- new SortOrder<DigitalFormVariable>(x => x.Sequence)),
|
|
|
- formQuery
|
|
|
- };
|
|
|
- if (ParentType == typeof(JobITPForm))
|
|
|
- {
|
|
|
- queries.Add(new KeyedQueryDef<JobITP>(
|
|
|
- new Filter<JobITP>(x => x.ID).InQuery((formQuery.Filter as Filter<JobITPForm>)!, x => x.Parent.ID),
|
|
|
- new Columns<JobITP>(x => x.ID, x => x.Job.JobNumber)));
|
|
|
- }
|
|
|
-
|
|
|
- var results = Client.QueryMultiple(queries);
|
|
|
-
|
|
|
- var questions = results.Get<QAQuestion>();
|
|
|
- var variables = results.Get<DigitalFormVariable>().ToList<DigitalFormVariable>();
|
|
|
- var formData = results.Get(formQuery.Key).Rows;
|
|
|
-
|
|
|
var data = new DataTable();
|
|
|
data.Columns.Add("ID", typeof(Guid));
|
|
|
data.Columns.Add("Form_ID", typeof(Guid));
|
|
@@ -920,12 +895,12 @@ namespace PRSDesktop
|
|
|
data.Columns.Add(code, typeof(string));
|
|
|
}
|
|
|
}
|
|
|
- else if (questions.Rows.Any())
|
|
|
+ else if (questions.Any())
|
|
|
{
|
|
|
- Questions = questions.ToList<QAQuestion>();
|
|
|
+ Questions = questions;
|
|
|
Progress.SetMessage("Loading Checks");
|
|
|
QAGrid.Clear();
|
|
|
- QAGrid.LoadChecks(Form.Description, Questions, new Dictionary<Guid, object>());
|
|
|
+ QAGrid.LoadChecks(Form!.Description, Questions, new Dictionary<Guid, object>());
|
|
|
QAGrid.CollapseMargins();
|
|
|
|
|
|
var i = 1;
|
|
@@ -942,7 +917,7 @@ namespace PRSDesktop
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- foreach (var row in formData)
|
|
|
+ foreach (var row in formData.Rows)
|
|
|
{
|
|
|
var form = (row.ToObject(FormType!) as IDigitalFormInstance)!;
|
|
|
if (!string.IsNullOrWhiteSpace(form.FormData))
|
|
@@ -958,14 +933,11 @@ namespace PRSDesktop
|
|
|
dataRow["FormData"] = form.FormData;
|
|
|
|
|
|
var desc = new List<string>();
|
|
|
- foreach (var col in formQuery.Columns!.ColumnNames().Where(x => x != "ID"))
|
|
|
+ foreach (var col in additionalColumns)
|
|
|
{
|
|
|
- if (col.StartsWith("Parent."))
|
|
|
- {
|
|
|
- var val = row[col];
|
|
|
- if (val != null && val is not Guid)
|
|
|
- desc.Add(val.ToString() ?? "");
|
|
|
- }
|
|
|
+ var val = row[col];
|
|
|
+ if (val != null && val is not Guid)
|
|
|
+ desc.Add(val.ToString() ?? "");
|
|
|
}
|
|
|
|
|
|
dataRow["Description"] = string.Join(" : ", desc);
|
|
@@ -978,8 +950,12 @@ namespace PRSDesktop
|
|
|
|
|
|
if (ParentType == typeof(JobITP))
|
|
|
{
|
|
|
- var jobITP = results.Get<JobITP>().Rows.FirstOrDefault(x => x.Get<JobITP, Guid>(x => x.ID) == form.ParentID());
|
|
|
- dataRow["Job No"] = jobITP?.Get<JobITP, string>(x => x.Job.JobNumber);
|
|
|
+ var jobITP = jobITPs!.Rows.FirstOrDefault(x => x.Get<JobITP, Guid>(x => x.ID) == form.ParentID());
|
|
|
+ if(jobITP is not null)
|
|
|
+ {
|
|
|
+ var jobID = jobITP.Get<JobITP, Guid>(x => x.Job.ID);
|
|
|
+ dataRow["Job No"] = Jobs.Where(x => x.ID == jobID).FirstOrDefault()?.JobNumber;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
if (pColumns != null)
|
|
@@ -999,10 +975,11 @@ namespace PRSDesktop
|
|
|
foreach (var key in dict.Keys)
|
|
|
{
|
|
|
var variable = variables.FirstOrDefault(x => string.Equals(key, x.Code));
|
|
|
+ var type = variable?.FieldType();
|
|
|
if (variable != null)
|
|
|
{
|
|
|
var value = variable.ParseValue(dict[key]);
|
|
|
- object format = variable.FormatValue(value);
|
|
|
+ var format = variable.FormatValue(value);
|
|
|
var sKey = key.Replace("/", " ");
|
|
|
if (data.Columns.Contains(sKey))
|
|
|
{
|
|
@@ -1030,11 +1007,45 @@ namespace PRSDesktop
|
|
|
}
|
|
|
DataGrid.ItemsSource = data;
|
|
|
|
|
|
- IsQAForm = !variables.Any() && questions.Rows.Any();
|
|
|
+ IsQAForm = !variables.Any() && questions.Any();
|
|
|
QAGrid.Visibility = IsQAForm ? Visibility.Visible : Visibility.Collapsed;
|
|
|
DataGrid.Visibility = Visibility.Visible;
|
|
|
}
|
|
|
|
|
|
+ private void RefreshData<TForm>()
|
|
|
+ where TForm : Entity, IRemotable, IPersistent, IDigitalFormInstance, new()
|
|
|
+ {
|
|
|
+ var formQuery = GetFormQuery<TForm>();
|
|
|
+
|
|
|
+ var queries = new List<IKeyedQueryDef>()
|
|
|
+ {
|
|
|
+ new KeyedQueryDef<QAQuestion>(new Filter<QAQuestion>(x => x.Form.ID).IsEqualTo(Form!.ID)),
|
|
|
+ new KeyedQueryDef<DigitalFormVariable>(
|
|
|
+ new Filter<DigitalFormVariable>(x => x.Form.ID).IsEqualTo(Form.ID),
|
|
|
+ null,
|
|
|
+ new SortOrder<DigitalFormVariable>(x => x.Sequence)),
|
|
|
+ formQuery
|
|
|
+ };
|
|
|
+ if (ParentType == typeof(JobITPForm))
|
|
|
+ {
|
|
|
+ queries.Add(new KeyedQueryDef<JobITP>(
|
|
|
+ new Filter<JobITP>(x => x.ID).InQuery((formQuery.Filter as Filter<JobITPForm>)!, x => x.Parent.ID),
|
|
|
+ new Columns<JobITP>(x => x.ID, x => x.Job.JobNumber)));
|
|
|
+ }
|
|
|
+
|
|
|
+ var results = Client.QueryMultiple(queries);
|
|
|
+
|
|
|
+ var questions = results.Get<QAQuestion>().ToList<QAQuestion>();
|
|
|
+ var variables = results.Get<DigitalFormVariable>().ToList<DigitalFormVariable>();
|
|
|
+ var formData = results.Get(formQuery.Key);
|
|
|
+
|
|
|
+ LoadDataIntoGrid(
|
|
|
+ variables, questions,
|
|
|
+ formData,
|
|
|
+ formQuery.Columns!.ColumnNames().Where(x => x != "ID" && x.StartsWith("Parent.")).ToList(),
|
|
|
+ ParentType == typeof(JobITP) ? results.Get<JobITP>() : null);
|
|
|
+ }
|
|
|
+
|
|
|
public void Refresh()
|
|
|
{
|
|
|
Progress.Show("Refreshing");
|