コード例 #1
0
        internal MpMainSettings()
        {
            InitializeComponent();
            Title = ModPlusAPI.Language.GetItem(LangItem, "h1");
            FillAndSetLanguages();
            SetLanguageValues();
            FillThemesAndColors();
            LoadSettingsFromConfigFileAndRegistry();
            GetDataByVars();
            Closed += MpMainSettings_OnClosed;

            // license server
            if (ClientStarter.IsClientWorking())
            {
                BtStopConnectionToLicenseServer.IsEnabled    = true;
                BtRestoreConnectionToLicenseServer.IsEnabled = false;
                TbLocalLicenseServerIpAddress.IsEnabled      = false;
                TbLocalLicenseServerPort.IsEnabled           = false;
            }
            else
            {
                BtStopConnectionToLicenseServer.IsEnabled    = false;
                BtRestoreConnectionToLicenseServer.IsEnabled = true;
                TbLocalLicenseServerIpAddress.IsEnabled      = true;
                TbLocalLicenseServerPort.IsEnabled           = true;
            }
        }
コード例 #2
0
        public SrvcManagerConsole()
        {
            // this.srvcManager = srvcManager;
            ClientStarter ccs = new ClientStarter();

            this.srvcManager = ccs.GetSrvcManagerConsole();
        }
コード例 #3
0
 /// <inheritdoc/>
 public void Terminate()
 {
     ClientStarter.StopConnection();
     AcApp.PreTranslateMessage -= AutoCadMessageHandler;
     Autodesk.Windows.ComponentManager.ToolTipOpened -= ComponentManager_ToolTipOpened;
     Autodesk.Windows.ComponentManager.ToolTipClosed -= ComponentManager_ToolTipClosed;
 }
コード例 #4
0
        private static void Main(string[] args)
        {
            var path = "clientSettings.json";

            var settings = new JavaScriptSerializer().Deserialize <ClientSettings>(System.IO.File.ReadAllText(path));

            //az összes adobe process bezárása
            Positioning.CloseAllAdobeProcess();

            //a shortcut managing elintézése
            ShortcutOperations.SetStartUp();

            //ha kell akkor az ablak elrejtése
            InitMainProgram.Hide();

            //a szükséges paraméterek betöltése
            InitMainProgram.SetUpParams(settings);

            ClientStarter.StartClients(Datas.CountOfMonitors);

            foreach (var item in ClientStarter.Clients)
            {
                item.Client.OnDisconnect += Client_OnDisconnect;
            }

            Console.ReadLine();
        }
コード例 #5
0
 private void BtRestoreConnectionToLicenseServer_OnClick(object sender, RoutedEventArgs e)
 {
     ClientStarter.StartConnection(ProductLicenseType.AutoCAD);
     BtRestoreConnectionToLicenseServer.IsEnabled = false;
     BtStopConnectionToLicenseServer.IsEnabled    = true;
     TbLocalLicenseServerIpAddress.IsEnabled      = false;
     TbLocalLicenseServerPort.IsEnabled           = false;
     _restartClientOnClose = true;
 }
コード例 #6
0
        /// <inheritdoc/>
        public void Stop()
        {
            foreach (var actionEventSource in ActionEventSources)
            {
                actionEventSource.Dispose();
            }

            ClientStarter.StopConnection();
        }
コード例 #7
0
ファイル: Form1.cs プロジェクト: KriszW/docshowv2
        private void Button1_Click(object sender, EventArgs e)
        {
            ClientStarter.StartClients(Datas.CountOfMonitors);

            foreach (var item in ClientStarter.Clients)
            {
                item.Client.OnDisconnect += Client_OnDisconnect;
            }
        }
