Bläddra i källkod

PRS MOBILE - error catching

Nick-PRSDigital@bitbucket.org 2 år sedan
förälder
incheckning
92168eda3c

+ 33 - 32
prs.desktop/Dashboards/Projects/Job Requisition Items Review Dashboard/JobRequisitionItemStockHoldingReserverGrid.cs

@@ -72,38 +72,38 @@ namespace PRSDesktop
         private bool ReserveStock(CoreRow row)
         {
             StockHolding holding = row.ToObject<StockHolding>();
-            if (holding.Job.IsValid())
-            {
-                CoreTable table = new Client<StockMovement>().Query(new Filter<StockMovement>(x => x.Location.ID).IsEqualTo(holding.ID)
-                    .And(x => x.JobRequisitionItem.ID).IsEqualTo(RequiItemID),
-                    new Columns<StockMovement>(x => x.ID));
-                if (table.Rows.Any())
-                {
-                    var choiceresult = MessageBox.Show("This will reverse previous stock movements created to reserve from this location. Proceed?", "Alert", MessageBoxButton.YesNo);
-                    switch (choiceresult)
-                    {
-                        case MessageBoxResult.Yes:
-                            break;
-                        case MessageBoxResult.No:
-                            return false;
-                        default:
-                            return false;
-                    }
-                    List<StockMovement> movements = new List<StockMovement>();
-                    foreach (CoreRow stockmovementRow in table.Rows)
-                    {
-                        StockMovement movement = new StockMovement { ID = Guid.Parse(stockmovementRow.Values[0].ToString()) };
-                        movements.Add(movement);
-                    }
-                    new Client<StockMovement>().Delete(movements, "Stock movements reversed from Job Requi Review Dashboard");
-                    return true;
-                }
-                else
-                {
-                    MessageBox.Show("The stock movements for this holding cannot be reversed");
-                    return false;
-                }
-            }
+            //if (holding.Job.IsValid())
+            //{
+            //    CoreTable table = new Client<StockMovement>().Query(new Filter<StockMovement>(x => x.Location.ID).IsEqualTo(holding.ID)
+            //        .And(x => x.JobRequisitionItem.ID).IsEqualTo(RequiItemID),
+            //        new Columns<StockMovement>(x => x.ID));
+            //    if (table.Rows.Any())
+            //    {
+            //        var choiceresult = MessageBox.Show("This will reverse previous stock movements created to reserve from this location. Proceed?", "Alert", MessageBoxButton.YesNo);
+            //        switch (choiceresult)
+            //        {
+            //            case MessageBoxResult.Yes:
+            //                break;
+            //            case MessageBoxResult.No:
+            //                return false;
+            //            default:
+            //                return false;
+            //        }
+            //        List<StockMovement> movements = new List<StockMovement>();
+            //        foreach (CoreRow stockmovementRow in table.Rows)
+            //        {
+            //            StockMovement movement = new StockMovement { ID = Guid.Parse(stockmovementRow.Values[0].ToString()) };
+            //            movements.Add(movement);
+            //        }
+            //        new Client<StockMovement>().Delete(movements, "Stock movements reversed from Job Requi Review Dashboard");
+            //        return true;
+            //    }
+            //    else
+            //    {
+            //        MessageBox.Show("The stock movements for this holding cannot be reversed");
+            //        return false;
+            //    }
+            //}
             var result = MessageBox.Show("This will reserve stock from the holding now. Proceed?", "Alert", MessageBoxButton.YesNo);
             switch (result)
             {
@@ -125,6 +125,7 @@ namespace PRSDesktop
                 List<StockMovement> movements = new List<StockMovement>();
 
                 StockMovement issuemovement = new StockMovement();
+                issuemovement.System = true;
                 issuemovement.Batch.Notes = batch.Notes;
                 issuemovement.Batch.Type = StockMovementBatchType.Transfer;
                 issuemovement.Units = units;

+ 2 - 1
prs.desktop/Dashboards/Projects/Job Requisition Items Review Dashboard/JobRequisitionReviewDashboard.xaml.cs

@@ -178,8 +178,9 @@ namespace PRSDesktop
             {
                 empID = Guid.Parse(table.Rows.FirstOrDefault().Values[0].ToString());
                 empName = table.Rows.FirstOrDefault().Values[1].ToString();
-            }
+            }        
         }
+      
 
         private bool ViewCancelled(Button button, CoreRow[] rows)
         {

+ 20 - 0
prs.desktop/Panels/Jobs/JobRequisitionItemGrid.cs

@@ -36,5 +36,25 @@ namespace PRSDesktop
             result.Job.ID = JobID;
             return result;
         }
