public bool Show(string msg)
        {
            SscDialog sscDialog = new SscDialog(msg);
            bool?     value     = sscDialog.ShowDialog();

            return(value.HasValue && value.Value);
        }
        private async Task CopyConfigFile()
        {
            await Task.Run(() =>
            {
                try
                {
                    string sharedConfigFile = Path.Combine(SscUpdateManager.VersionFolder, GlobalResources.ConfigPath);
                    string curConfigFile    = Path.Combine(Environment.CurrentDirectory, GlobalResources.ConfigPath);

                    bool hasSharedConfig = File.Exists(sharedConfigFile);
                    bool useSharedConfig = Settings.Default.UseUserConfig;

                    Log.Logger.Debug($"has shared config?{hasSharedConfig}, useSharedConfig?{useSharedConfig}");

                    if (hasSharedConfig && useSharedConfig)
                    {
                        Log.Logger.Debug($"【copy config file】:copy {sharedConfigFile} to {curConfigFile}");

                        File.Copy(sharedConfigFile, curConfigFile, true);
                    }
                }
                catch (Exception ex)
                {
                    Log.Logger.Error($"【copy config file exception】:{ex}");
                    Current.Dispatcher.BeginInvoke(new Action(() =>
                    {
                        SscDialog dialog = new SscDialog(Messages.ErrorCopyConfigFile);
                        dialog.ShowDialog();
                        Current.Shutdown();
                    }));
                }
            });
        }
        private void ShowHelp()
        {
            string helpMsg = GlobalResources.HelpMessage;

            SscDialog helpSscDialog = new SscDialog(helpMsg);

            helpSscDialog.ShowDialog();
        }
Beispiel #4
0
        private void CheckAppInstance()
        {
            Mutex1 = new Mutex(true, "ShengtaoSchoolClient", out _isNewInstance);

            if (!_isNewInstance)
            {
                SscDialog dialog = new SscDialog("程序已经在运行中!");
                dialog.ShowDialog();
                Current.Shutdown();
            }
        }
        private void ReadConfig()
        {
            BaseResult result = ConfigManager.ReadConfig();

            if (result.Status == "-1")
            {
                SscDialog dialog = new SscDialog(result.Message);
                dialog.ShowDialog();
                Current.Shutdown();
            }
        }
Beispiel #6
0
        private async Task <bool> GetDeviceInfoFromServer()
        {
            IBms bmsService = Container.Resolve <IBms>();

            ResponseResult getDeviceResult =
                await
                bmsService.GetDeviceInfo(GlobalData.Instance.SerialNo,
                                         GlobalData.Instance.AggregatedConfig.DeviceKey);

            if (getDeviceResult.Status != "0")
            {
                string msg = $"{getDeviceResult.Message}\r\n本机设备号:{GlobalData.Instance.SerialNo}";

                SscDialog dialog = new SscDialog(msg);
                dialog.ShowDialog();
                return(false);
            }

            Device device = getDeviceResult.Data as Device;

            if (device != null)
            {
                GlobalData.Instance.Device = device;
                GlobalData.Instance.AggregatedConfig.DeviceNo = device.Id;

                if (device.IsExpired)
                {
                    string msg = $"{Messages.WarningDeviceExpires}\r\n本机设备号:{GlobalData.Instance.SerialNo}";

                    SscDialog dialog = new SscDialog(msg);
                    dialog.ShowDialog();
                    return(false);
                }
                if (device.Locked)
                {
                    string msg = $"{Messages.WarningLockedDevice}\r\n本机设备号:{GlobalData.Instance.SerialNo}";

                    SscDialog dialog = new SscDialog(msg);
                    dialog.ShowDialog();
                    return(false);
                }

                return(true);
            }

            string    emptyDeviceMsg    = $"{Messages.WarningEmptyDevice}\r\n本机设备号:{GlobalData.Instance.SerialNo}";
            SscDialog emptyDeviceDialog = new SscDialog(emptyDeviceMsg);

            emptyDeviceDialog.ShowDialog();
            return(false);
        }