コード例 #8
0
 private async void BtCheckLocalLicenseServerConnection_OnClick(object sender, RoutedEventArgs e)
 {
     // ReSharper disable once AsyncConverter.AsyncAwaitMayBeElidedHighlighting
     await this.ShowMessageAsync(
         ClientStarter.IsLicenseServerAvailable()
         ?ModPlusAPI.Language.GetItem("ModPlusAPI", "h21")
         : ModPlusAPI.Language.GetItem("ModPlusAPI", "h20"),
         ModPlusAPI.Language.GetItem("ModPlusAPI", "h22") + " " +
         TbLocalLicenseServerIpAddress.Text + ":" + TbLocalLicenseServerPort.Value).ConfigureAwait(true);
 }
コード例 #9
0
        private void OnStartClient(object sender, RoutedEventArgs e)
        {
            // allow only one instance to run
            if (clientWatcher.IsProcessAlive())
            {
                // show error message
                return;
            }

            ClientStarter starter = new ClientStarter(ClientLocation.Text, LoginBackendURL.Text, LoginEmail.Text, LoginPassword.Text);
        }
コード例 #10
0
        /// <inheritdoc />
        public Result OnStartup(UIControlledApplication application)
        {
            try
            {
                // init lang
                if (!Language.Initialize())
                {
                    return(Result.Cancelled);
                }

                // statistic
                Statistic.SendModuleLoaded("Revit", VersionData.CurrentRevitVersion);

                // Принудительная загрузка сборок
                LoadAssemblies();
                UserConfigFile.InitConfigFile();
                LoadPlugins();

                // check adaptation
                CheckAdaptation();

                // Load ribbon
                App.RibbonBuilder.CreateRibbon(application);

                // проверка загруженности модуля автообновления
                CheckAutoUpdaterLoaded();

                var disableConnectionWithLicenseServer = Variables.DisableConnectionWithLicenseServerInRevit;

                // license server
                if (Variables.IsLocalLicenseServerEnable && !disableConnectionWithLicenseServer)
                {
                    ClientStarter.StartConnection(SupportedProduct.Revit);
                }

                if (Variables.IsWebLicenseServerEnable && !disableConnectionWithLicenseServer)
                {
                    WebLicenseServerClient.Instance.Start(SupportedProduct.Revit);
                }

                // user info
                AuthorizationOnStartup();

                return(Result.Succeeded);
            }
            catch (Exception exception)
            {
                // Тут отображение ошибки должно быть в обычном окне, т.к. сборки могли еще не загрузился
                TaskDialog.Show("ModPlus", exception.Message + Environment.NewLine + exception.StackTrace,
                                TaskDialogCommonButtons.Ok);
                return(Result.Failed);
            }
        }
コード例 #11
0
        /// <inheritdoc/>
        public bool Initialize(string pluginFolder)
        {
            RengaApplication   = new Renga.Application();
            ActionEventSources = new List <Renga.ActionEventSource>();
            try
            {
                // init lang
                if (!Language.Initialize())
                {
                    return(false);
                }

                // statistic
                Statistic.SendPluginStarting("Renga", "4.0");

                // Принудительная загрузка сборок
                LoadAssemblies();
                UserConfigFile.InitConfigFile();
                LoadFunctions();

                MenuBuilder.Build(RengaApplication, ActionEventSources);

                // проверка загруженности модуля автообновления
                CheckAutoUpdaterLoaded();

                var disableConnectionWithLicenseServer = Variables.DisableConnectionWithLicenseServerInRenga;

                // license server
                if (Variables.IsLocalLicenseServerEnable && !disableConnectionWithLicenseServer)
                {
                    ClientStarter.StartConnection(SupportedProduct.Renga);
                }

                if (Variables.IsWebLicenseServerEnable && !disableConnectionWithLicenseServer)
                {
                    WebLicenseServerClient.Instance.Start(SupportedProduct.Renga);
                }

                // user info
                AuthorizationOnStartup();

                return(true);
            }
            catch (Exception exception)
            {
                RengaApplication.UI.ShowMessageBox(Renga.MessageIcon.MessageIcon_Error, "ModPlus", exception.Message);
                return(false);
            }
        }
