コード例 #1
0
        public void ServiceAttributes()
        {
            Startup.LoadSettings();
            var key = new ServiceAttributesKeyWeb();

            key.PopulateLists = true;
            key.ServiceID     = 215;
            key.Attributes    = new AttributeInstanceWeb[0];
            key.ChildServices = new ServiceNamedCollectionWeb[0];
            key.Date          = DateTime.Now;
            key.IsValid       = true;
            var url   = FscApplication.Current.Settings.FscUrls.FSCMediation + MediationEndPoints.serviceAttrs;
            var attrs = ApiClient.Post <AttributeInfoWeb[], ServiceAttributesKeyWeb>
                            (HttpTargetType.FSCMediation, "FSC Mediation Serv Attributes", url, key, ApiClient.ContentType.Json, ApiClient.HeaderType.FSCMediation);

            Assert.IsNotNull(attrs);
            Assert.IsTrue(attrs.Length > 0);
        }
コード例 #2
0
        public ObjectResult Attributes(ServiceAttributesKeyWeb postData)
        {
            return(WebFunction.Execute <ServiceAttributesKeyWeb, AttributeInfoWeb[]>(this, postData, (sa) =>
            {
                AttributeInfoWeb[] list;

                if (sa == null)
                {
                    list = new AttributeInfoWeb[1];
                    list[0] = new AttributeInfoWeb {
                        ErrorString = "Key cannot be null", IsValid = false
                    };

                    return new WebResult <AttributeInfoWeb[]>(list);
                }
                var sKey = new ServiceKey(sa);
                try
                {
                    var atts = ServiceAttributes.Get(sKey, sa.PopulateLists);
                    list = new AttributeInfoWeb[atts.Count];
                    var i = 0;
                    foreach (var att in atts)
                    {
                        list[i++] = new AttributeInfoWeb(att);
                    }
                }
                catch (Exception e)
                {
                    list = new AttributeInfoWeb[1];
                    list[0] = new AttributeInfoWeb {
                        ErrorString = e.Message, IsValid = false
                    };
                }

                return new WebResult <AttributeInfoWeb[]>(list);
            }));
        }