Пример #1
0
        /// <summary>
        /// This program calculates the MD5 hashes for the given input files
        /// </summary>
        /// <param name="args"></param>
        private void Run(string[] args)
        {
            Console.OutputEncoding = Encoding.GetEncoding(Encoding.Default.CodePage);
            Args = new InputArgs("md5sums", string.Format(resource.IDS_TITLE, AppVersion.Get()) + "\r\n" + resource.IDS_COPYRIGHT);

            Args.Add(InputArgType.Flag, "recursive", false, Presence.Optional, resource.IDS_CMD_recursive_doc);
            Args.Add(InputArgType.RemainingParameters, "DIR {DIR}", null, Presence.Optional, resource.IDS_CMD_dir_doc);

            if (Args.Process(args))
            {
                Recursive = Args.GetFlag("recursive");

                List <string> directories = Args.GetStringList("DIR {DIR}");
                if (directories == null)
                {
                    Read(Directory.GetCurrentDirectory());
                }
                else
                {
                    foreach (string directory in directories)
                    {
                        Read(SanitizeInput(directory));
                    }
                }
            }
        }
Пример #2
0
        /// <summary>
        /// This program finds an executable on the PATH. It can also find other stuff on the path, but
        /// mostly it finds the executable.s
        /// </summary>
        /// <param name="args"></param>
        private void Run(string[] args)
        {
            Console.OutputEncoding = Encoding.GetEncoding(Encoding.Default.CodePage);
            Args = new InputArgs("ddupe", string.Format(resource.IDS_TITLE, AppVersion.Get()) + "\r\n" + resource.IDS_COPYRIGHT);

            Args.Add(InputArgType.Flag, "recursive", false, Presence.Optional, resource.IDS_CMD_recursive_doc);
            Args.Add(InputArgType.Flag, "rename", false, Presence.Optional, resource.IDS_CMD_rename_doc);
            Args.Add(InputArgType.Parameter, "cache", null, Presence.Optional, resource.IDS_CMD_cache_doc);
            Args.Add(InputArgType.Flag, "delete", false, Presence.Optional, resource.IDS_CMD_delete_doc);
            Args.Add(InputArgType.SizeInBytes, "minsize", 0, Presence.Optional, resource.IDS_CMD_minsize_doc);
            Args.Add(InputArgType.RemainingParameters, "DIR {DIR}", null, Presence.Required, resource.IDS_CMD_dir_doc);

            if (Args.Process(args))
            {
                UseDatabase = DatabaseCache.Initialize(Args.GetString("cache"), Cache);
                Recursive   = Args.GetFlag("recursive");
                RenameFiles = Args.GetFlag("rename");
                DeleteFiles = Args.GetFlag("delete");
                MinSize     = Args.GetSizeInBytes("minsize");

                foreach (string directory in Args.GetStringList("DIR {DIR}"))
                {
                    Read(SanitizeInput(directory));
                }
            }
            if (FilesChecked > 0)
            {
                DatabaseCache.Flush();

                TimeSpan elapsed = DateTime.Now - StartupTime;

                Console.WriteLine("____________________________________________________________________________________");
                Console.WriteLine(resource.IDS_finished, elapsed);

                Console.WriteLine(resource.IDS_total_checked,
                                  FilesChecked,
                                  BytesAsString(BytesChecked),
                                  HashesRead,
                                  TimeSpentCalculatingMD5s);

                if (RenameFiles)
                {
                    Console.WriteLine(resource.IDS_total_renamed,
                                      FilesRenamed,
                                      BytesAsString(BytesRenamed));

                    Console.WriteLine(resource.IDS_total_hashes,
                                      RenamedHashes,
                                      BytesAsString(RenamedBytes));
                }

                Console.WriteLine(resource.IDS_total_dupes,
                                  FilesDetected,
                                  BytesAsString(BytesDetected),
                                  ((double)FilesDetected) / ((double)FilesChecked),
                                  ((double)BytesDetected) / ((double)BytesChecked));
            }
        }
Пример #3
0
        public MainWindow()
        {
            InitializeComponent();

            Output = new StringBuilder();
            Output.EnsureCapacity(MAX_CAPACITY);
            LastKnownFileName = "";
            Calculator        = gcalc.gcalc_create();
            Title             = string.Format("gkalk {0}", AppVersion.Get());
        }
