public bool PutPartitionUpdate(Partition partition)
        {
            if (partition.Status == PartitionStatus.Unknown)
                return false;

            string path = string.Format("{0}partition/{1}/{2}", rootPath, (int)partition.Id, (int)partition.Status);
            var request = new RestRequest(path, Method.PUT) { RequestFormat = DataFormat.Json };
            request.AddQueryParameter("access_token", settings.AccessToken);

            var response = client.Execute(request);
            return response.Content.Contains("ok");     
        }
        public void PutPartitionUpdate(Partition partition)
        {
            if (partition.Status == PartitionStatus.Unknown)
                return;

            try
            {
                lock (this)
                {
                    string topic = string.Format("{0}/partition/{1}/status", settings.RootTopic, (int)partition.Id);
                    client.Publish(topic, Encoding.UTF8.GetBytes(partition.Status.ToString()), settings.QosLevel, settings.Retain);
                    logger.DebugFormat("{0}[{1}]", topic, partition.Status);
                }

            }
            catch (System.Exception exception)
            {
                logger.Error(exception);
            }
        }
        private void ProcessAreaAndZoneInformation(List<string> areas, List<object> zones)
        {

            int usedAreas = 0;
            int zoneNum = 1;

            for (int i = 0; i < zones.Count(); i++)
            {
                var partition = Convert.ToInt32(zones[i]);

                if (partition == 0)
                    break;

                usedAreas = Math.Max(usedAreas, partition);

                var device = new Device()
                {
                    DeviceType = DeviceType.Unknown,
                    Name = zones[++i].ToString(),
                    Partition = (PartitionNumber)(partition - 1),
                    Status = DeviceStatus.Unknown,
                    PreviousStatus = DeviceStatus.Unknown,
                    ZoneId = zoneNum
                };

                zoneNum++;
                device.DeviceType = ParseDeviceType(device.Name);
                Devices.Add(device);
            }

            Partitions = new List<Partition>();

            for (int i = 0; i < usedAreas; i++)
            {
                var p = new Partition()
                {
                    Name = areas[i],
                    Id = (PartitionNumber)i,
                    PreviousStatus = PartitionStatus.Unknown,
                    Status = PartitionStatus.Unknown
                };

                Partitions.Add(p);
            }
        }
 public PartitionUpdateEventArgs(Partition partition)
 {
     Partition = partition;
 }