DataModel.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Threading;
  5. using System.Threading.Tasks;
  6. using Comal.Classes;
  7. using InABox.Clients;
  8. using InABox.Configuration;
  9. using InABox.Core;
  10. using InABox.Mobile;
  11. using InABox.Rpc;
  12. namespace PRS.Mobile
  13. {
  14. public class GPSEventArgs : EventArgs
  15. {
  16. }
  17. public delegate void GPSLocationUpdatedEvent(GPSEventArgs args);
  18. public class BluetoothEventArgs : EventArgs
  19. {
  20. }
  21. public delegate void BluetoothScanFinishedEvent(BluetoothEventArgs args);
  22. public class DataModel : IModelHost
  23. {
  24. public event GPSLocationUpdatedEvent GPSLocationUpdated;
  25. public event BluetoothScanFinishedEvent BluetoothScanFinished;
  26. /// <summary>
  27. /// All Active Employees of the Company
  28. /// </summary>
  29. public EmployeeDetailModel CurrentEmployee { get; private set; }
  30. private readonly object _employeelock = new object();
  31. private EmployeeDetailShell _me;
  32. /// <summary>
  33. /// EmployeeDetails for Currently Logged in User
  34. /// </summary>
  35. public EmployeeDetailShell Me
  36. {
  37. get
  38. {
  39. lock (_employeelock)
  40. {
  41. if (_me == null)
  42. {
  43. CurrentEmployee.Refresh(false);
  44. _me = CurrentEmployee.FirstOrDefault(x => x.UserID == ClientFactory.UserGuid);
  45. }
  46. }
  47. return _me;
  48. }
  49. }
  50. /// <summary>
  51. /// All Active Employees of the Company
  52. /// </summary>
  53. public EmployeeModel Employees { get; private set; }
  54. /// <summary>
  55. /// All Employee Teams for the Company
  56. /// Should this be just teams I am a part of, or all available teams
  57. /// Need to implement a Security Token to differentiate
  58. /// </summary>
  59. public EmployeeTeamModel EmployeeTeams { get; private set; }
  60. /// <summary>
  61. /// Current Employee Form Instances for this employee
  62. /// </summary>
  63. public EmployeeFormModel EmployeeForms { get; private set; }
  64. public EmployeeQualificationModel EmployeeQualifications { get; private set; }
  65. /// <summary>
  66. /// Available Activity Codes for this Employee
  67. /// </summary>
  68. public ActivityModel Activities { get; private set; }
  69. /// <summary>
  70. /// All Available Contacts - used in Deliveries
  71. /// </summary>
  72. public ContactModel Contacts { get; private set; }
  73. /// <summary>
  74. /// All Defined Bluetooth-enabled Gates
  75. /// </summary>
  76. public BluetoothGateModel BluetoothGates { get; private set; }
  77. /// <summary>
  78. /// Unprocessed Timesheets for Currently Logged in User
  79. /// </summary>
  80. public TimeSheetModel TimeSheets { get; private set; }
  81. /// <summary>
  82. /// List of Jobs that Currently Logged in User has access To
  83. /// </summary>
  84. public JobModel Jobs { get; private set; }
  85. /// <summary>
  86. /// List of Assignments for ??? need to specify this.
  87. /// Can I see other people's assignments? (Security Token)
  88. /// How far back / forward can I look.
  89. /// This smells Transient, or maybe split into lookups (for all)
  90. /// and shells (for mine)
  91. /// Possibly need a back/forward window as well?
  92. /// </summary>
  93. public AssignmentModel Assignments { get; private set; }
  94. /// <summary>
  95. /// Master Product Catalogue for the company
  96. /// This should be split into Lookups and Shells
  97. /// </summary>
  98. public ProductModel Products { get; private set; }
  99. /// <summary>
  100. /// Master Supplier List for Lookups, etc
  101. /// </summary>
  102. public SupplierModel Suppliers { get; private set; }
  103. public ConsignmentTypeModel ConsignmentTypes { get; private set; }
  104. /// <summary>
  105. /// Master List of Dimension Units for the company
  106. /// </summary>
  107. public ProductDimensionUnitModel ProductDimensionUnits { get; private set; }
  108. /// <summary>
  109. /// Master Product Groups List (Lookup?)
  110. /// </summary>
  111. public ProductGroupModel ProductGroups { get; private set; }
  112. /// <summary>
  113. /// Master Product Styles List (Lookup?)
  114. /// </summary>
  115. public ProductStyleModel ProductStyles { get; private set; }
  116. /// <summary>
  117. /// All GPS Tracker Devices registered by the company
  118. /// </summary>
  119. public GPSTrackerModel GPSTrackers { get; private set; }
  120. /// <summary>
  121. /// Master Equipment Register
  122. /// </summary>
  123. public EquipmentModel Equipment { get; private set; }
  124. /// <summary>
  125. /// Master List of Equipment Groups
  126. /// </summary>
  127. public EquipmentGroupModel EquipmentGroups { get; private set; }
  128. /// <summary>
  129. /// Master List of Available Delivery Types
  130. /// </summary>
  131. public DeliveryTypeModel DeliveryTypes { get; private set; }
  132. /// <summary>
  133. /// List of all Deliveries
  134. /// hmmm.. should be configurable?
  135. /// </summary>
  136. public DeliveryModel Deliveries { get; private set; }
  137. /// <summary>
  138. /// List of all available Delivery Barcodes
  139. /// hmmm.. should be configurable?
  140. /// </summary>
  141. public DeliveryItemModel DeliveryItems { get; private set; }
  142. public RequisitionDestinationModel RequisitionDestinations { get; private set; }
  143. /// <summary>
  144. /// My Notifications (open only?)
  145. /// </summary>
  146. public NotificationModel Notifications { get; private set; }
  147. /// <summary>
  148. /// All Tasks I am subscribed to
  149. /// </summary>
  150. public KanbanModel Kanbans { get; private set; }
  151. /// <summary>
  152. /// All Kanban Types
  153. /// </summary>
  154. public KanbanTypeModel KanbanTypes { get; private set; }
  155. /// <summary>
  156. /// Available Form Library - this includes all "Applies To" values
  157. /// You can filter to a specific type by using the "Search" function
  158. /// </summary>
  159. public DigitalFormModel DigitalForms { get; private set; }
  160. // The list of open task-kased forms for the current user
  161. // Specifically for us in the "Forms" module
  162. // This overlaps the "Task" module a fair amount, but it provides
  163. // an alternative paradigm for tasks
  164. public KanbanFormModel KanbanForms { get; private set; }
  165. /// <summary>
  166. /// List of Employees, along with Clock on / off status
  167. /// </summary>
  168. public InOutModel InOut { get; private set; }
  169. /// <summary>
  170. /// List of Open Purchase Orders
  171. /// </summary>
  172. public PurchaseOrderModel PurchaseOrders { get; private set; }
  173. public ManufacturingFactoryModel ManufacturingFactories { get; private set; }
  174. public StockLocationModel StockLocations { get; set; }
  175. public StockAreaModel StockAreas { get; set; }
  176. public StockWarehouseModel StockWarehouses { get; set; }
  177. public DataModel()
  178. {
  179. Reset();
  180. }
  181. public void Reset()
  182. {
  183. _me = null;
  184. CurrentEmployee = new EmployeeDetailModel(this,
  185. () => new Filter<Employee>(x => x.UserLink.ID).IsEqualTo(ClientFactory.UserGuid)
  186. );
  187. Employees = new EmployeeModel(this,
  188. LookupFactory.DefineFilter<Employee>
  189. );
  190. EmployeeTeams = new EmployeeTeamModel(this,
  191. () => new Filter<EmployeeTeam>(x => x.EmployeeLink.ID)
  192. .InQuery(LookupFactory.DefineFilter<Employee>(), x => x.ID)
  193. );
  194. EmployeeForms = new EmployeeFormModel(this,
  195. () => new Filter<EmployeeForm>(x => x.Parent.ID).IsEqualTo(App.Data.Me.ID)
  196. );
  197. EmployeeQualifications = new EmployeeQualificationModel(this,
  198. () => new Filter<EmployeeQualification>(x => x.Employee.ID).IsEqualTo(App.Data.Me.ID)
  199. );
  200. Activities = new ActivityModel(this,
  201. () => new Filter<EmployeeActivity>(x => x.Employee.ID).IsEqualTo(App.Data.Me.ID)
  202. );
  203. InOut = new InOutModel(this,
  204. () => new Filters<Employee>()
  205. .Add(LookupFactory.DefineFilter<Employee>())
  206. .Add(new Filter<Employee>(x=>x.ID).IsNotEqualTo(App.Data.Me.ID).And(x=>x.ShowOnInOutBoard).IsEqualTo(true))
  207. .Combine()!
  208. );
  209. Jobs = new JobModel(this,
  210. MyJobsFilter,
  211. CoreRepository.CacheFileName<Job>
  212. );
  213. Products = new ProductModel(this,
  214. LookupFactory.DefineFilter<Product>,
  215. CoreRepository.CacheFileName<Product>
  216. );
  217. Suppliers = new SupplierModel(this,
  218. LookupFactory.DefineFilter<Supplier>,
  219. CoreRepository.CacheFileName<Supplier>
  220. );
  221. ConsignmentTypes = new ConsignmentTypeModel(this,
  222. LookupFactory.DefineFilter<ConsignmentType>,
  223. CoreRepository.CacheFileName<ConsignmentType>
  224. );
  225. ProductDimensionUnits = new ProductDimensionUnitModel(this,
  226. LookupFactory.DefineFilter<ProductDimensionUnit>,
  227. () => null);
  228. ProductGroups = new ProductGroupModel(this,
  229. LookupFactory.DefineFilter<ProductGroup>,
  230. CoreRepository.CacheFileName<ProductGroup>
  231. );
  232. ProductStyles = new ProductStyleModel(this,
  233. LookupFactory.DefineFilter<ProductStyle>
  234. );
  235. GPSTrackers = new GPSTrackerModel(this,
  236. LookupFactory.DefineFilter<GPSTracker>
  237. );
  238. Equipment = new EquipmentModel(this,
  239. () =>
  240. {
  241. var filters = new Filters<Equipment>();
  242. filters.Add(LookupFactory.DefineFilter<Equipment>());
  243. if (!Security.IsAllowed<CanViewPrivateEquipment>())
  244. filters.Add(new Filter<Equipment>(x => x.Private).IsEqualTo(false));
  245. return filters!.Combine();
  246. },
  247. CoreRepository.CacheFileName<Equipment>
  248. );
  249. EquipmentGroups = new EquipmentGroupModel(this,
  250. LookupFactory.DefineFilter<EquipmentGroup>
  251. );
  252. DeliveryTypes= new DeliveryTypeModel(this,
  253. null,
  254. CoreRepository.CacheFileName<DeliveryType>);
  255. Deliveries = new DeliveryModel(this);
  256. DeliveryItems = new DeliveryItemModel(this,
  257. LookupFactory.DefineFilter<DeliveryItem>
  258. );
  259. RequisitionDestinations = new RequisitionDestinationModel(this,
  260. null,
  261. CoreRepository.CacheFileName<RequisitionDestination>
  262. );
  263. Notifications = new NotificationModel(this,
  264. () => new Filter<Notification>(x=>x.Employee.ID).IsEqualTo(App.Data.Me.ID)
  265. .And(new Filter<Notification>(x=>x.Closed).IsEqualTo(DateTime.MinValue)
  266. .Or(x=>x.Created).IsGreaterThanOrEqualTo(DateTime.Today.AddDays(-90)))
  267. );
  268. TimeSheets = new TimeSheetModel(this,
  269. () => new Filter<TimeSheet>(x=>x.Processed).IsEqualTo(DateTime.MinValue)
  270. .And(x=>x.EmployeeLink.ID).IsEqualTo(App.Data.Me.ID)
  271. );
  272. Assignments = new AssignmentModel(this,
  273. () => new Filter<Assignment>(x => x.Date).IsGreaterThanOrEqualTo(DateTime.Today.AddDays(-90))
  274. .And(x => x.Date).IsLessThanOrEqualTo(DateTime.Today.AddDays(90))
  275. );
  276. Contacts = new ContactModel(this,
  277. () => LookupFactory.DefineFilter<Contact>()
  278. );
  279. Kanbans = new KanbanModel(this,
  280. () => new Filter<Kanban>(x => x.ID)
  281. .InQuery(new Filter<KanbanSubscriber>(x=>x.Employee.ID).IsEqualTo(App.Data.Me.ID), x=>x.Kanban.ID)
  282. .And(
  283. new Filter<Kanban>(x=>x.Status).IsNotEqualTo(KanbanStatus.Complete)
  284. .Or(x=>x.Completed).IsGreaterThanOrEqualTo(DateTime.Today.AddDays(-7)
  285. )
  286. ),
  287. CoreRepository.CacheFileName<Kanban>
  288. );
  289. KanbanTypes = new KanbanTypeModel(this);
  290. BluetoothGates = new BluetoothGateModel(this,
  291. () => new Filter<JobTracker>(x => x.Active).IsEqualTo(true)
  292. );
  293. DigitalForms = new DigitalFormModel(this,
  294. () => new Filter<EmployeeDigitalForm>(x => x.Employee.ID).IsEqualTo(App.Data.Me.ID)
  295. .And(x => x.Form.Active).IsEqualTo(true)
  296. );
  297. KanbanForms = new KanbanFormModel(this,
  298. () => new Filter<KanbanForm>(x=>x.Parent.EmployeeLink.ID).IsEqualTo(App.Data.Me.ID)
  299. .And(new Filter<KanbanForm>(x=>x.FormCompleted).IsEqualTo(DateTime.MinValue)
  300. .Or(x=>x.FormCompleted).IsGreaterThanOrEqualTo(DateTime.Today.AddDays(-7)))
  301. );
  302. PurchaseOrders = new PurchaseOrderModel(this,
  303. () => new Filter<PurchaseOrder>(x => x.ClosedDate).IsEqualTo(DateTime.MinValue)
  304. );
  305. ManufacturingFactories = new ManufacturingFactoryModel(this);
  306. StockLocations = new StockLocationModel(this,
  307. null,
  308. CoreRepository.CacheFileName<StockLocation>
  309. );
  310. StockAreas = new StockAreaModel(this,
  311. null,
  312. CoreRepository.CacheFileName<StockArea>
  313. );
  314. StockWarehouses = new StockWarehouseModel(this,
  315. null,
  316. CoreRepository.CacheFileName<StockWarehouse>
  317. );
  318. }
  319. private static Filter<Job> MyJobsFilter()
  320. {
  321. return Security.IsAllowed<CanViewAllJobs>()
  322. ? new Filter<Job>(X => X.Completed).IsEqualTo(DateTime.MinValue)
  323. .And(x => x.JobStatus.Active).IsEqualTo(true)
  324. : new Filter<Job>(X => X.Completed).IsEqualTo(DateTime.MinValue)
  325. .And(x => x.JobStatus.Active).IsEqualTo(true)
  326. .And(x => x.ID).InQuery(
  327. new Filter<JobEmployee>(x => x.EmployeeLink.ID).IsEqualTo(App.Data.Me.ID),
  328. x => x.JobLink.ID
  329. );
  330. }
  331. public void Setup()
  332. {
  333. // Clear All Transient Caches
  334. Reset();
  335. // Always load the current Employee and Security Tokens
  336. Task[] init = new Task[]
  337. {
  338. Task.Run(() => { CurrentEmployee.Refresh(true); }),
  339. Task.Run(() => { Security.CheckTokens(); })
  340. };
  341. Task.WaitAll(init);
  342. App.Bluetooth.OnScanFinished += OnBluetoothScanFinished;
  343. App.GPS.OnLocationFound += OnGPSLocationFound;
  344. App.Transport.OnOpen += OnTransportConnected;
  345. App.Transport.OnClose += OnTransportDisconnected;
  346. DigitalFormDocumentFactory.Init(
  347. new MobileDigitalFormDocumentHandler(
  348. b =>
  349. {
  350. IsBackgroundUpdateStatusActive = b;
  351. BackgroundUpdateStatusChanged?.Invoke(this, EventArgs.Empty);
  352. })
  353. );
  354. DigitalFormDocumentFactory.Run();
  355. StartUpdateQueue();
  356. }
  357. public bool IsBackgroundUpdateStatusActive { get; private set; }
  358. public event BackgroundUpdateStatusEvent BackgroundUpdateStatusChanged;
  359. public bool IsConnected() => App.Transport?.IsConnected() == true;
  360. public event TransportDisconnectedEvent TransportDisconnected;
  361. public event TransportConnectedEvent TransportConnected;
  362. private void OnTransportDisconnected(IRpcTransport transport, RpcTransportCloseArgs e)
  363. {
  364. DigitalFormDocumentFactory.Stop();
  365. TransportDisconnected?.Invoke(new TransportDisconnectedEventArgs());
  366. Task.Run(() =>
  367. {
  368. ValidationStatus status = ValidationStatus.INVALID;
  369. while (status != ValidationStatus.VALID)
  370. {
  371. try
  372. {
  373. while (!IsConnected())
  374. {
  375. try
  376. {
  377. App.Transport.Connect();
  378. }
  379. catch (Exception eConnect)
  380. {
  381. MobileLogging.Log($"Reconnect() {eConnect.Message} \n {eConnect.StackTrace}");
  382. Task.Delay(TimeSpan.FromMilliseconds(1000));
  383. }
  384. }
  385. status = ClientFactory.Validate(ClientFactory.SessionID);
  386. if (status != ValidationStatus.VALID)
  387. {
  388. ClientFactory.InvalidateUser();
  389. var settings = new LocalConfiguration<MobileDatabaseSettings>().LoadAll().Values
  390. .FirstOrDefault(x => x.IsDefault);
  391. if (settings != null)
  392. {
  393. var userid = settings.UserID;
  394. var password = settings.Password;
  395. status = ClientFactory.Validate(userid, password);
  396. if (status != ValidationStatus.VALID)
  397. break;
  398. }
  399. }
  400. }
  401. catch (Exception ex)
  402. {
  403. MobileLogging.Log($"Revalidate() {ex.Message} \n {ex.StackTrace}");
  404. Task.Delay(TimeSpan.FromMilliseconds(1000));
  405. }
  406. }
  407. DigitalFormDocumentFactory.Run();
  408. });
  409. }
  410. private void OnTransportConnected(IRpcTransport transport, RpcTransportOpenArgs e)
  411. {
  412. TransportConnected?.Invoke(new TransportConnectedEventArgs());
  413. }
  414. #region QueueUpdaterSupport
  415. private CancellationTokenSource? _cancelQueueUpdate;
  416. private List<IQueueUpdater> _updateQueues = new();
  417. private void StartUpdateQueue()
  418. {
  419. StopUpdateQueue();
  420. _cancelQueueUpdate = new CancellationTokenSource();
  421. Task.Run(
  422. () =>
  423. {
  424. while (_cancelQueueUpdate?.IsCancellationRequested != true)
  425. {
  426. foreach (var queue in _updateQueues.ToArray())
  427. queue.ProcessQueue();
  428. Thread.Sleep(100);
  429. }
  430. },
  431. _cancelQueueUpdate.Token
  432. );
  433. }
  434. private void StopUpdateQueue()
  435. {
  436. if (_cancelQueueUpdate != null)
  437. {
  438. _cancelQueueUpdate.Cancel();
  439. _cancelQueueUpdate.Dispose();
  440. _cancelQueueUpdate = null;
  441. }
  442. }
  443. public void AddUpdateQueue<TEntity>(QueueUpdater<TEntity> queue)
  444. where TEntity : Entity, IPersistent, IRemotable, new()
  445. {
  446. _updateQueues.Add(queue);
  447. }
  448. public void RemoveUpdateQueue<TEntity>(QueueUpdater<TEntity> queue)
  449. where TEntity : Entity, IPersistent, IRemotable, new()
  450. {
  451. _updateQueues.Remove(queue);
  452. }
  453. #endregion
  454. private Location _lastgpslocation = new Location();
  455. private GPSTrackerLocation GetGPSTrackerUpdate(string deviceid, Location location,
  456. TimeSpan threshold, double distance)
  457. {
  458. GPSTrackerShell tracker = GPSTrackers.FirstOrDefault(x => x.DeviceID.Equals(deviceid));
  459. if (tracker != null)
  460. {
  461. if ((tracker.Timestamp < location.Timestamp.Subtract(threshold)) || (tracker.Location.DistanceTo(location, UnitOfLength.Kilometers) > distance))
  462. {
  463. GPSTrackerLocation gpsTrackerLocation = new GPSTrackerLocation();
  464. gpsTrackerLocation.DeviceID = tracker.DeviceID;
  465. gpsTrackerLocation.Tracker.ID = tracker.ID;
  466. gpsTrackerLocation.Location = location;
  467. return gpsTrackerLocation;
  468. }
  469. }
  470. return null;
  471. }
  472. private void OnGPSLocationFound(LocationServices sender)
  473. {
  474. if (_lastgpslocation.Timestamp < DateTime.Now.Subtract(TimeSpan.FromMinutes(2)))
  475. {
  476. var devicelocation = new InABox.Core.Location()
  477. {
  478. Latitude = App.GPS.Latitude,
  479. Longitude = App.GPS.Longitude,
  480. Timestamp = App.GPS.TimeStamp,
  481. Address = App.GPS.Address
  482. };
  483. GPSTrackers.Refresh(false);
  484. var update = GetGPSTrackerUpdate(MobileUtils.GetDeviceID(), devicelocation, TimeSpan.FromMinutes(2),
  485. 0.1);
  486. if (update != null)
  487. new Client<GPSTrackerLocation>().Save(update, "Updated via Mobile Device", (o, e) => { });
  488. }
  489. GPSLocationUpdated?.Invoke(new GPSEventArgs());
  490. }
  491. private void OnBluetoothScanFinished(Bluetooth sender)
  492. {
  493. UploadTiles();
  494. BluetoothScanFinished?.Invoke(new BluetoothEventArgs());
  495. }
  496. private void UploadTiles()
  497. {
  498. try
  499. {
  500. if (App.GPS.Latitude.Equals(0.0F) && App.GPS.Longitude.Equals(0.0F))
  501. return;
  502. if (App.Bluetooth.DetectedBlueToothMACAddresses.Count == 0)
  503. return;
  504. var devicelocation = new InABox.Core.Location()
  505. {
  506. Latitude = App.GPS.Latitude,
  507. Longitude = App.GPS.Longitude,
  508. Timestamp = App.GPS.TimeStamp,
  509. Address = App.GPS.Address
  510. };
  511. GPSTrackers.Refresh(true);
  512. List<GPSTrackerLocation> updates = new List<GPSTrackerLocation>();
  513. foreach (String deviceid in App.Bluetooth.DetectedBlueToothMACAddresses)
  514. {
  515. var update = GetGPSTrackerUpdate(deviceid, devicelocation, TimeSpan.FromMinutes(2), 0.1);
  516. if (update != null)
  517. updates.Add(update);
  518. }
  519. if (updates.Any())
  520. new Client<GPSTrackerLocation>().Save(updates, $"Updated by Mobile {MobileUtils.GetDeviceID()}",
  521. (o, e) => { });
  522. }
  523. catch (Exception ex)
  524. {
  525. MobileLogging.Log($"UploadTiles() {ex.Message} \n {ex.StackTrace}");
  526. }
  527. }
  528. }
  529. }