ReviewerAppealModel.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text.Json;
  6. using System.Threading.Tasks;
  7. using wispro.sp.entity;
  8. using wispro.sp.web.Services;
  9. namespace wispro.sp.web.Models
  10. {
  11. public class ReviewerAppealModel
  12. {
  13. public PerformanceItem Item { get; set; }
  14. public AppealType AppealType { get; set; }
  15. public List<InputField> CreateInputFields { get; set; }
  16. public List<InputFieldValue> CreateAppealFieldValues { get; set; }
  17. public List<InputField> inputFields { get; set; }
  18. public List<InputFieldValue> inputFieldValues { get; set; }
  19. public List<AttachFile> attachFiles { get; set; }
  20. public AppealRecord AppealRecord { get; set; }
  21. public async Task Init(AppealTypeService _atService, int appealRecordId)
  22. {
  23. this.AppealRecord =await _atService.getAppealRecord(appealRecordId);
  24. Item = this.AppealRecord.Item;
  25. CreateInputFields = await _atService.GetInputFields(this.AppealRecord.TypeId, 0);
  26. CreateAppealFieldValues = await _atService.GetInputFieldValues(this.AppealRecord.Id,0);
  27. inputFields = await _atService.GetInputFields(this.AppealRecord.TypeId, 1);
  28. attachFiles = await _atService.GetAppealRecordAttachFiles(this.AppealRecord.Id);
  29. inputFieldValues = new List<InputFieldValue>();
  30. foreach (var field in inputFields)
  31. {
  32. if (!string.IsNullOrEmpty(field.MapObjectField) && !string.IsNullOrEmpty(field.MapObjectFieldLabel))
  33. {
  34. List<InputFieldValue> temValues = new List<InputFieldValue>();
  35. string[] pList = field.MapObjectField.Split(new char[] { '.' });
  36. string[] plList = field.MapObjectFieldLabel.Split(new char[] { '.' });
  37. var pInfo = Item.GetType().GetProperty(pList[0]);
  38. var o = pInfo.GetValue(Item);
  39. if (Array.IndexOf(o.GetType().GetInterfaces(), typeof(IEnumerable)) > -1)
  40. {
  41. List<string> Values = new List<string>();
  42. List<string> Labels = new List<string>();
  43. var objList = o as IEnumerable;
  44. foreach (var obj in objList)
  45. {
  46. var objValue = obj;
  47. var objLabel = obj;
  48. for (int i = 1; i < pList.Length; i++)
  49. {
  50. objValue = objValue.GetType().GetProperty(pList[i]).GetValue(objValue);
  51. }
  52. for (int i = 1; i < plList.Length; i++)
  53. {
  54. objLabel = objLabel.GetType().GetProperty(plList[i]).GetValue(objLabel);
  55. }
  56. var fValue = new InputFieldValue();
  57. fValue.InputField = field;
  58. fValue.InputFieldId = field.Id;
  59. fValue.Label = objLabel.ToString();
  60. if (objValue != null)
  61. {
  62. fValue.Value = objValue.ToString();
  63. }
  64. inputFieldValues.Add(fValue);
  65. temValues.Add(fValue);
  66. }
  67. }
  68. else
  69. {
  70. var fValue = new InputFieldValue();
  71. fValue.InputField = field;
  72. fValue.InputFieldId = field.Id;
  73. inputFieldValues.Add(fValue);
  74. }
  75. }
  76. else
  77. {
  78. var fValue = new InputFieldValue();
  79. fValue.InputField = field;
  80. fValue.InputFieldId = field.Id;
  81. inputFieldValues.Add(fValue);
  82. }
  83. }
  84. }
  85. }
  86. }