Brak opisu

Models.cs 14KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Runtime.InteropServices;
  5. using System.Security;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using Newtonsoft.Json;
  9. using Newtonsoft.Json.Serialization;
  10. namespace BulkPrinting
  11. {
  12. public class SavedSettings {
  13. [JsonProperty("vendorId")]
  14. public int VendorId { get; set; }
  15. [JsonProperty("userId")]
  16. public int UserId { get; set; }
  17. [JsonProperty("username")]
  18. public string Username { get; set; }
  19. }
  20. public enum SessionModes {
  21. Invalid = 0,
  22. Offline = 1,
  23. Online = 2
  24. }
  25. public class MaxException
  26. {
  27. [JsonProperty("code")]
  28. public int? Code { get; set; }
  29. [JsonProperty("error")]
  30. public string Error { get; set; }
  31. }
  32. public class LoginData
  33. {
  34. [JsonProperty("vendorId")]
  35. public int VendorId { get; set; }
  36. [JsonProperty("serialNumber")]
  37. public string SerialNumber { get; set; }
  38. [JsonProperty("userId")]
  39. public int UserId { get; set; }
  40. [JsonProperty("username")]
  41. public string Username { get; set; }
  42. [JsonProperty("password")]
  43. public string Password
  44. {
  45. get
  46. {
  47. if (SecurePassword != null)
  48. {
  49. IntPtr valuePtr = IntPtr.Zero;
  50. try
  51. {
  52. valuePtr = Marshal.SecureStringToGlobalAllocUnicode(SecurePassword);
  53. return Marshal.PtrToStringUni(valuePtr);
  54. }
  55. finally
  56. {
  57. Marshal.ZeroFreeGlobalAllocUnicode(valuePtr);
  58. }
  59. }
  60. return null;
  61. }
  62. }
  63. public SecureString SecurePassword;
  64. }
  65. public class OrderPlacementData
  66. {
  67. [JsonProperty("productId")]
  68. public int ProductId { get; set; }
  69. [JsonProperty("quantity")]
  70. public int Quantity { get; set; }
  71. [JsonProperty("customerReference")]
  72. public string CustomerReference { get; set; }
  73. [JsonProperty("internalReference")]
  74. public string InternalReference { get; set; }
  75. }
  76. public class Warehouse
  77. {
  78. [JsonProperty("id")]
  79. public int Id { get; set; }
  80. [JsonProperty("name")]
  81. public string Name { get; set; }
  82. }
  83. public enum AccountStatus
  84. {
  85. Unknown,
  86. Enabled,
  87. Suspended,
  88. Closed
  89. }
  90. public class Account
  91. {
  92. [JsonProperty("id")]
  93. public int Id { get; set; }
  94. [JsonProperty("name")]
  95. public string Name { get; set; }
  96. [JsonProperty("status")]
  97. public AccountStatus Status { get; set; }
  98. [JsonProperty("reference")]
  99. public string Reference { get; set; }
  100. [JsonProperty("warehouse")]
  101. public Warehouse Warehouse { get; set; }
  102. [JsonProperty("balance")]
  103. public decimal Balance { get; set; }
  104. }
  105. public class Vendor
  106. {
  107. [JsonProperty("Id")]
  108. public int id { get; set; }
  109. [JsonProperty("SerialNumber")]
  110. public string serialNumber { get; set; }
  111. [JsonProperty("AccountId")]
  112. public int accountId { get; set; }
  113. }
  114. public enum UserLevel
  115. {
  116. Unknown = 0,
  117. Administrator = 4,
  118. CustomUser = 6
  119. }
  120. public class User
  121. {
  122. [JsonProperty("id")]
  123. public int Id { get; set; }
  124. [JsonProperty("username")]
  125. public string Username { get; set; }
  126. [JsonProperty("firstName")]
  127. public string FirstName { get; set; }
  128. [JsonProperty("surname")]
  129. public string Surname { get; set; }
  130. [JsonProperty("account")]
  131. public Account Account { get; set; }
  132. [JsonProperty("enabled")]
  133. public bool Enabled { get; set; }
  134. [JsonProperty("level")]
  135. public int Level { get; set; }
  136. [JsonProperty("system")]
  137. public int System { get; set; }
  138. [JsonProperty("lastLogin")]
  139. public DateTime LastLogin { get; set; }
  140. [JsonProperty("canPrintOnline")]
  141. public bool CanPrintOnline { get; set; }
  142. [JsonProperty("onlinePrintValue")]
  143. public decimal OnlinePrintValue { get; set; }
  144. [JsonProperty("canReprintOnline")]
  145. public bool CanReprintOnline { get; set; }
  146. [JsonProperty("onlineReprintValue")]
  147. public decimal OnlineReprintValue { get; set; }
  148. [JsonProperty("canPrintOffline")]
  149. public bool CanPrintOffline { get; set; }
  150. [JsonProperty("offlinePrintValue")]
  151. public decimal OfflinePrintValue { get; set; }
  152. [JsonProperty("canReprintOffline")]
  153. public bool CanReprintOffline { get; set; }
  154. [JsonProperty("offlineReprintValue")]
  155. public decimal OfflineReprintValue { get; set; }
  156. [JsonProperty("bulkExport")]
  157. public bool BulkExport { get; set; }
  158. [JsonProperty("bulkReExport")]
  159. public bool BulkReExport { get; set; }
  160. [JsonProperty("bulkExportMaxValue")]
  161. public decimal BulkExportMaxValue { get; set; }
  162. [JsonProperty("bulkOrder")]
  163. public bool BulkOrder { get; set; }
  164. [JsonProperty("bulkOrderMaxValue")]
  165. public decimal BulkOrderMaxValue { get; set; }
  166. [JsonProperty("bulkViewPins")]
  167. public bool BulkViewPins { get; set; }
  168. }
  169. public class Payload
  170. {
  171. [JsonProperty("date")]
  172. public DateTime Date { get; set; }
  173. [JsonProperty("nonce")]
  174. public string Nonce { get; set; }
  175. [JsonProperty("user")]
  176. public User User { get; set; }
  177. [JsonProperty("vendor")]
  178. public Vendor Vendor { get; set; }
  179. [JsonProperty("encryptedDatabasePassword")]
  180. public byte[] EncryptedDatabasePassword { get; set; }
  181. [JsonProperty("encryptedVoucherKey")]
  182. public byte[] EncryptedVoucherKey { get; set; }
  183. }
  184. public class Credentials
  185. {
  186. public string responsePayload;
  187. [JsonProperty("payload")]
  188. public string payloadBase64
  189. {
  190. get
  191. {
  192. return Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(Globals.SessionData.Credentials.Payload)));
  193. }
  194. set
  195. {
  196. this.responsePayload = value;
  197. this.Payload = JsonConvert.DeserializeObject<Payload>(Encoding.UTF8.GetString(Convert.FromBase64String(value)));
  198. }
  199. }
  200. [JsonIgnore]
  201. public Payload Payload { get; set; }
  202. [JsonProperty("salt")]
  203. public byte[] Salt { get; set; }
  204. [JsonProperty("iterations")]
  205. public int Iterations { get; set; }
  206. [JsonProperty("signature")]
  207. public byte[] Signature { get; set; }
  208. }
  209. public class OKResponse
  210. {
  211. [JsonProperty("access_token")]
  212. public string AccessToken { get; set; }
  213. [JsonProperty("credentials")]
  214. public Credentials Credentials { get; set; }
  215. [JsonProperty("expires_in")]
  216. public int ExpiresIn { get; set; }
  217. }
  218. public class OrderData {
  219. [JsonProperty("productId")]
  220. public int ProductId { get; set; }
  221. [JsonProperty("quantity")]
  222. public int Quantity { get; set; }
  223. [JsonProperty("customerReference")]
  224. public string CustomerReference { get; set; }
  225. }
  226. public class NetworkCatalogue
  227. {
  228. public override string ToString() {
  229. return this.Name;
  230. }
  231. [JsonProperty("id")]
  232. public int Id { get; set; }
  233. [JsonProperty("name")]
  234. public string Name { get; set; }
  235. [JsonProperty("products")]
  236. public ICollection<ProductSubCatalogue> Products { get; set; }
  237. }
  238. public class ProductSubCatalogue
  239. {
  240. public override string ToString()
  241. {
  242. return this.Description;
  243. }
  244. [JsonProperty("id")]
  245. public int Id { get; set; }
  246. [JsonProperty("voucherType")]
  247. public int VoucherType { get; set; }
  248. [JsonProperty("description")]
  249. public string Description { get; set; }
  250. [JsonProperty("faceValue")]
  251. public decimal FaceValue { get; set; }
  252. [JsonProperty("discountPercentage")]
  253. public decimal DiscountPercentage { get; set; }
  254. }
  255. public class BatchListing {
  256. [JsonProperty("batch")]
  257. public Batch Batch { get; set; }
  258. [JsonProperty("remainingBalance")]
  259. public decimal RemainingBalance { get; set; }
  260. }
  261. public class Batch
  262. {
  263. [JsonProperty("id")]
  264. public int Id { get; set; }
  265. [JsonProperty("orderDate")]
  266. public DateTime OrderDate { get; set; }
  267. [JsonProperty("orderGuid")]
  268. public string OrderGuid { get; set; }
  269. [JsonProperty("orderReference")]
  270. public string OrderReference { get; set; }
  271. [JsonProperty("internalReference")]
  272. public string InternalReference { get; set; }
  273. [JsonProperty("networkId")]
  274. public int NetworkId { get; set; }
  275. [JsonProperty("networkName")]
  276. public string NetworkName { get; set; }
  277. [JsonProperty("productId")]
  278. public int ProductId { get; set; }
  279. [JsonProperty("productDescription")]
  280. public string ProductDescription { get; set; }
  281. [JsonProperty("voucherType")]
  282. public int VoucherType { get; set; }
  283. [JsonProperty("faceValue")]
  284. public decimal FaceValue { get; set; }
  285. [JsonProperty("discountPercentage")]
  286. public decimal DiscountPercentage { get; set; }
  287. [JsonProperty("requestedQuantity")]
  288. public int RequestedQuantity { get; set; }
  289. [JsonProperty("deliveredQuantity")]
  290. public int DeliveredQuantity { get; set; }
  291. [JsonProperty("cost")]
  292. public decimal Cost { get; set; }
  293. [JsonProperty("readyForDownload")]
  294. public bool ReadyForDownload { get; set; }
  295. }
  296. public class Page<T>
  297. {
  298. [JsonProperty("items")]
  299. public List<T> Items { get; set; }
  300. [JsonProperty("totalItems")]
  301. public int TotalItems { get; set; }
  302. [JsonProperty("pageNumber")]
  303. public int PageNumber { get; set; }
  304. [JsonProperty("pageSize")]
  305. public int PageSize { get; set; }
  306. [JsonProperty("numPages")]
  307. public int NumPages { get; set; }
  308. }
  309. public enum Vouchertype
  310. {
  311. Voucher = 1,
  312. SMS = 2,
  313. Data = 3
  314. }
  315. public class Voucher
  316. {
  317. [JsonProperty("id")]
  318. public int Id { get; set; }
  319. [JsonProperty("sequenceNumber")]
  320. public int SequenceNumber { get; set; }
  321. [JsonProperty("expiryDate")]
  322. public DateTime ExpiryDate { get; set; }
  323. [JsonProperty("serial")]
  324. public string Serial { get; set; }
  325. [JsonProperty("encryptedPIN")]
  326. public string EncryptedPIN { get; set; }
  327. }
  328. public class PrintVoucher
  329. {
  330. public int SequenceNumber { get; set; }
  331. public int BatchId { get; set; }
  332. public string Serial { get; set; }
  333. public int VoucherId { get; set; }
  334. public string Description { get; set; }
  335. public string DecryptedPIN { get; set; }
  336. }
  337. public class UserLimits {
  338. public enum UserLimitTypes {
  339. OnlinePrint ,
  340. OnlineReprint,
  341. OfflinePrint,
  342. OfflineReprint,
  343. BulkExport,
  344. BulkOrder
  345. }
  346. public decimal OnlinePrintValue { get; set; }
  347. public decimal OnlineReprintValue { get; set; }
  348. public decimal OfflinePrintValue { get; set; }
  349. public decimal OfflineReprintValue { get; set; }
  350. public decimal BulkExportValue { get; set; }
  351. public decimal BulkOrderValue { get; set; }
  352. }
  353. public class VendorEvent
  354. {
  355. public enum VendorEventType
  356. {
  357. Unknown = 0,
  358. Login = 1, //Logged by Server
  359. OfflineLogin = 2,
  360. ExtendLogin = 3, //Logged by Server
  361. Logout = 4,
  362. DownloadVoucher = 5, //Logged by Server
  363. PrintVoucher = 6,
  364. ViewVoucherPIN = 7,
  365. ExportVoucher = 8
  366. }
  367. public int Id { get; set; }
  368. public int VendorId { get; set; }
  369. public int UserId { get; set; }
  370. public int? VoucherId { get; set; }
  371. public int? RemoteId { get; set; }
  372. public DateTimeOffset EventDate { get; set; }
  373. public VendorEventType EventType { get; set; }
  374. public bool Retry { get; set; }
  375. }
  376. public class EventLog {
  377. public VendorEvent.VendorEventType EventType { get; set; }
  378. public int? VoucherId { get; set; }
  379. public int? BatchId { get; set; }
  380. public bool Retry { get; set; }
  381. }
  382. public class VendorEventsMetaData {
  383. [JsonProperty("date")]
  384. public DateTimeOffset Date { get; set; }
  385. [JsonProperty("vendorId")]
  386. public int VendorId { get; set; }
  387. [JsonProperty("lastVendorEventRemoteId")]
  388. public int? LastVendorEventRemoteId { get; set; }
  389. }
  390. public class RemoteVendorEvent
  391. {
  392. [JsonProperty("Id")]
  393. public int? Id { get; set; }
  394. [JsonProperty("VendorId")]
  395. public int? VendorId { get; set; }
  396. [JsonProperty("UserId")]
  397. public int? UserId { get; set; }
  398. [JsonProperty("VoucherId")]
  399. public int? VoucherId { get; set; }
  400. [JsonProperty("EventDate")]
  401. public DateTimeOffset? EventDate { get; set; }
  402. [JsonProperty("EventType")]
  403. public VendorEvent.VendorEventType? EventType { get; set; }
  404. [JsonProperty("Retry")]
  405. public bool Retry { get; set; }
  406. }
  407. public class RemoteVendorEventResponse
  408. {
  409. [JsonProperty("lastVendorEventRemoteId")]
  410. public int LastVendorEventRemoteId { get; set; }
  411. }
  412. public class InternalReferenceResponse
  413. {
  414. [JsonProperty("internalReference")]
  415. public string InternalReference { get; set; }
  416. }
  417. public class OrderList
  418. {
  419. public string OrderDate;
  420. public string OrderReference;
  421. public string User;
  422. public string OrderCost;
  423. public string Balance;
  424. public List<OrderReportLine> OrderLines;
  425. }
  426. public class OrderReportLine {
  427. public string OrderItem;
  428. public string QtyOrdered;
  429. public string QtyDelivered;
  430. public string Cost;
  431. }
  432. }