Ejemplo n.º 1
0
        public void UpdateList()
        {
            combolist.Items.Clear();
//	        if (cbmsvs.Checked) foreach (object mope in Globe.Lib.fx.MSVSMACROS.vals.Keys)
//	        {
//	            combolist.Items.Add(string.Format("$({0})",mope));
//	        }
//	        if (cbuser.Checked) foreach (object mope in Globe.Lib.fx.Constants)
//	        {
//	            if (mope is IConstant)
//	            {
//	                IConstant poo =(mope) as IConstant;
//	                if (poo.Alias!=null)
//	                {
//	                    if (poo.Alias!=string.Empty) combolist.Items.Add(string.Format("$({0})",poo.Alias));
//	                }
//	                //this.combolist.Items.Add(string.Format("$({0})",mope));
//	            }
//	        }
            if (cbsys.Checked)
            {
                StringDictionary sd = RunProcess.EnvVars("explorer.exe", @"c:\windows\");
                foreach (DictionaryEntry de in sd)
                {
                    combolist.Items.Add(string.Format("$({0})", de.Key));
                }
                sd.Clear();
                sd = null;
            }
        }
Ejemplo n.º 2
0
        /// <summary> send either a file name or path.</summary>
        static public void ExploreHere(string lvs)
        {
            if (lvs == null)
            {
                return;
            }
            if (lvs == string.Empty)
            {
                return;
            }
            RunProcess RP;

            if (!CheckFile(lvs))
            {
                RP = new RunProcess("Explorer.exe", "/e,/root," + lvs, @"C:\windows", false, true, false, false);
                RP.Start();
                RP.Close();
                RP.Dispose();
                return;
            }
            if (CheckFile(lvs))
            {
                RP = new RunProcess("Explorer.exe", "/e,/root,\"" + FileUtil.FInfo(lvs).FullName + "\" , /select,\"" + lvs + "\"", @"C:\windows", false, true, false, false);
                RP.Start();
                RP.Close();
                RP.Dispose();
            }
        }
Ejemplo n.º 3
0
            public void Dispose()
            {
                if (Disposed)
                {
                    return;
                }

                try
                {
                    if (!(RunProcess?.HasExited ?? true))
                    {
                        RunProcess?.Kill();
                    }

                    if (File.Exists(FilePath))
                    {
                        File.Delete(FilePath);
                    }

                    Console.WriteLine("Deleted temp file {0}", FilePath);
                }
                catch (Exception exc)
                {
                    Console.WriteLine(exc.Message);
                }

                Disposed = true;
            }
Ejemplo n.º 4
0
 public String ShellAction(String command)
 {
     if (RunProcess.Run(command))
     {
         return(JsonConstructor.SendMessage(true, "成功"));
     }
     else
     {
         return(JsonConstructor.SendMessage(false, "脚本不存在或执行失败"));
     }
 }
 public TaskManagerViewModel(Action <ProcessPriorityClass?> selectRadio)
 {
     _selectRadio       = selectRadio;
     ProcessList        = new ObservableCollection <ProcessListItem>(Process.GetProcesses().Select(p => new ProcessListItem(p)));
     SelectedProcess    = ProcessList[0];
     PriorityChanged    = new PriorityChanged(this);
     RefreshList        = new RefreshList(this);
     DeleteProcess      = new DeleteProcess();
     RunProcess         = new RunProcess();
     UpdateSpeedChanged = new UpdateSpeedChanged(async(r) =>
     {
         _refreshRate = r;
         await StartRefresh();
     });
 }
Ejemplo n.º 6
0
        public static void PostRunTask()
        {
            if (string.IsNullOrEmpty(Settings.Default.PostRunTask))
            {
                Log.Info("Post Run Task not defined, skipping...");
                return;
            }
            if (!File.Exists(Settings.Default.PostRunTask))
            {
                Log.Error(string.Format("Post Run Task {0} doesn't exist, skipping...", Settings.Default.PostRunTask));
                return;
            }
            var runTask = new RunProcess();

            runTask.Execute(Settings.Default.PostRunTask, null, true);
        }
Ejemplo n.º 7
0
 public void Exit()
 {
     if (RunProcess != null && RunProcess.HasExited == false)
     {
         try
         {
             RunProcess.Kill();
             RunProcess.Close();
         }
         catch
         {
         }
     }
     SetListViewInfo("未运行");
     IsRun      = false;
     RunProcess = null;
 }
Ejemplo n.º 8
0
    public static int RunExecutable(string ExeName, string Params, Stream StandardOut, Stream StandardError)
    {
        RunProcess myProc = new RunProcess(ExeName, Params, StandardOut, StandardError);

        return(myProc.RunStreams());
    }
Ejemplo n.º 9
0
    public static ProcessExitInfo RunExecutable(string ExeName, string Params, string WorkingDirectory)
    {
        RunProcess myProc = new RunProcess(ExeName, Params, WorkingDirectory);

        return(myProc.Run());
    }
Ejemplo n.º 10
0
    /// <summary>
    /// Runs an Executable and returns the output
    /// </summary>
    /// <param name="ExeName">The full path and name of the executable</param>
    /// <param name="Params">The parameters for the exe</param>
    /// <returns>string containing the STDOUT of the process</returns>
    public static ProcessExitInfo RunExecutable(string ExeName, string Params)
    {
        RunProcess myProc = new RunProcess(ExeName, Params);

        return(myProc.Run());
    }
Ejemplo n.º 11
0
 public override Task process(WatchedEvent @event)
 {
     return(Task.Run(() => RunProcess?.Invoke(@event)));
 }
Ejemplo n.º 12
0
        private void ProcessReceivedMessageResponse(SocketAsyncEventArgs e, ResponseMessage message)
        {
            var token = (HostAsyncUserToken)e.UserToken;

            if (message.Response is IdentificationData)
            {
                var idata = (IdentificationData)message.Response;
                Logger.WriteStr(" * New client has connected: " + idata.deviceName);
                // ...create ClientData (if does not exist already) and add to token
                //...

                //TODO: for testing only:
                //Get IP information
                var msg = new RequestMessage {
                    OpCode = (int)EOpCode.IpConfigData
                };
                SendMessage(e, WoxalizerAdapter.SerializeToXml(msg, TypeResolving.AssemblyResolveHandler));
            }
            else if (message.Response is IpConfigData)
            {
                var ipConf = (IpConfigData)message.Response;
                token.Data.IpConfig = ipConf;       //store in "database"


                //TODO: move to another place
                var msg = new RequestMessage {
                    OpCode = (int)EOpCode.RunProcess
                };
                var exec = new RunProcess
                {
                    RunId   = HostAsyncUserToken.RunId,
                    Cmd     = "notepad.exe",
                    Args    = "",
                    WorkDir = "c:\\",
                    TimeOut = 180000,                       //ms
                    Hidden  = true
                };

                msg.Request = exec;
                SendMessage(e, WoxalizerAdapter.SerializeToXml(msg, TypeResolving.AssemblyResolveHandler));
            }
            else if (message.Response is RunCompletedStatus)
            {
                var status = (RunCompletedStatus)message.Response;
                if (status.ExitCode == 0)
                {
                    Logger.WriteStr("Remote successfully executed");
                }
                else if (status.ExitCode > 0)
                {
                    Logger.WriteStr("Remote program executed with exit code: " + status.ExitCode +
                                    "and error message: \"" + status.ErrorMessage + "\"");
                }
                else
                {
                    throw new ArgumentException("Invalid exit code of remote execution (" + status.ExitCode + ")");
                }



                //...
            }
            else
            {
                Logger.WriteStr("WARNING: Recieved unkown response from " + token.Socket.RemoteEndPoint.ToString() + "!");
            }
        }
Ejemplo n.º 13
0
        public static SetupTask CreateFrom(XElement taskElement)
        {
            SetupTask result;

            switch (taskElement.Name.LocalName)
            {
            case "Group":
                result = new Composite(taskElement);
                break;

            case "ExtractArchive":
                result = new ExtractArchive(taskElement);
                break;

            case "TweakINI":
                result = new TweakINI(taskElement);
                break;

            case "CopyFile":
                result = new CopyFile(taskElement);
                break;

            case "Embedded":
                result = new Embedded(taskElement);
                break;

            case "Clean":
                result = new Clean(taskElement);
                break;

            case "CreateEmptyFolder":
                result = new CreateEmptyFolder(taskElement);
                break;

            case "RunProcess":
                result = new RunProcess(taskElement);
                break;

            case "DeleteFolder":
                result = new DeleteFolder(taskElement);
                break;

            case "DeleteFile":
                result = new DeleteFile(taskElement);
                break;

            case "MoveFolder":
                result = new MoveFolder(taskElement);
                break;

            case "EditFile":
                result = new EditFile(taskElement);
                break;

            case "Dummy":
                result = new Composite();
                break;

            default:
                throw new NotSupportedException("Task type " + taskElement.Name.LocalName + " is not supported.");
            }

            result.xml = taskElement.ToString();
            result.Id  = taskElement.Attribute("Id")?.Value ?? Guid.NewGuid().ToString();

            // this feels clunky, but that's fine I guess...
            result.WaitFor = result.WaitFor.Union(Program.Tokenize(taskElement.Attribute("WaitFor")?.Value)).ToImmutableArray();
            return(result);
        }
Ejemplo n.º 14
0
        static void Main(string[] args)
        {
            RunProcess runProcess = new RunProcess();

            runProcess.Run();
        }
Ejemplo n.º 15
0
 protected virtual void OnRunProcess(EventArgs e)
 {
     RunProcess?.Invoke(this, e);
 }
Ejemplo n.º 16
0
        public ActionResult ShowFinishForm(RunProcess process)
        {
            try
            {
                if (process.ProcessContext.CurrentFormId != null)
                {
                    var formId = (Guid)process.ProcessContext.CurrentFormId;
                    var form   = process.FindFormById(formId);
                    if (form == null)
                    {
                        var pm = GetPresentationProxy();
                        form = pm.Proxy.GetAnyForm(formId, GetLanguage());
                    }

                    if (form is BizDetailForm)
                    {
                        if (process.ProcessContext.CurrentDocument != null)
                        {
                            if (process.ProcessContext.CurrentDocument.IsNew)
                            {
                                return(RedirectTo(
                                           new EditDocForm(this, formId, process.ProcessContext.CurrentDocument,
                                                           process.ProcessContext.UserActions)
                                {
                                    FormCaption = process.ProcessContext.FormCaption,
                                    ControlOptions = GetFormOptions(formId, process.ProcessContext.FormOptions)
                                }));
                            }

                            return
                                (RedirectTo(
                                     new ShowDocForm(this, formId, process.ProcessContext.CurrentDocument,
                                                     process.ProcessContext.UserActions)
                            {
                                FormCaption = process.ProcessContext.FormCaption,
                                ControlOptions = GetFormOptions(formId, process.ProcessContext.FormOptions)
                            }));
                        }

                        if (process.ProcessContext.CurrentDocumentId != null)
                        {
                            return(RedirectTo(
                                       new ShowDocForm(this, formId, (Guid)process.ProcessContext.CurrentDocumentId,
                                                       process.ProcessContext.UserActions)
                            {
                                FormCaption = process.ProcessContext.FormCaption,
                                ControlOptions = GetFormOptions(formId, process.ProcessContext.FormOptions)
                            }));
                        }

                        return(RedirectTo(
                                   new ExceptionState(this, process.Previous, Process.ParameterError
                                                      /*"Не все параметры заданы!"*/)));
                    }
                    if (form is BizTableForm)
                    {
                        return(RedirectTo(new ShowTableForm(this, formId, process.ProcessContext.FilterDocument,
                                                            process.ProcessContext.UserActions)
                        {
                            FormCaption = process.ProcessContext.FormCaption,
                            QueryDef = process.ProcessContext.CurrentQuery,
                            ControlOptions = GetFormOptions(formId, process.ProcessContext.FormOptions)
                        }));
                    }

                    return(ThrowException(Form.FormTypeError /*"Ошибка в типе формы"*/));
                }
                return(RedirectTo(
                           new ExceptionState(this, process.Previous, Process.ParameterError
                                              /*"Не все параметры заданы!"*/)));
            }
            catch (Exception e)
            {
                return(RedirectTo(new ExceptionState(this, e.Message)));
            }
        }