/// <summary>
        /// Method to update passes to all the device
        /// </summary>
        /// <param name="userMl"></param>
        private static void UpdatePasses(UsersModel userMl)
        {
            StringBuilder objStringBuilderError = new StringBuilder();
            try
            {
                if (!string.IsNullOrEmpty(userMl.PassRFID))
                {
                    // construct a Jetstream service client
                    JetstreamServiceClient client = new JetstreamServiceClient(JetstreamConfiguration.Url,
                        JetstreamConfiguration.ApplicationAccessKey);

                    // create the GetDeviceDefinitions request
                    GetDeviceDefinitionsRequest deviceRequest = new GetDeviceDefinitionsRequest();

                    // call the Jetstream GetDeviceDefinitions ReST endpoint
                    GetDeviceDefinitionsResponse deviceResponse = client.GetDeviceDefinitions(deviceRequest);

                    //List the user passRFId
                    List<string> passes = new List<string> { userMl.PassRFID.ToUpper() };

                    //Get the list of Devices from local database
                    IEnumerable<DeviceModel> devices;
                    using (JetstreamClient objMainServiceClient = new JetstreamClient())
                    {
                        devices = objMainServiceClient.GetDeviceList();
                    }

                    //Itterate through the list of devices
                    foreach (var device in devices)
                    {
                        //get the device defination list for checking if device allow pass update
                        var deviceModel =
                            deviceResponse.DeviceDefinitionList.Where(x => x.Id == device.DeviceGuid).ToList();

                        if (deviceModel.Count > 0)
                        {
                            //Check if device allow pass update
                            var jetstreamGetDeviceDefinitionsResponseDeviceDefinition = deviceModel.FirstOrDefault();
                            bool updatePass = jetstreamGetDeviceDefinitionsResponseDeviceDefinition != null &&
                                              jetstreamGetDeviceDefinitionsResponseDeviceDefinition.CommandList
                                                  .DeviceSpecificCommandList.DeviceSpecificCommand.ToList()
                                                  .Select(x => x.CommandName)
                                                  .Contains("UpdatePasses");

                            if (updatePass)
                            {
                                //Update Pass to device
                                UpdatePassesRequest updateRequest = new UpdatePassesRequest
                                {
                                    LogicalDeviceId = device.LogicalDeviceId
                                };
                                if (userMl.Status != null && userMl.Status.Value)
                                {
                                    updateRequest.Add = passes;
                                }
                                else
                                {
                                    updateRequest.Remove = passes;
                                }

                                client.DeviceSpecificCommand(updateRequest);
                            }
                        }
                    }
                }
            }
            catch (FaultException<ServiceData> fex)
            {
                objStringBuilderError.AppendLine("In method : UpdatePasses(UsersModel userMl) :: UserController");
                objStringBuilderError.AppendFormat("ErrorMessage::{0} {1}", fex.Detail.ErrorMessage, Environment.NewLine);
                objStringBuilderError.AppendFormat("ErrorDetails::{0} {1}", Environment.NewLine, fex.Detail.ErrorDetails);
                SaveLogger.SaveLoggerError(objStringBuilderError.ToString());
            }
            catch (Exception ex)
            {
                objStringBuilderError.AppendLine("In method : UpdatePasses(UsersModel userMl) :: UserController");
                objStringBuilderError.AppendFormat("ErrorMessage::{0} {1}", ex.Message, Environment.NewLine);
                objStringBuilderError.AppendFormat("ErrorDetails::{0} {1}", Environment.NewLine, ex.ToString());

                SaveLogger.SaveLoggerError(objStringBuilderError.ToString());
            }
        }
        /// <summary>
        /// Method to process the pass syncronization event
        /// </summary>
        private void ProcessPassSynchronizationEvent()
        {
            try
            {
                StringBuilder sb = new StringBuilder();

                // construct a Jetstream service client
                JetstreamServiceClient client = new JetstreamServiceClient(JetstreamConfiguration.URL, JetstreamConfiguration.ApplicationAccessKey);

                // create the GetDeviceDefinitions request
                GetDeviceDefinitionsRequest deviceRequest = new GetDeviceDefinitionsRequest();

                // call the Jetstream GetDeviceDefinitions ReST endpoint
                GetDeviceDefinitionsResponse deviceResponse = client.GetDeviceDefinitions(deviceRequest);

                List<Device> devices = JetstreamEventRepository.GetDevices();

                //Get the passrfids to be added or updated
                List<User> users = JetstreamEventRepository.GetUser();
                List<string> passesAdd = users.Where(x => x.StatusId == 1).Select(x => x.PassRFID).Distinct().ToList();
                List<string> passesRemove = users.Where(x => x.StatusId == 0).Select(x => x.PassRFID).Distinct().ToList();

                foreach (var device in devices)
                {
                    var deviceModel = deviceResponse.DeviceDefinitionList.Where(x => x.Id == device.DeviceGuid).ToList();

                    if (deviceModel.Count > 0)
                    {
                        var jetstreamGetDeviceDefinitionsResponseDeviceDefinition = deviceModel.FirstOrDefault();
                        bool updatePass = jetstreamGetDeviceDefinitionsResponseDeviceDefinition != null && jetstreamGetDeviceDefinitionsResponseDeviceDefinition.CommandList.DeviceSpecificCommandList.DeviceSpecificCommand.ToList().Select(x => x.CommandName).Contains("UpdatePasses");

                        if (updatePass)
                        {
                            GetPassesRequest getPassRequest = new GetPassesRequest
                            {
                                LogicalDeviceId = device.LogicalDeviceId
                            };
                            DeviceSpecificCommandResponse getPassResponse = client.DeviceSpecificCommand(getPassRequest);

                            XmlDocument xmlDoc = new XmlDocument();
                            xmlDoc.LoadXml(getPassResponse.Body);

                            string xpath = System.Configuration.ConfigurationManager.AppSettings["xpath"];
                            var nodes = xmlDoc.SelectNodes(xpath);

                            if (nodes != null)
                                foreach (XmlNode childrenNode in nodes)
                                {
                                    var user = users.FirstOrDefault(x => x.PassRFID == childrenNode.Value);
                                    if (user == null)
                                    {
                                        passesRemove.Add(childrenNode.Value);
                                    }
                                    else
                                    {
                                        passesAdd.Remove(childrenNode.Value);
                                    }
                                }

                            UpdatePassesRequest updateRequest = new UpdatePassesRequest
                            {
                                LogicalDeviceId = device.LogicalDeviceId,
                                Add = passesAdd,
                                Remove = passesRemove
                            };

                            // call the Jetstream ResT endpoint 
                            client.DeviceSpecificCommand(updateRequest);
                        }
                    }
                    sb.AppendLine("ProcessPassSynchronizationEvent for Logical Device " + device.LogicalDeviceId);
                }

                // write the collected data to the event log
                EventLog.WriteEntry("JetstreamSDK ", sb.ToString());
            }
            catch (Exception)
            {
                // ignored
            }
        }