Exemplo n.º 1
0
        /// <summary>
        /// Gets the view properties.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <returns></returns>
        protected IAmplaViewProperties <TModel> GetViewProperties(TModel model)
        {
            IAmplaViewProperties <TModel> amplaView;

            string location;
            bool   checkForValidLocation;

            if (model == null)
            {
                location = ModelProperties.LocationFilter.Location;
                checkForValidLocation = false;
            }
            else
            {
                location = ModelProperties.GetLocation(model) ?? "";
                checkForValidLocation = true;
            }

            if (!amplaViewDictionary.TryGetValue(location, out amplaView))
            {
                if (checkForValidLocation)
                {
                    CheckLocationIsValid(location);
                }

                AmplaViewProperties <TModel> viewProperties = new AmplaViewProperties <TModel>(ModelProperties);
                GetViewsRequest request = new GetViewsRequest
                {
                    Credentials  = CreateCredentials(),
                    Mode         = NavigationMode.Location,
                    Context      = NavigationContext.Plant,
                    ViewPoint    = location,
                    Module       = ModelProperties.Module,
                    Localization = new Localization()
                };

                GetViewsResponse response = WebServiceClient.GetViews(request);
                viewProperties.Initialise(response);
                amplaViewDictionary[location] = viewProperties;
                amplaView = viewProperties;
            }
            return(amplaView);
        }