private static string DoPackageFileOperationsAndZip(DynamoModel dynamoModel, Package pkg, List<string> files, PackageUploadHandle uploadHandle) { uploadHandle.UploadState = PackageUploadHandle.State.Copying; DirectoryInfo rootDir, dyfDir, binDir, extraDir; FormPackageDirectory(dynamoModel.Loader.PackageLoader.RootPackagesDirectory, pkg.Name, out rootDir, out dyfDir, out binDir, out extraDir); // shouldn't do anything for pkg versions pkg.RootDirectory = rootDir.FullName; WritePackageHeader(pkg.Header, rootDir); CopyFilesIntoPackageDirectory(files, dyfDir, binDir, extraDir); RemoveDyfFiles(files, dyfDir); RemapCustomNodeFilePaths(dynamoModel.CustomNodeManager, files, dyfDir.FullName); uploadHandle.UploadState = PackageUploadHandle.State.Compressing; string zipPath; FileInfo info; try { zipPath = Greg.Utility.FileUtilities.Zip(rootDir.FullName); info = new FileInfo(zipPath); } catch { // give nicer error throw new Exception("Could not compress file. Is the file in use?"); } if (info.Length > 15 * 1000000) throw new Exception("The package is too large! The package must be less than 15 MB!"); return zipPath; }
public EngineController(DynamoModel dynamoModel, string geometryFactoryFileName) { this.dynamoModel = dynamoModel; // Create a core which is used for parsing code and loading libraries libraryCore = new ProtoCore.Core(new Options() { RootCustomPropertyFilterPathName = string.Empty }); libraryCore.Executives.Add(Language.kAssociative,new ProtoAssociative.Executive(libraryCore)); libraryCore.Executives.Add(Language.kImperative, new ProtoImperative.Executive(libraryCore)); libraryCore.ParsingMode = ParseMode.AllowNonAssignment; libraryServices = new LibraryServices(libraryCore); libraryServices.LibraryLoading += this.LibraryLoading; libraryServices.LibraryLoadFailed += this.LibraryLoadFailed; libraryServices.LibraryLoaded += this.LibraryLoaded; liveRunnerServices = new LiveRunnerServices(dynamoModel, this, geometryFactoryFileName); liveRunnerServices.ReloadAllLibraries(libraryServices.ImportedLibraries); codeCompletionServices = new CodeCompletionServices(LiveRunnerCore); astBuilder = new AstBuilder(dynamoModel, this); syncDataManager = new SyncDataManager(); dynamoModel.NodeDeleted += NodeDeleted; }
//Service start public static void Start(DynamoModel dynamoModel) { string appVersion = Process.GetCurrentProcess().ProcessName + "-" + UpdateManager.UpdateManager.Instance.ProductVersion.ToString(); CSharpAnalytics.MeasurementConfiguration mc = new MeasurementConfiguration(ANALYTICS_PROPERTY, "Dynamo", appVersion); sessionID = Guid.NewGuid().ToString(); loggerImpl = new Log("Dynamo", userID, sessionID); CSharpAnalytics.AutoMeasurement.Start(mc); client = AutoMeasurement.Client; if (IS_VERBOSE_DIAGNOSTICS) { AutoMeasurement.DebugWriter = d => Debug.WriteLine(d); } started = true; // The following starts the heartbeat, do not remove this // because of the unreferenced "heartbeat" variable. // ReSharper disable UnusedVariable var heartbeat = Heartbeat.GetInstance(dynamoModel); // ReSharper restore UnusedVariable }
protected AbstractMutator(Random rand) { this.Rand = rand; this.Controller = dynSettings.Controller; this.DynamoViewModel = Controller.DynamoViewModel; this.DynamoModel = Controller.DynamoModel; }
//Service start public static void Start(DynamoModel dynamoModel) { InstrumentationLogger.dynamoModel = dynamoModel; if (IsAnalyticsEnabled) { string appVersion = dynamoModel.AppVersion; var mc = new MeasurementConfiguration(ANALYTICS_PROPERTY, "Dynamo", appVersion); mc.AnonymizeIp = true; sessionID = Guid.NewGuid().ToString(); loggerImpl = new Log("Dynamo", userID, sessionID); AutoMeasurement.Start(mc); client = AutoMeasurement.Client; if (IS_VERBOSE_DIAGNOSTICS) AutoMeasurement.DebugWriter = d => Debug.WriteLine(d); started = true; } // The following starts the heartbeat, do not remove this // because of the unreferenced "heartbeat" variable. // ReSharper disable UnusedVariable var heartbeat = Heartbeat.GetInstance(dynamoModel); // ReSharper restore UnusedVariable }
public bool Extract(DynamoModel dynamoModel, string installDirectory, out Package pkg) { this.DownloadState = State.Installing; // unzip, place files var unzipPath = Greg.Utility.FileUtilities.UnZip(DownloadPath); if (!Directory.Exists(unzipPath)) { throw new Exception(Properties.Resources.PackageEmpty); } if (String.IsNullOrEmpty(installDirectory)) installDirectory = dynamoModel.PathManager.DefaultPackagesDirectory; var installedPath = BuildInstallDirectoryString(installDirectory); Directory.CreateDirectory(installedPath); // Now create all of the directories foreach (string dirPath in Directory.GetDirectories(unzipPath, "*", SearchOption.AllDirectories)) Directory.CreateDirectory(dirPath.Replace(unzipPath, installedPath)); // Copy all the files foreach (string newPath in Directory.GetFiles(unzipPath, "*.*", SearchOption.AllDirectories)) File.Copy(newPath, newPath.Replace(unzipPath, installedPath)); // provide handle to installed package pkg = new Package(installedPath, Header.name, VersionName, Header.license); return true; }
public CefCommands(PackageLoader loader, DynamoModel model) { this.ProductName = !string.IsNullOrEmpty(model.HostName) ? model.HostName : "Dynamo"; this.Loader = loader; this.Model = model; this.Client = new DynamoPackagesUIClient(); }
/// <summary> /// Class Constructor /// </summary> /// <param name="dynamoModel"></param> /// <param name="searchPath">The path to search for definitions</param> public CustomNodeManager(DynamoModel dynamoModel, string searchPath) { this.dynamoModel = dynamoModel; SearchPath = new ObservableCollection<string> { searchPath }; NodeInfos = new ObservableDictionary<Guid, CustomNodeInfo>(); AddDirectoryToSearchPath(DynamoPathManager.Instance.CommonDefinitions); }
public void ExecuteCommand(DynamoModel.RecordableCommand command, string uniqueId, string extensionName) { // log that the command is being executed if (dynamoModel.DebugSettings.VerboseLogging) { dynamoModel.Logger.Log("Command: " + command); } var extnDetails = string.Format( "ExtensionCommandExecutive ( UniqueId: {0}, Name: {1}, commandTypeName: {2} )", uniqueId, extensionName, command.GetType().Name); Log(LogMessage.Info(extnDetails)); try { // run the command dynamoModel.ExecuteCommand(command); } catch (Exception e) { // clean up or show failure messages Log(LogMessage.Error(string.Format("{0}, from {1}", e.Message, extnDetails))); } }
public Watch3DViewModelStartupParams(DynamoModel model) { Model = model; Scheduler = model.Scheduler; Logger = model.Logger; Preferences = model.PreferenceSettings; EngineControllerManager = model; }
public static string ConvertNodesToCode(DynamoModel dynamoModel, IEnumerable<NodeModel> nodeList) { var astBuilder = new AstBuilder(dynamoModel, null); var astNodes = astBuilder.CompileToAstNodes(nodeList, false); string code = GraphToDSCompiler.GraphUtilities.ASTListToCode(astNodes); return code; }
public static string ConvertNodesToCode(DynamoModel dynamoModel, IEnumerable<NodeModel> nodeList) { var astBuilder = new AstBuilder(dynamoModel, null); var astNodes = astBuilder.CompileToAstNodes(nodeList, false); var codeGen = new ProtoCore.CodeGenDS(astNodes); return codeGen.GenerateCode(); }
/// <summary> /// Constructor /// </summary> /// <param name="dynamoViewModel"></param> /// <param name="model"></param> /// <param name="address"></param> public PackageManagerViewModel(PackageLoader loader, DynamoModel model, string address) { PkgMgrCommands = new PackageManagerCommands(loader, model); var path = this.GetType().Assembly.Location; var config = ConfigurationManager.OpenExeConfiguration(path); this.Address = PACKAGE_MANAGER_URL + "/#/" + address; }
void OnModelCommandCompleted(DynamoModel.RecordableCommand command) { var name = command.GetType().Name; switch (name) { case "OpenFileCommand": this.AddToRecentFiles((command as DynamoModel.OpenFileCommand).XmlFilePath); this.VisualizationManager.UnPause(); break; case "MutateTestCommand": var mutatorDriver = new Dynamo.TestInfrastructure.MutatorDriver(this); mutatorDriver.RunMutationTests(); break; case "SelectInRegionCommand": var selectC = command as DynamoModel.SelectInRegionCommand; CurrentSpaceViewModel.SelectInRegion(selectC.Region, selectC.IsCrossSelection); break; case "DragSelectionCommand": var dragC = command as DynamoModel.DragSelectionCommand; if (DynamoModel.DragSelectionCommand.Operation.BeginDrag == dragC.DragOperation) CurrentSpaceViewModel.BeginDragSelection(dragC.MouseCursor); else CurrentSpaceViewModel.EndDragSelection(dragC.MouseCursor); break; case "DeleteModelCommand": case "CreateNodeCommand": case "CreateNoteCommand": case "UndoRedoCommand": case "ModelEventCommand": case "UpdateModelValueCommand": case "ConvertNodesToCodeCommand": UndoCommand.RaiseCanExecuteChanged(); RedoCommand.RaiseCanExecuteChanged(); break; case "SwitchTabCommand": if (command.IsInPlaybackMode) RaisePropertyChanged("CurrentWorkspaceIndex"); break; case "RunCancelCommand": case "ForceRunCancelCommand": case "SelectModelCommand": case "MakeConnectionCommand": case "CreateCustomNodeCommand": // for this commands there is no need // to do anything after execution break; default: throw new InvalidOperationException("Unhandled command name"); } }
public PublishCommands(PackageLoader loader, DynamoModel model) { fileCompressor = new MutatingFileCompressor(); //customNodeDefinitions = new List<CustomNodeDefinition>(); //Dependencies = new List<PackageDependency>(); //Assemblies = new List<PackageAssembly>(); //PackageAssemblyNodes = new List<TypeLoadData>(); //FilesToUpload = new List<string>(); }
/// <summary> /// Constructs a new execution session. /// </summary> public ExecutionSession(Scheduler.UpdateGraphAsyncTask updateTask, DynamoModel model, string geometryFactoryPath) { CurrentWorkspacePath = updateTask.TargetedWorkspace.FileName; pathManager = model.PathManager; parameters[ParameterKeys.GeometryFactory] = geometryFactoryPath; parameters[ParameterKeys.MajorVersion] = pathManager.MajorFileVersion; parameters[ParameterKeys.MinorVersion] = pathManager.MinorFileVersion; parameters[ParameterKeys.NumberFormat] = model.PreferenceSettings.NumberFormat; }
public static Heartbeat GetInstance(DynamoModel dynModel) { lock (typeof(Heartbeat)) { if (instance == null) instance = new Heartbeat(dynModel); } return instance; }
public PackageLoader(DynamoModel dynamoModel, string overridePackageDirectory) { this.dynamoModel = dynamoModel; this.RootPackagesDirectory = overridePackageDirectory; if (!Directory.Exists(this.RootPackagesDirectory)) { Directory.CreateDirectory(this.RootPackagesDirectory); } }
public void ExecuteCommand(DynamoModel.RecordableCommand command) { if (null != this.automationSettings) this.automationSettings.RecordCommand(command); if (Model.DebugSettings.VerboseLogging) model.Logger.Log("Command: " + command); this.model.ExecuteCommand(command); }
public CustomNodeWorkspaceModel(DynamoModel dynamoModel, String name, String category, string description, IEnumerable<NodeModel> e, IEnumerable<ConnectorModel> c, double x, double y) : base(dynamoModel, name, e, c, x, y) { WatchChanges = true; HasUnsavedChanges = false; Category = category; Description = description; PropertyChanged += OnPropertyChanged; }
public Package(DynamoModel dynamoModel, string directory, string name, string versionName) { this.dynamoModel = dynamoModel; this.Loaded = false; this.RootDirectory = directory; this.Name = name; this.VersionName = versionName; this.LoadedTypes = new ObservableCollection<Type>(); this.Dependencies = new ObservableCollection<PackageDependency>(); this.LoadedCustomNodes = new ObservableCollection<CustomNodeInfo>(); }
public void Start(DynamoModel model) { //Whether enabled or not, we still record the startup. Service.Instance.Register(new GATrackerFactory(ANALYTICS_PROPERTY)); StabilityCookie.Startup(); heartbeat = Heartbeat.GetInstance(model); logger = new UsageLog("Dynamo", UserId, SessionId); }
private Heartbeat(DynamoModel dynamoModel) { // KILLDYNSETTINGS - this is provisional - but we need to enforce that Hearbeat is // not referencing multiple DynamoModels this.dynamoModel = dynamoModel; startTime = DateTime.Now; heartbeatThread = new Thread(this.ExecThread); heartbeatThread.IsBackground = true; heartbeatThread.Start(); }
public void Init() { extensionsPath = Path.Combine(Directory.GetCurrentDirectory(), "extensions"); extMock = new Mock<IExtension>(); model = DynamoModel.Start( new DynamoModel.DefaultStartConfiguration() { StartInTestMode = true, Extensions = new List<IExtension> { extMock.Object } }); }
public Watch3DViewModelStartupParams(DynamoModel model, DynamoViewModel viewModel, string name) { Model = model; Scheduler = model.Scheduler; Logger = model.Logger; Preferences = model.PreferenceSettings; EngineControllerManager = model; RenderPackageFactory = viewModel.RenderPackageFactoryViewModel.Factory; ViewModel = viewModel; RenderPackageFactoryViewModel = viewModel.RenderPackageFactoryViewModel; Name = name; }
public void Init() { extensionsPath = Path.Combine(Directory.GetCurrentDirectory(), "extensions"); extMock = new Mock<IExtension>(); model = DynamoModel.Start( new DynamoModel.DefaultStartConfiguration() { StartInTestMode = true, Extensions = new List<IExtension> { extMock.Object }, ProcessMode = Core.Threading.TaskProcessMode.Synchronous }); }
public void Start(DynamoModel model) { //Whether enabled or not, we still record the startup. var service = Service.Instance; //Some clients such as Revit may allow start/close Dynamo multiple times //in the same session so register only if the factory is not registered. if(service.GetTrackerFactory(GATrackerFactory.Name) == null) service.Register(new GATrackerFactory(ANALYTICS_PROPERTY)); StabilityCookie.Startup(); heartbeat = Heartbeat.GetInstance(model); logger = new UsageLog("Dynamo", UserId, SessionId); }
public void TestOnRequestMigrationStatusDialog() { //Arrange //This will subscribe our local method to the RequestMigrationStatusDialog event DynCmd.RequestMigrationStatusDialog += DynamoModel_RequestMigrationStatusDialog; //Act //This will execute the OnRequestMigrationStatusDialog() in the DynamoModelEvents class DynCmd.OnRequestMigrationStatusDialog(new SettingsMigrationEventArgs( SettingsMigrationEventArgs.EventStatusType.Begin)); //Assert DynCmd.RequestMigrationStatusDialog -= DynamoModel_RequestMigrationStatusDialog; //This will validate that the local handler was executed and set the flag in true Assert.IsTrue(migrationStatusDialog); }
public EngineController(DynamoModel dynamoModel, string geometryFactoryFileName) { this.dynamoModel = dynamoModel; libraryServices = LibraryServices.GetInstance(); libraryServices.LibraryLoading += this.LibraryLoading; libraryServices.LibraryLoadFailed += this.LibraryLoadFailed; libraryServices.LibraryLoaded += this.LibraryLoaded; liveRunnerServices = new LiveRunnerServices(dynamoModel, this, geometryFactoryFileName); liveRunnerServices.ReloadAllLibraries(libraryServices.Libraries.ToList()); astBuilder = new AstBuilder(dynamoModel, this); syncDataManager = new SyncDataManager(); dynamoModel.NodeDeleted += NodeDeleted; }
public void Init() { extensionsPath = Path.Combine(Directory.GetCurrentDirectory(), "extensions"); extMock = new Mock<IExtension>(); extMock.Setup(ext => ext.Ready(It.IsAny<ReadyParams>())).Callback((ReadyParams r) => ExtensionReadyCallback(r)); cmdExecutionState = -1; model = DynamoModel.Start( new DynamoModel.DefaultStartConfiguration() { StartInTestMode = true, Extensions = new List<IExtension> { extMock.Object }, ProcessMode = TaskProcessMode.Synchronous }); model.ExtensionManager.ExtensionAdded += OnExtensionAdded; model.ExtensionManager.ExtensionRemoved += OnExtensionRemoved; }
private static string DoPackageFileOperationsAndZip(DynamoModel dynamoModel, Package pkg, List<string> files, PackageUploadHandle uploadHandle) { uploadHandle.UploadState = PackageUploadHandle.State.Copying; DirectoryInfo rootDir, dyfDir, binDir, extraDir; FormPackageDirectory(dynamoModel.Loader.PackageLoader.RootPackagesDirectory, pkg.Name, out rootDir, out dyfDir, out binDir, out extraDir); // shouldn't do anything for pkg versions pkg.RootDirectory = rootDir.FullName; WritePackageHeader(pkg.Header, rootDir); CopyFilesIntoPackageDirectory(files, dyfDir, binDir, extraDir); RemoveDyfFiles(files, dyfDir); RemapCustomNodeFilePaths(dynamoModel.CustomNodeManager, files, dyfDir.FullName); uploadHandle.UploadState = PackageUploadHandle.State.Compressing; var zipPath = Greg.Utility.FileUtilities.Zip(rootDir.FullName); return zipPath; }
public void CreateModel(XmlElement modelData) { XmlElementHelper helper = new XmlElementHelper(modelData); string typeName = helper.ReadString("type", String.Empty); if (string.IsNullOrEmpty(typeName)) { // If there wasn't a "type" attribute, then we fall-back onto // the name of the XmlElement itself, which is usually the type // name. typeName = modelData.Name; if (string.IsNullOrEmpty(typeName)) { string guid = helper.ReadString("guid"); throw new InvalidOperationException( string.Format("No type information: {0}", guid)); } } if (typeName.StartsWith("Dynamo.Nodes")) { NodeModel nodeModel = DynamoModel.CreateNodeInstance(typeName); nodeModel.WorkSpace = this; nodeModel.Deserialize(modelData, SaveContext.Undo); Nodes.Add(nodeModel); } else if (typeName.StartsWith("Dynamo.Models.ConnectorModel")) { ConnectorModel connector = ConnectorModel.Make(); connector.Deserialize(modelData, SaveContext.Undo); Connectors.Add(connector); } else if (typeName.StartsWith("Dynamo.Models.NoteModel")) { NoteModel noteModel = new NoteModel(0.0, 0.0); noteModel.Deserialize(modelData, SaveContext.Undo); Notes.Add(noteModel); } }
public HomeWorkspaceModel(DynamoModel dynamoModel) : this(dynamoModel, new List <NodeModel>(), new List <ConnectorModel>(), 0, 0) { }
public HomeWorkspaceModel(DynamoModel dynamoModel, IEnumerable <NodeModel> e, IEnumerable <ConnectorModel> c, double x, double y) : base(dynamoModel, "Home", e, c, x, y) { }
internal NodeFactory(WorkspaceModel workspaceModel, DynamoModel dynamoModel) { this.dynamoModel = dynamoModel; this.workspaceModel = workspaceModel; }
public CustomNodeWorkspaceModel(DynamoModel dynamoModel) : this(dynamoModel, "", "", "", new List <NodeModel>(), new List <ConnectorModel>(), 0, 0) { }
public static WorkspaceHeader FromPath(DynamoModel dynamoModel, string path) { try { var xmlDoc = new XmlDocument(); xmlDoc.Load(path); string funName = null; double cx = 0; double cy = 0; double zoom = 1.0; string id = ""; var topNode = xmlDoc.GetElementsByTagName("Workspace"); // legacy support if (topNode.Count == 0) { topNode = xmlDoc.GetElementsByTagName("dynWorkspace"); } // load the header foreach (XmlNode node in topNode) { foreach (XmlAttribute att in node.Attributes) { if (att.Name.Equals("X")) { cx = double.Parse(att.Value, CultureInfo.InvariantCulture); } else if (att.Name.Equals("Y")) { cy = double.Parse(att.Value, CultureInfo.InvariantCulture); } else if (att.Name.Equals("zoom")) { zoom = double.Parse(att.Value, CultureInfo.InvariantCulture); } else if (att.Name.Equals("Name")) { funName = att.Value; } else if (att.Name.Equals("ID")) { id = att.Value; } } } // we have a dyf and it lacks an ID field, we need to assign it // a deterministic guid based on its name. By doing it deterministically, // files remain compatible if (string.IsNullOrEmpty(id) && !string.IsNullOrEmpty(funName) && funName != "Home") { id = GuidUtility.Create(GuidUtility.UrlNamespace, funName).ToString(); } return(new WorkspaceHeader() { ID = id, Name = funName, X = cx, Y = cy, Zoom = zoom, FileName = path }); } catch (Exception ex) { dynamoModel.Logger.Log("There was an error opening the workbench."); dynamoModel.Logger.Log(ex); Debug.WriteLine(ex.Message + ":" + ex.StackTrace); if (DynamoModel.IsTestMode) { throw ex; // Rethrow for NUnit. } return(null); } }
protected override void ExecuteCore(DynamoModel dynamoModel) { // A PausePlaybackCommand should never be executed. throw new NotImplementedException(); }
protected override void ExecuteCore(DynamoModel dynamoModel) { dynamoModel.SwitchTabImpl(this); }
protected override void ExecuteCore(DynamoModel dynamoModel) { dynamoModel.SendModelEventImpl(this); }
protected override void ExecuteCore(DynamoModel dynamoModel) { dynamoModel.CreateNoteImpl(this); }
protected override void ExecuteCore(DynamoModel dynamoModel) { }
/// <summary> /// Call this method to execute a RecordableCommand. A RecordableCommand /// must be executed in the context of an existing DynamoViewModel. /// </summary> /// <param name="dynamoModel">The DynamoModel object this /// RecordableCommand is targeting.</param> /// internal void Execute(DynamoModel dynamoModel) { ExecuteCore(dynamoModel); }
protected override void ExecuteCore(DynamoModel dynamoModel) { dynamoModel.ForceRunCancelImpl(this); }
protected override void ExecuteCore(DynamoModel dynamoModel) { dynamoModel.OpenFileImpl(this); }
protected override void ExecuteCore(DynamoModel dynamoModel) { dynamoModel.ConvertNodesToCodeImpl(this); }
protected override void ExecuteCore(DynamoModel dynamoModel) { dynamoModel.UndoRedoImpl(this); }
protected override void ExecuteCore(DynamoModel dynamoModel) { dynamoModel.UpdateModelValueImpl(this); }
public CustomNodeWorkspaceModel(DynamoModel dynamoModel, String name, String category) : this(dynamoModel, name, category, "", new List <NodeModel>(), new List <ConnectorModel>(), 0, 0) { }
protected override void ExecuteCore(DynamoModel dynamoModel) { dynamoModel.MakeConnectionImpl(this); }
/// <summary> /// Derived classes must implement this method to perform the actual /// command execution. A typical implementation of this method involves /// calling a corresponding method on DynamoModel by passing itself as /// the only argument. /// </summary> /// <param name="dynamoModel">The DynamoModel object on which /// this command should be executed.</param> /// protected abstract void ExecuteCore(DynamoModel dynamoModel);
protected override void ExecuteCore(DynamoModel dynamoModel) { dynamoModel.DeleteModelImpl(this); }
public CustomNodeWorkspaceModel(DynamoModel dynamoModel, String name, String category, string description, double x, double y) : this(dynamoModel, name, category, description, new List <NodeModel>(), new List <ConnectorModel>(), x, y) { }