static bool Run(CmdArgs args, bool Verbose)
        {
            bool sim_run = true;
             MohidRunEngineData data = new MohidRunEngineData();
             data.args = args;
             OPTamegaScript op = new OPTamegaScript();

             try
             {
            if (Verbose) Console.Write("Loading Configuration...");
            LoadConfig(args, data);
            if (Verbose) Console.WriteLine("[OK]");

            if (Verbose) Console.Write("Running...");
            op.OnSimStart(data);
            if (Verbose) Console.WriteLine("[OK]");

             }
             catch (Exception ex)
             {
            if (Verbose)
            {
               Console.WriteLine("[FAILED]");
               Console.WriteLine("");
               Console.WriteLine("An EXCEPTION was raised. The message returned was:");
               Console.WriteLine(ex.Message);
               Console.WriteLine("");
            }
             }

             return sim_run;
        }
        static void Main(string[] args)
        {
            OPTamegaScript script = new OPTamegaScript();
             CmdArgs cmdArgs = null;
             Exception e = null;
             bool sendMail = false;
             bool sendSMS = false;
             bool verbose = false;

             try
             {
            Setup.StandartSetup();
            cmdArgs = new CmdArgs(args);

            if (cmdArgs.HasParameter("mailcfg"))
               sendMail = true;

            if (cmdArgs.HasParameter("smscfg"))
               sendSMS = true;

            if (cmdArgs.HasOption("verbose"))
               verbose = true;
             }
             catch (Exception ex)
             {
            Console.WriteLine("Exception raised during initialization: {0}", ex.Message);
            return;
             }

             try
             {
            if (Run(cmdArgs, verbose))
               throw new Exception("Run failed.");
             }
             catch (Exception ex)
             {
            e = ex;
             }

             if (sendMail)
             {
            try
            {
               Config cfg = new Config(cmdArgs.Parameter("mailcfg"));
               if (!cfg.Load())
               {
                  Console.WriteLine("[{0}] Was not possible to load the mail configuration file '{1}'", DateTime.Now, cmdArgs.Parameter("mailcfg"));
               }
               else
               {
                  MailSender ms = new MailSender();

                  string sendTo,
                         header,
                         message;

                  if (e != null)
                  {
                     header = "[ERROR] " + cfg.Root["header", "MohidRun Report"].AsString();
                     sendTo = "sendto.onerror";
                     message = cfg.Root["message", "Mohid Run Report"].AsString() + Environment.NewLine;
                     message += "Exception raised: " + Environment.NewLine;
                     message += e.Message;
                  }
                  else
                  {
                     header = "[SUCCESS] " + cfg.Root["header", "MohidRun Report"].AsString();
                     sendTo = "sendto.onsuccess";
                     message = cfg.Root["message", "Mohid Run Report"].AsString();
                  }

                  ms.SetFrom(cfg.Root["from"].AsString(), cfg.Root["display", cfg.Root["from"].AsString()].AsString());
                  ms.User = cfg.Root["user", "*****@*****.**"].AsString();
                  ms.Password = cfg.Root["pass", "MohidOperationalISTMARETEC2011"].AsString();
                  ms.SetMessage(message, header);
                  ms.Host = cfg.Root["host", "smtp.gmail.com"].AsString();
                  ms.Port = cfg.Root["port", 587].AsInt();
                  ms.EnableSSL = cfg.Root["enable.ssl", true].AsBool();

                  foreach (ConfigNode n in cfg.Root.ChildNodes.FindAll(delegate(ConfigNode node) { return (node.Name == sendTo || node.Name == "sendto"); }))
                  {
                     if (!(n["bcc", ""].AsString() == ""))
                        ms.AddBCC(n["bcc"].AsString(), n["display", n["bcc"].AsString()].AsString());
                     else if (!(n["cc", ""].AsString() == ""))
                        ms.AddCC(n["cc"].AsString(), n["display", n["cc"].AsString()].AsString());
                     else
                        ms.AddTo(n["to"].AsString(), n["display", n["to"].AsString()].AsString());
                  }

                  ms.SendMail();
               }
            }
            catch (Exception ex)
            {
               Console.WriteLine("[{0}] Was not possible to send the mail. An EXCEPTION happened. The message returned was:", DateTime.Now);
               Console.WriteLine("{0}", ex.Message);
            }
             }

             if (sendSMS)
             {
             }
        }