ActivityLogEntryPoint.cs 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using MediaBrowser.Common.Configuration;
  7. using MediaBrowser.Common.Plugins;
  8. using MediaBrowser.Common.Updates;
  9. using MediaBrowser.Controller;
  10. using MediaBrowser.Controller.Authentication;
  11. using MediaBrowser.Controller.Configuration;
  12. using MediaBrowser.Controller.Devices;
  13. using MediaBrowser.Controller.Entities;
  14. using MediaBrowser.Controller.Library;
  15. using MediaBrowser.Controller.Plugins;
  16. using MediaBrowser.Controller.Session;
  17. using MediaBrowser.Controller.Subtitles;
  18. using MediaBrowser.Model.Activity;
  19. using MediaBrowser.Model.Dto;
  20. using MediaBrowser.Model.Entities;
  21. using MediaBrowser.Model.Events;
  22. using MediaBrowser.Model.Globalization;
  23. using MediaBrowser.Model.Notifications;
  24. using MediaBrowser.Model.Tasks;
  25. using MediaBrowser.Model.Updates;
  26. using Microsoft.Extensions.Logging;
  27. namespace Emby.Server.Implementations.Activity
  28. {
  29. public class ActivityLogEntryPoint : IServerEntryPoint
  30. {
  31. private readonly IInstallationManager _installationManager;
  32. //private readonly ILogger _logger;
  33. private readonly ISessionManager _sessionManager;
  34. private readonly ITaskManager _taskManager;
  35. private readonly IActivityManager _activityManager;
  36. private readonly ILocalizationManager _localization;
  37. private readonly ILibraryManager _libraryManager;
  38. private readonly ISubtitleManager _subManager;
  39. private readonly IUserManager _userManager;
  40. private readonly IServerConfigurationManager _config;
  41. private readonly IServerApplicationHost _appHost;
  42. private readonly IDeviceManager _deviceManager;
  43. public ActivityLogEntryPoint(ISessionManager sessionManager, IDeviceManager deviceManager, ITaskManager taskManager, IActivityManager activityManager, ILocalizationManager localization, IInstallationManager installationManager, ILibraryManager libraryManager, ISubtitleManager subManager, IUserManager userManager, IServerConfigurationManager config, IServerApplicationHost appHost)
  44. {
  45. _sessionManager = sessionManager;
  46. _taskManager = taskManager;
  47. _activityManager = activityManager;
  48. _localization = localization;
  49. _installationManager = installationManager;
  50. _libraryManager = libraryManager;
  51. _subManager = subManager;
  52. _userManager = userManager;
  53. _config = config;
  54. _appHost = appHost;
  55. _deviceManager = deviceManager;
  56. }
  57. public void Run()
  58. {
  59. _taskManager.TaskCompleted += _taskManager_TaskCompleted;
  60. _installationManager.PluginInstalled += _installationManager_PluginInstalled;
  61. _installationManager.PluginUninstalled += _installationManager_PluginUninstalled;
  62. _installationManager.PluginUpdated += _installationManager_PluginUpdated;
  63. _installationManager.PackageInstallationFailed += _installationManager_PackageInstallationFailed;
  64. _sessionManager.SessionStarted += _sessionManager_SessionStarted;
  65. _sessionManager.AuthenticationFailed += _sessionManager_AuthenticationFailed;
  66. _sessionManager.AuthenticationSucceeded += _sessionManager_AuthenticationSucceeded;
  67. _sessionManager.SessionEnded += _sessionManager_SessionEnded;
  68. _sessionManager.PlaybackStart += _sessionManager_PlaybackStart;
  69. _sessionManager.PlaybackStopped += _sessionManager_PlaybackStopped;
  70. //_subManager.SubtitlesDownloaded += _subManager_SubtitlesDownloaded;
  71. _subManager.SubtitleDownloadFailure += _subManager_SubtitleDownloadFailure;
  72. _userManager.UserCreated += _userManager_UserCreated;
  73. _userManager.UserPasswordChanged += _userManager_UserPasswordChanged;
  74. _userManager.UserDeleted += _userManager_UserDeleted;
  75. _userManager.UserPolicyUpdated += _userManager_UserPolicyUpdated;
  76. _userManager.UserLockedOut += _userManager_UserLockedOut;
  77. //_config.ConfigurationUpdated += _config_ConfigurationUpdated;
  78. //_config.NamedConfigurationUpdated += _config_NamedConfigurationUpdated;
  79. _deviceManager.CameraImageUploaded += _deviceManager_CameraImageUploaded;
  80. _appHost.ApplicationUpdated += _appHost_ApplicationUpdated;
  81. }
  82. async void _deviceManager_CameraImageUploaded(object sender, GenericEventArgs<CameraImageUploadInfo> e)
  83. {
  84. await CreateLogEntry(new ActivityLogEntry
  85. {
  86. Name = string.Format(_localization.GetLocalizedString("CameraImageUploadedFrom"), e.Argument.Device.Name),
  87. Type = NotificationType.CameraImageUploaded.ToString()
  88. });
  89. }
  90. async void _userManager_UserLockedOut(object sender, GenericEventArgs<User> e)
  91. {
  92. await CreateLogEntry(new ActivityLogEntry
  93. {
  94. Name = string.Format(_localization.GetLocalizedString("UserLockedOutWithName"), e.Argument.Name),
  95. Type = NotificationType.UserLockedOut.ToString(),
  96. UserId = e.Argument.Id
  97. });
  98. }
  99. async void _subManager_SubtitleDownloadFailure(object sender, SubtitleDownloadFailureEventArgs e)
  100. {
  101. await CreateLogEntry(new ActivityLogEntry
  102. {
  103. Name = string.Format(_localization.GetLocalizedString("SubtitleDownloadFailureFromForItem"), e.Provider, Notifications.Notifications.GetItemName(e.Item)),
  104. Type = "SubtitleDownloadFailure",
  105. ItemId = e.Item.Id.ToString("N"),
  106. ShortOverview = e.Exception.Message
  107. });
  108. }
  109. async void _sessionManager_PlaybackStopped(object sender, PlaybackStopEventArgs e)
  110. {
  111. var item = e.MediaInfo;
  112. if (item == null)
  113. {
  114. //_logger.LogWarning("PlaybackStopped reported with null media info.");
  115. return;
  116. }
  117. if (e.Item != null && e.Item.IsThemeMedia)
  118. {
  119. // Don't report theme song or local trailer playback
  120. return;
  121. }
  122. if (e.Users.Count == 0)
  123. {
  124. return;
  125. }
  126. var user = e.Users.First();
  127. await CreateLogEntry(new ActivityLogEntry
  128. {
  129. Name = string.Format(_localization.GetLocalizedString("UserStoppedPlayingItemWithValues"), user.Name, GetItemName(item), e.DeviceName),
  130. Type = GetPlaybackStoppedNotificationType(item.MediaType),
  131. UserId = user.Id
  132. });
  133. }
  134. async void _sessionManager_PlaybackStart(object sender, PlaybackProgressEventArgs e)
  135. {
  136. var item = e.MediaInfo;
  137. if (item == null)
  138. {
  139. //_logger.LogWarning("PlaybackStart reported with null media info.");
  140. return;
  141. }
  142. if (e.Item != null && e.Item.IsThemeMedia)
  143. {
  144. // Don't report theme song or local trailer playback
  145. return;
  146. }
  147. if (e.Users.Count == 0)
  148. {
  149. return;
  150. }
  151. var user = e.Users.First();
  152. await CreateLogEntry(new ActivityLogEntry
  153. {
  154. Name = string.Format(_localization.GetLocalizedString("UserStartedPlayingItemWithValues"), user.Name, GetItemName(item), e.DeviceName),
  155. Type = GetPlaybackNotificationType(item.MediaType),
  156. UserId = user.Id
  157. });
  158. }
  159. private static string GetItemName(BaseItemDto item)
  160. {
  161. var name = item.Name;
  162. if (!string.IsNullOrEmpty(item.SeriesName))
  163. {
  164. name = item.SeriesName + " - " + name;
  165. }
  166. if (item.Artists != null && item.Artists.Length > 0)
  167. {
  168. name = item.Artists[0] + " - " + name;
  169. }
  170. return name;
  171. }
  172. private static string GetPlaybackNotificationType(string mediaType)
  173. {
  174. if (string.Equals(mediaType, MediaType.Audio, StringComparison.OrdinalIgnoreCase))
  175. {
  176. return NotificationType.AudioPlayback.ToString();
  177. }
  178. if (string.Equals(mediaType, MediaType.Game, StringComparison.OrdinalIgnoreCase))
  179. {
  180. return NotificationType.GamePlayback.ToString();
  181. }
  182. if (string.Equals(mediaType, MediaType.Video, StringComparison.OrdinalIgnoreCase))
  183. {
  184. return NotificationType.VideoPlayback.ToString();
  185. }
  186. return null;
  187. }
  188. private static string GetPlaybackStoppedNotificationType(string mediaType)
  189. {
  190. if (string.Equals(mediaType, MediaType.Audio, StringComparison.OrdinalIgnoreCase))
  191. {
  192. return NotificationType.AudioPlaybackStopped.ToString();
  193. }
  194. if (string.Equals(mediaType, MediaType.Game, StringComparison.OrdinalIgnoreCase))
  195. {
  196. return NotificationType.GamePlaybackStopped.ToString();
  197. }
  198. if (string.Equals(mediaType, MediaType.Video, StringComparison.OrdinalIgnoreCase))
  199. {
  200. return NotificationType.VideoPlaybackStopped.ToString();
  201. }
  202. return null;
  203. }
  204. async void _sessionManager_SessionEnded(object sender, SessionEventArgs e)
  205. {
  206. string name;
  207. var session = e.SessionInfo;
  208. if (string.IsNullOrEmpty(session.UserName))
  209. {
  210. name = string.Format(_localization.GetLocalizedString("DeviceOfflineWithName"), session.DeviceName);
  211. // Causing too much spam for now
  212. return;
  213. }
  214. else
  215. {
  216. name = string.Format(_localization.GetLocalizedString("UserOfflineFromDevice"), session.UserName, session.DeviceName);
  217. }
  218. await CreateLogEntry(new ActivityLogEntry
  219. {
  220. Name = name,
  221. Type = "SessionEnded",
  222. ShortOverview = string.Format(_localization.GetLocalizedString("LabelIpAddressValue"), session.RemoteEndPoint),
  223. UserId = session.UserId
  224. });
  225. }
  226. async void _sessionManager_AuthenticationSucceeded(object sender, GenericEventArgs<AuthenticationResult> e)
  227. {
  228. var user = e.Argument.User;
  229. await CreateLogEntry(new ActivityLogEntry
  230. {
  231. Name = string.Format(_localization.GetLocalizedString("AuthenticationSucceededWithUserName"), user.Name),
  232. Type = "AuthenticationSucceeded",
  233. ShortOverview = string.Format(_localization.GetLocalizedString("LabelIpAddressValue"), e.Argument.SessionInfo.RemoteEndPoint),
  234. UserId = user.Id
  235. });
  236. }
  237. async void _sessionManager_AuthenticationFailed(object sender, GenericEventArgs<AuthenticationRequest> e)
  238. {
  239. await CreateLogEntry(new ActivityLogEntry
  240. {
  241. Name = string.Format(_localization.GetLocalizedString("FailedLoginAttemptWithUserName"), e.Argument.Username),
  242. Type = "AuthenticationFailed",
  243. ShortOverview = string.Format(_localization.GetLocalizedString("LabelIpAddressValue"), e.Argument.RemoteEndPoint),
  244. Severity = LogLevel.Error
  245. });
  246. }
  247. async void _appHost_ApplicationUpdated(object sender, GenericEventArgs<PackageVersionInfo> e)
  248. {
  249. await CreateLogEntry(new ActivityLogEntry
  250. {
  251. Name = string.Format(_localization.GetLocalizedString("MessageApplicationUpdatedTo"), e.Argument.versionStr),
  252. Type = NotificationType.ApplicationUpdateInstalled.ToString(),
  253. Overview = e.Argument.description
  254. });
  255. }
  256. async void _config_NamedConfigurationUpdated(object sender, ConfigurationUpdateEventArgs e)
  257. {
  258. await CreateLogEntry(new ActivityLogEntry
  259. {
  260. Name = string.Format(_localization.GetLocalizedString("MessageNamedServerConfigurationUpdatedWithValue"), e.Key),
  261. Type = "NamedConfigurationUpdated"
  262. });
  263. }
  264. async void _config_ConfigurationUpdated(object sender, EventArgs e)
  265. {
  266. await CreateLogEntry(new ActivityLogEntry
  267. {
  268. Name = _localization.GetLocalizedString("MessageServerConfigurationUpdated"),
  269. Type = "ServerConfigurationUpdated"
  270. });
  271. }
  272. async void _userManager_UserPolicyUpdated(object sender, GenericEventArgs<User> e)
  273. {
  274. await CreateLogEntry(new ActivityLogEntry
  275. {
  276. Name = string.Format(_localization.GetLocalizedString("UserPolicyUpdatedWithName"), e.Argument.Name),
  277. Type = "UserPolicyUpdated",
  278. UserId = e.Argument.Id
  279. });
  280. }
  281. async void _userManager_UserDeleted(object sender, GenericEventArgs<User> e)
  282. {
  283. await CreateLogEntry(new ActivityLogEntry
  284. {
  285. Name = string.Format(_localization.GetLocalizedString("UserDeletedWithName"), e.Argument.Name),
  286. Type = "UserDeleted"
  287. });
  288. }
  289. async void _userManager_UserPasswordChanged(object sender, GenericEventArgs<User> e)
  290. {
  291. await CreateLogEntry(new ActivityLogEntry
  292. {
  293. Name = string.Format(_localization.GetLocalizedString("UserPasswordChangedWithName"), e.Argument.Name),
  294. Type = "UserPasswordChanged",
  295. UserId = e.Argument.Id
  296. });
  297. }
  298. async void _userManager_UserCreated(object sender, GenericEventArgs<User> e)
  299. {
  300. await CreateLogEntry(new ActivityLogEntry
  301. {
  302. Name = string.Format(_localization.GetLocalizedString("UserCreatedWithName"), e.Argument.Name),
  303. Type = "UserCreated",
  304. UserId = e.Argument.Id
  305. });
  306. }
  307. async void _subManager_SubtitlesDownloaded(object sender, SubtitleDownloadEventArgs e)
  308. {
  309. await CreateLogEntry(new ActivityLogEntry
  310. {
  311. Name = string.Format(_localization.GetLocalizedString("SubtitlesDownloadedForItem"), Notifications.Notifications.GetItemName(e.Item)),
  312. Type = "SubtitlesDownloaded",
  313. ItemId = e.Item.Id.ToString("N"),
  314. ShortOverview = string.Format(_localization.GetLocalizedString("ProviderValue"), e.Provider)
  315. });
  316. }
  317. async void _sessionManager_SessionStarted(object sender, SessionEventArgs e)
  318. {
  319. string name;
  320. var session = e.SessionInfo;
  321. if (string.IsNullOrEmpty(session.UserName))
  322. {
  323. name = string.Format(_localization.GetLocalizedString("DeviceOnlineWithName"), session.DeviceName);
  324. // Causing too much spam for now
  325. return;
  326. }
  327. else
  328. {
  329. name = string.Format(_localization.GetLocalizedString("UserOnlineFromDevice"), session.UserName, session.DeviceName);
  330. }
  331. await CreateLogEntry(new ActivityLogEntry
  332. {
  333. Name = name,
  334. Type = "SessionStarted",
  335. ShortOverview = string.Format(_localization.GetLocalizedString("LabelIpAddressValue"), session.RemoteEndPoint),
  336. UserId = session.UserId
  337. });
  338. }
  339. async void _installationManager_PluginUpdated(object sender, GenericEventArgs<Tuple<IPlugin, PackageVersionInfo>> e)
  340. {
  341. await CreateLogEntry(new ActivityLogEntry
  342. {
  343. Name = string.Format(_localization.GetLocalizedString("PluginUpdatedWithName"), e.Argument.Item1.Name),
  344. Type = NotificationType.PluginUpdateInstalled.ToString(),
  345. ShortOverview = string.Format(_localization.GetLocalizedString("VersionNumber"), e.Argument.Item2.versionStr),
  346. Overview = e.Argument.Item2.description
  347. });
  348. }
  349. async void _installationManager_PluginUninstalled(object sender, GenericEventArgs<IPlugin> e)
  350. {
  351. await CreateLogEntry(new ActivityLogEntry
  352. {
  353. Name = string.Format(_localization.GetLocalizedString("PluginUninstalledWithName"), e.Argument.Name),
  354. Type = NotificationType.PluginUninstalled.ToString()
  355. });
  356. }
  357. async void _installationManager_PluginInstalled(object sender, GenericEventArgs<PackageVersionInfo> e)
  358. {
  359. await CreateLogEntry(new ActivityLogEntry
  360. {
  361. Name = string.Format(_localization.GetLocalizedString("PluginInstalledWithName"), e.Argument.name),
  362. Type = NotificationType.PluginInstalled.ToString(),
  363. ShortOverview = string.Format(_localization.GetLocalizedString("VersionNumber"), e.Argument.versionStr)
  364. });
  365. }
  366. async void _installationManager_PackageInstallationFailed(object sender, InstallationFailedEventArgs e)
  367. {
  368. var installationInfo = e.InstallationInfo;
  369. await CreateLogEntry(new ActivityLogEntry
  370. {
  371. Name = string.Format(_localization.GetLocalizedString("NameInstallFailed"), installationInfo.Name),
  372. Type = NotificationType.InstallationFailed.ToString(),
  373. ShortOverview = string.Format(_localization.GetLocalizedString("VersionNumber"), installationInfo.Version),
  374. Overview = e.Exception.Message
  375. });
  376. }
  377. async void _taskManager_TaskCompleted(object sender, TaskCompletionEventArgs e)
  378. {
  379. var result = e.Result;
  380. var task = e.Task;
  381. var activityTask = task.ScheduledTask as IConfigurableScheduledTask;
  382. if (activityTask != null && !activityTask.IsLogged)
  383. {
  384. return;
  385. }
  386. var time = result.EndTimeUtc - result.StartTimeUtc;
  387. var runningTime = string.Format(_localization.GetLocalizedString("LabelRunningTimeValue"), ToUserFriendlyString(time));
  388. if (result.Status == TaskCompletionStatus.Failed)
  389. {
  390. var vals = new List<string>();
  391. if (!string.IsNullOrEmpty(e.Result.ErrorMessage))
  392. {
  393. vals.Add(e.Result.ErrorMessage);
  394. }
  395. if (!string.IsNullOrEmpty(e.Result.LongErrorMessage))
  396. {
  397. vals.Add(e.Result.LongErrorMessage);
  398. }
  399. await CreateLogEntry(new ActivityLogEntry
  400. {
  401. Name = string.Format(_localization.GetLocalizedString("ScheduledTaskFailedWithName"), task.Name),
  402. Type = NotificationType.TaskFailed.ToString(),
  403. Overview = string.Join(Environment.NewLine, vals.ToArray()),
  404. ShortOverview = runningTime,
  405. Severity = LogLevel.Error
  406. });
  407. }
  408. }
  409. private async Task CreateLogEntry(ActivityLogEntry entry)
  410. {
  411. try
  412. {
  413. await _activityManager.CreateAsync(entry);
  414. }
  415. catch
  416. {
  417. // Logged at lower levels
  418. }
  419. }
  420. public void Dispose()
  421. {
  422. _taskManager.TaskCompleted -= _taskManager_TaskCompleted;
  423. _installationManager.PluginInstalled -= _installationManager_PluginInstalled;
  424. _installationManager.PluginUninstalled -= _installationManager_PluginUninstalled;
  425. _installationManager.PluginUpdated -= _installationManager_PluginUpdated;
  426. _installationManager.PackageInstallationFailed -= _installationManager_PackageInstallationFailed;
  427. _sessionManager.SessionStarted -= _sessionManager_SessionStarted;
  428. _sessionManager.AuthenticationFailed -= _sessionManager_AuthenticationFailed;
  429. _sessionManager.AuthenticationSucceeded -= _sessionManager_AuthenticationSucceeded;
  430. _sessionManager.SessionEnded -= _sessionManager_SessionEnded;
  431. _sessionManager.PlaybackStart -= _sessionManager_PlaybackStart;
  432. _sessionManager.PlaybackStopped -= _sessionManager_PlaybackStopped;
  433. _subManager.SubtitlesDownloaded -= _subManager_SubtitlesDownloaded;
  434. _subManager.SubtitleDownloadFailure -= _subManager_SubtitleDownloadFailure;
  435. _userManager.UserCreated -= _userManager_UserCreated;
  436. _userManager.UserPasswordChanged -= _userManager_UserPasswordChanged;
  437. _userManager.UserDeleted -= _userManager_UserDeleted;
  438. _userManager.UserPolicyUpdated -= _userManager_UserPolicyUpdated;
  439. _userManager.UserLockedOut -= _userManager_UserLockedOut;
  440. _config.ConfigurationUpdated -= _config_ConfigurationUpdated;
  441. _config.NamedConfigurationUpdated -= _config_NamedConfigurationUpdated;
  442. _deviceManager.CameraImageUploaded -= _deviceManager_CameraImageUploaded;
  443. _appHost.ApplicationUpdated -= _appHost_ApplicationUpdated;
  444. }
  445. /// <summary>
  446. /// Constructs a user-friendly string for this TimeSpan instance.
  447. /// </summary>
  448. public static string ToUserFriendlyString(TimeSpan span)
  449. {
  450. const int DaysInYear = 365;
  451. const int DaysInMonth = 30;
  452. // Get each non-zero value from TimeSpan component
  453. var values = new List<string>();
  454. // Number of years
  455. int days = span.Days;
  456. if (days >= DaysInYear)
  457. {
  458. int years = days / DaysInYear;
  459. values.Add(CreateValueString(years, "year"));
  460. days = days % DaysInYear;
  461. }
  462. // Number of months
  463. if (days >= DaysInMonth)
  464. {
  465. int months = days / DaysInMonth;
  466. values.Add(CreateValueString(months, "month"));
  467. days = days % DaysInMonth;
  468. }
  469. // Number of days
  470. if (days >= 1)
  471. values.Add(CreateValueString(days, "day"));
  472. // Number of hours
  473. if (span.Hours >= 1)
  474. values.Add(CreateValueString(span.Hours, "hour"));
  475. // Number of minutes
  476. if (span.Minutes >= 1)
  477. values.Add(CreateValueString(span.Minutes, "minute"));
  478. // Number of seconds (include when 0 if no other components included)
  479. if (span.Seconds >= 1 || values.Count == 0)
  480. values.Add(CreateValueString(span.Seconds, "second"));
  481. // Combine values into string
  482. var builder = new StringBuilder();
  483. for (int i = 0; i < values.Count; i++)
  484. {
  485. if (builder.Length > 0)
  486. builder.Append(i == values.Count - 1 ? " and " : ", ");
  487. builder.Append(values[i]);
  488. }
  489. // Return result
  490. return builder.ToString();
  491. }
  492. /// <summary>
  493. /// Constructs a string description of a time-span value.
  494. /// </summary>
  495. /// <param name="value">The value of this item</param>
  496. /// <param name="description">The name of this item (singular form)</param>
  497. private static string CreateValueString(int value, string description)
  498. {
  499. return string.Format("{0:#,##0} {1}",
  500. value, value == 1 ? description : string.Format("{0}s", description));
  501. }
  502. }
  503. }