PageRenderTime 45ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/CmsWeb/Areas/OnlineReg/Controllers/ConfirmTest.cs

https://bitbucket.org/mahalowe/bvcms
C# | 164 lines | 97 code | 2 blank | 65 comment | 6 complexity | 531393ef47c36daf16a4741c56f88d9a MD5 | raw file
Possible License(s): CC-BY-SA-3.0, Apache-2.0, BSD-3-Clause, LGPL-2.1, MPL-2.0-no-copyleft-exception, AGPL-3.0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.Mvc;
  6. using System.Web.Mvc.Ajax;
  7. using CmsData;
  8. using CmsWeb.Models;
  9. using UtilityExtensions;
  10. using System.Configuration;
  11. using System.Net.Mail;
  12. using System.Runtime.Serialization;
  13. using System.IO;
  14. using System.Text;
  15. using System.Text.RegularExpressions;
  16. using CmsWeb.Areas.Manage.Controllers;
  17. using System.Xml.Linq;
  18. namespace CmsWeb.Areas.OnlineReg.Controllers
  19. {
  20. public partial class OnlineRegController
  21. {
  22. public class ConfirmTestInfo
  23. {
  24. public ExtraDatum ed;
  25. public OnlineRegModel m;
  26. }
  27. public class TransactionTestInfo
  28. {
  29. public ExtraDatum ed;
  30. public TransactionInfo ti;
  31. }
  32. private string EleVal(XElement r, string name)
  33. {
  34. var e = r.Element(name);
  35. if (e != null)
  36. return e.Value;
  37. return null;
  38. }
  39. [Authorize(Roles = "Admin")]
  40. public ActionResult ConfirmTest(int? start, int? count)
  41. {
  42. IEnumerable<ExtraDatum> q;
  43. q = from ed in DbUtil.Db.ExtraDatas
  44. where ed.Data.StartsWith("<?") && ed.Data.Contains("<OnlineRegModel")
  45. orderby ed.Stamp descending
  46. select ed;
  47. var list = q.Skip(start ?? 0).Take(count ?? 200).ToList();
  48. var q2 = new List<ConfirmTestInfo>();
  49. foreach (var ed in list)
  50. {
  51. try
  52. {
  53. var m = Util.DeSerialize<OnlineRegModel>(ed.Data);
  54. var i = new ConfirmTestInfo
  55. {
  56. ed = ed,
  57. m = m
  58. };
  59. q2.Add(i);
  60. }
  61. catch (Exception)
  62. {
  63. }
  64. }
  65. return View(q2);
  66. }
  67. [Authorize(Roles = "Admin")]
  68. public ActionResult ConfirmTestXml(int id)
  69. {
  70. var ed = (from i in DbUtil.Db.ExtraDatas
  71. where i.Id == id
  72. select i).SingleOrDefault();
  73. if (ed == null)
  74. return Content("no data");
  75. var m = Util.DeSerialize<OnlineRegModel>(ed.Data);
  76. return Content(ed.Data, contentType: "text/xml");
  77. }
  78. //[Authorize(Roles = "Admin")]
  79. //public ActionResult ConfirmTest(int? start, int? count)
  80. //{
  81. // IEnumerable<ExtraDatum> q;
  82. // q = from ed in DbUtil.Db.ExtraDatas
  83. // //where ed.Data.Contains("<OnlineRegModel ")
  84. // where ed.Data.Contains("<OnlineRegModel xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"")
  85. // orderby ed.Stamp descending
  86. // select ed;
  87. // var list = q.Skip(start ?? 0).Take(count ?? 200).ToList();
  88. // var q2 = new List<ConfirmTestInfo>();
  89. // foreach (var ed in list)
  90. // {
  91. // var xml = ed.Data.Replace(@"<OnlineRegModel xmlns=""http://schemas.datacontract.org/2004/07/CmsWeb.Models"" xmlns:i=""http://www.w3.org/2001/XMLSchema-instance"">", @"<OnlineRegModel>")
  92. // .Replace(" i:", " ")
  93. // .Replace(@"xmlns:a=""http://schemas.datacontract.org/2004/07/CmsData""", "")
  94. // .Replace(@"xmlns:a=""http://schemas.microsoft.com/2003/10/Serialization/Arrays""", "")
  95. // .Replace(@"_x003E_k__BackingField", "")
  96. // .Replace(@"_x003C_", "")
  97. // .Replace(@"<_", "<")
  98. // .Replace(@"</_", "</")
  99. // .Replace(@" a:", " ")
  100. // .Replace(@"<a:", "<")
  101. // .Replace(@"</a:", "</")
  102. // ;
  103. // var x = XDocument.Parse(xml);
  104. // var m = new OnlineRegModel();
  105. // m.divid = EleVal(x.Root, "Divid").ToInt2();
  106. // m.orgid = EleVal(x.Root,"Orgid").ToInt2();
  107. // m.masterorgid = EleVal(x.Root,"Masterorgid").ToInt2();
  108. // m.username = (EleVal(x.Root, "Username") ?? EleVal(x.Root, "username"));
  109. // m.List = new List<OnlineRegPersonModel>();
  110. // foreach (var e in x.Descendants("OnlineRegPersonModel"))
  111. // {
  112. // m.List.Add(new OnlineRegPersonModel
  113. // {
  114. // PeopleId = e.Element("PeopleId").Value.ToInt2(),
  115. // first = e.Element("first").Value,
  116. // last = e.Element("last").Value,
  117. // orgid = e.Element("orgid").Value.ToInt2(),
  118. // dob = e.Element("dob").Value,
  119. // phone = e.Element("phone").Value,
  120. // email = e.Element("email").Value,
  121. // mname = e.Element("mname").Value,
  122. // fname = e.Element("fname").Value,
  123. // ShowAddress = e.Element("ShowAddress").Value.ToBool(),
  124. // address = e.Element("address").Value,
  125. // city = e.Element("city").Value,
  126. // });
  127. // }
  128. // try
  129. // {
  130. // var i = new ConfirmTestInfo
  131. // {
  132. // ed = ed,
  133. // m = m
  134. // };
  135. // q2.Add(i);
  136. // }
  137. // catch (Exception)
  138. // {
  139. // }
  140. // }
  141. // return View(q2);
  142. //}
  143. [Authorize(Roles = "Admin")]
  144. public ActionResult TransactionTest(int? id, int? count)
  145. {
  146. var q = from ed in DbUtil.Db.ExtraDatas
  147. where ed.Data.StartsWith("<TransactionInfo ")
  148. where ed.Id >= id
  149. orderby ed.Stamp descending
  150. select ed;
  151. var list = q.Take(count ?? 1000).ToList();
  152. var q2 = from ed in list
  153. let s = ed.Data.Replace("CMSWeb.Models", "CmsWeb.Models")
  154. select new TransactionTestInfo
  155. {
  156. ed = ed,
  157. ti = Util.DeSerialize<TransactionInfo>(s) as TransactionInfo
  158. };
  159. return View(q2);
  160. }
  161. }
  162. }