Beispiel #1
0
        private void button3_Click(object sender, EventArgs e)
        {
            var obj = RVMCore.PipeClient <RVMCore.RmtFile> .GetMidObjectFromString(cmdJson.Text);

            if (obj is null)
            {
                return;
            }
            var client = new RVMCore.PipeClient <RVMCore.RmtFile>();

            client.Send(obj, "RVMCoreUploader");
        }
Beispiel #2
0
        /// <summary>
        /// Upload method *unstable* under test.
        /// </summary>
        /// <param name="file"><see cref="RmtFile"/> object.</param>
        /// <param name="counter">fail counter.</param>
        private static void Upload(RmtFile file, int counter = -1)
        {
            if (counter >= 3)
            {
                "Failed to startup or connact to upload instance!".ErrorLognConsole();
            }
            var client = new RVMCore.PipeClient <RmtFile>();

            for (int i = 0; i <= 3; i++)
            { // try up to 4 times.
                try
                {
                    client.Send(file, "RVMCoreUploader");
                    return; // if success return.
                }
                catch (Exception ex)
                {
                    System.Threading.Tasks.Task.Delay(1000);
                    ex.Message.ErrorLognConsole();
                }
            }
            // if it come to here. then there should be not a upload instance present. so strat one.
            int pid = 0;

            try
            {
                // this ProcessExtensions should help startup a instance to a user... ummmm..untested.
                ProcessExtensions.StartProcessAsCurrentUser(
                    System.Reflection.Assembly.GetEntryAssembly().Location, out pid);
                "Uploader process has been lanchued, PID[{0}]".InfoLognConsole(pid);
            }
            catch (Exception ex)
            {
                "Failed to start upload process [{0}]".ErrorLognConsole(ex.Message);
            }
            System.Threading.Tasks.Task.Delay(2000);
            counter += 1; //Pass fail to counter. then run from first line.
            Upload(file, counter);
        }