public static DataConsentTDS GetConsentChannelAndPurpose() { TDBTransaction T = new TDBTransaction(); TDataBase DB = DBAccess.Connect("Get Consent Channel + Purpose"); DataConsentTDS Set = new DataConsentTDS(); DB.ReadTransaction(ref T, delegate { PConsentChannelAccess.LoadAll(Set, T); PPurposeAccess.LoadAll(Set, T); }); return(Set); }
public static PartnerSetupTDS LoadConsentChannels() { TDBTransaction ReadTransaction = new TDBTransaction(); PartnerSetupTDS MainDS = new PartnerSetupTDS(); DBAccess.ReadTransaction(ref ReadTransaction, delegate { PConsentChannelAccess.LoadAll(MainDS, ReadTransaction); }); // Accept row changes here so that the Client gets 'unmodified' rows MainDS.AcceptChanges(); // Remove all Tables that were not filled with data before remoting them. MainDS.RemoveEmptyTables(); return(MainDS); }
public static DataConsentTDS LastKnownEntry( Int64 APartnerKey, string ADataType ) { TDBTransaction T = new TDBTransaction(); TDataBase DB = DBAccess.Connect("Get Last known entry"); DataConsentTDS Set = new DataConsentTDS(); List <OdbcParameter> SQLParameter = new List <OdbcParameter>(); DB.ReadTransaction(ref T, delegate { string sql = "SELECT " + "`p_data_history`.*, " + "GROUP_CONCAT(`p_data_history_permission`.`p_purpose_code_c` SEPARATOR ',') AS `AllowedPurposes` " + "FROM `p_data_history` " + "LEFT JOIN `p_data_history_permission` " + "ON `p_data_history`.`p_entry_id_i` = `p_data_history_permission`.`p_data_history_entry_i` " + "WHERE `p_data_history`.`p_partner_key_n` = ? " + "AND `p_data_history`.`p_type_c` = ? " + "GROUP BY `p_data_history`.`p_entry_id_i` " + "ORDER BY `p_data_history`.`p_entry_id_i` DESC " + "LIMIT 1"; SQLParameter.Add(new OdbcParameter("PartnerKey", OdbcType.VarChar) { Value = APartnerKey.ToString() }); SQLParameter.Add(new OdbcParameter("DataType", OdbcType.VarChar) { Value = ADataType }); // DB.SelectDT(Set, sql, T, SQLParameter.ToArray(), 0,0); DB.SelectDT(Set.PDataHistory, sql, T, SQLParameter.ToArray()); PConsentChannelAccess.LoadAll(Set, T); PPurposeAccess.LoadAll(Set, T); }); return(Set); }
public static DataConsentTDS GetHistory( Int64 APartnerKey, string ADataType ) { TDBTransaction T = new TDBTransaction(); TDataBase DB = DBAccess.Connect("Get data history for partner"); DataConsentTDS Set = new DataConsentTDS(); List <OdbcParameter> SQLParameter = new List <OdbcParameter>(); DB.ReadTransaction(ref T, delegate { // prepare for one huge cunk sql string sql = "" + "SELECT " + " `pdh`.*, " + " GROUP_CONCAT(`pdhp`.`p_purpose_code_c` SEPARATOR ',') AS `AllowedPurposes` " + "FROM `p_data_history` AS `pdh` " + "LEFT JOIN `p_data_history_permission` AS `pdhp` " + " ON `pdh`.`p_entry_id_i` = `pdhp`.`p_data_history_entry_i` " + "WHERE `pdh`.`p_partner_key_n` = ? " + " AND `pdh`.`p_type_c` = ? " + "GROUP BY `pdh`.`p_entry_id_i` " + "ORDER BY `pdh`.`p_entry_id_i` DESC"; SQLParameter.Add(new OdbcParameter("PartnerKey", OdbcType.BigInt) { Value = APartnerKey.ToString() }); SQLParameter.Add(new OdbcParameter("DataType", OdbcType.VarChar) { Value = ADataType }); Set.PDataHistory.Constraints.Clear(); //mmmm... DB.SelectDT(Set.PDataHistory, sql, T, SQLParameter.ToArray()); PConsentChannelAccess.LoadAll(Set, T); PPurposeAccess.LoadAll(Set, T); }); return(Set); }
public static DataConsentTDS LastKnownEntry( Int64 APartnerKey, string ADataType ) { TDBTransaction T = new TDBTransaction(); TDataBase DB = DBAccess.Connect("Get Last known entry"); DataConsentTDS Set = new DataConsentTDS(); List <OdbcParameter> SQLParameter = new List <OdbcParameter>(); DB.ReadTransaction(ref T, delegate { string sql = "SELECT " + "`p_consent_history`.*, " + "GROUP_CONCAT(`p_consent_history_permission`.`p_purpose_code_c` SEPARATOR ',') AS `AllowedPurposes` " + "FROM `p_consent_history` " + "LEFT JOIN `p_consent_history_permission` " + "ON `p_consent_history`.`p_entry_id_i` = `p_consent_history_permission`.`p_consent_history_entry_i` " + "WHERE `p_consent_history`.`p_partner_key_n` = ? " + "AND `p_consent_history`.`p_type_c` = ? " + "GROUP BY `p_consent_history`.`p_entry_id_i` " + "ORDER BY `p_consent_history`.`p_entry_id_i` DESC " + "LIMIT 1"; SQLParameter.Add(new OdbcParameter("PartnerKey", OdbcType.BigInt) { Value = APartnerKey }); SQLParameter.Add(new OdbcParameter("DataType", OdbcType.VarChar) { Value = ADataType }); DB.SelectDT(Set.PConsentHistory, sql, T, SQLParameter.ToArray()); if (Set.PConsentHistory.Count == 0) { // there is no consent yet // do we have a value at all? List <string> Subscriptions; List <string> PartnerTypes; string DefaultEmailAddress; string DefaultPhoneMobile; string DefaultPhoneLandline; PartnerEditTDS PartnerDS = TSimplePartnerEditWebConnector.GetPartnerDetails(APartnerKey, out Subscriptions, out PartnerTypes, out DefaultEmailAddress, out DefaultPhoneMobile, out DefaultPhoneLandline); if (ADataType == MPartnerConstants.CONSENT_TYPE_ADDRESS) { // what about new contact? PLocationRow locationRow = null; if (PartnerDS.PLocation.Rows.Count > 0) { locationRow = PartnerDS.PLocation[0]; } else { locationRow = PartnerDS.PLocation.NewRowTyped(); } PConsentHistoryRow row = Set.PConsentHistory.NewRowTyped(); row.EntryId = -1; row.PartnerKey = APartnerKey; row.Type = ADataType; row.Value = locationRow.StreetName + ", " + locationRow.PostalCode + " " + locationRow.City + ", " + locationRow.CountryCode; row.ConsentDate = DateTime.Today; Set.PConsentHistory.Rows.Add(row); } if (ADataType == MPartnerConstants.CONSENT_TYPE_EMAIL) { PConsentHistoryRow row = Set.PConsentHistory.NewRowTyped(); row.EntryId = -1; row.PartnerKey = APartnerKey; row.Type = ADataType; row.Value = DefaultEmailAddress; row.ConsentDate = DateTime.Today; Set.PConsentHistory.Rows.Add(row); } if (ADataType == MPartnerConstants.CONSENT_TYPE_LANDLINE) { PConsentHistoryRow row = Set.PConsentHistory.NewRowTyped(); row.EntryId = -1; row.PartnerKey = APartnerKey; row.Type = ADataType; row.Value = DefaultPhoneLandline; row.ConsentDate = DateTime.Today; Set.PConsentHistory.Rows.Add(row); } if (ADataType == MPartnerConstants.CONSENT_TYPE_MOBILE) { PConsentHistoryRow row = Set.PConsentHistory.NewRowTyped(); row.EntryId = -1; row.PartnerKey = APartnerKey; row.Type = ADataType; row.Value = DefaultPhoneMobile; row.ConsentDate = DateTime.Today; Set.PConsentHistory.Rows.Add(row); } } PConsentChannelAccess.LoadAll(Set, T); PConsentPurposeAccess.LoadAll(Set, T); }); return(Set); }