private IExecutionContext CreateContext(string cookie) { IExecutionContext context = new Gin.Context.ExecutionContext(_ginRoot); Logging.Logging loggingObject = new Logging.Logging(); Directory.CreateDirectory(_cookiePath); string mainLoggerPath = Path.Combine(_ginRoot, Gin.ExecutionLogger.EXECUTION_LOG_FILENAME); ExecutionLogger mainFileLogger = new ExecutionLoggerTextFile(mainLoggerPath); loggingObject.AddLogger(mainFileLogger); string textLoggerPath = Path.Combine(_cookiePath, Gin.ExecutionLogger.EXECUTION_LOG_FILENAME); ExecutionLogger textFileLogger = new ExecutionLoggerTextFile(textLoggerPath); loggingObject.AddLogger(textFileLogger); _state.LogPath = textLoggerPath; _progressProxy = new ExecutionProgressProxy(OnProgress); loggingObject.SetProgress(_progressProxy); context.Log = loggingObject; return(context); }
private IExecutionContext CreateExecutionContext() { string rootPath = ConfigurationManager.AppSettings["ROOT_PATH"]; string logPath = ConfigurationManager.AppSettings["LOG_PATH"]; IExecutionContext context = new ExecutionContext(rootPath); Logging.Logging log = new Logging.Logging(); log.AutoFlushLoggers = true; log.AddLogger(new ExecutionLoggerTextFile(logPath)); context.Log = log; return context; }
private void LoadPackageAsync(string packageFilePath) { string rootPath = ConfigurationManager.AppSettings["ROOT_PATH"]; string logPath = ConfigurationManager.AppSettings["LOG_PATH"]; IExecutionContext context = new Gin.Context.ExecutionContext(rootPath); Logging.Logging log = new Logging.Logging(); log.AutoFlushLoggers = true; log.AddLogger(new ExecutionLoggerTextFile(logPath)); context.Log = log; Package pkg = new Package(context); SetCurrentStatus("Загрузка пакета"); SetFilePathStatus(packageFilePath); pkg.Load(packageFilePath); BuildPackageTree(pkg); }
public override CommandResult Do(ExecutionContext context) { if (String.IsNullOrEmpty(FileExt) || String.IsNullOrEmpty(ProgramPath)) { return CommandResult.Next; } if (!FileExt.StartsWith(".")) { FileExt = "." + FileExt; } string denormFileExt = FileExt.Substring(1); if (String.IsNullOrEmpty(FileType)) { FileType = "ft" + denormFileExt; } if (String.IsNullOrEmpty(TypeDescription)) { TypeDescription = denormFileExt.ToUpper() + " file"; } if (Registry.ClassesRoot.OpenSubKey(FileExt) == null) { RegistryKey key = Registry.ClassesRoot.CreateSubKey(FileExt); if(key==null) { throw new InvalidOperationException("Не могу создать ключ реестра"); } key.SetValue(null, FileType); } if (Registry.ClassesRoot.OpenSubKey(FileType) == null) { RegistryKey key = Registry.ClassesRoot.CreateSubKey(FileType); if (key == null) { throw new InvalidOperationException("Не могу создать ключ реестра"); } key.SetValue(null, TypeDescription); } RegistryKey regKey = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts"); if (regKey == null) { throw new InvalidOperationException("Не могу найти ключ реестра"); } if (regKey.OpenSubKey(FileExt.ToUpper()) == null) { RegistryKey key = regKey.CreateSubKey(FileExt.ToUpper()); if (key == null) { throw new InvalidOperationException("Не могу создать ключ реестра"); } key.SetValue("DefaultIcon", ProgramPath + ",0"); RegistryKey shell = key.CreateSubKey("Shell"); if (shell == null) { throw new InvalidOperationException("Не могу создать ключ реестра"); } shell.SetValue(null, "Open"); RegistryKey open = shell.CreateSubKey("Open"); shell.SetValue(null, "Default action"); if (open == null) { throw new InvalidOperationException("Не могу создать ключ реестра"); } shell.SetValue(null, ProgramPath + " %1"); } return CommandResult.Next; }
private IExecutionContext CreateContext(string cookie) { IExecutionContext context = new Gin.Context.ExecutionContext(_ginRoot); Logging.Logging loggingObject = new Logging.Logging(); Directory.CreateDirectory(_cookiePath); string mainLoggerPath = Path.Combine(_ginRoot, Gin.ExecutionLogger.EXECUTION_LOG_FILENAME); ExecutionLogger mainFileLogger = new ExecutionLoggerTextFile(mainLoggerPath); loggingObject.AddLogger(mainFileLogger); string textLoggerPath = Path.Combine(_cookiePath, Gin.ExecutionLogger.EXECUTION_LOG_FILENAME); ExecutionLogger textFileLogger = new ExecutionLoggerTextFile(textLoggerPath); loggingObject.AddLogger(textFileLogger); _state.LogPath = textLoggerPath; _progressProxy = new ExecutionProgressProxy(OnProgress); loggingObject.SetProgress(_progressProxy); context.Log = loggingObject; return context; }
private IExecutionContext CreateExecutionContext() { string rootPath = ConfigurationManager.AppSettings["ROOT_PATH"]; string logPath = ConfigurationManager.AppSettings["LOG_PATH"]; IExecutionContext context = new ExecutionContext(rootPath); context.ControlContainer = panelMain; Logging.Logging log = new Logging.Logging(); log.AutoFlushLoggers = true; log.AddLogger(new ExecutionLoggerTextFile(logPath)); log.AddLogger(new ExecutionLoggerMessageBox(this)); log.SetProgress(new ExecutionProgressWindowsForms(MainProgressBar, MainProgressLabel)); context.Log = log; return context; }