Esempio n. 1
0
        public static string LogArrivalWithWait(Node n)
        {
            string s = "Customer " + n.GetCustomerNumber() + " arrives at time " + n.GetArrivalTime()
                       + ", and waits for customer " + SimulationAlgorithm.GetCustomerAtTellerNumber();

            return(s);
        }
        //Method to export the simulation output & analysis to a text file.
        public static void ExportResult(TextBox outputText, TextBox analysis)
        {
            string filePath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);

            filePath = filePath + "/SimOutput" + outputFileCount.ToString() + ".txt";
            outputFileCount++;

            try
            {
                if (File.Exists(filePath))
                {
                    File.Delete(filePath);
                }

                using (FileStream fs = File.Create(filePath))
                {
                    if (outputText.Text.Equals("Please Select a Data File to Run the Simulation With!") || outputText.Text.Equals(""))
                    {
                        Byte[] output = new UTF8Encoding(true).GetBytes("");
                        fs.Write(output, 0, output.Length);
                    }
                    else
                    {
                        Byte[] output = new UTF8Encoding(true).GetBytes(GetSimStartLabel()
                                                                        + SimulationAlgorithm.GetOutputString() + GetSimFinishedLabel() + analysis.Text);
                        fs.Write(output, 0, output.Length);
                    }
                }
            }
            catch (System.IO.IOException e)
            {
                System.Windows.MessageBox.Show("This file is being used by another process.");
            }
        }