Example #1
0
        /// <summary>
        /// Retrieves PartnerLocation information and the rest of the PartnerInfo data, but not the
        /// 'Head' data.
        /// </summary>
        /// <param name="APartnerKey">PartnerKey of Partner to find the short name for</param>
        /// <param name="ALocationKey" >Location Key of the Location that the information should be
        /// retrieved for.</param>
        /// <param name="APartnerInfoDS">Typed DataSet that contains the requested data.</param>
        /// <param name="AIncludeRest">Include 'Rest' data as well</param>
        /// <param name="AReadTransaction" >Open DB Transaction.</param>
        private static bool PartnerLocationInternal(Int64 APartnerKey, TLocationPK ALocationKey,
                                                    ref PartnerInfoTDS APartnerInfoDS,
                                                    bool AIncludeRest, TDBTransaction AReadTransaction)
        {
            bool        ReturnValue = false;
            PPartnerRow PartnerDR;

            try
            {
                /*
                 * Check for existance of Partner
                 */
                PartnerDR = MCommonMain.CheckPartnerExists2(APartnerKey, true, AReadTransaction.DataBaseObj);

                if (PartnerDR != null)
                {
                    /*
                     * Perform security checks; these throw ESecurityPartnerAccessDeniedException
                     * in case access isn't granted.
                     */
                    TSecurity.CanAccessPartnerExc(PartnerDR, AReadTransaction.DataBaseObj);

                    /*
                     * Partner exists --> we can go ahead with data gathering
                     */
                    PartnerLocationInternal(APartnerKey, ALocationKey, AReadTransaction, ref APartnerInfoDS);

                    if (AIncludeRest)
                    {
                        RestInternal(PartnerDR, ref APartnerInfoDS, AReadTransaction);
                    }

                    ReturnValue = true;
                }
            }
            catch (ESecurityPartnerAccessDeniedException)
            {
                // don't log this exception - this is thrown on purpose here and the Client knows how to deal with it.
                throw;
            }
            catch (EDBAccessLackingCoordinationException)
            {
                // don't log this Exception - the Client knows how to deal with it.
                throw;
            }
            catch (Exception Exp)
            {
                TLogging.Log("TServerLookups_PartnerInfo.PartnerLocationInternal exception: " + Exp.ToString(), TLoggingType.ToLogfile);
                TLogging.Log(Exp.StackTrace, TLoggingType.ToLogfile);

                throw;
            }

            return(ReturnValue);
        }
Example #2
0
        /// <summary>
        /// Retrieves Location and PartnerLocation information and the rest of the PartnerInfo data,
        /// but not the 'Head' data.
        /// </summary>
        /// <param name="APartnerKey">PartnerKey of Partner to find the short name for</param>
        /// <param name="ALocationKey">Location Key of the Location that the information should be
        /// retrieved for.</param>
        /// <param name="APartnerInfoDS">Typed DataSet that contains the requested data.</param>
        /// <param name="AIncludeRest">Include 'Rest' data as well</param>
        /// <param name="AReadTransaction" >Open DB Transaction.</param>
        private static bool LocationPartnerLocationInternal(Int64 APartnerKey, TLocationPK ALocationKey,
                                                            ref PartnerInfoTDS APartnerInfoDS,
                                                            bool AIncludeRest, TDBTransaction AReadTransaction)
        {
            bool                  ReturnValue = false;
            PPartnerRow           PartnerDR;
            PLocationTable        LocationDT;
            PPartnerLocationTable PartnerLocationDT;

            try
            {
                /*
                 * Check for existance of Partner
                 */
                PartnerDR = MCommonMain.CheckPartnerExists2(APartnerKey, true, AReadTransaction.DataBaseObj);

                if (PartnerDR != null)
                {
                    /*
                     * Perform security checks; these throw ESecurityPartnerAccessDeniedException
                     * in case access isn't granted.
                     */
                    TSecurity.CanAccessPartnerExc(PartnerDR, AReadTransaction.DataBaseObj);

                    /*
                     * Load Partner Location data and rest of data first
                     */
                    PartnerLocationInternal(APartnerKey, ALocationKey, AReadTransaction, ref APartnerInfoDS);

                    /*
                     * Load Location Information; this gets merged into the already retrieved
                     * information in APartnerInfoDS (eg. Partner Location data and rest of data)
                     */
                    APartnerInfoDS.Merge(TPPartnerAddressAggregate.LoadByPrimaryKey(
                                             ALocationKey.SiteKey, ALocationKey.LocationKey, AReadTransaction));

                    // Apply Address Security
                    LocationDT        = APartnerInfoDS.PLocation;
                    PartnerLocationDT = APartnerInfoDS.PPartnerLocation;

                    TPPartnerAddressAggregate.ApplySecurity(ref PartnerLocationDT,
                                                            ref LocationDT);

                    if (AIncludeRest)
                    {
                        RestInternal(PartnerDR, ref APartnerInfoDS, AReadTransaction);
                    }

                    ReturnValue = true;
                }
            }
            catch (ESecurityPartnerAccessDeniedException)
            {
                // don't log this Exception - this is thrown on purpose here and the Client knows how to deal with it.
                throw;
            }
            catch (EDBAccessLackingCoordinationException)
            {
                // don't log this Exception - the Client knows how to deal with it.
                throw;
            }
            catch (Exception Exp)
            {
                TLogging.Log("TServerLookups_PartnerInfo.PartnerLocationInternal exception: " + Exp.ToString(), TLoggingType.ToLogfile);
                TLogging.Log(Exp.StackTrace, TLoggingType.ToLogfile);

                throw;
            }

            return(ReturnValue);
        }
