/// <summary> /// Creates a new pathway with a few processes, then inserts that pathway in the database /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonNewPathway_Click(object sender, EventArgs e) { //Hardcoded crude oil resource ID, could be fetched from the IData class instead int CRUDE_RES_ID = 23; //Hardcoded process model id int PROC_ID_REC = 200, PROC_ID_TRA = 1000, PROC_ID_STO = 201; //Creates an instance of a pathway IPathway path = _dataHelper.CreateNewPathway("Example4 Pathway"); //Retrieves process models from the current dataset IProcess procr = _controller.CurrentProject.Data.Processes.ValueForKey(PROC_ID_REC); IProcess proct = _controller.CurrentProject.Data.Processes.ValueForKey(PROC_ID_TRA); IProcess procs = _controller.CurrentProject.Data.Processes.ValueForKey(PROC_ID_STO); //Add processes models to the pathway, vertices will be created for each process model added to the pathway IVertex vertexR = _dataHelper.PathwayAddModel(path, procr); IVertex vertexT = _dataHelper.PathwayAddModel(path, proct); IVertex vertexS = _dataHelper.PathwayAddModel(path, procs); //finds input and outputs ID from the model, then add a connector in the pathway IInput inpT = proct.FlattenInputList.First(); IIO outR = procr.FlattenAllocatedOutputList.First(); bool success = _dataHelper.PathwayAddConnector(path, vertexR.ID, outR.Id, vertexT.ID, inpT.Id); //finds input and outputs ID from the model, then add a connector in the pathway IInput inpS = procs.FlattenInputList.First(); IIO outT = proct.FlattenAllocatedOutputList.First(); success &= _dataHelper.PathwayAddConnector(path, vertexT.ID, outT.Id, vertexS.ID, inpS.Id); //creates a pathway output then connect the last process in the pathway to that output IIO pathOut = _dataHelper.PathwayCreateOutput(path, CRUDE_RES_ID); success &= _dataHelper.PathwaySetMainOutput(path, pathOut.Id); IIO outS = procs.FlattenAllocatedOutputList.First(); success &= _dataHelper.PathwayAddConnector(path, vertexS.ID, outS.Id, pathOut.Id); //inserts the pathway to the current dataset success &= _dataHelper.DataInsertOrUpdatePathway(path); if (success) { MessageBox.Show("Pathway named : '" + path.Name + "' inserted in dataset"); } else { MessageBox.Show("Failure"); } }