Esempio n. 1
0
        /// <summary>
        /// Retrieve a list of tuple (DSRecord, Table) attached to a given record (table, id) for the given profile
        /// This function is used to retrieve a list of records attached to the current update
        /// Example :
        ///    The object A is not visible for the user Y
        ///    The user X updates the object A
        ///    The object A becomes visible for the user Y
        ///    In that case, object A must be added and notified to the user Y
        ///    This function builds this case
        /// </summary>
        /// <param name="cache"></param>
        /// <param name="table"></param>
        /// <param name="id"></param>
        /// <param name="customerId"></param>
        /// <param name="userId"></param>
        /// <param name="profile"></param>
        /// <param name="area"></param>
        /// <param name="deepUpdate"></param>
        /// <param name="recordAlreadyRead"></param>
        /// <param name="informationAlreadyRead"></param>
        /// <returns></returns>
        virtual public void GetListRecordsConcernedByUpdate(DSCache cache,
                                                            string table,
                                                            int id,
                                                            int customerId,
                                                            int userId,
                                                            UserProfile.EUserProfile profile,
                                                            string area,
                                                            bool deepUpdate,
                                                            DSRecord recordAlreadyRead,
                                                            InformationRecord informationAlreadyRead)
        {
            if (id < 0 || profile != UserProfile.EUserProfile.None || cache.Is(table, id) != null)
            {
                return;
            }

            cache.Set(table, id, null);
        }
Esempio n. 2
0
        /// <summary>
        /// Retrieve a list of tuple (DSRecord, Table) attached to a given record (table, id) for the given profile
        /// </summary>
        /// <param name="cache"></param>
        /// <param name="table"></param>
        /// <param name="id"></param>
        /// <param name="customerId"></param>
        /// <param name="userId"></param>
        /// <param name="profile"></param>
        /// <param name="area"></param>
        /// <param name="deepUpdate"></param>
        /// <param name="recordAlreadyRead"></param>
        /// <param name="informationAlreadyRead"></param>
        /// <returns></returns>
        public override void GetListRecordsConcernedByUpdate(DSCache cache,
                                                             string table,
                                                             int id,
                                                             int customerId,
                                                             int userId,
                                                             UserProfile.EUserProfile profile,
                                                             string area,
                                                             bool deepUpdate,
                                                             DSRecord recordAlreadyRead,
                                                             InformationRecord informationAlreadyRead)
        {
            if (id < 0 || profile == UserProfile.EUserProfile.None || cache.Is(table, id) != null)
            {
                return;
            }

            // Retrieve the current record

            DSRecord currentRecord = null;
            Tuple <DSRecord, InformationRecord> currentRecordFromCache = cache.GetRecord(this, table, id);

            if (currentRecordFromCache == null && recordAlreadyRead == null)
            {
                switch (table)
                {
                case "Customer":
                    currentRecord = Customer.Find(id);
                    break;

                case "Language":
                    currentRecord = Language.Find(id);
                    break;

                case "User":
                    currentRecord = User.Find(id);
                    break;

                case "Module":
                    currentRecord = Module.Find(id);
                    break;

                case "UserModule":
                    currentRecord = UserModule.Find(id);
                    break;

                default:
                    base.GetListRecordsConcernedByUpdate(cache, table, id, customerId, userId, profile, area, deepUpdate, recordAlreadyRead, informationAlreadyRead);
                    return;
                }

                if (currentRecord == null)
                {
                    cache.Set(table, id, null);
                    return;
                }

                currentRecordFromCache = cache.SetRecord(this, table, id, currentRecord, null);
            }
            else if (currentRecordFromCache == null && recordAlreadyRead != null)
            {
                currentRecordFromCache = cache.SetRecord(this, table, id, recordAlreadyRead, informationAlreadyRead);
            }

            if (currentRecordFromCache != null)
            {
                currentRecord = currentRecordFromCache.Item1;
            }

            // Check if the record is concerned by the current update

            if (currentRecord is DSRecordWithCustomerId currentCustomerRecord)
            {
                if (currentCustomerRecord.CustomerId != customerId)
                {
                    cache.Set(table, id, null);
                    return;
                }
            }

            if (currentRecord is CustomerRecord customer)
            {
                cache.Set(table, id, customer.Id != customerId ? null : currentRecord);
                return;
            }

            if (currentRecord as LanguageRecord != null ||
                currentRecord as ModuleRecord != null ||
                currentRecord as UserModuleRecord != null ||
                currentRecord as UserRecord != null)
            {
                cache.Set(table, id, currentRecord);
                return;
            }

            base.GetListRecordsConcernedByUpdate(cache, table, id, customerId, userId, profile, area, deepUpdate, recordAlreadyRead, informationAlreadyRead);
        }