Пример #4
0
 public MainWindow()
 {
     InitializeComponent();
     KnownViews[MainViewType.ListByDLLName] = new DataView(new GetModulesByName(), BtDllName);
     KnownViews[MainViewType.ListByDLLPath] = new DataView(new GetModulesByPath(), BtDllPath);
     KnownViews[MainViewType.ListByEXEName] = new DataView(new GetProcessesByName(), BtExeName);
     KnownViews[MainViewType.ListByEXEPath] = new DataView(new GetProcessesByPath(), BtExePath);
     UnselectedBackgroundColor = new SolidColorBrush(Color.FromArgb(255, 0xF5, 0xF5, 0xF5));
     UnselectedForegroundColor = new SolidColorBrush(Colors.Black);
     SelectedBackgroundColor   = new SolidColorBrush(Colors.CornflowerBlue);
     SelectedForegroundColor   = new SolidColorBrush(Colors.White);
     Title = string.Format("dllusage {0}", AppVersion.Get());
     MainTreeView.ItemsSource = Items;
     MainTreeView.ContextMenu = CreateContextMenu();
 }
Пример #5
0
        public ActionResult Index()
        {
            var environment = new WebHostingEnvironment();
            var version     = AppVersion.Get();

            var info = new InfoModel
            {
                Environment      = environment.EnvironmentName,
                IsProduction     = environment.IsProduction(),
                FileVersion      = version.FileVersion,
                ProductVersion   = version.ProductVersion,
                ConnectionString = ConfigurationManager.ConnectionStrings["Demo"].ConnectionString,
            };

            return(View(info));
        }
Пример #6
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public MainViewModel(IPluginService pluginService, IClipboardService clipboardService, IPortableNavigationService navigationService,
                             IDialogService dialogService)
        {
            this.pluginService     = pluginService;
            this.clipboardService  = clipboardService;
            this.navigationService = navigationService;
            this.dialogService     = dialogService;

            var version = AppVersion.Get().ProductVersion.Split('+')[0];

            Title    = $"Timesheet Parser {version}";
            JobsDate = DateTime.Now;

            GenerateCommand   = new RelayCommand(GenerateCommand_Executed);
            SubmitJobsCommand = new RelayCommand(SubmitJobs_Executed, SubmitJobs_CanExecute);
            HelpCommand       = new RelayCommand(HelpCommand_Executed);
        }
Пример #7
0
Файл: su.cs Проект: jwg4/gtools
        /// <summary>
        /// This program finds an executable on the PATH. It can also find other stuff on the path, but
        /// mostly it finds the executable.s
        /// </summary>
        /// <param name="args"></param>
        private void Run(string[] args)
        {
            Console.OutputEncoding = Encoding.GetEncoding(Encoding.Default.CodePage);

            Args = new InputArgs("su", string.Format(resource.IDS_TITLE, AppVersion.Get()) + "\r\n" + resource.IDS_COPYRIGHT);

            Args.Add(InputArgType.Parameter, "cmd", "cmd.exe", Presence.Optional, resource.IDS_DOC_cmd_param);

            if (Args.Process(args))
            {
                string command = Args.GetString("cmd");
                if (command.Equals("cmd.exe", StringComparison.OrdinalIgnoreCase))
                {
                    if (!IsAdministrator())
                    {
                        ProcessStartInfo startInfo = new ProcessStartInfo(Path.Combine(Environment.SystemDirectory, "cmd.exe"));
                        startInfo.Verb             = "runas";
                        startInfo.WorkingDirectory = Environment.CurrentDirectory;
                        startInfo.Arguments        = string.Format("/K \"cd /d {0}\"", startInfo.WorkingDirectory);

                        System.Diagnostics.Process.Start(startInfo);
                    }
                    else
                    {
                        Console.WriteLine(resource.IDS_ERR_AlreadyRunningAsAdministrator);
                    }
                }
                else
                {
                    string exe;
                    if (ProcessInfoTools.FindExecutable(command, out exe))
                    {
                        ProcessStartInfo startInfo = new ProcessStartInfo(exe);
                        startInfo.Verb             = "runas";
                        startInfo.WorkingDirectory = Environment.CurrentDirectory;

                        System.Diagnostics.Process.Start(startInfo);
                    }
                    else
                    {
                        Console.WriteLine(resource.IDS_ERR_UnableToFindFile, command);
                    }
                }
            }
        }
