public static RegisterReferrer[] RemoveRegisterReferrersByEmailMobile( RegisterReferrer[] regRefs, bool incHasBothMobileEmail, bool incHasMobileNoEmail, bool incHasEmailNoMobile, bool incHasNeitherMobileEmail) { if (incHasBothMobileEmail && incHasMobileNoEmail && incHasEmailNoMobile && incHasNeitherMobileEmail) return regRefs; if (!incHasBothMobileEmail && !incHasMobileNoEmail && !incHasEmailNoMobile && !incHasNeitherMobileEmail) return new RegisterReferrer[] { }; int[] regRefIDs = regRefs.Select(r => r.RegisterReferrerID).ToArray(); int[] entityIDs = regRefs.Select(r => r.Organisation.EntityID).ToArray(); Hashtable entityIDHash = RegisterReferrerDB.GetOrgEntityIDsHash(regRefIDs); Hashtable regRefIDHash = RegisterReferrerDB.GetByIDsInHashtable(regRefIDs); Hashtable emailHash = PatientsContactCacheDB.GetBullkEmail(entityIDs, -1); Hashtable mobileHash = PatientsContactCacheDB.GetBullkPhoneNumbers(entityIDs, -1, "30"); ArrayList newList = new ArrayList(); for (int i = 0; i < regRefs.Length; i++) { bool hasEmail = emailHash[regRefs[i].Organisation.EntityID] != null; bool hasMobile = mobileHash[regRefs[i].Organisation.EntityID] != null; if ((incHasBothMobileEmail && hasEmail && hasMobile) || (incHasMobileNoEmail && !hasEmail && hasMobile) || (incHasEmailNoMobile && hasEmail && !hasMobile) || (incHasNeitherMobileEmail && !hasEmail && !hasMobile)) newList.Add(regRefs[i]); } return (RegisterReferrer[])newList.ToArray(typeof(RegisterReferrer)); }
public static void GetCountsByEmailMobile( RegisterReferrer[] regRefs, ref int hasBothMobileEmail, ref int hasMobileNoEmail, ref int hasEmailNoMobile, ref int hasNeitherMobileEmail) { int[] regRefIDs = regRefs.Select(r => r.RegisterReferrerID).ToArray(); int[] entityIDs = regRefs.Select(r => r.Organisation.EntityID).ToArray(); Hashtable entityIDHash = RegisterReferrerDB.GetOrgEntityIDsHash(regRefIDs); Hashtable regRefIDHash = RegisterReferrerDB.GetByIDsInHashtable(regRefIDs); Hashtable emailHash = PatientsContactCacheDB.GetBullkEmail(entityIDs, -1); Hashtable mobileHash = PatientsContactCacheDB.GetBullkPhoneNumbers(entityIDs, -1, "30"); hasBothMobileEmail = 0; hasMobileNoEmail = 0; hasEmailNoMobile = 0; hasNeitherMobileEmail = 0; for (int i = 0; i < regRefs.Length; i++) { bool hasEmail = emailHash[regRefs[i].Organisation.EntityID] != null; bool hasMobile = mobileHash[regRefs[i].Organisation.EntityID] != null; if (hasEmail && hasMobile) hasBothMobileEmail++; if (!hasEmail && hasMobile) hasMobileNoEmail++; if (hasEmail && !hasMobile) hasEmailNoMobile++; if (!hasEmail && !hasMobile) hasNeitherMobileEmail++; } }