示例#1
0
 private void btnSelectFolder_Click(object sender, EventArgs e)
 {
     if (SelectFolder.ShowDialog() == DialogResult.OK)
     {
         txtFilePath.Text = SelectFolder.SelectedPath;
     }
 }
示例#2
0
 private void LogButton_Click(object sender, System.EventArgs e)
 {
     if (SelectFolder.ShowDialog() == DialogResult.OK)
     {
         LogBox.Text = SelectFolder.SelectedPath + "\\Log.txt";
     }
 }
示例#3
0
        public static List <int> Execute(MailDb maildb, SelectFolder Folder, List <SearchItem> SearchItems, Func <MailDb, SelectFolder, Message, int> toResult)
        {
            // return list of seqno.
            var StartCol = FindStartCollectionItems(ref SearchItems);

            var Msgs = GetCollection(maildb, Folder, StartCol);

            List <int> result = new List <int>();

            foreach (var msg in Msgs)
            {
                bool match = true;

                foreach (var searchitem in SearchItems)
                {
                    if (!Check(maildb, Folder, searchitem, msg))
                    {
                        match = false;
                        break;
                    }
                }

                if (match)
                {
                    result.Add(toResult(maildb, Folder, msg));
                }
            }

            return(result);
        }
示例#4
0
 private void MainMenuSettingsPath_Click(object sender, EventArgs e)
 {
     if (SelectFolder.ShowDialog() == DialogResult.OK)
     {
         UnpackArgs.Path = SelectFolder.SelectedPath;
     }
 }
示例#5
0
        private bool clockstop = false;                                                    //定时关闭 true:停止 false:继续

        public BatchChaxunWindow(UserClass user)
        {
            InitializeComponent();
            DeleteCookies deleteCookies = new DeleteCookies();

            deleteCookies.SuppressWininetBehavior();
            if (File.Exists(filesavepath))
            {
                //账号信息文件存在
                StreamReader reader = new StreamReader(filesavepath);
                string       acce   = reader.ReadToEnd();
                if (!acce.Trim().Equals(""))
                {
                    string[] accearray = acce.Split('\n');
                    for (int i = 0; i < accearray.Length; i++)
                    {
                        string exce = accearray[i];
                        if (exce.IndexOf("caiji") >= 0)
                        {
                            this.pathTb.Text = exce.Substring(exce.IndexOf('@') + 1);
                        }
                    }
                    reader.Close();
                }
            }
            if (this.pathTb.Text.Trim().Equals(""))
            {
                this.pathTb.Text = SelectFolder.getWinPath();
            }
            this.user             = user;
            xianzhi.Content       = "*最多输入" + user.gatherresourcecount + "条资源!";
            this.ContentRendered += MLoad;
            this.webBrower.ObjectForScripting = new ChaXunScriptEvent(this);
        }
示例#6
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (SelectFolder.ShowDialog().Equals(DialogResult.OK) && !checkedListBox1.Items.Contains(SelectFolder.SelectedPath))
     {
         checkedListBox1.Items.Add(SelectFolder.SelectedPath, false);
     }
 }
        public async Task AddFolder()
        {
            var(success, folder) = SelectFolder.AskForLocation();
            if (success)
            {
                try
                {
                    InfoBox.Write($"Scanning 3rd party folder: {folder}.\n Please Wait.", InfoBox.Level.Status);
                    tokenSource = new();
                    await Task.Run(() => model.ThirdParty.AddFolder(folder, tokenSource.Token), tokenSource.Token);

                    SaveCache();
                    InfoBox.Write($"Finished scanning 3rd party folder: {folder}.", InfoBox.Level.Status);
                }
                catch (TargetInvocationException error)
                {
                    InfoBox.Write($"Error source: {error.InnerException.Source}", InfoBox.Level.Error);
                    InfoBox.Write($"Error error message: {error.InnerException.Message}", InfoBox.Level.Error);
                }
                catch (OperationCanceledException)
                {
                    InfoBox.Write($"Scanning 3rd party folder task canceled.", InfoBox.Level.Status);
                }
                finally
                {
                    tokenSource.Dispose();
                }
            }
        }
示例#8
0
 private void DatabaseButton_Click(object sender, System.EventArgs e)
 {
     if (SelectFolder.ShowDialog() == DialogResult.OK)
     {
         DatabaseBox.Text = SelectFolder.SelectedPath + "\\Database.sqlite";
     }
 }
