Пример #1
0
        public bool SetMessagesTag(IDaoFactory daoFactory, List <int> messageIds, int tagId)
        {
            var daoTag = daoFactory.CreateTagDao(Tenant, User);

            var tag = daoTag.GetTag(tagId);

            if (tag == null)
            {
                return(false);
            }

            List <int>       validIds;
            List <ChainInfo> chains;

            GetValidForUserMessages(daoFactory, messageIds, out validIds, out chains);

            var daoTagMail = daoFactory.CreateTagMailDao(Tenant, User);

            daoTagMail.SetMessagesTag(validIds, tag.Id);

            UpdateTagsCount(daoTagMail, daoTag, tag);

            foreach (var chain in chains)
            {
                Factory.ChainEngine.UpdateChainTags(daoFactory, chain.Id, chain.Folder, chain.MailboxId, Tenant, User);
            }

            var daoMail = daoFactory.CreateMailDao(Tenant, User);

            // Change time_modified for index
            daoMail.SetMessagesChanged(validIds);

            return(true);
        }
Пример #2
0
        private static void UpdateMessageChainFlag(IDaoFactory daoFactory, int tenant, string user, int messageId, string fieldFrom, string fieldTo)
        {
            var daoMail = daoFactory.CreateMailDao(tenant, user);

            var mail = daoMail.GetMail(new ConcreteUserMessageExp(messageId, tenant, user));

            if (mail == null)
            {
                return;
            }

            var daoMailInfo = daoFactory.CreateMailInfoDao(tenant, user);

            var maxValue = daoMailInfo.GetFieldMaxValue <bool>(
                SimpleMessagesExp.CreateBuilder(tenant, user)
                .SetChainId(mail.ChainId)
                .SetMailboxId(mail.MailboxId)
                .SetFolder((int)mail.Folder)
                .Build(),
                fieldFrom);

            var daoChain = daoFactory.CreateChainDao(tenant, user);

            daoChain.SetFieldValue(
                SimpleConversationsExp.CreateBuilder(tenant, user)
                .SetChainId(mail.ChainId)
                .SetMailboxId(mail.MailboxId)
                .SetFolder((int)mail.Folder)
                .Build(),
                fieldTo,
                maxValue);
        }