chr
7 天以前 43a0207d207390abdeeb3ab9155eebf03edd7b1a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
using PdmSwPlugin.Common.Entity.System;
using PdmSwPlugin.Common.Interface;
using SolidWorks.Interop.sldworks;
using System;
using System.Windows;
using System.Windows.Controls;
using SolidWorks.Interop.swconst;
using PdmSwPlugin.Common.Setting;
using System.Threading.Tasks;
using PdmSwPlugin.Common.Util.Http;
using System.Collections.Generic;
 
namespace PdmSwPlugin.Main
{
    /// <summary>
    /// MainTab.xaml 的交互逻辑
    /// </summary>
    public partial class MainTab : UserControl, ISwAppSetter
    {
        private Action logout;
        public MainTab(Action logout)
        {
            this.logout = logout;
            InitializeComponent();
            userLabel.Content = $"欢迎您,{PdmUser.LoginUser?.realname}";
            configLabel.Content = CustomerSetting.Instance["historyFlag"];
        }
 
        private SldWorks swApp;
        public SldWorks SwApp => swApp;
 
        public void SetSwApp(SldWorks SwApp)
        {
            this.swApp = SwApp;
        }
 
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (SwApp.SendMsgToUser2("确定退出登录吗?", (int)swMessageBoxIcon_e.swMbWarning,
                (int)swMessageBoxBtn_e.swMbYesNo) == (int)swMessageBoxResult_e.swMbHitYes)
            {
                logout();
            }
        }
 
        private void Refresh_Click(object sender, RoutedEventArgs e)
        {
            configLabel.Content = "刷新中...";
            Task.Run(() =>
            {
                try
                {
                    Result<Dictionary<string, string>> res = HttpClientCreator.PostSyncAction<Dictionary<string, string>>("openApi/wpf/refreshConfig", null);
                    Dictionary<string, string> setting = res.HandleResult();
                    CustomerSetting.Set(setting);
                }
                catch (Exception ex)
                {
 
                }
                finally
                {
                    Dispatcher.Invoke(() =>
                    {
                        configLabel.Content = CustomerSetting.Instance["historyFlag"];
                    });
                }
            });
        }
    }
}