private ContactObject ProcessAddressToHashmap(string accountId, string inputAddress, DateTime modifiedOn)
        {
            ContactObject contactEntry = null;

            try
            {
                // computing an hash from the address provided
                var hashedAddress = GetMd5Hash(inputAddress);

                // getting a reference to Party or Role dictionary
                var currentDictionary = _contactSrc.GetDictionary();

                if (!currentDictionary.ContainsKey(accountId))
                {
                    // the accountId is not already known, we're adding a new contact entry to the dictionary
                    contactEntry = new ContactObject(accountId, hashedAddress, modifiedOn);
                    currentDictionary.Add(accountId, contactEntry);
                }
                else
                {
                    // the accountId is known, we're just updating it
                    contactEntry = _contactSrc.UpdateDictionary(accountId, hashedAddress, modifiedOn);
                }
            }
            catch (Exception ex)
            {
                var innerExMsg = ex.InnerException != null ? ex.InnerException.Message : "";
                Console.WriteLine($"ProcessAddressToHashmap() : Add/Modify entry to Hashmap error {ex.Message} : {innerExMsg}");
            }

            return(contactEntry);
        }
Beispiel #2
0
        public ContactObject UpdateDictionary(string accountId, string hashedAddress, DateTime modifiedOn)
        {
            ContactObject contactEntry = null;

            try
            {
                if (!ContactDictionary.ContainsKey(accountId))
                {
                    Console.WriteLine($"UpdateDictionary() : {accountId} entry could not be found");
                    return(null);
                }
                ContactDictionary.TryGetValue(accountId, out contactEntry);
                if (contactEntry != null)
                {
                    // The address is not matching any known address, we're adding it to the known list
                    if (!contactEntry.DoesKnowAddress(hashedAddress))
                    {
                        contactEntry.AddToKnownAddress(hashedAddress);
                        contactEntry.ModifiedOn = modifiedOn;
                    }
                }
            }
            catch (Exception Ex)
            {
                var Innermessage = Ex.InnerException != null ? Ex.InnerException.Message : "";
                Console.WriteLine($"[UpdateDictionary] {Ex.Message}  {Innermessage}");
            }

            return(contactEntry);
        }