瀏覽代碼

Merge branch 'master' of https://git.dev.tencent.com/xuhuo1234/saga

xulisong 6 年之前
父節點
當前提交
bb6798b9ab
共有 40 個文件被更改,包括 2150 次插入979 次删除
  1. 49 27
      MBI/FirmLib/Com.FirmLib.UI/Insuer/VmInsuerBaseInfo.cs
  2. 64 42
      MBI/FirmLib/Com.FirmLib.UI/Insuer/VmInsuerInfo.cs
  3. 151 113
      MBI/FirmLib/Com.FirmLib.UI/Insuer/VmInsuerProjectInfo.cs
  4. 92 60
      MBI/FirmLib/Com.FirmLib.UI/Insuer/VmInsurancePolicyEditor.cs
  5. 24 8
      MBI/FirmLib/Com.FirmLib.UI/Insuer/VmPolicySelector.cs
  6. 16 8
      MBI/FirmLib/Com.FirmLib.UI/Insuer/VmSimplePolicyEditor.cs
  7. 14 6
      MBI/FirmLib/Com.FirmLib.UI/Maintainer/VmAddLossProductType.cs
  8. 16 8
      MBI/FirmLib/Com.FirmLib.UI/Maintainer/VmMaintainerAssetSelector.cs
  9. 52 28
      MBI/FirmLib/Com.FirmLib.UI/Maintainer/VmMaintainerBaseInfo.cs
  10. 27 11
      MBI/FirmLib/Com.FirmLib.UI/Maintainer/VmMaintainerEditor.cs
  11. 144 88
      MBI/FirmLib/Com.FirmLib.UI/Maintainer/VmMaintainerInfo.cs
  12. 85 53
      MBI/FirmLib/Com.FirmLib.UI/Maintainer/VmMaintainerProjectAsset.cs
  13. 106 66
      MBI/FirmLib/Com.FirmLib.UI/Maintainer/VmManitainerProjectInfo.cs
  14. 66 34
      MBI/FirmLib/Com.FirmLib.UI/Manufacturer/VmBrandEditor.cs
  15. 66 35
      MBI/FirmLib/Com.FirmLib.UI/Manufacturer/VmManufactureBaseInfo.cs
  16. 194 130
      MBI/FirmLib/Com.FirmLib.UI/Manufacturer/VmManufactureInfo.cs
  17. 29 13
      MBI/FirmLib/Com.FirmLib.UI/Manufacturer/VmManufacturerEditor.cs
  18. 32 16
      MBI/FirmLib/Com.FirmLib.UI/Manufacturer/VmProductEditor.cs
  19. 14 6
      MBI/FirmLib/Com.FirmLib.UI/Manufacturer/VmProductType.cs
  20. 18 10
      MBI/FirmLib/Com.FirmLib.UI/Manufacturer/VmProjectAssetList.cs
  21. 9 1
      MBI/FirmLib/Com.FirmLib.UI/Manufacturer/WinProductEditor.xaml
  22. 14 6
      MBI/FirmLib/Com.FirmLib.UI/Seller/VmAddLossProductType.cs
  23. 10 1
      MBI/FirmLib/Com.FirmLib.UI/Seller/VmMultiProductTypeSelector.cs
  24. 54 30
      MBI/FirmLib/Com.FirmLib.UI/Seller/VmSellerBaseInfo.cs
  25. 27 11
      MBI/FirmLib/Com.FirmLib.UI/Seller/VmSellerEditor.cs
  26. 99 59
      MBI/FirmLib/Com.FirmLib.UI/Seller/VmSellerInfo.cs
  27. 102 62
      MBI/FirmLib/Com.FirmLib.UI/Seller/VmSellerProjectContract.cs
  28. 69 37
      MBI/FirmLib/Com.FirmLib.UI/Seller/VmSellerProjectInfo.cs
  29. 12 4
      MBI/FirmLib/Com.FirmLib.UI/Seller/VmSupplyContractNoSelector.cs
  30. 18 0
      MBI/MBIResource/Config/HttpSetting - 亚心.ini
  31. 1 1
      MBI/MBIResource/Config/HttpSetting - 亚投行.ini
  32. 1 0
      MBI/MBIResource/Config/MBI.config
  33. 53 2
      MBI/SAGA.DotNetUtils/Extend/ConfigurationUtil.cs
  34. 6 0
      MBI/SAGA.DotNetUtils/Utilities/CommonUtil.cs
  35. 1 1
      MBI/SAGA.GplotDrawData/View/WinMachineRoom.xaml.cs
  36. 1 1
      MBI/SAGA.MBI/App.xaml.cs
  37. 157 0
      MBI/SAGA.MBI/RequestData/FileContentTransferUnit.cs
  38. 27 1
      MBI/SAGA.MBI/RequestData/UpLoadFileRequest.cs
  39. 2 0
      MBI/SAGA.MBI/SAGA.MBI.csproj
  40. 228 0
      MBI/SAGA.MBI/Utilities/FileContent.cs

+ 49 - 27
MBI/FirmLib/Com.FirmLib.UI/Insuer/VmInsuerBaseInfo.cs

@@ -76,22 +76,30 @@ namespace Com.FirmLib.UI.Insuer
         [Command]
         public void AddCommand(object parameter)
         {
-            WinInsuerEditor win = new WinInsuerEditor();
-            win.Owner = this.GetWindow();
-            if (win.ShowDialog() == true)
+            try
             {
-                if (win.IsManage)
+                WinInsuerEditor win = new WinInsuerEditor();
+                win.Owner = this.GetWindow();
+                if (win.ShowDialog() == true)
                 {
-                    WinInsuerInfo winInsuerInfo = new WinInsuerInfo();
-                    LoadParameter.StartParameter(winInsuerInfo, new LoadParameter(win.NewId));
-                    winInsuerInfo.Show(this.GetNavigationBar());
-                }
-                else
-                {
-                    //todo 刷新界面
-                    LoadItems();
+                    if (win.IsManage)
+                    {
+                        WinInsuerInfo winInsuerInfo = new WinInsuerInfo();
+                        LoadParameter.StartParameter(winInsuerInfo, new LoadParameter(win.NewId));
+                        winInsuerInfo.Show(this.GetNavigationBar());
+                    }
+                    else
+                    {
+                        //todo 刷新界面
+                        LoadItems();
+                    }
                 }
             }
+            catch (Exception ex)
+            {
+
+                MessageTipEx.Show(ex);
+            }
         }
         public bool CanAddCommand(object parameter)
         {
@@ -105,18 +113,25 @@ namespace Com.FirmLib.UI.Insuer
         [Command]
         public void DeleteCommand(object parameter)
         {
-            var item = parameter as InsuerShowItem;
-            if (item == null)
-                return;
-            var result = MessageTip.Show(this.GetWindow(),"是否要删除", "提示", MessageBoxButton.YesNo);       
-            if (result == MessageBoxResult.Yes)
+            try
             {
-                //todo 网络api处理
-                DeleteItem(item.Id);
-                //todo 刷新窗体
-                LoadItems();
-                //todo 删除操作
-                //Sellers.Remove(item);
+                var item = parameter as InsuerShowItem;
+                if (item == null)
+                    return;
+                var result = MessageTip.Show(this.GetWindow(), "是否要删除", "提示", MessageBoxButton.YesNo);
+                if (result == MessageBoxResult.Yes)
+                {
+                    //todo 网络api处理
+                    DeleteItem(item.Id);
+                    //todo 刷新窗体
+                    LoadItems();
+                    //todo 删除操作
+                    //Sellers.Remove(item);
+                }
+            }
+            catch (Exception ex)
+            {
+                MessageTipEx.Show(ex);
             }
         }
         public bool CanDeleteCommand(object parameter)
@@ -131,10 +146,17 @@ namespace Com.FirmLib.UI.Insuer
         [Command]
         public void ManageCommand(object parameter)
         {
-            var item = parameter as InsuerShowItem;
-            WinInsuerInfo win = new WinInsuerInfo();
-            LoadParameter.StartParameter(win, new LoadParameter(item.Id));
-            win.Show(this.GetNavigationBar());
+            try
+            {
+                var item = parameter as InsuerShowItem;
+                WinInsuerInfo win = new WinInsuerInfo();
+                LoadParameter.StartParameter(win, new LoadParameter(item.Id));
+                win.Show(this.GetNavigationBar());
+            }
+            catch (Exception ex)
+            {
+                MessageTipEx.Show(ex);
+            }
         }
         public bool CanManageCommand(object parameter)
         {

+ 64 - 42
MBI/FirmLib/Com.FirmLib.UI/Insuer/VmInsuerInfo.cs

@@ -107,11 +107,19 @@ namespace Com.FirmLib.UI.Insuer
         [Command]
         public void AddInsuracncePolicy(object parameter)
         {
-            WinInsurancePolicyEditor win = new WinInsurancePolicyEditor();
-            var f = new InsuerParameter();
-            f.Insuer.Id = Id;
-            LoadParameter.StartParameter(win, new LoadParameter(f));
-            win.Show(this.GetNavigationBar());
+            try
+            {
+                WinInsurancePolicyEditor win = new WinInsurancePolicyEditor();
+                var f = new InsuerParameter();
+                f.Insuer.Id = Id;
+                LoadParameter.StartParameter(win, new LoadParameter(f));
+                win.Show(this.GetNavigationBar());
+            }
+            catch (Exception ex)
+            {
+
+                MessageTipEx.Show(ex);
+            }
         }
         public bool CanAddInsuracncePolicy(object parameter)
         {
@@ -125,15 +133,22 @@ namespace Com.FirmLib.UI.Insuer
         [Command]
         public void GoToProject(object parameter)
         {
-            ProjectRelationShowItem showItem = parameter as ProjectRelationShowItem;
-            var pa = new InsuerParameter();
-            pa.Insuer.Id = Id;
-            pa.Project.Id = showItem.ProjectId;
-            pa.Project.Name = showItem.ProjectLocalName; 
-            LoadParameter loadParameter= new LoadParameter(pa);        
-            WinInsuerProjectInfo win = new WinInsuerProjectInfo();
-            LoadParameter.StartParameter(win,loadParameter);
-            win.Show(this.GetNavigationBar());
+            try
+            {
+                ProjectRelationShowItem showItem = parameter as ProjectRelationShowItem;
+                var pa = new InsuerParameter();
+                pa.Insuer.Id = Id;
+                pa.Project.Id = showItem.ProjectId;
+                pa.Project.Name = showItem.ProjectLocalName;
+                LoadParameter loadParameter = new LoadParameter(pa);
+                WinInsuerProjectInfo win = new WinInsuerProjectInfo();
+                LoadParameter.StartParameter(win, loadParameter);
+                win.Show(this.GetNavigationBar());
+            }
+            catch (Exception ex)
+            {
+                MessageTipEx.Show(ex);
+            }
         }
         public bool CanGoToProject(object parameter)
         {
@@ -161,44 +176,51 @@ namespace Com.FirmLib.UI.Insuer
         [Command]
         public void RefreshCommand(object parameter)
         {
-            var item = parameter as ProjectRelationShowItem;
-            if (item != null)
+            try
             {
-                item.IsLoading = true;
-                TaskUtil.StartSTATask((obj) =>
-              {
-                  var useItem = obj as ProjectRelationShowItem;
-                  if (useItem == null)
-                      return;
-                  try
+                var item = parameter as ProjectRelationShowItem;
+                if (item != null)
+                {
+                    item.IsLoading = true;
+                    TaskUtil.StartSTATask((obj) =>
                   {
-                      BllFactory<ProjectBll>.Instance.ProjectSync(useItem.ProjectId);
-                      Thread.Sleep(3000);//立即执行偶尔导致连接取消
-                      var projects = BllFactory<InsuerBll>.Instance.GetProjectItems(Id);
-                      foreach (var project in projects)
+                      var useItem = obj as ProjectRelationShowItem;
+                      if (useItem == null)
+                          return;
+                      try
                       {
-                          if (project.Id == useItem.ProjectId)
+                          BllFactory<ProjectBll>.Instance.ProjectSync(useItem.ProjectId);
+                          Thread.Sleep(3000);//立即执行偶尔导致连接取消
+                         var projects = BllFactory<InsuerBll>.Instance.GetProjectItems(Id);
+                          foreach (var project in projects)
                           {
-                              useItem.AssetCount = (int)project.TotalCount.ToDouble();
-                              useItem.InsurancePolicyCount = (int)project.ContractCount.ToDouble();
-                          }
+                              if (project.Id == useItem.ProjectId)
+                              {
+                                  useItem.AssetCount = (int)project.TotalCount.ToDouble();
+                                  useItem.InsurancePolicyCount = (int)project.ContractCount.ToDouble();
+                              }
 
+                          }
+                      }
+                      catch (Exception ex)
+                      {
+                          MessageTipEx.Show(ex);
                       }
-                  }
-                  catch (Exception ex)
-                  {
-                      MessageTipEx.Show(ex);
-                  }
 
-                  finally
-                  {
+                      finally
+                      {
 
-                      useItem.IsLoading = false;
-                  }
-              }, item);
+                          useItem.IsLoading = false;
+                      }
+                  }, item);
 
-            }
+                }
 
+            }
+            catch (Exception ex)
+            {
+                MessageTipEx.Show(ex);
+            }
 
         }
         public bool CanRefreshCommand(object parameter)

+ 151 - 113
MBI/FirmLib/Com.FirmLib.UI/Insuer/VmInsuerProjectInfo.cs

@@ -154,15 +154,23 @@ namespace Com.FirmLib.UI.Insuer
         [Command]
         public void ScanAsset(object parameter)
         {
-            AssetShowItem item = parameter as AssetShowItem;
-            if (item == null)
-                return;
-            AssetItem parItem = new AssetItem();
-            parItem.Id = item.AssetNo;
-            parItem.ProjectId = item.ProjectId;
-            parItem.FamilyCode = item.FamilyCode;
-            string url = BllFactory<AssetBll>.Instance.GetAssetUrl(parItem);
-            WinBrowser.Instance.Show(url, "资产信息");
+
+            try
+            {
+                AssetShowItem item = parameter as AssetShowItem;
+                if (item == null)
+                    return;
+                AssetItem parItem = new AssetItem();
+                parItem.Id = item.AssetNo;
+                parItem.ProjectId = item.ProjectId;
+                parItem.FamilyCode = item.FamilyCode;
+                string url = BllFactory<AssetBll>.Instance.GetAssetUrl(parItem);
+                WinBrowser.Instance.Show(url, "资产信息");
+            }
+            catch (Exception ex)
+            {
+                MessageTipEx.Show(ex);
+            }
         }
         public bool CanScanAsset(object parameter)
         {
@@ -175,14 +183,22 @@ namespace Com.FirmLib.UI.Insuer
         [Command]
         public void EditPolicy(object parameter)
         {
-            PolicyShowItem item = parameter as PolicyShowItem;
-            WinInsurancePolicyEditor win = new WinInsurancePolicyEditor();
-            var f = new InsuerParameter();
-            f.Insuer.Id = item.InsuerId; 
-            f.Project.Id = item.ProjectId;
-            f.Policy.Id = item.PolicyNo;//传递表单编号
-            LoadParameter.StartParameter(win, new LoadParameter(f));
-            win.Show(this.GetNavigationBar());
+
+            try
+            {
+                PolicyShowItem item = parameter as PolicyShowItem;
+                WinInsurancePolicyEditor win = new WinInsurancePolicyEditor();
+                var f = new InsuerParameter();
+                f.Insuer.Id = item.InsuerId;
+                f.Project.Id = item.ProjectId;
+                f.Policy.Id = item.PolicyNo;//传递表单编号
+                LoadParameter.StartParameter(win, new LoadParameter(f));
+                win.Show(this.GetNavigationBar());
+            }
+            catch (Exception ex)
+            {
+                MessageTipEx.Show(ex);
+            }
         }
         public bool CanEditPolicy(object parameter)
         {
@@ -195,12 +211,20 @@ namespace Com.FirmLib.UI.Insuer
         [Command]
         public void AddInsuracncePolicy(object parameter)
         {
-            WinInsurancePolicyEditor win = new WinInsurancePolicyEditor();
-            var f = new InsuerParameter();
-            f.Project.Id = ProjectId;
-            f.Insuer.Id = InsuerId;
-            LoadParameter.StartParameter(win, new LoadParameter(f));
-            win.Show(this.GetNavigationBar());
+
+            try
+            {
+                WinInsurancePolicyEditor win = new WinInsurancePolicyEditor();
+                var f = new InsuerParameter();
+                f.Project.Id = ProjectId;
+                f.Insuer.Id = InsuerId;
+                LoadParameter.StartParameter(win, new LoadParameter(f));
+                win.Show(this.GetNavigationBar());
+            }
+            catch (Exception ex)
+            {
+                MessageTipEx.Show(ex);
+            }
         }
         public bool CanAddInsuracncePolicy(object parameter)
         {
@@ -213,14 +237,22 @@ namespace Com.FirmLib.UI.Insuer
         [Command]
         public void SaveCommand(object parameter)
         {
-            if (CreatePolicyAsset())
+
+            try
             {
-                AfterSuccessSave();
-                MessageTip.Show(this.GetWindow(), "保存成功");
+                if (CreatePolicyAsset())
+                {
+                    AfterSuccessSave();
+                    MessageTip.Show(this.GetWindow(), "保存成功");
+                }
+                else
+                {
+                    MessageTip.Show(this.GetWindow(), "保存失败");
+                }
             }
-            else
+            catch (Exception ex)
             {
-                MessageTip.Show(this.GetWindow(), "保存失败");
+                MessageTipEx.Show(ex);
             }
            
         }
@@ -287,73 +319,74 @@ namespace Com.FirmLib.UI.Insuer
         [Command]
         public void EditPolicyNoCommand(object parameter)
         {
-            AssetShowItem item = parameter as AssetShowItem;
-            if (item == null)
-                return;
-            item.CacheParameters.Clear();
-            string originPolicyNo = item.InsurancePolicyNo;
-            #region 初始化传入参数
-            PolicyUpdateContext context = new PolicyUpdateContext();
-            context.InsuerParameter.Policy.Id = item.InsurancePolicyNo;
-            context.InsuerParameter.Project.Id = item.ProjectId;
-            context.InsuerParameter.Insuer.Id = InsuerId;
-            context.PolicyNo = item.InsurancePolicyNo; 
-            #endregion
-            #region 保单编辑节点
-            WizardState wizardState = new WizardState("Root");
-            wizardState.SetHandle((obj) =>
+
+            try
             {
-                WinSimplePolicyEditor win = new WinSimplePolicyEditor();
-                win.Owner = this.GetWindow();
-                LoadParameter.StartParameter(win, new LoadParameter(obj));
-                if (win.ShowDialog() == true)
+                AssetShowItem item = parameter as AssetShowItem;
+                if (item == null)
+                    return;
+                item.CacheParameters.Clear();
+                string originPolicyNo = item.InsurancePolicyNo;
+                #region 初始化传入参数
+                PolicyUpdateContext context = new PolicyUpdateContext();
+                context.InsuerParameter.Policy.Id = item.InsurancePolicyNo;
+                context.InsuerParameter.Project.Id = item.ProjectId;
+                context.InsuerParameter.Insuer.Id = InsuerId;
+                context.PolicyNo = item.InsurancePolicyNo;
+                #endregion
+                #region 保单编辑节点
+                WizardState wizardState = new WizardState("Root");
+                wizardState.SetHandle((obj) =>
                 {
-                    var tempContext = win.GetRealResult<PolicyUpdateContext>();
-                    if (string.IsNullOrEmpty(originPolicyNo)||tempContext.PolicyNo == originPolicyNo)
+                    WinSimplePolicyEditor win = new WinSimplePolicyEditor();
+                    win.Owner = this.GetWindow();
+                    LoadParameter.StartParameter(win, new LoadParameter(obj));
+                    if (win.ShowDialog() == true)
                     {
+                        var tempContext = win.GetRealResult<PolicyUpdateContext>();
+                        if (string.IsNullOrEmpty(originPolicyNo) || tempContext.PolicyNo == originPolicyNo)
+                        {
                         //如果原始单号为null,获取与新单号相同,则直接完成修改
                         tempContext.CanExecute = false;
-                        return WizardState.CompletedState;
+                            return WizardState.CompletedState;
+                        }
+                        else
+                        {
+                            return WizardState.NextState;
+                        }
                     }
                     else
                     {
-                        return WizardState.NextState;
+                        (obj as PolicyUpdateContext).CanExecute = false;
+                        return WizardState.CancelState;
                     }
-                }
-                else
-                {
-                    (obj as PolicyUpdateContext).CanExecute = false;
-                    return WizardState.CancelState;
-                }
-            });
-            #endregion
+                });
+                #endregion
 
-            #region 确认修改时间节点
-            WizardState ensureState = new WizardState("Ensure");
-            ensureState.SetHandle((obj) =>
-            {
-                WinPolicyEnsure win = new WinPolicyEnsure();
-                win.Owner = this.GetWindow();
-                LoadParameter.StartParameter(win, new LoadParameter(obj));
-                if (win.ShowDialog() == true)
-                {
-                    var tempContext = win.GetRealResult<PolicyUpdateContext>();
-                    tempContext.CanExecute = true;
-                    return WizardState.CompletedState;                
-                }
-                else
+                #region 确认修改时间节点
+                WizardState ensureState = new WizardState("Ensure");
+                ensureState.SetHandle((obj) =>
                 {
-                    (obj as PolicyUpdateContext).CanExecute = false;
-                    return WizardState.CancelState;
-                }
-            });
-            #endregion
-            wizardState.AddState(WizardState.NextState, ensureState);
-            wizardState.Execute(context);
-            //不增加完成节点,直接通过context的CanExecute判断是否执行修改
-            if (UpdateAssetPolicyNo(item, context))
-            {
-                try
+                    WinPolicyEnsure win = new WinPolicyEnsure();
+                    win.Owner = this.GetWindow();
+                    LoadParameter.StartParameter(win, new LoadParameter(obj));
+                    if (win.ShowDialog() == true)
+                    {
+                        var tempContext = win.GetRealResult<PolicyUpdateContext>();
+                        tempContext.CanExecute = true;
+                        return WizardState.CompletedState;
+                    }
+                    else
+                    {
+                        (obj as PolicyUpdateContext).CanExecute = false;
+                        return WizardState.CancelState;
+                    }
+                });
+                #endregion
+                wizardState.AddState(WizardState.NextState, ensureState);
+                wizardState.Execute(context);
+                //不增加完成节点,直接通过context的CanExecute判断是否执行修改
+                if (UpdateAssetPolicyNo(item, context))
                 {
                     item.InsurancePolicyNo = context.PolicyNo;
                     item.EndDate = DateTimeManager.ConvertDateTime(context.ExpiryDate).ToString("yyyy-MM-dd");
@@ -361,11 +394,10 @@ namespace Com.FirmLib.UI.Insuer
                     var items = CollectionViewSource.GetDefaultView(this.AssetItems);
                     items.Refresh();
                 }
-                catch (Exception ex)
-                {
-
-                    Debug.Write(ex.StackTrace);
-                }
+            }
+            catch (Exception ex)
+            {
+                MessageTipEx.Show(ex);
             }
         }
         public bool CanEditPolicyNoCommand(object parameter)
@@ -381,31 +413,39 @@ namespace Com.FirmLib.UI.Insuer
         [Command]
         public void DeleteAssetPolicy(object parameter)
         {
-            AssetShowItem showItem = parameter as AssetShowItem;
-            if (showItem == null)
-                return;
-            //todo 删除资产关联关系,是直接删除,不需要保存确定
-            var result = MessageTip.Show(this.GetWindow(), "是否要删除", "提示", MessageBoxButton.YesNo);
-            if (result == MessageBoxResult.Yes)
+
+            try
             {
-                bool flag = false;
-                if (showItem.InsuerId == InsuerId)
+                AssetShowItem showItem = parameter as AssetShowItem;
+                if (showItem == null)
+                    return;
+                //todo 删除资产关联关系,是直接删除,不需要保存确定
+                var result = MessageTip.Show(this.GetWindow(), "是否要删除", "提示", MessageBoxButton.YesNo);
+                if (result == MessageBoxResult.Yes)
                 {
-                    flag = AssetManager.DeleteInsuerAssets(ProjectId, new List<string>() { showItem.Id });
-                }
-                else
-                {
-                    flag = true;
-                }
-                if (flag)
-                {
-                    this.AssetItems.Remove(showItem);
-                }
-                else
-                {
-                    MessageTip.Show(this.GetWindow(), "删除失败");
-                }
+                    bool flag = false;
+                    if (showItem.InsuerId == InsuerId)
+                    {
+                        flag = AssetManager.DeleteInsuerAssets(ProjectId, new List<string>() { showItem.Id });
+                    }
+                    else
+                    {
+                        flag = true;
+                    }
+                    if (flag)
+                    {
+                        this.AssetItems.Remove(showItem);
+                    }
+                    else
+                    {
+                        MessageTip.Show(this.GetWindow(), "删除失败");
+                    }
 
+                }
+            }
+            catch (Exception ex)
+            {
+                MessageTipEx.Show(ex);
             }
         }
         public bool CanDeleteAssetPolicy(object parameter)
@@ -438,8 +478,6 @@ namespace Com.FirmLib.UI.Insuer
                         fileKey = policyItem.PolicyFile;
                          break;
                     }
