FactoryFloorAnalysis.xaml.cs 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data;
  4. using System.Diagnostics;
  5. using System.Linq;
  6. using System.Text.RegularExpressions;
  7. using System.Windows;
  8. using System.Windows.Controls;
  9. using System.Windows.Data;
  10. using System.Windows.Input;
  11. using Comal.Classes;
  12. using InABox.Clients;
  13. using InABox.Configuration;
  14. using InABox.Core;
  15. using InABox.WPF;
  16. using PRSDesktop.WidgetGroups;
  17. using Syncfusion.UI.Xaml.Grid;
  18. using Syncfusion.UI.Xaml.Grid.Cells;
  19. using Syncfusion.UI.Xaml.Grid.Converter;
  20. using Syncfusion.XlsIO;
  21. using DataRow = System.Data.DataRow;
  22. using SelectionChangedEventArgs = System.Windows.Controls.SelectionChangedEventArgs;
  23. namespace PRSDesktop
  24. {
  25. public class FactoryFloorAnalysisDashboardProperties : IUserConfigurationSettings, IDashboardProperties { }
  26. public class FactoryFloorAnalysisDashboardElement : DashboardElement<FactoryFloorAnalysis, Manufacturing, FactoryFloorAnalysisDashboardProperties> { }
  27. /// <summary>
  28. /// Interaction logic for FactoryFloorAnalysis.xaml
  29. /// </summary>
  30. public partial class FactoryFloorAnalysis : UserControl, IPanel<ManufacturingPacket>, IDashboardWidget<Manufacturing, FactoryFloorAnalysisDashboardProperties>
  31. {
  32. private bool _changing;
  33. private DateTime _from;
  34. private string _search = "";
  35. private DateTime _to;
  36. private readonly Dictionary<string, string> SectionDisplayNames = new() { { "Total", "Total" } };
  37. private CoreTable sections;
  38. private CoreTable templatestages;
  39. public FactoryFloorAnalysis()
  40. {
  41. _from = DateTime.Today.AddDays(0 - WeekDay(DateTime.Today));
  42. _to = DateTime.Today;
  43. InitializeComponent();
  44. dataGrid.CellRenderers.Remove("StackedHeader");
  45. dataGrid.CellRenderers.Add("StackedHeader", new GridCustomStackedRenderer(Resources));
  46. }
  47. public event DataModelUpdateEvent OnUpdateDataModel;
  48. public bool IsReady { get; set; }
  49. public void CreateToolbarButtons(IPanelHost host)
  50. {
  51. }
  52. public void Setup()
  53. {
  54. FromDate.SelectedDate = _from;
  55. ToDate.SelectedDate = _to;
  56. var employees = new Dictionary<Guid, string> { { Guid.Empty, "All Employees" } };
  57. var emps = new Client<Employee>().Query(
  58. LookupFactory.DefineFilter<Employee>(),
  59. LookupFactory.DefineColumns<Employee>(),
  60. LookupFactory.DefineSort<Employee>()
  61. );
  62. foreach (var row in emps.Rows)
  63. //if (row.Get<Employee, String>(x => x.Group.Description).Equals("FACTORY"))
  64. employees[row.Get<Employee, Guid>(x => x.ID)] = row.Get<Employee, string>(x => x.Name);
  65. Employees.ItemsSource = employees;
  66. var joblist = new Dictionary<Guid, string> { { Guid.Empty, "All Jobs" } };
  67. var jobs = new Client<Job>().Query(
  68. LookupFactory.DefineFilter<Job>(),
  69. LookupFactory.DefineColumns<Job>(),
  70. LookupFactory.DefineSort<Job>()
  71. );
  72. foreach (var row in jobs.Rows)
  73. //if (row.Get<Employee, String>(x => x.Group.Description).Equals("FACTORY"))
  74. joblist[row.Get<Job, Guid>(x => x.ID)] =
  75. string.Format("{0} - {1}", row.Get<Job, string>(x => x.JobNumber), row.Get<Job, string>(x => x.Name));
  76. Jobs.ItemsSource = joblist;
  77. sections = new Client<ManufacturingSection>().Query(
  78. new Filter<ManufacturingSection>(x => x.Hidden).IsEqualTo(false),
  79. null,
  80. new SortOrder<ManufacturingSection>(x => x.Factory.Sequence).ThenBy(x => x.Sequence));
  81. var templates = new Dictionary<Guid, string> { { Guid.Empty, "All Templates" } };
  82. templatestages = new Client<ManufacturingTemplateStage>().Query();
  83. foreach (var row in templatestages.Rows)
  84. templates[row.Get<ManufacturingTemplateStage, Guid>(x => x.Template.ID)] = string.Format("{0} - {1}",
  85. row.Get<ManufacturingTemplateStage, string>(x => x.Template.Code),
  86. row.Get<ManufacturingTemplateStage, string>(x => x.Template.Name));
  87. Templates.ItemsSource = templates;
  88. dataGrid.ScrollMode = ScrollMode.Async;
  89. var columns = new Dictionary<string, List<string>>();
  90. var factories = new Dictionary<Guid, string> { { Guid.Empty, "All Factories" } };
  91. foreach (var row in sections.Rows)
  92. {
  93. var factoryid = row.Get<ManufacturingSection, Guid>(x => x.Factory.ID);
  94. var factoryname = row.Get<ManufacturingSection, string>(x => x.Factory.Name);
  95. factories[factoryid] = factoryname;
  96. if (!columns.ContainsKey(factoryname))
  97. columns[factoryname] = new List<string>();
  98. }
  99. Factories.ItemsSource = factories;
  100. ReloadHeaders(columns);
  101. }
  102. public void Shutdown()
  103. {
  104. }
  105. public void Refresh()
  106. {
  107. var data = new DataTable();
  108. data.Columns.Add("Template", typeof(string));
  109. data.Columns.Add("Job", typeof(string));
  110. data.Columns.Add("Setout", typeof(string));
  111. data.Columns.Add("Serial", typeof(string));
  112. data.Columns.Add("Description", typeof(string));
  113. data.Columns.Add("Qty", typeof(int));
  114. var columns = new Dictionary<string, List<string>>();
  115. foreach (var row in sections.Rows)
  116. if (Factories.SelectedValue.Equals(Guid.Empty) ||
  117. row.Get<ManufacturingSection, Guid>(x => x.Factory.ID).Equals(Factories.SelectedValue))
  118. {
  119. var factory = row.Get<ManufacturingSection, string>(x => x.Factory.Name);
  120. if (!columns.ContainsKey(factory))
  121. columns[factory] = new List<string>();
  122. CreateColumn(data, columns, row, "Est");
  123. CreateColumn(data, columns, row, "Act");
  124. CreateColumn(data, columns, row, "Var");
  125. }
  126. ReloadHeaders(columns);
  127. //dataGrid.CoveredCells.Clear();
  128. dataGrid.ItemsSource = data;
  129. Progress.Show("Retrieving Completed Work (0%) ...");
  130. data.Rows.Clear();
  131. var empid = Employees.SelectedValue != null ? (Guid)Employees.SelectedValue : Guid.Empty;
  132. var jobid = Jobs.SelectedValue != null ? (Guid)Jobs.SelectedValue : Guid.Empty;
  133. var stgfilter = new Filter<ManufacturingPacketStage>(x => x.Completed).IsGreaterThanOrEqualTo(_from).And(x => x.Completed)
  134. .IsLessThan(_to.AddDays(1));
  135. if (jobid != Guid.Empty)
  136. stgfilter = stgfilter.And(x => x.Parent.SetoutLink.JobLink.ID).IsEqualTo(jobid);
  137. var completedstages = new Client<ManufacturingPacketStage>().Query(stgfilter,
  138. new Columns<ManufacturingPacketStage>(
  139. x => x.Parent.ID,
  140. x => x.Parent.ManufacturingTemplateLink.ID,
  141. x => x.Parent.ManufacturingTemplateLink.Code,
  142. x => x.Parent.SetoutLink.JobLink.JobNumber,
  143. x => x.Parent.SetoutLink.Number,
  144. x => x.Parent.Serial,
  145. x => x.Parent.Title,
  146. x => x.Parent.Quantity
  147. )
  148. );
  149. var pktids = new List<Guid> { Guid.Empty };
  150. foreach (var stagerow in completedstages.Rows)
  151. {
  152. var id = stagerow.Get<ManufacturingPacketStage, Guid>(c => c.Parent.ID);
  153. if (!pktids.Contains(id))
  154. pktids.Add(id);
  155. }
  156. Progress.SetMessage("Retrieving History (10%) ...");
  157. var filter = new Filter<ManufacturingHistory>(x => x.Employee).LinkValid(empid);
  158. if (jobid != Guid.Empty)
  159. filter = filter.And(x => x.Packet.SetoutLink.JobLink.ID).IsEqualTo(jobid);
  160. filter = filter.And(x => x.Packet.ID).InList(pktids.ToArray());
  161. var history = new Client<ManufacturingHistory>().Query(
  162. filter,
  163. new Columns<ManufacturingHistory>(
  164. x => x.Packet.ID,
  165. x => x.Section.ID,
  166. x => x.WorkDuration,
  167. x => x.QADuration
  168. )
  169. );
  170. var totals = new Dictionary<string, double>();
  171. var qtytotal = 0;
  172. for (var i = 0; i < pktids.Count; i++)
  173. {
  174. var bHasData = false;
  175. Progress.SetMessage(string.Format("Calculating ({0:F2}%) ...", 20.0F + i * 80.0F / (double)pktids.Count));
  176. //var packet = packets.Rows[i];
  177. var pktid = pktids[i];
  178. if (pktid != Guid.Empty)
  179. {
  180. var row = data.NewRow();
  181. // Get the First completed stage, so that we can extract the info from the packetlink
  182. var srow = completedstages.Rows.FirstOrDefault(r => r.Get<ManufacturingPacketStage, Guid>(x => x.Parent.ID).Equals(pktid));
  183. var stage = srow.ToObject<ManufacturingPacketStage>();
  184. row["Template"] = stage.Parent.ManufacturingTemplateLink.Code;
  185. row["Job"] = stage.Parent.SetoutLink.JobLink.JobNumber;
  186. row["Setout"] = stage.Parent.SetoutLink.Number;
  187. row["Serial"] = stage.Parent.Serial;
  188. row["Description"] = stage.Parent.Title;
  189. row["Qty"] = stage.Parent.Quantity;
  190. var pktstages = templatestages.Rows.Where(r =>
  191. r.Get<ManufacturingTemplateStage, Guid>(c => c.Template.ID).Equals(stage.Parent.ManufacturingTemplateLink.ID));
  192. foreach (var stagerow in pktstages)
  193. {
  194. var sectionid = stagerow.Get<ManufacturingTemplateStage, Guid>(c => c.Section.ID);
  195. var section = sections.Rows.FirstOrDefault(r => r.Get<ManufacturingSection, Guid>(c => c.ID).Equals(sectionid));
  196. var prefix = string.Format("{0}:{1}:", section.Get<ManufacturingSection, string>(x => x.Factory.Name),
  197. Regex.Replace(section.Get<ManufacturingSection, string>(x => x.Name), "[^a-zA-Z0-9]", string.Empty));
  198. var estimated = stagerow.Get<ManufacturingTemplateStage, TimeSpan>(x => x.Time).TotalHours * stage.Parent.Quantity;
  199. var histrecords = history.Rows.Where(r =>
  200. r.Get<ManufacturingHistory, Guid>(c => c.Packet.ID).Equals(stage.Parent.ID) &&
  201. r.Get<ManufacturingHistory, Guid>(c => c.Section.ID).Equals(sectionid));
  202. var actual = new TimeSpan(histrecords.Sum(r =>
  203. r.Get<ManufacturingHistory, TimeSpan>(c => c.WorkDuration).Ticks +
  204. r.Get<ManufacturingHistory, TimeSpan>(c => c.QADuration).Ticks)).TotalHours;
  205. if (actual > 0.0F)
  206. {
  207. if (data.Columns.Contains(prefix + "Est"))
  208. {
  209. UpdateColumn(totals, row, prefix + "Est", estimated);
  210. UpdateColumn(totals, row, prefix + "Act", actual);
  211. UpdateColumn(totals, row, prefix + "Var", actual - estimated);
  212. }
  213. bHasData = true;
  214. }
  215. }
  216. if (bHasData)
  217. {
  218. qtytotal += (int)row["Qty"];
  219. data.Rows.Add(row);
  220. }
  221. }
  222. }
  223. var total = data.NewRow();
  224. total["Template"] = "Totals";
  225. total["qty"] = qtytotal;
  226. foreach (var key in totals.Keys)
  227. total[key] = totals[key];
  228. data.Rows.Add(total);
  229. //dataGrid.CoveredCells.Add(new CoveredCellInfo(1, 5, data.Rows.Count, data.Rows.Count));
  230. Progress.Close();
  231. }
  232. public string SectionName => "Factory Floor Analysis";
  233. public FactoryFloorAnalysisDashboardProperties Properties { get; set; }
  234. public event LoadSettings<FactoryFloorAnalysisDashboardProperties>? LoadSettings;
  235. public event SaveSettings<FactoryFloorAnalysisDashboardProperties>? SaveSettings;
  236. public DataModel DataModel(Selection selection)
  237. {
  238. Filter<ManufacturingPacket>? filter = null;
  239. if(selection == Selection.None)
  240. {
  241. filter = new Filter<ManufacturingPacket>();
  242. }
  243. return new AutoDataModel<ManufacturingPacket>(filter);
  244. }
  245. public Dictionary<string, object[]> Selected()
  246. {
  247. return new Dictionary<string, object[]>();
  248. }
  249. public void Heartbeat(TimeSpan time)
  250. {
  251. }
  252. private void ReloadHeaders(Dictionary<string, List<string>> columns)
  253. {
  254. dataGrid.StackedHeaderRows.Clear();
  255. //dataGrid.TableSummaryRows.Clear();
  256. var FactoryRow = new StackedHeaderRow();
  257. var SectionRow = new StackedHeaderRow();
  258. //var summaryRow = new GridTableSummaryRow();
  259. //summaryRow.ShowSummaryInRow = false;
  260. //var summaries = new ObservableCollection<ISummaryColumn>();
  261. //summaryRow.SummaryColumns = summaries;
  262. // fab / prs / glz
  263. foreach (var factory in columns.Keys)
  264. {
  265. FactoryRow.StackedColumns.Add(new StackedColumn
  266. { ChildColumns = string.Join(",", columns[factory]), HeaderText = factory, MappingName = factory });
  267. var sections = new Dictionary<string, List<string>>();
  268. foreach (var col in columns[factory])
  269. {
  270. var bits = col.Split(':');
  271. if (!sections.ContainsKey(bits[1]))
  272. sections[bits[1]] = new List<string>();
  273. sections[bits[1]].Add(col);
  274. //var summary = new GridSummaryColumn()
  275. //{
  276. // Name = col,
  277. // MappingName = col,
  278. // SummaryType = SummaryType.DoubleAggregate,
  279. // Format = "{Sum:F2}"
  280. //};
  281. //summaries.Add(summary);
  282. }
  283. // cut / mach / ass
  284. foreach (var sect in sections.Keys)
  285. SectionRow.StackedColumns.Add(new StackedColumn
  286. { ChildColumns = string.Join(",", sections[sect]), HeaderText = sect, MappingName = sect });
  287. }
  288. dataGrid.StackedHeaderRows.Add(FactoryRow);
  289. dataGrid.StackedHeaderRows.Add(SectionRow);
  290. //dataGrid.TableSummaryRows.Add(summaryRow);
  291. }
  292. private void CreateColumn(DataTable data, Dictionary<string, List<string>> columns, CoreRow row, string subcolumn)
  293. {
  294. var factory = row.Get<ManufacturingSection, string>(x => x.Factory.Name);
  295. var section = row.Get<ManufacturingSection, string>(x => x.Name);
  296. var columnname = string.Format("{0}:{1}:{2}", factory, Regex.Replace(section, "[^a-zA-Z0-9]", string.Empty), subcolumn);
  297. columns[factory].Add(columnname);
  298. data.Columns.Add(columnname, typeof(double));
  299. SectionDisplayNames[columnname] = section;
  300. }
  301. private static void UpdateColumn(Dictionary<string, double> totals, DataRow row, string fieldname, double value)
  302. {
  303. row[fieldname] = value;
  304. if (!totals.ContainsKey(fieldname))
  305. totals[fieldname] = 0.00F;
  306. totals[fieldname] = totals[fieldname] + value;
  307. }
  308. private void Employees_SelectionChanged(object sender, SelectionChangedEventArgs e)
  309. {
  310. if (IsReady && !_changing)
  311. Refresh();
  312. }
  313. private void Jobs_SelectionChanged(object sender, SelectionChangedEventArgs e)
  314. {
  315. if (IsReady && !_changing)
  316. Refresh();
  317. }
  318. private void Factories_SelectionChanged(object sender, SelectionChangedEventArgs e)
  319. {
  320. if (IsReady && !_changing)
  321. Refresh();
  322. }
  323. private void Templates_SelectionChanged(object sender, SelectionChangedEventArgs e)
  324. {
  325. if (IsReady && !_changing)
  326. Refresh();
  327. }
  328. private void Export_Click(object sender, RoutedEventArgs e)
  329. {
  330. var emp = (KeyValuePair<Guid, string>)Employees.SelectedItem;
  331. var fact = (KeyValuePair<Guid, string>)Factories.SelectedItem;
  332. var temp = (KeyValuePair<Guid, string>)Templates.SelectedItem;
  333. var filename = string.Format("{0} - {1} - {2} - {3:yyyy-MM-dd} - {4:yyyy-MM-dd}.xlsx", emp.Value, fact.Value, temp.Value,
  334. FromDate.SelectedDate, ToDate.SelectedDate);
  335. var options = new ExcelExportingOptions();
  336. options.ExcelVersion = ExcelVersion.Excel2013;
  337. options.ExportStackedHeaders = true;
  338. var excelEngine = dataGrid.ExportToExcel(dataGrid.View, options);
  339. var workBook = excelEngine.Excel.Workbooks[0];
  340. workBook.SaveAs(filename);
  341. var startInfo = new ProcessStartInfo(filename);
  342. startInfo.Verb = "open";
  343. startInfo.UseShellExecute = true;
  344. Process.Start(startInfo);
  345. }
  346. private void Search_KeyUp(object sender, KeyEventArgs e)
  347. {
  348. if (string.IsNullOrWhiteSpace(Search.Text) || e.Key == Key.Return)
  349. {
  350. _search = Search.Text;
  351. Refresh();
  352. }
  353. }
  354. private void DataGrid_AutoGeneratingColumn(object sender, AutoGeneratingColumnArgs e)
  355. {
  356. e.Column.TextAlignment = TextAlignment.Center;
  357. e.Column.HorizontalHeaderContentAlignment = HorizontalAlignment.Center;
  358. e.Column.ColumnSizer = GridLengthUnitType.None;
  359. var value = e.Column.ValueBinding as Binding;
  360. if (value.Path.Path.Equals("Serial"))
  361. {
  362. e.Column.Width = 150;
  363. e.Column.HeaderStyle = Resources["TemplateHeaderStyle"] as Style;
  364. }
  365. else if (value.Path.Path.Equals("Job"))
  366. {
  367. e.Column.Width = 60;
  368. e.Column.HeaderStyle = Resources["TemplateHeaderStyle"] as Style;
  369. }
  370. else if (value.Path.Path.Equals("Setout"))
  371. {
  372. e.Column.Width = 120;
  373. e.Column.HeaderStyle = Resources["TemplateHeaderStyle"] as Style;
  374. }
  375. else if (value.Path.Path.Equals("Description"))
  376. {
  377. e.Column.Width = 350;
  378. e.Column.HeaderStyle = Resources["TemplateHeaderStyle"] as Style;
  379. }
  380. else if (value.Path.Path.Equals("Template"))
  381. {
  382. e.Column.Width = 80;
  383. e.Column.HeaderStyle = Resources["TemplateHeaderStyle"] as Style;
  384. }
  385. else
  386. {
  387. var style = new Style(typeof(GridCell));
  388. e.Column.CellStyle = style;
  389. e.Column.Width = 50;
  390. e.Column.HeaderStyle = Resources["TemplateHeaderStyle"] as Style;
  391. e.Column.HeaderText = e.Column.HeaderText.Split(':').Last(); //SectionDisplayNames[value.Path.Path];
  392. }
  393. }
  394. private class GridCustomStackedRenderer : GridStackedHeaderCellRenderer
  395. {
  396. private readonly ResourceDictionary _resources;
  397. public GridCustomStackedRenderer(ResourceDictionary resources)
  398. {
  399. _resources = resources;
  400. }
  401. public override void OnInitializeEditElement(DataColumnBase dataColumn, GridStackedHeaderCellControl uiElement, object dataContext)
  402. {
  403. uiElement.Style = _resources["GroupHeaderStyle"] as Style;
  404. base.OnInitializeEditElement(dataColumn, uiElement, dataContext);
  405. }
  406. }
  407. #region Date Handling
  408. private int WeekDay(DateTime date)
  409. {
  410. if (date.DayOfWeek == DayOfWeek.Sunday)
  411. return 7;
  412. return (int)date.DayOfWeek - 1;
  413. }
  414. private void SetDates(DateTime from, DateTime to, bool enable)
  415. {
  416. if (_changing)
  417. return;
  418. _changing = true;
  419. _from = from;
  420. FromDate.SelectedDate = from;
  421. FromDate.IsEnabled = enable;
  422. _to = to;
  423. ToDate.SelectedDate = to;
  424. ToDate.IsEnabled = enable;
  425. _changing = false;
  426. if (!enable)
  427. Refresh();
  428. }
  429. private void DateRange_SelectionChanged(object sender, SelectionChangedEventArgs e)
  430. {
  431. if (!IsReady)
  432. return;
  433. if (DateRange.SelectedIndex == 0) // Week To Date
  434. SetDates(DateTime.Today.AddDays(0 - WeekDay(DateTime.Today)), DateTime.Today, false);
  435. else if (DateRange.SelectedIndex == 1) // Last 7 Days
  436. SetDates(DateTime.Today.AddDays(-6), DateTime.Today, false);
  437. else if (DateRange.SelectedIndex == 2) // Month To Date
  438. SetDates(new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1), DateTime.Today, false);
  439. else if (DateRange.SelectedIndex == 3) // Last 30 days
  440. SetDates(DateTime.Today.AddDays(-29), DateTime.Today, false);
  441. else if (DateRange.SelectedIndex == 4) // Year To Date
  442. SetDates(new DateTime(DateTime.Today.Year, 1, 1), DateTime.Today, false);
  443. else if (DateRange.SelectedIndex == 5) // Last 12 Months
  444. SetDates(DateTime.Today.AddYears(-1).AddDays(1), DateTime.Today, false);
  445. else if (DateRange.SelectedIndex == 6) // Custom
  446. SetDates(FromDate.SelectedDate.Value, ToDate.SelectedDate.Value, true);
  447. }
  448. private void FromDate_SelectedDateChanged(object sender, SelectionChangedEventArgs e)
  449. {
  450. if (IsReady && !_changing)
  451. {
  452. _from = FromDate.SelectedDate.Value.Date;
  453. Refresh();
  454. }
  455. }
  456. private void ToDate_SelectedDateChanged(object sender, SelectionChangedEventArgs e)
  457. {
  458. if (IsReady && !_changing)
  459. {
  460. _to = ToDate.SelectedDate.Value.Date;
  461. Refresh();
  462. }
  463. }
  464. #endregion
  465. }
  466. }