Exemplo n.º 1
0
 public CommandRunner(ServiceManager svc, ExtensionClientManager extmgr)
 {
     _svc    = svc;
     _extmgr = extmgr;
     Add(ExecCommand.Get());
     Add(RestartCommand.Get());
 }
Exemplo n.º 2
0
        public CommandEndpoint(ImportEngine engine, XmlNode node)
            : base(engine, node, ActiveMode.Lazy | ActiveMode.Local)
        {
            XmlNodeList chlds = node.ChildNodes;// node.SelectMandatoryNodes("*");
            var         cmds  = new List <Command>(chlds.Count);

            for (int i = 0; i < chlds.Count; i++)
            {
                XmlNode n    = chlds[i];
                String  name = n.Name;
                Command cmd;
                switch (name)
                {
                default: continue;

                case "command":
                case "exec": cmd = new ExecCommand(engine, n); break;

                case "delete":
                case "del": cmd = new DeleteCommand(engine, n); break;

                case "copy": cmd = new CopyCommand(engine, n); break;

                case "move": cmd = new MoveCommand(engine, n); break;
                }
                cmds.Add(cmd);
            }
            Commands = cmds.ToArray();
            if (cmds.Count == 0)
            {
                engine.ImportLog.Log("Endpoint [{0}] has no commands. Resulting in a no-op.", Name);
            }
        }
Exemplo n.º 3
0
        public SqlCommand Execute(ExecCommand cmd)
        {
            Command.Transaction = (SqlTransaction)Open();
            cmd(Command);

            return Command;
        }
Exemplo n.º 4
0
 private static void SetFirstIncomeMessage(string s, int targetServiceID)
 {
     foreach (int num in AdminClientService.Instance.FrontendServiceIDs())
     {
         if (targetServiceID == -1 || num == targetServiceID)
         {
             ExecCommand op = new ExecCommand("SetFirstIncomeMessage", s);
             AdminClientService.Instance.RequestOperation(num, op);
         }
     }
 }
