Example #1
0
    public Worker(Action <string, string> logAdder = null, bool popup = false)
    {
        AddLog = logAdder ?? Print;

        Conf = new Conf(Abort);

        if (Conf.OutFileDir != null)
        {
            FileLogger = new MyFileLogger(Conf);
        }

        Psi = new ProcessStartInfo
        {
            FileName         = Conf.WorkerFileName,
            Arguments        = Conf.WorkerArguments,
            WorkingDirectory = Conf.WorkingDir
        };

        if (popup)
        {
            RedirectMode        = false;
            Psi.UseShellExecute = true;
            return;
        }

        RedirectMode               = true;
        Psi.UseShellExecute        = false;
        Psi.RedirectStandardOutput = true;
        Psi.RedirectStandardError  = true;
        Psi.RedirectStandardInput  = true;
        Psi.StandardErrorEncoding  = Conf.WorkerEncodingObj;
        Psi.StandardOutputEncoding = Conf.WorkerEncodingObj;

        foreach (var item in Conf.Environments)
        {
            Psi.EnvironmentVariables[item.Key] = item.Value;
        }
    }
Example #2
0
 public CommentController(WorksContext context, ManagerLoginAdmin managerLoginAdmin, MyFileLogger logger)
 {
     db = context;
     _managerLoginAdmin = managerLoginAdmin;
     _logger            = logger;
 }