コード例 #12
0
        private void OnStartClient(object sender, RoutedEventArgs e)
        {
            string check_client_file = laucherSettings.GetClientLocation() + @"\" + laucherSettings.GetClientFilename() + ".exe";

            if (!File.Exists(check_client_file))
            {
                ErrorHandler.AddError(111, "Cannot find client at this location.");
            }
            else
            {
                ErrorHandler.RemoveError(111, "Cannot find client at this location.");
                // allow only one instance to run
                if (clientWatcher.IsProcessAlive())
                {
                    ErrorHandler.AddError(201, "Client is already running");
                }
                else
                {
                    ErrorHandler.RemoveError(201, "Client is already running");
                    ClientStarter starter = new ClientStarter(ClientLocation.Text, LoginBackendURL.Text, LoginEmail.Text, LoginPassword.Text, ClientFileName.Text, CreateArguments());
                }
            }
            DisplayErrors();
        }
コード例 #13
0
        private void OnStartClient(object sender, RoutedEventArgs e)
        {
            string check_client_file = laucherSettings.GetClientLocation() + @"\" + laucherSettings.GetClientFilename() + ".exe";

            if (!File.Exists(check_client_file))
            {
                ErrorHandler.AddError(ErrorType.error_Client_noLocation);
            }
            else
            {
                ErrorHandler.RemoveError(ErrorType.error_Client_noLocation);
                // allow only one instance to run
                if (clientWatcher.IsProcessAlive())
                {
                    ErrorHandler.AddError(ErrorType.error_ClientAlreadyRunning);
                }
                else
                {
                    ErrorHandler.RemoveError(ErrorType.error_ClientAlreadyRunning);
                    ClientStarter starter = new ClientStarter(laucherSettings.GetClientLocation(), laucherSettings.PrepareBackendURL(), laucherSettings.GetEmail(), laucherSettings.GetPassword(), laucherSettings.GetClientFilename(), CreateArguments());
                }
            }
            DisplayErrors();
        }