+
+        protected override void GenerateColumns(DynamicGridColumns columns)
+        {
+            columns.Add<JobRequisitionItem, DateTime>(x => x.Created, 80, "Date", "", Alignment.MiddleLeft);
+            columns.Add<JobRequisitionItem, string>(x => x.Requisition.Job.JobNumber, 70, "Job", "", Alignment.MiddleLeft);
+            columns.Add<JobRequisitionItem, int>(x => x.Requisition.Number, 50, "NO.", "", Alignment.MiddleLeft);
+            columns.Add<JobRequisitionItem, string>(x => x.Product.Code, 70, "Code", "", Alignment.MiddleLeft);
+            columns.Add<JobRequisitionItem, string>(x => x.Product.Name, 200, "Product Name", "", Alignment.MiddleLeft);
+            columns.Add<JobRequisitionItem, string>(x => x.Style.Description, 150, "Style", "", Alignment.MiddleLeft);
+            columns.Add<JobRequisitionItem, double>(x => x.Qty, 50, "Qty", "", Alignment.MiddleLeft);
+            columns.Add<JobRequisitionItem, string>(x => x.Dimensions.UnitSize, 50, "Size", "", Alignment.MiddleLeft);
+            columns.Add<JobRequisitionItem, string>(x => x.PurchaseOrderItem.PurchaseOrderLink.PONumber, 80, "PO Number", "", Alignment.MiddleLeft);
+            columns.Add<JobRequisitionItem, string>(x => x.PurchaseOrderItem.PONumber, 80, "PO Number", "", Alignment.MiddleLeft);
+            columns.Add<JobRequisitionItem, DateTime>(x => x.PurchaseOrderItem.DueDate, 80, "Due", "", Alignment.MiddleLeft);
+            columns.Add<JobRequisitionItem, DateTime>(x => x.PurchaseOrderItem.ReceivedDate, 80, "Received", "", Alignment.MiddleLeft);
+            columns.Add<JobRequisitionItem, JobRequisitionItemStatus>(x => x.Status, 80, "Status", "", Alignment.MiddleLeft);
+            columns.Add<JobRequisitionItem, string>(x => x.Notes, 300, "Notes", "", Alignment.MiddleLeft);
+
+            base.GenerateColumns(columns);
+        }
     }
 }

+ 0 - 1
prs.mobile/comal.timesheets.Android/Resources/Resource.designer.cs

@@ -2,7 +2,6 @@
 //------------------------------------------------------------------------------
 // <auto-generated>
 //     This code was generated by a tool.
-//     Runtime Version:4.0.30319.42000
 //
 //     Changes to this file may cause incorrect behavior and will be lost if
 //     the code is regenerated.

+ 34 - 30
prs.mobile/comal.timesheets/DigitalForms/CustomUserControls/EmbeddedImageCapture.cs

@@ -282,37 +282,41 @@ namespace comal.timesheets
 
                     Device.BeginInvokeOnMainThread(() =>
                     {
-                        Children.Clear();
-                        RowDefinitions.Clear();
-                        ColumnDefinitions.Clear();
-                        RowDefinitions.Add(new RowDefinition() { Height = new GridLength(35, GridUnitType.Absolute) });
-                        RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Auto) });
-                        ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Auto) });
-
-
-                        Image img = new Image { Source = "closee.png" };
-                        img.GestureRecognizers.Add(new TapGestureRecognizer
+                        try
                         {
-                            Command = new Command(OnVideoTap),
-                            CommandParameter = data,
-                            NumberOfTapsRequired = 1
-                        });
-                        img.HorizontalOptions = LayoutOptions.Center;
-                        img.VerticalOptions = LayoutOptions.Center;
-                        img.HeightRequest = 35;
-                        img.WidthRequest = 35;
-                        img.Margin = new Thickness(5, 5, 5, 0);
-
-                        SetRow(img, 0);
-                        SetColumn(img, 0);
-
-                        SetRow(element, 1);
-                        SetColumn(element, 0);
-                        Padding = new Thickness(0);
-                        Children.Add(img);
-                        Children.Add(element);
-                        HorizontalOptions = LayoutOptions.CenterAndExpand;
-                        ForceLayout();
+                            Children.Clear();
+                            RowDefinitions.Clear();
+                            ColumnDefinitions.Clear();
+                            RowDefinitions.Add(new RowDefinition() { Height = new GridLength(35, GridUnitType.Absolute) });
+                            RowDefinitions.Add(new RowDefinition() { Height = new GridLength(1, GridUnitType.Auto) });
+                            ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Auto) });
+
+
+                            Image img = new Image { Source = "closee.png" };
+                            img.GestureRecognizers.Add(new TapGestureRecognizer
+                            {
+                                Command = new Command(OnVideoTap),
+                                CommandParameter = data,
+                                NumberOfTapsRequired = 1
+                            });
+                            img.HorizontalOptions = LayoutOptions.Center;
+                            img.VerticalOptions = LayoutOptions.Center;
+                            img.HeightRequest = 35;
+                            img.WidthRequest = 35;
+                            img.Margin = new Thickness(5, 5, 5, 0);
+
+                            SetRow(img, 0);
+                            SetColumn(img, 0);
+
+                            SetRow(element, 1);
+                            SetColumn(element, 0);
+                            Padding = new Thickness(0);
+                            Children.Add(img);
+                            Children.Add(element);
+                            HorizontalOptions = LayoutOptions.CenterAndExpand;
+                            ForceLayout();
+                        }
+                        catch { }
                     });
                 }
             }

