System.Reflection.Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args) { var dllName = args.Name.Split(',')[0]; string execAsmPath = Path.GetDirectoryName( System.Reflection.Assembly .GetExecutingAssembly().Location); var filename = Path.Combine(execAsmPath, $"{dllName}.dll"); if (File.Exists(filename)) { HyparLogger.Information("Loading {AsmName}...", args.Name); return(System.Reflection.Assembly.LoadFrom(filename)); } return(null); }
public bool Stop() { HyparLogger.Information("Stopping the hypar connection..."); var task = Task.Run(async() => { try { await _hyparConnection.StopAsync(); return(true); } catch (Exception ex) { HyparLogger.Debug(ex.Message); HyparLogger.Debug(ex.StackTrace); return(false); } }); return(task.Result); }
public bool Start(UIDocument uiDocument) { if (_hyparConnection == null) { HyparLogger.Information("Creating hypar connection..."); _hyparConnection = new HubConnectionBuilder() .WithUrl("http://localhost:5000/functionHub") .Build(); _hyparConnection.On <Dictionary <string, WorkflowSettings> >("WorkflowSettings", (settings) => { _settings = settings; }); _hyparConnection.On <Workflow>("WorkflowUpdated", (workflow) => { HyparLogger.Information("Received workflow updated for {WorkflowId}", workflow); // Check if the settings include sync with this document. if (!_settings.ContainsKey(workflow.Id)) { return; } var workflowSettings = _settings[workflow.Id]; var fileName = Path.GetFileName(uiDocument.Document.PathName); if (workflowSettings.Revit == null || workflowSettings.Revit.FileName == null || workflowSettings.Revit.FileName != fileName) { HyparLogger.Debug("The current Revit file, {RevitFileName} was not associated with the workflow settings. No sync will occur.", fileName); return; } if (!CurrentWorkflows.ContainsKey(workflow.Id)) { CurrentWorkflows.Add(workflow.Id, workflow); } else { CurrentWorkflows[workflow.Id] = workflow; } RefreshView(uiDocument); }); } HyparLogger.Information("Starting the hypar connection..."); var task = Task.Run <bool>(async() => { try { await _hyparConnection.StartAsync(); return(true); } catch (Exception ex) { HyparLogger.Debug(ex.Message); HyparLogger.Debug(ex.StackTrace); return(false); } }); return(task.Result); }