コード例 #1
0
        /// <summary>
        /// Update the specified Schedule
        /// </summary>
        /// <param name="id">Id of the scedule to update</param>
        /// <param name="schedule">new schedule settings</param>
        /// <returns>true or false of the update was applied</returns>
        public bool UpdateSchedule(string id, Schedule schedule)
        {
            bool result = false;

            CommResult comres = Communication.SendRequest(new Uri(BridgeUrl + "/schedules/" + id), WebRequestType.PUT, Serializer.SerializeToJson <Schedule>(schedule));

            switch (comres.status)
            {
            case WebExceptionStatus.Success:
                List <Message> lstmsg = Serializer.DeserializeToObject <List <Message> >(comres.data);
                if (lstmsg == null)
                {
                    goto default;
                }
                else
                {
                    lastMessages = new MessageCollection(lstmsg);
                    if (lastMessages.SuccessCount == 1)
                    {
                        result = true;
                    }
                }
                break;

            case WebExceptionStatus.Timeout:
                lastMessages = new MessageCollection {
                    _bridgeNotResponding
                };
                BridgeNotResponding?.Invoke(this, _e);
                break;

            default:
                lastMessages = new MessageCollection {
                    new UnkownError(comres)
                };
                break;
            }

            return(result);
        }
コード例 #2
0
        /// <summary>
        /// Change the name of Schedule.
        /// </summary>
        /// <param name="id">ID of the schedule to rename.</param>
        /// <param name="newName">New name of the schedule.</param>
        /// <returns>A collection of messages.</returns>
        public MessageCollection ChangeScheduleName(string id, string newName)
        {
            CommResult comres = Communication.SendRequest(new Uri(BridgeUrl + "/schedules/" + id.ToString()), WebRequestType.PUT, Serializer.SerializeToJson <Schedule>(new Schedule()
            {
                name = newName
            }));

            switch (comres.status)
            {
            case WebExceptionStatus.Success:
                List <Message> lstmsg = Serializer.DeserializeToObject <List <Message> >(comres.data);
                if (lstmsg == null)
                {
                    goto default;
                }
                else
                {
                    lastMessages = new MessageCollection(lstmsg);
                }
                break;

            case WebExceptionStatus.Timeout:
                lastMessages = new MessageCollection {
                    _bridgeNotResponding
                };
                BridgeNotResponding?.Invoke(this, _e);
                break;

            default:
                lastMessages = new MessageCollection {
                    new UnkownError(comres)
                };
                break;
            }
            return(lastMessages);
        }