Example #3
0
        /// <summary>
        /// Retrieves PartnerLocation information and the rest of the PartnerInfo data, but not the
        /// 'Head' data.
        /// </summary>
        /// <param name="APartnerKey">PartnerKey of Partner to find the short name for</param>
        /// <param name="ALocationKey" >Location Key of the Location that the information should be
        /// retrieved for.</param>
        /// <param name="APartnerInfoDS">Typed DataSet that contains the requested data.</param>
        /// <param name="AIncludeRest">Include 'Rest' data as well</param>
        private static bool PartnerLocationInternal(Int64 APartnerKey, TLocationPK ALocationKey,
                                                    ref PartnerInfoTDS APartnerInfoDS,
                                                    bool AIncludeRest)
        {
            bool           ReturnValue = false;
            TDBTransaction ReadTransaction;
            Boolean        NewTransaction = false;
            PPartnerRow    PartnerDR;

            ReadTransaction = DBAccess.GDBAccessObj.GetNewOrExistingTransaction(IsolationLevel.RepeatableRead,
                                                                                TEnforceIsolationLevel.eilMinimum,
                                                                                out NewTransaction);

            try
            {
                /*
                 * Check for existance of Partner
                 */
                PartnerDR = MCommonMain.CheckPartnerExists2(APartnerKey, true);

                if (PartnerDR != null)
                {
                    /*
                     * Perform security checks; these throw ESecurityPartnerAccessDeniedException
                     * in case access isn't granted.
                     */
                    TSecurity.CanAccessPartnerExc(PartnerDR);

                    /*
                     * Partner exists --> we can go ahead with data gathering
                     */
                    PartnerLocationInternal(APartnerKey, ALocationKey, ReadTransaction, ref APartnerInfoDS);

                    if (AIncludeRest)
                    {
                        RestInternal(PartnerDR, ReadTransaction, ref APartnerInfoDS);
                    }

                    ReturnValue = true;
                }
            }
            catch (ESecurityPartnerAccessDeniedException)
            {
                // don't log this exception - this is thrown on purpose here and the Client needs to deal with it.
                throw;
            }
            catch (Exception Exp)
            {
                TLogging.Log("TServerLookups_PartnerInfo.PartnerLocationInternal exception: " + Exp.ToString(), TLoggingType.ToLogfile);
                TLogging.Log(Exp.StackTrace, TLoggingType.ToLogfile);
                throw;
            }
            finally
            {
                if (NewTransaction)
                {
                    DBAccess.GDBAccessObj.CommitTransaction();
                    TLogging.LogAtLevel(7, "TServerLookups_PartnerInfo.LocationPartnerLocationAndRestOnly: committed own transaction.");
                }
            }

            return(ReturnValue);
        }