Пример #8
0
        /// <summary>
        /// This program calculates the MD5 hashes for the given input files
        /// </summary>
        /// <param name="args"></param>
        private void Run(string[] args)
        {
            Console.OutputEncoding = Encoding.GetEncoding(Encoding.Default.CodePage);
            Args = new InputArgs("touch", string.Format(resource.IDS_TITLE, AppVersion.Get()) + "\r\n" + resource.IDS_COPYRIGHT);

            Args.Add(InputArgType.Parameter, "date", "", Presence.Optional, resource.IDS_CMD_date_doc);
            Args.Add(InputArgType.Parameter, "time", "", Presence.Optional, resource.IDS_CMD_time_doc);
            Args.Add(InputArgType.Flag, "recursive", false, Presence.Optional, resource.IDS_CMD_recursive_doc);
            Args.Add(InputArgType.RemainingParameters, "DIR {DIR}", null, Presence.Optional, resource.IDS_CMD_dir_doc);

            if (Args.Process(args))
            {
                DateTime dateSpec = DateTime.Now;
                DateTime timeSpec = DateTime.Now;
                string   date     = Args.GetString("DATE");
                if (!string.IsNullOrEmpty(date))
                {
                    try
                    {
                        dateSpec = DateTime.Parse(date);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                        Console.WriteLine(e.StackTrace);
                        Console.WriteLine(resource.IDS_ERR_unable_to_decode_date, date);
                        return;
                    }
                }
                string time = Args.GetString("TIME");
                if (!string.IsNullOrEmpty(time))
                {
                    try
                    {
                        timeSpec = DateTime.Parse(time);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                        Console.WriteLine(e.StackTrace);
                        Console.WriteLine(resource.IDS_ERR_unable_to_decode_time, time);
                        return;
                    }
                }
                TimeStamp = new DateTime(dateSpec.Year, dateSpec.Month, dateSpec.Day, timeSpec.Hour, timeSpec.Minute, timeSpec.Second);

                Recursive = Args.GetFlag("recursive");

                List <string> directories = Args.GetStringList("DIR {DIR}");
                if (directories == null)
                {
                    Read(Directory.GetCurrentDirectory());
                }
                else
                {
                    foreach (string directory in directories)
                    {
                        Read(SanitizeInput(directory));
                    }
                }
            }
        }
Пример #9
0
        /// <summary>
        /// This program finds an executable on the PATH. It can also find other stuff on the path, but
        /// mostly it finds the executable.s
        /// </summary>
        /// <param name="args"></param>
        private void Run(string[] args)
        {
            Console.OutputEncoding = Encoding.GetEncoding(Encoding.Default.CodePage);

            Args = new InputArgs("which", string.Format(resource.IDS_TITLE, AppVersion.Get()) + "\r\n" + resource.IDS_COPYRIGHT);


            Args.Add(InputArgType.StringList, "extension", null, Presence.Optional, resource.IDS_CMD_extension_doc);
            Args.Add(InputArgType.StringList, "dir", null, Presence.Optional, resource.IDS_CMD_dir_doc);
            Args.Add(InputArgType.Flag, "recursive", false, Presence.Optional, resource.IDS_CMD_recursive_doc);
            Args.Add(InputArgType.Flag, "single", false, Presence.Optional, resource.IDS_CMD_single_doc);
            Args.Add(InputArgType.RemainingParameters, "FILE {FILE}", null, Presence.Required, resource.IDS_CMD_file_doc);
            Args.Add(InputArgType.Parameter, "env", "PATH", Presence.Optional, resource.IDS_CMD_env_doc);

            if (Args.Process(args))
            {
                Filenames   = Args.GetStringList("FILE {FILE}");
                Directories = Args.FindOrCreateStringList("dir");

                string EnvironmentVariableName = Args.GetString("env");
                if (!string.IsNullOrEmpty(EnvironmentVariableName))
                {
                    string env = Environment.GetEnvironmentVariable(EnvironmentVariableName, EnvironmentVariableTarget.User);
                    if (string.IsNullOrEmpty(env))
                    {
                        env = Environment.GetEnvironmentVariable(EnvironmentVariableName);
                    }
                    EnvironmentVariablesAlreadyChecked[EnvironmentVariableName] = true;
                    if (string.IsNullOrEmpty(env))
                    {
                        Console.WriteLine(resource.IDS_ERR_invalid_env_var, EnvironmentVariableName);
                    }
                    else
                    {
                        foreach (string token in env.Split(';'))
                        {
                            Directories.Add(token);
                        }
                    }
                }

                if (FilenamesAreIncludes())
                {
                    AddEnvBasedDirectories("INCLUDE");
                }
                else if (FilenamesAreLibs())
                {
                    AddEnvBasedDirectories("LIB");
                }
                else
                {
                    // default: use standard windows lookup
                    Directories.Add(Directory.GetCurrentDirectory());
                    Directories.Add(PathSanitizer.GetWindowsDirectory());
                    Directories.Add(PathSanitizer.Get32BitSystemDirectory());
                    Directories.Add(Environment.SystemDirectory);
                    Directories.Add(Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName));
                    Directories.Add(Environment.GetFolderPath(Environment.SpecialFolder.System));
                    Directories.Add(Path.GetDirectoryName(Environment.GetFolderPath(Environment.SpecialFolder.System)));
                    AddEnvBasedDirectories("PATH");
                }

                Directories.MakeUnique(StringComparison.OrdinalIgnoreCase);

                List <string> Extensions = Args.FindOrCreateStringList("extension");
                if (Extensions.Count == 0)
                {
                    foreach (string path in Environment.GetEnvironmentVariable("PATHEXT").Split(';'))
                    {
                        Extensions.Add(path);
                    }
                }

                List <string> FoundItems = new List <string>();
                foreach (string filename in Filenames)
                {
                    bool found = false;
                    foreach (string foundname in Locate(filename))
                    {
                        if (!Contains(FoundItems, foundname))
                        {
                            FileInfo fi = new FileInfo(foundname);

                            Console.WriteLine(resource.IDS_RESULT_PATTERN,
                                              foundname, fi.LastWriteTime, fi.Length);
                            FoundItems.Add(foundname);
                            if (Args.GetFlag("single"))
                            {
                                break;
                            }

                            found = true;
                        }
                    }
                    if (!found)
                    {
                        Console.WriteLine(resource.IDS_ERR_not_found, filename);
                    }
                }
            }
        }