コード例 #14
0
        /// <inheritdoc />
        public void Initialize()
        {
            try
            {
                var sw = new Stopwatch();
                sw.Start();

                // init lang
                if (!Language.Initialize())
                {
                    return;
                }

                // Получим значение переменной "Тихая загрузка" в первую очередь
                _quiteLoad = ModPlusAPI.Variables.QuietLoading;

                // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
                // Файла конфигурации может не существовать при загрузке плагина!
                // Поэтому все, что связанно с работой с файлом конфигурации должно это учитывать!
                // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
                var ed = AcApp.DocumentManager.MdiActiveDocument.Editor;
                if (!CheckCadVersion())
                {
                    ed.WriteMessage("\n***************************");
                    ed.WriteMessage($"\n{Language.GetItem(LangItem, "p1")}");
                    ed.WriteMessage($"\n{Language.GetItem(LangItem, "p2")}");
                    ed.WriteMessage($"\n{Language.GetItem(LangItem, "p3")}");
                    ed.WriteMessage("\n***************************");
                    return;
                }

                Statistic.SendPluginStarting("AutoCAD", VersionData.CurrentCadVersion);
                ed.WriteMessage("\n***************************");
                ed.WriteMessage($"\n{Language.GetItem(LangItem, "p4")}");
                if (!_quiteLoad)
                {
                    ed.WriteMessage($"\n{Language.GetItem(LangItem, "p5")}");
                }

                // Принудительная загрузка сборок
                LoadAssemblies(ed);
                if (!_quiteLoad)
                {
                    ed.WriteMessage($"\n{Language.GetItem(LangItem, "p6")}");
                }
                LoadBaseAssemblies(ed);
                if (!_quiteLoad)
                {
                    ed.WriteMessage($"\n{Language.GetItem(LangItem, "p7")}");
                }
                UserConfigFile.InitConfigFile();
                if (!_quiteLoad)
                {
                    ed.WriteMessage($"\n{Language.GetItem(LangItem, "p8")}");
                }
                LoadFunctions(ed);

                // check adaptation
                CheckAdaptation();

                // Строим: ленту, меню, плавающее меню
                // Загрузка ленты
                Autodesk.Windows.ComponentManager.ItemInitialized += ComponentManager_ItemInitialized;
                if (ModPlusAPI.Variables.Palette)
                {
                    MpPalette.CreatePalette(false);
                }

                // Загрузка основного меню (с проверкой значения из файла настроек)
                FloatMenuCommand.LoadMainMenu();

                // Загрузка окна Чертежи
                MpDrawingsFunction.LoadMainMenu();

                // Загрузка контекстных меню для мини-функций
                MiniFunctions.LoadUnloadContextMenu();

                // проверка загруженности модуля автообновления
                CheckAutoUpdaterLoaded();

                // Включение иконок для продуктов
                var showProductsIcon =
                    bool.TryParse(UserConfigFile.GetValue("mpProductInsert", "ShowIcon"), out var b) && b; // false
                if (showProductsIcon)
                {
                    ProductIconFunctions.ShowIcon();
                }

                // license server
                var disableConnectionWithLicenseServerInAutoCad =
                    ModPlusAPI.Variables.DisableConnectionWithLicenseServerInAutoCAD;

                if (ModPlusAPI.Variables.IsLocalLicenseServerEnable &&
                    !disableConnectionWithLicenseServerInAutoCad)
                {
                    ClientStarter.StartConnection(SupportedProduct.AutoCAD);
                }

                if (ModPlusAPI.Variables.IsWebLicenseServerEnable &&
                    !disableConnectionWithLicenseServerInAutoCad)
                {
                    WebLicenseServerClient.Instance.Start(SupportedProduct.AutoCAD);
                }

                // user info
                AuthorizationOnStartup();

                // tooltip hook
                AcApp.PreTranslateMessage += AutoCadMessageHandler;
                Autodesk.Windows.ComponentManager.ToolTipOpened += ComponentManager_ToolTipOpened;
                Autodesk.Windows.ComponentManager.ToolTipClosed += ComponentManager_ToolTipClosed;

                sw.Stop();
                ed.WriteMessage($"\n{Language.GetItem(LangItem, "p9")} {sw.ElapsedMilliseconds}");
                ed.WriteMessage($"\n{Language.GetItem(LangItem, "p10")}");
                ed.WriteMessage("\n***************************");
            }
            catch (System.Exception exception)
            {
                ExceptionBox.Show(exception);
            }
        }
コード例 #15
0
 /// <inheritdoc />
 public Result OnShutdown(UIControlledApplication application)
 {
     ClientStarter.StopConnection();
     return(Result.Succeeded);
 }
