Esempio n. 1
0
        public void RefreshAssociations()
        {
            _logger.Information("Attempting to link sites and folders");
            SiteDal siteDal = new SiteDal(_configuration, _logger);
            IEnumerable <SiteForExtendedTicketDto> sites = siteDal.GetSiteForExtendedTicket("red alert").GetAwaiter().GetResult();

            _logger.Information($"Retreived {sites.Count()} new link sites");
            Dictionary <string, int> siteAssociation = new AssociationHelper(sites, _logger).SiteAssociation;

            foreach (KeyValuePair <string, int> site in siteAssociation)
            {
                CRUDEnums.ActionResult result = siteDal.Post(site.Value, site.Key).GetAwaiter().GetResult();
                if (result != CRUDEnums.ActionResult.Success)
                {
                    _logger.Error($"Error updating site {site.Value} with external identifier {site.Key} Error {result.ToString()}");
                }
            }
            _logger.Information("Completed link sites and folders");
        }
Esempio n. 2
0
        protected IEnumerable <FullEmailModel> saveAndValidateExtendedEmails(IEnumerable <FullEmailModel> emails)
        {
            //Any emails to be saved to database

            List <FullEmailModel> validEmails = new List <FullEmailModel>();

            foreach (FullEmailModel email in emails)
            {
                if (email.From.ToLower() != _acceptedEmailAddress)
                {
                    if (!_emailHelper.MoveEmail(email.UniqueIdentifier, CommunicationLocationEnum.InvalidSender))
                    {
                        _logger.Error($"Could not send Email {email.UniqueIdentifier} to Invalid Sender Folder");
                    }
                    continue;
                }

                CRUDEnums.ActionResult actionResult = _emailAlertsDal.Put(email).GetAwaiter().GetResult();

                if (actionResult != CRUDEnums.ActionResult.Success)
                {
                    if (actionResult == CRUDEnums.ActionResult.Duplicate)
                    {
                        _logger.Information($"Full email {email.UniqueIdentifier} did not save due to duplication");
                        if (!_emailHelper.MoveEmail(email.UniqueIdentifier, CommunicationLocationEnum.Duplicate))
                        {
                            _logger.Error($"Could not send Email {email.UniqueIdentifier} to Duplicated Folder");
                        }
                    }
                    else
                    {
                        _logger.Error($"An error occured while saving full email {email.UniqueIdentifier} to the database Error Type {actionResult.ToString()}");
                        if (!_emailHelper.MoveEmail(email.UniqueIdentifier, CommunicationLocationEnum.Unparsed))
                        {
                            _logger.Error($"Could not send Email {email.UniqueIdentifier} to Unparsed Folder");
                        }
                    }


                    continue;
                }
                validEmails.Add(email);
                if (!_emailHelper.DeleteBatch(new string[] { email.UniqueIdentifier }))
                {
                    _logger.Error($"Could not remove emails {email.UniqueIdentifier} from mailbox");
                }
            }
            return(validEmails);
        }