wanghan 3 ヶ月 前
コミット
c4a0467feb

+ 31 - 23
LogForceTestApp.Modules.MainModule/ViewModels/KBWindowViewModel.cs

@@ -28,6 +28,8 @@ using System.Threading.Tasks;
 using System.Data.SqlTypes;
 using System.Threading;
 using Timer = System.Timers.Timer;
+using System.Windows.Forms;
+using Serilog;
 
 
 namespace LogoForceTestApp.Modules.MainModule.ViewModels
@@ -35,7 +37,8 @@ namespace LogoForceTestApp.Modules.MainModule.ViewModels
     public class KBWindowViewModel : BindableBase
     {
         #region
-        IRepository repository;
+        IRepository repository; 
+        private readonly ILogger _logger;
         private readonly IEventAggregator _eventAggregator;
         public ObservableCollection<HouseDto> MyHouse { get; set; }
         private readonly IMapper _mapper;
@@ -102,10 +105,11 @@ namespace LogoForceTestApp.Modules.MainModule.ViewModels
         public string Fix { get; set; }
         #endregion
 
-        public KBWindowViewModel(IRepository repository, IEventAggregator eventAggregator, IMapper mapper)
+        public KBWindowViewModel(IRepository repository, IEventAggregator eventAggregator, IMapper mapper, ILogger logger)
         {
             this.repository = repository;
             this._eventAggregator = eventAggregator;
+            _logger = logger;
             Series = new List<ISeries>();
             #region timer
             _timer = new Timer();
@@ -161,7 +165,7 @@ namespace LogoForceTestApp.Modules.MainModule.ViewModels
                 }
                 catch (ObjectDisposedException ex)
                 {
-
+                    _logger.Information("KB_Main:" + ex);
                 }
                 finally
                 {
@@ -226,7 +230,7 @@ namespace LogoForceTestApp.Modules.MainModule.ViewModels
             }
             catch (Exception ex)
             {
-
+                _logger.Information("KB_ShowOutWork:" + ex);
             }
         }
         public IEnumerable<ISeries> Series12 { get; set; }
@@ -336,9 +340,9 @@ namespace LogoForceTestApp.Modules.MainModule.ViewModels
                     SerQuality3(qua3);
                 }
             }
-            catch (Exception)
+            catch (Exception ex)
             {
-
+                _logger.Information("KB_ShowQuality:" + ex);
             }
         }
         #region 生产问题
@@ -573,10 +577,22 @@ namespace LogoForceTestApp.Modules.MainModule.ViewModels
                 if (list != null)
                 {
                     var dto = _mapper.Map<HouseDto>(list);
-                    Application.Current.Dispatcher.Invoke(new Action(() =>
+                    System.Windows.Application.Current.Dispatcher.Invoke(new Action(() =>
                     {
                         MyHouse.Clear();
                         MyHouse.Add(dto);
+                        if (list.LackH==null)
+                        {
+                            list.LackH = "0";
+                        }
+                        if (list.UsedH == null)
+                        {
+                            list.UsedH = "0";
+                        }
+                        if (list.TotalH == null)
+                        {
+                            list.TotalH = "0";
+                        }
                         SerHouse(double.Parse(list.LackH), double.Parse(list.UsedH), double.Parse(list.TotalH));
                     }));
 
@@ -585,7 +601,7 @@ namespace LogoForceTestApp.Modules.MainModule.ViewModels
             }
             catch (Exception ex)
             {
-
+                _logger.Information("KB_ShowHouse:" + ex);
             }
         }
         public IEnumerable<ISeries> Series13 { get; set; }
@@ -926,9 +942,9 @@ namespace LogoForceTestApp.Modules.MainModule.ViewModels
 
                 SerLine(listval1, listval2, xlabel);
             }
-            catch (Exception)
+            catch (Exception ex)
             {
-
+                _logger.Information("KB_ShowProcess:" + ex);
             }
         }
 
@@ -1030,24 +1046,16 @@ namespace LogoForceTestApp.Modules.MainModule.ViewModels
                     BillNo = str;
                     AuxQty = (double)list.FAuxQty;
                 }
-            }
-            catch (Exception ex)
-            {
-
-            }
-            try
-            {
-                var ps = repository.GetFirstDefault<ProStatus>(c => c.OrdNoS==str);
+                var ps = repository.GetFirstDefault<ProStatus>(c => c.OrdNoS == str);
                 if (ps != null)
                 {
                     Finished = ps.RealityS;
                 }
             }
-            catch (Exception)
+            catch (Exception ex)
             {
-
+                _logger.Information("KB_ShowOrder:"+ex);
             }
-
         }
         #endregion
 
@@ -1068,9 +1076,9 @@ namespace LogoForceTestApp.Modules.MainModule.ViewModels
                     PassNum = allnumbers.OkA;
                 }
             }
-            catch (Exception)
+            catch (Exception ex)
             {
-
+                _logger.Information("KB_ShowNowProcess:" + ex);
             }
         }
         #endregion