diff --git a/LogisticsMgrMobile/LogisticsMgrMobile/Mobile/App/App.xaml.cs b/LogisticsMgrMobile/LogisticsMgrMobile/Mobile/App/App.xaml.cs index 345cfdd..225e8a0 100644 --- a/LogisticsMgrMobile/LogisticsMgrMobile/Mobile/App/App.xaml.cs +++ b/LogisticsMgrMobile/LogisticsMgrMobile/Mobile/App/App.xaml.cs @@ -80,7 +80,7 @@ namespace Sarand.LogisticsMgr.Mobile.App public override async Task IsWebServiceAlive (SlmSiteDefinition siteDefinition) { SlmWebServiceClient webServiceClient = new SlmWebServiceClient(); - return await webServiceClient.IsAlive(siteDefinition); + return await webServiceClient.RequestIsAlive(siteDefinition); } //------------------------------------------------------------------- @@ -119,8 +119,8 @@ namespace Sarand.LogisticsMgr.Mobile.App { sites.Add(new SlmSiteDefinition_App(Slm.Site.Southampton, "Localhost", "http://localhost:34567/SaLogMgr")); sites.Add(new SlmSiteDefinition_App(Slm.Site.Southampton, "Sarand107", "http://Sarand107:34567/SaLogMgr")); - sites.Add(new SlmSiteDefinition_App(Slm.Site.Southampton, "Sarand107 IP4", "http://10.53.2.208:34567/SaLogMgr")); - //sites.Add(new SlmSiteDefinition_App(Slm.Site.Southampton, "Sarand107 IP6", "http://[fe80::c1b6:f5ee:a3ea:35e3]:34567/SaLogMgr")); + sites.Add(new SlmSiteDefinition_App(Slm.Site.Southampton, "Sarand107 IP4", "http://192.168.1.117:34567/SaLogMgr")); + sites.Add(new SlmSiteDefinition_App(Slm.Site.Southampton, "Sarand107 IP6", "http://[2a00:23c4:1b29:cc00:87d:e29d:3ee4:7829]:34567/SaLogMgr")); } } return sites; diff --git a/LogisticsMgrMobile/LogisticsMgrMobile/Mobile/App/Commands/SlmCommand_Assets_CreateRepair.cs b/LogisticsMgrMobile/LogisticsMgrMobile/Mobile/App/Commands/SlmCommand_Assets_CreateRepair.cs index 7cafacb..03ee1fc 100644 --- a/LogisticsMgrMobile/LogisticsMgrMobile/Mobile/App/Commands/SlmCommand_Assets_CreateRepair.cs +++ b/LogisticsMgrMobile/LogisticsMgrMobile/Mobile/App/Commands/SlmCommand_Assets_CreateRepair.cs @@ -1,7 +1,7 @@ using Sarand.Core.Base; using Sarand.LogisticsMgr.Core.App; using Sarand.LogisticsMgr.Mobile.Core.App; -using Sarand.LogisticsMgr.Mobile.Forms.Pages.Assets; +using Sarand.LogisticsMgr.Mobile.Forms.Pages.Forms.Assets; using Sarand.LogisticsMgr.Mobile.Forms.Pages.Templates; using System; using System.Collections.Generic; @@ -38,8 +38,8 @@ namespace Sarand.LogisticsMgr.Mobile.App.Commands try { if (!await App.GetInstance().SlmMainPage.IsWebServiceActive()) return; - SlmPage_Assets_Repair.Config pageConfig = new SlmPage_Assets_Repair.Config(); - SlmPage_Assets_Repair assetRepairForm = new SlmPage_Assets_Repair (pageConfig); + SlmFormPage_Assets_Repair.Config pageConfig = new SlmFormPage_Assets_Repair.Config(); + SlmFormPage_Assets_Repair assetRepairForm = new SlmFormPage_Assets_Repair (pageConfig); assetRepairForm.Disappearing += (sender2, e2) => { AssetRepairFormActive = false; diff --git a/LogisticsMgrMobile/LogisticsMgrMobile/Mobile/App/SlmMainPage.cs b/LogisticsMgrMobile/LogisticsMgrMobile/Mobile/App/SlmMainPage.cs index 1e77a4c..bf20456 100644 --- a/LogisticsMgrMobile/LogisticsMgrMobile/Mobile/App/SlmMainPage.cs +++ b/LogisticsMgrMobile/LogisticsMgrMobile/Mobile/App/SlmMainPage.cs @@ -4,9 +4,11 @@ using Sarand.LogisticsMgr.Core.App; using Sarand.LogisticsMgr.Mobile.Core.App; using Sarand.LogisticsMgr.Mobile.Core.Forms.Base; using Sarand.LogisticsMgr.Mobile.Forms.Components; -using Sarand.LogisticsMgr.Mobile.Forms.Pages.Assets; +using Sarand.LogisticsMgr.Mobile.Forms.Pages.Forms.Assets; using Sarand.LogisticsMgr.Mobile.Forms.Pages.Templates; using Sarand.LogisticsMgr.Mobile.Forms.Panels.Main; +using Sarand.LogisticsMgr.Mobile.Forms.Panels.Main.Assets; +using Sarand.LogisticsMgr.Mobile.Forms.Panels.Main.Bulk; using Sarand.LogisticsMgr.Mobile.Forms.Views; using System; using System.Collections.Generic; @@ -91,8 +93,8 @@ namespace Sarand.LogisticsMgr.Mobile.App // Bulk. case SlmMobile.MainView.ShipFile: { - SlmMainPanel_ShipFile.Config panelConfig = new SlmMainPanel_ShipFile.Config(); - SlmMainPanel_ShipFile loginPanel = new SlmMainPanel_ShipFile(panelConfig); + SlmMainPanel_Bulk_Berthings.Config panelConfig = new SlmMainPanel_Bulk_Berthings.Config(); + SlmMainPanel_Bulk_Berthings loginPanel = new SlmMainPanel_Bulk_Berthings(panelConfig); mainPanel = loginPanel; break; } diff --git a/LogisticsMgrMobile/LogisticsMgrMobile/Mobile/App/SlmMenu.cs b/LogisticsMgrMobile/LogisticsMgrMobile/Mobile/App/SlmMenu.cs index 5ffec92..ef78564 100644 --- a/LogisticsMgrMobile/LogisticsMgrMobile/Mobile/App/SlmMenu.cs +++ b/LogisticsMgrMobile/LogisticsMgrMobile/Mobile/App/SlmMenu.cs @@ -1,7 +1,7 @@ using Sarand.Core.Base; using Sarand.LogisticsMgr.Mobile.App.Commands; using Sarand.LogisticsMgr.Mobile.Core.App; -using Sarand.LogisticsMgr.Mobile.Forms.Pages.Assets; +using Sarand.LogisticsMgr.Mobile.Forms.Pages.Forms.Assets; using Sarand.LogisticsMgr.Mobile.Forms.Pages.Config; using Sarand.LogisticsMgr.Mobile.Forms.Views; using System; @@ -99,8 +99,8 @@ namespace Sarand.LogisticsMgr.Mobile.App { InvokeMenuOptionClicked(); if (!await MainPage.IsWebServiceActive()) return; - SlmPage_Assets_Repair.Config pageConfig = new SlmPage_Assets_Repair.Config(); - SlmPage_Assets_Repair assetRepairForm = new SlmPage_Assets_Repair (pageConfig); + SlmFormPage_Assets_Repair.Config pageConfig = new SlmFormPage_Assets_Repair.Config(); + SlmFormPage_Assets_Repair assetRepairForm = new SlmFormPage_Assets_Repair (pageConfig); assetRepairForm.Disappearing += (sender2, e2) => { AssetRepairFormActive = false; diff --git a/LogisticsMgrMobile/LogisticsMgrMobile/Mobile/Forms/Components/SlmComponents_AssetMovement.cs b/LogisticsMgrMobile/LogisticsMgrMobile/Mobile/Forms/Components/Assets/SlmComponents_AssetMovement.cs similarity index 71% rename from LogisticsMgrMobile/LogisticsMgrMobile/Mobile/Forms/Components/SlmComponents_AssetMovement.cs rename to LogisticsMgrMobile/LogisticsMgrMobile/Mobile/Forms/Components/Assets/SlmComponents_AssetMovement.cs index e1d1638..10e16d5 100644 --- a/LogisticsMgrMobile/LogisticsMgrMobile/Mobile/Forms/Components/SlmComponents_AssetMovement.cs +++ b/LogisticsMgrMobile/LogisticsMgrMobile/Mobile/Forms/Components/Assets/SlmComponents_AssetMovement.cs @@ -11,7 +11,7 @@ using System.Collections.Generic; using System.Text; using Xamarin.Forms; -namespace Sarand.LogisticsMgr.Mobile.Forms.Components +namespace Sarand.LogisticsMgr.Mobile.Forms.Components.Assets { //======================================================================= public class SlmComponents_AssetMovement : SlmComponents @@ -32,66 +32,35 @@ namespace Sarand.LogisticsMgr.Mobile.Forms.Components //------------------------------------------------------------------- // Properties. public String MessageTitle { get; set; } = "Asset Movement"; - // Asset Code. - public SlmLabel LabelAssetCode { get; } = new SlmLabel() { Text = "Container no." }; - public SlmEntryView EntryAssetCode { get; } = new SlmEntryView(); - // Asset Size. - public SlmLabel LabelAssetSize { get; } = new SlmLabel() { Text = "Size" }; - public SlmPickerView_CodeType PickerAssetSize { get; } = new SlmPickerView_CodeType() { CodeType = Slm.CodeType.ContainerSize }; - // Movement type. - public SlmLabel LabelMovementType { get; } = new SlmLabel() { Text = "Movement type" }; - public SlmPickerView_SystemCodes PickerMovementType { get; } = new SlmPickerView_SystemCodes(Slm.SystemCode.AssetMovementType) { }; - // Reference. - public SlmLabel LabelReference { get; } = new SlmLabel() { Text = "Reference" }; - public SlmEntryView EntryReference { get; } = new SlmEntryView(); - // Movement date. - public SlmLabel LabelMovementDate { get; } = new SlmLabel() { Text = "Movement date" }; - public SlmDatePickerView DatePickerMovementDate { get; } = new SlmDatePickerView(); + // Asset. + public SlmEntryView EntryAssetCode { get; } = new SlmEntryView() { LabelText = "Container no." }; + public SlmPickerView_CodeType PickerAssetSize { get; } = new SlmPickerView_CodeType() { LabelText = "Size", CodeType = Slm.CodeType.ContainerSize }; + // Movement. + public SlmPickerView_SystemCodes PickerMovementType { get; } = new SlmPickerView_SystemCodes(Slm.SystemCode.AssetMovementType) { LabelText = "Movement type" }; + public SlmEntryView EntryReference { get; } = new SlmEntryView() { LabelText = "Reference" }; + public SlmDatePickerView DatePickerMovementDate { get; } = new SlmDatePickerView() { LabelText = "Movement date" }; // Customer. - public SlmLabel LabelCustomer { get; } = new SlmLabel() { Text = "Customer" }; - public SlmEntryView EntryCustomer { get; } = new SlmEntryView(); - // Customer reference. - public SlmLabel LabelCustomerReference { get; } = new SlmLabel() { Text = "Customer ref" }; - public SlmEntryView EntryCustomerReference { get; } = new SlmEntryView(); - // Location - start. - public SlmLabel LabelLocationStart { get; } = new SlmLabel() { Text = "Location - start" }; - public SlmEntryView EntryLocationStart { get; } = new SlmEntryView(); - // Location - current. - public SlmLabel LabelLocationCurrent { get; } = new SlmLabel() { Text = "Location - current" }; - public SlmEntryView EntryLocationCurrent { get; } = new SlmEntryView(); - // Location - finish. - public SlmLabel LabelLocationFinish { get; } = new SlmLabel() { Text = "Location - finish" }; - public SlmEntryView EntryLocationFinish { get; } = new SlmEntryView(); - // Haulier - initial. - public SlmLabel LabelHaulierInitial { get; } = new SlmLabel() { Text = "Haulier - initial" }; - public SlmEntryView EntryHaulierInitial { get; } = new SlmEntryView(); - // Registration - initial. - public SlmLabel LabelRegistrationInitial { get; } = new SlmLabel() { Text = "Registration - initial" }; - public SlmEntryView EntryRegistrationInitial { get; } = new SlmEntryView(); - // Haulier - final. - public SlmLabel LabelHaulierFinal { get; } = new SlmLabel() { Text = "Haulier - final" }; - public SlmEntryView EntryHaulierFinal { get; } = new SlmEntryView(); - // Registration - final. - public SlmLabel LabelRegistrationFinal { get; } = new SlmLabel() { Text = "Registration - final" }; - public SlmEntryView EntryRegistrationFinal { get; } = new SlmEntryView(); - // Pin number. - public SlmLabel LabelPinNumber { get; } = new SlmLabel() { Text = "PIN" }; - public SlmEntryView EntryPinNumber { get; } = new SlmEntryView(); - // Seal number. - public SlmLabel LabelSealNumber { get; } = new SlmLabel() { Text = "Seal number" }; - public SlmEntryView EntrySealNumber { get; } = new SlmEntryView(); - // Status. - public SlmLabel LabelStatus { get; } = new SlmLabel() { Text = "Status" }; - public SlmEntryView EntryStatus { get; } = new SlmEntryView(); - // InProgress date. - public SlmLabel LabelInProgressDate { get; } = new SlmLabel() { Text = "In progress" }; - public SlmDatePickerView DatePickerInProgressDate { get; } = new SlmDatePickerView(); - // Completed date. - public SlmLabel LabelCompletedDate { get; } = new SlmLabel() { Text = "Completed" }; - public SlmDatePickerView DatePickerCompletedDate { get; } = new SlmDatePickerView(); + public SlmEntryView EntryCustomer { get; } = new SlmEntryView() { LabelText = "Customer" }; + public SlmEntryView EntryCustomerReference { get; } = new SlmEntryView() { LabelText = "Customer ref" }; + // Location. + public SlmEntryView EntryLocationStart { get; } = new SlmEntryView() { LabelText = "Location - start" }; + public SlmEntryView EntryLocationCurrent { get; } = new SlmEntryView() { LabelText = "Location - current" }; + public SlmEntryView EntryLocationFinish { get; } = new SlmEntryView() { LabelText = "Location - finish" }; + // Haulier. + public SlmEntryView EntryHaulierInitial { get; } = new SlmEntryView() { LabelText = "Haulier - initial" }; + public SlmEntryView EntryHaulierFinal { get; } = new SlmEntryView() { LabelText = "Haulier - final" }; + // Registration. + public SlmEntryView EntryRegistrationInitial { get; } = new SlmEntryView() { LabelText = "Registration - initial" }; + public SlmEntryView EntryRegistrationFinal { get; } = new SlmEntryView() { LabelText = "Registration - final" }; + // Numbers. + public SlmEntryView EntryPinNumber { get; } = new SlmEntryView() { LabelText = "PIN" }; + public SlmEntryView EntrySealNumber { get; } = new SlmEntryView() { LabelText = "Seal number" }; + // Status & dates. + public SlmEntryView EntryStatus { get; } = new SlmEntryView() { LabelText = "Status" }; + public SlmDatePickerView DatePickerInProgressDate { get; } = new SlmDatePickerView() { LabelText = "In progress" }; + public SlmDatePickerView DatePickerCompletedDate { get; } = new SlmDatePickerView() { LabelText = "Completed" }; // Notes. - public SlmLabel LabelNotes { get; } = new SlmLabel() { Text = "Notes" }; - public SlmEditorView EntryNotes { get; } = new SlmEditorView(); + public SlmEditorView EditorNotes { get; } = new SlmEditorView() { LabelText = "Notes" }; //------------------------------------------------------------------- // Utilities. @@ -144,7 +113,7 @@ namespace Sarand.LogisticsMgr.Mobile.Forms.Components EntryReference.Text = data.MovementRef; DatePickerInProgressDate.Date = data.InProgressAt; DatePickerCompletedDate.Date = data.CompletedAt; - EntryNotes.Text = data.Notes; + EditorNotes.Text = data.Notes; Changed = false; } //------------------------------------------------------------------- @@ -186,7 +155,7 @@ namespace Sarand.LogisticsMgr.Mobile.Forms.Components EntryStatus.ReadOnly = ReadOnly; DatePickerInProgressDate.ReadOnly = ReadOnly; DatePickerCompletedDate.ReadOnly = ReadOnly; - EntryNotes.ReadOnly = ReadOnly; + EditorNotes.ReadOnly = ReadOnly; } //------------------------------------------------------------------- diff --git a/LogisticsMgrMobile/LogisticsMgrMobile/Mobile/Forms/Components/SlmComponents_AssetRepair.cs b/LogisticsMgrMobile/LogisticsMgrMobile/Mobile/Forms/Components/Assets/SlmComponents_AssetRepair.cs similarity index 88% rename from LogisticsMgrMobile/LogisticsMgrMobile/Mobile/Forms/Components/SlmComponents_AssetRepair.cs rename to LogisticsMgrMobile/LogisticsMgrMobile/Mobile/Forms/Components/Assets/SlmComponents_AssetRepair.cs index 0e5f6e5..ccf4fcd 100644 --- a/LogisticsMgrMobile/LogisticsMgrMobile/Mobile/Forms/Components/SlmComponents_AssetRepair.cs +++ b/LogisticsMgrMobile/LogisticsMgrMobile/Mobile/Forms/Components/Assets/SlmComponents_AssetRepair.cs @@ -11,7 +11,7 @@ using System.Collections.Generic; using System.Text; using Xamarin.Forms; -namespace Sarand.LogisticsMgr.Mobile.Forms.Components +namespace Sarand.LogisticsMgr.Mobile.Forms.Components.Assets { //======================================================================= public class SlmComponents_AssetRepair : SlmComponents @@ -30,21 +30,15 @@ namespace Sarand.LogisticsMgr.Mobile.Forms.Components //------------------------------------------------------------------- // Properties. public String MessageTitle { get; set; } = "Asset Repair"; + // Controls. // Shipping Line company. - public SlmLabel LabelCompany { get; } = new SlmLabel() { Text = "Shipping line" }; - public SlmPickerView_Companies PickerCompany { get; } = new SlmPickerView_Companies() { CompanyType = Slm.CompanyType.ContainerLine }; - // Asset Code. - public SlmLabel LabelAssetCode { get; } = new SlmLabel() { Text = "Container no." }; - public SlmEntryView EntryAssetCode { get; } = new SlmEntryView(); - // Asset Size. - public SlmLabel LabelAssetSize { get; } = new SlmLabel() { Text = "Size" }; - public SlmPickerView_CodeType PickerAssetSize { get; } = new SlmPickerView_CodeType() { CodeType = Slm.CodeType.ContainerSize }; - // Repair Narrative. - public SlmLabel LabelRepairNarrative { get; } = new SlmLabel() { Text = "Narrative" }; - public SlmEntryView EntryRepairNarrative { get; } = new SlmEntryView(); - // Repair Inspector. - public SlmLabel LabelRepairInspector { get; } = new SlmLabel() { Text = "Inspector" }; - public SlmEntryView EntryRepairInspector { get; } = new SlmEntryView(); + public SlmPickerView_Companies PickerCompany { get; } = new SlmPickerView_Companies() { LabelText = "Shipping line", CompanyType = Slm.CompanyType.ContainerLine }; + // Asset. + public SlmEntryView EntryAssetCode { get; } = new SlmEntryView() { LabelText = "Container no." }; + public SlmPickerView_CodeType PickerAssetSize { get; } = new SlmPickerView_CodeType() { LabelText = "Size", CodeType = Slm.CodeType.ContainerSize }; + // Repair. + public SlmEntryView EntryRepairNarrative { get; } = new SlmEntryView() { LabelText = "Narrative" }; + public SlmEntryView EntryRepairInspector { get; } = new SlmEntryView() { LabelText = "Inspector" }; // Repair Authorisation type. public Slm.AssetRepairAuthoriseType RepairAuthoriseType { diff --git a/LogisticsMgrMobile/LogisticsMgrMobile/Mobile/Forms/Components/SlmComponents_AssetRepairImage.cs b/LogisticsMgrMobile/LogisticsMgrMobile/Mobile/Forms/Components/Assets/SlmComponents_AssetRepairImage.cs similarity index 92% rename from LogisticsMgrMobile/LogisticsMgrMobile/Mobile/Forms/Components/SlmComponents_AssetRepairImage.cs rename to LogisticsMgrMobile/LogisticsMgrMobile/Mobile/Forms/Components/Assets/SlmComponents_AssetRepairImage.cs index b86f181..31e45a7 100644 --- a/LogisticsMgrMobile/LogisticsMgrMobile/Mobile/Forms/Components/SlmComponents_AssetRepairImage.cs +++ b/LogisticsMgrMobile/LogisticsMgrMobile/Mobile/Forms/Components/Assets/SlmComponents_AssetRepairImage.cs @@ -7,14 +7,13 @@ using System.Collections.Generic; using System.Text; using Xamarin.Forms; -namespace Sarand.LogisticsMgr.Mobile.Forms.Components +namespace Sarand.LogisticsMgr.Mobile.Forms.Components.Assets { //======================================================================= public class SlmComponents_AssetRepairImage : SlmComponents { //------------------------------------------------------------------- // Data members. - private SlmSessionProfile_Mobile sessionProfile = SlmGlobals_Mobile.SessionProfile; //------------------------------------------------------------------- // Construction. @@ -26,8 +25,7 @@ namespace Sarand.LogisticsMgr.Mobile.Forms.Components //------------------------------------------------------------------- // Properties. // Filename. - public SlmLabel LabelFilename { get; } = new SlmLabel() { Text = "Filename" }; - public SlmEntryView EntryFilename { get; } = new SlmEntryView(); + public SlmEntryView EntryFilename { get; } = new SlmEntryView() { LabelText = "Filename" }; //------------------------------------------------------------------- // Utilities. diff --git a/LogisticsMgrMobile/LogisticsMgrMobile/Mobile/Forms/Components/SlmComponents_AssetRepairJob.cs b/LogisticsMgrMobile/LogisticsMgrMobile/Mobile/Forms/Components/Assets/SlmComponents_AssetRepairJob.cs similarity index 92% rename from LogisticsMgrMobile/LogisticsMgrMobile/Mobile/Forms/Components/SlmComponents_AssetRepairJob.cs rename to LogisticsMgrMobile/LogisticsMgrMobile/Mobile/Forms/Components/Assets/SlmComponents_AssetRepairJob.cs index c468beb..573cd15 100644 --- a/LogisticsMgrMobile/LogisticsMgrMobile/Mobile/Forms/Components/SlmComponents_AssetRepairJob.cs +++ b/LogisticsMgrMobile/LogisticsMgrMobile/Mobile/Forms/Components/Assets/SlmComponents_AssetRepairJob.cs @@ -10,7 +10,7 @@ using System.Collections.Generic; using System.Text; using Xamarin.Forms; -namespace Sarand.LogisticsMgr.Mobile.Forms.Components +namespace Sarand.LogisticsMgr.Mobile.Forms.Components.Assets { //======================================================================= public class SlmComponents_AssetRepairJob : SlmComponents @@ -20,7 +20,6 @@ namespace Sarand.LogisticsMgr.Mobile.Forms.Components //------------------------------------------------------------------- // Data members. - private SlmSessionProfile_Mobile sessionProfile = SlmGlobals_Mobile.SessionProfile; private static readonly int codeEntryWidth = 48; //------------------------------------------------------------------- @@ -33,24 +32,19 @@ namespace Sarand.LogisticsMgr.Mobile.Forms.Components //------------------------------------------------------------------- // Properties. // Location code. - public SlmLabel LabelLocation { get; } = new SlmLabel() { Text = "Location" }; - public SlmEntryView EntryLocation { get; } = new SlmEntryView(); + public SlmEntryView EntryLocation { get; } = new SlmEntryView() { LabelText = "Location" }; public SlmPickerView_CodeType PickerLocation { get; } = new SlmPickerView_CodeType() { CodeType = Slm.CodeType.AssetRepair_Location }; // Component code. - public SlmLabel LabelComponent { get; } = new SlmLabel() { Text = "Component" }; - public SlmEntryView EntryComponent { get; } = new SlmEntryView(); + public SlmEntryView EntryComponent { get; } = new SlmEntryView() { LabelText = "Component" }; public SlmPickerView_CodeType PickerComponent { get; } = new SlmPickerView_CodeType() { CodeType = Slm.CodeType.AssetRepair_Component }; // Damage code. - public SlmLabel LabelDamage { get; } = new SlmLabel() { Text = "Damage" }; - public SlmEntryView EntryDamage { get; } = new SlmEntryView(); + public SlmEntryView EntryDamage { get; } = new SlmEntryView() { LabelText = "Damage" }; public SlmPickerView_CodeType PickerDamage { get; } = new SlmPickerView_CodeType() { CodeType = Slm.CodeType.AssetRepair_Damage }; // Repair code. - public SlmLabel LabelRepair { get; } = new SlmLabel() { Text = "Repair" }; - public SlmEntryView EntryRepair { get; } = new SlmEntryView(); + public SlmEntryView EntryRepair { get; } = new SlmEntryView() { LabelText = "Repair" }; public SlmPickerView_CodeType PickerRepair { get; } = new SlmPickerView_CodeType() { CodeType = Slm.CodeType.AssetRepair_Repair }; // Quantity. - public SlmLabel LabelQuantity { get; } = new SlmLabel() { Text = "Quantity" }; - public SlmEntryView EntryQuantity { get; } = new SlmEntryView(); + public SlmEntryView EntryQuantity { get; } = new SlmEntryView() { LabelText = "Quantity" }; //------------------------------------------------------------------- // Utilities. diff --git a/LogisticsMgrMobile/LogisticsMgrMobile/Mobile/Forms/Components/Bulk/SlmComponents_Berthing.cs b/LogisticsMgrMobile/LogisticsMgrMobile/Mobile/Forms/Components/Bulk/SlmComponents_Berthing.cs new file mode 100644 index 0000000..8a9efd9 --- /dev/null +++ b/LogisticsMgrMobile/LogisticsMgrMobile/Mobile/Forms/Components/Bulk/SlmComponents_Berthing.cs @@ -0,0 +1,123 @@ +using Sarand.Core.Base; +using Sarand.LogisticsMgr.Core.App; +using Sarand.LogisticsMgr.Core.Bus; +using Sarand.LogisticsMgr.Mobile.App; +using Sarand.LogisticsMgr.Mobile.Core.App; +using Sarand.LogisticsMgr.Mobile.Core.Forms.Base; +using Sarand.LogisticsMgr.Mobile.Core.Forms.Controls; +using System; +using System.Collections.Generic; +using System.Text; +using Xamarin.Forms; + +namespace Sarand.LogisticsMgr.Mobile.Forms.Components.Bulk +{ + //======================================================================= + public class SlmComponents_Berthing : SlmComponents + { + //------------------------------------------------------------------- + // Data members. + private SlmSessionProfile_Mobile sessionProfile = SlmGlobals_Mobile.SessionProfile; + + //------------------------------------------------------------------- + // Construction. + public SlmComponents_Berthing () + { + InitialiseComponents(); + } + + //------------------------------------------------------------------- + // Properties. + // Vessel. + public SlmPickerView PickerVessel { get; } = new SlmPickerView() { LabelText = "Vessel", ReadOnly = true }; + // Berthing. + public SlmPickerView PickerAgent { get; } = new SlmPickerView() { LabelText = "Agent", ReadOnly = true }; + public SlmPickerView PickerCustomer { get; } = new SlmPickerView() { LabelText = "Customer", ReadOnly = true }; + // Notes. + public SlmEditorView EditorNotes { get; } = new SlmEditorView() { LabelText = "Notes" }; + + //------------------------------------------------------------------- + // Utilities. + + //------------------------------------------------------------------- + // I n i t i a l i s e + //------------------------------------------------------------------- + private void InitialiseComponents () + { + // Control events. + PickerVessel.SelectedIndexChanged += PickerVessel_SelectedIndexChanged; + PickerAgent.SelectedIndexChanged += PickerAgent_SelectedIndexChanged; + PickerCustomer.SelectedIndexChanged += PickerCustomer_SelectedIndexChanged; + EditorNotes.TextChanged += EditorNotes_TextChanged; + EditorNotes.Completed += EditorNotes_Completed; + + Changed = false; + } + + //------------------------------------------------------------------- + // P o p u l a t i o n + //------------------------------------------------------------------- + public void PopulateToControls (SlmVessel.Data data) + { + Changed = false; + } + public void PopulateToControls (SlmBerthing.Data data) + { + EditorNotes.Text = data.Notes; + Changed = false; + } + //------------------------------------------------------------------- + public bool IsDataValid (SlmAssetMovement.Data data) + { + return true; + } + //------------------------------------------------------------------- + public void PopulateFromControls (SlmAssetMovement.Data data) + { + } + + //------------------------------------------------------------------- + // C o n t r o l A c t i v i t y + //------------------------------------------------------------------- + protected override void SetControlActivity () + { + SetControlsReadOnly(); + } + protected override void SetControlsReadOnly () + { + PickerVessel.ReadOnly = true; + PickerAgent.ReadOnly = ReadOnly; + PickerCustomer.ReadOnly = ReadOnly; + EditorNotes.ReadOnly = ReadOnly; + } + + //------------------------------------------------------------------- + // C o n t r o l E v e n t s + //------------------------------------------------------------------- + private void PickerVessel_SelectedIndexChanged (object sender, EventArgs e) + { + Changed = true; + } + //------------------------------------------------------------------- + private void PickerAgent_SelectedIndexChanged (object sender, EventArgs e) + { + Changed = true; + } + //------------------------------------------------------------------- + private void PickerCustomer_SelectedIndexChanged (object sender, EventArgs e) + { + Changed = true; + } + //------------------------------------------------------------------- + private void EditorNotes_TextChanged (object sender, TextChangedEventArgs e) + { + } + private void EditorNotes_Completed (object sender, EventArgs e) + { + Changed = true; + } + + //------------------------------------------------------------------- + } + //======================================================================= +} diff --git a/LogisticsMgrMobile/LogisticsMgrMobile/Mobile/Forms/Components/Bulk/SlmComponents_BerthingTask.cs b/LogisticsMgrMobile/LogisticsMgrMobile/Mobile/Forms/Components/Bulk/SlmComponents_BerthingTask.cs new file mode 100644 index 0000000..3d862fd --- /dev/null +++ b/LogisticsMgrMobile/LogisticsMgrMobile/Mobile/Forms/Components/Bulk/SlmComponents_BerthingTask.cs @@ -0,0 +1,107 @@ +using Sarand.Core.Base; +using Sarand.LogisticsMgr.Core.App; +using Sarand.LogisticsMgr.Core.Bus; +using Sarand.LogisticsMgr.Mobile.Core.App; +using Sarand.LogisticsMgr.Mobile.Core.Forms.Base; +using Sarand.LogisticsMgr.Mobile.Core.Forms.Controls; +using System; +using System.Collections.Generic; +using System.Text; +using Xamarin.Forms; + +namespace Sarand.LogisticsMgr.Mobile.Forms.Components.Bulk +{ + //======================================================================= + public class SlmComponents_BerthingTask : SlmComponents + { + //------------------------------------------------------------------- + // Data members. + private SlmSessionProfile_Mobile sessionProfile = SlmGlobals_Mobile.SessionProfile; + private readonly List berthingTaskTypes; + + //------------------------------------------------------------------- + // Construction. + public SlmComponents_BerthingTask() + { + berthingTaskTypes = SlmSystem.GetCodesOfType(Slm.SystemCode.BerthingTaskType); + InitialiseComponents(); + } + + //------------------------------------------------------------------- + // Properties. + // Controls. + public SlmPickerView_SystemCodes PickerTaskType { get; } = new SlmPickerView_SystemCodes(Slm.SystemCode.BerthingTaskType) { LabelText = "Task type" }; + public SlmDatePickerView DatePickerStarted { get; } = new SlmDatePickerView() { LabelText = "Started" }; + public SlmDatePickerView DatePickerCompleted { get; } = new SlmDatePickerView() { LabelText = "Completed" }; + public SlmEditorView EntryRemarks { get; } = new SlmEditorView() { LabelText = "Remarks" }; + + //------------------------------------------------------------------- + // Utilities. + + //------------------------------------------------------------------- + // I n i t i a l i s e + //------------------------------------------------------------------- + private void InitialiseComponents () + { + // Filename. + EntryRemarks.MaxLength = (int)SlmDbDfn.GetColTextLen(SlmDbDfn.ColumnIdx.BerthingTask_Remarks); + EntryRemarks.TextChanged += EntryRemarks_TextChanged; + EntryRemarks.Completed += EntryRemarks_Completed; + + Changed = false; + } + + //------------------------------------------------------------------- + // P o p u l a t i o n + //------------------------------------------------------------------- + public void PopulateToControls (SlmBerthingTask.Data data) + { + PickerTaskType.SelectedCode = berthingTaskTypes.GetCodeForType((int)data.BerthingTaskType); + DatePickerStarted.Date = data.Started; + DatePickerCompleted.Date = data.Completed; + EntryRemarks.Text = data.Remarks; + Changed = false; + } + public bool IsDataValid (SlmBerthingTask.Data data) + { + return true; + } + public void PopulateFromControls (SlmBerthingTask.Data data) + { + data.BerthingTaskType = (Slm.BerthingTaskType)berthingTaskTypes.GetTypeForCode(PickerTaskType.SelectedCode); + data.Started = DatePickerStarted.Date; + data.Completed = DatePickerCompleted.Date; + data.Remarks = EntryRemarks.Text; + } + + //------------------------------------------------------------------- + // C o n t r o l A c t i v i t y + //------------------------------------------------------------------- + protected override void SetControlActivity () + { + SetControlsReadOnly(); + } + protected override void SetControlsReadOnly () + { + PickerTaskType.ReadOnly = ReadOnly; + DatePickerStarted.ReadOnly = ReadOnly; + DatePickerCompleted.ReadOnly = ReadOnly; + EntryRemarks.ReadOnly = ReadOnly; + } + + //------------------------------------------------------------------- + // C o n t r o l E v e n t s + //------------------------------------------------------------------- + // Filename. + private void EntryRemarks_TextChanged (object sender, TextChangedEventArgs e) + { + } + private void EntryRemarks_Completed (object sender, EventArgs e) + { + Changed = true; + } + + //------------------------------------------------------------------- + } + //======================================================================= +} diff --git a/LogisticsMgrMobile/LogisticsMgrMobile/Mobile/Forms/Pages/Assets/SlmPage_Assets_Movement.cs b/LogisticsMgrMobile/LogisticsMgrMobile/Mobile/Forms/Pages/Assets/SlmPage_Assets_Movement.cs deleted file mode 100644 index 7aac75d..0000000 --- a/LogisticsMgrMobile/LogisticsMgrMobile/Mobile/Forms/Pages/Assets/SlmPage_Assets_Movement.cs +++ /dev/null @@ -1,271 +0,0 @@ -using Sarand.Core.App; -using Sarand.Core.Base; -using Sarand.Core.Bus; -using Sarand.Core.Tasks; -using Sarand.Core.Xml; -using Sarand.LogisticsMgr.Core.App; -using Sarand.LogisticsMgr.Core.Bus; -using Sarand.LogisticsMgr.Core.WebService; -using Sarand.LogisticsMgr.Mobile.Core.Forms.Base; -using Sarand.LogisticsMgr.Mobile.Forms.Components; -using Sarand.LogisticsMgr.Mobile.Forms.Effects; -using Sarand.LogisticsMgr.Mobile.Forms.Panels.Assets; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Xml.Linq; -using Xamarin.Forms; - -namespace Sarand.LogisticsMgr.Mobile.Forms.Pages.Assets -{ - //======================================================================= - public class SlmPage_Assets_Movement : SlmFormPage - { - //------------------------------------------------------------------- - // Definitions. - public new class Config : SlmFormPage.Config - { - public SlmAssetMovement AssetMovementToUpdate { get; set; } - public SlmContainer AssetMovement_Container { get; set; } - } - private class AssetMovementData - { - public Slm.AssetItemType AssetItemType { get; set; } - public SysId AssetItemId { get; set; } - } - - //------------------------------------------------------------------- - // Data members. - private readonly Config config; - private readonly AssetMovementData assetMovementData = new AssetMovementData(); - private SlmGrid gridProperties = new SlmGrid(); - private SlmComponents_AssetMovement assetMovementComponents = new SlmComponents_AssetMovement(); - - //------------------------------------------------------------------- - // Construction. - public SlmPage_Assets_Movement (Config config) : base(config) - { - this.config = config; - Title = "Asset Movement"; - AddMode = config.AssetMovementToUpdate == null; - if (config.ReadOnly) - { - assetMovementComponents.ReadOnly = true; - } - InitialiseComponents(); - } - - //------------------------------------------------------------------- - // Properties. - - //------------------------------------------------------------------- - // I n i t i a l i s e - //------------------------------------------------------------------- - private void InitialiseComponents () - { - // Asset Repair form. - FormBodyView.Content = gridProperties; - gridProperties.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto }); - gridProperties.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Star }); - gridProperties.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto }); - int rowIdx = -1; - - // Asset code. - rowIdx = gridProperties.RowDefinitions.Count; - gridProperties.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); - gridProperties.Children.Add(assetMovementComponents.LabelAssetCode, 0, rowIdx); - //entryAssetCode.Effects.Add(new InputCaseEffect()); - gridProperties.Children.Add(assetMovementComponents.EntryAssetCode, 1, rowIdx); - Grid.SetColumnSpan(assetMovementComponents.EntryAssetCode, 2); - assetMovementComponents.EntryAssetCode.TextChanged += EntryAssetCode_TextChanged; - assetMovementComponents.EntryAssetCode.Completed += EntryAssetCode_Completed; - - // Asset Size. - rowIdx = gridProperties.RowDefinitions.Count; - gridProperties.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); - gridProperties.Children.Add(assetMovementComponents.LabelAssetSize, 0, rowIdx); - gridProperties.Children.Add(assetMovementComponents.PickerAssetSize, 1, rowIdx); - Grid.SetColumnSpan(assetMovementComponents.PickerAssetSize, 2); - - // Movement type. - rowIdx = gridProperties.RowDefinitions.Count; - gridProperties.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); - gridProperties.Children.Add(assetMovementComponents.LabelMovementType, 0, rowIdx); - gridProperties.Children.Add(assetMovementComponents.PickerMovementType, 1, rowIdx); - Grid.SetColumnSpan(assetMovementComponents.PickerMovementType, 2); - - // Reference. - rowIdx = gridProperties.RowDefinitions.Count; - gridProperties.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); - gridProperties.Children.Add(assetMovementComponents.LabelReference, 0, rowIdx); - gridProperties.Children.Add(assetMovementComponents.EntryReference, 1, rowIdx); - Grid.SetColumnSpan(assetMovementComponents.EntryReference, 2); - - // Movement date. - rowIdx = gridProperties.RowDefinitions.Count; - gridProperties.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); - gridProperties.Children.Add(assetMovementComponents.LabelMovementDate, 0, rowIdx); - gridProperties.Children.Add(assetMovementComponents.DatePickerMovementDate, 1, rowIdx); - Grid.SetColumnSpan(assetMovementComponents.DatePickerMovementDate, 2); - - // Customer. - rowIdx = gridProperties.RowDefinitions.Count; - gridProperties.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); - gridProperties.Children.Add(assetMovementComponents.LabelCustomer, 0, rowIdx); - gridProperties.Children.Add(assetMovementComponents.EntryCustomer, 1, rowIdx); - Grid.SetColumnSpan(assetMovementComponents.EntryCustomer, 2); - - // CustomerReference. - rowIdx = gridProperties.RowDefinitions.Count; - gridProperties.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); - gridProperties.Children.Add(assetMovementComponents.LabelCustomerReference, 0, rowIdx); - gridProperties.Children.Add(assetMovementComponents.EntryCustomerReference, 1, rowIdx); - Grid.SetColumnSpan(assetMovementComponents.EntryCustomerReference, 2); - - // LocationStart. - rowIdx = gridProperties.RowDefinitions.Count; - gridProperties.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); - gridProperties.Children.Add(assetMovementComponents.LabelLocationStart, 0, rowIdx); - gridProperties.Children.Add(assetMovementComponents.EntryLocationStart, 1, rowIdx); - Grid.SetColumnSpan(assetMovementComponents.EntryLocationStart, 2); - - // LocationCurrent. - rowIdx = gridProperties.RowDefinitions.Count; - gridProperties.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); - gridProperties.Children.Add(assetMovementComponents.LabelLocationCurrent, 0, rowIdx); - gridProperties.Children.Add(assetMovementComponents.EntryLocationCurrent, 1, rowIdx); - Grid.SetColumnSpan(assetMovementComponents.EntryLocationCurrent, 2); - - // LocationFinish. - rowIdx = gridProperties.RowDefinitions.Count; - gridProperties.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); - gridProperties.Children.Add(assetMovementComponents.LabelLocationFinish, 0, rowIdx); - gridProperties.Children.Add(assetMovementComponents.EntryLocationFinish, 1, rowIdx); - Grid.SetColumnSpan(assetMovementComponents.EntryLocationFinish, 2); - - // HaulierInitial. - rowIdx = gridProperties.RowDefinitions.Count; - gridProperties.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); - gridProperties.Children.Add(assetMovementComponents.LabelHaulierInitial, 0, rowIdx); - gridProperties.Children.Add(assetMovementComponents.EntryHaulierInitial, 1, rowIdx); - Grid.SetColumnSpan(assetMovementComponents.EntryHaulierInitial, 2); - - // RegistrationInitial. - rowIdx = gridProperties.RowDefinitions.Count; - gridProperties.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); - gridProperties.Children.Add(assetMovementComponents.LabelRegistrationInitial, 0, rowIdx); - gridProperties.Children.Add(assetMovementComponents.EntryRegistrationInitial, 1, rowIdx); - Grid.SetColumnSpan(assetMovementComponents.EntryRegistrationInitial, 2); - - // HaulierFinal. - rowIdx = gridProperties.RowDefinitions.Count; - gridProperties.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); - gridProperties.Children.Add(assetMovementComponents.LabelHaulierFinal, 0, rowIdx); - gridProperties.Children.Add(assetMovementComponents.EntryHaulierFinal, 1, rowIdx); - Grid.SetColumnSpan(assetMovementComponents.EntryHaulierFinal, 2); - - // RegistrationFinal. - rowIdx = gridProperties.RowDefinitions.Count; - gridProperties.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); - gridProperties.Children.Add(assetMovementComponents.LabelRegistrationFinal, 0, rowIdx); - gridProperties.Children.Add(assetMovementComponents.EntryRegistrationFinal, 1, rowIdx); - Grid.SetColumnSpan(assetMovementComponents.EntryRegistrationFinal, 2); - - // PinNumber. - rowIdx = gridProperties.RowDefinitions.Count; - gridProperties.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); - gridProperties.Children.Add(assetMovementComponents.LabelPinNumber, 0, rowIdx); - gridProperties.Children.Add(assetMovementComponents.EntryPinNumber, 1, rowIdx); - Grid.SetColumnSpan(assetMovementComponents.EntryPinNumber, 2); - - // SealNumber. - rowIdx = gridProperties.RowDefinitions.Count; - gridProperties.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); - gridProperties.Children.Add(assetMovementComponents.LabelSealNumber, 0, rowIdx); - gridProperties.Children.Add(assetMovementComponents.EntrySealNumber, 1, rowIdx); - Grid.SetColumnSpan(assetMovementComponents.EntrySealNumber, 2); - - // Status. - rowIdx = gridProperties.RowDefinitions.Count; - gridProperties.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); - gridProperties.Children.Add(assetMovementComponents.LabelStatus, 0, rowIdx); - gridProperties.Children.Add(assetMovementComponents.EntryStatus, 1, rowIdx); - Grid.SetColumnSpan(assetMovementComponents.EntryStatus, 2); - - // InProgress date. - rowIdx = gridProperties.RowDefinitions.Count; - gridProperties.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); - gridProperties.Children.Add(assetMovementComponents.LabelInProgressDate, 0, rowIdx); - gridProperties.Children.Add(assetMovementComponents.DatePickerInProgressDate, 1, rowIdx); - Grid.SetColumnSpan(assetMovementComponents.DatePickerInProgressDate, 2); - - // Completed date. - rowIdx = gridProperties.RowDefinitions.Count; - gridProperties.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); - gridProperties.Children.Add(assetMovementComponents.LabelCompletedDate, 0, rowIdx); - gridProperties.Children.Add(assetMovementComponents.DatePickerCompletedDate, 1, rowIdx); - Grid.SetColumnSpan(assetMovementComponents.DatePickerCompletedDate, 2); - - // Notes. - rowIdx = gridProperties.RowDefinitions.Count; - gridProperties.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); - gridProperties.Children.Add(assetMovementComponents.LabelNotes, 0, rowIdx); - gridProperties.Children.Add(assetMovementComponents.EntryNotes, 1, rowIdx); - Grid.SetColumnSpan(assetMovementComponents.EntryNotes, 2); - - // Complete page configuration. - ConfigureComponents(); - } - - //------------------------------------------------------------------- - // C o n f i g u r e C o n t r o l s - //------------------------------------------------------------------- - private void ConfigureComponents () - { - // Populate properties to components. - assetMovementComponents.PopulateToControls(config.AssetMovement_Container?.GetData() ?? new SlmContainer.Data()); - assetMovementComponents.PopulateToControls(config.AssetMovementToUpdate?.GetData() ?? new SlmAssetMovement.Data()); - } - - //------------------------------------------------------------------- - // C o n t r o l A c t i v i t y - //------------------------------------------------------------------- - protected override void SetControlActivity () - { - base.SetControlActivity(); - } - protected override void SetControlsReadOnly () - { - } - - //------------------------------------------------------------------- - // N a v i g a t i o n E v e n t s - //------------------------------------------------------------------- - protected override bool SaveFormData () - { - return true; - } - //------------------------------------------------------------------- - protected override bool QueryCancelForm () - { - if (!base.QueryCancelForm()) return false; - return true; - } - - //------------------------------------------------------------------- - // P r o p e r t y E v e n t s - //------------------------------------------------------------------- - // Asset code. - private void EntryAssetCode_TextChanged (object sender, TextChangedEventArgs e) - { - } - private void EntryAssetCode_Completed (object sender, EventArgs e) - { - } - - //------------------------------------------------------------------- - } - //======================================================================= -} \ No newline at end of file diff --git a/LogisticsMgrMobile/LogisticsMgrMobile/Mobile/Forms/Pages/Forms/Assets/SlmFormPage_Assets_Movement.cs b/LogisticsMgrMobile/LogisticsMgrMobile/Mobile/Forms/Pages/Forms/Assets/SlmFormPage_Assets_Movement.cs new file mode 100644 index 0000000..b55421d --- /dev/null +++ b/LogisticsMgrMobile/LogisticsMgrMobile/Mobile/Forms/Pages/Forms/Assets/SlmFormPage_Assets_Movement.cs @@ -0,0 +1,234 @@ +using Sarand.Core.App; +using Sarand.Core.Base; +using Sarand.Core.Bus; +using Sarand.Core.Tasks; +using Sarand.LogisticsMgr.Core.App; +using Sarand.LogisticsMgr.Core.Bus; +using Sarand.LogisticsMgr.Mobile.Core.Forms.Base; +using Sarand.LogisticsMgr.Mobile.Forms.Components.Assets; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Linq; +using Xamarin.Forms; + +namespace Sarand.LogisticsMgr.Mobile.Forms.Pages.Forms.Assets +{ + //======================================================================= + public class SlmFormPage_Assets_Movement : SlmFormPage + { + //------------------------------------------------------------------- + // Definitions. + public new class Config : SlmFormPage.Config + { + public SysId AssetMovementIdToUpdate { get; set; } + } + private class AssetMovementData + { + public Slm.AssetItemType AssetItemType { get; set; } + public SysId AssetItemId { get; set; } + } + + //------------------------------------------------------------------- + // Data members. + private readonly Config config; + private readonly AssetMovementData assetMovementData = new AssetMovementData(); + private SlmGrid gridProperties = new SlmGrid(); + private SlmComponents_AssetMovement assetMovementComponents = new SlmComponents_AssetMovement(); + // Data to view/update. + public SlmAssetMovement assetMovementToUpdate { get; set; } + public SlmContainer assetMovement_Container { get; set; } + + //------------------------------------------------------------------- + // Construction. + public SlmFormPage_Assets_Movement (Config config) : base(config) + { + this.config = config; + Title = "Asset Movement"; + AddMode = !SysId.IsValid(config.AssetMovementIdToUpdate); + if (config.ReadOnly) + { + assetMovementComponents.ReadOnly = true; + } + PrepareFormData(); + } + + //------------------------------------------------------------------- + // Properties. + + //------------------------------------------------------------------- + // P r e p a r a t i o n + //------------------------------------------------------------------- + private SacsTaskData taskDataPrepareData = new SacsTaskData(null); + private void PrepareFormData () + { + String fn = GetType().Name+".PrepareFormData"; + if (!SysId.IsValid(config.AssetMovementIdToUpdate)) return; + + // Form is initialised on separate thread while data is retrieved from the service. + // 'Please wait' message is displayed during preparation. + // Any issue during preparation results in an alert message and the form is closed. + FormBodyView.Content = new SlmLabel() { Text = DataPreparationMessage }; + Task.Run(async () => + { + try + { + await PopulateAssetMovementData(taskDataPrepareData); + } + catch (Exception exc) + { + if (SacsSystem.DebugMode) Logger.Warn(fn + " " + ExceptionUtil.GetLogMessage(exc)); + CloseFormWithAlert(nameof(exc) + " on form initialisation.\n\n" + exc.Message); + } + }, taskDataPrepareData.CancellationToken) + .ContinueWith(task => + { + taskDataPrepareData.Dispose(); + }); + } + //------------------------------------------------------------------- + private async Task PopulateAssetMovementData (SacsTaskData taskDataPrepareData_Local) + { + String fn = GetType().Name + ".PopulateAssetMovementData"; + + // Retrieve Asset Movement and associated details. + try + { + // Retrieve Asset Movement. + SlmAssetMovement.Params prmAssetMovement = new SlmAssetMovement.Params(); + prmAssetMovement.IncludedIds.Add(config.AssetMovementIdToUpdate); + prmAssetMovement.StatusCat = SlmAssetMovement.StatusCat.Any; + assetMovementToUpdate = await AssetMgr.GetAssetMovement_Mobile(prmAssetMovement, taskDataPrepareData_Local); + // Retrieve Container. + if (assetMovementToUpdate != null) + { + if (assetMovementToUpdate.AssetItemType == Slm.AssetItemType.Container) + { + SlmContainer.Params prmContainer = new SlmContainer.Params(); + prmContainer.IncludedIds.Add(assetMovementToUpdate.AssetItemId); + prmContainer.StatusCat = SlmContainer.StatusCat.Any; + assetMovement_Container = await AssetMgr.GetContainer_Mobile(prmContainer, taskDataPrepareData_Local); + } + } + } + catch (Exception exc) { Logger.Debug(fn + " " + exc.GetLogMessage(6)); } + if (assetMovementToUpdate == null) + { + CloseFormWithAlert("Failed to retrieve Asset movement data."); + return; + } + if (assetMovementToUpdate.AssetItemType == Slm.AssetItemType.Container) + { + if (assetMovement_Container == null) + { + CloseFormWithAlert("Failed to retrieve Container data."); + return; + } + } + else + { + CloseFormWithAlert("Unrecognised asset type: " + assetMovementToUpdate.AssetItemType.ToString() + "."); + return; + } + if (taskDataPrepareData_Local.IsCancellationRequested) return; + + Device.BeginInvokeOnMainThread(() => + { + // Initialise form. + InitialiseComponents(); + }); + } + + //------------------------------------------------------------------- + // I n i t i a l i s e + //------------------------------------------------------------------- + private void InitialiseComponents () + { + // Asset Repair form. + FormBodyView.Content = gridProperties; + gridProperties.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto }); + gridProperties.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Star }); + gridProperties.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto }); + + //--------------------------------------------------------------- + // Asset. + AddControlViewToGrid(gridProperties, assetMovementComponents.EntryAssetCode); + AddControlViewToGrid(gridProperties, assetMovementComponents.PickerAssetSize); + + // Movement. + AddControlViewToGrid(gridProperties, assetMovementComponents.PickerMovementType); + AddControlViewToGrid(gridProperties, assetMovementComponents.EntryReference); + AddControlViewToGrid(gridProperties, assetMovementComponents.DatePickerMovementDate); + + // Customer. + AddControlViewToGrid(gridProperties, assetMovementComponents.EntryCustomer); + AddControlViewToGrid(gridProperties, assetMovementComponents.EntryCustomerReference); + + // Location. + AddControlViewToGrid(gridProperties, assetMovementComponents.EntryLocationStart); + AddControlViewToGrid(gridProperties, assetMovementComponents.EntryLocationCurrent); + AddControlViewToGrid(gridProperties, assetMovementComponents.EntryLocationFinish); + + // Haulier & Registration. + AddControlViewToGrid(gridProperties, assetMovementComponents.EntryHaulierInitial); + AddControlViewToGrid(gridProperties, assetMovementComponents.EntryRegistrationInitial); + AddControlViewToGrid(gridProperties, assetMovementComponents.EntryHaulierFinal); + AddControlViewToGrid(gridProperties, assetMovementComponents.EntryRegistrationFinal); + + // Numbers. + AddControlViewToGrid(gridProperties, assetMovementComponents.EntryPinNumber); + AddControlViewToGrid(gridProperties, assetMovementComponents.EntrySealNumber); + + // Status. + AddControlViewToGrid(gridProperties, assetMovementComponents.EntryStatus); + AddControlViewToGrid(gridProperties, assetMovementComponents.DatePickerInProgressDate); + AddControlViewToGrid(gridProperties, assetMovementComponents.DatePickerCompletedDate); + + // Notes. + AddControlViewToGrid(gridProperties, assetMovementComponents.EditorNotes); + + //--------------------------------------------------------------- + // Populate properties to components. + assetMovementComponents.PopulateToControls(assetMovement_Container?.GetData() ?? new SlmContainer.Data()); + assetMovementComponents.PopulateToControls(assetMovementToUpdate?.GetData() ?? new SlmAssetMovement.Data()); + + // Complete page configuration. + SetControlActivity(); + Changed = false; + } + + //------------------------------------------------------------------- + // C o n t r o l A c t i v i t y + //------------------------------------------------------------------- + protected override void SetControlActivity () + { + base.SetControlActivity(); + } + protected override void SetControlsReadOnly () + { + } + + //------------------------------------------------------------------- + // N a v i g a t i o n E v e n t s + //------------------------------------------------------------------- + protected override bool SaveFormData () + { + return true; + } + //------------------------------------------------------------------- + protected override bool QueryCancelForm () + { + if (!base.QueryCancelForm()) return false; + return true; + } + + //------------------------------------------------------------------- + // P r o p e r t y E v e n t s + //------------------------------------------------------------------- + + //------------------------------------------------------------------- + } + //======================================================================= +} \ No newline at end of file diff --git a/LogisticsMgrMobile/LogisticsMgrMobile/Mobile/Forms/Pages/Assets/SlmPage_Assets_Repair.cs b/LogisticsMgrMobile/LogisticsMgrMobile/Mobile/Forms/Pages/Forms/Assets/SlmFormPage_Assets_Repair.cs similarity index 76% rename from LogisticsMgrMobile/LogisticsMgrMobile/Mobile/Forms/Pages/Assets/SlmPage_Assets_Repair.cs rename to LogisticsMgrMobile/LogisticsMgrMobile/Mobile/Forms/Pages/Forms/Assets/SlmFormPage_Assets_Repair.cs index a019c82..7bc80c8 100644 --- a/LogisticsMgrMobile/LogisticsMgrMobile/Mobile/Forms/Pages/Assets/SlmPage_Assets_Repair.cs +++ b/LogisticsMgrMobile/LogisticsMgrMobile/Mobile/Forms/Pages/Forms/Assets/SlmFormPage_Assets_Repair.cs @@ -7,8 +7,7 @@ using Sarand.LogisticsMgr.Core.App; using Sarand.LogisticsMgr.Core.Bus; using Sarand.LogisticsMgr.Core.WebService; using Sarand.LogisticsMgr.Mobile.Core.Forms.Base; -using Sarand.LogisticsMgr.Mobile.Forms.Components; -using Sarand.LogisticsMgr.Mobile.Forms.Effects; +using Sarand.LogisticsMgr.Mobile.Forms.Components.Assets; using Sarand.LogisticsMgr.Mobile.Forms.Panels.Assets; using System; using System.Collections.Generic; @@ -18,10 +17,10 @@ using System.Threading.Tasks; using System.Xml.Linq; using Xamarin.Forms; -namespace Sarand.LogisticsMgr.Mobile.Forms.Pages.Assets +namespace Sarand.LogisticsMgr.Mobile.Forms.Pages.Forms.Assets { //======================================================================= - public class SlmPage_Assets_Repair : SlmFormPage + public class SlmFormPage_Assets_Repair : SlmFormPage { //------------------------------------------------------------------- // Definitions. @@ -40,7 +39,7 @@ namespace Sarand.LogisticsMgr.Mobile.Forms.Pages.Assets // Data members. private readonly Config config; private readonly AssetRepairData assetRepairData = new AssetRepairData(); - private SlmGrid gridRepairProperties = new SlmGrid(); + private SlmGrid gridProperties = new SlmGrid(); private SlmComponents_AssetRepair assetRepairComponents = new SlmComponents_AssetRepair(); private SlmPanel_AssetMovement_SearchResults assetSearchResultsWebView = new SlmPanel_AssetMovement_SearchResults() { IsVisible = false, }; private SlmPanel_AssetRepair_Jobs repairJobsPanel; @@ -48,7 +47,7 @@ namespace Sarand.LogisticsMgr.Mobile.Forms.Pages.Assets //------------------------------------------------------------------- // Construction. - public SlmPage_Assets_Repair (Config config) : base(config) + public SlmFormPage_Assets_Repair (Config config) : base(config) { this.config = config; AddMode = (config.AssetRepairToUpdate == null); @@ -66,35 +65,26 @@ namespace Sarand.LogisticsMgr.Mobile.Forms.Pages.Assets private void InitialiseComponents () { // Asset Repair form. - FormBodyView.Content = gridRepairProperties; - gridRepairProperties.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto }); - gridRepairProperties.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Star }); - gridRepairProperties.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto }); + FormBodyView.Content = gridProperties; + gridProperties.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto }); + gridProperties.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Star }); + gridProperties.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto }); int rowIdx = -1; // Shipping line company. - rowIdx = gridRepairProperties.RowDefinitions.Count; - gridRepairProperties.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); - gridRepairProperties.Children.Add(assetRepairComponents.LabelCompany, 0, rowIdx); - gridRepairProperties.Children.Add(assetRepairComponents.PickerCompany, 1, rowIdx); - Grid.SetColumnSpan(assetRepairComponents.PickerCompany, 2); + AddControlViewToGrid(gridProperties, assetRepairComponents.PickerCompany); assetRepairComponents.PickerCompany.Populated += PickerCompany_Populated; assetRepairComponents.PickerCompany.SelectedIndexChanged += PickerCompany_SelectedIndexChanged; // Asset code. - rowIdx = gridRepairProperties.RowDefinitions.Count; - gridRepairProperties.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); - gridRepairProperties.Children.Add(assetRepairComponents.LabelAssetCode, 0, rowIdx); - //entryAssetCode.Effects.Add(new InputCaseEffect()); - gridRepairProperties.Children.Add(assetRepairComponents.EntryAssetCode, 1, rowIdx); - Grid.SetColumnSpan(assetRepairComponents.EntryAssetCode, 2); + AddControlViewToGrid(gridProperties, assetRepairComponents.EntryAssetCode); assetRepairComponents.EntryAssetCode.TextChanged += EntryAssetCode_TextChanged; assetRepairComponents.EntryAssetCode.Completed += EntryAssetCode_Completed; // Asset search results view. - rowIdx = gridRepairProperties.RowDefinitions.Count; - gridRepairProperties.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); - gridRepairProperties.Children.Add(assetSearchResultsWebView, 0, rowIdx); + rowIdx = gridProperties.RowDefinitions.Count; + gridProperties.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); + gridProperties.Children.Add(assetSearchResultsWebView, 0, rowIdx); Grid.SetColumnSpan(assetSearchResultsWebView, 3); assetSearchResultsWebView.ColumnsToDisplay.AddRange(new List() { @@ -107,42 +97,30 @@ namespace Sarand.LogisticsMgr.Mobile.Forms.Pages.Assets assetSearchResultsWebView.AssetMovementSelected += AssetSearchResultsWebView_AssetMovementSelected; // Asset Size. - rowIdx = gridRepairProperties.RowDefinitions.Count; - gridRepairProperties.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); - gridRepairProperties.Children.Add(assetRepairComponents.LabelAssetSize, 0, rowIdx); - gridRepairProperties.Children.Add(assetRepairComponents.PickerAssetSize, 1, rowIdx); - Grid.SetColumnSpan(assetRepairComponents.PickerAssetSize, 2); + AddControlViewToGrid(gridProperties, assetRepairComponents.PickerAssetSize); // Repair Narrative. - rowIdx = gridRepairProperties.RowDefinitions.Count; - gridRepairProperties.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); - gridRepairProperties.Children.Add(assetRepairComponents.LabelRepairNarrative, 0, rowIdx); - gridRepairProperties.Children.Add(assetRepairComponents.EntryRepairNarrative, 1, rowIdx); - Grid.SetColumnSpan(assetRepairComponents.EntryRepairNarrative, 2); + AddControlViewToGrid(gridProperties, assetRepairComponents.EntryRepairNarrative); // Repair Inspector. - rowIdx = gridRepairProperties.RowDefinitions.Count; - gridRepairProperties.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); - gridRepairProperties.Children.Add(assetRepairComponents.LabelRepairInspector, 0, rowIdx); - gridRepairProperties.Children.Add(assetRepairComponents.EntryRepairInspector, 1, rowIdx); - Grid.SetColumnSpan(assetRepairComponents.EntryRepairInspector, 2); + AddControlViewToGrid(gridProperties, assetRepairComponents.EntryRepairInspector); // Jobs panel. SlmPanel_AssetRepair_Jobs.Config jobsPanelConfig = new SlmPanel_AssetRepair_Jobs.Config(); jobsPanelConfig.AssetRepairPage = this; repairJobsPanel = new SlmPanel_AssetRepair_Jobs(jobsPanelConfig); - rowIdx = gridRepairProperties.RowDefinitions.Count; - gridRepairProperties.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); - gridRepairProperties.Children.Add(repairJobsPanel, 0, rowIdx); + rowIdx = gridProperties.RowDefinitions.Count; + gridProperties.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); + gridProperties.Children.Add(repairJobsPanel, 0, rowIdx); Grid.SetColumnSpan(repairJobsPanel, 3); // Images panel. SlmPanel_AssetRepair_Images.Config imagesPanelConfig = new SlmPanel_AssetRepair_Images.Config(); imagesPanelConfig.AssetRepairPage = this; repairImagesPanel = new SlmPanel_AssetRepair_Images(imagesPanelConfig); - rowIdx = gridRepairProperties.RowDefinitions.Count; - gridRepairProperties.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); - gridRepairProperties.Children.Add(repairImagesPanel, 0, rowIdx); + rowIdx = gridProperties.RowDefinitions.Count; + gridProperties.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); + gridProperties.Children.Add(repairImagesPanel, 0, rowIdx); Grid.SetColumnSpan(repairImagesPanel, 3); } diff --git a/LogisticsMgrMobile/LogisticsMgrMobile/Mobile/Forms/Pages/Assets/SlmPage_Assets_RepairImage.cs b/LogisticsMgrMobile/LogisticsMgrMobile/Mobile/Forms/Pages/Forms/Assets/SlmFormPage_Assets_RepairImage.cs similarity index 73% rename from LogisticsMgrMobile/LogisticsMgrMobile/Mobile/Forms/Pages/Assets/SlmPage_Assets_RepairImage.cs rename to LogisticsMgrMobile/LogisticsMgrMobile/Mobile/Forms/Pages/Forms/Assets/SlmFormPage_Assets_RepairImage.cs index cf2fac8..6d577c6 100644 --- a/LogisticsMgrMobile/LogisticsMgrMobile/Mobile/Forms/Pages/Assets/SlmPage_Assets_RepairImage.cs +++ b/LogisticsMgrMobile/LogisticsMgrMobile/Mobile/Forms/Pages/Forms/Assets/SlmFormPage_Assets_RepairImage.cs @@ -5,8 +5,7 @@ using Sarand.LogisticsMgr.Core.App; using Sarand.LogisticsMgr.Core.Bus; using Sarand.LogisticsMgr.Core.WebService; using Sarand.LogisticsMgr.Mobile.Core.Forms.Base; -using Sarand.LogisticsMgr.Mobile.Forms.Components; -using Sarand.LogisticsMgr.Mobile.Forms.Effects; +using Sarand.LogisticsMgr.Mobile.Forms.Components.Assets; using Sarand.LogisticsMgr.Mobile.Forms.Panels.Assets; using System; using System.Collections.Generic; @@ -15,10 +14,10 @@ using System.Text; using System.Threading.Tasks; using Xamarin.Forms; -namespace Sarand.LogisticsMgr.Mobile.Forms.Pages.Assets +namespace Sarand.LogisticsMgr.Mobile.Forms.Pages.Forms.Assets { //======================================================================= - public class SlmPage_Assets_RepairImage : SlmFormPage + public class SlmFormPage_Assets_RepairImage : SlmFormPage { //------------------------------------------------------------------- // Definitions. @@ -36,12 +35,12 @@ namespace Sarand.LogisticsMgr.Mobile.Forms.Pages.Assets // Data members. private readonly Config config; private SlmAssetRepairImage.Data newRepairImageData = null; - private SlmGrid gridRepairImageProperties = new SlmGrid(); + private SlmGrid gridProperties = new SlmGrid(); private SlmComponents_AssetRepairImage repairImageComponents = new SlmComponents_AssetRepairImage(); //------------------------------------------------------------------- // Construction. - public SlmPage_Assets_RepairImage (Config config) : base(config) + public SlmFormPage_Assets_RepairImage (Config config) : base(config) { this.config = config; AddMode = (config.AssetRepairImageToUpdate == null); @@ -59,19 +58,15 @@ namespace Sarand.LogisticsMgr.Mobile.Forms.Pages.Assets private void InitialiseComponents () { // Asset Repair form. - FormBodyView.Content = gridRepairImageProperties; - gridRepairImageProperties.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto }); - gridRepairImageProperties.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto }); - gridRepairImageProperties.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Star }); - gridRepairImageProperties.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto }); + FormBodyView.Content = gridProperties; + gridProperties.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto }); + gridProperties.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto }); + gridProperties.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Star }); + gridProperties.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto }); int rowIdx = -1; // Filename. - rowIdx = gridRepairImageProperties.RowDefinitions.Count; - gridRepairImageProperties.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); - gridRepairImageProperties.Children.Add(repairImageComponents.LabelFilename, 0, rowIdx); - gridRepairImageProperties.Children.Add(repairImageComponents.EntryFilename, 1, rowIdx); - Grid.SetColumnSpan(repairImageComponents.EntryFilename, 2); + AddControlViewToGrid(gridProperties, repairImageComponents.EntryFilename); } //------------------------------------------------------------------- diff --git a/LogisticsMgrMobile/LogisticsMgrMobile/Mobile/Forms/Pages/Assets/SlmPage_Assets_RepairJob.cs b/LogisticsMgrMobile/LogisticsMgrMobile/Mobile/Forms/Pages/Forms/Assets/SlmFormPage_Assets_RepairJob.cs similarity index 56% rename from LogisticsMgrMobile/LogisticsMgrMobile/Mobile/Forms/Pages/Assets/SlmPage_Assets_RepairJob.cs rename to LogisticsMgrMobile/LogisticsMgrMobile/Mobile/Forms/Pages/Forms/Assets/SlmFormPage_Assets_RepairJob.cs index 04e0fed..40d651b 100644 --- a/LogisticsMgrMobile/LogisticsMgrMobile/Mobile/Forms/Pages/Assets/SlmPage_Assets_RepairJob.cs +++ b/LogisticsMgrMobile/LogisticsMgrMobile/Mobile/Forms/Pages/Forms/Assets/SlmFormPage_Assets_RepairJob.cs @@ -5,8 +5,7 @@ using Sarand.LogisticsMgr.Core.App; using Sarand.LogisticsMgr.Core.Bus; using Sarand.LogisticsMgr.Core.WebService; using Sarand.LogisticsMgr.Mobile.Core.Forms.Base; -using Sarand.LogisticsMgr.Mobile.Forms.Components; -using Sarand.LogisticsMgr.Mobile.Forms.Effects; +using Sarand.LogisticsMgr.Mobile.Forms.Components.Assets; using Sarand.LogisticsMgr.Mobile.Forms.Panels.Assets; using System; using System.Collections.Generic; @@ -15,10 +14,10 @@ using System.Text; using System.Threading.Tasks; using Xamarin.Forms; -namespace Sarand.LogisticsMgr.Mobile.Forms.Pages.Assets +namespace Sarand.LogisticsMgr.Mobile.Forms.Pages.Forms.Assets { //======================================================================= - public class SlmPage_Assets_RepairJob : SlmFormPage + public class SlmFormPage_Assets_RepairJob : SlmFormPage { //------------------------------------------------------------------- // Definitions. @@ -36,12 +35,12 @@ namespace Sarand.LogisticsMgr.Mobile.Forms.Pages.Assets // Data members. private readonly Config config; private SlmAssetRepairJob.Data newRepairJobData = null; - private SlmGrid gridRepairJobProperties = new SlmGrid(); + private SlmGrid gridProperties = new SlmGrid(); private SlmComponents_AssetRepairJob repairJobComponents = new SlmComponents_AssetRepairJob(); //------------------------------------------------------------------- // Construction. - public SlmPage_Assets_RepairJob (Config config) : base(config) + public SlmFormPage_Assets_RepairJob (Config config) : base(config) { this.config = config; AddMode = (config.AssetRepairJobToUpdate == null); @@ -63,51 +62,47 @@ namespace Sarand.LogisticsMgr.Mobile.Forms.Pages.Assets private void InitialiseComponents () { // Asset Repair form. - FormBodyView.Content = gridRepairJobProperties; - gridRepairJobProperties.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto }); - gridRepairJobProperties.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto }); - gridRepairJobProperties.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Star }); - gridRepairJobProperties.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto }); + FormBodyView.Content = gridProperties; + gridProperties.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto }); + gridProperties.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto }); + gridProperties.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Star }); + gridProperties.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto }); int rowIdx = -1; // Location. - rowIdx = gridRepairJobProperties.RowDefinitions.Count; - gridRepairJobProperties.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); - gridRepairJobProperties.Children.Add(repairJobComponents.LabelLocation, 0, rowIdx); - gridRepairJobProperties.Children.Add(repairJobComponents.EntryLocation, 1, rowIdx); - gridRepairJobProperties.Children.Add(repairJobComponents.PickerLocation, 2, rowIdx); + rowIdx = gridProperties.RowDefinitions.Count; + gridProperties.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); + gridProperties.Children.Add(repairJobComponents.EntryLocation.Label, 0, rowIdx); + gridProperties.Children.Add(repairJobComponents.EntryLocation, 1, rowIdx); + gridProperties.Children.Add(repairJobComponents.PickerLocation, 2, rowIdx); Grid.SetColumnSpan(repairJobComponents.PickerLocation, 2); // Component. - rowIdx = gridRepairJobProperties.RowDefinitions.Count; - gridRepairJobProperties.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); - gridRepairJobProperties.Children.Add(repairJobComponents.LabelComponent, 0, rowIdx); - gridRepairJobProperties.Children.Add(repairJobComponents.EntryComponent, 1, rowIdx); - gridRepairJobProperties.Children.Add(repairJobComponents.PickerComponent, 2, rowIdx); + rowIdx = gridProperties.RowDefinitions.Count; + gridProperties.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); + gridProperties.Children.Add(repairJobComponents.EntryComponent.Label, 0, rowIdx); + gridProperties.Children.Add(repairJobComponents.EntryComponent, 1, rowIdx); + gridProperties.Children.Add(repairJobComponents.PickerComponent, 2, rowIdx); Grid.SetColumnSpan(repairJobComponents.PickerComponent, 2); // Damage. - rowIdx = gridRepairJobProperties.RowDefinitions.Count; - gridRepairJobProperties.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); - gridRepairJobProperties.Children.Add(repairJobComponents.LabelDamage, 0, rowIdx); - gridRepairJobProperties.Children.Add(repairJobComponents.EntryDamage, 1, rowIdx); - gridRepairJobProperties.Children.Add(repairJobComponents.PickerDamage, 2, rowIdx); + rowIdx = gridProperties.RowDefinitions.Count; + gridProperties.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); + gridProperties.Children.Add(repairJobComponents.EntryDamage.Label, 0, rowIdx); + gridProperties.Children.Add(repairJobComponents.EntryDamage, 1, rowIdx); + gridProperties.Children.Add(repairJobComponents.PickerDamage, 2, rowIdx); Grid.SetColumnSpan(repairJobComponents.PickerDamage, 2); // Repair. - rowIdx = gridRepairJobProperties.RowDefinitions.Count; - gridRepairJobProperties.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); - gridRepairJobProperties.Children.Add(repairJobComponents.LabelRepair, 0, rowIdx); - gridRepairJobProperties.Children.Add(repairJobComponents.EntryRepair, 1, rowIdx); - gridRepairJobProperties.Children.Add(repairJobComponents.PickerRepair, 2, rowIdx); + rowIdx = gridProperties.RowDefinitions.Count; + gridProperties.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); + gridProperties.Children.Add(repairJobComponents.EntryRepair.Label, 0, rowIdx); + gridProperties.Children.Add(repairJobComponents.EntryRepair, 1, rowIdx); + gridProperties.Children.Add(repairJobComponents.PickerRepair, 2, rowIdx); Grid.SetColumnSpan(repairJobComponents.PickerRepair, 2); // Quantity. - rowIdx = gridRepairJobProperties.RowDefinitions.Count; - gridRepairJobProperties.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); - gridRepairJobProperties.Children.Add(repairJobComponents.LabelQuantity, 0, rowIdx); - gridRepairJobProperties.Children.Add(repairJobComponents.EntryQuantity, 1, rowIdx); - Grid.SetColumnSpan(repairJobComponents.EntryQuantity, 2); + AddControlViewToGrid(gridProperties, repairJobComponents.EntryQuantity); } //------------------------------------------------------------------- diff --git a/LogisticsMgrMobile/LogisticsMgrMobile/Mobile/Forms/Pages/Forms/Bulk/SlmFormPage_Bulk_Berthing.cs b/LogisticsMgrMobile/LogisticsMgrMobile/Mobile/Forms/Pages/Forms/Bulk/SlmFormPage_Bulk_Berthing.cs new file mode 100644 index 0000000..49932c7 --- /dev/null +++ b/LogisticsMgrMobile/LogisticsMgrMobile/Mobile/Forms/Pages/Forms/Bulk/SlmFormPage_Bulk_Berthing.cs @@ -0,0 +1,246 @@ +using Sarand.Core.App; +using Sarand.Core.Base; +using Sarand.Core.Bus; +using Sarand.Core.Tasks; +using Sarand.LogisticsMgr.Core.Bus; +using Sarand.LogisticsMgr.Core.WebService; +using Sarand.LogisticsMgr.Mobile.Core.Bus; +using Sarand.LogisticsMgr.Mobile.Core.Forms.Base; +using Sarand.LogisticsMgr.Mobile.Forms.Components.Bulk; +using Sarand.LogisticsMgr.Mobile.Forms.Panels.Bulk; +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading.Tasks; +using Xamarin.Forms; + +namespace Sarand.LogisticsMgr.Mobile.Forms.Pages.Forms.Bulk +{ + //======================================================================= + public class SlmFormPage_Bulk_Berthing : SlmFormPage + { + //------------------------------------------------------------------- + // Definitions. + public new class Config : SlmFormPage.Config + { + public SysId BerthingIdToUpdate { get; set; } + } + + //------------------------------------------------------------------- + // Data members. + private readonly Config config; + private SlmGrid gridProperties = new SlmGrid(); + private SlmComponents_Berthing berthingComponents = new SlmComponents_Berthing(); + private SlmPanel_Bulk_BerthingTasks berthingTasksPanel; + // Data to view/update. + private SlmBerthing BerthingToUpdate; + private SlmVessel Berthing_Vessel; + private SlmCompany Berthing_Company_Agent; + private SlmCompany Berthing_Company_Customer; + + //------------------------------------------------------------------- + // Construction. + public SlmFormPage_Bulk_Berthing (Config config) : base(config) + { + this.config = config; + Title = "Bulk - Berthing"; + AddMode = !SysId.IsValid(config.BerthingIdToUpdate); + if (config.ReadOnly) + { + berthingComponents.ReadOnly = true; + } + PrepareFormData(); + } + + //------------------------------------------------------------------- + // Properties. + public SysId BerthingId { get { return BerthingToUpdate?.Id ?? new SysId(); } } + + //------------------------------------------------------------------- + // P r e p a r a t i o n + //------------------------------------------------------------------- + private SacsTaskData taskDataPrepareData = new SacsTaskData(null); + private void PrepareFormData () + { + String fn = GetType().Name+".PrepareFormData"; + if (!SysId.IsValid(config.BerthingIdToUpdate)) return; + + // Form is initialised on separate thread while data is retrieved from the service. + // 'Please wait' message is displayed during preparation. + // Any issue during preparation results in an alert message and the form is closed. + FormBodyView.Content = new SlmLabel() { Text = DataPreparationMessage }; + Task.Run(async () => + { + try + { + await PopulateBerthingData(taskDataPrepareData); + } + catch (Exception exc) + { + if (SacsSystem.DebugMode) Logger.Warn(fn + " " + ExceptionUtil.GetLogMessage(exc)); + CloseFormWithAlert(nameof(exc)+" on form initialisation.\n\n"+exc.Message); + } + }, taskDataPrepareData.CancellationToken) + .ContinueWith(task => + { + taskDataPrepareData.Dispose(); + }); + } + //------------------------------------------------------------------- + private async Task PopulateBerthingData (SacsTaskData taskDataPrepareData_Local) + { + String fn = GetType().Name + ".PopulateBerthingData"; + + // Retrieve Berthing and associated details. + try + { + // Berthing filter. + SlmBerthing_Mobile.Params prmBerthing = new SlmBerthing_Mobile.Params(); + prmBerthing.IncludedIds.Add(config.BerthingIdToUpdate); + prmBerthing.StatusCat = SlmBerthing.StatusCat.Any; + // Associated data item are retrieved at the same time to avoid multiple service requests. + prmBerthing.IncludeVessel = true; + prmBerthing.IncludeCompanies = true; + + // Request config. + SlmWebServiceRequest.Config requestConfig = new SlmWebServiceRequest.Config(); + requestConfig.RequestType = SlmWebServiceRequest.RequestType.Item; + requestConfig.DataType = SlmWebServiceRequest.DataType.Berthing; + requestConfig.Context.SiteDefinition = SessionContext.SiteDefinition; + requestConfig.Context.User = UserContext.User.SecurityItemCode; + requestConfig.Context.Email = UserContext.User.EmailAddress; + requestConfig.Context.Debug = SacsSystem.DebugMode; + + // Retrieve Berthing data. + SlmWebServiceClient.ItemDataResponseData response = + await WebServiceClient.RequestItemData(requestConfig, BerthingMgr.GetBerthingQueryFilter_Mobile(prmBerthing), taskDataPrepareData_Local); + + // Populate berthing. + BerthingToUpdate = BerthingMgr.CreateBerthing_Mobile(response.Item); + + if (BerthingToUpdate != null) + { + // Retrieve Vessel. + List vesselItems = response.Item.ChildItems.GetValue("VesselList",null); + SlmWebServiceItemData vesselItem = vesselItems?.Find(item=>item.GetIdValue(nameof(SlmVessel.Id)).Equals(BerthingToUpdate.VesselId)) ?? null; + if (vesselItem != null) + Berthing_Vessel = BerthingMgr.CreateVessel_Mobile(vesselItem); + + // Retrieve Companies. + List companyItems = response.Item.ChildItems.GetValue("CompanyList",null); + SlmWebServiceItemData companyItem_Agent = companyItems?.Find(item=>item.GetIdValue(nameof(SlmCompany.Id)).Equals(BerthingToUpdate.CompanyIdAgent)) ?? null; + if (companyItem_Agent != null) + Berthing_Company_Agent = AccountMgr.CreateCompany_Mobile(companyItem_Agent); + SlmWebServiceItemData companyItem_Customer = companyItems?.Find(item=>item.GetIdValue(nameof(SlmCompany.Id)).Equals(BerthingToUpdate.CompanyIdCustomer)) ?? null; + if (companyItem_Customer != null) + Berthing_Company_Customer = AccountMgr.CreateCompany_Mobile(companyItem_Customer); + } + + } + catch (Exception exc) { Logger.Debug(fn + " " + exc.GetLogMessage(6)); } + if (BerthingToUpdate == null) + { + CloseFormWithAlert("Failed to retrieve Berthing data."); + return; + } + if (Berthing_Vessel == null) + { + CloseFormWithAlert("Failed to retrieve Vessel data."); + return; + } + if (SysId.IsValid(BerthingToUpdate.CompanyIdAgent) && Berthing_Company_Agent == null) + { + CloseFormWithAlert("Failed to retrieve Agent data."); + return; + } + if (SysId.IsValid(BerthingToUpdate.CompanyIdCustomer) && Berthing_Company_Customer == null) + { + CloseFormWithAlert("Failed to retrieve Customer data."); + return; + } + if (taskDataPrepareData_Local.IsCancellationRequested) return; + + Device.BeginInvokeOnMainThread(() => + { + // Initialise form. + InitialiseComponents(); + }); + } + + //------------------------------------------------------------------- + // I n i t i a l i s e + //------------------------------------------------------------------- + private void InitialiseComponents () + { + // Asset Repair form. + gridProperties.BackgroundColor = Color.Transparent; + FormBodyView.Content = gridProperties; + gridProperties.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto }); + gridProperties.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Star }); + gridProperties.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto }); + + //--------------------------------------------------------------- + // Vessel. + AddControlViewToGrid(gridProperties, berthingComponents.PickerVessel); + + // Companies. + AddControlViewToGrid(gridProperties, berthingComponents.PickerAgent); + AddControlViewToGrid(gridProperties, berthingComponents.PickerCustomer); + + // Notes. + AddControlViewToGrid(gridProperties, berthingComponents.EditorNotes); + + // Tasks panel. + SlmPanel_Bulk_BerthingTasks.Config berthingTasksPanelConfig = new SlmPanel_Bulk_BerthingTasks.Config(); + berthingTasksPanelConfig.BerthingForm = this; + berthingTasksPanel = new SlmPanel_Bulk_BerthingTasks(berthingTasksPanelConfig); + int rowIdx = gridProperties.RowDefinitions.Count; + gridProperties.RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); + gridProperties.Children.Add(berthingTasksPanel, 0, rowIdx); + Grid.SetColumnSpan(berthingTasksPanel, 3); + + //--------------------------------------------------------------- + // Populate properties to components. + berthingComponents.PopulateToControls(Berthing_Vessel?.GetData() ?? new SlmVessel.Data()); + berthingComponents.PopulateToControls(BerthingToUpdate?.GetData() ?? new SlmBerthing.Data()); + + // Complete page configuration. + SetControlActivity(); + Changed = false; + } + + //------------------------------------------------------------------- + // C o n t r o l A c t i v i t y + //------------------------------------------------------------------- + protected override void SetControlActivity () + { + base.SetControlActivity(); + } + protected override void SetControlsReadOnly () + { + } + + //------------------------------------------------------------------- + // N a v i g a t i o n E v e n t s + //------------------------------------------------------------------- + protected override bool SaveFormData () + { + return true; + } + //------------------------------------------------------------------- + protected override bool QueryCancelForm () + { + if (!base.QueryCancelForm()) return false; + // Cancel data preparation - in case user has closed form during process. + taskDataPrepareData.TriggerCancellation(); + return true; + } + + //------------------------------------------------------------------- + // P r o p e r t y E v e n t s + //------------------------------------------------------------------- + + //------------------------------------------------------------------- + } + //======================================================================= +} diff --git a/LogisticsMgrMobile/LogisticsMgrMobile/Mobile/Forms/Pages/Forms/Bulk/SlmFormPage_Bulk_BerthingTask.cs b/LogisticsMgrMobile/LogisticsMgrMobile/Mobile/Forms/Pages/Forms/Bulk/SlmFormPage_Bulk_BerthingTask.cs new file mode 100644 index 0000000..bfdbb4b --- /dev/null +++ b/LogisticsMgrMobile/LogisticsMgrMobile/Mobile/Forms/Pages/Forms/Bulk/SlmFormPage_Bulk_BerthingTask.cs @@ -0,0 +1,123 @@ +using Sarand.Core.Base; +using Sarand.Core.Bus; +using Sarand.Core.Tasks; +using Sarand.LogisticsMgr.Core.Bus; +using Sarand.LogisticsMgr.Mobile.Core.Forms.Base; +using Sarand.LogisticsMgr.Mobile.Forms.Components.Bulk; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Xamarin.Forms; + +namespace Sarand.LogisticsMgr.Mobile.Forms.Pages.Forms.Bulk +{ + //======================================================================= + public class SlmFormPage_Bulk_BerthingTask : SlmFormPage + { + //------------------------------------------------------------------- + // Definitions. + public new class Config : SlmFormPage.Config + { + public Config (SysId berthingId) + { + BerthingId = berthingId; + } + public SysId BerthingId { get; set; } + public SlmBerthingTask.Data BerthingTaskToUpdate { get; set; } + } + + //------------------------------------------------------------------- + // Data members. + private readonly Config config; + private SlmBerthingTask.Data newBerthingTaskData = null; + private SlmGrid gridProperties = new SlmGrid(); + private SlmComponents_BerthingTask berthingTaskComponents = new SlmComponents_BerthingTask(); + + //------------------------------------------------------------------- + // Construction. + public SlmFormPage_Bulk_BerthingTask (Config config) : base(config) + { + this.config = config; + AddMode = (config.BerthingTaskToUpdate == null); + Title = "Berthing Task"; + InitialiseComponents(); + } + + //------------------------------------------------------------------- + // Properties. + public SlmBerthingTask.Data NewBerthingTaskData { get { return newBerthingTaskData; } } + + //------------------------------------------------------------------- + // I n i t i a l i s e + //------------------------------------------------------------------- + private void InitialiseComponents () + { + // Asset Repair form. + FormBodyView.Content = gridProperties; + gridProperties.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto }); + gridProperties.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto }); + gridProperties.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Star }); + gridProperties.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto }); + + // Controls. + AddControlViewToGrid(gridProperties, berthingTaskComponents.PickerTaskType); + AddControlViewToGrid(gridProperties, berthingTaskComponents.DatePickerStarted); + AddControlViewToGrid(gridProperties, berthingTaskComponents.DatePickerCompleted); + AddControlViewToGrid(gridProperties, berthingTaskComponents.EntryRemarks); + + if (AddMode) + { + } + else + { + berthingTaskComponents.PopulateToControls(config.BerthingTaskToUpdate); + } + } + + //------------------------------------------------------------------- + // C o n f i g u r e C o n t r o l s + //------------------------------------------------------------------- + + //------------------------------------------------------------------- + // C o n t r o l A c t i v i t y + //------------------------------------------------------------------- + protected override void SetControlActivity () + { + SetControlsReadOnly(); + } + protected override void SetControlsReadOnly () + { + } + + //------------------------------------------------------------------- + // N a v i g a t i o n E v e n t s + //------------------------------------------------------------------- + protected override bool SaveFormData () + { + SlmBerthingTask.Data berthingTaskData = (AddMode ? new SlmBerthingTask.Data() : config.BerthingTaskToUpdate.Clone()); + berthingTaskComponents.PopulateFromControls(berthingTaskData); + if (!berthingTaskComponents.IsDataValid(berthingTaskData)) + return false; + if (AddMode) + { + newBerthingTaskData = berthingTaskData; + } + else + { + berthingTaskComponents.PopulateFromControls(config.BerthingTaskToUpdate); + } + return true; + } + protected override bool QueryCancelForm () + { + if (berthingTaskComponents.Changed) Changed = true; + if (!base.QueryCancelForm()) return false; + return true; + } + + //------------------------------------------------------------------- + } + //======================================================================= +} \ No newline at end of file diff --git a/LogisticsMgrMobile/LogisticsMgrMobile/Mobile/Forms/Panels/Assets/SlmPanel_AssetRepair_Images.cs b/LogisticsMgrMobile/LogisticsMgrMobile/Mobile/Forms/Panels/Assets/SlmPanel_AssetRepair_Images.cs index b960133..c84bd77 100644 --- a/LogisticsMgrMobile/LogisticsMgrMobile/Mobile/Forms/Panels/Assets/SlmPanel_AssetRepair_Images.cs +++ b/LogisticsMgrMobile/LogisticsMgrMobile/Mobile/Forms/Panels/Assets/SlmPanel_AssetRepair_Images.cs @@ -1,7 +1,7 @@ using Sarand.LogisticsMgr.Core.Bus; using Sarand.LogisticsMgr.Mobile.Core.Forms.Base; using Sarand.LogisticsMgr.Mobile.Core.Forms.Panels; -using Sarand.LogisticsMgr.Mobile.Forms.Pages.Assets; +using Sarand.LogisticsMgr.Mobile.Forms.Pages.Forms.Assets; using System; using System.Collections.Generic; using System.Text; @@ -16,7 +16,7 @@ namespace Sarand.LogisticsMgr.Mobile.Forms.Panels.Assets // Definitions. public new class Config : SlmPanel_AssociatedItems.Config { - public SlmPage_Assets_Repair AssetRepairPage { get; set; } + public SlmFormPage_Assets_Repair AssetRepairPage { get; set; } } //------------------------------------------------------------------- @@ -37,7 +37,7 @@ namespace Sarand.LogisticsMgr.Mobile.Forms.Panels.Assets //------------------------------------------------------------------- // Properties. - public List RepairImages => new List(repairImages); + public List RepairImages { get { return new List(repairImages); } } //------------------------------------------------------------------- // I n i t i a l i s e @@ -86,8 +86,8 @@ namespace Sarand.LogisticsMgr.Mobile.Forms.Panels.Assets //------------------------------------------------------------------- protected async override void ButtonAddItem_Clicked (object sender, EventArgs e) { - SlmPage_Assets_RepairImage.Config pageConfig = new SlmPage_Assets_RepairImage.Config(config.AssetRepairPage.CompanyId); - SlmPage_Assets_RepairImage page = new SlmPage_Assets_RepairImage(pageConfig); + SlmFormPage_Assets_RepairImage.Config pageConfig = new SlmFormPage_Assets_RepairImage.Config(config.AssetRepairPage.CompanyId); + SlmFormPage_Assets_RepairImage page = new SlmFormPage_Assets_RepairImage(pageConfig); page.Disappearing += (sender2, e2) => { if (!page.Cancelled) diff --git a/LogisticsMgrMobile/LogisticsMgrMobile/Mobile/Forms/Panels/Assets/SlmPanel_AssetRepair_Jobs.cs b/LogisticsMgrMobile/LogisticsMgrMobile/Mobile/Forms/Panels/Assets/SlmPanel_AssetRepair_Jobs.cs index 22f13ea..64b524b 100644 --- a/LogisticsMgrMobile/LogisticsMgrMobile/Mobile/Forms/Panels/Assets/SlmPanel_AssetRepair_Jobs.cs +++ b/LogisticsMgrMobile/LogisticsMgrMobile/Mobile/Forms/Panels/Assets/SlmPanel_AssetRepair_Jobs.cs @@ -3,7 +3,7 @@ using Sarand.Core.Mobile.Utils; using Sarand.LogisticsMgr.Core.Bus; using Sarand.LogisticsMgr.Mobile.Core.Forms.Base; using Sarand.LogisticsMgr.Mobile.Core.Forms.Panels; -using Sarand.LogisticsMgr.Mobile.Forms.Pages.Assets; +using Sarand.LogisticsMgr.Mobile.Forms.Pages.Forms.Assets; using System; using System.Collections.Generic; using System.Text; @@ -18,7 +18,7 @@ namespace Sarand.LogisticsMgr.Mobile.Forms.Panels.Assets // Definitions. public new class Config : SlmPanel_AssociatedItems.Config { - public SlmPage_Assets_Repair AssetRepairPage { get; set; } + public SlmFormPage_Assets_Repair AssetRepairPage { get; set; } } //------------------------------------------------------------------- @@ -39,7 +39,7 @@ namespace Sarand.LogisticsMgr.Mobile.Forms.Panels.Assets //------------------------------------------------------------------- // Properties. - public List RepairJobs => new List(repairJobs); + public List RepairJobs { get { return new List(repairJobs); } } //------------------------------------------------------------------- // I n i t i a l i s e @@ -106,9 +106,9 @@ namespace Sarand.LogisticsMgr.Mobile.Forms.Panels.Assets buttonUpdate.Pressed += (sender, evt) => { // Update job. - SlmPage_Assets_RepairJob.Config pageConfig = new SlmPage_Assets_RepairJob.Config(config.AssetRepairPage.CompanyId); + SlmFormPage_Assets_RepairJob.Config pageConfig = new SlmFormPage_Assets_RepairJob.Config(config.AssetRepairPage.CompanyId); pageConfig.AssetRepairJobToUpdate = repairJob; - SlmPage_Assets_RepairJob page = new SlmPage_Assets_RepairJob(pageConfig); + SlmFormPage_Assets_RepairJob page = new SlmFormPage_Assets_RepairJob(pageConfig); page.Disappearing += (sender2, e2) => { if (page.Cancelled) return; @@ -140,8 +140,8 @@ namespace Sarand.LogisticsMgr.Mobile.Forms.Panels.Assets //------------------------------------------------------------------- protected override void ButtonAddItem_Clicked (object sender, EventArgs e) { - SlmPage_Assets_RepairJob.Config pageConfig = new SlmPage_Assets_RepairJob.Config(config.AssetRepairPage.CompanyId); - SlmPage_Assets_RepairJob page = new SlmPage_Assets_RepairJob(pageConfig); + SlmFormPage_Assets_RepairJob.Config pageConfig = new SlmFormPage_Assets_RepairJob.Config(config.AssetRepairPage.CompanyId); + SlmFormPage_Assets_RepairJob page = new SlmFormPage_Assets_RepairJob(pageConfig); page.Disappearing += (sender2, e2) => { if (!page.Cancelled) diff --git a/LogisticsMgrMobile/LogisticsMgrMobile/Mobile/Forms/Panels/Bulk/SlmPanel_Bulk_BerthingTasks.cs b/LogisticsMgrMobile/LogisticsMgrMobile/Mobile/Forms/Panels/Bulk/SlmPanel_Bulk_BerthingTasks.cs new file mode 100644 index 0000000..3b73877 --- /dev/null +++ b/LogisticsMgrMobile/LogisticsMgrMobile/Mobile/Forms/Panels/Bulk/SlmPanel_Bulk_BerthingTasks.cs @@ -0,0 +1,280 @@ +using Sarand.Core.App; +using Sarand.Core.Base; +using Sarand.Core.Bus; +using Sarand.Core.Mobile.Forms.Controls; +using Sarand.Core.Tasks; +using Sarand.LogisticsMgr.Core.App; +using Sarand.LogisticsMgr.Core.Bus; +using Sarand.LogisticsMgr.Core.WebService; +using Sarand.LogisticsMgr.Mobile.Core.App; +using Sarand.LogisticsMgr.Mobile.Core.Forms.Base; +using Sarand.LogisticsMgr.Mobile.Core.Forms.Panels; +using Sarand.LogisticsMgr.Mobile.Forms.Pages.Forms.Assets; +using Sarand.LogisticsMgr.Mobile.Forms.Pages.Forms.Bulk; +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading.Tasks; +using Xamarin.Forms; + +namespace Sarand.LogisticsMgr.Mobile.Forms.Panels.Bulk +{ + //======================================================================= + public class SlmPanel_Bulk_BerthingTasks : SlmPanel_AssociatedItems + { + //------------------------------------------------------------------- + // Definitions. + public new class Config : SlmPanel_AssociatedItems.Config + { + public SlmFormPage_Bulk_Berthing BerthingForm { get; set; } + } + + //------------------------------------------------------------------- + // Data members. + private Config config; + private readonly List berthingTaskTypes; + private List berthingTaskDataList = new List(); + private SlmLabel labelSummary = new SlmLabel(); + //private SlmGrid gridDetails = new SlmGrid(); + private SlmWebView webViewDetails = new SlmWebView(); + private String berthingTaskUpdatePrefix = "BthTskUpdate_"; + + //------------------------------------------------------------------- + // Construction. + public SlmPanel_Bulk_BerthingTasks (Config config) : + base(config) + { + this.config = config; + berthingTaskTypes = SlmSystem.GetCodesOfType(Slm.SystemCode.BerthingTaskType); + InitialiseComponents(); + PopulateBerthingTasks(); + } + + //------------------------------------------------------------------- + // Properties. + public List BerthingTasks { get { return new List(berthingTaskDataList); } } + + //------------------------------------------------------------------- + // I n i t i a l i s e + //------------------------------------------------------------------- + private void InitialiseComponents () + { + Caption = "Berthing Tasks"; + + // Summary panel. + labelSummary.HorizontalOptions = LayoutOptions.FillAndExpand; + SummaryPanel.Content = labelSummary; + + // Details panel. + webViewDetails.HorizontalOptions = LayoutOptions.StartAndExpand; + webViewDetails.VerticalOptions = LayoutOptions.StartAndExpand; + webViewDetails.AppNavigating += WebViewDetails_AppNavigating; + DetailsPanel.Content = webViewDetails; + + RefreshPanels(); + } + + //------------------------------------------------------------------- + // P o p u l a t i o n + //------------------------------------------------------------------- + private SacsTaskData taskDataPrepareData = new SacsTaskData(null); + private void PopulateBerthingTasks () + { + String fn = GetType().Name + ".PopulateBerthingTasks"; + if (!SysId.IsValid(config.BerthingForm.BerthingId)) return; + Task.Run(async () => + { + try + { + await PopulateBerthingTasks(taskDataPrepareData); + } + catch (Exception exc) + { + if (SacsSystem.DebugMode) Logger.Warn(fn + " " + ExceptionUtil.GetLogMessage(exc)); + ErrorStateMessage = nameof(exc) + " on population - " + exc.Message; + } + }, taskDataPrepareData.CancellationToken) + .ContinueWith(task => + { + taskDataPrepareData.Dispose(); + }); + } + //------------------------------------------------------------------- + private async Task PopulateBerthingTasks (SacsTaskData taskDataPrepareData_Local) + { + String fn = GetType().Name + ".PopulateBerthingTasks"; + + // Berthing Task filter. + SlmBerthingTask.Params prmBerthingTask = new SlmBerthingTask.Params(); + prmBerthingTask.BerthingId = config.BerthingForm.BerthingId; + prmBerthingTask.StatusCat = SlmBerthingTask.StatusCat.NotDeleted; + + // Retrieve Berthing Tasks. + List berthingTasks = await BerthingMgr.GetBerthingTaskList_Mobile(prmBerthingTask, taskDataPrepareData_Local); + + // Populate berthing tasks. + foreach (SlmBerthingTask berthingTask in berthingTasks) + { + if (taskDataPrepareData_Local.IsCancellationRequested) return; + berthingTaskDataList.Add(berthingTask.GetData()); + } + if (taskDataPrepareData_Local.IsCancellationRequested) return; + + Device.BeginInvokeOnMainThread(() => + { + // Update panel with revised task info. + RefreshPanels(); + }); + } + + //------------------------------------------------------------------- + // R e f r e s h + //------------------------------------------------------------------- + private void RefreshPanels () + { + RefreshSummaryPanel(); + RefreshDetailsPanel(); + } + //------------------------------------------------------------------- + private void RefreshSummaryPanel () + { + if (berthingTaskDataList.Count == 0) + labelSummary.Text = "No tasks defined"; + else if (berthingTaskDataList.Count == 1) + labelSummary.Text = "1 task defined"; + else + labelSummary.Text = berthingTaskDataList.Count + " tasks defined"; + } + //------------------------------------------------------------------- + private void RefreshDetailsPanel () + { + List html = new List(); + html.Add("" + GetItemListStyles().Concat("\n") + GetItemListScripts().Concat("\n") + ""); + foreach (SlmBerthingTask.Data item in berthingTaskDataList) + { + html.Add("
"); + html.Add(""); + html.Add(" "); + html.Add(" "); + html.Add(" "); + html.Add(" "); + html.Add(" "); + html.Add(" "); + html.Add(" "); + html.Add(" "); + html.Add(" "); + html.Add(" "); + html.Add(" "); + if (SacsSystem.DebugMode) + { + html.Add(" "); + html.Add(" "); + html.Add(" "); + html.Add(" "); + } + html.Add("
Type" + berthingTaskTypes.GetDescForType((int)item.BerthingTaskType) + "Status" + SacsSystem.GetStatusDesc(item.Status) + "
Started" + DateUtil.Format(item.Started, "ddd d-MMM-yyyy") + "Completed" + DateUtil.Format(item.Completed, "ddd d-MMM-yyyy") + "
Arrived" + item.Remarks.ReplaceAll("\n","
") + "
BerthingId" + SysId.ToString(item.BerthingId) + "Id" + SysId.ToString(item.Id) + "
"); + html.Add("
"); + } + html.Add(""); + webViewDetails.Html = html.Concat("\n"); + } + private List GetItemListStyles () + { + return new List() + { + "", + "", + "", + "" + }; + } + private List GetItemListScripts () + { + return new List() + { + "", + "", + "", + "", + "" + }; + } + + //------------------------------------------------------------------- + // P a n e l E v e n t s + //------------------------------------------------------------------- + protected override void ButtonAddItem_Clicked (object sender, EventArgs e) + { + SlmFormPage_Bulk_BerthingTask.Config formConfig = new SlmFormPage_Bulk_BerthingTask.Config(config.BerthingForm.BerthingId); + SlmFormPage_Bulk_BerthingTask berthingTaskForm = new SlmFormPage_Bulk_BerthingTask(formConfig); + berthingTaskForm.Disappearing += (sender2, e2) => + { + if (!berthingTaskForm.Cancelled) + { + SlmBerthingTask.Data berthingTaskData = berthingTaskForm.NewBerthingTaskData; + if (berthingTaskData != null) + { + berthingTaskDataList.Add(berthingTaskData); + RefreshPanels(); + DropDown(); + } + } + }; + Application.Current.MainPage.Navigation.PushModalAsync(berthingTaskForm, false); + } + //------------------------------------------------------------------- + private void WebViewDetails_AppNavigating (object sender, SaxWebView.AppNavigatingEventArgs eventArgs) + { + String fn = GetType().Name + ".WebViewDetails_AppNavigating"; + if (SacsSystem.DebugMode) Logger.Debug(fn + " AppAction: " + eventArgs.AppAction); + if (eventArgs.AppAction.StartsWithCI(berthingTaskUpdatePrefix)) + { + SysId berthingTaskId = new SysId(StringUtil.ToInt(eventArgs.AppAction.Right(eventArgs.AppAction.Length - berthingTaskUpdatePrefix.Length))); + if (!SysId.IsValid(berthingTaskId)) + { + DisplayAlert(Caption, "Invalid berthing task selected.", "OK"); + return; + } + SlmBerthingTask.Data berthingTaskData = berthingTaskDataList.Find(item => item.Id.Equals(berthingTaskId)); + if (!SysId.IsValid(berthingTaskId)) + { + DisplayAlert(Caption, "Failed to retrieve berthing task.", "OK"); + return; + } + + // Show Berthing Task form. + SlmFormPage_Bulk_BerthingTask.Config formConfig = new SlmFormPage_Bulk_BerthingTask.Config(config.BerthingForm.BerthingId); + formConfig.BerthingTaskToUpdate = berthingTaskData; + SlmFormPage_Bulk_BerthingTask berthingTaskForm = new SlmFormPage_Bulk_BerthingTask(formConfig); + berthingTaskForm.Disappearing += (sender2, e2) => + { + if (!berthingTaskForm.Cancelled) + { + berthingTaskDataList.Add(berthingTaskData); + RefreshPanels(); + DropDown(); + } + }; + Application.Current.MainPage.Navigation.PushModalAsync(berthingTaskForm, false); + } + } + + //------------------------------------------------------------------- + } + //======================================================================= +} diff --git a/LogisticsMgrMobile/LogisticsMgrMobile/Mobile/Forms/Panels/Main/SlmMainPanel_AssetMovements.cs b/LogisticsMgrMobile/LogisticsMgrMobile/Mobile/Forms/Panels/Main/Assets/SlmMainPanel_AssetMovements.cs similarity index 75% rename from LogisticsMgrMobile/LogisticsMgrMobile/Mobile/Forms/Panels/Main/SlmMainPanel_AssetMovements.cs rename to LogisticsMgrMobile/LogisticsMgrMobile/Mobile/Forms/Panels/Main/Assets/SlmMainPanel_AssetMovements.cs index 65a527b..5031e7a 100644 --- a/LogisticsMgrMobile/LogisticsMgrMobile/Mobile/Forms/Panels/Main/SlmMainPanel_AssetMovements.cs +++ b/LogisticsMgrMobile/LogisticsMgrMobile/Mobile/Forms/Panels/Main/Assets/SlmMainPanel_AssetMovements.cs @@ -8,13 +8,13 @@ using Sarand.LogisticsMgr.Core.App; using Sarand.LogisticsMgr.Core.Bus; using Sarand.LogisticsMgr.Core.WebService; using Sarand.LogisticsMgr.Mobile.Core.App; -using Sarand.LogisticsMgr.Mobile.Forms.Pages.Assets; +using Sarand.LogisticsMgr.Mobile.Forms.Pages.Forms.Assets; using System; using System.Collections.Generic; using System.Threading.Tasks; using Xamarin.Forms; -namespace Sarand.LogisticsMgr.Mobile.Forms.Panels.Main +namespace Sarand.LogisticsMgr.Mobile.Forms.Panels.Main.Assets { //======================================================================= public class SlmMainPanel_AssetMovements : SlmMainPanel_ItemList @@ -145,19 +145,19 @@ namespace Sarand.LogisticsMgr.Mobile.Forms.Panels.Main } public SlmAssetMovement.Params GetAssetMovementParams (uint pageNo, ushort pageLength) { - SlmAssetMovement.Params assetMovementParams = new SlmAssetMovement.Params(); + SlmAssetMovement.Params prmAssetMovement = new SlmAssetMovement.Params(); // Filter. - assetMovementParams.AssetCodePartial = HeaderPanel.PanelFilter.GetFilterPropertyValue((int)FilterProperty.Code); - assetMovementParams.AssetSizeCodePartial = HeaderPanel.PanelFilter.GetFilterPropertyValue((int)FilterProperty.Size); - assetMovementParams.MovementRefPartial = HeaderPanel.PanelFilter.GetFilterPropertyValue((int)FilterProperty.Reference); - assetMovementParams.StatusCat = SlmAssetMovement.StatusCat.NotDeleted; + prmAssetMovement.AssetCodePartial = HeaderPanel.PanelFilter.GetFilterPropertyValue((int)FilterProperty.Code); + prmAssetMovement.AssetSizeCodePartial = HeaderPanel.PanelFilter.GetFilterPropertyValue((int)FilterProperty.Size); + prmAssetMovement.MovementRefPartial = HeaderPanel.PanelFilter.GetFilterPropertyValue((int)FilterProperty.Reference); + prmAssetMovement.StatusCat = SlmAssetMovement.StatusCat.NotDeleted; // Paging. - assetMovementParams.ResultsPaging.PageNo = pageNo; - assetMovementParams.ResultsPaging.PageLength = pageLength; + prmAssetMovement.ResultsPaging.PageNo = pageNo; + prmAssetMovement.ResultsPaging.PageLength = pageLength; // Mode. if (config.Mode == PanelMode.InProgress) - assetMovementParams.StatusCat = SlmAssetMovement.StatusCat.NotClosed; - return assetMovementParams; + prmAssetMovement.StatusCat = SlmAssetMovement.StatusCat.NotClosed; + return prmAssetMovement; } private SacsTaskData taskDataRefreshList = null; protected override void RefreshItemList (uint pageNo = 1) @@ -192,7 +192,7 @@ namespace Sarand.LogisticsMgr.Mobile.Forms.Panels.Main // Configure request. SlmWebServiceRequest.Config configRequest = new SlmWebServiceRequest.Config(); configRequest.DataType = SlmWebServiceRequest.DataType.AssetMovement; - configRequest.RequestType = SlmWebServiceRequest.RequestType.List; + configRequest.RequestType = SlmWebServiceRequest.RequestType.QueryList; configRequest.Context.SiteDefinition = SlmGlobals_Mobile.SessionProfile.SiteDefinition; configRequest.Context.Debug = SacsSystem.DebugMode; // Filter. @@ -220,8 +220,8 @@ namespace Sarand.LogisticsMgr.Mobile.Forms.Panels.Main }; // Request User profile. if (SacsSystem.DebugMode) Logger.Debug(fn + " Querying data - START"); - SlmWebServiceClient.ItemListResponseData responseData = - await new SlmWebServiceClient().GetItemList(configRequest, filter, queryColumns, taskDataRefreshList_Local); + SlmWebServiceClient.QueryListResponseData responseData = + await new SlmWebServiceClient().RequestQueryList(configRequest, filter, queryColumns, taskDataRefreshList_Local); if (SacsSystem.DebugMode) Logger.Debug(fn + " Querying data - END Items: " + (responseData?.Items.Count.ToString() ?? "None") + (taskDataRefreshList_Local.IsCancellationRequested ? " [Cancelled]" : "")); // Display item list. @@ -244,7 +244,7 @@ namespace Sarand.LogisticsMgr.Mobile.Forms.Panels.Main } //------------------------------------------------------------------- - protected override void DisplayItemList (SlmWebServiceClient.ItemListResponseData responseData, SacsMessage message = null) + protected override void DisplayItemList (SlmWebServiceClient.QueryListResponseData responseData, SacsMessage message = null) { // Refresh paging properties. if (responseData != null) @@ -278,8 +278,8 @@ namespace Sarand.LogisticsMgr.Mobile.Forms.Panels.Main html += "
"; html += ""; html += " "; - html += " "; - html += " "; + html += " "; + html += " "; html += " "; html += " "; html += " "; @@ -318,11 +318,7 @@ namespace Sarand.LogisticsMgr.Mobile.Forms.Panels.Main "", "" @@ -353,115 +349,30 @@ namespace Sarand.LogisticsMgr.Mobile.Forms.Panels.Main //------------------------------------------------------------------- // P a n e l E v e n t s //------------------------------------------------------------------- - private SacsTaskData taskDataAppAction; /// 'App' navigation events on Item List web view control. protected override void ItemListWebView_AppNavigating (object sender, SaxWebView.AppNavigatingEventArgs eventArgs) { String fn = GetType().Name + ".ItemListWebView_AppNavigating"; if (SacsSystem.DebugMode) Logger.Debug(fn + " AppAction: " + eventArgs.AppAction); - // Cancel previous action. - if (taskDataAppAction != null) - { - taskDataAppAction.TriggerCancellation(); - taskDataAppAction = null; - } - taskDataAppAction = new SacsTaskData(null); if (eventArgs.AppAction.StartsWithCI(assetMovementDoubleClickedPrefix)) { - SacsTaskData taskDataAppAction_Local = taskDataAppAction; SysId assetMovementId = new SysId(StringUtil.ToInt(eventArgs.AppAction.Right(eventArgs.AppAction.Length - assetMovementDoubleClickedPrefix.Length))); - Task.Run(async () => + if (!SysId.IsValid(assetMovementId)) { - try - { - await showAssetMovementForm(assetMovementId, taskDataAppAction_Local); - } - catch (Exception exc) { if (SacsSystem.DebugMode) Logger.Warn(fn + " " + ExceptionUtil.GetLogMessage(exc)); } - }, taskDataAppAction_Local.CancellationToken) - .ContinueWith(task => - { - taskDataAppAction_Local.Dispose(); - if (taskDataAppAction == taskDataAppAction_Local) - taskDataAppAction = null; - }); - } - } - //------------------------------------------------------------------- - private async Task showAssetMovementForm (SysId assetMovementId, SacsTaskData taskDataAppAction_Local) - { - String fn = GetType().Name + ".ItemListWebView_AppNavigating"; - if (!SysId.IsValid(assetMovementId)) - { - Device.BeginInvokeOnMainThread(async () => - { - await DisplayAlert("Asset Movement", "Invalid asset movement selected.", "OK"); - }); - return; - } - - // Retrieve Asset Movement and associated details. - SlmAssetMovement assetMovement = null; - SlmContainer container = null; - try - { - SacsTaskData taskData = new SacsTaskData(null) { Debug = SacsSystem.DebugMode }; - // Retrieve Asset Movement. - SlmAssetMovement.Params prmAssetMovement = new SlmAssetMovement.Params(); - prmAssetMovement.IncludedIds.Add(assetMovementId); - prmAssetMovement.StatusCat = SlmAssetMovement.StatusCat.Any; - assetMovement = await AssetMgr.GetAssetMovement_Mobile(prmAssetMovement, taskData); - // Retrieve Container. - if (assetMovement != null) - { - if (assetMovement.AssetItemType == Slm.AssetItemType.Container) - { - SlmContainer.Params prmContainer = new SlmContainer.Params(); - prmContainer.IncludedIds.Add(assetMovement.AssetItemId); - prmContainer.StatusCat = SlmContainer.StatusCat.Any; - container = await AssetMgr.GetContainer_Mobile(prmContainer, taskData); - } - } - } - catch (Exception exc) { Logger.Debug(fn + " " + exc.GetLogMessage(6)); } - if (assetMovement == null) - { - Device.BeginInvokeOnMainThread(async () => - { - await DisplayAlert("Asset Movement", "Failed to retrieve Asset movement data.", "OK"); - }); - return; - } - if (assetMovement.AssetItemType == Slm.AssetItemType.Container) - { - if (container == null) - { - Device.BeginInvokeOnMainThread(async () => - { - await DisplayAlert("Asset Movement", "Failed to retrieve Container data.", "OK"); - }); + DisplayAlert(HeaderCaption, "Invalid asset movement selected.", "OK"); return; } - } - else - { - await DisplayAlert("Asset Movement", "Unrecognised asset type: " + assetMovement.AssetItemType.ToString() + ".", "OK"); - return; - } - Device.BeginInvokeOnMainThread(async () => - { // Configure Asset Movement page. - SlmPage_Assets_Movement.Config pageConfig = new SlmPage_Assets_Movement.Config(); - pageConfig.AssetMovementToUpdate = assetMovement; - pageConfig.AssetMovement_Container = container; + // Data will be retrieved and validated by the page. + SlmFormPage_Assets_Movement.Config pageConfig = new SlmFormPage_Assets_Movement.Config(); + pageConfig.AssetMovementIdToUpdate = assetMovementId; pageConfig.ReadOnly = true; if (pageConfig.ReadOnly) pageConfig.NavigationMode = Core.Forms.Base.SlmFormPage.NavigationMode.Close; - SlmPage_Assets_Movement assetRepairForm = new SlmPage_Assets_Movement (pageConfig); - assetRepairForm.Disappearing += (sender2, e2) => - { - }; - await SlmGlobals_Mobile.Application.MainPage.Navigation.PushModalAsync(assetRepairForm, false); - }); + SlmFormPage_Assets_Movement assetRepairForm = new SlmFormPage_Assets_Movement (pageConfig); + //assetRepairForm.Disappearing += (sender2, e2) => { }; + SlmGlobals_Mobile.Application.MainPage.Navigation.PushModalAsync(assetRepairForm, false); + } } //------------------------------------------------------------------- diff --git a/LogisticsMgrMobile/LogisticsMgrMobile/Mobile/Forms/Panels/Main/SlmMainPanel_ShipFile.cs b/LogisticsMgrMobile/LogisticsMgrMobile/Mobile/Forms/Panels/Main/Bulk/SlmMainPanel_Bulk_Berthings.cs similarity index 72% rename from LogisticsMgrMobile/LogisticsMgrMobile/Mobile/Forms/Panels/Main/SlmMainPanel_ShipFile.cs rename to LogisticsMgrMobile/LogisticsMgrMobile/Mobile/Forms/Panels/Main/Bulk/SlmMainPanel_Bulk_Berthings.cs index 2144f05..880c73e 100644 --- a/LogisticsMgrMobile/LogisticsMgrMobile/Mobile/Forms/Panels/Main/SlmMainPanel_ShipFile.cs +++ b/LogisticsMgrMobile/LogisticsMgrMobile/Mobile/Forms/Panels/Main/Bulk/SlmMainPanel_Bulk_Berthings.cs @@ -8,19 +8,17 @@ using Sarand.LogisticsMgr.Core.App; using Sarand.LogisticsMgr.Core.Bus; using Sarand.LogisticsMgr.Core.WebService; using Sarand.LogisticsMgr.Mobile.Core.App; -using Sarand.LogisticsMgr.Mobile.Core.Forms.Base; -using Sarand.LogisticsMgr.Mobile.Forms.Components; +using Sarand.LogisticsMgr.Mobile.Core.Bus; +using Sarand.LogisticsMgr.Mobile.Forms.Pages.Forms.Bulk; using System; using System.Collections.Generic; -using System.Runtime.CompilerServices; -using System.Text; using System.Threading.Tasks; using Xamarin.Forms; -namespace Sarand.LogisticsMgr.Mobile.Forms.Panels.Main +namespace Sarand.LogisticsMgr.Mobile.Forms.Panels.Main.Bulk { //======================================================================= - public class SlmMainPanel_ShipFile : SlmMainPanel_ItemList + public class SlmMainPanel_Bulk_Berthings : SlmMainPanel_ItemList { //------------------------------------------------------------------- // Definitions. @@ -30,11 +28,15 @@ namespace Sarand.LogisticsMgr.Mobile.Forms.Panels.Main } public enum PanelMode { - Last2Weeks + Last2Weeks, + Last2Months, } public new class Config : SlmMainPanel_ItemList.Config { - public PanelMode Mode { get; set; } = PanelMode.Last2Weeks; + public Config () + { + } + public PanelMode Mode { get; set; } = PanelMode.Last2Months; } //------------------------------------------------------------------- @@ -63,7 +65,7 @@ namespace Sarand.LogisticsMgr.Mobile.Forms.Panels.Main //------------------------------------------------------------------- // Construction. - public SlmMainPanel_ShipFile (Config config) : + public SlmMainPanel_Bulk_Berthings (Config config) : base(config) { this.config = config; @@ -71,10 +73,10 @@ namespace Sarand.LogisticsMgr.Mobile.Forms.Panels.Main cols.Id = BerthingMgr.GetBerthingColumnDfn(SlmBerthing.Column.Id); cols.VesselId = BerthingMgr.GetBerthingColumnDfn(SlmBerthing.Column.VesselId); cols.VesselName = BerthingMgr.GetBerthingColumnDfn(SlmBerthing.Column.Vessel_Name); - cols.AgentId = BerthingMgr.GetBerthingColumnDfn(SlmBerthing.Column.AgentId); - cols.AgentName = BerthingMgr.GetBerthingColumnDfn(SlmBerthing.Column.Agent_Name); - cols.CustomerId = BerthingMgr.GetBerthingColumnDfn(SlmBerthing.Column.CustomerId); - cols.CustomerName = BerthingMgr.GetBerthingColumnDfn(SlmBerthing.Column.Customer_Name); + cols.AgentId = BerthingMgr.GetBerthingColumnDfn(SlmBerthing.Column.CompanyIdAgent); + cols.AgentName = BerthingMgr.GetBerthingColumnDfn(SlmBerthing.Column.CompanyAgent_Name); + cols.CustomerId = BerthingMgr.GetBerthingColumnDfn(SlmBerthing.Column.CompanyIdCustomer); + cols.CustomerName = BerthingMgr.GetBerthingColumnDfn(SlmBerthing.Column.CompanyCustomer_Name); cols.Berth = BerthingMgr.GetBerthingColumnDfn(SlmBerthing.Column.Berth); cols.Bollard = BerthingMgr.GetBerthingColumnDfn(SlmBerthing.Column.Bollard); cols.Expected = BerthingMgr.GetBerthingColumnDfn(SlmBerthing.Column.Expected); @@ -137,19 +139,27 @@ namespace Sarand.LogisticsMgr.Mobile.Forms.Panels.Main filterPropertyTypes.Add(new SacsFilterPropertyType((int)FilterProperty.Vessel, "Vessel") { Mode = SacsFilterPropertyType.FilterMode.Text }); return filterPropertyTypes; } - public SlmBerthing.Params GetBerthingParams (uint pageNo, ushort pageLength) + public SlmBerthing_Mobile.Params GetBerthingParams (uint pageNo, ushort pageLength) { - SlmBerthing.Params berthingParams = new SlmBerthing.Params(); + SlmBerthing_Mobile.Params prmBerthing = new SlmBerthing_Mobile.Params(); // Filter. - berthingParams.VesselPartial = HeaderPanel.PanelFilter.GetFilterPropertyValue((int)FilterProperty.Vessel); - berthingParams.StatusCat = SlmBerthing.StatusCat.NotDeleted; + prmBerthing.VesselPartial = HeaderPanel.PanelFilter.GetFilterPropertyValue((int)FilterProperty.Vessel); + prmBerthing.StatusCat = SlmBerthing.StatusCat.NotDeleted; // Paging. - berthingParams.ResultsPaging.PageNo = pageNo; - berthingParams.ResultsPaging.PageLength = pageLength; + prmBerthing.ResultsPaging.PageNo = pageNo; + prmBerthing.ResultsPaging.PageLength = pageLength; // Mode. if (config.Mode == PanelMode.Last2Weeks) - berthingParams.ArrivedFrom = DateUtil.IncrementDate(DateTime.Today, -14); - return berthingParams; + { + prmBerthing.ArrivedFrom = DateUtil.IncrementDate(DateTime.Today, -14); + prmBerthing.IncludeAllCurrent = true; + } + else if (config.Mode == PanelMode.Last2Months) + { + prmBerthing.ArrivedFrom = DateUtil.IncrementDate(DateTime.Today, -60); + prmBerthing.IncludeAllCurrent = true; + } + return prmBerthing; } private SacsTaskData taskDataRefreshList = null; protected override void RefreshItemList (uint pageNo = 1) @@ -169,7 +179,7 @@ namespace Sarand.LogisticsMgr.Mobile.Forms.Panels.Main // Refresh the list. RefreshItemList(GetBerthingParams(pageNo, ItemsPerPage), taskDataRefreshList = new SacsTaskData(null)); } - private void RefreshItemList (SlmBerthing.Params berthingParams, SacsTaskData taskDataRefreshList_Local) + private void RefreshItemList (SlmBerthing_Mobile.Params berthingParams, SacsTaskData taskDataRefreshList_Local) { String fn = GetType().Name + ".RefreshItemList"; @@ -184,7 +194,7 @@ namespace Sarand.LogisticsMgr.Mobile.Forms.Panels.Main // Configure request. SlmWebServiceRequest.Config configRequest = new SlmWebServiceRequest.Config(); configRequest.DataType = SlmWebServiceRequest.DataType.Berthing; - configRequest.RequestType = SlmWebServiceRequest.RequestType.List; + configRequest.RequestType = SlmWebServiceRequest.RequestType.QueryList; configRequest.Context.SiteDefinition = SlmGlobals_Mobile.SessionProfile.SiteDefinition; configRequest.Context.Debug = SacsSystem.DebugMode; // Filter. @@ -210,8 +220,8 @@ namespace Sarand.LogisticsMgr.Mobile.Forms.Panels.Main }; // Request User profile. if (SacsSystem.DebugMode) Logger.Debug(fn + " Querying data - START"); - SlmWebServiceClient.ItemListResponseData responseData = - await new SlmWebServiceClient().GetItemList(configRequest, filter, queryColumns, taskDataRefreshList_Local); + SlmWebServiceClient.QueryListResponseData responseData = + await new SlmWebServiceClient().RequestQueryList(configRequest, filter, queryColumns, taskDataRefreshList_Local); if (SacsSystem.DebugMode) Logger.Debug(fn + " Querying data - END Items: " + (responseData?.Items.Count.ToString() ?? "None") + (taskDataRefreshList_Local.IsCancellationRequested ? " [Cancelled]" : "")); // Display item list. @@ -234,7 +244,7 @@ namespace Sarand.LogisticsMgr.Mobile.Forms.Panels.Main } //------------------------------------------------------------------- - protected override void DisplayItemList (SlmWebServiceClient.ItemListResponseData responseData, SacsMessage message = null) + protected override void DisplayItemList (SlmWebServiceClient.QueryListResponseData responseData, SacsMessage message = null) { // Refresh paging properties. if (responseData != null) @@ -262,18 +272,18 @@ namespace Sarand.LogisticsMgr.Mobile.Forms.Panels.Main { } else if (responseData.Items.Count > 0) { - //html += "
Movements found: " + responseData.Items.Count + "
"; + //html += "
Berthings found: " + responseData.Items.Count + "
"; foreach (var item in responseData.Items) { - html += "
"; + html += "
"; html += "
Container"+item.GetValue(cols.Asset_Code.DataName)+"Size"+item.GetValue(cols.AssetSizeCode.DataName)+"Container" + item.GetValue(cols.Asset_Code.DataName) + "Size" + item.GetValue(cols.AssetSizeCode.DataName) + "
Customer" + item.GetValue(cols.Customer.DataName) + "
"; html += " "; html += " "; - html += " "; + html += " "; html += " "; html += " "; html += " "; - html += " "; + html += " "; html += " "; html += " "; html += " "; @@ -298,7 +308,7 @@ namespace Sarand.LogisticsMgr.Mobile.Forms.Panels.Main html += ""; } } - else html += "
No movements found
"; + else html += "
No Berthings found
"; html += ""; ItemListWebView.Html = html; //Logger.Debug("HTML: " + html); @@ -312,11 +322,7 @@ namespace Sarand.LogisticsMgr.Mobile.Forms.Panels.Main "", "" @@ -333,7 +339,7 @@ namespace Sarand.LogisticsMgr.Mobile.Forms.Panels.Main "
Vessel" + item.GetValue(cols.VesselName.DataName) + "Agent" + item.GetValue(cols.AgentName.DataName) + "" + "
Customer" + item.GetValue(cols.CustomerName.DataName) + "" + "Agent" + item.GetValue(cols.AgentName.DataName) + "
Berth" + item.GetValue(cols.Berth.DataName) + "