chr
2024-11-02 b5234c5ab1e9e6826b8d8fc1e95fa752aaa40b74
PdmSwPlugin.Main/MainControl.xaml.cs
@@ -18,6 +18,8 @@
using SuperSocket.SocketBase;
using SuperSocket.SocketBase.Protocol;
using PdmSwPlugin.Main.Tcp;
using SolidWorks.Interop.swconst;
using System.Windows.Interop;
namespace PdmSwPlugin.Main
{
@@ -121,6 +123,20 @@
            string updaterPath = "AutoUpdater\\AutoUpdater.exe";
            string exePath = new DirectoryInfo(Assembly.GetExecutingAssembly().Location).Parent.FullName;
            string exeFileName = $"{exePath}\\{updaterPath}";
            //if (SwApp.SendMsgToUser2("检测到插件更新,是否立刻更新?(请注意保存当前工作)", (int)swMessageBoxIcon_e.swMbInformation, (int)swMessageBoxBtn_e.swMbYesNo)
            //    == (int)swMessageBoxResult_e.swMbHitYes)
            //{
            //    Process updaterProcess = new Process
            //    {
            //        StartInfo = new ProcessStartInfo
            //        {
            //            FileName = exeFileName,
            //            Arguments = mainProcessId + ""
            //        }
            //    };
            //    updaterProcess.Start();
            //}
            // 非必要更新
            new Task(() =>
            {
@@ -209,9 +225,29 @@
        public void Logout()
        {
            string binPath = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData), "HengXin", "PdmSwPlugin", "bin");
            File.Delete(binPath);
            DeActiveHandler();
            try
            {
                // 删除缓存bin文件
                string binPath = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData), "HengXin", "PdmSwPlugin", "bin");
                File.Delete(binPath);
            }
            catch (Exception ex)
            {
                //SwApp.SendMsgToUser2("用户缓存清理失败!", (int)swMessageBoxIcon_e.swMbWarning, (int)swMessageBoxBtn_e.swMbOk);
                Logger.Error("Delete User Bin File Failed.", ex);
            }
            try
            {
                // 清除UserControl事件
                DeActiveHandler();
            }
            catch (Exception ex)
            {
                SwApp.SendMsgToUser2("发生未知异常,详情请见日志!", (int)swMessageBoxIcon_e.swMbWarning, (int)swMessageBoxBtn_e.swMbOk);
                Logger.Error("DeActiveHandler Failed.", ex);
            }
            mainTab.tabControl.Items.Clear();
            PdmUser.SetLoginUser(null);
            mainBorder.Child = new LoginControl(LoginSuccess);
@@ -238,7 +274,7 @@
        private void self_Unloaded(object sender, RoutedEventArgs e)
        {
            StopTcpServer();
            // StopTcpServer();
        }
    }
}