Ejemplo n.º 1
0
 public override void DefaultFlags(FlagCollection flags)
 {
     flags.Add('v', "verbose", "Outputs additional information", false);
     flags.Add('w', "wait", "Waits for enter before closing the console", false);
     flags.Add('p', "progress", "Display a progress bar", false);
     flags.Add('r', "raw", "Disables auto-conversion of binary files", false);
     flags.Add('e', "excel", "Uses ; instead of , as csv delimiter", false);
 }
        public void BitVectorTest()
        {
            FlagCollection <object, int> flagCollection = new FlagCollection <object, int>(converter);

            flagCollection.Add(new object(), -100);
            flagCollection.Add(new object(), 100);
            IList <int> list = new List <int>(flagCollection.Values);

            Assert.AreEqual(-1, list[0]);
            Assert.AreEqual(1, list[1]);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Email objects will be marked as unread and moved to a different folder for the next iteration
 /// </summary>
 /// <param name="unread"></param>
 /// <param name="markAsUnreadFlag"></param>
 /// <param name="inbox"></param>
 private static void MarkAsUnread(int[] unread, FlagCollection markAsUnreadFlag, Mailbox inbox)
 {
     foreach (var item in unread)
     {
         markAsUnreadFlag.Add(OutlookConstant.OutlookSeenMessages);
         inbox.RemoveFlags(item, markAsUnreadFlag);
         inbox.MoveMessage(item, OutlookConstant.OutlookProcessedFolder);
     }
 }
        public void AddTest()
        {
            Random random = RandomManager.CreateRandom((int)DateTime.Now.Ticks);
            FlagCollection <object, int> flagCollection = new FlagCollection <object, int>(converter);

            for (int i = 0; i < ItemCount; i++)
            {
                flagCollection.Add(new object(), random.Next(-100, 100));
            }
            Assert.AreEqual(ItemCount, flagCollection.Count);

            FlagCollection <object, int> flagCollection1 = new FlagCollection <object, int>(converter, flagCollection);

            Assert.AreEqual(flagCollection, flagCollection1);
        }
Ejemplo n.º 5
0
        private void _bSetFlag_Click(object sender, EventArgs e)
        {
            try
            {
                int            index = int.Parse(_lvMessages.SelectedItems[0].Text);
                FlagCollection flags = new FlagCollection();
                flags.Add("Answered");
                inbox.SetFlags(1, flags);

                this.AddLogEntry(string.Format("Flat answered setted to the message with index {0}", index.ToString()));
            }

            catch (Exception ex)
            {
                this.AddLogEntry(string.Format("Failed: {0}", ex.Message));
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Deletes a set of E-Mails by their messageID from a given mailbox
        /// </summary>
        /// <param name="messages">The IDs of the messages to delete</param>
        /// <param name="mailBoxName">The mailbox to delete the messages from</param>
        public void DeleteMails(List <EMail> messages, string mailBoxName)
        {
            if (messages.Count < 1)
            {
                return;
            }
            // get the mailbox
            Mailbox mailBox = Client.SelectMailbox(mailBoxName);

            // create a collection of flags to set for the emails
            var flags = new FlagCollection();

            // set only the deleted flag
            flags.Add(new Flag("DELETED"));


            // set the flag for each email in the messageIds
            try
            {
                Logging.Log.Info($"Deleting {messages.Count} mails from '{mailBoxName}'");
                if (mailBoxName == "INBOX")
                {
                    foreach (var mail in messages)
                    {
                        mailBox.SetFlags(mail.InBoxID, flags);
                    }
                }
                else
                {
                    foreach (var mail in messages)
                    {
                        mailBox.SetFlags(mail.PayPalFolderID, flags);
                    }
                }
                Logging.Log.Info($"Finished deleting {messages.Count} mails from '{mailBoxName}'");
            }
            catch (Exception ex)
            {
                Logging.Log.Error($"{ex.Message}:{ex.StackTrace}");
            }

            Client.Expunge();
        }
Ejemplo n.º 7
0
        public void MoveEmailRead(string SourceMailBox, string DestinationMailBox, string MessageId)
        {
            Mailbox mails = Client.SelectMailbox(SourceMailBox);

            int[] ids = mails.Search("ALL");

            if (ids.Length > 0)
            {
                for (var i = 0; i < ids.Length; i++)
                {
                    if (MessageId.Contains(Convert.ToString(ids[i])))
                    {
                        Client.Command("copy " + ids[i].ToString() + DestinationMailBox); //copy emails

                        FlagCollection flags = new FlagCollection();                      //delete emails
                        flags.Add("Deleted");
                        mails.AddFlags(ids[i], flags);
                    }
                }
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Method marks all READ mail as UNREAD MAIL.
        /// Method fetched the messageObject which automatically marks a message as read
        /// </summary>
        public void markMsgObjAsUnread()
        {
            Imap4Client    client           = new Imap4Client();
            FlagCollection markAsUnreadFlag = new FlagCollection();

            try
            {
                //Authenticate
                client.ConnectSsl(Constant.OutlookImapHost, Constant.ImapPort);
                client.Login(Constant.OutlookUserName, Constant.GenericPassword);

                //stage the enviornment
                Mailbox inbox       = client.SelectMailbox("inbox");
                int[]   allMessages = inbox.Search("ALL");

                Console.WriteLine("Message-Count: " + allMessages.Length);

                //Itearate and mark each mail object as unread
                foreach (var id in allMessages)
                {
                    Message msg = inbox.Fetch.MessageObject(id);
                    markAsUnreadFlag.Add("SEEN"); //adding all the read email objects to the flag collection
                    inbox.RemoveFlags(id, markAsUnreadFlag);
                    //then removing the flags, making each mail object as unread
                }
            }
            catch (Imap4Exception ie)
            {
                Console.WriteLine(string.Format("Imap4 Exception: {0}", ie.Message));
            }
            catch (Exception e)
            {
                Console.WriteLine(string.Format("Unexpected Exception: {0}"), e.Message);
            }
            finally
            {
                client.Disconnect();
            }
        }
        public void EnsureMessagesCanBeMarkedAsUnread()
        {
            Imap4Client client = new Imap4Client();

            client.ConnectSsl("imap-mail.outlook.com", 993);
            client.Login("*****@*****.**", "secret");

            Mailbox        inbox = client.SelectMailbox("Test");
            FlagCollection markAsUnreadFlagCollection = new FlagCollection();

            int[] inboxMessages = inbox.Search("ALL");

            foreach (var msg in inboxMessages)
            {
                Message m = inbox.Fetch.MessageObject(msg);
                markAsUnreadFlagCollection.Add("SEEN");
                inbox.RemoveFlags(msg, markAsUnreadFlagCollection);
            }

            int[] unreadEmailMessages = inbox.Search("UNSEEN");

            Assert.AreEqual(12, unreadEmailMessages.Length);
        }
Ejemplo n.º 10
0
    public void MoveTOProcessedFolder(string fromMailBox, string toMailBox, string strMsgId)
    {
        //Copy and delete from fromMailBox folder to toMailBox folder
        FlagCollection flags;
        Mailbox        mails = Client.SelectMailbox(fromMailBox);

        int[] ids = mails.Search("ALL");
        if (ids.Length > 0)
        {
            ActiveUp.Net.Mail.Message msg = null;
            for (var i = 0; i < ids.Length; i++)
            {
                msg = mails.Fetch.MessageObject(ids[i]);
                if (strMsgId.Contains(Convert.ToString(ids[i])))
                {
                    Client.Command("copy " + ids[i].ToString() + toMailBox); //copy emails

                    flags = new FlagCollection();                            //delete emails
                    flags.Add("Deleted");
                    mails.AddFlags(ids[i], flags);
                }
            }
        }
    }
Ejemplo n.º 11
0
 public override void DefaultFlags(FlagCollection flags)
 {
     flags.Add('v', "verbose", "Outputs additional information", false);
     flags.Add('w', "wait", "Waits for enter before closing the console", false);
 }
Ejemplo n.º 12
0
 public override void DefaultFlags(FlagCollection flags)
 {
     flags.Add('v', "verbose", "Enables logging of additional information", false);
 }
Ejemplo n.º 13
0
 public override void DefaultFlags(FlagCollection flags)
 {
     flags.Add('v', "verbose", "Outputs additional information", false);
     flags.Add('w', "wait", "Waits for enter before closing the console", false);
     flags.Add('e', "excel", "Uses ; instead of , as csv delimiter", false);
 }
Ejemplo n.º 14
0
 public override void DefaultFlags(FlagCollection flags)
 {
     flags.Add('v', "verbose", "Outputs additional information", false);
     flags.Add('w', "wait", "Waits for enter before closing the console", false);
     flags.Add('i', "init", "Initialize a new deployment resource");
 }
Ejemplo n.º 15
0
        private static Race LoadRace(PropertyBag raceProp, DropMacroCollection <Item> dropMacros, Content content,
                                     out int depth, out int rarity)
        {
            Character character = new Character('*', TermColor.Purple);

            PropertyBag art;

            if (raceProp.TryGetValue("art", out art))
            {
                //### bob: old style color and glyph combined
                character = Character.Parse(art.Value);
            }
            else
            {
                // separate glyph and color
                character = new Character(
                    Character.ParseGlyph(raceProp["glyph"].Value),
                    TermColors.FromName(raceProp["color"].Value));
            }

            // depth
            depth = raceProp["depth"].ToInt32();

            // speed
            int speed = raceProp.GetOrDefault("speed", 0) + Energy.NormalSpeed;

            // health
            Roller health = Roller.Parse(raceProp["health"].Value);

            // rarity
            rarity = raceProp.GetOrDefault("rarity", 1);

            // create the race
            Race race = new Race(content, raceProp.Name, depth, character, speed, health);

            // attacks
            PropertyBag attacks;

            if (raceProp.TryGetValue("attacks", out attacks))
            {
                foreach (PropertyBag attackProp in attacks)
                {
                    string[] attackParts = attackProp.Value.Split(' ');

                    // create the attack
                    Roller damage = Roller.Parse(attackParts[0]);

                    FlagCollection flags   = new FlagCollection();
                    Element        element = Element.Anima;

                    // add the flags or element
                    for (int i = 1; i < attackParts.Length; i++)
                    {
                        try
                        {
                            // see if the part is an element
                            element = (Element)Enum.Parse(typeof(Element), attackParts[i], true);
                        }
                        catch (ArgumentException)
                        {
                            // must be a flag
                            flags.Add(attackParts[i]);
                        }
                    }

                    //### bob: need to support different effect types
                    Attack attack = new Attack(damage, 0, 1.0f, element, attackProp.Name, EffectType.Hit, flags);

                    race.Attacks.Add(attack);
                }
            }

            // moves
            PropertyBag moves;

            if (raceProp.TryGetValue("moves", out moves))
            {
                foreach (PropertyBag moveProp in moves)
                {
                    string moveName = moveProp.Name;

                    // if an explicit move field is provided, then the prop name is not the name of the move itself
                    PropertyBag explicitMove;
                    if (moveProp.TryGetValue("move", out explicitMove))
                    {
                        moveName = explicitMove.Value;
                    }

                    // parse the specific move info
                    MoveInfo info = ParseMove(moveProp);

                    Move move;

                    // construct the move
                    switch (moveName)
                    {
                    case "haste self": move = new HasteSelfMove(); break;

                    case "ball self": move = new BallSelfMove(); break;

                    case "cone": move = new ElementConeMove(); break;

                    case "breathe": move = new BreatheMove(); break;

                    case "bolt": move = new BoltMove(); break;

                    case "message": move = new MessageMove(); break;

                    case "breed": move = new BreedMove(); break;

                    default:
                        throw new Exception("Unknown move \"" + moveName + "\".");
                    }

                    move.BindInfo(info);

                    race.Moves.Add(move);
                }
            }

            // flags
            foreach (PropertyBag childProp in raceProp)
            {
                if (childProp.Name.StartsWith("+ "))
                {
                    string flag = childProp.Name.Substring(2).Trim();

                    // handle the flags
                    switch (flag)
                    {
                    case "groups":              race.SetGroupSize(GroupSize.Group); break;

                    case "packs":               race.SetGroupSize(GroupSize.Pack); break;

                    case "swarms":              race.SetGroupSize(GroupSize.Swarm); break;

                    case "hordes":              race.SetGroupSize(GroupSize.Horde); break;

                    case "very-bright":         race.SetLightRadius(2); break;

                    case "bright":              race.SetLightRadius(1); break;

                    case "glows":               race.SetLightRadius(0); break;

                    case "unmoving":            race.SetPursue(Pursue.Unmoving); break;

                    case "slightly-erratic":    race.SetPursue(Pursue.SlightlyErratically); break;

                    case "erratic":             race.SetPursue(Pursue.Erratically); break;

                    case "very-erratic":        race.SetPursue(Pursue.VeryErratically); break;

                    case "unique":              race.SetFlag(RaceFlags.Unique); break;

                    case "boss":                race.SetFlag(RaceFlags.Boss); break;

                    case "opens-doors":         race.SetFlag(RaceFlags.OpensDoors); break;

                    default: Console.WriteLine("Unknown flag \"{0}\"", flag); break;
                    }
                }
            }

            // resists
            PropertyBag resists;

            if (raceProp.TryGetValue("resists", out resists))
            {
                ParseResists(resists.Value, race);
            }

            // drops
            PropertyBag drops;

            if (raceProp.TryGetValue("drops", out drops))
            {
                var          parser = new ItemDropParser(content);
                IDrop <Item> drop   = parser.ParseDefinition(drops, dropMacros);
                race.SetDrop(drop);
            }

            // description
            PropertyBag description;

            if (raceProp.TryGetValue("description", out description))
            {
                race.SetDescription(description.Value);
            }

            // groups
            PropertyBag groups;

            if (raceProp.TryGetValue("groups", out groups))
            {
                race.SetGroups(groups.Value.Split(' '));
            }

            return(race);
        }