示例#1
0
        public bool CreateAttribute(LazyPI.Common.Connection Connection, string FrameID, LazyObjects.AFAttribute attribute)
        {
            WebAPIConnection webConnection = (WebAPIConnection)Connection;
            var request = new RestRequest("/eventframes/{webId}/attributes", Method.POST);

            request.AddUrlSegment("webId", FrameID);
            ResponseModels.AFAttribute body = DataConversions.Convert(attribute);
            request.AddParameter("application/json; charset=utf-8", Newtonsoft.Json.JsonConvert.SerializeObject(body), ParameterType.RequestBody);

            var statusCode = webConnection.Client.Execute(request).StatusCode;

            return((int)statusCode == 201 ? true : false);
        }
示例#2
0
        public bool CreateUnitClass(LazyPI.Common.Connection Connection, string AFServerID, LazyObjects.AFUnit UnitClass)
        {
            WebAPIConnection webConnection = (WebAPIConnection)Connection;
            var request = new RestRequest("/assetservers/{webId}/unitclasses", Method.POST);

            request.AddUrlSegment("webId", AFServerID);
            ResponseModels.UnitClass body = DataConversions.Convert(UnitClass);
            request.AddParameter("application/json; charset=utf-8", Newtonsoft.Json.JsonConvert.SerializeObject(body), ParameterType.RequestBody);

            var statusCode = webConnection.Client.Execute(request).StatusCode;

            return((int)statusCode == 201);
        }
        public bool CreateElement(LazyPI.Common.Connection Connection, string DatabaseID, LazyPI.LazyObjects.AFElement Element)
        {
            WebAPIConnection webConnection = (WebAPIConnection)Connection;
            var request = new RestRequest("/assetdatabases/{webId}/elements", Method.POST);

            request.AddUrlSegment("webId", DatabaseID);
            ResponseModels.AFElement body = DataConversions.Convert(Element);
            request.AddParameter("application/json; charset=utf-8", Newtonsoft.Json.JsonConvert.SerializeObject(body), ParameterType.RequestBody);

            var statusCode = webConnection.Client.Execute(request).StatusCode;

            return((int)statusCode == 204);
        }
        /// <summary>
        /// Update an attribute by replacing items in its definition.
        /// </summary>
        /// <param name="Attr">A partial attribute that contains the WebID and any properties to be updated.</param>
        /// <returns>Returns true if update completed.</returns>
        public bool Update(LazyPI.Common.Connection Connection, LazyObjects.AFAttribute Attr)
        {
            WebAPIConnection webConnection = (WebAPIConnection)Connection;
            var request = new RestRequest("/attributes/{webId}", Method.PATCH);

            request.AddUrlSegment("webId", Attr.WebID);

            ResponseModels.AFAttribute body = DataConversions.Convert(Attr);
            request.AddParameter("application/json; charset=utf-8", Newtonsoft.Json.JsonConvert.SerializeObject(body), ParameterType.RequestBody);

            var statusCode = webConnection.Client.Execute(request).StatusCode;

            return((int)statusCode == 204);
        }