+ 56 - 34
prs.mobile/comal.timesheets/Grids/DeliveryGrid.cs

@@ -1,4 +1,5 @@
-using Comal.Classes;
+using Com.Airbnb.Lottie.Model.Layer;
+using Comal.Classes;
 using InABox.Clients;
 using InABox.Core;
 using Syncfusion.SfMaps.XForms;
@@ -7,6 +8,7 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using Xamarin.CommunityToolkit.Converters;
 using Xamarin.Forms;
 using XF.Material.Forms.UI.Dialogs;
 using PRSSecurity = InABox.Core.Security;
@@ -33,17 +35,24 @@ namespace comal.timesheets
 
         private List<DataGridViewModelItem> LoadList()
         {
-            CoreTable table = DoQuery();
+            try
+            {
+                CoreTable table = DoQuery();
 
-            if (!table.Rows.Any())
-                return null;
+                if (!table.Rows.Any())
+                    return null;
 
-            List<DataGridViewModelItem> items = new List<DataGridViewModelItem>();
+                List<DataGridViewModelItem> items = new List<DataGridViewModelItem>();
 
-            foreach (var row in table.Rows)
-                items.Add(CreateItem(row));
+                foreach (var row in table.Rows)
+                    items.Add(CreateItem(row));
 
-            return items;
+                return items;
+            }
+            catch
+            {
+                return null;
+            }
         }
 
         private DataGridViewModelItem CreateItem(CoreRow row)
@@ -90,27 +99,34 @@ namespace comal.timesheets
 
         private CoreTable DoQuery()
         {
-            return new Client<Delivery>().Query(
-                    filter,
-                    new Columns<Delivery>(
-                        x => x.ID,
-                        x => x.Job.JobNumber,
-                        x => x.Job.ID,
-                        x => x.Job.Name,
-                        x => x.Number,
-                        x => x.Date,
-                        x => x.Contact.Name,
-                        x => x.Location.Latitude,
-                        x => x.Location.Longitude,
-                        x => x.Assignment.Date,
-                        x => x.DeliveredBy.Name,
-                        x => x.Delivered,
-                        x => x.Due,
-                        x => x.Location.Address,
-                        x => x.Created
-                    ),
-                    new SortOrder<Delivery>(x => x.Created, SortDirection.Descending)
-                    );
+            try
+            {
+                return new Client<Delivery>().Query(
+                        filter,
+                        new Columns<Delivery>(
+                            x => x.ID,
+                            x => x.Job.JobNumber,
+                            x => x.Job.ID,
+                            x => x.Job.Name,
+                            x => x.Number,
+                            x => x.Date,
+                            x => x.Contact.Name,
+                            x => x.Location.Latitude,
+                            x => x.Location.Longitude,
+                            x => x.Assignment.Date,
+                            x => x.DeliveredBy.Name,
+                            x => x.Delivered,
+                            x => x.Due,
+                            x => x.Location.Address,
+                            x => x.Created
+                        ),
+                        new SortOrder<Delivery>(x => x.Created, SortDirection.Descending)
+                        );
+            }
+            catch (Exception e)
+            {
+                return null;
+            }
         }
 
         private Filter<Delivery> CheckFilter()