Example #4
0
        /// <summary>
        /// Retrieves all of the PartnerInfo data.
        /// </summary>
        /// <param name="APartnerKey">PartnerKey of Partner to find the PartnerInfo data for</param>
        /// <param name="APartnerInfoDS">Typed DataSet that contains the requested data.</param>
        /// <param name="AReadTransaction" >Open DB Transaction.</param>
        /// <returns>True if Partner exists, otherwise false.</returns>
        public static bool AllPartnerInfoData(Int64 APartnerKey, ref PartnerInfoTDS APartnerInfoDS,
                                              TDBTransaction AReadTransaction)
        {
            bool        ReturnValue = false;
            PPartnerRow PartnerDR;

            TLocationPK           BestLocationPK;
            PLocationRow          LocationDR;
            PLocationRow          LocationDR2;
            PPartnerLocationRow   PartnerLocationDR;
            PPartnerLocationRow   PartnerLocationDR2;
            PLocationTable        LocationDT;
            PPartnerLocationTable PartnerLocationDT;

            try
            {
                /*
                 * Check for existance of Partner
                 */
                PartnerDR = MCommonMain.CheckPartnerExists2(APartnerKey, true, AReadTransaction.DataBaseObj);

                if (PartnerDR != null)
                {
                    /*
                     * Perform security checks; these throw ESecurityPartnerAccessDeniedException
                     * in case access isn't granted.
                     */
                    TSecurity.CanAccessPartnerExc(PartnerDR, AReadTransaction.DataBaseObj);

                    /*
                     * Get the Partner's Address data of its 'Best' Address
                     */
                    if (TMailing.GetPartnersBestLocationData(APartnerKey, out BestLocationPK,
                                                             out LocationDR, out PartnerLocationDR, AReadTransaction.DataBaseObj))
                    {
                        #region Process Address

                        /*
                         * Check for existance of PLocation and PPartnerLocation Tables in the passed in
                         * DataSet APartnerInfoDS.
                         */
                        if (!APartnerInfoDS.Tables.Contains(PLocationTable.GetTableName()))
                        {
                            // Need to create Table here
                            APartnerInfoDS.Tables.Add(new PLocationTable());
                        }

                        if (!APartnerInfoDS.Tables.Contains(PPartnerLocationTable.GetTableName()))
                        {
                            // Need to create Table here
                            APartnerInfoDS.Tables.Add(new PPartnerLocationTable());
                        }

                        // Add copies of the Location and PartnerLocation DataRows of the 'Best Address'

                        /*
                         * Remove DataColumns that might have been added by the call to
                         * TMailing.GetPartnersBestLocationData - otherwise PartnerLocationDR2.ItemArray
                         * assignment will fail.
                         */
                        if (PartnerLocationDR.Table.Columns.Contains(Calculations.PARTNERLOCATION_BESTADDR_COLUMN))
                        {
                            PartnerLocationDR.Table.Columns.Remove(Calculations.PARTNERLOCATION_BESTADDR_COLUMN);
                        }

                        if (PartnerLocationDR.Table.Columns.Contains(Calculations.PARTNERLOCATION_ICON_COLUMN))
                        {
                            PartnerLocationDR.Table.Columns.Remove(Calculations.PARTNERLOCATION_ICON_COLUMN);
                        }

                        LocationDR2                  = APartnerInfoDS.PLocation.NewRowTyped(false);
                        LocationDR2.ItemArray        = LocationDR.ItemArray;
                        PartnerLocationDR2           = APartnerInfoDS.PPartnerLocation.NewRowTyped(false);
                        PartnerLocationDR2.ItemArray = PartnerLocationDR.ItemArray;

                        APartnerInfoDS.PLocation.Rows.Add(LocationDR2);
                        APartnerInfoDS.PPartnerLocation.Rows.Add(PartnerLocationDR2);

                        #endregion

                        // Apply Address Security
                        LocationDT        = APartnerInfoDS.PLocation;
                        PartnerLocationDT = APartnerInfoDS.PPartnerLocation;

                        TPPartnerAddressAggregate.ApplySecurity(ref PartnerLocationDT,
                                                                ref LocationDT);

                        // Process 'Head' data and rest of data for the Partner
                        HeadInternal(PartnerDR, ref APartnerInfoDS);
                        RestInternal(PartnerDR, ref APartnerInfoDS, AReadTransaction);

                        ReturnValue = true;
                    }
                }
            }
            catch (ESecurityPartnerAccessDeniedException)
            {
                // don't log this exception - this is thrown on purpose here and the Client needs to deal with it.
                throw;
            }
            catch (Exception Exp)
            {
                TLogging.Log("TServerLookups_PartnerInfo.AllPartnerInfoData exception: " + Exp.ToString(), TLoggingType.ToLogfile);
                TLogging.Log(Exp.StackTrace, TLoggingType.ToLogfile);

                throw;
            }

            return(ReturnValue);
        }
