コード例 #1
0
        public void Initialise(GetViewsResponse response)
        {
            GetView view = response.Views[0];

            permissions.Initialise(view.AllowedOperations);

            viewFieldsCollection.Initialise(view);
            viewFiltersCollection.Initialise(view);
            viewPeriodsCollection.Initialise(view);
            fieldResolvers = BuildFieldResolvers();
        }
コード例 #2
0
        private void Initialise()
        {
            GetViewsRequest request = new GetViewsRequest
            {
                Credentials = CreateCredentials(),
                Module      = modelProperties.Module,
                Context     = NavigationContext.Plant,
                ViewPoint   = viewPoint.Location
            };

            GetViewsResponse response = webServiceClient.GetViews(request);

            viewProperties.Initialise(response);
        }
コード例 #3
0
 /// <summary>
 /// Gets the views.
 /// </summary>
 /// <param name="request">The request.</param>
 /// <returns></returns>
 public GetViewsResponse GetViews(GetViewsRequest request)
 {
     return(TryCatchThrowFault(() =>
     {
         CheckCredentials(request.Credentials);
         string module = request.Module.ToString();
         CheckLocation(module, request.ViewPoint);
         GetViewsResponse response = new GetViewsResponse
         {
             Views = new[]
             {
                 amplaConfiguration.GetViewForLocation(module, request.ViewPoint)
             }
         };
         return response;
     }));
 }
コード例 #4
0
ファイル: AmplaRepository.cs プロジェクト: braim/Ampla-Data
        /// <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);
        }
コード例 #5
0
        public void BindWithEmptyOriginalValue_double()
        {
            AmplaRecord amplaRecord = new AmplaRecord(100)
            {
                Location = location, Module = module, ModelName = ""
            };

            amplaRecord.AddColumn("Value", typeof(double));
            amplaRecord.AddColumn("Area", typeof(string));
            amplaRecord.SetValue("Value", "100.0");
            amplaRecord.SetValue("Area", "ROM");

            AmplaAuditRecord auditRecord = new AmplaAuditRecord
            {
                Id       = amplaRecord.Id,
                Location = amplaRecord.Location,
                Module   = amplaRecord.Module,
                Changes  = new List <AmplaAuditSession>
                {
                    new AmplaAuditSession("User", DateTime.Today)
                }
            };

            auditRecord.Changes[0].Fields.Add(new AmplaAuditField
            {
                Name          = "Value",
                OriginalValue = "",
                EditedValue   = "100"
            });

            AreaValueModel model = new AreaValueModel {
                Id = 100, Area = "ROM", Value = 100.0d
            };
            ModelVersions modelVersions = new ModelVersions(amplaRecord);
            IModelProperties <AreaValueModel> modelProperties = new ModelProperties <AreaValueModel>();

            AmplaViewProperties <AreaValueModel> viewProperties = new AmplaViewProperties <AreaValueModel>(modelProperties);
            GetViewsResponse view = new GetViewsResponse
            {
                Context = new GetViewsResponseContext(),
                Views   = new[] { ProductionViews.AreaValueModelView() }
            };

            viewProperties.Initialise(view);
            AmplaGetDataVersionsBinding <AreaValueModel> binding =
                new AmplaGetDataVersionsBinding <AreaValueModel>(amplaRecord, auditRecord, model, modelVersions,
                                                                 modelProperties, viewProperties);

            Assert.That(binding.Validate(), Is.True);
            Assert.That(binding.Bind(), Is.True);

            Assert.That(modelVersions.Versions, Is.Not.Empty);
            Assert.That(modelVersions.Versions.Count, Is.EqualTo(2));

            ModelVersion <AreaValueModel> last    = (ModelVersion <AreaValueModel>)modelVersions.Versions[0];
            ModelVersion <AreaValueModel> current = (ModelVersion <AreaValueModel>)modelVersions.Versions[1];

            Assert.That(last.IsCurrentVersion, Is.False);
            Assert.That(current.IsCurrentVersion, Is.True);

            Assert.That(last.Model.Area, Is.EqualTo(model.Area));
            Assert.That(current.Model.Area, Is.EqualTo(model.Area));

            Assert.That(last.Model.Value, Is.EqualTo(0d));
            Assert.That(current.Model.Value, Is.EqualTo(100d));

            Assert.That(last.Model.Id, Is.EqualTo(100));
            Assert.That(current.Model.Id, Is.EqualTo(100));
        }