public static void Run(RunComplexType runSettings, Diagnostics diagnostics, string[] args)
        {
            string sourceExe = runSettings.SourceExeToUse().Replace('/', '\\');
            string registryName = "SourceFromFEWSPlugins";

            // Set RegistryPath for sourceExe to X
            RegistryKey timeKey = Registry.CurrentUser.CreateSubKey("Software").CreateSubKey("TIME");
            RegistryKey registryPaths = timeKey.CreateSubKey("RegistryPaths");
            registryPaths.SetValue(sourceExe, registryName);
            registryPaths.SetValue(sourceExe.Replace("CommandLine","Forms"),registryName);

            RegistryKey pluginsKey = timeKey.CreateSubKey(registryName);
            pluginsKey.ClearValues();

            int i = 0;
            foreach (string plugin in Directory.EnumerateFiles(runSettings.Property(Keys.PLUGIN_DIR), "*.dll"))
            {
                i++;
                pluginsKey.SetValue(String.Format("Assembly{0}",i),plugin);
            }
        }
        public static void Run(RunComplexType runSettings, Diagnostics diagnostics, string[] args)
        {
            var start = DateTimeComplexType.DateTimeFromPI(runSettings.startDateTime);
            var end = DateTimeComplexType.DateTimeFromPI(runSettings.endDateTime);

            //            string dateFormat = "dd/MM/yyyy";
            var dtf = Thread.CurrentThread.CurrentCulture.DateTimeFormat;

            string dateFormat = dtf.ShortDatePattern; // "MM/dd/yyyy";
            if (runSettings.TimeStepInSeconds != 86400)
                dateFormat += " HH:mm:ss";

            string sourceExe = runSettings.SourceExeToUse();
            string sourceProject = runSettings.Property(Keys.PROJECT_FILE);

            string sourceOutput = runSettings.Property(Keys.OUTPUT_FILE);

            if (File.Exists(sourceOutput))
            {
                diagnostics.Log(3,string.Format("Deleting old source output file {0}",sourceOutput));
                File.Delete(sourceOutput);
            }

            string mode = runSettings.ExecutionMode();

            if (mode == "")
            {
                if(runSettings.ConfiguredServer()!="")
                    diagnostics.Log(3,string.Format("Running locally because configured server ({0}) is unavailable",runSettings.ConfiguredServer()));
            }
            else
                sourceProject = "";

            string sourceCommand = string.Format("-p \"{0};;{1};{2}\" {4} -o {3}",
                                                 sourceProject, start.ToString(dateFormat),
                                                 end.ToString(dateFormat), sourceOutput,mode);
            diagnostics.Log(3, string.Format("Starting Source Run with command line {0}",sourceCommand));

            ProcessStartInfo startInfo = new ProcessStartInfo
                {
                    Arguments = sourceCommand,
                    CreateNoWindow = true,
                    FileName = sourceExe,
                    UseShellExecute = false,
                    RedirectStandardError = true,
                    RedirectStandardOutput = true
                };
            Process p = Process.Start(startInfo);
            string output = p.StandardOutput.ReadToEnd();
            p.WaitForExit();
            string errors = p.StandardError.ReadToEnd();

            if (!File.Exists(sourceOutput))
            {
                File.WriteAllText(runSettings.workDir+"\\SourceErrors.txt",errors);
                File.WriteAllText(runSettings.workDir+"\\SourceOutput.txt",output);
                foreach (string line in errors.Split('\n'))
                    diagnostics.Log(1, line);
                throw new Exception(string.Format("Source run failed. No output file: {0}", sourceOutput));
            }

            diagnostics.Log(3,"All done");
        }