Example #5
0
        /// <summary>
        /// Retrieves Location and PartnerLocation information and the rest of the PartnerInfo data,
        /// but not the 'Head' data.
        /// </summary>
        /// <param name="APartnerKey">PartnerKey of Partner to find the short name for</param>
        /// <param name="ALocationKey">Location Key of the Location that the information should be
        /// retrieved for.</param>
        /// <param name="APartnerInfoDS">Typed DataSet that contains the requested data.</param>
        /// <param name="AIncludeRest">Include 'Rest' data as well</param>
        private static bool LocationPartnerLocationInternal(Int64 APartnerKey, TLocationPK ALocationKey,
                                                            ref PartnerInfoTDS APartnerInfoDS,
                                                            bool AIncludeRest)
        {
            bool                  ReturnValue = false;
            TDBTransaction        ReadTransaction;
            Boolean               NewTransaction = false;
            PPartnerRow           PartnerDR;
            PLocationTable        LocationDT;
            PPartnerLocationTable PartnerLocationDT;


            ReadTransaction = DBAccess.GDBAccessObj.GetNewOrExistingTransaction(IsolationLevel.RepeatableRead,
                                                                                TEnforceIsolationLevel.eilMinimum,
                                                                                out NewTransaction);

            try
            {
                /*
                 * Check for existance of Partner
                 */
                PartnerDR = MCommonMain.CheckPartnerExists2(APartnerKey, true);

                if (PartnerDR != null)
                {
                    /*
                     * Perform security checks; these throw ESecurityPartnerAccessDeniedException
                     * in case access isn't granted.
                     */
                    TSecurity.CanAccessPartnerExc(PartnerDR);

                    /*
                     * Load Partner Location data and rest of data first
                     */
                    PartnerLocationInternal(APartnerKey, ALocationKey, ReadTransaction, ref APartnerInfoDS);

                    /*
                     * Load Location Information; this gets merged into the already retrieved
                     * information in APartnerInfoDS (eg. Partner Location data and rest of data)
                     */
                    APartnerInfoDS.Merge(TPPartnerAddressAggregate.LoadByPrimaryKey(
                                             ALocationKey.SiteKey, ALocationKey.LocationKey, ReadTransaction));

                    // Apply Address Security
                    LocationDT        = APartnerInfoDS.PLocation;
                    PartnerLocationDT = APartnerInfoDS.PPartnerLocation;
                    TPPartnerAddressAggregate.ApplySecurity(ref PartnerLocationDT,
                                                            ref LocationDT);

                    if (AIncludeRest)
                    {
                        RestInternal(PartnerDR, ReadTransaction, ref APartnerInfoDS);
                    }

                    ReturnValue = true;
                }
            }
            catch (ESecurityPartnerAccessDeniedException)
            {
                // don't log this exception  this is thrown on purpose here and the Client needs to deal with it.
                throw;
            }
            catch (Exception Exp)
            {
                TLogging.Log("TServerLookups_PartnerInfo.PartnerLocationInternal exception: " + Exp.ToString(), TLoggingType.ToLogfile);
                TLogging.Log(Exp.StackTrace, TLoggingType.ToLogfile);
                throw;
            }
            finally
            {
                if (NewTransaction)
                {
                    DBAccess.GDBAccessObj.CommitTransaction();
                    TLogging.LogAtLevel(7, "TServerLookups_PartnerInfo.LocationPartnerLocationAndRestOnly: committed own transaction.");
                }
            }

            return(ReturnValue);
        }