-
-
                 } while (false);
              
                 InsuerUtils.LoadPolicyFile(fileKey);

+ 92 - 60
MBI/FirmLib/Com.FirmLib.UI/Insuer/VmInsurancePolicyEditor.cs

@@ -300,15 +300,23 @@ namespace Com.FirmLib.UI.Insuer
         [Command]
         public void ScanAsset(object parameter)
         {
-            AssetShowItem item = parameter as AssetShowItem;
-            if (item == null)
-                return;
-            AssetItem parItem = new AssetItem();
-            parItem.Id = item.Id;
-            parItem.ProjectId = item.ProjectId;
-            parItem.FamilyCode = item.FamilyCode;
-            string url = BllFactory<AssetBll>.Instance.GetAssetUrl(parItem);
-            WinBrowser.Instance.Show(url, "资产信息");
+
+            try
+            {
+                AssetShowItem item = parameter as AssetShowItem;
+                if (item == null)
+                    return;
+                AssetItem parItem = new AssetItem();
+                parItem.Id = item.Id;
+                parItem.ProjectId = item.ProjectId;
+                parItem.FamilyCode = item.FamilyCode;
+                string url = BllFactory<AssetBll>.Instance.GetAssetUrl(parItem);
+                WinBrowser.Instance.Show(url, "资产信息");
+            }
+            catch (Exception ex)
+            {
+                MessageTipEx.Show(ex);
+            }
         }
         public bool CanScanAsset(object parameter)
         {
@@ -355,21 +363,29 @@ namespace Com.FirmLib.UI.Insuer
         {
             //传入当前输入的保单号,为显示默认值
             //如果项目为空,可以不弹窗
-            WinPolicySelector win = new WinPolicySelector();
-            InsuerParameter insuerParameter = new InsuerParameter();
-            insuerParameter.Insuer.Id = InsuerId;
-            insuerParameter.Project.Id =SystemProjectId;
-            insuerParameter.Policy.Id = PolicyNo;
-            LoadParameter.StartParameter(win, new LoadParameter(insuerParameter));
-            win.Owner = this.GetWindow();
-            if (win.ShowDialog() == true)
-            {
-                var tempPolicyNo = win.GetRealResult<string>();
-                if (!string.IsNullOrEmpty(tempPolicyNo))
+
+            try
+            {
+                WinPolicySelector win = new WinPolicySelector();
+                InsuerParameter insuerParameter = new InsuerParameter();
+                insuerParameter.Insuer.Id = InsuerId;
+                insuerParameter.Project.Id = SystemProjectId;
+                insuerParameter.Policy.Id = PolicyNo;
+                LoadParameter.StartParameter(win, new LoadParameter(insuerParameter));
+                win.Owner = this.GetWindow();
+                if (win.ShowDialog() == true)
                 {
-                    this.PolicyNo = tempPolicyNo;
+                    var tempPolicyNo = win.GetRealResult<string>();
+                    if (!string.IsNullOrEmpty(tempPolicyNo))
+                    {
+                        this.PolicyNo = tempPolicyNo;
+                    }
                 }
             }
+            catch (Exception ex)
+            {
+                MessageTipEx.Show(ex);
+            }
         }
         public bool CanSelectPolicyCommand(object parameter)
         {
@@ -382,28 +398,36 @@ namespace Com.FirmLib.UI.Insuer
         [Command]
         public void SelectAssetCommand(object parameter)
         {
-            WinInsuerAssetSelector win = new WinInsuerAssetSelector();
-            win.Owner = this.GetWindow();
-            SelectAssetContext context = new SelectAssetContext();
-            context.ProjectId = SystemProjectId;
-            context.VenderId = InsuerId;
 
-            context.ContainIds = new List<string>(AssetItems.Select(p => p.Id));
-            LoadParameter.StartParameter(win, new LoadParameter(context));
-            if (win.ShowDialog() == true)
+            try
             {
-                if (AssetItems == null)
-                {
-                    AssetItems = new ObservableCollection<AssetShowItem>();
-                }
-                var addRelations = context.AddedItems;
-                foreach (var item in addRelations)
+                WinInsuerAssetSelector win = new WinInsuerAssetSelector();
+                win.Owner = this.GetWindow();
+                SelectAssetContext context = new SelectAssetContext();
+                context.ProjectId = SystemProjectId;
+                context.VenderId = InsuerId;
+
+                context.ContainIds = new List<string>(AssetItems.Select(p => p.Id));
+                LoadParameter.StartParameter(win, new LoadParameter(context));
+                if (win.ShowDialog() == true)
                 {
-                    if (AssetItems.Any(c => c.Id == item.Id))
-                        return;
-                    AssetItems.Add(item);
+                    if (AssetItems == null)
+                    {
+                        AssetItems = new ObservableCollection<AssetShowItem>();
+                    }
+                    var addRelations = context.AddedItems;
+                    foreach (var item in addRelations)
+                    {
+                        if (AssetItems.Any(c => c.Id == item.Id))
+                            return;
+                        AssetItems.Add(item);
+                    }
                 }
             }
+            catch (Exception ex)
+            {
+                MessageTipEx.Show(ex);
+            }
         }
         public bool CanSelectAssetCommand(object parameter)
         {
@@ -416,31 +440,39 @@ namespace Com.FirmLib.UI.Insuer
         [Command]
         public void DeleteCommand(object parameter)
         {
-            AssetShowItem showItem = parameter as AssetShowItem;
-            if (showItem == null)
-                return;
-            //todo 删除资产关联关系,是直接删除,不需要保存确定
-            var result = MessageTip.Show(this.GetWindow(), "是否要删除", "提示", MessageBoxButton.YesNo);
-            if (result == MessageBoxResult.Yes)
+
+            try
             {
-                bool flag = false;
-                if (showItem.InsuerId == InsuerId&&showItem.InsurancePolicyNo==PolicyNo)
-                {
-                    flag = AssetManager.DeleteInsuerAssets(SystemProjectId, new List<string>() { showItem.Id });
-                }
-                else
-                {
-                    flag = true;
-                }
-                if (flag)
-                {
-                     this.AssetItems.Remove(showItem);
-                }
-                else
+                AssetShowItem showItem = parameter as AssetShowItem;
+                if (showItem == null)
+                    return;
+                //todo 删除资产关联关系,是直接删除,不需要保存确定
+                var result = MessageTip.Show(this.GetWindow(), "是否要删除", "提示", MessageBoxButton.YesNo);
+                if (result == MessageBoxResult.Yes)
                 {
-                     MessageTip.Show(this.GetWindow(), "删除失败");
+                    bool flag = false;
+                    if (showItem.InsuerId == InsuerId && showItem.InsurancePolicyNo == PolicyNo)
+                    {
+                        flag = AssetManager.DeleteInsuerAssets(SystemProjectId, new List<string>() { showItem.Id });
+                    }
+                    else
+                    {
+                        flag = true;
+                    }
+                    if (flag)
+                    {
+                        this.AssetItems.Remove(showItem);
+                    }
+                    else
+                    {
+                        MessageTip.Show(this.GetWindow(), "删除失败");
+                    }
+
                 }
-               
+            }
+            catch (Exception ex)
+            {
+                MessageTipEx.Show(ex);
             }
         }
         public bool CanDeleteCommand(object parameter)

+ 24 - 8
MBI/FirmLib/Com.FirmLib.UI/Insuer/VmPolicySelector.cs

@@ -91,12 +91,20 @@ namespace Com.FirmLib.UI.Insuer
         [Command]
         public void EnsureCommand(object parameter)
         {
-            Window window = parameter as Window;
-            if (window != null)
+
+            try
+            {
+                Window window = parameter as Window;
+                if (window != null)
+                {
+                    window.SetRealResult(m_CurrentPolicyItem.PolicyNo);
+                    window.DialogResult = true;
+
+                }
+            }
+            catch (Exception ex)
             {
-                window.SetRealResult(m_CurrentPolicyItem.PolicyNo);
-                window.DialogResult = true;
-                
+                MessageTipEx.Show(ex);
             }
         }
         public bool CanEnsureCommand(object parameter)
@@ -110,10 +118,18 @@ namespace Com.FirmLib.UI.Insuer
         [Command]
         public void SelectCommand(object parameter)
         {
-            PolicyShowItem item = parameter as PolicyShowItem;
-            if (item != null)
+
+            try
+            {
+                PolicyShowItem item = parameter as PolicyShowItem;
+                if (item != null)
+                {
+                    this.CurrentPolicyItem = item;
+                }
+            }
+            catch (Exception ex)
             {
-                this.CurrentPolicyItem = item;
+                MessageTipEx.Show(ex);
             }
         }
         public bool CanSelectCommand(object parameter)

+ 16 - 8
MBI/FirmLib/Com.FirmLib.UI/Insuer/VmSimplePolicyEditor.cs

@@ -154,18 +154,26 @@ namespace Com.FirmLib.UI.Insuer
         [Command]
         public void SelectPolicyCommand(object parameter)
         {
-            //传入当前输入的保单号,为显示默认值
-            WinPolicySelector win = new WinPolicySelector();
-            LoadParameter.StartParameter(win, new LoadParameter(Context.InsuerParameter));
-            win.Owner = this.GetWindow();
-            if (win.ShowDialog() == true)
+
+            try
             {
-                var tempPolicyNo = win.GetRealResult<string>();
-                if (!string.IsNullOrEmpty(tempPolicyNo))
+                //传入当前输入的保单号,为显示默认值
+                WinPolicySelector win = new WinPolicySelector();
+                LoadParameter.StartParameter(win, new LoadParameter(Context.InsuerParameter));
+                win.Owner = this.GetWindow();
+                if (win.ShowDialog() == true)
                 {
-                    this.PolicyNo = tempPolicyNo;
+                    var tempPolicyNo = win.GetRealResult<string>();
+                    if (!string.IsNullOrEmpty(tempPolicyNo))
+                    {
+                        this.PolicyNo = tempPolicyNo;
+                    }
                 }
             }
+            catch (Exception ex)
+            {
+                MessageTipEx.Show(ex);
+            }
         }
         public bool CanSelectPolicyCommand(object parameter)
         {

+ 14 - 6
MBI/FirmLib/Com.FirmLib.UI/Maintainer/VmAddLossProductType.cs

@@ -67,13 +67,21 @@ namespace Com.FirmLib.UI.Maintainer
         [Command]
         public void OkCommand(object parameter)
         {
-            Window window = parameter as Window;
-            if (window != null)
+
+            try
+            {
+                Window window = parameter as Window;
+                if (window != null)
+                {
+                    var checkedItems = ProductTypes.Where(c => c.IsChecked).Select(c => c.RefObject).ToList();
+                    //设置需要处理的值
+                    window.SetRealResult<List<ProductTypeShowItem>>(checkedItems);
+                    window.DialogResult = true;
+                }
+            }
+            catch (Exception ex)
             {
-                var checkedItems = ProductTypes.Where(c => c.IsChecked).Select(c => c.RefObject).ToList();
-                //设置需要处理的值
-                window.SetRealResult<List<ProductTypeShowItem>>(checkedItems);
-                window.DialogResult = true;
+                MessageTipEx.Show(ex);
             }
         }
         public bool CanOkCommand(object parameter)

+ 16 - 8
MBI/FirmLib/Com.FirmLib.UI/Maintainer/VmMaintainerAssetSelector.cs

@@ -128,23 +128,31 @@ namespace Com.FirmLib.UI.Maintainer
         [Command]
         public void EnsureCommand(object parameter)
         {
+
             try
             {
-                if (Context != null)
+                try
                 {
-                    Context.AddedItems.AddRange(SelectedAssetItems);
+                    if (Context != null)
+                    {
+                        Context.AddedItems.AddRange(SelectedAssetItems);
+                    }
+                    Window win = parameter as Window;
+                    if (win != null)
+                    {
+                        win.DialogResult = true;
+                    }
+
                 }
-                Window win = parameter as Window;
-                if (win != null)
+                catch (Exception ex)
                 {
-                    win.DialogResult = true;
-                }
 
+                    MessageTipEx.Show(ex);
+                }
             }
             catch (Exception ex)
             {
-
-               MessageTipEx.Show(ex);
+                MessageTipEx.Show(ex);
             }
         }
         public bool CanEnsureCommand(object parameter)

+ 52 - 28
MBI/FirmLib/Com.FirmLib.UI/Maintainer/VmMaintainerBaseInfo.cs

@@ -84,22 +84,30 @@ namespace Com.FirmLib.UI.Maintainer
         [Command]
         public void AddCommand(object parameter)
         {
-            WinMaintainerEditor win = new WinMaintainerEditor();
-            win.Owner = this.GetWindow();
-            if (win.ShowDialog() == true)
+
+            try
             {
-                if (win.IsManage)
+                WinMaintainerEditor win = new WinMaintainerEditor();
+                win.Owner = this.GetWindow();
+                if (win.ShowDialog() == true)
                 {
-                    WinMaintainerInfo winMaintrainerInfo = new WinMaintainerInfo();
-                    LoadParameter.StartParameter(winMaintrainerInfo, new LoadParameter(win.NewId));
-                    winMaintrainerInfo.Show(this.GetNavigationBar());
-                }
-                else
-                {
-                    //todo 刷新界面
-                    LoadItems();
+                    if (win.IsManage)
+                    {
+                        WinMaintainerInfo winMaintrainerInfo = new WinMaintainerInfo();
+                        LoadParameter.StartParameter(winMaintrainerInfo, new LoadParameter(win.NewId));
+                        winMaintrainerInfo.Show(this.GetNavigationBar());
+                    }
+                    else
+                    {
+                        //todo 刷新界面
+                        LoadItems();
+                    }
                 }
             }
+            catch (Exception ex)
+            {
+                MessageTipEx.Show(ex);
+            }
         }
         public bool CanAddCommand(object parameter)
         {
@@ -115,17 +123,25 @@ namespace Com.FirmLib.UI.Maintainer
         [Command]
         public void DeleteCommand(object parameter)
         {
-            MaintainerShowItem item = parameter as  MaintainerShowItem;
-            if (item == null)
-                return;
-            var result= MessageTip.Show(this.GetWindow(), "是否要删除", "提示", MessageBoxButton.YesNo);
-            if (result == MessageBoxResult.Yes)
+
+            try
             {
-                //todo 网络api处理
-                DeleteItem(item.Id);
-                //todo 刷新窗体
-                LoadItems();
-               // Manitainers.Remove(item);
+                MaintainerShowItem item = parameter as MaintainerShowItem;
+                if (item == null)
+                    return;
+                var result = MessageTip.Show(this.GetWindow(), "是否要删除", "提示", MessageBoxButton.YesNo);
+                if (result == MessageBoxResult.Yes)
+                {
+                    //todo 网络api处理
+                    DeleteItem(item.Id);
+                    //todo 刷新窗体
+                    LoadItems();
+                    // Manitainers.Remove(item);
+                }
+            }
+            catch (Exception ex)
+            {
+                MessageTipEx.Show(ex);
             }
             
         }
@@ -140,12 +156,20 @@ namespace Com.FirmLib.UI.Maintainer
         [Command]
         public void ManageCommand(object parameter)
         {
-            MaintainerShowItem item = parameter as MaintainerShowItem;
-            if (item == null)
-                return;
-            WinMaintainerInfo win = new WinMaintainerInfo();
-            LoadParameter.StartParameter(win, new LoadParameter(item.Id));
-            win.Show(this.GetNavigationBar());
+
+            try
+            {
+                MaintainerShowItem item = parameter as MaintainerShowItem;
+                if (item == null)
+                    return;
+                WinMaintainerInfo win = new WinMaintainerInfo();
+                LoadParameter.StartParameter(win, new LoadParameter(item.Id));
+                win.Show(this.GetNavigationBar());
+            }
+            catch (Exception ex)
+            {
+                MessageTipEx.Show(ex);
+            }
         }
         public bool CanManageCommand(object parameter)
         {

+ 27 - 11
MBI/FirmLib/Com.FirmLib.UI/Maintainer/VmMaintainerEditor.cs

@@ -81,11 +81,19 @@ namespace Com.FirmLib.UI.Maintainer
         [Command]
         public void AddCommand(object parameter)
         {
-            if (!CreateMaintainer())
-                return;
-            Window window = parameter as Window;
-            if (window != null)
-                window.DialogResult = true;
+
+            try
+            {
+                if (!CreateMaintainer())
+                    return;
+                Window window = parameter as Window;
+                if (window != null)
+                    window.DialogResult = true;
+            }
+            catch (Exception ex)
+            {
+                MessageTipEx.Show(ex);
+            }
         }
         public bool CanAddCommand(object parameter)
         {
@@ -99,12 +107,20 @@ namespace Com.FirmLib.UI.Maintainer
         [Command]
         public void AddAndManageCommand(object parameter)
         {
-            if (!CreateMaintainer())
-                return;
-            IsManage = true;
-            Window window = parameter as Window;
-            if (window != null)
-                window.DialogResult = true;
+
+            try
+            {
+                if (!CreateMaintainer())
+                    return;
+                IsManage = true;
+                Window window = parameter as Window;
+                if (window != null)
+                    window.DialogResult = true;
+            }
+            catch (Exception ex)
+            {
+                MessageTipEx.Show(ex);
+            }
         }
         public bool CanAddAndManageCommand(object parameter)
         {

+ 144 - 88
MBI/FirmLib/Com.FirmLib.UI/Maintainer/VmMaintainerInfo.cs

@@ -126,9 +126,17 @@ namespace Com.FirmLib.UI.Maintainer
         [Command]
         public void AddProjectAsset(object parameter)
         {
-            WinMaintainerProjectAsset win = new WinMaintainerProjectAsset();
-            LoadParameter.StartParameter(win, new LoadParameter(Id));
-            win.Show(this.GetNavigationBar());
+
+            try
+            {
+                WinMaintainerProjectAsset win = new WinMaintainerProjectAsset();
+                LoadParameter.StartParameter(win, new LoadParameter(Id));
+                win.Show(this.GetNavigationBar());
+            }
+            catch (Exception ex)
+            {
+                MessageTipEx.Show(ex);
+            }
         }
         public bool CanAddContract(object parameter)
         {
@@ -142,13 +150,21 @@ namespace Com.FirmLib.UI.Maintainer
         [Command]
         public void GoToProject(object parameter)
         {
-            var item = parameter as ProjectMaintainerAssetItem;
-            WinManitainerProjectInfo win = new WinManitainerProjectInfo();
-            var p = new MaintainerParameter();
-            p.Project.Id = item.ProjectId;
-            p.Maintainer.Id = Id;
-            LoadParameter.StartParameter(win, new LoadParameter(p));
-            win.Show(this.GetNavigationBar());
+
+            try
+            {
+                var item = parameter as ProjectMaintainerAssetItem;
+                WinManitainerProjectInfo win = new WinManitainerProjectInfo();
+                var p = new MaintainerParameter();
+                p.Project.Id = item.ProjectId;
+                p.Maintainer.Id = Id;
+                LoadParameter.StartParameter(win, new LoadParameter(p));
+                win.Show(this.GetNavigationBar());
+            }
+            catch (Exception ex)
+            {
+                MessageTipEx.Show(ex);
+            }
         }
         public bool CanGoToProject(object parameter)
         {
@@ -178,13 +194,21 @@ namespace Com.FirmLib.UI.Maintainer
         [Command]
         public void AddProductTypeCommand(object parameter)
         {
-            WinAddProductType win = new WinAddProductType();
-            win.Owner = this.GetWindow();
-            LoadParameter.StartParameter(win, new LoadParameter(Id));
-            if (win.ShowDialog() == true)
+
+            try
             {
-                ///todo 是不是要刷新,因为可能连续添加;
-                LoadProductTypeItems(Id);
+                WinAddProductType win = new WinAddProductType();
+                win.Owner = this.GetWindow();
+                LoadParameter.StartParameter(win, new LoadParameter(Id));
+                if (win.ShowDialog() == true)
+                {
+                    ///todo 是不是要刷新,因为可能连续添加;
+                    LoadProductTypeItems(Id);
+                }
+            }
+            catch (Exception ex)
+            {
+                MessageTipEx.Show(ex);
             }
         }
         public bool CanAddProductTypeCommand(object parameter)
@@ -199,32 +223,40 @@ namespace Com.FirmLib.UI.Maintainer
         [Command]
         public void DeleteCommand(object parameter)
         {
-            TreeNavigationItem<BasePropertyChanged> item = parameter as TreeNavigationItem<BasePropertyChanged>;
-            if (item == null)
-                return;
-            BrandInfoShowItem showItem = item.RefItem as BrandInfoShowItem;
-            if (showItem == null)
-                return;
-            var result = MessageTip.Show(this.GetWindow(), "是否要删除", "提示", MessageBoxButton.YesNo);
-            if (result == MessageBoxResult.Yes)
+
+            try
             {
-                 var flag=DeleteItem(Id, showItem.ProductTypes.Select(p=>p.Id).ToList());
-                if (flag)
+                TreeNavigationItem<BasePropertyChanged> item = parameter as TreeNavigationItem<BasePropertyChanged>;
+                if (item == null)
+                    return;
+                BrandInfoShowItem showItem = item.RefItem as BrandInfoShowItem;
+                if (showItem == null)
+                    return;
+                var result = MessageTip.Show(this.GetWindow(), "是否要删除", "提示", MessageBoxButton.YesNo);
+                if (result == MessageBoxResult.Yes)
                 {
-                    if (Brands != null)
+                    var flag = DeleteItem(Id, showItem.ProductTypes.Select(p => p.Id).ToList());
+                    if (flag)
                     {
-                        if (DataSource != null)
+                        if (Brands != null)
                         {
-                            DataSource.RemoveAll(p => showItem.ProductTypes.Any(s => s.Id == p.ProductTypeId));
+                            if (DataSource != null)
+                            {
+                                DataSource.RemoveAll(p => showItem.ProductTypes.Any(s => s.Id == p.ProductTypeId));
+                            }
+                            Brands.Remove(item);
                         }
-                        Brands.Remove(item);
                     }
+                    else
+                    {
+                        MessageTip.Show(this.GetWindow(), BllFactory<ProductDirectoryBll>.Instance.ErrorMessage, "失败");
+                    }
+
                 }
-                else
-                {
-                    MessageTip.Show(this.GetWindow(), BllFactory<ProductDirectoryBll>.Instance.ErrorMessage, "失败");
-                }
-              
+            }
+            catch (Exception ex)
+            {
+                MessageTipEx.Show(ex);
             }
         }
         public bool CanDeleteCommand(object parameter)
@@ -240,17 +272,25 @@ namespace Com.FirmLib.UI.Maintainer
         [Command]
         public void ScanProductTypeCommand(object parameter)
         {
-            BrandInfoShowItem showItem = (parameter as TreeNavigationItem<BasePropertyChanged>)?.RefItem as BrandInfoShowItem;
-            if (showItem == null)
-                return;
-            WinUpdateProductType win = new WinUpdateProductType();
-            win.Title = "查看维修型号";
-            win.Owner = this.GetWindow();
-            EditParameter pa = new EditParameter(Id, showItem.BrandId);
-            LoadParameter.StartParameter(win, new LoadParameter(pa));
-            if (win.ShowDialog() == true)
+
+            try
             {
-                LoadProductTypeItems(Id);
+                BrandInfoShowItem showItem = (parameter as TreeNavigationItem<BasePropertyChanged>)?.RefItem as BrandInfoShowItem;
+                if (showItem == null)
+                    return;
+                WinUpdateProductType win = new WinUpdateProductType();
+                win.Title = "查看维修型号";
+                win.Owner = this.GetWindow();
+                EditParameter pa = new EditParameter(Id, showItem.BrandId);
+                LoadParameter.StartParameter(win, new LoadParameter(pa));
+                if (win.ShowDialog() == true)
+                {
+                    LoadProductTypeItems(Id);
+                }
+            }
+            catch (Exception ex)
+            {
+                MessageTipEx.Show(ex);
             }
         }
         public bool CanScanProductTypeCommand(object parameter)
@@ -265,17 +305,25 @@ namespace Com.FirmLib.UI.Maintainer
         [Command]
         public void EditProductTypeCommand(object parameter)
         {
-            BrandInfoShowItem showItem = (parameter as TreeNavigationItem<BasePropertyChanged>)?.RefItem as BrandInfoShowItem;
-            if (showItem == null)
-                return;
-            WinUpdateProductType win = new WinUpdateProductType();
-            win.Title = "编辑维修型号";
-            win.Owner = this.GetWindow();
-            EditParameter pa = new EditParameter(Id, showItem.BrandId) { IsEdit = true };
-            LoadParameter.StartParameter(win, new LoadParameter(pa));
-            if (win.ShowDialog() == true)
+
+            try
+            {
+                BrandInfoShowItem showItem = (parameter as TreeNavigationItem<BasePropertyChanged>)?.RefItem as BrandInfoShowItem;
+                if (showItem == null)
+                    return;
+                WinUpdateProductType win = new WinUpdateProductType();
+                win.Title = "编辑维修型号";
+                win.Owner = this.GetWindow();
+                EditParameter pa = new EditParameter(Id, showItem.BrandId) { IsEdit = true };
+                LoadParameter.StartParameter(win, new LoadParameter(pa));
+                if (win.ShowDialog() == true)
+                {
+                    LoadProductTypeItems(Id);
+                }
+            }
+            catch (Exception ex)
             {
-                LoadProductTypeItems(Id);
+                MessageTipEx.Show(ex);
             }
 
         }
@@ -290,41 +338,49 @@ namespace Com.FirmLib.UI.Maintainer
         [Command]
         public void RefreshCommand(object parameter)
         {
-            var item = parameter as ProjectMaintainerAssetItem;
-            if (item != null)
-            {
-                item.IsLoading = true;
-               TaskUtil.StartSTATask((obj) =>
-              {
-                  var useItem = obj as ProjectMaintainerAssetItem;
-                  if (useItem == null)
-                      return;
-                  try
-                  {
-                      BllFactory<ProjectBll>.Instance.ProjectSync(useItem.ProjectId);
-                      Thread.Sleep(3000);//立即执行偶尔导致连接取消
+
+            try
+            {
+                var item = parameter as ProjectMaintainerAssetItem;
+                if (item != null)
+                {
+                    item.IsLoading = true;
+                    TaskUtil.StartSTATask((obj) =>
+                   {
+                       var useItem = obj as ProjectMaintainerAssetItem;
+                       if (useItem == null)
+                           return;
+                       try
+                       {
+                           BllFactory<ProjectBll>.Instance.ProjectSync(useItem.ProjectId);
+                           Thread.Sleep(3000);//立即执行偶尔导致连接取消
                       var projects = BllFactory<MaintainerBll>.Instance.GetProjectItems(Id);
-                      foreach (var project in projects)
-                      {
-                          if (project.Id == useItem.ProjectId)
-                          {
-                              useItem.ValidityAssetCount = project.TotalCount;
-                              useItem.NearOutDateAssetCount = project.NearlyExpireCount;
-                          }
-                      }
-                  }
-                  catch (Exception ex)
-                  {
-                      MessageTipEx.Show(ex);
-                  }
-
-                  finally
-                  {
-
-                      useItem.IsLoading = false;
-                  }
-              }, item);
+                           foreach (var project in projects)
+                           {
+                               if (project.Id == useItem.ProjectId)
+                               {
+                                   useItem.ValidityAssetCount = project.TotalCount;
+                                   useItem.NearOutDateAssetCount = project.NearlyExpireCount;
+                               }
+                           }
+                       }
+                       catch (Exception ex)
+                       {
+                           MessageTipEx.Show(ex);
+                       }
+
+                       finally
+                       {
+
+                           useItem.IsLoading = false;
+                       }
+                   }, item);
 
+                }
+            }
+            catch (Exception ex)
+            {
+                MessageTipEx.Show(ex);
             }
 
 

+ 85 - 53
MBI/FirmLib/Com.FirmLib.UI/Maintainer/VmMaintainerProjectAsset.cs

@@ -143,15 +143,23 @@ namespace Com.FirmLib.UI.Maintainer
         [Command]
         public void SaveCommand(object parameter)
         {
-            if (CreateProjectInfo()&&CreateRefEquipment())
+
+            try
             {
+                if (CreateProjectInfo() && CreateRefEquipment())
+                {
 
-                AfterSuccessSave();
-                MessageTip.Show(this.GetWindow(), "保存成功");
+                    AfterSuccessSave();
+                    MessageTip.Show(this.GetWindow(), "保存成功");
+                }
+                else
+                {
+                    MessageTip.Show(this.GetWindow(), "保存失败");
+                }
             }
-            else
+            catch (Exception ex)
             {
-                MessageTip.Show(this.GetWindow(), "保存失败");
+                MessageTipEx.Show(ex);
             }
         }
         public bool CanSaveCommand(object parameter)
@@ -165,27 +173,35 @@ namespace Com.FirmLib.UI.Maintainer
         [Command]
         public void SelectAssetCommand(object parameter)
         {
-            WinMaintainerAssetSelector win = new WinMaintainerAssetSelector();
-            win.Owner = this.GetWindow();
-            SelectAssetContext context = new SelectAssetContext();
-            context.ProjectId = SystemProjectId;
-            context.VenderId = MaintainerId;
-            context.ContainIds = new List<string>(RefAssetItems.Select(p=>p.Id));
-            LoadParameter.StartParameter(win, new LoadParameter(context));
-            if (win.ShowDialog() == true)
+
+            try
             {
-                if (RefAssetItems == null)
-                {
-                    RefAssetItems = new ObservableCollection<AssetShowItem>();
-                }
-                var addRelations = context.AddedItems;
-                foreach (var item in addRelations)
+                WinMaintainerAssetSelector win = new WinMaintainerAssetSelector();
+                win.Owner = this.GetWindow();
+                SelectAssetContext context = new SelectAssetContext();
+                context.ProjectId = SystemProjectId;
+                context.VenderId = MaintainerId;
+                context.ContainIds = new List<string>(RefAssetItems.Select(p => p.Id));
+                LoadParameter.StartParameter(win, new LoadParameter(context));
+                if (win.ShowDialog() == true)
                 {
-                    if (RefAssetItems.Any(c => c.Id == item.Id))
-                        return;
-                    RefAssetItems.Add(item);
+                    if (RefAssetItems == null)
+                    {
+                        RefAssetItems = new ObservableCollection<AssetShowItem>();
+                    }
+                    var addRelations = context.AddedItems;
+                    foreach (var item in addRelations)
+                    {
+                        if (RefAssetItems.Any(c => c.Id == item.Id))
+                            return;
+                        RefAssetItems.Add(item);
+                    }
                 }
             }
+            catch (Exception ex)
+            {
+                MessageTipEx.Show(ex);
+            }
         }
         public bool CanSelectAssetCommand(object parameter)
         {
@@ -200,30 +216,38 @@ namespace Com.FirmLib.UI.Maintainer
         [Command]
         public void DeleteCommand(object parameter)
         {
-            AssetShowItem showItem = parameter as AssetShowItem;
-            if (showItem == null)
-                return;
-            var result = MessageTip.Show(this.GetWindow(), "是否要删除", "提示", MessageBoxButton.YesNo);
-            if (result == MessageBoxResult.Yes)
+
+            try
             {
-                bool flag = false;
-                if (showItem.MaintainerId == MaintainerId)
-                {
-                    flag = AssetManager.DeleteMaintainerEquipments(SystemProjectId, new List<string>() { showItem.Id });
-                }
-                else
-                {
-                    flag = true;
-                }        
-                if (flag)
-                {
-                    this.RefAssetItems.Remove(showItem);
-                }
-                else
+                AssetShowItem showItem = parameter as AssetShowItem;
+                if (showItem == null)
+                    return;
+                var result = MessageTip.Show(this.GetWindow(), "是否要删除", "提示", MessageBoxButton.YesNo);
+                if (result == MessageBoxResult.Yes)
                 {
-                    MessageTip.Show(this.GetWindow(), "删除失败");
-                }
+                    bool flag = false;
+                    if (showItem.MaintainerId == MaintainerId)
+                    {
+                        flag = AssetManager.DeleteMaintainerEquipments(SystemProjectId, new List<string>() { showItem.Id });
+                    }
+                    else
+                    {
+                        flag = true;
+                    }
+                    if (flag)
+                    {
+                        this.RefAssetItems.Remove(showItem);
+                    }
+                    else
+                    {
+                        MessageTip.Show(this.GetWindow(), "删除失败");
+                    }
 
+                }
+            }
+            catch (Exception ex)
+            {
+                MessageTipEx.Show(ex);
             }
         }
         public bool CanDeleteCommand(object parameter)
@@ -239,18 +263,26 @@ namespace Com.FirmLib.UI.Maintainer
         [Command]
         public void ScanCommand(object parameter)
         {
-            AssetShowItem showItem = parameter as AssetShowItem;
-            if (showItem == null)
+
+            try
             {
-                return;
+                AssetShowItem showItem = parameter as AssetShowItem;
+                if (showItem == null)
+                {
+                    return;
+                }
+                AssetItem parItem = new AssetItem();
+                parItem.Id = showItem.Id;
+                parItem.ProjectId = showItem.Id;
+                //获取三位编码
+                parItem.FamilyCode = showItem.FamilyCode.Substring(2);
+                string url = BllFactory<AssetBll>.Instance.GetEquipmentUrl(parItem);
+                WinBrowser.Instance.Show(url, "设备信息");
+            }
+            catch (Exception ex)
+            {
+                MessageTipEx.Show(ex);
             }
-            AssetItem parItem = new AssetItem();
-            parItem.Id = showItem.Id;
-            parItem.ProjectId = showItem.Id;
-            //获取三位编码
-            parItem.FamilyCode = showItem.FamilyCode.Substring(2);
-            string url = BllFactory<AssetBll>.Instance.GetEquipmentUrl(parItem);
-            WinBrowser.Instance.Show(url, "设备信息");
         }
         public bool CanScanCommand(object parameter)
         {

+ 106 - 66
MBI/FirmLib/Com.FirmLib.UI/Maintainer/VmManitainerProjectInfo.cs

@@ -157,16 +157,24 @@ namespace Com.FirmLib.UI.Maintainer
         [Command]
         public void ScanAssetInfo(object parameter)
         {
-            AssetShowItem item = parameter as AssetShowItem;
-            if (item == null)
-                return;
-            AssetItem parItem = new AssetItem();
-            parItem.Id = item.Id;
-            parItem.ProjectId = item.ProjectId;
-            //获取三位编码
-            parItem.FamilyCode = item.FamilyCode.Substring(2);// EquipmentFamilyManager.GetaTopCode(item.Category.Substring(2)); //item.Category.Substring(0,3);
-            string url = BllFactory<AssetBll>.Instance.GetEquipmentUrl(parItem);
-            WinBrowser.Instance.Show(url, "设备信息");
+
+            try
+            {
+                AssetShowItem item = parameter as AssetShowItem;
+                if (item == null)
+                    return;
+                AssetItem parItem = new AssetItem();
+                parItem.Id = item.Id;
+                parItem.ProjectId = item.ProjectId;
+                //获取三位编码
+                parItem.FamilyCode = item.FamilyCode.Substring(2);// EquipmentFamilyManager.GetaTopCode(item.Category.Substring(2)); //item.Category.Substring(0,3);
+                string url = BllFactory<AssetBll>.Instance.GetEquipmentUrl(parItem);
+                WinBrowser.Instance.Show(url, "设备信息");
+            }
+            catch (Exception ex)
+            {
+                MessageTipEx.Show(ex);
+            }
         }
         public bool CanScanAssetInfo(object parameter)
         {
@@ -179,16 +187,24 @@ namespace Com.FirmLib.UI.Maintainer
         [Command]
         public void SaveCommand(object parameter)
         {
-            var flag = CreateAssets();
-            if (flag)
+
+            try
             {
-                AfterSuccessSave();
-                 MessageTip.Show(this.GetWindow(), "保存成功");
+                var flag = CreateAssets();
+                if (flag)
+                {
+                    AfterSuccessSave();
+                    MessageTip.Show(this.GetWindow(), "保存成功");
+                }
+                else
+                {
+                    MessageTip.Show(this.GetWindow(), "保存失败");
+
+                }
             }
-            else
+            catch (Exception ex)
             {
-                MessageTip.Show(this.GetWindow(), "保存失败");
-
+                MessageTipEx.Show(ex);
             }
 
         }
@@ -203,27 +219,35 @@ namespace Com.FirmLib.UI.Maintainer
         [Command]
         public void SelectAssetCommand(object parameter)
         {
-            WinMaintainerAssetSelector win = new WinMaintainerAssetSelector();
-            win.Owner = this.GetWindow();
-            SelectAssetContext context = new SelectAssetContext();
-            context.ProjectId = ProjectId;
-            context.VenderId = MaintainerId;
-            context.ContainIds = new List<string>(CurrentAssets.Select(p => p.Id));
-            LoadParameter.StartParameter(win, new LoadParameter(context));
-            if (win.ShowDialog() == true)
+
+            try
             {
-                if (CurrentAssets == null)
-                {
-                    CurrentAssets = new ObservableCollection<AssetShowItem>();
-                }
-                var addRelations = context.AddedItems;
-                foreach (var item in addRelations)
+                WinMaintainerAssetSelector win = new WinMaintainerAssetSelector();
+                win.Owner = this.GetWindow();
+                SelectAssetContext context = new SelectAssetContext();
+                context.ProjectId = ProjectId;
+                context.VenderId = MaintainerId;
+                context.ContainIds = new List<string>(CurrentAssets.Select(p => p.Id));
+                LoadParameter.StartParameter(win, new LoadParameter(context));
+                if (win.ShowDialog() == true)
                 {
-                    if (CurrentAssets.Any(c => c.Id == item.Id))
-                        return;
-                    CurrentAssets.Add(item);
+                    if (CurrentAssets == null)
+                    {
+                        CurrentAssets = new ObservableCollection<AssetShowItem>();
+                    }
+                    var addRelations = context.AddedItems;
+                    foreach (var item in addRelations)
+                    {
+                        if (CurrentAssets.Any(c => c.Id == item.Id))
+                            return;
+                        CurrentAssets.Add(item);
+                    }
                 }
             }
+            catch (Exception ex)
+            {
+                MessageTipEx.Show(ex);
+            }
         }
         public bool CanSelectAssetCommand(object parameter)
         {
@@ -236,30 +260,38 @@ namespace Com.FirmLib.UI.Maintainer
         [Command]
         public void DeleteCommand(object parameter)
         {
-            AssetShowItem showItem = parameter as AssetShowItem;
-            if (showItem == null)
-                return;
-            var result = MessageTip.Show(this.GetWindow(), "是否要删除", "提示", MessageBoxButton.YesNo);
-            if (result == MessageBoxResult.Yes)
+
+            try
             {
-                bool flag = false;
-                if (showItem.MaintainerId == MaintainerId)
-                {
-                    flag = AssetManager.DeleteMaintainerEquipments(ProjectId, new List<string>() { showItem.Id });
-                }
-                else
+                AssetShowItem showItem = parameter as AssetShowItem;
+                if (showItem == null)
+                    return;
+                var result = MessageTip.Show(this.GetWindow(), "是否要删除", "提示", MessageBoxButton.YesNo);
+                if (result == MessageBoxResult.Yes)
                 {
-                    flag = true;
-                }
-                if (flag)
-                {
-                    this.CurrentAssets.Remove(showItem);
-                }
-                else
-                {
-                    MessageTip.Show(this.GetWindow(), "删除失败");
+                    bool flag = false;
+                    if (showItem.MaintainerId == MaintainerId)
+                    {
+                        flag = AssetManager.DeleteMaintainerEquipments(ProjectId, new List<string>() { showItem.Id });
+                    }
+                    else
+                    {
+                        flag = true;
+                    }
+                    if (flag)
+                    {
+                        this.CurrentAssets.Remove(showItem);
+                    }
+                    else
+                    {
+                        MessageTip.Show(this.GetWindow(), "删除失败");
+                    }
                 }
             }
+            catch (Exception ex)
+            {
+                MessageTipEx.Show(ex);
+            }
         }
 
         public bool CanDeleteCommand(object parameter)
@@ -275,22 +307,30 @@ namespace Com.FirmLib.UI.Maintainer
         [Command]
         public void FilterNearCommand(object parameter)
         {
-            this.IsFilter = !IsFilter;
-            if (this.CurrentAssets != null)
-            {
-                var view = CollectionViewSource.GetDefaultView(this.CurrentAssets);
 
-                if (IsFilter)
-                {
-                    view.Filter = DatetimeFilter;
-                }
-                else
+            try
+            {
+                this.IsFilter = !IsFilter;
+                if (this.CurrentAssets != null)
                 {
-                    view.Filter = null;
-                }
+                    var view = CollectionViewSource.GetDefaultView(this.CurrentAssets);
 
-                view.Refresh();
+                    if (IsFilter)
+                    {
+                        view.Filter = DatetimeFilter;
+                    }
+                    else
+                    {
+                        view.Filter = null;
+                    }
+
+                    view.Refresh();
 
+                }
+            }
+            catch (Exception ex)
+            {
+                MessageTipEx.Show(ex);
             }
         }
         public bool CanFilterNearCommand(object parameter)

+ 66 - 34
MBI/FirmLib/Com.FirmLib.UI/Manufacturer/VmBrandEditor.cs

@@ -116,26 +116,34 @@ namespace Com.FirmLib.UI.Manufacturer
         [Command]
         public void UploadCommand(object parameter)
         {
-            OpenFileDialog ofd = new OpenFileDialog();
-            //过滤上传图片的类型  
-            ofd.Filter = "jpg图片|*.jpg|png图片|*.png|jpeg图片|*.jpeg|bmp图片|*.bmp";
-            if (ofd.ShowDialog() == true)
+
+            try
             {
-                string fileName = ofd.FileName;
-                ImageSourceConverter isConverter = new ImageSourceConverter();
-                var bytes = File.ReadAllBytes(fileName);
-                if (bytes.Length > m_MaxSize)
+                OpenFileDialog ofd = new OpenFileDialog();
+                //过滤上传图片的类型  
+                ofd.Filter = "jpg图片|*.jpg|png图片|*.png|jpeg图片|*.jpeg|bmp图片|*.bmp";
+                if (ofd.ShowDialog() == true)
                 {
-                    MessageTip.Show("logo不能大于2M,如需要请重新选择");
-                    return;
+                    string fileName = ofd.FileName;
+                    ImageSourceConverter isConverter = new ImageSourceConverter();
+                    var bytes = File.ReadAllBytes(fileName);
+                    if (bytes.Length > m_MaxSize)
+                    {
+                        MessageTip.Show("logo不能大于2M,如需要请重新选择");
+                        return;
+                    }
+                    BitmapSource imageSource = (BitmapSource)isConverter.ConvertFrom(bytes);
+                    ImageBrush = null;
+                    //ImageBrush =
+                    //    new ImageBrush((ImageSource)isConverter.ConvertFrom(bytes));
+                    ImageBrush = new ImageBrush(ImageUtil.GetCenterCropped(imageSource));
+                    LogoKey.Value = fileName;
+                    LogoKey.Tag = bytes;
                 }
-                BitmapSource imageSource = (BitmapSource)isConverter.ConvertFrom(bytes);          
-                ImageBrush = null;
-                //ImageBrush =
-                //    new ImageBrush((ImageSource)isConverter.ConvertFrom(bytes));
-                ImageBrush = new ImageBrush(ImageUtil.GetCenterCropped(imageSource));
-                LogoKey.Value = fileName;
-                LogoKey.Tag = bytes;
+            }
+            catch (Exception ex)
+            {
+                MessageTipEx.Show(ex);
             }
         }
         public bool CanUploadCommand(object parameter)
@@ -149,11 +157,19 @@ namespace Com.FirmLib.UI.Manufacturer
         [Command]
         public void AddCommand(object parameter)
         {
-            if (!AddBrand())
-                return;
-            Window window = parameter as Window;
-            if (window != null)
-                window.DialogResult = true;
+
+            try
+            {
+                if (!AddBrand())
+                    return;
+                Window window = parameter as Window;
+                if (window != null)
+                    window.DialogResult = true;
+            }
+            catch (Exception ex)
+            {
+                MessageTipEx.Show(ex);
+            }
         }
         public bool CanAddCommand(object parameter)
         {
@@ -168,12 +184,20 @@ namespace Com.FirmLib.UI.Manufacturer
         [Command]
         public void AddProductCommand(object parameter)
         {
-            if (!AddBrand())
-                return;
-            AddProduct = true;
-            Window window = parameter as Window;
-            if (window != null)
-                window.DialogResult = true;
+
+            try
+            {
+                if (!AddBrand())
+                    return;
+                AddProduct = true;
+                Window window = parameter as Window;
+                if (window != null)
+                    window.DialogResult = true;
+            }
+            catch (Exception ex)
+            {
+                MessageTipEx.Show(ex);
+            }
         }
         public bool CanAddProductCommand(object parameter)
         {
@@ -188,12 +212,20 @@ namespace Com.FirmLib.UI.Manufacturer
         [Command]
         public void DeleteCommand(object parameter)
         {
-            if (!DeleteBrand())
-                return;
-            UseDelete = true;
-            Window window = parameter as Window;
-            if (window != null)
-                window.DialogResult = true; 
+
+            try
+            {
+                if (!DeleteBrand())
+                    return;
+                UseDelete = true;
+                Window window = parameter as Window;
+                if (window != null)
+                    window.DialogResult = true;
+            }
+            catch (Exception ex)
+            {
+                MessageTipEx.Show(ex);
+            }
         }
         public bool CanDeleteCommand(object parameter)
         {

+ 66 - 35
MBI/FirmLib/Com.FirmLib.UI/Manufacturer/VmManufactureBaseInfo.cs

@@ -31,17 +31,18 @@ namespace Com.FirmLib.UI.Manufacturer
 
         private void Init()
         {
-            
         }
+
         public void Init(LoadParameter parameter)
         {
             LoadItems();
-
         }
+
         #region 属性相关
 
 
         private ObservableCollection<ManufacturerShowItem> m_Manufacturers;
+
         /// <summary>
         /// 生产厂家明细
         /// </summary>
@@ -66,26 +67,35 @@ namespace Com.FirmLib.UI.Manufacturer
         [Command]
         public void AddCommand(object parameter)
         {
-            WinManufacturerEditor win = new WinManufacturerEditor();
-            win.Owner = this.GetWindow();
-            if (win.ShowDialog() == true)
+
+            try
             {
-                if (win.IsManage)
-                {
-                    WinManufactureInfo winInfo = new WinManufactureInfo();
-                    LoadParameter.StartParameter(winInfo, new LoadParameter(win.ManufacturerId));
-                    winInfo.Show(this.GetNavigationBar());
-                }
-                else
+                WinManufacturerEditor win = new WinManufacturerEditor();
+                win.Owner = this.GetWindow();
+                if (win.ShowDialog() == true)
                 {
-                    //todo 刷新窗体
-                    LoadItems();
-                    
+                    if (win.IsManage)
+                    {
+                        WinManufactureInfo winInfo = new WinManufactureInfo();
+                        LoadParameter.StartParameter(winInfo, new LoadParameter(win.ManufacturerId));
+                        winInfo.Show(this.GetNavigationBar());
+                    }
+                    else
+                    {
+                        //todo 刷新窗体
+                        LoadItems();
+
+                    }
+
                 }
-                
             }
-           
+            catch (Exception ex)
+            {
+                MessageTipEx.Show(ex);
+            }
+
         }
+
         public bool CanAddCommand(object parameter)
         {
             return true;
@@ -98,18 +108,27 @@ namespace Com.FirmLib.UI.Manufacturer
         [Command]
         public void DeleteCommand(object parameter)
         {
-            var item = parameter as ManufacturerShowItem;
-            if (item == null)
-                return;
-            var result= MessageTip.Show(this.GetWindow(), "是否要删除", "提示", MessageBoxButton.YesNo);
-            if (result == MessageBoxResult.Yes)
+
+            try
             {
-                DeleteItem(item.ManufactureId);
-                //todo 刷新窗体
-                LoadItems();
-               // Manufacturers.Remove(item);
+                var item = parameter as ManufacturerShowItem;
+                if (item == null)
+                    return;
+                var result = MessageTip.Show(this.GetWindow(), "是否要删除", "提示", MessageBoxButton.YesNo);
+                if (result == MessageBoxResult.Yes)
+                {
+                    DeleteItem(item.ManufactureId);
+                    //todo 刷新窗体
+                    LoadItems();
+                    // Manufacturers.Remove(item);
+                }
+            }
+            catch (Exception ex)
+            {
+                MessageTipEx.Show(ex);
             }
         }
+
         public bool CanDeleteCommand(object parameter)
         {
             return true;
@@ -122,33 +141,44 @@ namespace Com.FirmLib.UI.Manufacturer
         [Command]
         public void ManageCommand(object parameter)
         {
-            var manufacturer = parameter as ManufacturerShowItem;
-            if (manufacturer == null)
-                return;
-            WinManufactureInfo win = new WinManufactureInfo();
-            LoadParameter.StartParameter(win, new LoadParameter(manufacturer.ManufactureId));
-            win.Show(this.GetNavigationBar());
+
+            try
+            {
+                var manufacturer = parameter as ManufacturerShowItem;
+                if (manufacturer == null)
+                    return;
+                WinManufactureInfo win = new WinManufactureInfo();
+                LoadParameter.StartParameter(win, new LoadParameter(manufacturer.ManufactureId));
+                win.Show(this.GetNavigationBar());
+            }
+            catch (Exception ex)
+            {
+                MessageTipEx.Show(ex);
+            }
         }
+
         public bool CanManageCommand(object parameter)
         {
             return true;
         }
 
         #endregion
+
         /// <summary>
         /// 加载数据
         /// </summary>
         private void LoadItems()
         {
-            Manufacturers=new ObservableCollection<ManufacturerShowItem>();
-            var items=BllFactory<ManufacturerBll>.Instance.GetAllItems();
+            Manufacturers = new ObservableCollection<ManufacturerShowItem>();
+            var items = BllFactory<ManufacturerBll>.Instance.GetAllItems();
             foreach (var manufacturerItem in items)
             {
                 var tempItem = new ManufacturerShowItem();
                 tempItem.ManufactureId = manufacturerItem.Id;
                 tempItem.ManufacturerName = manufacturerItem.Name;
                 tempItem.BrandNames = manufacturerItem.Brands.Select(b => b.Name).ToList();
-                tempItem.FamilyNames = manufacturerItem.Familys.Select(f => EquipmentFamilyManager.GetFamilyName(f.Code)).ToList();
+                tempItem.FamilyNames = manufacturerItem.Familys
+                    .Select(f => EquipmentFamilyManager.GetFamilyName(f.Code)).ToList();
                 Manufacturers.Add(tempItem);
             }
         }
@@ -165,6 +195,7 @@ namespace Com.FirmLib.UI.Manufacturer
             {
                 MessageTip.Show(this.GetWindow(), BllFactory<ManufacturerBll>.Instance.ErrorMessage ?? string.Empty);
             }
+
             return result;
         }
     }

+ 194 - 130
MBI/FirmLib/Com.FirmLib.UI/Manufacturer/VmManufactureInfo.cs

@@ -167,50 +167,58 @@ namespace Com.FirmLib.UI.Manufacturer
         [Command]
         public void AddBranchCommand(object parameter)
         {
-            WinBrandEditor win = new WinBrandEditor();
-            BrandShowItem item = new BrandShowItem() {ManufacturerId= Id };
-            LoadParameter.StartParameter(win, new LoadParameter(item));
-            win.Owner = this.GetWindow();
-            if (win.ShowDialog() == true)
-            {
-                //刷新品牌列表,切换到当前品牌视图
-                LoadBrandItems();
-                if (!win.AddProduct)
-                    return;
-                #region 继续添加产品
-                //todo 进行产品添加,存在默认的品牌初始值
-                var brandId = win.BrandId;
-                WinProductEditor winProduct = new WinProductEditor();
-                ManufactureParameter startParameter = new ManufactureParameter();
-                startParameter.Manufacture.Id = Id;
-                startParameter.Branch.Id = brandId;
-                LoadParameter.StartParameter(winProduct, new LoadParameter(startParameter));
-                winProduct.Owner = this.GetWindow();
-                if (winProduct.ShowDialog() == true)
+
+            try
+            {
+                WinBrandEditor win = new WinBrandEditor();
+                BrandShowItem item = new BrandShowItem() { ManufacturerId = Id };
+                LoadParameter.StartParameter(win, new LoadParameter(item));
+                win.Owner = this.GetWindow();
+                if (win.ShowDialog() == true)
                 {
-                    //todo 刷新产品列表
-                    if (CurrentSelectedBrand != null && CurrentSelectedBrand.Id == brandId)
-                    {
-                        LoadProdutItems(brandId);//这个可能无效刷新,因为当前
-                    }
-                
-                    if (winProduct.ManageType)
+                    //刷新品牌列表,切换到当前品牌视图
+                    LoadBrandItems();
+                    if (!win.AddProduct)
+                        return;
+                    #region 继续添加产品
+                    //todo 进行产品添加,存在默认的品牌初始值
+                    var brandId = win.BrandId;
+                    WinProductEditor winProduct = new WinProductEditor();
+                    ManufactureParameter startParameter = new ManufactureParameter();
+                    startParameter.Manufacture.Id = Id;
+                    startParameter.Branch.Id = brandId;
+                    LoadParameter.StartParameter(winProduct, new LoadParameter(startParameter));
+                    winProduct.Owner = this.GetWindow();
+                    if (winProduct.ShowDialog() == true)
                     {
-                        WinProductType winType = new WinProductType();
-                        //todo 初始化参数信息
-                        ProductShowItem showItem = new ProductShowItem();
-                        showItem.VenderId = Id;
-                        showItem.BrandId = brandId;
+                        //todo 刷新产品列表
+                        if (CurrentSelectedBrand != null && CurrentSelectedBrand.Id == brandId)
+                        {
+                            LoadProdutItems(brandId);//这个可能无效刷新,因为当前
+                        }
 
-                        showItem.ProductId = winProduct.ProductId;
-                     
+                        if (winProduct.ManageType)
+                        {
+                            WinProductType winType = new WinProductType();
+                            //todo 初始化参数信息
+                            ProductShowItem showItem = new ProductShowItem();
+                            showItem.VenderId = Id;
+                            showItem.BrandId = brandId;
 
-                        LoadParameter.StartParameter(winType, new LoadParameter(showItem));
-                        winType.Show(this.GetNavigationBar());
+                            showItem.ProductId = winProduct.ProductId;
+
+
+                            LoadParameter.StartParameter(winType, new LoadParameter(showItem));
+                            winType.Show(this.GetNavigationBar());
+                        }
                     }
+                    #endregion
+
                 }
-                #endregion
-              
+            }
+            catch (Exception ex)
+            {
+                MessageTipEx.Show(ex);
             }
         }
         public bool CanAddBranchCommand(object parameter)
@@ -224,32 +232,40 @@ namespace Com.FirmLib.UI.Manufacturer
         [Command]
         public void AddProductCommand(object parameter)
         {
-            ManufactureParameter startParameter = new ManufactureParameter();
-            startParameter.Manufacture.Id = Id;          
-            WinProductEditor win = new WinProductEditor();
-            LoadParameter.StartParameter(win, new LoadParameter(startParameter));
-            win.Owner = this.GetWindow();
-            if (win.ShowDialog() == true)
+
+            try
             {
-                if (CurrentSelectedBrand != null)
-                {
-                    //理论上添加了该品牌的产品,才去更新
-                    LoadProdutItems(CurrentSelectedBrand.Id);
-                }
-               
-                if (win.ManageType)
+                ManufactureParameter startParameter = new ManufactureParameter();
+                startParameter.Manufacture.Id = Id;
+                WinProductEditor win = new WinProductEditor();
+                LoadParameter.StartParameter(win, new LoadParameter(startParameter));
+                win.Owner = this.GetWindow();
+                if (win.ShowDialog() == true)
                 {
-                    WinProductType winType = new WinProductType();
-                    ProductShowItem showItem = new ProductShowItem();
-                    showItem.VenderId = Id;
-                    showItem.BrandId = win.BrandId;
-                    showItem.ProductId = win.ProductId;
-                    //showItem.ProductName = "新产品名";//todo通过id获取产品名称
-                   
-                    LoadParameter.StartParameter(winType, new LoadParameter(showItem));
-                    winType.Show(this.GetNavigationBar());
+                    if (CurrentSelectedBrand != null)
+                    {
+                        //理论上添加了该品牌的产品,才去更新
+                        LoadProdutItems(CurrentSelectedBrand.Id);
+                    }
+
+                    if (win.ManageType)
+                    {
+                        WinProductType winType = new WinProductType();
+                        ProductShowItem showItem = new ProductShowItem();
+                        showItem.VenderId = Id;
+                        showItem.BrandId = win.BrandId;
+                        showItem.ProductId = win.ProductId;
+                        //showItem.ProductName = "新产品名";//todo通过id获取产品名称
+
+                        LoadParameter.StartParameter(winType, new LoadParameter(showItem));
+                        winType.Show(this.GetNavigationBar());
+                    }
                 }
             }
+            catch (Exception ex)
+            {
+                MessageTipEx.Show(ex);
+            }
         }
         public bool CanAddProductCommand(object parameter)
         {
@@ -297,24 +313,32 @@ namespace Com.FirmLib.UI.Manufacturer
         [Command]
         public void UpdateBranchCommand(object parameter)
         {
-            BrandShowItem item = parameter as BrandShowItem;
-            WinBrandEditor win = new WinBrandEditor();
-            LoadParameter.StartParameter(win, new LoadParameter(item));
-            win.Owner = this.GetWindow();
-            if (win.ShowDialog() == true)
+
+            try
             {
-                //如果是修改完成,根据Id去更新名称。如果是删除完成,则重新加载品牌信息
-                if (win.UseDelete)
-                {
-                    //更新品牌信息
-                    LoadBrandItems();
-                }
-                else
+                BrandShowItem item = parameter as BrandShowItem;
+                WinBrandEditor win = new WinBrandEditor();
+                LoadParameter.StartParameter(win, new LoadParameter(item));
+                win.Owner = this.GetWindow();
+                if (win.ShowDialog() == true)
                 {
-                    //更新BranchItem名称
-                    item.Name = GetBrandName(item.Id);
+                    //如果是修改完成,根据Id去更新名称。如果是删除完成,则重新加载品牌信息
+                    if (win.UseDelete)
+                    {
+                        //更新品牌信息
+                        LoadBrandItems();
+                    }
+                    else
+                    {
+                        //更新BranchItem名称
+                        item.Name = GetBrandName(item.Id);
+                    }
                 }
             }
+            catch (Exception ex)
+            {
+                MessageTipEx.Show(ex);
+            }
         }
         public bool CanUpdateBranchCommand(object parameter)
         {
@@ -329,12 +353,20 @@ namespace Com.FirmLib.UI.Manufacturer
         [Command]
         public void GoAssetCommand(object parameter)
         {
-            ProjectAssetShowItem item = parameter as ProjectAssetShowItem;
-            if (item == null)
-                return;
-            WinProjectAssetList win = new WinProjectAssetList();
-            LoadParameter.StartParameter(win, new LoadParameter(item));
-            win.Show(this.GetNavigationBar());
+
+            try
+            {
+                ProjectAssetShowItem item = parameter as ProjectAssetShowItem;
+                if (item == null)
+                    return;
+                WinProjectAssetList win = new WinProjectAssetList();
+                LoadParameter.StartParameter(win, new LoadParameter(item));
+                win.Show(this.GetNavigationBar());
+            }
+            catch (Exception ex)
+            {
+                MessageTipEx.Show(ex);
+            }
         }
         public bool CanGoAssetCommand(object parameter)
         {
@@ -349,12 +381,20 @@ namespace Com.FirmLib.UI.Manufacturer
         [Command]
         public void ManageTypeCommand(object parameter)
         {
-            ProductShowItem showItem = parameter as ProductShowItem;
-            if (showItem == null)
-                return;      
-            WinProductType win = new WinProductType();
-            LoadParameter.StartParameter(win, new LoadParameter(showItem));
-            win.Show(this.GetNavigationBar());
+
+            try
+            {
+                ProductShowItem showItem = parameter as ProductShowItem;
+                if (showItem == null)
+                    return;
+                WinProductType win = new WinProductType();
+                LoadParameter.StartParameter(win, new LoadParameter(showItem));
+                win.Show(this.GetNavigationBar());
+            }
+            catch (Exception ex)
+            {
+                MessageTipEx.Show(ex);
+            }
         }
         public bool CanManageTypeCommand(object parameter)
         {
@@ -369,13 +409,21 @@ namespace Com.FirmLib.UI.Manufacturer
         [Command]
         public void SaveCommand(object parameter)
         {
-            if (UpdateProduct())
+
+            try
             {
-                MessageTip.Show(this.GetWindow(), "保存成功");
+                if (UpdateProduct())
+                {
+                    MessageTip.Show(this.GetWindow(), "保存成功");
+                }
+                else
+                {
+                    MessageTip.Show(this.GetWindow(), "保存失败");
+                }
             }
-            else
+            catch (Exception ex)
             {
-                MessageTip.Show(this.GetWindow(), "保存失败");
+                MessageTipEx.Show(ex);
             }
         }
         public bool CanSaveCommand(object parameter)
@@ -391,23 +439,31 @@ namespace Com.FirmLib.UI.Manufacturer
         [Command]
         public void ScanRefTypesCommand  (object parameter)
         {
-            var showItem = parameter as RefVenderShowItem;
-            if (showItem == null)
-            {
-                return;
-            }
-            WinProductList win = new WinProductList();
-            bool isSeller = false;
-            if (this.SellerItems != null)
+
+            try
             {
-                  isSeller=this.SellerItems.Contains(showItem);
-            }
+                var showItem = parameter as RefVenderShowItem;
+                if (showItem == null)
+                {
+                    return;
+                }
+                WinProductList win = new WinProductList();
+                bool isSeller = false;
+                if (this.SellerItems != null)
+                {
+                    isSeller = this.SellerItems.Contains(showItem);
+                }
 
-            win.Title = isSeller ? "供应产品名录" : "维修产品名录";
-            win.Owner = this.GetWindow();
-            LoadParameter.StartParameter(win, new LoadParameter(showItem));
-            if (win.ShowDialog() == true)
+                win.Title = isSeller ? "供应产品名录" : "维修产品名录";
+                win.Owner = this.GetWindow();
+                LoadParameter.StartParameter(win, new LoadParameter(showItem));
+                if (win.ShowDialog() == true)
+                {
+                }
+            }
+            catch (Exception ex)
             {
+                MessageTipEx.Show(ex);
             }
         }
         public bool CanScanRefTypesCommand  (object parameter)
@@ -423,42 +479,50 @@ namespace Com.FirmLib.UI.Manufacturer
         [Command]
         public void RefreshCommand(object parameter)
         {
-            var item = parameter as ProjectAssetShowItem;
-            if (item != null)
+
+            try
             {
-                item.IsLoading = true;          
-                TaskUtil.StartSTATask((obj) =>
+                var item = parameter as ProjectAssetShowItem;
+                if (item != null)
                 {
-                    var useItem = obj as ProjectAssetShowItem;
-                    if (useItem == null)
-                        return;
-                    try
+                    item.IsLoading = true;
+                    TaskUtil.StartSTATask((obj) =>
                     {
-                        BllFactory<ProjectBll>.Instance.ProjectSync(useItem.ProjectId);
-                        Thread.Sleep(3000);//立即执行偶尔导致连接取消
-                        var projectAssetItems = BllFactory<ManufacturerBll>.Instance.GetProjectItems(Id);
-                        foreach (var dataItem in projectAssetItems)
+                        var useItem = obj as ProjectAssetShowItem;
+                        if (useItem == null)
+                            return;
+                        try
                         {
-                            if (dataItem.Id == useItem.ProjectId)
+                            BllFactory<ProjectBll>.Instance.ProjectSync(useItem.ProjectId);
+                            Thread.Sleep(3000);//立即执行偶尔导致连接取消
+                        var projectAssetItems = BllFactory<ManufacturerBll>.Instance.GetProjectItems(Id);
+                            foreach (var dataItem in projectAssetItems)
                             {
-                                useItem.AssetCount = dataItem.TotalCount.ToString();
+                                if (dataItem.Id == useItem.ProjectId)
+                                {
+                                    useItem.AssetCount = dataItem.TotalCount.ToString();
+                                }
                             }
                         }
-                    }
-                    catch (Exception ex)
-                    {
-                        MessageTipEx.Show(ex);
-                    }
+                        catch (Exception ex)
+                        {
+                            MessageTipEx.Show(ex);
+                        }
 
-                    finally
-                    {
+                        finally
+                        {
 
-                        useItem.IsLoading = false;
-                    }
-                }, item);
-            
-            }
+                            useItem.IsLoading = false;
+                        }
+                    }, item);
+
+                }
 
+            }
+            catch (Exception ex)
+            {
+                MessageTipEx.Show(ex);
+            }
            
         }
         public bool CanRefreshCommand(object parameter)

+ 29 - 13
MBI/FirmLib/Com.FirmLib.UI/Manufacturer/VmManufacturerEditor.cs

@@ -69,13 +69,21 @@ namespace Com.FirmLib.UI.Manufacturer
         [Command]
         public void AddCommand(object parameter)
         {
-          
-            if (!CreateManufacturer())
-                return;
-            ManagerManufacturer = false;
-            Window window = parameter as Window;
-            if (window != null)
-                window.DialogResult = true;
+
+
+            try
+            {
+                if (!CreateManufacturer())
+                    return;
+                ManagerManufacturer = false;
+                Window window = parameter as Window;
+                if (window != null)
+                    window.DialogResult = true;
+            }
+            catch (Exception ex)
+            {
+                MessageTipEx.Show(ex);
+            }
         }
         public bool CanAddCommand(object parameter)
         {
@@ -90,12 +98,20 @@ namespace Com.FirmLib.UI.Manufacturer
         [Command]
         public void AddAndManage(object parameter)
         {
-            if (!CreateManufacturer())
-                return;
-            ManagerManufacturer = true;
-            Window window = parameter as Window;
-            if (window != null)
-                window.DialogResult = true;
+
+            try
+            {
+                if (!CreateManufacturer())
+                    return;
+                ManagerManufacturer = true;
+                Window window = parameter as Window;
+                if (window != null)
+                    window.DialogResult = true;
+            }
+            catch (Exception ex)
+            {
+                MessageTipEx.Show(ex);
+            }
         }
         public bool CanAddAndManage(object parameter)
         {

+ 32 - 16
MBI/FirmLib/Com.FirmLib.UI/Manufacturer/VmProductEditor.cs

@@ -170,11 +170,19 @@ namespace Com.FirmLib.UI.Manufacturer
         [Command]
         public void AddCommand(object parameter)
         {
-            if (!CreateProduct())
-                return;
-            Window window = parameter as Window;
-            if (window != null)
-                window.DialogResult = true;
+
+            try
+            {
+                if (!CreateProduct())
+                    return;
+                Window window = parameter as Window;
+                if (window != null)
+                    window.DialogResult = true;
+            }
+            catch (Exception ex)
+            {
+                MessageTipEx.Show(ex);
+            }
         }
         public bool CanAddCommand(object parameter)
         {
@@ -189,12 +197,20 @@ namespace Com.FirmLib.UI.Manufacturer
         [Command]
         public void AddAndManageCommand(object parameter)
         {
-            if (!CreateProduct())
-                return;
-            this.ManageType = true;
-            Window window = parameter as Window;
-            if (window != null)
-                window.DialogResult = true;
+
+            try
+            {
+                if (!CreateProduct())
+                    return;
+                this.ManageType = true;
+                Window window = parameter as Window;
+                if (window != null)
+                    window.DialogResult = true;
+            }
+            catch (Exception ex)
+            {
+                MessageTipEx.Show(ex);
+            }
         }
         public bool CanAddAndManageCommand(object parameter)
         {
@@ -235,6 +251,11 @@ namespace Com.FirmLib.UI.Manufacturer
 
         private bool CreateProduct()
         {
+            if (string.IsNullOrWhiteSpace(this.CurrentBrandId))
+            {
+                MessageTip.Show(this.GetWindow(), "品牌不能为空");
+                return false;
+            }
             ProductItem item = new ProductItem();
             item.Id = ProductId ?? string.Empty;
             item.Name = this.ProductName;
@@ -248,11 +269,6 @@ namespace Com.FirmLib.UI.Manufacturer
 
                 ProductId = item.Id;
             }
-            //没有更新操作
-            //else
-            //{
-            //    result = BllFactory<ProductBll>.Instance.Update(item);
-            //}
             if (result)
             {
                 ProductId = item.Id;

+ 14 - 6
MBI/FirmLib/Com.FirmLib.UI/Manufacturer/VmProductType.cs

@@ -132,14 +132,22 @@ namespace Com.FirmLib.UI.Manufacturer
         [Command]
         public void AddTypeCommand(object parameter)
         {
-            var tempItem = new TypeShowItem();
-            tempItem.TypeName = "";
-            tempItem.Parameters = PropertyCollection.CreateCollection(RefDefinitions ?? new List<PropertyDefinition>());
-            foreach (var tempItemParameter in tempItem.Parameters)
+
+            try
+            {
+                var tempItem = new TypeShowItem();
+                tempItem.TypeName = "";
+                tempItem.Parameters = PropertyCollection.CreateCollection(RefDefinitions ?? new List<PropertyDefinition>());
+                foreach (var tempItemParameter in tempItem.Parameters)
+                {
+                    tempItemParameter.Value = "";
+                }
+                TypeItems.Add(tempItem);
+            }
+            catch (Exception ex)
             {
-                tempItemParameter.Value = "";
+                MessageTipEx.Show(ex);
             }
-            TypeItems.Add(tempItem);
         }
         public bool CanAddTypeCommand(object parameter)
         {

+ 18 - 10
MBI/FirmLib/Com.FirmLib.UI/Manufacturer/VmProjectAssetList.cs

@@ -68,16 +68,24 @@ namespace Com.FirmLib.UI.Manufacturer
         [Command]
         public void ScanAssetInfo(object parameter)
         {
-            AssetShowItem item = parameter as AssetShowItem;
-            if (item == null)
-                return;
-            AssetItem parItem = new AssetItem();
-            parItem.Id = item.Id;
-            parItem.ProjectId = item.ProjectId;
-            parItem.FamilyCode = item.Family;
-            string url = BllFactory<AssetBll>.Instance.GetAssetUrl(parItem);
-            //WinBrowser.Instance.Show("http://www.baidu.com", "资产信息");
-            WinBrowser.Instance.Show(url, "资产信息");
+
+            try
+            {
+                AssetShowItem item = parameter as AssetShowItem;
+                if (item == null)
+                    return;
+                AssetItem parItem = new AssetItem();
+                parItem.Id = item.Id;
+                parItem.ProjectId = item.ProjectId;
+                parItem.FamilyCode = item.Family;
+                string url = BllFactory<AssetBll>.Instance.GetAssetUrl(parItem);
+                //WinBrowser.Instance.Show("http://www.baidu.com", "资产信息");
+                WinBrowser.Instance.Show(url, "资产信息");
+            }
+            catch (Exception ex)
+            {
+                MessageTipEx.Show(ex);
+            }
         }
         public bool CanScanAssetInfo(object parameter)
         {

+ 9 - 1
MBI/FirmLib/Com.FirmLib.UI/Manufacturer/WinProductEditor.xaml

@@ -19,7 +19,15 @@
         <StackPanel Orientation="Vertical" HorizontalAlignment="Stretch">
             <Label  Style="{StaticResource ResourceKey={x:Static uc:CommonStyles.StarLableKey}}" Content="所属品牌:"></Label>
 
-            <ComboBox ItemsSource="{Binding Brands,Mode=OneWay}" DisplayMemberPath="Name" SelectedValuePath="Value" SelectedValue="{Binding CurrentBrandId,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"  Style="{StaticResource ResourceKey={x:Static uc:CommonStyles.ComboBoxKey}}" Margin="5">
+            <ComboBox ItemsSource="{Binding Brands,Mode=OneWay}" DisplayMemberPath="Name" SelectedValuePath="Value"   Style="{StaticResource ResourceKey={x:Static uc:CommonStyles.ComboBoxKey}}" Margin="5">
+                <ComboBox.SelectedValue>
+                    <Binding Path="CurrentBrandId" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged">
+                        <Binding.ValidationRules>
+                            <fw:RequireValidationRule ></fw:RequireValidationRule>
+                        </Binding.ValidationRules>
+                    </Binding>
+                </ComboBox.SelectedValue>
+               
             </ComboBox>
             <Label  Style="{StaticResource ResourceKey={x:Static uc:CommonStyles.StarLableKey}}" Content="产品名:"></Label>
 

+ 14 - 6
MBI/FirmLib/Com.FirmLib.UI/Seller/VmAddLossProductType.cs

@@ -67,13 +67,21 @@ namespace Com.FirmLib.UI.Seller
         [Command]
         public void OkCommand(object parameter)
         {
-            Window window = parameter as Window;
-            if (window != null)
+
+            try
+            {
+                Window window = parameter as Window;
+                if (window != null)
+                {
+                    var checkedItems = ProductTypes.Where(c => c.IsChecked).Select(c => c.RefObject).ToList();
+                    //设置需要处理的值
+                    window.SetRealResult<List<ProductTypeShowItem>>(checkedItems);
+                    window.DialogResult = true;
+                }
+            }
+            catch (Exception ex)
             {
-                var checkedItems = ProductTypes.Where(c => c.IsChecked).Select(c => c.RefObject).ToList();
-                //设置需要处理的值
-                window.SetRealResult<List<ProductTypeShowItem>>(checkedItems);
-                window.DialogResult = true;
+                MessageTipEx.Show(ex);
             }
         }
         public bool CanOkCommand(object parameter)

+ 10 - 1
MBI/FirmLib/Com.FirmLib.UI/Seller/VmMultiProductTypeSelector.cs

@@ -92,7 +92,16 @@ namespace Com.FirmLib.UI.Seller
         [Command]
         public void AddCommand(object parameter)
         {
-            AddTypeList(parameter as Window);
+
+            try
+            {
+                AddTypeList(parameter as Window);
+            }
+            catch (Exception ex)
+            {
+                MessageTipEx.Show(ex);
+            }
+            
         }
         public bool CanAddCommand(object parameter)
         {

+ 54 - 30
MBI/FirmLib/Com.FirmLib.UI/Seller/VmSellerBaseInfo.cs

@@ -85,22 +85,30 @@ namespace Com.FirmLib.UI.Seller
         [Command]
         public void AddCommand(object parameter)
         {
-            WinSellerEditor win = new WinSellerEditor();
-            win.Owner = this.GetWindow();
-            if (win.ShowDialog() == true)
+
+            try
             {
-                if (win.IsManage)
-                {
-                    WinSellerInfo winSellerInfo = new WinSellerInfo();
-                    LoadParameter.StartParameter(winSellerInfo, new LoadParameter(win.SellerId));
-                    winSellerInfo.Show(this.GetNavigationBar());
-                }
-                else
+                WinSellerEditor win = new WinSellerEditor();
+                win.Owner = this.GetWindow();
+                if (win.ShowDialog() == true)
                 {
-                    //todo 刷新界面
-                    LoadItems();
-                }
+                    if (win.IsManage)
+                    {
+                        WinSellerInfo winSellerInfo = new WinSellerInfo();
+                        LoadParameter.StartParameter(winSellerInfo, new LoadParameter(win.SellerId));
+                        winSellerInfo.Show(this.GetNavigationBar());
+                    }
+                    else
+                    {
+                        //todo 刷新界面
+                        LoadItems();
+                    }
 
+                }
+            }
+            catch (Exception ex)
+            {
+                MessageTipEx.Show(ex);
             }
         }
         public bool CanAddCommand(object parameter)
@@ -117,18 +125,26 @@ namespace Com.FirmLib.UI.Seller
         [Command]
         public void DeleteCommand(object parameter)
         {
-            SellerShowItem item = parameter as SellerShowItem;
-            if (item == null)
-                return;
-           var result= MessageTip.Show(this.GetWindow(), "是否要删除", "提示", MessageBoxButton.YesNo);
-            if (result == MessageBoxResult.Yes)
+
+            try
             {
-                //todo 网络api处理
-                DeleteItem(item.Id);
-                //todo 刷新窗体
-                LoadItems();
-                //todo 删除操作
-                //Sellers.Remove(item);
+                SellerShowItem item = parameter as SellerShowItem;
+                if (item == null)
+                    return;
+                var result = MessageTip.Show(this.GetWindow(), "是否要删除", "提示", MessageBoxButton.YesNo);
+                if (result == MessageBoxResult.Yes)
+                {
+                    //todo 网络api处理
+                    DeleteItem(item.Id);
+                    //todo 刷新窗体
+                    LoadItems();
+                    //todo 删除操作
+                    //Sellers.Remove(item);
+                }
+            }
+            catch (Exception ex)
+            {
+                MessageTipEx.Show(ex);
             }
         }
         public bool CanDeleteCommand(object parameter)
@@ -142,12 +158,20 @@ namespace Com.FirmLib.UI.Seller
         [Command]
         public void ManageCommand(object parameter)
         {
-            SellerShowItem item = parameter as SellerShowItem;
-            if (item == null)
-                return;
-            WinSellerInfo win = new WinSellerInfo();
-            LoadParameter.StartParameter(win, new LoadParameter(item.Id));
-            win.Show(this.GetNavigationBar());
+
+            try
+            {
+                SellerShowItem item = parameter as SellerShowItem;
+                if (item == null)
+                    return;
+                WinSellerInfo win = new WinSellerInfo();
+                LoadParameter.StartParameter(win, new LoadParameter(item.Id));
+                win.Show(this.GetNavigationBar());
+            }
+            catch (Exception ex)
+            {
+                MessageTipEx.Show(ex);
+            }
         }
         public bool CanManageCommand(object parameter)
         {

+ 27 - 11
MBI/FirmLib/Com.FirmLib.UI/Seller/VmSellerEditor.cs

@@ -80,11 +80,19 @@ namespace Com.FirmLib.UI.Seller
         [Command]
         public void AddCommand(object parameter)
         {
-            if (!CreateSeller())
-                return;
-            Window window = parameter as Window;
-            if (window != null)
-                window.DialogResult = true;
+
+            try
+            {
+                if (!CreateSeller())
+                    return;
+                Window window = parameter as Window;
+                if (window != null)
+                    window.DialogResult = true;
+            }
+            catch (Exception ex)
+            {
+                MessageTipEx.Show(ex);
+            }
         }
         public bool CanAddCommand(object parameter)
         {
@@ -99,12 +107,20 @@ namespace Com.FirmLib.UI.Seller
         [Command]
         public void AddAndManageCommand(object parameter)
         {
-            if (!CreateSeller())
-                return;
-            IsManage = true;
-            Window window = parameter as Window;
-            if (window != null)
-                window.DialogResult = true;
+
+            try
+            {
+                if (!CreateSeller())
+                    return;
+                IsManage = true;
+                Window window = parameter as Window;
+                if (window != null)
+                    window.DialogResult = true;
+            }
+            catch (Exception ex)
+            {
+                MessageTipEx.Show(ex);
+            }
         }
         public bool CanAddAndManageCommand(object parameter)
         {

+ 99 - 59
MBI/FirmLib/Com.FirmLib.UI/Seller/VmSellerInfo.cs

@@ -142,9 +142,17 @@ namespace Com.FirmLib.UI.Seller
         [Command]
         public void AddContract(object parameter)
         {
-            WinSellerProjectContract win = new WinSellerProjectContract();
-            LoadParameter.StartParameter(win, new LoadParameter(new VenderProjectParameter(Id)));
-            win.Show(this.GetNavigationBar());
+
+            try
+            {
+                WinSellerProjectContract win = new WinSellerProjectContract();
+                LoadParameter.StartParameter(win, new LoadParameter(new VenderProjectParameter(Id)));
+                win.Show(this.GetNavigationBar());
+            }
+            catch (Exception ex)
+            {
+                MessageTipEx.Show(ex);
+            }
         }
         public bool CanAddContract(object parameter)
         {
@@ -158,15 +166,23 @@ namespace Com.FirmLib.UI.Seller
         [Command]
         public void GoToProject(object parameter)
         {
-            ProjectRelationShowItem item = parameter as ProjectRelationShowItem;
-            if (item == null)
-                return;
-            WinSellerProjectInfo win = new WinSellerProjectInfo();
-            var p = new SellerParameter();
-            p.Project.Id = item.ProjectId;
-            p.Seller.Id = Id;
-            LoadParameter.StartParameter(win, new LoadParameter(p));
-            win.Show(this.GetNavigationBar());
+
+            try
+            {
+                ProjectRelationShowItem item = parameter as ProjectRelationShowItem;
+                if (item == null)
+                    return;
+                WinSellerProjectInfo win = new WinSellerProjectInfo();
+                var p = new SellerParameter();
+                p.Project.Id = item.ProjectId;
+                p.Seller.Id = Id;
+                LoadParameter.StartParameter(win, new LoadParameter(p));
+                win.Show(this.GetNavigationBar());
+            }
+            catch (Exception ex)
+            {
+                MessageTipEx.Show(ex);
+            }
         }
         public bool CanGoToProject(object parameter)
         {
@@ -193,15 +209,23 @@ namespace Com.FirmLib.UI.Seller
         [Command]
         public void AddProductTypeCommand(object parameter)
         {
-            //抽象成树形结构,去维护现在的层级数据
-            WinMultiProductTypeSelector win = new WinMultiProductTypeSelector();
-            win.Owner = this.GetWindow();
-            LoadParameter.StartParameter(win, new LoadParameter(Id));
-            if (win.ShowDialog() == true)
+
+            try
             {
-                ///todo 是不是要刷新,因为可能连续添加;
-                //局部刷新
-                LoadBrandItems(Id);
+                //抽象成树形结构,去维护现在的层级数据
+                WinMultiProductTypeSelector win = new WinMultiProductTypeSelector();
+                win.Owner = this.GetWindow();
+                LoadParameter.StartParameter(win, new LoadParameter(Id));
+                if (win.ShowDialog() == true)
+                {
+                    ///todo 是不是要刷新,因为可能连续添加;
+                    //局部刷新
+                    LoadBrandItems(Id);
+                }
+            }
+            catch (Exception ex)
+            {
+                MessageTipEx.Show(ex);
             }
 
         }
@@ -216,23 +240,31 @@ namespace Com.FirmLib.UI.Seller
         [Command]
         public void DeleteCommand(object parameter)
         {
-            TreeNavigationItem<BasePropertyChanged> item = parameter as TreeNavigationItem<BasePropertyChanged>;
-            if (item == null)
-                return;
-            var result = MessageTip.Show(this.GetWindow(), "是否要删除", "提示", MessageBoxButton.YesNo);
-            if (result == MessageBoxResult.Yes)
+
+            try
             {
-                var typeShow = item.RefItem as TypeShowItem;
-                bool flag = false;
-                if (typeShow!=null)
-                {
-                    flag=DeleteItem(Id, typeShow.ProductTypeId);
-                }            
-                if (flag&&ProductTypes != null)
+                TreeNavigationItem<BasePropertyChanged> item = parameter as TreeNavigationItem<BasePropertyChanged>;
+                if (item == null)
+                    return;
+                var result = MessageTip.Show(this.GetWindow(), "是否要删除", "提示", MessageBoxButton.YesNo);
+                if (result == MessageBoxResult.Yes)
                 {
-                    ProductTypes.Remove(item);
+                    var typeShow = item.RefItem as TypeShowItem;
+                    bool flag = false;
+                    if (typeShow != null)
+                    {
+                        flag = DeleteItem(Id, typeShow.ProductTypeId);
+                    }
+                    if (flag && ProductTypes != null)
+                    {
+                        ProductTypes.Remove(item);
+                    }
                 }
             }
+            catch (Exception ex)
+            {
+                MessageTipEx.Show(ex);
+            }
         }
         public bool CanDeleteCommand(object parameter)
         {
@@ -246,43 +278,51 @@ namespace Com.FirmLib.UI.Seller
         [Command]
         public void RefreshCommand(object parameter)
         {
-            var item = parameter as ProjectRelationShowItem;
-            if (item != null)
+
+            try
             {
-                item.IsLoading = true;
-                TaskUtil.StartSTATask((obj) =>
-               {
-                   var useItem = obj as ProjectRelationShowItem;
-                   if (useItem == null)
-                       return;
-                   try
+                var item = parameter as ProjectRelationShowItem;
+                if (item != null)
+                {
+                    item.IsLoading = true;
+                    TaskUtil.StartSTATask((obj) =>
                    {
-                       BllFactory<ProjectBll>.Instance.ProjectSync(useItem.ProjectId);
-                       Thread.Sleep(3000);//立即执行偶尔导致连接取消
-                       var projects = BllFactory<SellerBll>.Instance.GetProjectItems(Id);
-                       foreach (var project in projects)
+                       var useItem = obj as ProjectRelationShowItem;
+                       if (useItem == null)
+                           return;
+                       try
                        {
-                           if (project.Id == useItem.ProjectId)
+                           BllFactory<ProjectBll>.Instance.ProjectSync(useItem.ProjectId);
+                           Thread.Sleep(3000);//立即执行偶尔导致连接取消
+                       var projects = BllFactory<SellerBll>.Instance.GetProjectItems(Id);
+                           foreach (var project in projects)
                            {
-                               useItem.ContractCount = project.ContractCount;
-                               useItem.AssetCount = project.TotalCount;
+                               if (project.Id == useItem.ProjectId)
+                               {
+                                   useItem.ContractCount = project.ContractCount;
+                                   useItem.AssetCount = project.TotalCount;
+                               }
                            }
                        }
-                   }
-                   catch (Exception ex)
-                   {
-                       MessageTipEx.Show(ex);
-                   }
+                       catch (Exception ex)
+                       {
+                           MessageTipEx.Show(ex);
+                       }
 
-                   finally
-                   {
+                       finally
+                       {
 
-                       useItem.IsLoading = false;
-                   }
+                           useItem.IsLoading = false;
+                       }
 
 
-               }, item);
+                   }, item);
 
+                }
+            }
+            catch (Exception ex)
+            {
+                MessageTipEx.Show(ex);
             }
 
 

+ 102 - 62
MBI/FirmLib/Com.FirmLib.UI/Seller/VmSellerProjectContract.cs

@@ -170,10 +170,18 @@ namespace Com.FirmLib.UI.Seller
         [Command]
         public void ScanAssetInfo(object parameter)
         {
-            AssetShowItem item = parameter as AssetShowItem;
-            if (item == null)
-                return;
-            AssetShowItemUtils.ShowAssetDetail(item);
+
+            try
+            {
+                AssetShowItem item = parameter as AssetShowItem;
+                if (item == null)
+                    return;
+                AssetShowItemUtils.ShowAssetDetail(item);
+            }
+            catch (Exception ex)
+            {
+                MessageTipEx.Show(ex);
+            }
         }
         public bool CanScanAssetInfo(object parameter)
         {
@@ -186,14 +194,22 @@ namespace Com.FirmLib.UI.Seller
         [Command]
         public void SaveCommand(object parameter)
         {
-            if (CreateProjectInfo()&&CreateAsset())
+
+            try
             {
-                AfterSuccessSave();
-                MessageTip.Show(this.GetWindow(), "保存成功");
+                if (CreateProjectInfo() && CreateAsset())
+                {
+                    AfterSuccessSave();
+                    MessageTip.Show(this.GetWindow(), "保存成功");
+                }
+                else
+                {
+                    MessageTip.Show(this.GetWindow(), "保存失败");
+                }
             }
-            else
+            catch (Exception ex)
             {
-                MessageTip.Show(this.GetWindow(), "保存失败");
+                MessageTipEx.Show(ex);
             }
             
         }
@@ -208,30 +224,38 @@ namespace Com.FirmLib.UI.Seller
         [Command]
         public void DeleteCommand(object parameter)
         {
-            AssetShowItem showItem = parameter as AssetShowItem;
-            if (showItem == null)
-                return;
-            var result = MessageTip.Show(this.GetWindow(), "是否要删除", "提示", MessageBoxButton.YesNo);
-            if (result == MessageBoxResult.Yes)
+
+            try
             {
-                bool flag = false;
-                if (showItem.SellerId == SellerId&&showItem.SellerContractNo==ContractNo)
-                {
-                    flag = AssetManager.DeleteSellerAssets(SystemProjectId, new List<string>() { showItem.Id });
-                }
-                else
-                {
-                    flag = true;
-                }
-                if (flag)
-                {
-                    this.RefAssetItems.Remove(showItem);
-                }
-                else
+                AssetShowItem showItem = parameter as AssetShowItem;
+                if (showItem == null)
+                    return;
+                var result = MessageTip.Show(this.GetWindow(), "是否要删除", "提示", MessageBoxButton.YesNo);
+                if (result == MessageBoxResult.Yes)
                 {
-                    MessageTip.Show(this.GetWindow(), "删除失败");
-                }
+                    bool flag = false;
+                    if (showItem.SellerId == SellerId && showItem.SellerContractNo == ContractNo)
+                    {
+                        flag = AssetManager.DeleteSellerAssets(SystemProjectId, new List<string>() { showItem.Id });
+                    }
+                    else
+                    {
+                        flag = true;
+                    }
+                    if (flag)
+                    {
+                        this.RefAssetItems.Remove(showItem);
+                    }
+                    else
+                    {
+                        MessageTip.Show(this.GetWindow(), "删除失败");
+                    }
 
+                }
+            }
+            catch (Exception ex)
+            {
+                MessageTipEx.Show(ex);
             }
         }
         public bool CanDeleteCommand(object parameter)
@@ -245,25 +269,33 @@ namespace Com.FirmLib.UI.Seller
         [Command]
         public void CreateAssetCommand(object parameter)
         {
-            WinSupplyAssetCreater win = new WinSupplyAssetCreater();
-            SelectAssetContext context = new SelectAssetContext();
-           context.ProjectId = SystemProjectId;
-            context.VenderId = SellerId;
-            LoadParameter.StartParameter(win, new LoadParameter(context));
-            if (win.ShowDialog() == true)
+
+            try
             {
-                if (RefAssetItems == null)
-                {
-                    RefAssetItems = new ObservableCollection<AssetShowItem>();
-                }
-                var addRelations = context.AddedItems;
-                foreach (var item in addRelations)
+                WinSupplyAssetCreater win = new WinSupplyAssetCreater();
+                SelectAssetContext context = new SelectAssetContext();
+                context.ProjectId = SystemProjectId;
+                context.VenderId = SellerId;
+                LoadParameter.StartParameter(win, new LoadParameter(context));
+                if (win.ShowDialog() == true)
                 {
-                    if (RefAssetItems.Any(c => c.Id == item.Id))
-                        return;
-                    RefAssetItems.Add(item);
+                    if (RefAssetItems == null)
+                    {
+                        RefAssetItems = new ObservableCollection<AssetShowItem>();
+                    }
+                    var addRelations = context.AddedItems;
+                    foreach (var item in addRelations)
+                    {
+                        if (RefAssetItems.Any(c => c.Id == item.Id))
+                            return;
+                        RefAssetItems.Add(item);
+                    }
                 }
             }
+            catch (Exception ex)
+            {
+                MessageTipEx.Show(ex);
+            }
         }
         public bool CanCreateAssetCommand(object parameter)
         {
@@ -278,32 +310,40 @@ namespace Com.FirmLib.UI.Seller
         [Command]
         public void SelectAssetCommand(object parameter)
         {
-            WinSupplyAssetSelector win = new WinSupplyAssetSelector();
-            win.Owner = this.GetWindow();
-            SelectAssetContext context = new SelectAssetContext();
-            context.ProjectId = SystemProjectId;
-            context.VenderId = SellerId;
-            if (RefAssetItems == null)
-            {
-                RefAssetItems = new ObservableCollection<AssetShowItem>();
-            }
 
-            context.ContainIds = new List<string>(RefAssetItems.Select(p => p.Id));
-            LoadParameter.StartParameter(win, new LoadParameter(context));
-            if (win.ShowDialog() == true)
+            try
             {
+                WinSupplyAssetSelector win = new WinSupplyAssetSelector();
+                win.Owner = this.GetWindow();
+                SelectAssetContext context = new SelectAssetContext();
+                context.ProjectId = SystemProjectId;
+                context.VenderId = SellerId;
                 if (RefAssetItems == null)
                 {
                     RefAssetItems = new ObservableCollection<AssetShowItem>();
                 }
-                var addRelations = context.AddedItems;
-                foreach (var item in addRelations)
+
+                context.ContainIds = new List<string>(RefAssetItems.Select(p => p.Id));
+                LoadParameter.StartParameter(win, new LoadParameter(context));
+                if (win.ShowDialog() == true)
                 {
-                    if (RefAssetItems.Any(c => c.Id == item.Id))
-                        return;
-                    RefAssetItems.Add(item);
+                    if (RefAssetItems == null)
+                    {
+                        RefAssetItems = new ObservableCollection<AssetShowItem>();
+                    }
+                    var addRelations = context.AddedItems;
+                    foreach (var item in addRelations)
+                    {
+                        if (RefAssetItems.Any(c => c.Id == item.Id))
+                            return;
+                        RefAssetItems.Add(item);
+                    }
                 }
             }
+            catch (Exception ex)
+            {
+                MessageTipEx.Show(ex);
+            }
         }
         public bool CanSelectAssetCommand(object parameter)
         {

+ 69 - 37
MBI/FirmLib/Com.FirmLib.UI/Seller/VmSellerProjectInfo.cs

@@ -127,10 +127,18 @@ namespace Com.FirmLib.UI.Seller
         [Command]
         public void ScanAssetInfo(object parameter)
         {
-            AssetShowItem item = parameter as AssetShowItem;
-            if (item == null)
-                return;
-            AssetShowItemUtils.ShowAssetDetail(item);
+
+            try
+            {
+                AssetShowItem item = parameter as AssetShowItem;
+                if (item == null)
+                    return;
+                AssetShowItemUtils.ShowAssetDetail(item);
+            }
+            catch (Exception ex)
+            {
+                MessageTipEx.Show(ex);
+            }
         }
         public bool CanScanAssetInfo(object parameter)
         {
@@ -143,15 +151,23 @@ namespace Com.FirmLib.UI.Seller
         [Command]
         public void SaveCommand(object parameter)
         {
-            bool flag = UpdateAsset();
-            if (flag)
+
+            try
             {
-                AfterSuccessSave();
-                MessageTip.Show(this.GetWindow(), "保存成功");
+                bool flag = UpdateAsset();
+                if (flag)
+                {
+                    AfterSuccessSave();
+                    MessageTip.Show(this.GetWindow(), "保存成功");
+                }
+                else
+                {
+                    MessageTip.Show(this.GetWindow(), "保存失败");
+                }
             }
-            else
+            catch (Exception ex)
             {
-                MessageTip.Show(this.GetWindow(), "保存失败");
+                MessageTipEx.Show(ex);
             }
         }
         public bool CanSaveCommand(object parameter)
@@ -205,10 +221,18 @@ namespace Com.FirmLib.UI.Seller
         [Command]
         public void AddSupplyContract(object parameter)
         {
-            //添加供应合同
-            WinSellerProjectContract win = new WinSellerProjectContract();
-            LoadParameter.StartParameter(win, new LoadParameter(new VenderProjectParameter(SellerId,ProjectId)));
-            win.Show(this.GetNavigationBar());
+
+            try
+            {
+                //添加供应合同
+                WinSellerProjectContract win = new WinSellerProjectContract();
+                LoadParameter.StartParameter(win, new LoadParameter(new VenderProjectParameter(SellerId, ProjectId)));
+                win.Show(this.GetNavigationBar());
+            }
+            catch (Exception ex)
+            {
+                MessageTipEx.Show(ex);
+            }
         }
         public bool CanAddSupplyContract(object parameter)
         {
@@ -222,32 +246,40 @@ namespace Com.FirmLib.UI.Seller
         [Command]
         public void DeleteCommand(object parameter)
         {
-            AssetShowItem showItem = parameter as AssetShowItem;
-            if (showItem == null)
-                return;
-         
-            var result = MessageTip.Show(this.GetWindow(), "是否要删除", "提示", MessageBoxButton.YesNo);
-            if (result == MessageBoxResult.Yes)
+
+            try
             {
-                bool flag = false;
-                if (showItem.SellerId == SellerId)
-                {
-                    flag = AssetManager.DeleteSellerAssets(ProjectId, new List<string>() { showItem.Id });
-                }
-                else
-                {
-                    flag = true;
-                }
-              
-                if (flag)
-                {
-                    this.AssetItems.Remove(showItem);
-                }
-                else
+                AssetShowItem showItem = parameter as AssetShowItem;
+                if (showItem == null)
+                    return;
+
+                var result = MessageTip.Show(this.GetWindow(), "是否要删除", "提示", MessageBoxButton.YesNo);
+                if (result == MessageBoxResult.Yes)
                 {
-                    MessageTip.Show(this.GetWindow(), "删除失败");
-                }
+                    bool flag = false;
+                    if (showItem.SellerId == SellerId)
+                    {
+                        flag = AssetManager.DeleteSellerAssets(ProjectId, new List<string>() { showItem.Id });
+                    }
+                    else
+                    {
+                        flag = true;
+                    }
 
+                    if (flag)
+                    {
+                        this.AssetItems.Remove(showItem);
+                    }
+                    else
+                    {
+                        MessageTip.Show(this.GetWindow(), "删除失败");
+                    }
+
+                }
+            }
+            catch (Exception ex)
+            {
+                MessageTipEx.Show(ex);
             }
         }
         public bool CanDeleteCommand(object parameter)

+ 12 - 4
MBI/FirmLib/Com.FirmLib.UI/Seller/VmSupplyContractNoSelector.cs

@@ -117,11 +117,19 @@ namespace Com.FirmLib.UI.Seller
         [Command]
         public void GetContractNo(object parameter)
         {
-            Window window = parameter as Window;
-            if (window != null)
+
+            try
+            {
+                Window window = parameter as Window;
+                if (window != null)
+                {
+                    window.SetRealResult<string>(UseNo);
+                    window.DialogResult = true;
+                }
+            }
+            catch (System.Exception ex)
             {
-                window.SetRealResult<string>(UseNo);
-                window.DialogResult = true;
+                MessageTipEx.Show(ex);
             }
                 
         }

+ 18 - 0
MBI/MBIResource/Config/HttpSetting - 亚心.ini

@@ -0,0 +1,18 @@
+[Configure]
+SaasLocalHost = http://133.0.13.136:8080/
+DataPlatformLocalHost = http://133.0.3.115:8888/
+ScanBuildingLocalHost = http://133.0.3.116:8080/ScanBuilding/
+Html5ImageLocalHost = http://133.0.3.116:8890/
+Html5DetailLocalHost = http://133.0.3.116:8889/#/
+Html5ScanLocalHost = http://133.0.3.116:8888/#/
+OssClientFileKey = test/files/revit/
+GoodHandLocalHost = http://133.0.3.115:8888/godhand/
+GplotViewHost = http://133.0.3.116:8888/#/
+ImageServiceLocalHost = http://133.0.3.115:8888/
+
+VenderAddress=http://133.0.3.115:8888/venders
+DependencyAddress=http://133.0.3.115:8888/venders-dp
+EquipmentFamilyAddress=http://133.0.3.115:8888/data-platform-3
+FileAddress=http://133.0.3.115:8888
+H5Address=http://133.0.3.116:8889/#
+

+ 1 - 1
MBI/MBIResource/Config/HttpSetting - 亚投行.ini

@@ -1,5 +1,5 @@
 [Configure]
-SaasLocalHost = http://192.168.30.96:8080/
+SaasLocalHost = http://39.96.187.128:8081/
 DataPlatformLocalHost = http://39.96.187.128:28888/
 ScanBuildingLocalHost = http://39.96.187.128:8080/ScanBuilding/
 Html5ImageLocalHost = http://39.96.187.128:8890/

+ 1 - 0
MBI/MBIResource/Config/MBI.config

@@ -2,5 +2,6 @@
 <configuration>
   <appSettings>
     <add key="HttpSetting" value="HttpSetting.ini"/>
+   <add key="UpDownFlag" value="0"/>
   </appSettings>
 </configuration>

+ 53 - 2
MBI/SAGA.DotNetUtils/Extend/ConfigurationUtil.cs

@@ -13,15 +13,56 @@ using System.Linq;
 using System.Reflection;
 using System.Text;
 using System.Threading.Tasks;
+using SAGA.DotNetUtils.Utilities;
 
 namespace SAGA.DotNetUtils.Extend
 {
     public static class ConfigurationUtil
     {
+        #region 默认路径持久化保存,应对向revit这种,启动之后设置,然后又跳转到其他程序的情况
+        private static string GetDefuatPathLocation()
+        {
+            return CommonUtil.GetPath(typeof(ConfigurationUtil), ".txt");
+        }
+        private static bool SavePersistenceDefuatPath(string defualtPath)
+        {
+            var path = GetDefuatPathLocation();
+            if (!string.IsNullOrWhiteSpace(path))
+            {
+                var directory = Directory.GetParent(path);
+                if (!directory.Exists)
+                {
+                    directory.Create();
+                }
+                File.WriteAllText(path, defualtPath);
+                return true;
+            }
+            return false;
+        }
+        private static string GetPersistencetDefuatPath()
+        {
+            var path = GetDefuatPathLocation();
+            if (!CommonUtil.InvalidFilePath(path))
+            {
+                return File.ReadAllText(path); ;
+            }
+            return null;
+        }
+        #endregion
+
+        private static string m_DefaultPath;
         private static string GetDefaultPath()
         {
-            string defaultPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "BaseSettings.config");
-            return defaultPath;
+            var defualtPath = m_DefaultPath;
+            if (CommonUtil.InvalidFilePath(defualtPath))
+            {
+                defualtPath = GetPersistencetDefuatPath();
+            }
+            if (CommonUtil.InvalidFilePath(defualtPath))
+            {
+                defualtPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "BaseSettings.config");
+            }            
+            return defualtPath;
         }
         private static Configuration m_Default;
         /// <summary>
@@ -71,6 +112,16 @@ namespace SAGA.DotNetUtils.Extend
             File.Copy(path, GetDefaultPath(),true);
             return true;
         }
+        public static bool SetDefaultPath(string path)
+        {
+            if (!File.Exists(path))
+            {
+                return false;
+            }
+            m_DefaultPath = path;
+            SavePersistenceDefuatPath(path);
+            return true;
+        }
         public static string GetSettingValue(this Configuration config,string appsettingKey)
         {
             try

+ 6 - 0
MBI/SAGA.DotNetUtils/Utilities/CommonUtil.cs

@@ -9,6 +9,7 @@ using System;
 using System.Collections.Generic;
 using System.IO;
 using System.Linq;
+using System.Reflection;
 using System.Text;
 using System.Threading.Tasks;
 
@@ -31,5 +32,10 @@ namespace SAGA.DotNetUtils.Utilities
             string fileName = type.Name + extensionName;
             return Path.Combine(basePath, md5, fileName);
         }
+
+        public static bool InvalidFilePath(string filePath)
+        {
+            return string.IsNullOrWhiteSpace(filePath) || !File.Exists(filePath);
+        }
     }
 }

+ 1 - 1
MBI/SAGA.GplotDrawData/View/WinMachineRoom.xaml.cs

@@ -21,7 +21,7 @@ namespace SAGA.GplotDrawData.View
         public WinMachineRoom()
         {
             InitializeComponent();
-            ucShowElement.RegisterJsObject("wpfEvent", this);
+           // ucShowElement.RegisterJsObject("wpfEvent", this);
         }
         protected override void OnLoaded(object sender, RoutedEventArgs e)
         {

+ 1 - 1
MBI/SAGA.MBI/App.xaml.cs

@@ -78,7 +78,7 @@ namespace SAGA.MBI
         public static void InitApp()
         {
             MessageManager.InitMessageMap();
-            ConfigurationUtil.SaveToDefault(Path.Combine(MBIConst.MBIResourcePath, "Config", "MBI.config"));
+            ConfigurationUtil.SetDefaultPath(Path.Combine(MBIConst.MBIResourcePath, "Config", "MBI.config"));
         }
     }
 }

+ 157 - 0
MBI/SAGA.MBI/RequestData/FileContentTransferUnit.cs

@@ -0,0 +1,157 @@
+/*-------------------------------------------------------------------------
+ * 功能描述:FileContentTransferUnit
+ * 作者:xulisong
+ * 创建时间: 2019/4/23 9:53:09
+ * 版本号:v1.0
+ *  -------------------------------------------------------------------------*/
+
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.IO;
+using System.Linq;
+using System.Net;
+using System.Text;
+using System.Threading.Tasks;
+using Aliyun.OSS;
+using Newtonsoft.Json.Linq;
+using SAGA.DotNetUtils.Encrypt;
+using SAGA.DotNetUtils.FileOperate;
+using SAGA.DotNetUtils.Logger;
+using SAGA.DotNetUtils.Others;
+using SAGA.MBI.Common;
+using SAGA.MBI.FileStream;
+using SAGA.MBI.Utilities;
+
+namespace SAGA.MBI.RequestData
+{
+    public class FileContentTransferUnit
+    {
+        #region 生成Url地址
+        public static string DownloadFileUrl(FileServiceSetting setting, string key)
+        {
+            var url =
+                $"{MBIConst.ImageServiceLocalHost}image-service/common/file_get/{key}?systemId={setting.SystemId}";
+            return url;
+        }
+
+        public static string UploadFileUrl(FileServiceSetting setting, string key)
+        {
+            string url =
+                $"{MBIConst.ImageServiceLocalHost}image-service/common/file_upload?systemId={setting.SystemId}&secret={setting.Secret}&key={key}&overwrite=true";
+            return url;
+        }
+        public static string DownloadFileUrl(string key)
+        {
+            return DownloadFileUrl(FileServiceSetting.RevitSetting, key);
+        }
+        public static string UploadFileUrl(string key)
+        {
+
+            return UploadFileUrl(FileServiceSetting.RevitSetting, key);
+        } 
+        #endregion
+        /// <summary>
+        /// 下载指定文件到指定
+        /// </summary>
+        /// <returns></returns>
+        public static bool DownLoadFileAsync(Tuple<string, int, string> tuple, int count, int cur)
+        {
+            bool result = false;
+            string fullPath = tuple.Item1;
+            string floorName = tuple.Item3;
+            string cloudName = CommonTool.GetCloudRevitName(fullPath);
+            int state = tuple.Item2;
+            if (state == 2)
+                FloorFileOperate.BakFile(fullPath);
+            try
+            {
+                var url = DownloadFileUrl(cloudName);
+                GetFlieContent fileContent = new GetFlieContent(url);
+                #region 进度管理
+                long stargIndex = 0;
+                UpLoadFileRequest.ShowDownloadWindow(tuple.Item3, fullPath, count, cur);
+                fileContent.TransferProgress += (s, args) =>
+                {
+                    var tempTrans = stargIndex + args.TransferredBytes;
+                    var tempTotal = stargIndex + args.TotalBytes;
+                    var currentData = Math.Round(((double) tempTrans) / tempTotal * 100d, 3);
+                    Debug.WriteLine("ProgressCallback - TotalBytes:{0}M, TransferredBytes:{1}M,上传百分比:{2}%",
+                        Math.Round(tempTotal / 1024d / 1024, 3), Math.Round(tempTrans / 1024d / 1024, 3), currentData);
+                    var window = UpLoadFileRequest.GetProcessWin();
+                    window?.Update(currentData);
+                    if (tempTrans >= tempTotal && window != null && window.Count == window.Cur)
+                    {
+                        UpLoadFileRequest.CloseDownloadWin(true, false);
+                    }
+                };
+              #endregion
+                var bytes=fileContent.GetContent();
+                FileStreamOperate.WriteFile(bytes.ToArray(), fullPath);
+                result = true;
+            }
+            catch (Exception ex)
+            {
+                MessageShowBase.Infomation("Revit文件下载失败!\r\n" + ex.Message + "\r\n" + ex.StackTrace);
+                result = false;
+                UpLoadFileRequest.CloseDownloadWin(result, false);
+            }
+            return result;
+        }
+        /// <summary>
+        /// 上传Revit文件到服务器
+        /// </summary>
+        /// <returns></returns>
+        public static bool UpLoadRevitAsync(string floorName, string filePath, string fileName, int count, int cur)
+        {
+            bool result = true;
+            string key = $"{MBIConst.OssClientFileKey}{fileName}";
+            var url = UploadFileUrl(fileName);
+            try
+            {
+                using (var fs = new MemoryStream(FileStreamOperate.ReadFile(filePath)))
+                {
+                    PutFlieContent fileContent = new PutFlieContent(url, fs);
+                    UpLoadFileRequest.ShowUploadWindow(floorName, filePath, count, cur);
+                    #region 进度条管理
+                    fileContent.TransferProgress += (sender, args) =>
+                           {
+                               try
+                               {
+                                   var currentData = Math.Round(args.TransferredBytes * 100d / args.TotalBytes, 3);
+                                   Debug.WriteLine("ProgressCallback - TotalBytes:{0}M, TransferredBytes:{1}M,上传百分比:{2}%",
+                                       args.TotalBytes / 1024 / 1024, args.TransferredBytes / 1024 / 1024, currentData);
+                                   var window = UpLoadFileRequest.GetUpProcessWin();
+                                   window?.Update(currentData);
+                                   if (currentData >= 100d && window!=null&&window.Count == window.Cur)
+                                   {
+                                       UpLoadFileRequest.CloseDownloadWin(true, false);
+                                   }
+                               }
+                               catch (Exception ex)
+                               {
+
+                                   throw;
+                               }
+                           }; 
+                    #endregion
+                    var resultStr=fileContent.PutContent();
+                    JObject rj = JObject.Parse(resultStr);
+                    if (rj["Result"].ToString() == "success")
+                    {
+                        return true;
+                    }                  
+                    throw new Exception(rj["ResultMsg"].ToString());
+                }
+                Console.WriteLine("Put object:{0} succeeded", key);
+            }
+            catch (Exception ex)
+            {
+                MessageShowBase.Infomation("Revit文件上传载失败!\r\n" + ex.Message + "\r\n" + ex.StackTrace);
+                result = false;
+                UpLoadFileRequest.CloseUploadWindow(result, false);
+            }
+            return result;
+        }
+    }
+}

+ 27 - 1
MBI/SAGA.MBI/RequestData/UpLoadFileRequest.cs

@@ -37,6 +37,15 @@ namespace SAGA.MBI.RequestData
     /// </summary>
     public class UpLoadFileRequest
     {
+        /// <summary>
+        /// 是否使用oss
+        /// </summary>
+        /// <returns></returns>
+        public static bool UseOss()
+        {
+            var flag = ConfigurationUtil.Default.GetSettingValue("UpDownFlag");
+            return flag==null||flag.Trim() == "0";
+        }
         #region Download
 
         /// <summary>
@@ -81,8 +90,13 @@ namespace SAGA.MBI.RequestData
         #endregion
 
         #region DownLoadAsync
-
+        
         private static WinMFMDownloadProcress windown = null;
+
+        public static WinMFMDownloadProcress GetProcessWin()
+        {
+            return windown;
+        }
         /// <summary>
         /// 显示下载窗体
         /// </summary>
@@ -106,6 +120,10 @@ namespace SAGA.MBI.RequestData
         /// <returns></returns>
         public static bool DownLoadFileAsync(Tuple<string, int, string> tuple, int count, int cur)
         {
+            if (!UpLoadFileRequest.UseOss())
+            {
+                return FileContentTransferUnit.DownLoadFileAsync(tuple, count, cur);
+            }
             bool result = true;
             string fullPath = tuple.Item1;
             string floorName = tuple.Item3;
@@ -382,6 +400,10 @@ namespace SAGA.MBI.RequestData
         #region UploadAsync
 
         private static WinMFMUploadProcress win = null;
+        public static WinMFMUploadProcress GetUpProcessWin()
+        {
+            return win;
+        }
         /// <summary>
         /// 显示上传窗体
         /// </summary>
@@ -422,6 +444,10 @@ namespace SAGA.MBI.RequestData
         /// <returns></returns>
         public static bool UpLoadRevitAsync(string floorName, string filePath, string fileName, int count, int cur)
         {
+            if (!UpLoadFileRequest.UseOss())
+            {
+                return FileContentTransferUnit.UpLoadRevitAsync(floorName, filePath, fileName,count,cur);
+            }
             bool result = true;
             string key = $"{MBIConst.OssClientFileKey}{fileName}";
 

+ 2 - 0
MBI/SAGA.MBI/SAGA.MBI.csproj

@@ -313,6 +313,7 @@
     <Compile Include="Model\GraphRelationType.cs" />
     <Compile Include="Model\MBSpace.cs" />
     <Compile Include="Model\MQRCode.cs" />
+    <Compile Include="RequestData\FileContentTransferUnit.cs" />
     <Compile Include="RequestData\QRCodeRequest.cs" />
     <Compile Include="RequestData\RequestResultUtil.cs" />
     <Compile Include="RevitModelHandle\ParameterDefinitionFactory.cs" />
@@ -401,6 +402,7 @@
     <Compile Include="ToolsData\WinSelectCheckFloors.xaml.cs">
       <DependentUpon>WinSelectCheckFloors.xaml</DependentUpon>
     </Compile>
+    <Compile Include="Utilities\FileContent.cs" />
     <Compile Include="WinView\BeModingDutyList\MEquipNoMode.cs" />
     <Compile Include="WinView\BeModingDutyList\VMBeModeDutyList.cs" />
     <Compile Include="Extend\MRevitEquipBaseExtend.cs" />

+ 228 - 0
MBI/SAGA.MBI/Utilities/FileContent.cs

@@ -0,0 +1,228 @@
+/*-------------------------------------------------------------------------
+ * 功能描述:FileContent
+ * 作者:xulisong
+ * 创建时间: 2019/4/23 9:47:51
+ * 版本号:v1.0
+ *  -------------------------------------------------------------------------*/
+
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Net;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SAGA.MBI.Utilities
+{
+    /// <summary>
+    /// 流传输参数
+    /// </summary>
+    public class StreamProgressArgs : EventArgs
+    {
+        public StreamProgressArgs(long incrementTransferred, long transferred, long total)
+        {
+            IncrementTransferred = incrementTransferred;
+            TransferredBytes = transferred;
+            TotalBytes = total;
+        }
+        public long IncrementTransferred { get; private set; }
+        public long TransferredBytes { get; private set; }
+        public long TotalBytes { get; private set; }
+        /// <summary>
+        /// 传输是否完成
+        /// </summary>
+        public bool TransCompleted { get; internal set; }
+    }
+
+    public class FileContent
+    {
+        public int BufferLength { get; set; } = 1024 * 1024;
+        /// <summary>
+        /// 超时设置
+        /// </summary>
+        public int Timeout { get; set; } = 60000;
+        public EventHandler<StreamProgressArgs> TransferProgress { get; set; }
+    }
+    /// <summary>
+    /// 推送对象内容
+    /// </summary>
+    public class PutFlieContent : FileContent
+    {
+        private string m_Url;
+        private Stream m_Stream;
+        public PutFlieContent(string url, Stream stream)
+        {
+            m_Url = url;
+            m_Stream = stream;
+        }
+        /// <summary>
+        /// 上传文件
+        /// </summary>
+        /// <returns></returns>
+        public virtual string PutContent()
+        {
+            var url = m_Url;
+            var stream = m_Stream;
+            if (stream == null)
+                throw new ArgumentNullException(nameof(stream));
+            var responseValue = string.Empty;
+            HttpWebRequest request = null;
+            try
+            {
+                var totalLength = stream.Length;
+                request = (HttpWebRequest) WebRequest.Create(url);
+                request.KeepAlive = true;
+                request.Timeout = Timeout;
+                request.Method = "POST";
+                request.ContentLength = totalLength;
+                request.ContentType = "multipart/form-data; ";
+                #region 请求数据
+
+                byte[] buffer = new byte[BufferLength];
+
+                var transLength = 0;
+                using (BinaryReader r = new BinaryReader(stream))
+                {
+                    Stream postStream = request.GetRequestStream();
+                    try
+                    {
+                        int size = 0;
+                        do
+                        {
+                            size = r.Read(buffer, 0, buffer.Length);
+                            postStream.Write(buffer, 0, size);
+                            transLength += size;
+
+                            #region 调用事件
+
+                            StreamProgressArgs args = new StreamProgressArgs(size, transLength, totalLength);
+                            args.TransCompleted = (size == (long) 0);
+                            TransferProgress?.Invoke(this, args);
+
+                            #endregion
+                        } while (size > 0);
+                    }
+                    finally
+                    {
+                        postStream?.Close();
+                    }
+                }
+
+                #endregion
+
+                #region 相应数据
+
+                //返回数据
+                using (var response = (HttpWebResponse) request.GetResponse())
+                {
+                    if (response.StatusCode != HttpStatusCode.OK)
+                    {
+                        var message = String.Format("请求失败. 获得http状态 {0}", response.StatusCode);
+                        throw new ApplicationException(message);
+                    }
+
+                    using (var responseStream = response.GetResponseStream())
+                    {
+                        if (responseStream != null)
+
+                            using (var reader = new StreamReader(responseStream))
+                            {
+                                responseValue = reader.ReadToEnd();
+                            }
+                    }
+                }
+
+                #endregion
+            }
+            catch (Exception e)
+            {
+                throw;
+            }
+            finally
+            {
+                //request?.dis
+            }
+            return responseValue;
+        }
+    }
+    /// <summary>
+    /// 获取对象内容
+    /// </summary>
+    public class GetFlieContent : FileContent
+    {
+        private string m_Url;
+        public GetFlieContent(string url)
+        {
+            m_Url = url;
+        }
+        public virtual byte[] GetContent()
+        {
+            string url = m_Url;
+            byte[] results = null;
+            HttpWebRequest request = null ;
+            try
+            {
+                request = (HttpWebRequest)WebRequest.Create(url);
+                request.KeepAlive = true;
+                request.Timeout = Timeout;
+                request.Method = "Get";
+                using (var response = (HttpWebResponse) request.GetResponse())
+                {
+                    if (response.StatusCode != HttpStatusCode.OK)
+                    {
+                        var message = String.Format("请求失败. 获取http状态 {0}", response.StatusCode);
+                        throw new ApplicationException(message);
+                    }
+
+                    #region 获取返回值
+
+                    using (MemoryStream memoryStream = new MemoryStream())
+                    {
+                        using (var responseStream = response.GetResponseStream())
+                        {
+                            if (responseStream != null)
+                            {
+                                long totalLength = response.ContentLength;
+                                var transLength = 0;
+                                if ((response.Headers.AllKeys.Contains("ContentLength") && totalLength < 0) ||
+                                    totalLength == 0) //当没有连接是可能返回长度为0
+                                {
+                                    return results;
+                                }
+                                var buffer = new byte[BufferLength]; //缓存对象
+                                var readSize = 0;
+                                while ((readSize = responseStream.Read(buffer, 0, buffer.Length)) > 0)
+                                {
+                                    memoryStream.Write(buffer, 0, readSize);
+                                    transLength += readSize;
+
+                                    #region 调用事件
+                                    StreamProgressArgs args =
+                                        new StreamProgressArgs(readSize, transLength, totalLength);
+                                    args.TransCompleted = (totalLength == transLength);
+                                    TransferProgress?.Invoke(this, args);
+
+                                    #endregion
+                                }
+
+                                results = memoryStream.ToArray();
+                                if ((totalLength!=-1)&&results.Length != totalLength)
+                                {
+                                    throw new Exception("文件下载不完整");
+                                }
+                            }
+                        }
+                    }
+
+                    #endregion
+                }
+            }
+            catch (Exception ex)
+            {
+                throw;
+            }
+            return results;
+        }
+    }
+}