コード例 #1
0
 private void OpenGitAsAdminMethod()
 {
     if (FolderPath.Contains(" "))
     {
         StartProcess.StartInfo("C:\\Program Files\\Git\\git-cmd.exe", "--cd=" + "\"" + FolderPath + "\"", false, true);
     }
     else
     {
         StartProcess.StartInfo("C:\\Program Files\\Git\\git-cmd.exe", "--cd=" + FolderPath, false, true);
     }
 }
コード例 #2
0
        private void OpenTerminalAsAdminMethod()
        {
            string appPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), @"Microsoft\WindowsApps\Microsoft.WindowsTerminal_8wekyb3d8bbwe\wt.exe");

            if (FolderPath.Contains(" "))
            {
                StartProcess.StartInfo(appPath, "-d " + "\"" + FolderPath + "\"", false, true);
            }
            else
            {
                StartProcess.StartInfo(appPath, "-d " + FolderPath, false, true);
            }
        }
コード例 #3
0
        private void CheckSpecialtyAlbum()
        {
            foreach (var specialtyAlbumFolder in SpecialtyAlbums)
            {
                IsSpecialtyAlbum = FolderPath.Contains(specialtyAlbumFolder);

                if (IsSpecialtyAlbum)
                {
                    SpecialtyAlbumName = specialtyAlbumFolder.Replace("\\", "");
                    break;
                }
            }
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: kib/RemovePrivateFlag
        /// <summary>
        /// The main function of the program
        /// </summary>
        /// <param name="args">String array containing program arguments</param>
        public static void Main(string[] args)
        {
            if (args.Length > 0)
            {
                // getting all arguments from the command line
                var arguments = new UtilityArguments(args);

                if (arguments.Help)
                {
                    DisplayHelp();
                    Environment.Exit(0);
                }

                log.Info("Application started");

                string Mailbox = arguments.Mailbox;

                if ((Mailbox == null) || (Mailbox.Length == 0))
                {
                    if (log.IsWarnEnabled)
                    {
                        log.Warn("No mailbox is given. Use -help to refer to the usage.");
                    }
                    else
                    {
                        Console.WriteLine("No mailbox is given. Use -help to refer to the usage.");
                    }

                    DisplayHelp();
                    Environment.Exit(1);
                }

                // Log all arguments if DEBUG is set in xml
                log.Debug("Parsing arguments");
                log.Debug("Arguments:");
                log.Debug(string.Format("Mailbox: {0}", arguments.Mailbox));
                log.Debug(string.Format("Help: {0}", arguments.Help));
                log.Debug(string.Format("NoConfirmation: {0}", arguments.NoConfirmation));
                log.Debug(string.Format("LogOnly: {0}", arguments.LogOnly));
                log.Debug(string.Format("Impersonate: {0}", arguments.Impersonate));
                log.Debug(string.Format("AllowRedirection: {0}", arguments.AllowRedirection));
                log.Debug(string.Format("Archive: {0}", arguments.Archive));

                if (arguments.Foldername != null)
                {
                    log.Debug(string.Format("foldername: {0}", arguments.Foldername));
                }
                else
                {
                    log.Debug("foldername: not specified");
                }

                if (arguments.User != null)
                {
                    log.Debug(string.Format("User: {0}", arguments.User));
                }

                if (arguments.Password != null)
                {
                    log.Debug("Password: is set");
                }

                log.Debug(string.Format("ignorecertificate: {0}", arguments.IgnoreCertificate));
                if (arguments.URL != null)
                {
                    log.Debug(string.Format("Server URL: {0}", arguments.URL));
                }
                else
                {
                    log.Debug("Server URL: using autodiscover");
                }

                // Check if we need to ignore certificate errors
                // need to be set before the service is created
                if (arguments.IgnoreCertificate)
                {
                    log.Warn("Ignoring SSL error because option -ignorecertificate is set");
                    ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true;
                }

                WellKnownFolderName RootFolder;

                if (arguments.Archive)
                {
                    RootFolder = WellKnownFolderName.ArchiveMsgFolderRoot;
                }
                else
                {
                    RootFolder = WellKnownFolderName.MsgFolderRoot;
                }

                // create the service
                ExchangeService ExService;
                // connect to the server
                if (arguments.URL != null)
                {
                    ExService = ConnectToExchange(Mailbox, arguments.URL, arguments.User, arguments.Password, arguments.Impersonate);
                }
                else
                {
                    ExService = ConnectToExchange(Mailbox, arguments.AllowRedirection, arguments.User, arguments.Password, arguments.Impersonate);
                }

                if (log.IsInfoEnabled)
                {
                    log.Info("Service created.");
                }

                // find all folders (under MsgFolderRoot)
                List <Folder> FolderList = Folders(ExService, new FolderId(RootFolder, Mailbox));

                // check if we need to remove items from the list because we want to filter it (folderpath)
                string FolderName = arguments.Foldername;

                if (log.IsInfoEnabled)
                {
                    log.Info(string.Format("Folders with minimum one item inside: {0}", FolderList.Count));
                }
                if (FolderName != null)
                {
                    if (FolderName.Length > 0)
                    {
                        if (log.IsInfoEnabled)
                        {
                            log.Info("Filter the folder list to apply filter.");
                        }

                        for (int i = FolderList.Count - 1; i >= 0; i--) // yes, we need to it this way...
                        {
                            try
                            {
                                string FolderPath;

                                FolderPath = GetFolderPath(ExService, FolderList[i].Id);

                                if (!(FolderPath.Contains(FolderName)))
                                {
                                    log.Debug(string.Format("The folder: \"{0}\" does not match with the filter: \"{1}\"", FolderPath, FolderName));
                                    FolderList.RemoveAt(i);
                                }
                            }
                            catch
                            {
                                Environment.Exit(2);
                            }
                        }
                    }
                }

                // now try to find all items that are marked as "private"
                for (int i = FolderList.Count - 1; i >= 0; i--)
                {
                    if (log.IsDebugEnabled)
                    {
                        log.Debug(string.Format("Processing folder \"{0}\"", GetFolderPath(ExService, FolderList[i].Id)));
                    }

                    if (log.IsDebugEnabled)
                    {
                        log.Debug(string.Format("ID: {0}", FolderList[i].Id));
                    }

                    List <Item> Results = PrivateItems(FolderList[i]);

                    if (Results.Count > 0)
                    {
                        if (log.IsInfoEnabled)
                        {
                            log.Info(string.Format("Private items in folder: {0}", Results.Count));
                        }
                    }

                    foreach (var Result in Results)
                    {
                        if (Result is EmailMessage)
                        {
                            if (log.IsInfoEnabled)
                            {
                                if (log.IsInfoEnabled)
                                {
                                    log.Info(string.Format("Found private element. Folder: \"{0}\" ", GetFolderPath(ExService, FolderList[i].Id)));
                                }
                                if (log.IsInfoEnabled)
                                {
                                    log.Info(string.Format("Subject: \"{0}\"", Result.Subject));
                                }
                                if (log.IsDebugEnabled)
                                {
                                    log.Debug(string.Format("ID of the item: {0}", Result.Id));
                                }
                            }
                            else
                            {
                                Console.WriteLine("Found private element. Folder: {0}", GetFolderPath(ExService, FolderList[i].Id));
                                Console.WriteLine("Subject: {0}", Result.Subject);
                            }
                            if (!(arguments.NoConfirmation))
                            {
                                if (!(arguments.LogOnly))
                                {
                                    Console.WriteLine(string.Format("Change to normal? (Y/N) (Folder: {0} - Subject {1})", GetFolderPath(ExService, FolderList[i].Id), Result.Subject));
                                    string Question = Console.ReadLine();

                                    if (Question == "y" || Question == "Y")
                                    {
                                        log.Info("Change the item? Answer: Yes.");
                                        ChangeItem(Result);
                                    }
                                }
                            }
                            else
                            {
                                if (!(arguments.LogOnly))
                                {
                                    if (log.IsInfoEnabled)
                                    {
                                        log.Info("Changing item without confirmation because -NoConfirmation is true.");
                                    }
                                    else
                                    {
                                        Console.WriteLine("Changing item without confirmation because -NoConfirmation is true.");
                                    }
                                    ChangeItem(Result);
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                DisplayHelp();
                Environment.Exit(1);
            }
        }