Advertisement
Guest User

Untitled

a guest
Oct 24th, 2016
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.78 KB | None | 0 0
  1. public async Task<ActionResult> GetRMschools()
  2. {
  3. Account account = new Account("chr_coko.pto@mail.ru", "***");
  4. var api = new MailRuCloud();
  5. api.Account = account;
  6. string schoolID = User.Identity.Name;
  7. var items = await api.GetItems($@"/Reports/{schoolID}");
  8.  
  9. school school_current = schoolRepository.GetT(schoolID);
  10. List<RMschool> model = new List<RMschool>();
  11. foreach (var file_name in items.Files) //e.g. file_name = "0001_201636.zip"
  12. {
  13. int report_code = Convert.ToInt32(file_name.Name.Substring(5, 6)); //e.g. report_code = 201636
  14. var ob = monit95Context.ReportMetas.Find(report_code);
  15. model.Add(new RMschool
  16. {
  17. code = ob.code,
  18. name = ob.name,
  19. ProjectName = ob.ProjectName,
  20. year = ob.year,
  21. WWWref = $@"{school_current.ReportLink}/{file_name.Name}"
  22. });
  23. }
  24. return PartialView("_GetRMschools", model);
  25.  
  26. @using Monit95App.Models
  27. @model List<RMschool>
  28. <body>
  29. <table class="table">
  30. <thead class="thead-inverse">
  31. <tr>
  32. <th>Проект</th>
  33. <th>Отчет</th>
  34. <th>Учебный год</th>
  35. </tr>
  36. </thead>
  37. @foreach (var reportMeta in Model.OrderByDescending(x => x.code))
  38. {
  39. <tr>
  40. <td>@reportMeta.ProjectName</td>
  41. <td><a href="@reportMeta.WWWref">@reportMeta.name</a></td>
  42. <td>@reportMeta.year</td>
  43. </tr>
  44. }
  45. </table>
  46. </body>
  47.  
  48. <h2>Отчеты</h2>
  49. @Html.Action("GetRMschools")
  50.  
  51. [HttpGet]
  52. public async Task<ActionResult> Report()
  53. {
  54. var model = await GetRMschoolList(User.Identity.Name);
  55. return View(model);
  56. }
  57.  
  58. public async Task<ActionResult> GetRMschoolPV(string _schoolID)
  59. {
  60. var model = await this.GetRMschoolList(_schoolID);
  61. return PartialView("_RMschool", model);
  62. }
  63.  
  64. public async Task<List<RMschool>> GetRMschoolList(string _schoolID) //GetViewModel
  65. {
  66. Account account = new Account("chr_coko.pto@mail.ru", "***");
  67. var api = new MailRuCloud();
  68. api.Account = account;
  69. var items = await api.GetItems($@"/Reports/{_schoolID}");
  70.  
  71. school school_current = schoolRepository.GetT(_schoolID);
  72. List<RMschool> model = new List<RMschool>();
  73. foreach (var file_name in items.Files) //e.g. file_name = "0001_201636.zip"
  74. {
  75. int report_code = Convert.ToInt32(file_name.Name.Substring(5, 6)); //e.g. report_code = 201636
  76. var ob = monit95Context.ReportMetas.Find(report_code);
  77. model.Add(new RMschool
  78. {
  79. code = ob.code,
  80. name = ob.name,
  81. ProjectName = ob.ProjectName,
  82. year = ob.year,
  83. WWWref = $@"{school_current.ReportLink}/{file_name.Name}"
  84. });
  85. }
  86. return (model);
  87. }
  88.  
  89. @model IEnumerable<Monit95App.Models.RMschool>
  90.  
  91. @{ Html.RenderPartial("_RMschool", Model);}
  92.  
  93. @model IEnumerable<Monit95App.Models.RMschool>
  94.  
  95. <body>
  96. <table class="table">
  97. <thead class="thead-inverse">
  98. <tr>
  99. <th>Проект</th>
  100. <th>Отчет</th>
  101. <th>Учебный год</th>
  102. </tr>
  103. </thead>
  104. @foreach (var reportMeta in Model.OrderByDescending(x => x.code))
  105. {
  106. <tr>
  107. <td>@reportMeta.ProjectName</td>
  108. <td><a href="@reportMeta.WWWref">@reportMeta.name</a></td>
  109. <td>@reportMeta.year</td>
  110. </tr>
  111. }
  112. </table>
  113. </body>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement