/// <summary>
        ///     Validate the package manager url and initialize the PackageManagerClient object
        /// </summary>
        public void Startup(StartupParams startupParams)
        {
            var path   = this.GetType().Assembly.Location;
            var config = ConfigurationManager.OpenExeConfiguration(path);

            //var key = config.AppSettings.Settings["packageManagerAddress"];
            //string url = null;
            //if (key != null)
            //{
            //    url = key.Value;
            //}

            //OnMessageLogged(LogMessage.Info("Dynamo will use the package manager server at : " + url));

            //if (!Uri.IsWellFormedUriString(url, UriKind.Absolute))
            //{
            //    throw new ArgumentException("Incorrectly formatted URL provided for Package Manager address.", "url");
            //}

            PackageLoader = new PackageLoader(startupParams.PathManager.PackagesDirectories);
            PackageLoader.MessageLogged          += OnMessageLogged;
            RequestLoadNodeLibraryHandler         = startupParams.LibraryLoader.LoadNodeLibrary;
            RequestLoadCustomNodeDirectoryHandler = (dir) => startupParams.CustomNodeManager
                                                    .AddUninitializedCustomNodesInPath(dir, true);

            //raise the public events on this extension when the package loader requests.
            PackageLoader.RequestLoadExtension += RequestLoadExtension;
            PackageLoader.RequestAddExtension  += RequestAddExtension;

            PackageLoader.RequestLoadNodeLibrary         += RequestLoadNodeLibraryHandler;
            PackageLoader.RequestLoadCustomNodeDirectory += RequestLoadCustomNodeDirectoryHandler;
        }
        /// <summary>
        ///     Validate the package manager url and initialize the PackageManagerClient object
        /// </summary>
        public void Startup(StartupParams startupParams)
        {
            var    path   = this.GetType().Assembly.Location;
            var    config = ConfigurationManager.OpenExeConfiguration(path);
            var    key    = config.AppSettings.Settings["packageManagerAddress"];
            string url    = null;

            if (key != null)
            {
                url = key.Value;
            }

            OnMessageLogged(LogMessage.Info("Dynamo will use the package manager server at : " + url));

            if (!Uri.IsWellFormedUriString(url, UriKind.Absolute))
            {
                throw new ArgumentException("Incorrectly formatted URL provided for Package Manager address.", "url");
            }

            this.packageLoader = new PackageLoader(startupParams.PathManager.PackagesDirectory);
            this.packageLoader.MessageLogged                  += OnMessageLogged;
            this.packageLoader.RequestLoadNodeLibrary         += OnRequestLoadNodeLibrary;
            this.packageLoader.RequestLoadCustomNodeDirectory +=
                (dir) => startupParams.CustomNodeManager
                .AddUninitializedCustomNodesInPath(dir, DynamoModel.IsTestMode, true);

            var dirBuilder = new PackageDirectoryBuilder(
                new MutatingFileSystem(),
                new CustomNodePathRemapper(startupParams.CustomNodeManager, DynamoModel.IsTestMode));

            var uploadBuilder = new PackageUploadBuilder(dirBuilder, new MutatingFileCompressor());

            this.packageManagerClient = new PackageManagerClient(new GregClient(startupParams.AuthProvider, url),
                                                                 uploadBuilder, PackageLoader.RootPackagesDirectory);
        }
Example #3
0
        public void Startup(StartupParams sp)
        {
            var revitProcess  = Process.GetCurrentProcess();
            var revitFilePath = revitProcess.MainModule?.FileName;

            if (string.IsNullOrWhiteSpace(revitFilePath))
            {
                return;
            }

            var binDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            if (string.IsNullOrWhiteSpace(binDir))
            {
                return;
            }

            var version = FileVersionInfo.GetVersionInfo(revitFilePath).FileMajorPart;
            var zipPath = Path.Combine(Path.Combine(binDir, @"..\"), $"extra\\20{version}.zip");

            if (!File.Exists(zipPath))
            {
                return;
            }

            var unzippedDir = Path.Combine(Path.Combine(binDir, @"..\"), $"extra\\20{version}");

            using (var zipToOpen = new FileStream(zipPath, FileMode.Open))
            {
                using (var archive = new ZipArchive(zipToOpen, ZipArchiveMode.Update))
                {
                    archive.ExtractToDirectory(unzippedDir, true);
                }
            }

            if (!Directory.Exists(unzippedDir))
            {
                return;
            }

            var pathUi = Path.Combine(Path.Combine(binDir, @"..\"), $"extra\\20{version}\\archilabUI20{version}.dll");
            var path   = Path.Combine(Path.Combine(binDir, @"..\"), $"extra\\20{version}\\archilab20{version}.dll");

            if (!File.Exists(path) || !File.Exists(pathUi))
            {
                return;
            }

            sp.LibraryLoader.LoadNodeLibrary(Assembly.LoadFrom(path));
            sp.LibraryLoader.LoadNodeLibrary(Assembly.LoadFrom(pathUi));

            // (Konrad) Load the View Extension as a Node Library so that the Relay Node Model is loaded.
            var viewExtensionPath = Path.Combine(binDir, "archilabViewExtension.dll");

            if (File.Exists(viewExtensionPath))
            {
                sp.LibraryLoader.LoadNodeLibrary(Assembly.LoadFrom(viewExtensionPath));
            }
        }
Example #4
0
        static void Main(string[] args)
        {
            try
            {
                Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
                AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

                CheckForUpgradeSettings();

                string dataMartClientId = Properties.Settings.Default.DataMartClientId;
                if (dataMartClientId == null || dataMartClientId == string.Empty)
                {
                    dataMartClientId = Properties.Settings.Default.DataMartClientId = Guid.NewGuid().ToString().ToUpper();
                }

                log4net.GlobalContext.Properties["LogFilePath"] = Properties.Settings.Default.LogFilePath;

                XmlConfigurator.ConfigureAndWatch(new FileInfo(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile));
                logWatcher = new LogWatcher(Properties.Settings.Default.LogLevel, Properties.Settings.Default.LogFilePath, dataMartClientId);
                log.Info("Started DataMart Client Application");
                SystemInfo.LogUserMachineInfo();
                Configuration.LogNetworkSettingsFile();
                log.Info("Check for single instance");

                CheckForShortcut();

                if (!SingleInstanceChecker.Start())
                {
                    StartupParams.WriteStartupParamsToFile(args);
                    SingleInstanceChecker.ShowFirstInstance();
                    return;
                }

                Dictionary <string, string> AddNetworkStartupParamsDict = StartupParams.GetAddNetworkStartupParamsDictionary(StartupParams.GetStartupParamsXml(args));

                log.Info("Run instance");

                System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12 | System.Net.SecurityProtocolType.Tls11 | System.Net.SecurityProtocolType.Tls;
                System.Net.ServicePointManager.CheckCertificateRevocationList       = true;
                System.Net.ServicePointManager.ServerCertificateValidationCallback += delegate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
                {
                    ////Commented out for removal of Thumprint Check
                    // return ValidateCertificate((System.Net.HttpWebRequest)sender, certificate, chain);
                    return(true);
                };


                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new RequestListForm(AddNetworkStartupParamsDict));
            }
            catch (Exception ex)
            {
                log.Fatal("Following error occured starting DataMartClient: " + ex.Message, ex);
                MessageBox.Show("Error occured starting DataMartClient. Please contact administrator.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            SingleInstanceChecker.Stop();
        }
Example #5
0
        /// <summary>
        ///     Validate the package manager url and initialize the PackageManagerClient object
        /// </summary>
        public void Startup(StartupParams startupParams)
        {
            var    path   = this.GetType().Assembly.Location;
            var    config = ConfigurationManager.OpenExeConfiguration(path);
            var    key    = config.AppSettings.Settings["packageManagerAddress"];
            string url    = null;

            if (key != null)
            {
                url = key.Value;
            }

            OnMessageLogged(LogMessage.Info("Dynamo will use the package manager server at : " + url));

            if (!Uri.IsWellFormedUriString(url, UriKind.Absolute))
            {
                throw new ArgumentException("Incorrectly formatted URL provided for Package Manager address.", "url");
            }

            PackageLoader = new PackageLoader(startupParams.PathManager);
            PackageLoader.MessageLogged  += OnMessageLogged;
            PackageLoader.PackgeLoaded   += OnPackageLoaded;
            PackageLoader.PackageRemoved += OnPackageRemoved;
            RequestLoadNodeLibraryHandler = (startupParams.LibraryLoader as ExtensionLibraryLoader).LoadLibraryAndSuppressZTSearchImport;
            //TODO: Add LoadPackages to ILibraryLoader interface in 3.0
            LoadPackagesHandler = (startupParams.LibraryLoader as ExtensionLibraryLoader).LoadPackages;
            customNodeManager   = (startupParams.CustomNodeManager as Core.CustomNodeManager);

            //TODO - in 3.0 we can add the other overload of AddUninitializedCustomNodesInPath to the ICustomNodeManager interface.
            RequestLoadCustomNodeDirectoryHandler = (dir, pkgInfo) => customNodeManager
                                                    .AddUninitializedCustomNodesInPath(dir, DynamoModel.IsTestMode, pkgInfo);

            //when the customNodeManager requests to know the owner of a customNode handle this query.
            customNodeManager.RequestCustomNodeOwner += handleCustomNodeOwnerQuery;

            //raise the public events on this extension when the package loader requests.
            PackageLoader.RequestLoadExtension           += RequestLoadExtension;
            PackageLoader.RequestAddExtension            += RequestAddExtension;
            PackageLoader.PackagesLoaded                 += LoadPackagesHandler;
            PackageLoader.RequestLoadNodeLibrary         += RequestLoadNodeLibraryHandler;
            PackageLoader.RequestLoadCustomNodeDirectory += RequestLoadCustomNodeDirectoryHandler;

            var dirBuilder = new PackageDirectoryBuilder(
                new MutatingFileSystem(),
                new CustomNodePathRemapper(startupParams.CustomNodeManager, DynamoModel.IsTestMode));

            PackageUploadBuilder.SetEngineVersion(startupParams.DynamoVersion);
            var uploadBuilder = new PackageUploadBuilder(dirBuilder, new MutatingFileCompressor());

            var packageUploadDirectory = startupParams.PathManager.DefaultPackagesDirectory;

            PackageManagerClient = new PackageManagerClient(
                new GregClient(startupParams.AuthProvider, url),
                uploadBuilder, packageUploadDirectory);

            LoadPackages(startupParams.Preferences, startupParams.PathManager);
        }
Example #6
0
        public void WarningShowsWhenSavingWithLinterWarningsOrErrors()
        {
            // Arrange
            var expectedWindowTitle = WpfResources.GraphIssuesOnSave_Title;
            var recivedEvents       = new List <string>();

            ViewModel.SaveWarningOnUnresolvedIssuesShows += delegate(SaveWarningOnUnresolvedIssuesArgs e)
            {
                recivedEvents.Add(e.TaskDialog.Title);
            };

            Mock <LinterExtensionBase> mockLinter = new Mock <LinterExtensionBase>()
            {
                CallBase = true
            };

            SetupMockLinter(mockLinter);

            var startupParams = new StartupParams(Model.AuthenticationManager.AuthProvider,
                                                  Model.PathManager, new ExtensionLibraryLoader(Model), Model.CustomNodeManager,
                                                  Model.GetType().Assembly.GetName().Version, Model.PreferenceSettings, Model.LinterManager);

            mockLinter.Object.InitializeBase(Model.LinterManager);
            mockLinter.Object.Startup(startupParams);
            Model.ExtensionManager.Add(mockLinter.Object);

            OpenDynamoDefinition(Path.Combine(GetTestDirectory(ExecutingDirectory), @"UI/SaveWithIssuesWarning.dyn"));

            var failureNode = new DummyNode();

            Model.ExecuteCommand(new DynamoModel.CreateNodeCommand(failureNode, 0, 0, false, false));

            Model.LinterManager.SetActiveLinter(Model.LinterManager.AvailableLinters
                                                .Where(x => x.Id == mockLinter.Object.UniqueId)
                                                .FirstOrDefault());

            // Act
            failureNode.Name = "NewNodeName";
            Assert.That(Model.LinterManager.RuleEvaluationResults.Count > 0);

            ViewModel.ShowSaveDialogIfNeededAndSaveResult(null);

            // Assert
            Assert.That(recivedEvents.Count == 1);
            Assert.That(recivedEvents.First() == expectedWindowTitle);
        }
 /// <summary>
 /// Code to show single instance.
 /// </summary>
 /// <param name="message"></param>
 protected override void WndProc(ref Message message)
 {
     try
     {
         if (message.Msg == SingleInstanceChecker.WM_SHOWFIRSTINSTANCE)
         {
             ShowWindow();
             ShowConnectToNetworkDialog(StartupParams.GetAddNetworkStartupParamsDictionary(StartupParams.ReadStartupParamsFromFile(true)));
         }
         base.WndProc(ref message);
     }
     catch (Exception ex)
     {
         log.Error(ex);
         // Log it and keep going.
     }
 }
 /// <summary>
 /// Method that is called when Dynamo starts, but is not yet ready to be used.
 /// </summary>
 /// <param name="sp">Parameters that provide references to Dynamo settings and version.</param>
 public void Startup(StartupParams sp)
 {
 }
 /// <summary>
 /// Action to be invoked when Dynamo begins to start up.
 /// </summary>
 /// <param name="sp"></param>
 public void Startup(StartupParams sp)
 {
     // Do nothing for now
 }
Example #10
0
 public void Startup(StartupParams sp)
 {
     AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
 }
Example #11
0
 /// <summary>
 /// Method that is called when Dynamo starts, but is not yet ready to be used.
 /// </summary>
 /// <param name="sp">Parameters that provide references to Dynamo settings and version.</param>
 public void Startup(StartupParams sp)
 {
     DynamoVersion = sp.DynamoVersion.ToString();
     TrackerEvents.DynamoVersion = DynamoVersion;
 }