Esempio n. 1
0
 public static void StartZTree(object sender, EventArgs eventArgs)
 {
     try
     {
         var exeToRun = Path.Combine(Path.GetTempPath(), "ztree.exe");
         if (ProcessControl.FindProcess("ztree"))
         {
             DialogResult dialogResult = MessageBox.Show(Resources.Control_StartZTree_Are_you_sure_to_restart_z_Tree_, Resources.Control_StartZTree_z_Tree_is_still_running, MessageBoxButtons.YesNo);
             if (dialogResult == DialogResult.No)
             {
                 return;
             }
         }
         try
         {
             FindDeleteFileAndStartAgain(exeToRun, "ztree", true);
         }
         catch (Exception innerException)
         {
             TraceOps.Out(innerException.ToString());
         }
     }
     catch (Exception exception)
     {
         TraceOps.Out(exception.ToString());
     }
 }
Esempio n. 2
0
        public void StartZLeaf()
        {
            try
            {
                var exeToRun  = Path.Combine(Path.GetTempPath(), "zleaf.exe");
                var ci        = _connectionTable.Get("Server");
                var arguments = ClientModel.BuildCommandLineOptionsZLeaf(ci.GetIp(), _name, 200, 200, 200, 200);

                ProcessControl.FindDeleteFileAndStartAgain(exeToRun, "zleaf", true, true, Resources.zleaf, arguments);
            }
            catch (Exception exception)
            {
                TraceOps.Out(exception.ToString());
            }
        }
Esempio n. 3
0
        public static void FindDeleteFileAndStartAgain(string path, string process, bool panel)
        {
            try
            {
                var thread = new Thread(new ThreadStart(() =>
                {
                    try
                    {
                        var found = true;
                        while (found)
                        {
                            Thread.Sleep(10);
                            found = false;
                            foreach (Process clsProcess in Process.GetProcesses())
                            {
                                if (clsProcess.ProcessName.StartsWith(process))
                                {
                                    found = true;
                                    try
                                    {
                                        clsProcess.Kill();
                                    }
                                    catch (Exception e)
                                    {
                                        TraceOps.Out(e.ToString());
                                    }
                                }
                            }
                        }

                        while (File.Exists(path))
                        {
                            File.Delete(path);
                            ProcessControl.FindAndDeleteGsf(AppDomain.CurrentDomain.BaseDirectory);
                        }

                        var exeBytes  = Properties.Resources.ztree;
                        _processZTree = new Process {
                            StartInfo = { FileName = path }
                        };

                        using (var exeFile = new FileStream(path, FileMode.CreateNew))
                        {
                            exeFile.Write(exeBytes, 0, exeBytes.Length);
                        }

                        _processZTree.Start();

                        if (panel)
                        {
                            var d = new PluginCallback(SetWindowToPanel);
                            _mainForm.Invoke(d, new object[] { });
                        }
                    }
                    catch (Exception e)
                    {
                        TraceOps.Out(e.ToString());
                    }
                }));
                thread.Start();
            }
            catch (Exception e)
            {
                TraceOps.Out(e.ToString());
            }
        }
Esempio n. 4
0
 public void StopZLeaf()
 {
     ProcessControl.FindAndKillProcess("zleaf");
 }