示例#9
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var path = (string)value;

            if (path == null)
            {
                return(null);
            }
            string image;

            var name = SelectFolder.GetFileFolderName(path);

            if (string.IsNullOrEmpty(name))             // disk
            {
                image = "Images/disk.png";
            }
            else if (new FileInfo(path).Attributes.HasFlag(FileAttributes.Directory))
            {
                image = "Images/folder.png";
            }
            else
            {
                image = "Images/file.png";
            }

            return(new BitmapImage(new Uri($"pack://application:,,,/AppData/{image}")));
        }
示例#10
0
        public static List <ImapResponse> ExecuteByUid(MailDb mailDb, SelectFolder folder, string args)
        {
            var storeArgs = ParseStoreArgs(args);

            var messages = ImapHelper.GetMessagesByUid(mailDb, folder, storeArgs.Ranges);

            return(ExecuteNew(mailDb, messages, storeArgs.DataItem, storeArgs.Flags, storeArgs.Silent));
        }
示例#11
0
 public void showSaveEmailOther(Outlook.MailItem mailItem)
 {
     if (mailItem != null)
     {
         SelectFolder screen = new SelectFolder();
         screen.ShowDialog();
     }
 }
示例#12
0
#pragma warning restore CS0169 // The field 'SubFolderManager.FolderPathType' is never used

        public SubFolderManager(FolderRoute fr)
        {
            FolderRoute = fr;

            FolderRoute.PathChange   += onPathPathChangeEvent;
            FolderRoute.SelectFolder += onPathSelectFolderEvent;

            sf = new SelectFolder();
        }
示例#13
0
        /// <summary>
        /// 选择文件夹路径按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SelectFolderButtonClick(object sender, RoutedEventArgs e)
        {
            string path = SelectFolder.SelectFolderUtils();

            if (!path.Equals(""))
            {
                pathTb.Text = path;
            }
        }
示例#14
0
        public HeaderControl()
        {
            InitializeComponent();

            sm = SetgMgr.Instance;

            sf = new SelectFolder();

            sfm[SavedFolderType.HISTORY.Value()] = SavedFolderManager.GetHistoryManager();

            sfm[SavedFolderType.FAVORITES.Value()] = SavedFolderManager.GetFavoriteManager();
        }
示例#15
0
        /// <summary>
        /// FETCH
        /// </summary>
        public static List <ImapResponse> GenerateBySeqId(MailDb mailDb, SelectFolder Folder, string Cmd)
        {
            var cmdReader = new CommandReader(Cmd);
            var set       = cmdReader.SequenceSet;
            var range     = GetSequenceRange(set);

            var AllDataItems = cmdReader.ReadAllDataItems();

            var messages = ImapHelper.GetMessagesBySeqNo(mailDb, Folder, range);

            return(Generate(mailDb, Folder, AllDataItems, messages));
        }
示例#16
0
        /*
         * Brings up a folder browser dialog, allowing
         * user to navigate to and select a folder to
         * search.
         * @param object sender, EventArgs e
         */
        private void SelectBut_Click(object sender, EventArgs e)
        {
            DialogResult result = folderBrowserDialog1.ShowDialog();

            //sets result to button selected on dialog box
            //displays folder browser window.
            if (result == DialogResult.OK)                      //fires if a folder is selected and OK pressed.
            {
                folderPath = folderBrowserDialog1.SelectedPath; //sets folderpath to the selected file path.
                SelectFolder.Clear();                           //sets the textbox to clear
                SelectFolder.Text = folderPath;                 //sets the textbox to folderpath.
            }
        }
示例#17
0
        private void btnPickFolder_Click(object sender, EventArgs e)
        {
            //FolderId oFolderId = null;  // WellKnownFolderName.Root
            FolderId     oFolder = WellKnownFolderName.Root;
            SelectFolder oform   = new SelectFolder(_ExchangeService, oFolder);

            oform.ShowDialog();
            if (oform.ChoseOK == true)
            {
                //oform.ChosenFolderId;
                this.txtPickedFolder.Text = oform.ChosenFolderId.UniqueId;
                this.ChosenFolderId       = oform.ChosenFolderId;
            }
        }
