private static void ActionRepairWindows(ServiceBusApp.AlarmMessage alarmMessage)
        {
            //DateTime date1 = Convert.ToDateTime(alarmMessage.createdAt);
            IFormatProvider culture = new System.Globalization.CultureInfo("en-US", true);
            //DateTime date1 = DateTime.Parse(alarmMessage.createdAt, culture, System.Globalization.DateTimeStyles.AssumeLocal);
            DateTime date1 = DateTime.Parse(alarmMessage.time, culture, System.Globalization.DateTimeStyles.AssumeLocal);
            DateTime date2 = DateTime.UtcNow;
            TimeSpan diff  = date2.Subtract(date1.AddHours(-16));

            /* if (diff.TotalSeconds > 20)
             * {
             *   //WriteHighlightedMessage("Message Expired(Open door), " + "Diff=" + diff.TotalSeconds.ToString(), ConsoleColor.Blue);
             *   ignore_messages.Add(GetDeviceIdHint(alarmMessage.deviceId) +
             *       " OpenDoor! Certificate=" + alarmMessage.name +
             *       ", MessageID=" + alarmMessage.msgId +
             *       ", Diff=" + diff.TotalSeconds.ToString());
             *   open_ignore_count += 1;
             *   return;
             * }*/
            WriteHighlightedMessage(
                GetDeviceIdHint(alarmMessage.deviceId) +
                " CloseDoor! Certificate=" + alarmMessage.name +
                ", MessageID=" + alarmMessage.msgId +
                ", Diff=" + diff.TotalSeconds.ToString(),
                ConsoleColor.Blue);

            /*C2DCommand c2dCommand = new C2DCommand();
             * c2dCommand.command = C2DCommand.COMMAND_OPEN_DOOR_WARNING;
             * c2dCommand.value = alarmMessage.msgId;
             * c2dCommand.time = alarmMessage.time;
             * SendCloudToDeviceCommand(_serviceClient, alarmMessage.deviceId, c2dCommand).Wait();*/

            C2DCommand2 c2dCommand = new C2DCommand2();

            c2dCommand.name = alarmMessage.name;
            c2dCommand.Lock = false;
            color c = new color(alarmMessage);

            c2dCommand.R = c.R;
            c2dCommand.G = c.G;
            c2dCommand.B = c.B;
            SendCloudToDeviceCommand(_serviceClient, "Devices", c2dCommand).Wait();


            // using (var db = new HumanContext())
            //{
            // Create and save a new Blog

            /*var entity = new Dbmsg
             * {
             * // name = alarmMessage.name,
             *  deviceId = alarmMessage.deviceId,
             *  msgId = alarmMessage.msgId,
             *  open = alarmMessage.open,
             *  age = alarmMessage.age,
             *  gender = alarmMessage.gender,
             *  emotion = alarmMessage.emotion,
             *  angerScore = alarmMessage.angerScore,
             *  happyScore = alarmMessage.happyScore,
             *  neutralScore = alarmMessage.neutralScore,
             *  contemptScore = alarmMessage.contemptScore,
             *  disgustScore = alarmMessage.disgustScore,
             *  fearScore = alarmMessage.fearScore,
             *  sadScore = alarmMessage.sadScore,
             *  surpriseScore = alarmMessage.surpriseScore,
             *  CreatedAt = DateTime.UtcNow.AddHours(8)
             *  //time = alarmMessage.time
             * };
             * db.Data.Add(entity);
             * db.SaveChanges();*/

            // }
        }
 private async static Task SendCloudToDeviceCommand(ServiceClient serviceClient, String deviceId, C2DCommand2 command)
 {
     var commandMessage = new Message(Encoding.ASCII.GetBytes(JsonConvert.SerializeObject(command)));
     await serviceClient.SendAsync(deviceId, commandMessage);
 }