浏览代码

Added exception trapping and logging for digital forms

Frank vandenBos 4 天之前
父节点
当前提交
f9dfd5b262

+ 0 - 4
prs.mobile.new/PRS.Mobile.iOS/PRS.Mobile.iOS.csproj

@@ -28,7 +28,6 @@
     <MtouchDebug>true</MtouchDebug>
     <MtouchNoSymbolStrip>true</MtouchNoSymbolStrip>
     <IOSDebugOverWiFi>true</IOSDebugOverWiFi>
-    <MtouchExtraArgs></MtouchExtraArgs>
     <CodesignKey>iPhone Developer</CodesignKey>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhoneSimulator' ">
@@ -41,7 +40,6 @@
     <MtouchArch>x86_64</MtouchArch>
     <ConsolePause>false</ConsolePause>
     <MtouchFloat32>true</MtouchFloat32>
-    <MtouchExtraArgs></MtouchExtraArgs>
     <CodesignKey>iPhone Developer</CodesignKey>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhone' ">
@@ -62,7 +60,6 @@
     <CreatePackage>
     </CreatePackage>
     <MtouchLink>None</MtouchLink>
-    <MtouchExtraArgs></MtouchExtraArgs>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhone' ">
     <DebugType>none</DebugType>
@@ -82,7 +79,6 @@
     <CrashReportingEnabled>false</CrashReportingEnabled>
     <EnableCodeSigning>
     </EnableCodeSigning>
-    <MtouchExtraArgs></MtouchExtraArgs>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Ad-Hoc|iPhone' ">
     <DebugType>none</DebugType>

+ 127 - 95
prs.mobile.new/PRS.Mobile/Components/DigitalForms/Editor/QAFormViewer.cs

@@ -197,13 +197,20 @@ namespace PRS.Mobile
                 ColumnDefinitions.Add(def);
             }
 
-            Children.Clear();
-            foreach (DFLayoutControl element in _layout.Elements)
-                LoadViewAccordingToElement(element);
+            try
+            {
+                Children.Clear();
+                foreach (DFLayoutControl element in _layout.Elements)
+                    LoadViewAccordingToElement(element);
+                
+                foreach (var header in headersToCollapse)
+                    AdjustHeaderSection(header, false);
+            }
+            catch (Exception ex)
+            {
+                InABox.Mobile.MobileLogging.Log(ex,"LoadFormLayout");
+            }
             
-            foreach (var header in headersToCollapse)
-                AdjustHeaderSection(header, false);
-
         }
         
         private static void SetRowHeight(string row, RowDefinition def)