Beispiel #7
0
        private bool ReadConfig()
        {
            BaseResult result = ConfigManager.ReadConfig();

            if (result.Status == "-1")
            {
                SscDialog dialog = new SscDialog(result.Message);
                dialog.ShowDialog();
                Current.Shutdown();
                return(false);
            }

            return(true);
        }
Beispiel #8
0
        public async Task Logout()
        {
            TimerManager.Instance.StopTimer();
            if (GlobalData.Instance.Device.EnableLogin)
            {
                SscDialog dialog = new SscDialog(Messages.WarningYouAreSignedOut);
                dialog.ShowDialog();
                Application.Current.Shutdown();
            }
            else
            {
                Log.Logger.Debug($"【rt server connected】:{_rtClientService.IsConnected()}");
                Log.Logger.Debug($"【stop rt server begins】:");
                _rtClientService.Stop();
                Log.Logger.Debug($"【rt server connected】:{_rtClientService.IsConnected()}");

                _userInfo.IsLogouted = true;

                foreach (Window currentWindow in Application.Current.Windows)
                {
                    if (currentWindow is LoginView)
                    {
                        Log.Logger.Debug("【already in login view, do nothing】");
                        return;
                    }

                    var meeting = currentWindow.DataContext as IExitMeeting;
                    if (meeting != null)
                    {
                        Log.Logger.Debug("【in meeting view, exit meeting】");
                        IExitMeeting exitMeetingService = meeting;
                        await exitMeetingService.ExitAsync();
                    }
                }

                Log.Logger.Debug("【in main view】");
                HideShell();

                LoginView loginView = IoC.Get <LoginView>();
                loginView.Show();

                await _meetingSdkAgent.Stop();

                //_sdkService.Stop();
                //_sdkService.IsServerStarted = false;
            }
        }
Beispiel #9
0
        private void CopyConfigFile(string newestVersion)
        {
            //await Task.Run(() =>
            //{
            try
            {
                //string sharedConfigFile = Path.Combine(SscUpdateManager.VersionFolder, GlobalResources.ConfigPath);
                string curConfigFile = Path.Combine(Environment.CurrentDirectory, GlobalResources.ConfigPath);

                DirectoryInfo di = new DirectoryInfo(Environment.CurrentDirectory);

                string destinationFile = Path.Combine(di.Parent.FullName, $"app-{newestVersion}", GlobalResources.ConfigPath);

                bool useSharedConfig = Settings.Default.UseUserConfig;

                Log.Logger.Debug($"useSharedConfig?{useSharedConfig}");


                string curDeviceInfo   = Path.Combine(Environment.CurrentDirectory, "sdk\\UserData\\setting\\setting_deviceinfo.xml");
                string curDeviceDetail = Path.Combine(Environment.CurrentDirectory, "sdk\\UserData\\setting\\setting_vediodetail.xml");

                string tarDeviceInfo   = Path.Combine(di.Parent.FullName, $"app-{newestVersion}", "sdk\\UserData\\setting\\setting_deviceinfo.xml");
                string tarDeviceDetail = Path.Combine(di.Parent.FullName, $"app-{newestVersion}", "sdk\\UserData\\setting\\setting_vediodetail.xml");

                if (useSharedConfig)
                {
                    Log.Logger.Debug($"【copy config file】:copy {curConfigFile} to {destinationFile}");
                    File.Copy(curConfigFile, destinationFile, true);
                    Log.Logger.Debug($"【copy config file】:copy {curDeviceInfo} to {tarDeviceInfo}");
                    File.Copy(curDeviceInfo, tarDeviceInfo, true);
                    Log.Logger.Debug($"【copy config file】:copy {curDeviceDetail} to {tarDeviceDetail}");
                    File.Copy(curDeviceDetail, tarDeviceDetail, true);
                }
            }
            catch (Exception ex)
            {
                Log.Logger.Error($"【copy config file exception】:{ex}");
                Current.Dispatcher.BeginInvoke(new Action(() =>
                {
                    SscDialog dialog = new SscDialog(Messages.ErrorCopyConfigFile);
                    dialog.ShowDialog();
                    Current.Shutdown();
                }));
            }
            //});
        }