示例#18
0
        /*
         * Brings up a folder browser dialog, allowing
         * user to navigate to and select a folder to
         * search.
         * @param object sender, EventArgs e
         */
        private void SelectBut_Click(object sender, EventArgs e)
        {
            DialogResult result = folderBrowserDialog1.ShowDialog();

            //sets result to button selected on dialog box
            //displays folder browser window.
            if (result == DialogResult.OK)                      //fires if a folder is selected and OK pressed.
            {
                folderPath = folderBrowserDialog1.SelectedPath; //sets folderpath to the selected file path.
                SelectFolder.Clear();                           //sets the textbox to clear
                SelectFolder.Text = folderPath;                 //sets the textbox to folderpath.
                index.ResetInvertedIndex();                     // resets inverted index in memory to a new Hashtable, so it can be built.
                index.StopWords();                              //builds the stopwords ArrayList
            }
        }
示例#19
0
        public static List <ImapResponse> Execute(MailDb maildb, SelectFolder Folder, string args, Func <MailDb, SelectFolder, Message, int> toResult)
        {
            var cmdreader = new SearchCommand.CommandReader(args);

            var allitems = cmdreader.ReadAllDataItems();

            var searchResult = Execute(maildb, Folder, allitems, toResult);

            List <ImapResponse> result = new List <ImapResponse>();

            var line = ResultLine.SEARCH(searchResult);

            result.Add(new ImapResponse(line));

            return(result);
        }
示例#20
0
        public static List <ImapResponse> Generate(MailDb maildb, SelectFolder Folder, List <DataItem> DataItems, List <FetchMessage> messages)
        {
            var response = new List <ImapResponse>();

            foreach (var message in messages)
            {
                var builder = new StringBuilder()
                              .Append("* " + message.SeqNo + " FETCH (");

                bool firstDataItem = true;
                foreach (var dataitem in DataItems)
                {
                    var itemResponse = ResponseManager.GetResponse(dataitem, maildb, message);
                    foreach (var each in itemResponse)
                    {
                        if (each.Line != null)
                        {
                            // Continue to append string if it's string
                            if (firstDataItem)
                            {
                                firstDataItem = false;
                            }
                            else
                            {
                                builder.Append(" ");
                            }

                            builder.Append(each.Line);
                        }
                        else
                        {
                            // Otherwise end the string and add bytes
                            response.Add(new ImapResponse(builder.ToString()));
                            response.Add(each);
                            builder.Clear();
                        }
                    }
                }

                builder.Append(")");
                response.Add(new ImapResponse(builder.ToString()));
            }

            return(response);
        }
示例#21
0
        /// <summary>
        /// UID FETCH
        /// </summary>
        public static List <ImapResponse> GenerateByUid(MailDb mailDb, SelectFolder Folder, string Cmd)
        {
            var cmdReader = new CommandReader(Cmd);
            var set       = cmdReader.SequenceSet;
            var range     = GetSequenceRange(set);

            var AllDataItems = cmdReader.ReadAllDataItems();

            var messages = ImapHelper.GetMessagesByUid(mailDb, Folder, range);

            // Auto include UID data item
            if (!AllDataItems.Any(o => o.Name == "UID"))
            {
                AllDataItems.Insert(0, new DataItem
                {
                    Name         = "UID",
                    FullItemName = "UID"
                });
            }

            return(Generate(mailDb, Folder, AllDataItems, messages));
        }
示例#22
0
 public static List <ImapResponse> ExecuteBySeqNo(MailDb maildb, SelectFolder Folder, string args)
 {
     return(Execute(maildb, Folder, args, (d, f, m) =>
                    d.Messages.GetSeqNo(f.Folder, f.Stat.LastestMsgId, f.Stat.Exists, m.Id)
                    ));
 }
