/// <summary> /// Creates a transportation process with a few steps, then insert this process to the database /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonNewTransportationProcess_Click(object sender, EventArgs e) { //Hardcoded crude oil resource ID, could be fetched from the IData class instead int CRUDE_RES_ID = 23; //Creates an instance of a process IProcess process = _dataHelper.CreateNewProcess(1, "Example4 Transportation Process"); //Set the resource being transported by the process. It is necessary to do that before inserting steps _dataHelper.TransportationSetResource(process, CRUDE_RES_ID); //Creates instances of transportation steps ITransportationStep step1 = _dataHelper.CreateNewTStep(1, 1, 100); ITransportationStep step2 = _dataHelper.CreateNewTStep(1, 1, 100); //Adds steps to the transportation step bool success = _dataHelper.TransportationAddTStep(process, step1); success &= _dataHelper.TransportationAddTStep(process, step2); //Retrieves locations from the current dataset, it's not relevant to the calculation to know which locations are used, only for visualisation ILocation locationA = _controller.CurrentProject.Data.Locations.ValueForKey(3); ILocation locationB = _controller.CurrentProject.Data.Locations.ValueForKey(1); ILocation locationC = _controller.CurrentProject.Data.Locations.ValueForKey(2); //Connecting the steps and locoations together to form the transportation process success &= _dataHelper.TransportationAddConnector(locationA, step1); // A -> Step1 success &= _dataHelper.TransportationAddConnector(step1, locationB); // Step1 -> B success &= _dataHelper.TransportationAddConnector(locationB, step2); // B -> Step2 success &= _dataHelper.TransportationAddConnector(step2, locationC); // Step2 -> C //Insert the completed transportation process in the current dataset success &= _dataHelper.DataInsertOrUpdateProcess(process); if (success) { MessageBox.Show("Process named : '" + process.Name + "' inserted in dataset"); } else { MessageBox.Show("Failure"); } }