@@ -236,102 +243,127 @@ namespace PRS.Mobile
         
         private void LoadViewAccordingToElement(DFLayoutControl element)
         {
-            // Not sure why this is here - perhaps to ry and handle malformed element definitions?
-            if (string.IsNullOrEmpty(element.Description))
-                return;
-            
-            if (element is DFLayoutLabel l)
-            {
-                var result = new DigitalFormLabel() { Definition = l };
-                AddViewToGrid(result, element);
-            }
-            
-            else if (element is DFLayoutImage img )
-            {
-                var result = new DigitalFormImage() { Definition = img };
-                AddViewToGrid(result, element);
-            }
-            
-            else if (element is DFLayoutHeader hdr)
-            {
-                var result = new DigitalFormHeader() { Definition = hdr };
-                result.CollapsedChanged += (sender, args) => AdjustHeaderSection(result, result.Collapsed);
-                if (hdr.Collapsed)
-                    headersToCollapse.Add(result);
-                AddViewToGrid(result, element);
-            }
-            
-            else if (element is DFLayoutBooleanField b)
-                CreateView<DigitalFormBoolean, DFLayoutBooleanField, DFLayoutBooleanFieldProperties, bool, bool?>(b);
-            
-            else if (element is DFLayoutStringField s)
+            try
             {
-                if (s.Properties.PopupEditor)
-                    CreateView<DigitalFormStringPopup, DFLayoutStringField, DFLayoutStringFieldProperties, string, string?>(s);
-                else if (s.Properties.TextWrapping)
-                    CreateView<DigitalFormStringEditor, DFLayoutStringField, DFLayoutStringFieldProperties, string, string?>(s);
-                else
-                    CreateView<DigitalFormStringEntry, DFLayoutStringField, DFLayoutStringFieldProperties, string, string?>(s);
-            }
-            
-            else if (element is DFLayoutIntegerField i)
-                CreateView<DigitalFormIntegerEntry, DFLayoutIntegerField, DFLayoutIntegerFieldProperties, int, int?>(i);  
-            
-            else if (element is DFLayoutDoubleField d)
-                CreateView<DigitalFormDoubleEntry, DFLayoutDoubleField, DFLayoutDoubleFieldProperties, double, double?>(d);
+                // Not sure why this is here - perhaps to ry and handle malformed element definitions?
+                if (string.IsNullOrEmpty(element.Description))
+                    return;
 
-            else if (element is DFLayoutDateField df)
-                CreateView<DigitalFormDateEntry, DFLayoutDateField, DFLayoutDateFieldProperties, DateTime, DateTime?>(df);
-            
-            else if (element is DFLayoutTimeField tf)
-                CreateView<DigitalFormTimeEntry, DFLayoutTimeField, DFLayoutTimeFieldProperties, TimeSpan,TimeSpan?>(tf);
-            
+                if (element is DFLayoutLabel l)
+                {
+                    var result = new DigitalFormLabel() { Definition = l };
+                    AddViewToGrid(result, element);
+                }
 
-            else if (element is DFLayoutOptionField of)
-            {
-                if (of.Properties.OptionType == DFLayoutOptionType.Radio)
-                    CreateView<DigitalFormOptionRadioList, DFLayoutOptionField, DFLayoutOptionFieldProperties, string, string?>(of);
-                else if (of.Properties.OptionType == DFLayoutOptionType.Buttons)
-                    CreateView<DigitalFormOptionButtonList, DFLayoutOptionField, DFLayoutOptionFieldProperties, string, string?>(of);
-                else
-                    CreateView<DigitalFormOptionComboBox, DFLayoutOptionField, DFLayoutOptionFieldProperties, string, string?>(of);
-            }
-            
-            else if (element is DFLayoutLookupField lf)
-            {
-                if (lf.Properties.DisplayType == DFLayoutLookupDisplayType.Combo)
-                    CreateView<DigitalFormLookupComboBox, DFLayoutLookupField, DFLayoutLookupFieldProperties, Guid, DFLayoutLookupValue>(lf);
-                else
-                    CreateView<DigitalFormLookupButton, DFLayoutLookupField, DFLayoutLookupFieldProperties, Guid, DFLayoutLookupValue>(lf);
-            }
-            
-            else if (element is DFLayoutSignaturePad sp)
-                CreateView<DigitalFormSignature, DFLayoutSignaturePad, DFLayoutSignaturePadProperties, byte[], byte[]?>(sp);
+                else if (element is DFLayoutImage img)
+                {
+                    var result = new DigitalFormImage() { Definition = img };
+                    AddViewToGrid(result, element);
+                }
 
-            else if (element is DFLayoutEmbeddedImage ei)
-                CreateView<DigitalFormEmbeddedImage, DFLayoutEmbeddedImage, DFLayoutEmbeddedImageProperties, Guid, DFLayoutEmbeddedMediaValue>(ei);
-            
-            else if (element is DFLayoutVideoField ev)
-                CreateView<DigitalFormEmbeddedVideo, DFLayoutVideoField, DFLayoutVideoFieldProperties, byte[], DFLayoutEmbeddedMediaValue>(ev);
-            
-            else if (element is DFLayoutMultiImage mi)
-                CreateView<DigitalFormMultiImage, DFLayoutMultiImage, DFLayoutMultiImageProperties, List<Guid>, DFLayoutEmbeddedMediaValues>(mi);
-            
-            else if (element is DFLayoutMultiSignaturePad ms)
-            {
-                CreateView<DigitalFormMultiSignature, DFLayoutMultiSignaturePad, DFLayoutMultiSignaturePadProperties,
-                    Dictionary<string, byte[]>, Dictionary<string, byte[]>?>(ms);
-                //var tuple = LoadMultiSignaturePad(element);
-                //AddViewToGrid(tuple.Item1, element);
+                else if (element is DFLayoutHeader hdr)
+                {
+                    var result = new DigitalFormHeader() { Definition = hdr };
+                    result.CollapsedChanged += (sender, args) => AdjustHeaderSection(result, result.Collapsed);
+                    if (hdr.Collapsed)
+                        headersToCollapse.Add(result);
+                    AddViewToGrid(result, element);
+                }
+
+                else if (element is DFLayoutBooleanField b)
+                    CreateView<DigitalFormBoolean, DFLayoutBooleanField, DFLayoutBooleanFieldProperties, bool, bool?>(
+                        b);
+
+                else if (element is DFLayoutStringField s)
+                {
+                    if (s.Properties.PopupEditor)
+                        CreateView<DigitalFormStringPopup, DFLayoutStringField, DFLayoutStringFieldProperties, string,
+                            string?>(s);
+                    else if (s.Properties.TextWrapping)
+                        CreateView<DigitalFormStringEditor, DFLayoutStringField, DFLayoutStringFieldProperties, string,
+                            string?>(s);
+                    else
+                        CreateView<DigitalFormStringEntry, DFLayoutStringField, DFLayoutStringFieldProperties, string,
+                            string?>(s);
+                }
+
+                else if (element is DFLayoutIntegerField i)
+                    CreateView<DigitalFormIntegerEntry, DFLayoutIntegerField, DFLayoutIntegerFieldProperties, int, int
+                        ?>(i);
+
+                else if (element is DFLayoutDoubleField d)
+                    CreateView<DigitalFormDoubleEntry, DFLayoutDoubleField, DFLayoutDoubleFieldProperties, double,
+                        double?>(d);
+
+                else if (element is DFLayoutDateField df)
+                    CreateView<DigitalFormDateEntry, DFLayoutDateField, DFLayoutDateFieldProperties, DateTime, DateTime
+                        ?>(df);
+
+                else if (element is DFLayoutTimeField tf)
+                    CreateView<DigitalFormTimeEntry, DFLayoutTimeField, DFLayoutTimeFieldProperties, TimeSpan, TimeSpan
+                        ?>(tf);
+
+
+                else if (element is DFLayoutOptionField of)
+                {
+                    if (of.Properties.OptionType == DFLayoutOptionType.Radio)
+                        CreateView<DigitalFormOptionRadioList, DFLayoutOptionField, DFLayoutOptionFieldProperties,
+                            string, string?>(of);
+                    else if (of.Properties.OptionType == DFLayoutOptionType.Buttons)
+                        CreateView<DigitalFormOptionButtonList, DFLayoutOptionField, DFLayoutOptionFieldProperties,
+                            string, string?>(of);
+                    else
+                        CreateView<DigitalFormOptionComboBox, DFLayoutOptionField, DFLayoutOptionFieldProperties, string
+                            , string?>(of);
+                }
+
+                else if (element is DFLayoutLookupField lf)
+                {
+                    if (lf.Properties.DisplayType == DFLayoutLookupDisplayType.Combo)
+                        CreateView<DigitalFormLookupComboBox, DFLayoutLookupField, DFLayoutLookupFieldProperties, Guid,
+                            DFLayoutLookupValue>(lf);
+                    else
+                        CreateView<DigitalFormLookupButton, DFLayoutLookupField, DFLayoutLookupFieldProperties, Guid,
+                            DFLayoutLookupValue>(lf);
+                }
+
+                else if (element is DFLayoutSignaturePad sp)
+                    CreateView<DigitalFormSignature, DFLayoutSignaturePad, DFLayoutSignaturePadProperties, byte[], byte
+                        []?>(sp);
+
+                else if (element is DFLayoutEmbeddedImage ei)
+                    CreateView<DigitalFormEmbeddedImage, DFLayoutEmbeddedImage, DFLayoutEmbeddedImageProperties, Guid,
+                        DFLayoutEmbeddedMediaValue>(ei);
+
+                else if (element is DFLayoutVideoField ev)
+                    CreateView<DigitalFormEmbeddedVideo, DFLayoutVideoField, DFLayoutVideoFieldProperties, byte[],
+                        DFLayoutEmbeddedMediaValue>(ev);
+
+                else if (element is DFLayoutMultiImage mi)
+                    CreateView<DigitalFormMultiImage, DFLayoutMultiImage, DFLayoutMultiImageProperties, List<Guid>,
+                        DFLayoutEmbeddedMediaValues>(mi);
+
+                else if (element is DFLayoutMultiSignaturePad ms)
+                {
+                    CreateView<DigitalFormMultiSignature, DFLayoutMultiSignaturePad, DFLayoutMultiSignaturePadProperties
+                        ,
+                        Dictionary<string, byte[]>, Dictionary<string, byte[]>?>(ms);
+                    //var tuple = LoadMultiSignaturePad(element);
+                    //AddViewToGrid(tuple.Item1, element);
+                }
+                else if (element is DFLayoutAddTaskField at)
+                {
+                    CreateView<DigitalFormAddTask, DFLayoutAddTaskField, DFLayoutAddTaskFieldProperties,
+                        string?, string?>(at);
+                    //var tuple = LoadAddTaskField(element);
+                    //AddViewToGrid(tuple.Item1, element);
+                }
             }
-            else if (element is DFLayoutAddTaskField at)
+            catch (Exception e)
             {
-                CreateView<DigitalFormAddTask, DFLayoutAddTaskField, DFLayoutAddTaskFieldProperties,
-                    string?, string?>(at);
-                //var tuple = LoadAddTaskField(element);
-                //AddViewToGrid(tuple.Item1, element);
+                InABox.Mobile.MobileLogging.Log(e,"LoadFormLayout");
             }
-            
+
         }
         
         private TField CreateView<TField, TDefinition, TProperties, TValue, TSerialized>(TDefinition definition)