示例#23
0
        public static bool Check(MailDb maildb, SelectFolder folder, SearchItem item, Message message)
        {
            //ALL ANSWERED DELETED DRAFT FLAGGED NEW OLD RECENT SEEN UNANSWERED UNDELETED UNDRAFT UNFLAGGED UNSEEN
            switch (item.Name)
            {
            case "ALL":
            {
                return(true);
            }

            case "ANSWERED":
            {
                return(message.Answered);
            }

            case "DELETED":
            {
                return(message.Deleted);
            }

            case "DRAFT":
            {
                return(message.Draft);
            }

            case "FLAGGED":
            {
                return(message.Flagged);
            }

            case "NEW":
            {
                return(message.Recent);
            }

            case "OLD":
            {
                return(!message.Recent);
            }

            case "RECENT":
            {
                return(message.Recent);
            }

            case "SEEN":
            {
                return(message.Read);
            }

            ///UNANSWERED UNDELETED UNDRAFT UNFLAGGED UNSEEN
            case "UNANSWERED":
            {
                return(!message.Answered);
            }

            case "UNDELETED":
            {
                return(!message.Deleted);
            }

            case "UNDRAFT":
            {
                return(!message.Draft);
            }

            case "UNFLAGGED":
            {
                return(!message.Flagged);
            }

            case "UNSEEN":
            {
                return(!message.Read);
            }

            case "BCC":
            {
                return(CheckText(maildb, message, item.Name, item.Parameters.First().Value.ToString()));
            }

            ///"BCC BODY CC FROM SUBJECT TEXT TO";
            case "CC":
            {
                return(CheckText(maildb, message, item.Name, item.Parameters.First().Value.ToString()));
            }

            case "TO":
            {
                return(CheckText(maildb, message, item.Name, item.Parameters.First().Value.ToString()));
            }

            case "FROM":
            {
                return(CheckText(maildb, message, item.Name, item.Parameters.First().Value.ToString()));
            }

            case "SUBJECT":
            {
                return(CheckText(maildb, message, item.Name, item.Parameters.First().Value.ToString()));
            }

            case "TEXT":
            {
                return(CheckText(maildb, message, item.Name, item.Parameters.First().Value.ToString()));
            }

            case "BODY":
            {
                return(CheckText(maildb, message, item.Name, item.Parameters.First().Value.ToString()));
            }

            case "HEADER":
            {
                var    field = item.Parameters["FIELD-NAME"].ToString();
                string value = null;
                if (item.Parameters.ContainsKey("STRING"))
                {
                    value = item.Parameters["STRING"].ToString();
                }
                return(CheckText(maildb, message, field, value));
            }

            ///string dateKey = "BEFORE SENTBEFORE SENTON SENTSINCE SINCE ON";
            case "BEFORE":
            {
                return(CheckDate(maildb, message, item.Name, (DateTime)item.Parameters["DATE"]));
            }

            case "SENTBEFORE":
            {
                return(CheckDate(maildb, message, item.Name, (DateTime)item.Parameters["DATE"]));
            }

            case "SENTON":
            {
                return(CheckDate(maildb, message, item.Name, (DateTime)item.Parameters["DATE"]));
            }

            case "SENTSINCE":
            {
                return(CheckDate(maildb, message, item.Name, (DateTime)item.Parameters["DATE"]));
            }

            case "SINCE":
            {
                return(CheckDate(maildb, message, item.Name, (DateTime)item.Parameters["DATE"]));
            }

            case "ON":
            {
                return(CheckDate(maildb, message, item.Name, (DateTime)item.Parameters["DATE"]));
            }

            case "SMALLER":
            {
                if (item.SeqCompareUid == -1)
                {
                    int value = (int)item.Parameters["N"];
                    var msg   = maildb.Messages.GetBySeqNo(folder.Folder, folder.Stat.LastestMsgId, folder.Stat.Exists, value);
                    if (msg != null)
                    {
                        item.SeqCompareUid = msg.Id;
                    }
                    else
                    {
                        item.SeqCompareUid = 0;
                    }
                }
                return(message.Id < item.SeqCompareUid);
            }

            case "LARGER":
            {
                if (item.SeqCompareUid == -1)
                {
                    int value = (int)item.Parameters["N"];
                    var msg   = maildb.Messages.GetBySeqNo(folder.Folder, folder.Stat.LastestMsgId, folder.Stat.Exists, value);

                    if (msg != null)
                    {
                        item.SeqCompareUid = msg.Id;
                    }
                    else
                    {
                        item.SeqCompareUid = 0;
                    }
                }
                return(message.Id > item.SeqCompareUid);
            }

            case "NOT":
            {
                if (item.NOT != null)
                {
                    return(!Check(maildb, folder, item.NOT, message));
                }
                else
                {
                    return(true);
                }
            }

            case "OR":
            {
                if (item.OROne == null && item.ORTwo == null)
                {
                    return(false);
                }

                bool match = false;
                if (item.OROne != null)
                {
                    if (Check(maildb, folder, item.OROne, message))
                    {
                        match = true;
                    }
                }

                if (item.ORTwo != null)
                {
                    if (Check(maildb, folder, item.ORTwo, message))
                    {
                        match = true;
                    }
                }
                return(match);
            }

            case "KEYWORD":
            {
                var value = item.Parameters["FLAG"].ToString();

                foreach (var flag in maildb.Messages.GetFlags(message.Id))
                {
                    if (flag.ToUpper() == value)
                    {
                        return(true);
                    }
                }
                return(false);
            }

            default:
                break;
            }

            return(true);
        }