コード例 #16
0
        private void MpMainSettings_OnClosed(object sender, EventArgs e)
        {
            try
            {
                var isDifferentLanguage = IsDifferentLanguage();

                // Если отключили плавающее меню
                if (!ChkMpFloatMenu.IsChecked.Value)
                {
                    // Закрываем плавающее меню
                    if (MpMenuFunction.MpMainMenuWin != null)
                    {
                        MpMenuFunction.MpMainMenuWin.Close();
                    }
                }
                else // Если включили плавающее меню
                {
                    // Если плавающее меню было включено
                    if (MpMenuFunction.MpMainMenuWin != null)
                    {
                        // Перегружаем плавающее меню, если изменилась тема, вкл/выкл открытые чертежи, сворачивать в
                        if (!Regestry.GetValue("PluginStyle").Equals(_curTheme) ||
                            !Regestry.GetValue("FloatMenuCollapseTo").Equals(_curFloatMenuCollapseTo.ToString()) ||
                            !ChkMpChkDrwsOnMnu.IsChecked.Value.Equals(_curDrawingsOnMenu) ||
                            isDifferentLanguage)
                        {
                            MpMenuFunction.MpMainMenuWin.Close();
                            MpMenuFunction.LoadMainMenu();
                        }
                    }
                    else
                    {
                        MpMenuFunction.LoadMainMenu();
                    }
                }

                // если отключили палитру
                if (!ChkMpPalette.IsChecked.Value)
                {
                    if (MpPalette.MpPaletteSet != null)
                    {
                        MpPalette.MpPaletteSet.Visible = false;
                    }
                }
                else // если включили палитру
                {
                    MpPalette.CreatePalette();
                }

                // Если отключили плавающее меню Чертежи
                if (!ChkMpDrawingsAlone.IsChecked.Value)
                {
                    if (MpDrawingsFunction.MpDrawingsWin != null)
                    {
                        MpDrawingsFunction.MpDrawingsWin.Close();
                    }
                }
                else
                {
                    if (MpDrawingsFunction.MpDrawingsWin != null)
                    {
                        // Перегружаем плавающее меню, если изменилась тема, вкл/выкл открытые чертежи, границы, сворачивать в
                        if (!Regestry.GetValue("PluginStyle").Equals(_curTheme) ||
                            !Regestry.GetValue("DrawingsCollapseTo").Equals(_curDrawingsCollapseTo.ToString()) ||
                            !ChkMpDrawingsAlone.IsChecked.Value.Equals(_curDrawingsAlone) ||
                            isDifferentLanguage)
                        {
                            MpDrawingsFunction.MpDrawingsWin.Close();
                            MpDrawingsFunction.LoadMainMenu();
                        }
                    }
                    else
                    {
                        MpDrawingsFunction.LoadMainMenu();
                    }
                }

                // Ribbon
                // Если включили и была выключена
                if (ChkMpRibbon.IsChecked.Value && !_curRibbon)
                {
                    RibbonBuilder.BuildRibbon();
                }

                // Если включили и была включена, но сменился язык
                if (ChkMpRibbon.IsChecked.Value && _curRibbon && isDifferentLanguage)
                {
                    RibbonBuilder.RemoveRibbon();
                    RibbonBuilder.BuildRibbon(true);
                }

                // Если выключили и была включена
                if (!ChkMpRibbon.IsChecked.Value && _curRibbon)
                {
                    RibbonBuilder.RemoveRibbon();
                }

                // context menu
                // если сменился язык, то все выгружаю
                if (isDifferentLanguage)
                {
                    MiniFunctions.UnloadAll();
                }

                MiniFunctions.LoadUnloadContextMenu();

                // License server
                UserConfigFile.SetValue(UserConfigFile.ConfigFileZone.Settings, "DisableConnectionWithLicenseServerInAutoCAD",
                                        ChkDisableConnectionWithLicenseServer.IsChecked.Value.ToString(), true);
                Regestry.SetValue("LocalLicenseServerIpAddress", TbLocalLicenseServerIpAddress.Text);
                Regestry.SetValue("LocalLicenseServerPort", TbLocalLicenseServerPort.Value.ToString());

                if (_restartClientOnClose)
                {
                    // reload server
                    ClientStarter.StopConnection();
                    ClientStarter.StartConnection(ProductLicenseType.AutoCAD);
                }

                // перевод фокуса на автокад
                Utils.SetFocusToDwgView();
            }
            catch (Exception ex)
            {
                ExceptionBox.Show(ex);
            }
        }
コード例 #17
0
 private static void ConnectallClients()
 {
     _logger.Info($"{Datas.CountOfMonitors} kliens létrehozássa...");
     ClientStarter.StartClients(Datas.CountOfMonitors);
     _logger.Info($"{Datas.CountOfMonitors} kliens létrehozássa kész");
 }
コード例 #18
0
 private static void Client_OnDisconnect(object sender, EasyTcpClient e)
 {
     ClientStarter.StartClients(Datas.CountOfMonitors);
 }