Пример #10
0
 public void UpdateTitle()
 {
     Title = string.Format("pserv {0}: {1}", AppVersion.Get(), CurrentController.Caption);
 }
Пример #11
0
        /// <summary>
        /// This program allows you to view and modify the PATH environment.
        /// </summary>
        /// <param name="args"></param>
        private void Run(string[] args)
        {
            Console.OutputEncoding = Encoding.GetEncoding(Encoding.Default.CodePage);
            Args = new InputArgs("pathed", string.Format(resource.IDS_TITLE, AppVersion.Get()) + "\r\n" + resource.IDS_COPYRIGHT);

            Args.Add(InputArgType.Flag, "machine", false, Presence.Optional, resource.IDS_CMD_machine_doc);
            Args.Add(InputArgType.Flag, "user", false, Presence.Optional, resource.IDS_CMD_user_doc);
            Args.Add(InputArgType.ExistingDirectory, "add", "", Presence.Optional, resource.IDS_CMD_add_doc);
            Args.Add(InputArgType.ExistingDirectory, "append", "", Presence.Optional, resource.IDS_CMD_append_doc);
            Args.Add(InputArgType.StringList, "remove", null, Presence.Optional, resource.IDS_CMD_remove_doc);
            Args.Add(InputArgType.Flag, "slim", false, Presence.Optional, resource.IDS_CMD_slim_doc);
            Args.Add(InputArgType.Parameter, "env", "PATH", Presence.Optional, resource.IDS_CMD_env_doc);

            if (Args.Process(args))
            {
                EnvironmentVariableName = Args.GetString("env");

                if (Args.GetFlag("slim"))
                {
                    SlimPath();
                }

                if (Args.GetFlag("machine"))
                {
                    EnvironmentVariableTarget = EnvironmentVariableTarget.Machine;
                }

                else if (Args.GetFlag("user"))
                {
                    EnvironmentVariableTarget = EnvironmentVariableTarget.User;
                }

                try
                {
                    List <string> removeItems = Args.GetStringList("remove");
                    if (removeItems != null)
                    {
                        Remove(removeItems);
                    }

                    string add = Args.GetString("add");
                    if (!string.IsNullOrEmpty(add))
                    {
                        AddHead(SanitizePath(add));
                    }

                    string append = Args.GetString("append");
                    if (!string.IsNullOrEmpty(append))
                    {
                        AddTail(SanitizePath(append));
                    }
                }
                catch (SecurityException ex)
                {
                    if (EnvironmentVariableTarget == EnvironmentVariableTarget.Machine)
                    {
                        Console.WriteLine(ex.Message);
                        Console.WriteLine(resource.IDS_ERR_access_denied);
                        return;
                    }
                    else
                    {
                        throw;
                    }
                }

                ListPath();
            }
        }