예제 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="UPCRMRecordTile"/> class.
        /// </summary>
        /// <param name="tiles">The tiles.</param>
        /// <param name="viewReference">The view reference.</param>
        /// <param name="parameters">The parameters.</param>
        /// <param name="menuAction">The menu action.</param>
        /// <exception cref="Exception">
        /// RecordIdentification is null
        /// or
        /// TableCaptionName is null
        /// </exception>
        public UPCRMRecordTile(UPCRMTiles tiles, ViewReference viewReference, Dictionary <string, object> parameters, Menu menuAction)
            : base(tiles, viewReference, parameters, menuAction)
        {
            this.tableCaptionName     = this.ViewReference.ContextValueForKey("tableCaption");
            this.recordIdentification = this.ViewReference.ContextValueForKey("uid");
            string imageMapFilterName           = this.ViewReference.ContextValueForKey("imageMapFilter");
            IConfigurationUnitStore configStore = ConfigurationUnitStore.DefaultStore;

            if (string.IsNullOrEmpty(this.recordIdentification))
            {
                throw new Exception("RecordIdentification is null");
            }

            if (!string.IsNullOrEmpty(this.tableCaptionName))
            {
                this.tableCaption = configStore.TableCaptionByName(this.tableCaptionName);
            }

            if (this.tableCaption == null)
            {
                if (string.IsNullOrEmpty(this.tableCaptionName))
                {
                    throw new Exception("TableCaptionName is null");
                }
            }

            if (!string.IsNullOrEmpty(imageMapFilterName))
            {
                this.imageFilter = configStore.FilterByName(imageMapFilterName);
                this.imageFilter = this.imageFilter?.FilterByApplyingValueDictionaryDefaults(this.Parameters, true);

                if (this.imageFilter != null)
                {
                    this.catalogAttributes = configStore.CatalogAttributesByFilter(this.imageFilter);
                    if (this.catalogAttributes != null)
                    {
                        this.crmQuery?.AddCrmFields(new List <UPCRMField> {
                            this.catalogAttributes.CrmField
                        });
                    }
                }
            }
        }