PrinterInfo.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. using Newtonsoft.Json;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Runtime.Serialization;
  5. using System.Xml.Serialization;
  6. namespace fis.Win.Dev.Managers.Interfaces.Printer
  7. {
  8. [JsonObject(MemberSerialization.OptIn)]
  9. public class PrinterInfo : ISerializable
  10. {
  11. [JsonProperty(PropertyName = "Name")]
  12. public string Name { get; set; }
  13. [JsonProperty(PropertyName = "PageSize")]
  14. public string PageSize { get; set; }
  15. [JsonProperty(PropertyName = "PageOrientation")]
  16. public string PageOrientation { get; set; }
  17. [JsonProperty(PropertyName = "PageOrientationList")]
  18. public List<string> PageOrientationList { get; set; }
  19. [JsonProperty(PropertyName = "PageSizeList")]
  20. public List<string> PageSizeList { get; set; }
  21. [JsonProperty(PropertyName = "Manufacturer")]
  22. public string Manufacturer { get; set; }
  23. public PrinterInfo()
  24. {
  25. }
  26. protected PrinterInfo(SerializationInfo info, StreamingContext context)
  27. {
  28. Name = (string)info.GetValue("Name", typeof(string));
  29. PageSize = (string)info.GetValue("PageSize", typeof(string));
  30. PageOrientation = (string)info.GetValue("PageOrientation", typeof(string));
  31. PageOrientationList = (List<string>)info.GetValue("PageOrientationList", typeof(List<string>));
  32. PageSizeList = (List<string>)info.GetValue("PageSizeList", typeof(List<string>));
  33. Manufacturer = (string)info.GetValue("Manufacturer", typeof(string));
  34. }
  35. public virtual void GetObjectData(SerializationInfo info, StreamingContext context)
  36. {
  37. info.AddValue("Name", Name);
  38. info.AddValue("PageSize", PageSize);
  39. info.AddValue("PageOrientation", PageOrientation);
  40. info.AddValue("PageOrientationList", PageOrientationList);
  41. info.AddValue("PageSizeList", PageSizeList);
  42. info.AddValue("Manufacturer", Manufacturer);
  43. }
  44. }
  45. /// <summary>
  46. /// The network printer info.
  47. /// </summary>
  48. [JsonObject(MemberSerialization.OptIn)]
  49. public class NetworkPrinterInfo : PrinterInfo
  50. {
  51. /// <summary>
  52. /// Gets or sets the IP address.
  53. /// </summary>
  54. [JsonProperty(PropertyName = "IPAddress")]
  55. public string IPAddress { get; set; }
  56. public override void GetObjectData(SerializationInfo info, StreamingContext context)
  57. {
  58. base.GetObjectData(info, context);
  59. info.AddValue("IPAddress", IPAddress);
  60. }
  61. }
  62. /// <summary>
  63. /// The remote maintenance script execute result info.
  64. /// </summary>
  65. [Serializable]
  66. public class ExecuteResultInfo : ISerializable
  67. {
  68. /// <summary>
  69. /// Gets or sets the action type.
  70. /// </summary>
  71. public string ActionType { get; set; }
  72. /// <summary>
  73. /// Gets or sets the action result.
  74. /// </summary>
  75. public string Result { get; set; }
  76. public void GetObjectData(SerializationInfo info, StreamingContext context)
  77. {
  78. info.AddValue("ActionType", ActionType);
  79. info.AddValue("Result", Result);
  80. }
  81. }
  82. /// <summary>
  83. /// The printer setting info or result from ultrasonic machine.
  84. /// </summary>
  85. [Serializable]
  86. public class PrinterSettingInfo : ISerializable
  87. {
  88. /// <summary>
  89. /// Gets or sets the printers.
  90. /// </summary>
  91. public List<PrinterInfo> Printers { get; set; }
  92. /// <summary>
  93. /// Gets or sets the execute result.
  94. /// </summary>
  95. public ExecuteResultInfo ExecuteResult { get; set; }
  96. public void GetObjectData(SerializationInfo info, StreamingContext context)
  97. {
  98. info.AddValue("Printers", Printers);
  99. info.AddValue("ExecuteResult", ExecuteResult);
  100. }
  101. }
  102. }