示例#24
0
 public static List <ImapResponse> ExecuteByUid(MailDb maildb, SelectFolder Folder, string args)
 {
     return(Execute(maildb, Folder, args, (d, f, m) => m.Id));
 }
示例#25
0
        public static List <Message> GetCollection(MailDb maildb, SelectFolder Folder, SearchItem item)
        {
            if (item == null || item.Name == null)
            {
                return(maildb.Messages.FolderQuery(Folder.Folder).SelectAll());
            }

            if (item.Name == "LARGER" || item.Name == "SMALLER")
            {
                int value = (int)item.Parameters["N"];

                var msg = maildb.Messages.GetBySeqNo(Folder.Folder, Folder.Stat.LastestMsgId, Folder.Stat.Exists, value);

                if (msg == null)
                {
                    throw new CommandException("NO", "not a valid sequence no. ");
                }

                if (item.Name == "LARGER")
                {
                    return(maildb.Messages.FolderQuery(Folder.Folder).Where(o => o.Id > msg.Id).SelectAll());
                }
                else if (item.Name == "SMALLER")
                {
                    return(maildb.Messages.FolderQuery(Folder.Folder).Where(o => o.Id < msg.Id).SelectAll());
                }
            }
            else if (item.Name == "UID")
            {
                var set   = item.Parameters["SEQUENCE-SET"].ToString();
                var range = Kooboo.Mail.Imap.ImapHelper.GetSequenceRange(set);
                ImapHelper.CorrectRange(range, Folder, true);

                List <Message> result = new List <Message>();
                foreach (var uidrange in range)
                {
                    for (int i = uidrange.LowBound; i <= uidrange.UpBound; i++)
                    {
                        var msg = maildb.Messages.Get(i);
                        if (msg != null)
                        {
                            result.Add(msg);
                        }
                    }
                }
                return(result);
            }
            else
            {
                if (item.Name == "BEFORE" || item.Name == "SENTBEFORE")
                {
                    var date = (DateTime)item.Parameters["DATE"];
                    var tick = date.Ticks;
                    return(maildb.Messages.FolderQuery(Folder.Folder).Where(o => o.CreationTimeTick < tick).SelectAll());
                }
                else if (item.Name == "SENTSINCE" || item.Name == "SINCE")
                {
                    var date = (DateTime)item.Parameters["DATE"];
                    var tick = date.Ticks;
                    return(maildb.Messages.FolderQuery(Folder.Folder).Where(o => o.CreationTimeTick > tick).SelectAll());
                }
                else if (item.Name == "ON" || item.Name == "SENTON")
                {
                    var date = (DateTime)item.Parameters["DATE"];
                    // get the day before and after, then filter... I think this has better performance because there is an index on tick.
                    var before = date.AddDays(-1);
                    var after  = date.AddDays(1);

                    var allmessages = maildb.Messages.FolderQuery(Folder.Folder).Where(o => o.CreationTimeTick > before.Ticks && o.CreationTimeTick < after.Ticks).SelectAll();

                    if (allmessages != null && allmessages.Count() > 0)
                    {
                        return(allmessages.Where(o => o.CreationTime.DayOfYear == date.DayOfYear && o.CreationTime.Year == date.Year).ToList());
                    }
                }
                // string dateKey = "BEFORE SENTBEFORE SENTON SENTSINCE SINCE ON";
                // only those left...
            }

            // not collection found, loop all.
            return(maildb.Messages.FolderQuery(Folder.Folder).SelectAll());
        }
示例#26
0
 public static List <int> ExecuteBySeqNo(MailDb maildb, SelectFolder Folder, List <SearchItem> SearchItems)
 {
     return(Execute(maildb, Folder, SearchItems, (d, f, m) =>
                    d.Messages.GetSeqNo(f.Folder, f.Stat.LastestMsgId, f.Stat.Exists, m.Id)
                    ));
 }