@@ -218,12 +234,18 @@ namespace comal.timesheets
 
         public void RefreshGrid()
         {
-            var list = LoadList();
-            Items.Clear();
-            Items.AddRange(list);
-            Refresh(Items);
+            try
+            {
+                var list = LoadList();
+                if (list == null)
+                    return;
+                Items.Clear();
+                Items.AddRange(list);
+                Refresh(Items);
+            }
+            catch { }
         }
     }
 
-    
+
 }

+ 33 - 29
prs.mobile/comal.timesheets/Main/MainPage.xaml.cs

@@ -164,43 +164,47 @@ namespace comal.timesheets
 
                 if (!isLatest)
                 {
-                    if (!MainPageUtils.recentlyAskedToUpdate)
+                    try
                     {
-                        string latestVersionNumber = await MobileUtils.AppVersion.GetLatestVersionNumber();
-                        if (MainPageUtils.updateCounter < 3)
+                        if (!MainPageUtils.recentlyAskedToUpdate)
                         {
-                            Device.BeginInvokeOnMainThread(async () =>
+                            string latestVersionNumber = await MobileUtils.AppVersion.GetLatestVersionNumber();
+                            if (MainPageUtils.updateCounter < 3)
                             {
-                                string chosenOption = await DisplayActionSheet(String.Format("Version {0} Available. Update now?", latestVersionNumber), "You will be reminded again in 10 minutes.", null, "Yes", "No");
-                                switch (chosenOption)
+                                Device.BeginInvokeOnMainThread(async () =>
                                 {
-                                    case "No":
-                                        break;
-                                    case "Cancel":
-                                        break;
-                                    case "Yes":
-                                        Dispatcher.BeginInvokeOnMainThread(() => { MobileUtils.AppVersion.OpenAppInStore(); });
-                                        break;
-                                    default:
-                                        break;
-                                }
+                                    string chosenOption = await DisplayActionSheet(String.Format("Version {0} Available. Update now?", latestVersionNumber), "You will be reminded again in 10 minutes.", null, "Yes", "No");
+                                    switch (chosenOption)
+                                    {
+                                        case "No":
+                                            break;
+                                        case "Cancel":
+                                            break;
+                                        case "Yes":
+                                            Dispatcher.BeginInvokeOnMainThread(() => { MobileUtils.AppVersion.OpenAppInStore(); });
+                                            break;
+                                        default:
+                                            break;
+                                    }
 
-                            });
-                        }
-                        else if (MainPageUtils.updateCounter >= 3)
-                        {
-                            Device.BeginInvokeOnMainThread(() =>
-                            {
-                                DisplayAlert(String.Format("Version {0} Available", latestVersionNumber), "Please update your software to the latest version.", "OK")
-                            .ContinueWith((Task task) =>
+                                });
+                            }
+                            else if (MainPageUtils.updateCounter >= 3)
                             {
-                                Dispatcher.BeginInvokeOnMainThread(() => { MobileUtils.AppVersion.OpenAppInStore(); });
-                            });
-                            });
+                                Device.BeginInvokeOnMainThread(() =>
+                                {
+                                    DisplayAlert(String.Format("Version {0} Available", latestVersionNumber), "Please update your software to the latest version.", "OK")
+                                .ContinueWith((Task task) =>
+                                {
+                                    Dispatcher.BeginInvokeOnMainThread(() => { MobileUtils.AppVersion.OpenAppInStore(); });
+                                });
+                                });
+                            }
+                            MainPageUtils.recentlyAskedToUpdate = true;
+                            MainPageUtils.updateCounter++;
                         }
-                        MainPageUtils.recentlyAskedToUpdate = true;
-                        MainPageUtils.updateCounter++;
                     }
+                    catch { }
                 }
 
             });

+ 4 - 1
prs.mobile/comal.timesheets/SettingsPage.xaml

@@ -71,7 +71,10 @@
 
                 <Button x:Name="changePasswordBtn" Clicked="ChangePasswordBtn_Clicked" IsVisible="False" Margin="5"
                Text="Change Password" Padding="3" FontSize="Medium" TextColor="White" BackgroundColor="#15C7C1" FontAttributes="Bold" CornerRadius="10"/>
-                
+
+                <Button x:Name="websocketLogBtn" Clicked="WebsocketLogBtn_Clicked" IsVisible="False" Margin="5"
+               Text="Web socket logs" Padding="3" FontSize="Medium" TextColor="White" BackgroundColor="#15C7C1" FontAttributes="Bold" CornerRadius="10"/>
+
             </StackLayout>
         </ScrollView>
     </ContentPage.Content>

+ 34 - 3
prs.mobile/comal.timesheets/SettingsPage.xaml.cs

