Esempio n. 1
0
        /// <summary>
        /// Update Signal Property. Along with the required variables you must also supply the SignalPropertyID.
        /// </summary>
        /// <param name="objSignalProperty"></param>
        /// <returns></returns>
        public HttpResponseMessage Post([FromUri] SignalPropertyModels objSignalProperty)
        {
            string query = "UPDATE cfgTblSignalProperties SET " +
                           "SignalID = '" + objSignalProperty.SignalID + "'" +
                           ",Name = '" + objSignalProperty.PropertyName + "'" +
                           ",DisplayName = '" + objSignalProperty.DisplayName + "'" +
                           ",Value = '" + objSignalProperty.PropertyValue + "' " +
                           "WHERE ID = '" + objSignalProperty.SignalPropertyID + "'";

            sqlObject.QuerySQL(query, ref sqlStatus);
            HttpResponseMessage response;

            if (sqlStatus == "Success")
            {
                response = Request.CreateResponse(HttpStatusCode.OK, sqlStatus);
            }
            else
            {
                response = Request.CreateResponse(HttpStatusCode.BadRequest, sqlStatus);
            }
            response.Content = new StringContent(sqlStatus, Encoding.Unicode);
            response.Headers.CacheControl = new CacheControlHeaderValue()
            {
                MaxAge = TimeSpan.FromMinutes(20)
            };
            return(response);
        }
Esempio n. 2
0
        /// <summary>
        /// Returns a Signal Property set if signalID is set or a specific property if signalPropertyID is set.
        /// An empty Signal Property will be returned if neither are set.
        /// </summary>
        /// <returns></returns>
        public SignalPropertiesModels Get(string signalID = null, string signalPropertyID = null)
        {
            SignalPropertiesModels returnObjs = new SignalPropertiesModels();
            string query = string.Empty;

            if (!string.IsNullOrWhiteSpace(signalPropertyID))
            {
                query = "EXEC rGetSignalProperty @SignalPropertyID = '" + signalPropertyID + "'";
            }
            else if (!string.IsNullOrWhiteSpace(signalID))
            {
                query = "EXEC rGetSignalProperties @SignalID = '" + signalID + "'";
            }
            else
            {
                return(returnObjs);
            }
            using (DataTable tblData = sqlObject.QuerySQL(query, ref sqlStatus))
            {
                if (tblData != null)
                {
                    foreach (DataRow item in tblData.Rows)
                    {
                        SignalPropertyModels newObj = new SignalPropertyModels();
                        newObj.DisplayName      = item["DisplayName"].ToString();
                        newObj.PropertyName     = item["PropertyName"].ToString();
                        newObj.PropertyValue    = item["PropertyValue"].ToString();
                        newObj.SignalPropertyID = item["SignalPropertyID"].ToString();
                    }
                }
            }
            return(returnObjs);
        }
Esempio n. 3
0
        /// <summary>
        /// Add new Signal Property
        /// </summary>
        /// <param name="objSignalProperty"></param>
        /// <returns></returns>
        public HttpResponseMessage Put([FromUri] SignalPropertyModels objSignalProperty)
        {
            string value = "NULL";

            if (!string.IsNullOrWhiteSpace(objSignalProperty.PropertyValue))
            {
                value = "'" + objSignalProperty.PropertyValue + "'";
            }
            string query = "INSERT INTO cfgTblSignalProperties (" +
                           "SignalID" +
                           ",Name" +
                           ",DisplayName" +
                           ",Value" +
                           ") VALUES (" +
                           "'" + objSignalProperty.SignalID + "'" +
                           "," + objSignalProperty.PropertyName + "''" +
                           ",'" + objSignalProperty.DisplayName + "'" +
                           "," + value +
                           ")";

            sqlObject.QuerySQL(query, ref sqlStatus);
            HttpResponseMessage response;

            if (sqlStatus == "Success")
            {
                response = Request.CreateResponse(HttpStatusCode.OK, sqlStatus);
            }
            else
            {
                response = Request.CreateResponse(HttpStatusCode.BadRequest, sqlStatus);
            }
            response.Content = new StringContent(sqlStatus, Encoding.Unicode);
            response.Headers.CacheControl = new CacheControlHeaderValue()
            {
                MaxAge = TimeSpan.FromMinutes(20)
            };
            return(response);
        }