Beispiel #10
0
        private async void _timer_Elapsed(object sender, ElapsedEventArgs e)
        {
            Log.Logger.Debug("【refresh token begins】");
            IBms bmsService = IoC.Get <IBms>();

            ResponseResult refreshResult;

            if (GlobalData.Instance.Device.EnableLogin)
            {
                refreshResult =
                    await
                    bmsService.GetImeiToken(GlobalData.Instance.Device.Id,
                                            GlobalData.Instance.AggregatedConfig.DeviceKey);
            }
            else
            {
                UserInfo userInfo = IoC.Get <UserInfo>();
                refreshResult =
                    await bmsService.ApplyForToken(userInfo.UserName, userInfo.Pwd, GlobalData.Instance.Device.Id);
            }

            Log.Logger.Debug(
                $"【refresh token result】:status={refreshResult.Status}, msg={refreshResult.Message}, data={refreshResult.Data}");

            if (refreshResult.Status == "0")
            {
                IRtClientService rtClientService = IoC.Get <IRtClientService>();

                rtClientService.RefreshToken(bmsService.AccessToken);
            }
            else
            {
                await Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                {
                    SscDialog refreshTokenDialog =
                        new SscDialog($"{Messages.WarningRefreshTokenFailed}\r\n{refreshResult.Message}");
                    refreshTokenDialog.ShowDialog();
                }));
            }
        }
        private async Task UnzipExeFilesAndCopyConfigAsync()
        {
            string sdkexesPath = Path.Combine(Environment.CurrentDirectory, "sdkexes.zip");

            if (File.Exists(sdkexesPath))
            {
                Log.Logger.Debug($"【unzip {sdkexesPath}】:assume it's first startup after installation");
                await Task.Run(() =>
                {
                    try
                    {
                        using (ZipInputStream zipInputStream = new ZipInputStream(File.OpenRead(sdkexesPath)))
                        {
                            ZipEntry entry;

                            while ((entry = zipInputStream.GetNextEntry()) != null)
                            {
                                string fileName = Path.GetFileName(entry.Name);

                                if (!string.IsNullOrEmpty(fileName))
                                {
                                    string fileItemName = Path.Combine(Environment.CurrentDirectory, fileName);

                                    Log.Logger.Debug($"【unzip file】:unzip {entry.Name} to {fileItemName}");

                                    using (FileStream streamWriter = File.Create(fileItemName))
                                    {
                                        byte[] data = new byte[2048];

                                        while (true)
                                        {
                                            var size = zipInputStream.Read(data, 0, data.Length);
                                            if (size > 0)
                                            {
                                                streamWriter.Write(data, 0, size);
                                            }
                                            else
                                            {
                                                break;
                                            }
                                        }
                                    }
                                }
                            }
                        }

                        Log.Logger.Debug($"【delete {sdkexesPath} begins】");
                        File.Delete(sdkexesPath);

                        string sharedConfigFile = Path.Combine(UpdateManager.VersionFolder, GlobalResources.ConfigPath);
                        string curConfigFile    = Path.Combine(Environment.CurrentDirectory, GlobalResources.ConfigPath);

                        if (File.Exists(sharedConfigFile) && Settings.Default.UseUserConfig)
                        {
                            Log.Logger.Debug($"【copy config file】:copy {sharedConfigFile} to {curConfigFile}");

                            File.Copy(sharedConfigFile, curConfigFile, true);
                        }
                    }
                    catch (Exception ex)
                    {
                        Log.Logger.Error($"【unzip sdkexes.zip or copy config exception】:{ex}");
                        Current.Dispatcher.BeginInvoke(new Action(() =>
                        {
                            SscDialog dialog = new SscDialog(Messages.ErrorUnzipExesFailed);
                            dialog.ShowDialog();
                            Current.Shutdown();
                        }));
                    }
                });
            }
        }