@@ -93,6 +93,11 @@ namespace comal.timesheets
 
                 deviceIDEnt.Text = MobileUtils.GetDeviceID();
                 appVersionEnt.Text = MobileUtils.AppVersion.InstalledVersionNumber;
+
+                if (GlobalVariables.EmpID == Guid.Parse("40f6ccd9-5272-4b1a-99bf-de7542205aac") || GlobalVariables.EmpID == Guid.Parse("8fa878db-6bc9-421d-ac4d-ac3ec0a2cd19"))
+                {
+                    websocketLogBtn.IsVisible = true;
+                }
             }
             catch { }
         }
@@ -115,9 +120,13 @@ namespace comal.timesheets
             }
             else if (!isLatest)
             {
-                string latestVersionNumber = await MobileUtils.AppVersion.GetLatestVersionNumber();
-                updateVersionBtn.IsEnabled = true;
-                updateVersionBtn.Text = "Update App Version (" + latestVersionNumber + ")";
+                try
+                {
+                    string latestVersionNumber = await MobileUtils.AppVersion.GetLatestVersionNumber();
+                    updateVersionBtn.IsEnabled = true;
+                    updateVersionBtn.Text = "Update App Version (" + latestVersionNumber + ")";
+                }
+                catch { }
             }
 
             const string errorFilename = "Fatal.log";
@@ -207,6 +216,28 @@ namespace comal.timesheets
                 }
             }
         }
+
+        private async void WebsocketLogBtn_Clicked(object sender, EventArgs e)
+        {
+            const string errorFilename = "Websocket.log";
+            string libraryPath = "";
+            if (Device.RuntimePlatform.Equals(Device.Android))
+                libraryPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
+            else if (Device.RuntimePlatform.Equals(Device.iOS))
+                libraryPath = Environment.GetFolderPath(Environment.SpecialFolder.Resources);
+
+            var errorFilePath = Path.Combine(libraryPath, errorFilename);
+
+            if (!File.Exists(errorFilePath))
+            {
+                return;
+            }
+
+            var errorText = File.ReadAllText(errorFilePath);
+
+            var page = new TextViewer(errorText);
+            Navigation.PushAsync(page);
+        }
         #endregion
     }
 }

+ 12 - 0
prs.mobile/comal.timesheets/TextViewer.xaml

@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
+             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
+             x:Class="comal.timesheets.TextViewer">
+    <ContentPage.Content>
+        <ScrollView>
+            <StackLayout>
+                <Label x:Name="textLbl"/>
+            </StackLayout>
+        </ScrollView>
+    </ContentPage.Content>
+</ContentPage>

+ 21 - 0
prs.mobile/comal.timesheets/TextViewer.xaml.cs

@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+using Xamarin.Forms;
+using Xamarin.Forms.Xaml;
+
+namespace comal.timesheets
+{
+	[XamlCompilation(XamlCompilationOptions.Compile)]
+	public partial class TextViewer : ContentPage
+	{
+		public TextViewer (string text)
+		{
+			InitializeComponent ();
+			textLbl.Text = text;
+		}
+	}
+}

+ 9 - 0
prs.mobile/comal.timesheets/comal.timesheets.projitems

@@ -363,6 +363,9 @@
     <Compile Include="$(MSBuildThisFileDirectory)StringList.xaml.cs">
       <SubType>Code</SubType>
     </Compile>
+    <Compile Include="$(MSBuildThisFileDirectory)TextViewer.xaml.cs">
+      <SubType>Code</SubType>
+    </Compile>
     <Compile Include="$(MSBuildThisFileDirectory)ViewCellFrame.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)Warehousing\Receivals\Receivals.xaml.cs">
       <DependentUpon>Receivals.xaml</DependentUpon>
@@ -1150,4 +1153,10 @@
       <Generator>MSBuild:UpdateDesignTimeXaml</Generator>
     </EmbeddedResource>
   </ItemGroup>
+  <ItemGroup>
+    <EmbeddedResource Include="$(MSBuildThisFileDirectory)TextViewer.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:UpdateDesignTimeXaml</Generator>
+    </EmbeddedResource>
+  </ItemGroup>
 </Project>

+ 2 - 0
prs.stores/PurchaseOrderItemStore.cs

@@ -267,6 +267,8 @@ namespace Comal.Stores
                     item.Status = JobRequisitionItemStatus.TreatmentReceived;
                 else
                     item.Status = JobRequisitionItemStatus.Received;
+
+                Provider.Save(item);
             }
         }