Пример #1
0
        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);
        }
        public async Task <uint> ProcessImpactedAccounts(string OutputPath)
        {
            uint impactedEntitiesCpt = 0;

            Stopwatch sw = new Stopwatch();

            sw.Start();
            try
            {
                // Setting CVS Export File Header
                var colomn1 = "Account GUID";
                var colomn2 = "Contact ModifiedOn";
                var colomn3 = "Addresses Count";

                var outputText = String.Format($"{colomn1};{colomn2};{colomn3}");
                await WriteCvsLineAsync(OutputPath, outputText);

                // getting a reference to the account based contact dictionnary
                var partyContractDict = _partyContactSrc.GetDictionary();

                // getting a reference to the role based contact dictionnary
                var roleContractDict = _roleContactSrc.GetDictionary();

                foreach (var partyContact in partyContractDict.Values)
                {
                    var accoundId = partyContact.AccountId;

                    if (roleContractDict.ContainsKey(accoundId))
                    {
                        var roleContact    = roleContractDict[accoundId];
                        var addressToCheck = partyContact.GetFisrtKnownAddress();

                        // The party address was not found into the role possible addresses
                        // We're dealing with a discrepency
                        // The information are tracked into the CVS Export File
                        if (roleContact.DoesKnowAddress(addressToCheck) == false)
                        {
                            impactedEntitiesCpt++;
                            outputText = String.Format($"{accoundId};{roleContact.ModifiedOn.ToString("dd-MM-yyyy")};{roleContact.GetKnownAddressesCount() + partyContact.GetKnownAddressesCount()}");
                            await WriteCvsLineAsync(OutputPath, outputText);

                            if (BatchAddressAnalyzer.IsDebugMode)
                            {
                                roleContact.DumpKnownAddresses("Role");
                                partyContact.DumpKnownAddresses("Party");
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("[ProcessImpactedAccounts] : {0} {1}",
                                  ex.Message,
                                  ex.InnerException != null ? ex.InnerException.Message : "");
            }
            finally
            {
                sw.Stop();
                Console.WriteLine($"Data Export operation time : {new DateTime(sw.ElapsedTicks).ToString("HH: mm:ss.fff")}");

                if (_streamWriter != null)
                {
                    _streamWriter.Close();
                }
            }

            return(impactedEntitiesCpt);
        }