示例#1
0
        /// <summary>
        /// Creates a stationary process with a few inputs and outputs, then insert this process to the database
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonNewStationaryProcess_Click(object sender, EventArgs e)
        {
            //Hardcoded crude oil resource ID, could be fetched from the IData class instead
            int CRUDE_RES_ID = 23;
            //Hardcoded mix for crude oil production, could be fectched from the IData class instead
            int CRUDE_FOR_US_MIX = 0;
            //Hardcoded pathway id for conventional crude recovery, could be fetched from the IData class instead
            int CRUDE_RECOVERY_PROCESS = 34;
            //Approximation of a BTU International in Joules
            double BTU = 1055.5;
            //Technology
            int TECH_BOIL = 230106;

            //Creates an instance of a process
            IProcess process = _dataHelper.CreateNewProcess(0, "Example4 Stationary Process");

            //Creates instances of inputs and outputs to be used in that stationary process
            IInput input      = _dataHelper.CreateNewInput(CRUDE_RES_ID, BTU / 2, "joules", 3, CRUDE_FOR_US_MIX);
            bool   success    = _dataHelper.InputAddTechnology(input, TECH_BOIL, 1);
            IInput input2     = _dataHelper.CreateNewInput(CRUDE_RES_ID, BTU / 2, "joules", 2, CRUDE_RECOVERY_PROCESS);
            IIO    mainOutput = _dataHelper.CreateNewMainOutput(CRUDE_RES_ID, 1055, "joules");
            IIO    coProduct  = _dataHelper.CreateNewCoProduct(CRUDE_RES_ID, 0, "joules");

            //Adds all inputs and outputs to the process
            success &= _dataHelper.ProcessAddInput(process, input, false);
            success &= _dataHelper.ProcessAddInput(process, input2, false);
            success &= _dataHelper.ProcessAddOrUpdateOutput(process, coProduct);
            success &= _dataHelper.ProcessAddOrUpdateOutput(process, mainOutput);

            //Inserts the complete process to the current dataset
            success &= _dataHelper.DataInsertOrUpdateProcess(process);

            if (success)
            {
                MessageBox.Show("Process named : '" + process.Name + "' inserted in dataset");
            }
            else
            {
                MessageBox.Show("Failure");
            }
        }