Exemplo n.º 5
0
        private async Task TaskProc(PeerApi golemApi, DeploymentSpec spec)
        {
            try
            {
                if (deployment == null)
                {
                    deployment   = spec;
                    deploymentID = await golemApi.CreateDeploymentAsync(Peer.NodeId, deployment);
                }

                //1. Take all input files and includes and package them into one TAR package + notify HttpServer about that file
                string packedFileName = PackFilesPreProcessed(taskList);

                //2. Create command to compile those source files -> cl.exe ....
                ExecCommand compileCmd = GenerateCompileCommand(packedFileName, taskList);

                var results = await golemApi.UpdateDeploymentAsync(Peer.NodeId, deploymentID, new List <Command>() {
                    new DownloadFileCommand(Service.GetHttpDownloadUri(packedFileName), packedFileName + ".tar", FileFormat.Tar),
                    compileCmd
                });

                bool     error = false;
                string[] lines = results[0].Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None);
                foreach (string line in lines)
                {
                    if (line.Contains(" error") || line.Contains("fatal error"))
                    {
                        Logger.LogError("[ERROR] " + packedFileName + ": " + line);
                        error = true;
                    }
                    else if (line.Contains("warning"))
                    {
                        Logger.LogMessage("[WARNING] " + packedFileName + ": " + line);
                    }
                }

                if (!error)
                {
                    Logger.LogMessage("[SUCCESS] " + packedFileName);

                    // Upload output.zip
                    results = await golemApi.UpdateDeploymentAsync(Peer.NodeId, deploymentID, new List <Command>() {
                        new UploadFileCommand(Service.GetHttpUploadUri(packedFileName), packedFileName + ".tar/output.zip")
                    });
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Exemplo n.º 6
0
        private void KickUser_Click(object sender, EventArgs e)
        {
            ExecCommand execCommand = new ExecCommand("Kick", this.textBoxKick.Text);

            execCommand.OnComplete += delegate(Operation op)
            {
                this.Result2.Text = "Kick 성공!";
            };
            execCommand.OnFail += delegate(Operation op)
            {
                this.Result2.Text = "Kick 실패!";
            };
            this.Service.Thread.Enqueue(Job.Create <string, ExecCommand>(new Action <string, ExecCommand>(this.Service.RequestOperation), "FrontendServiceCore.FrontendService", execCommand));
        }
Exemplo n.º 7
0
        public void OnExecute_ExitsSuccessfully_WhenCommandIsEmpty()
        {
            // Arrange
            var cmd = new ExecCommand {
                DebugMode = true, SourceDir = _testDir.RootDirPath
            };
            var console = new TestConsole();

            // Act
            var exitCode = cmd.OnExecute(new CommandLineApplication(console), console);

            // Assert
            Assert.Equal(ProcessConstants.ExitSuccess, exitCode);
        }
Exemplo n.º 8
0
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        static void Main()
        {
            string[] args = Environment.GetCommandLineArgs();

            // --install site host
            // --uninstall
            if (args[1].Equals("-i"))
            {
                string path = Environment.CurrentDirectory + "\\" + ServiceMain.EXE_NAME;
                string site = args[2];
                string host = args[3];

                StringBuilder exeArgs = new StringBuilder("create \"" + ServiceMain.SERVICE_NAME + " " + site + " " + host + "\" ");
                exeArgs.Append("binPath=\"" + path + "\" ");
                exeArgs.Append("DisplayName=\"" + ServiceMain.DISPLAY_NAME + "\" ");
                exeArgs.Append("start=auto");
                string outStr = ExecCommand.Execute("sc", exeArgs.ToString());

                System.Console.WriteLine(outStr);
            }
            // --uninstall
            else if (args[1].Equals("-u"))
            {
                StringBuilder exeArgs = new StringBuilder("delete \"" + ServiceMain.SERVICE_NAME + "\"");
                string        outStr  = ExecCommand.Execute("sc", exeArgs.ToString());

                System.Console.WriteLine(outStr);
            }
            if (args[1].Equals("-d"))   //Debug
            {
                string      path = Environment.CurrentDirectory + "\\" + ServiceMain.EXE_NAME;
                ServiceMain app  = new ServiceMain();

                app.debugOnStart();
                System.Console.ReadLine();
            }
            else if (args.Length == 3)
            {
                ServiceBase[] ServicesToRun;
                ServicesToRun = new ServiceBase[]
                {
                    new ServiceMain()
                };
                ServiceBase.Run(ServicesToRun);
            }
        }
Exemplo n.º 9
0
 public PipelineCommand(IEnumerable<RedisCommand> commands, bool transactional)
 {
     if (commands == null)
         throw new ArgumentNullException("commands");
     _commands.AddRange(commands);
     _transactional = transactional;
     if (transactional)
     {
         _multi = new MultiCommand();
         _exec = new ExecCommand();
     } 
     else
     {
         _multi = null;
         _exec = null;
     }
 }
Exemplo n.º 10
0
        private void doCommand(string command, string args)
        {
            StringBuilder sb = new StringBuilder("");

            if (args == null)
            {
                args = "";
            }

            sb.Append("$> Ejecutando comando: " + Environment.NewLine);
            sb.Append("\t" + command + " " + args + Environment.NewLine);

            string outStr = ExecCommand.Execute(command, args);

            sb.Append("Output: " + Environment.NewLine);
            sb.Append(outStr);
            log.Info(sb.ToString());
        }
Exemplo n.º 11
0
            public ExecGlobals(ExecCommand parent)
            {
                Context         = parent.Context;
                Client          = parent.Client;
                Bot             = parent.Bot;
                Logger          = parent.Logger;
                CommandService  = parent.CommandService;
                SettingsManager = parent.SettingsManager;
                TextManager     = Bot.DependencyFactory.GetOrStore <ITextResourceManager>();

                Database   = parent.Database;
                Scheduler  = parent.Scheduler;
                Downloader = parent.Downloader;

                ReplyBase    = parent.Reply;
                ReplyChannel = parent.Reply;
                ReplyUser    = parent.Reply;
                ReplyBoth    = parent.Reply;
                ModifyBase   = parent.Modify;
                ModifyUser   = parent.Modify;
            }
Exemplo n.º 12
0
        static int Main(string[] args)
        {
            IConfiguration configuration = new ConfigurationBuilder()
                                           .SetBasePath(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location))
                                           .AddJsonFile("flutnet.appsettings.json")
                                           .Build();

#if DEBUG
            //return Core.Infrastructure.DevWorkUnit.Run();
#endif

            try
            {
#if DEBUG
                if (configuration.GetValue("Debuggable", false))
                {
                    for (;;)
                    {
                        Console.WriteLine("Waiting for debugger...");
                        if (Debugger.IsAttached)
                        {
                            break;
                        }
                        System.Threading.Thread.Sleep(1000);
                    }
                }
#endif
                return(Parser.Default.ParseArguments <ExecOptions, PackOptions>(args)
                       .MapResult(
                           (ExecOptions options) => ExecCommand.Run(options),
                           (PackOptions options) => PackCommand.Run(options),
                           errors => ReturnCodes.OptionsParsingError));
            }
            catch (OptionsValidationException ex)
            {
                Console.WriteLine(ex.Message);
                return(ReturnCodes.OptionsValidationError);
            }
        }
Exemplo n.º 13
0
        /// <summary>
        ///     Parses, validates and dispatches messages from the client
        /// </summary>
        /// <param name="s">The raw message sent from the client</param>
        /// <returns>the response to be returned to the client</returns>
        private string HandleMessage(string s)
        {
            //parse the request from the client into an XML document
            XmlDocument requestDocument = new XmlDocument();

            //load the message into the document
            requestDocument.LoadXml(s);

            //get a reference to the command element node.
            XmlNode commandNode = requestDocument.SelectSingleNode("/command");

            //check that there is a command element
            if (commandNode == null)
            {
                //if not, the message is formatted wrong and we cant recognize it.
                //return an error message to send to the client
                return(CreateErrorDocument("Input not recognized").OuterXml);
            }

            //create an XMLDocument to hold to response to be sent back to the client
            XmlDocument responseDocument = new XmlDocument();

            //create the top level response element
            XmlNode responseElement = responseDocument.CreateNode(XmlNodeType.Element, "response", "");

            //add the response element to the response document
            responseDocument.AppendChild(responseElement);

            //get the id for the command
            string id = ExtractId(commandNode);

            //create a new attribute named id
            XmlAttribute idAttribute = responseDocument.CreateAttribute("id");

            //set its value to the request id
            idAttribute.Value = id;

            //add the new id element to the response id
            responseElement.Attributes.SetNamedItem(idAttribute);


            //get child nodes from the request document. Each one should
            //represent a command (there should be only one)
            XmlNodeList children = commandNode.ChildNodes;

            //IProxyCommand that contains the command sent from the client
            IProxyCommand command = null;

            //attribute tha holds response type
            XmlAttribute typeAttribute = responseDocument.CreateAttribute("type");

            //loop through all of the command nodes (usually only one)
            foreach (XmlNode node in children)
            {
                //look at the node name. This will indicate the command
                switch (node.Name)
                {
                //exececute command
                case "exec":
                {
                    //create a new ExecCommand instance
                    command = new ExecCommand();

                    //try and run the command
                    try
                    {
                        //pass in the response and request document, capture the response document
                        //with output from the command included
                        responseDocument = command.Exec(requestDocument, responseDocument);

                        //set the type attribute to success
                        typeAttribute.Value = "success";

                        //add the type attribute to the response document
                        responseDocument.FirstChild.Attributes.SetNamedItem(typeAttribute);

                        //return a string of XML representing the response document to send to
                        //the client
                        return(responseDocument.OuterXml);
                    }
                    catch (Exception e)
                    {
                        //something went wrong, create error document and send its xml to the client
                        return(CreateErrorDocument(e.Message, id).OuterXml);
                    }
                }

                //screenshot command
                case "screenshot":
                {
                    //create the screenshot command
                    command = new ScreenshotCommand();

                    try
                    {
                        //pass in the response and request document, capture the response document
                        //with output from the command included
                        responseDocument = command.Exec(requestDocument, responseDocument);

                        //set the type attribute to success
                        typeAttribute.Value = "success";

                        //add the type attribute to the response document
                        responseDocument.FirstChild.Attributes.SetNamedItem(typeAttribute);

                        //return a string of XML representing the response document to send to
                        //the client
                        return(responseDocument.OuterXml);
                    }
                    catch (Exception e)
                    {
                        //something went wrong, create error document and send its xml to the client
                        return(CreateErrorDocument(e.Message, id).OuterXml);
                    }
                }
                }
            }

            //if we get to here we didnt recognize the command, so we just return null
            //todo: should this move to switch defaul
            //todo: should be through an error?
            return(null);
        }
Exemplo n.º 14
0
    protected virtual void OnGUI()
    {
        GUI.skin.label.wordWrap = true;

        // setup info text
        GUI.skin.label.richText = true;
        GUILayout.Label("Welcome to the Mxlvl Publisher tool for Unity.\nThis window will let you publish your game to the Mxlvl platform <b>AFTER</b> you have built a WebGL platform version of your game.\n\n<b>-</b>Enter the Publisher ID below\n<b>-</b>Select folder location of the WebGL platform build\n<b>-</b>Click Publish\n\n*upload can take up to 5 minutes");

        GUILayout.BeginHorizontal();
        GUILayout.Label("Version");
        this.version = EditorGUILayout.TextField(this.version).Trim();
        GUILayout.EndHorizontal();

        GUILayout.Label("Game Deployment ID");
        string setGameId = EditorGUILayout.TextField(this.gameId).Trim();

        GUILayout.Space(5);

        if (setGameId != this.gameId)
        {
            this.gameId = setGameId;
        }

        EditorGUILayout.TextField(this.webglBuildFolder).Trim();
        if (GUILayout.Button("Select WebGL Build Folder"))
        {
            this.webglBuildFolder = EditorUtility.OpenFolderPanel("WebGL Platform Build Folder", "", "");
            this.HasUpdated();
        }
        GUILayout.Space(5);

        string dirToBuildFiles = Path.Combine(this.webglBuildFolder, buildFolder);

        if (!string.IsNullOrEmpty(this.webglBuildFolder))
        {
            this.scrollPos = GUILayout.BeginScrollView(this.scrollPos);
            foreach (string file in this.uploadFiles)
            {
                string filePath = Path.Combine(dirToBuildFiles, file);
                if (!File.Exists(filePath))
                {
                    GUILayout.Label("File Not Found: " + file);
                    Debug.Log("File Not Found: " + file);
                }
            }
            GUILayout.EndScrollView();
        }
        EditorGUI.BeginDisabledGroup(string.IsNullOrEmpty(this.webglBuildFolder));
        if (GUILayout.Button("[Publish]"))
        {
            this.HasUpdated();

            try
            {
                UploadUrls urls = GetS3PresignedUrls(this.gameId);
                foreach (string file in this.uploadFiles)
                {
                    continue;
                    string upload_url_name = file.Replace(".unityweb", "");
                    upload_url_name = upload_url_name.Replace('.', '_');
                    string filePath = Path.Combine(dirToBuildFiles, file);
                    if (File.Exists(filePath))
                    {
                        if (file == "webgl_build.asm.code.unityweb")
                        {
                            Debug.Log(ExecCommand.ExecuteCommand(string.Format(urls.webgl_build_asm_code_unityweb, filePath)));
                        }
                        if (upload_url_name == "webgl_build_asm_framework")
                        {
                            Debug.Log(ExecCommand.ExecuteCommand(string.Format(urls.webgl_build_asm_framework_unityweb, filePath)));
                        }
                        if (upload_url_name == "webgl_build_asm_memory")
                        {
                            Debug.Log(ExecCommand.ExecuteCommand(string.Format(urls.webgl_build_asm_memory_unityweb, filePath)));
                        }
                        if (upload_url_name == "webgl_build_data")
                        {
                            Debug.Log(ExecCommand.ExecuteCommand(string.Format(urls.webgl_build_data_unityweb, filePath)));
                        }
                    }
                }
            }catch (Exception e)
            {
            }
        }
        EditorGUI.EndDisabledGroup();

        GUI.skin.label.richText = false;
    }
Exemplo n.º 15
0
        /// <summary>
        /// Run SQL command
        /// </summary>
        /// <param name="context">script context</param>
        /// <param name="cmdText">SQL statement text</param>
        /// <param name="parameters">list of parameters</param>
        /// <param name="timeout">Timeout, may be null</param>
        /// <param name="execCommand">callback</param>
        /// <param name="messagesTo">Where to output messages (for example, by PRINT SQL statement)</param>
        /// <param name="errorsTo">Where to output errors</param>
        /// <param name="ignoreDataErrors">If true, SQL errors below severity 17 do not throw exceptions and instead just write messages to the output</param>
        public static void RunCommand(ScriptContext context,
                                      string cmdText,
                                      List <SqlParam> parameters,
                                      TimeSpan?timeout,
                                      ExecCommand execCommand,
                                      string messagesTo,
                                      string errorsTo,
                                      bool ignoreDataErrors)
        {
            var connection = Database.CurrentConnection;

            if (connection == null)
            {
                throw new ScriptRuntimeException("There is no active database connection");
            }

            {
                IDbCommand cmd = connection.CreateCommand();
                if (timeout.HasValue)
                {
                    cmd.CommandTimeout = (int)(timeout.Value.TotalSeconds + 0.999);
                }
                cmd.CommandType = CommandType.Text;
                cmd.CommandText = cmdText;

                context.WriteVerbose(Utils.PrefixEachLine("SQL> ", cmdText));
                if (parameters != null && parameters.Count > 0)
                {
                    context.WriteVerbose(String.Format("SQL> -- with {0} params: ", parameters.Count));
                    foreach (var parameter in parameters)
                    {
                        object val  = context.Transform(parameter.Value, parameter.Transform);
                        string type = context.TransformStr(parameter.SqlType, parameter.Transform);

                        var param = cmd.CreateParameter();
                        if (String.IsNullOrEmpty(type))
                        {
                            if (param is SqlParameter)
                            {
                                type = "nvarchar(4000)";
                            }
                            else
                            {
                                type = "string(4000)";
                            }
                            if (val != null)
                            {
                                if (val is DateTime || val is DateTime?)
                                {
                                    type = "datetime";
                                }
                                else if (val is DateTimeOffset || val is DateTimeOffset?)
                                {
                                    type = "datetimeoffset";
                                }
                                if (param is SqlParameter)
                                {
                                    if (val is int || val is int?)
                                    {
                                        type = SqlDbType.Int.ToString();
                                    }
                                    else if (val is short || val is short? || val is byte || val is byte?)
                                    {
                                        type = SqlDbType.SmallInt.ToString();
                                    }
                                    else if (val is sbyte || val is sbyte?)
                                    {
                                        type = SqlDbType.TinyInt.ToString();
                                    }
                                    else if (val is decimal || val is decimal?)
                                    {
                                        type = SqlDbType.Money.ToString();
                                    }
                                    else if (val is byte[])
                                    {
                                        type = SqlDbType.Binary.ToString();
                                    }
                                    else if (val is double || val is double? || val is float || val is float?)
                                    {
                                        type = SqlDbType.Real.ToString();
                                    }
                                    else if (val is uint || val is Nullable <uint> ||
                                             val is ushort || val is Nullable <ushort> )
                                    {
                                        type = SqlDbType.Int.ToString();
                                    }
                                    else if (val is long || val is Nullable <long> ||
                                             val is Nullable <ulong> || val is ulong)
                                    {
                                        type = SqlDbType.BigInt.ToString();
                                    }
                                }
                                else
                                {
                                    if (val is int || val is int?)
                                    {
                                        type = DbType.Int32.ToString();
                                    }
                                    else if (val is short || val is short? || val is byte || val is byte?)
                                    {
                                        type = DbType.Int16.ToString();
                                    }
                                    else if (val is sbyte || val is sbyte?)
                                    {
                                        type = DbType.SByte.ToString();
                                    }
                                    else if (val is decimal || val is decimal?)
                                    {
                                        type = DbType.Decimal.ToString();
                                    }
                                    else if (val is byte[])
                                    {
                                        type = DbType.Binary.ToString();
                                    }
                                    else if (val is double || val is double? || val is float || val is float?)
                                    {
                                        type = DbType.Double.ToString();
                                    }
                                    else if (val is uint || val is Nullable <uint> ||
                                             val is ushort || val is Nullable <ushort> )
                                    {
                                        type = DbType.Int64.ToString();
                                    }
                                    else if (val is long || val is Nullable <long> ||
                                             val is Nullable <ulong> || val is ulong)
                                    {
                                        type = DbType.Int64.ToString();
                                    }
                                }
                            }
                        }

                        int?size = null;
                        int n    = type.IndexOf('(');
                        if (n != -1)
                        {
                            var sz = type.Substring(n + 1).TrimEnd().TrimEnd(new char[] { ')' }).Trim();
                            size = (string.Compare(sz, "max", StringComparison.OrdinalIgnoreCase) == 0)?-1:Utils.To <int>(sz);
                            type = type.Substring(0, n).Trim();
                        }
                        if (param is SqlParameter && Array.Exists(s_sqlDbTypeNames, x => StringComparer.OrdinalIgnoreCase.Compare(type, x) == 0))
                        {
                            ((SqlParameter)param).SqlDbType = Utils.To <SqlDbType>(type);
                        }
                        else
                        {
                            param.DbType = Utils.To <DbType>(type);
                        }


                        param.ParameterName = parameter.Name;
                        param.Direction     = ParameterDirection.Input;


                        if (size.HasValue)
                        {
                            param.Size = size.Value;
                        }

                        if (val == null || ((val is string && String.IsNullOrEmpty((string)val)) && parameter.EmptyAsNull))
                        {
                            param.Value = DBNull.Value;
                            val         = null;
                        }
                        else
                        {
                            param.Value = val;
                        }
                        cmd.Parameters.Add(param);

                        context.WriteVerbose(String.Format("SQL> --     {1} {0}=> {2}", param.ParameterName, param.DbType, Dump.ToDump(val)));
                    }
                }



                SqlInfoMessageEventHandler handler = (sender, e) =>
                {
                    if (e.Errors.Count > 0)
                    {
                        foreach (SqlError s1 in e.Errors)
                        {
                            context.Debug.WriteLine(String.Format("SQL> (Error: {0}, Class:{1}, State:{2}, Proc: {3}, #: {4}): {5}", s1.Number, s1.Class, s1.State, s1.Procedure, s1.LineNumber, s1.Message));
                            if (s1.Class >= 11)
                            {
                                context.OutTo(errorsTo, s1.Message + Environment.NewLine);
                            }
                            else
                            {
                                context.OutTo(messagesTo, s1.Message + Environment.NewLine);
                            }
                        }
                    }
                };

                var  sql = connection as SqlConnection;
                bool b   = false;
                if (sql != null)
                {
                    b = sql.FireInfoMessageEventOnUserErrors;
                    sql.FireInfoMessageEventOnUserErrors = ignoreDataErrors;
                    sql.InfoMessage += handler;
                }

                try
                {
                    int nRows = execCommand(cmd);
                    if (nRows != -1)
                    {
                        context.WriteVerbose(String.Format("SQL>-- {0} rows affected", nRows));
                    }
                }
                finally
                {
                    if (sql != null)
                    {
                        sql.InfoMessage -= handler;
                        sql.FireInfoMessageEventOnUserErrors = b;
                    }
                }
            }
        }
Exemplo n.º 16
0
 public Task <HttpResponseMessage> SendCommand(ExecCommand cmd)
 {
     return($"{_httpURL}version/run".PostJsonAsync(cmd));
 }
Exemplo n.º 17
0
        /// <summary>
        /// Install ("Run") this control..
        /// It will download, unzip, save and exec something.
        /// </summary>
        public void Install()
        {
            ButtonAction = BUTTONACTION_CANCEL;
            if (this.cbDownloadUrls.Text != null && !this.cbDownloadUrls.Text.Equals(""))
            {
                cancelCalled        = false;
                panDownload.Enabled = true;

                progressBar.Visible      = true;
                labProgressBytes.Visible = true;

                //download file, it will wait inside until its done or error.
                DownloadFile(this.cbDownloadUrls.Text);

                // is cancel pressed?!
                if (!cancelCalled)
                {
                    try
                    {
                        // is it set? we will unzip
                        if (UnZipToPath != null && !UnZipToPath.Equals(""))
                        {
                            labProgressBytes.Text = "Unzipping...";
                            UnZipFile(this.dataDownloaded, UnZipToPath, UnzipToExcludeDir);
                            labProgressBytes.Text = "Unzipping done!";
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.Write(ex);
                        labProgressBytes.Text = "Unzip error!";
                        MessageBox.Show("A Error occur when unzipping package.\nException: " + ex.StackTrace, "Error",
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                        ButtonAction = BUTTONACTION_DONTINSTALL;
                        return;
                    }

                    try
                    {
                        // if set, we will write the (unziped data) or (not unziped data) to disk.
                        if (SaveAsFilename != null && !SaveAsFilename.Equals("") && SaveToPath != null && !SaveToPath.Equals(""))
                        {
                            // save only to disk
                            labProgressBytes.Text = "Saving...";
                            SaveFile(this.dataDownloaded, SaveToPath, SaveAsFilename);
                            labProgressBytes.Text = "Saving done!";
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.Write(ex);
                        labProgressBytes.Text = "Save file error!";
                        MessageBox.Show("A Error occur when saving file to disk.\nException: " + ex.StackTrace, "Error",
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                        ButtonAction = BUTTONACTION_DONTINSTALL;
                        return;
                    }

                    try
                    {
                        //if set, we will execute a command with arguments..
                        if (ExecCommand != null && !ExecCommand.Equals(""))
                        {
                            labProgressBytes.Text = "Running application...";
                            Process proc = new Process();
                            proc.EnableRaisingEvents = false;
                            proc.StartInfo.FileName  = ExecCommand;
                            proc.StartInfo.Arguments = ExecCmdArguments;
                            proc.Start();
                            proc.WaitForExit(60000 * 3); // the exec got 3 min to finnish. (else error)

                            if (proc.ExitCode == 0)
                            {
                                labProgressBytes.Text = "Running application done!";
                                progressBar.Value     = progressBar.Maximum = 1;
                                Thread.Sleep(500);
                                labProgressBytes.Text = "Done!";
                                panDownload.Enabled   = false;
                                ButtonAction          = BUTTONACTION_INSTALLED;
                            }
                            else
                            {
                                labProgressBytes.Text = "Exec error! (status!=0)";
                                MessageBox.Show(
                                    "A Error occur when running 3-part-package installation.\nThe installation did not return status 0, could be a problem.",
                                    "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                ButtonAction = BUTTONACTION_DONTINSTALL;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.Write(ex);
                        labProgressBytes.Text = "Exec error!";
                        MessageBox.Show("A Error occur when 3-part-package installation.\nException: " + ex.StackTrace, "Error",
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                        ButtonAction = BUTTONACTION_DONTINSTALL;
                        return;
                    }

                    labProgressBytes.Text = "Installation done!";
                    ButtonAction          = BUTTONACTION_INSTALLED;
                }
            }
        }