protected void _btnSend_Click(object sender, EventArgs e)
        {
            if (_txtCaptcha.Text == Session["strRandom"].ToString())
            {
                _lblCaptchaError.Text = "";

                _logonService = new LogonServiceClient();
                ReturnValue returnValue;

                returnValue = _logonService.RequestPassword(_txtEmail.Text);

                if (!returnValue.Success)
                {
                    _lblError.CssClass = "errorMessage";
                    _lblError.Text = returnValue.Message;
                    return;
                }
                else
                {
                    _lblError.CssClass = "successMessage";
                    _lblError.Text = "The new password will be sent to you by e-mail";
                }

                _txtEmail.Text = "";
                _txtEmailConfirm.Text = "";
                _txtCaptcha.Text = "";
            }
            else
            {
                _lblCaptchaError.Text = "entry is not correct";
            }
        }
        protected void _btnLogin_Click(object sender, EventArgs e)
        {
            LogonServiceClient _logonService = null;

            try
            {
                _logonService = new LogonServiceClient();
                LogonReturnValue returnValue = _logonService.Logon(_txtUsername.Text.Trim(), _txtPassword.Text.Trim());

                if (!returnValue.Success)
                {
                    _lblError.Text = returnValue.Message;
                    return;
                }

                if (returnValue.UserType != 1)
                {
                    _lblError.Text = "Access Denied";
                    return;
                }


                Session[SessionName.LogonId]          = returnValue.LogonId;
                Session[SessionName.MemberId]         = returnValue.MemberId;
                Session[SessionName.DefaultFeeEarner] = returnValue.UserDefaultFeeMemberId;

                Response.Redirect("~/Pages/Time/AddTimeEntryMobile.aspx");
            }
            catch (System.ServiceModel.EndpointNotFoundException)
            {
                _lblError.Text = DataConstants.WSEndPointErrorMessage;
                _logonService  = null;
                return;
            }
            catch (Exception ex)
            {
                _lblError.Text = ex.Message;
                _logonService  = null;
                return;
            }
            finally
            {
                if (_logonService != null)
                {
                    if (_logonService.State != System.ServiceModel.CommunicationState.Faulted)
                    {
                        _logonService.Close();
                    }
                }
            }
        }
        protected void _btnLogin_Click(object sender, EventArgs e)
        {
            LogonServiceClient _logonService = null;
            try
            {
                _logonService = new LogonServiceClient();
                LogonReturnValue returnValue = _logonService.Logon(_txtUsername.Text.Trim(), _txtPassword.Text.Trim());

                if (!returnValue.Success)
                {
                    _lblError.Text = returnValue.Message;
                    return;
                }

                if (returnValue.UserType != 1)
                {
                    _lblError.Text = "Access Denied";
                    return;
                }

                Session[SessionName.LogonId] = returnValue.LogonId;
                Session[SessionName.MemberId] = returnValue.MemberId;
                Session[SessionName.DefaultFeeEarner] = returnValue.UserDefaultFeeMemberId;

                Response.Redirect("~/Pages/Time/AddTimeEntryMobile.aspx");
            }
            catch (System.ServiceModel.EndpointNotFoundException)
            {
                _lblError.Text = DataConstants.WSEndPointErrorMessage;
                _logonService = null;
                return;
            }
            catch (Exception ex)
            {
                _lblError.Text = ex.Message;
                _logonService = null;
                return;
            }
            finally
            {
                if (_logonService != null)
                {
                    if (_logonService.State != System.ServiceModel.CommunicationState.Faulted)
                        _logonService.Close();
                }
            }
        }
        protected void _btnSubmit_Click(object sender, EventArgs e)
        {
            _logonService = new LogonServiceClient();
            ReturnValue returnValue;

            returnValue = _logonService.ChangePassword(_logonSettings.LogonId, Convert.ToString(Session[SessionName.LogonName]), _txtCurrentPassword.Text.Trim(), _txtNewPassword.Text.Trim());

            if (!returnValue.Success)
            {
                _lblError.CssClass = "errorMessage";
                _lblError.Text     = returnValue.Message;
                return;
            }
            else
            {
                _lblError.CssClass = "successMessage";
                _lblError.Text     = "Password Changed";
            }
        }
        protected void _btnSubmit_Click(object sender, EventArgs e)
        {
            _logonService = new LogonServiceClient();
            ReturnValue returnValue;

            returnValue = _logonService.ChangePassword(_logonSettings.LogonId, Convert.ToString(Session[SessionName.LogonName]), _txtCurrentPassword.Text.Trim(), _txtNewPassword.Text.Trim());

            if (!returnValue.Success)
            {
                _lblError.CssClass = "errorMessage";
                _lblError.Text = returnValue.Message;
                return;
            }
            else
            {
                _lblError.CssClass = "successMessage";
                _lblError.Text = "Password Changed";
            }
        }
Ejemplo n.º 6
0
        private void DoLogin(string username, string password)
        {
            // Block MSH from loggin into FED because it is too well known
            // Block rekoop integration user as well as it should only be using web services
            if (username.Trim().ToLower() == "msh" || username.Trim().ToLower() == "rekoop")
            {
                _lblError.Text = "Invalid logon details";
                return;
            }

            _logonService = new LogonServiceClient();
            LogonReturnValue returnValue;

            returnValue = _logonService.Logon(username, password);

            if (!returnValue.Success)
            {
                _lblError.Text = returnValue.Message;
                return;
            }

            Session[SessionName.LogonName] = username;

            Session["LogonID"] = returnValue.LogonId;

            if (null == Session[SessionName.ControlSettings])
            {
                PopulateControlPermissions(returnValue.UserType);
            }

            Session[SessionName.LogonSettings] = returnValue;

            if (!string.IsNullOrEmpty(returnValue.WebStyleSheet))
            {
                // This session is used for all kind of operation being done on CSS files
                Session[SessionName.StyleSheet] = returnValue.WebStyleSheet;

                // This session is used for security purpose
                // for instance, if user change the CSS contents, then on click of preview button of ChangeStyle.aspx screen
                // the new temperory CSS file is created and this CSS is set to Session[SessionName.StyleSheet]
                // and if user wants to cancel the operation, the Session[SessionName.UserStyleSheet] will set to Session[SessionName.StyleSheet]
                Session[SessionName.UserStyleSheet] = returnValue.WebStyleSheet;
            }

            if (returnValue.UserType == 2)
            {
                _clientService = new ClientServiceClient();
                bool isMember   = true;
                Guid memOrOrgId = Guid.Empty;

                if (returnValue.MemberId == IRIS.Law.WebApp.App_Code.DataConstants.DummyGuid)
                {
                    memOrOrgId = returnValue.OrganisationId;
                    isMember   = false;
                }
                else
                {
                    memOrOrgId = returnValue.MemberId;
                }

                ClientDetailReturnValue _clientReturnValue = _clientService.GetClientDetail(returnValue.LogonId, memOrOrgId,
                                                                                            isMember);

                Session[SessionName.MemberId]       = returnValue.MemberId;
                Session[SessionName.OrganisationId] = returnValue.OrganisationId;
                Session[SessionName.ClientRef]      = _clientReturnValue.ClientReference;
                Session[SessionName.ClientName]     = _clientReturnValue.Name;
            }

            if (returnValue.IsFirstTimeLoggedIn && returnValue.UserType != 1)
            {
                Response.Redirect("~/Pages/Password/ForceChangePassword.aspx", true);
            }

            if (Session["CurrentPage"] != null)
            {
                Response.Redirect(Session["CurrentPage"].ToString());
            }
            else
            {
                Response.Redirect("Home.aspx", true);
            }
        }
Ejemplo n.º 7
0
        private string Request(MetodoWebService metodo, string xml)
        {
            if (SalvarXmls)
            {
                if (!Directory.Exists(PathXmls))
                {
                    Directory.CreateDirectory(PathXmls);
                }

                string path = Path.Combine(PathXmls, $"{metodo}Request_{DateTime.Now:yyyy-MM-dd_HHmmss}.xml");
                File.WriteAllText(path, xml);
            }

            XmlEnvio    = string.Empty;
            XmlResposta = string.Empty;

            var _timeout = TimeSpan.FromMilliseconds(Timeout);

            X509Certificate2 _certificado = null;

            try
            {
                switch (CertificadoTipo)
                {
                case TipoCertificado.A1Repositorio:
                    _certificado = CertificadoDigital.ObterDoRepositorio(CertificadoSerial, OpenFlags.MaxAllowed);
                    break;

                case TipoCertificado.A1ByteArray:
                    _certificado = CertificadoDigital.ObterDoArrayBytes(CertificadoArrayBytes, CertificadoSenha);
                    break;

                case TipoCertificado.A1Arquivo:
                    _certificado = CertificadoDigital.ObterDeArquivo(CertificadoPath, CertificadoSenha);
                    break;

                case TipoCertificado.A3:
                    _certificado = CertificadoDigital.ObterDoRepositorioPassandoPin(CertificadoSerial, CertificadoSenha);
                    break;

                case TipoCertificado.Nenhum:
                    break;

                default:
                    throw new ArgumentOutOfRangeException("Tipo de certificado não implementado");
                }

                switch (metodo)
                {
                case MetodoWebService.Login:
                    using (var rqst = new LogonServiceClient(_timeout))
                    {
                        try
                        {
                            XmlResposta = rqst.Login(xml);
                        }
                        finally
                        {
                            XmlEnvio = rqst.XmlEnvio;
                        }
                    }
                    break;

                case MetodoWebService.Logout:
                    using (var rqst = new LogonServiceClient(_timeout))
                    {
                        try
                        {
                            XmlResposta = rqst.Logout(xml);
                        }
                        finally
                        {
                            XmlEnvio = rqst.XmlEnvio;
                        }
                    }
                    break;

                case MetodoWebService.MotoristaGravar:
                    using (var rqst = new MotoristasServiceClient(_timeout))
                    {
                        try
                        {
                            XmlResposta = rqst.MotoristaGravar(xml);
                        }
                        finally
                        {
                            XmlEnvio = rqst.XmlEnvio;
                        }
                    }
                    break;

                case MetodoWebService.MotoristaObter:
                    using (var rqst = new MotoristasServiceClient(_timeout))
                    {
                        try
                        {
                            XmlResposta = rqst.MotoristaObter(xml);
                        }
                        finally
                        {
                            XmlEnvio = rqst.XmlEnvio;
                        }
                    }
                    break;

                case MetodoWebService.ProprietarioGravar:
                    using (var rqst = new ProprietariosServiceClient(_timeout))
                    {
                        try
                        {
                            XmlResposta = rqst.ProprietarioGravar(xml);
                        }
                        finally
                        {
                            XmlEnvio = rqst.XmlEnvio;
                        }
                    }
                    break;

                case MetodoWebService.ProprietarioObter:
                    using (var rqst = new ProprietariosServiceClient(_timeout))
                    {
                        try
                        {
                            XmlResposta = rqst.ProprietarioObter(xml);
                        }
                        finally
                        {
                            XmlEnvio = rqst.XmlEnvio;
                        }
                    }
                    break;

                case MetodoWebService.VeiculoGravar:
                    using (var rqst = new VeiculosServiceClient(_timeout))
                    {
                        try
                        {
                            XmlResposta = rqst.VeiculoGravar(xml);
                        }
                        finally
                        {
                            XmlEnvio = rqst.XmlEnvio;
                        }
                    }
                    break;

                case MetodoWebService.VeiculoObter:
                    using (var rqst = new VeiculosServiceClient(_timeout))
                    {
                        try
                        {
                            XmlResposta = rqst.VeiculoObter(xml);
                        }
                        finally
                        {
                            XmlEnvio = rqst.XmlEnvio;
                        }
                    }
                    break;

                case MetodoWebService.PefAdicionarOperacaoTransporte:
                    using (var rqst = new PefServiceClient(_timeout))
                    {
                        try
                        {
                            XmlResposta = rqst.AdicionarOperacaoTransportePef(xml);
                        }
                        finally
                        {
                            XmlEnvio = rqst.XmlEnvio;
                        }
                    }
                    break;

                case MetodoWebService.PefAdicionarPagamento:
                    using (var rqst = new PefServiceClient(_timeout))
                    {
                        try
                        {
                            XmlResposta = rqst.AdicionarPagamentoPef(xml);
                        }
                        finally
                        {
                            XmlEnvio = rqst.XmlEnvio;
                        }
                    }
                    break;

                case MetodoWebService.PefObterCodigoIdentificacaoOperacaoTransportePorIdOperacaoCliente:
                    using (var rqst = new PefServiceClient(_timeout))
                    {
                        try
                        {
                            XmlResposta = rqst.ObterCodigoIdentificacaoOperacaoTransportePorIdOperacaoClientePef(xml);
                        }
                        finally
                        {
                            XmlEnvio = rqst.XmlEnvio;
                        }
                    }
                    break;

                case MetodoWebService.PefObterOperacaoTransportePdf:
                    using (var rqst = new PefServiceClient(_timeout))
                    {
                        try
                        {
                            XmlResposta = rqst.ObterOperacaoTransportePdfPef(xml);
                        }
                        finally
                        {
                            XmlEnvio = rqst.XmlEnvio;
                        }
                    }
                    break;

                case MetodoWebService.PefRetificarOperacaoTransporte:
                    using (var rqst = new PefServiceClient(_timeout))
                    {
                        try
                        {
                            XmlResposta = rqst.RetificarOperacaoTransportePef(xml);
                        }
                        finally
                        {
                            XmlEnvio = rqst.XmlEnvio;
                        }
                    }
                    break;

                case MetodoWebService.PefCancelarOperacaoTransporte:
                    using (var rqst = new PefServiceClient(_timeout))
                    {
                        try
                        {
                            XmlResposta = rqst.CancelarOperacaoTransportePef(xml);
                        }
                        finally
                        {
                            XmlEnvio = rqst.XmlEnvio;
                        }
                    }
                    break;

                case MetodoWebService.PefEncerrarOperacaoTransporte:
                    using (var rqst = new PefServiceClient(_timeout))
                    {
                        try
                        {
                            XmlResposta = rqst.EncerrarOperacaoTransportePef(xml);
                        }
                        finally
                        {
                            XmlEnvio = rqst.XmlEnvio;
                        }
                    }
                    break;

                case MetodoWebService.PefAdicionarViagem:
                    using (var rqst = new PefServiceClient(_timeout))
                    {
                        try
                        {
                            XmlResposta = rqst.AdicionarViagemPef(xml);
                        }
                        finally
                        {
                            XmlEnvio = rqst.XmlEnvio;
                        }
                    }
                    break;

                default:
                    throw new NotImplementedException();
                }

                if (SalvarXmls)
                {
                    string path = Path.Combine(PathXmls, $"{metodo}Response_{DateTime.Now:yyyy-MM-dd_HHmmss}.xml");
                    File.WriteAllText(path, XmlResposta);
                }
            }
            finally
            {
#if NETFRAMEWORK
                if (_certificado != null)
                {
                    _certificado.ForceUnload();
                }
#else
                _certificado?.Dispose();
#endif
            }

            return(XmlResposta);
        }
Ejemplo n.º 8
0
 protected void _btnLogin_Click(object sender, EventArgs e)
 {
     try
     {
         DoLogin(_txtUsername.Text.Trim(), _txtPassword.Text.Trim());
     }
     catch (System.ServiceModel.EndpointNotFoundException ex)
     {
         _logger.ErrorException("Endpoint not found", ex);
         _lblError.Text = IRIS.Law.WebApp.App_Code.DataConstants.WSEndPointErrorMessage;
         _logonService = null;
         return;
     }
     catch (TimeoutException ex)
     {
         _logger.ErrorException("Login timeout", ex);
         _lblError.Text = ex.Message;
         _logonService = null;
         return;
     }
     catch (ThreadAbortException) //ignore as thrown by Response.Redirect
     { }
     catch (Exception ex)
     {
         _logger.ErrorException("Could not login", ex);
         _lblError.Text = ex.Message;
         _logonService = null;
         return;
     }
 }
Ejemplo n.º 9
0
        private void DoLogin(string username, string password)
        {
            // Block MSH from loggin into FED because it is too well known
            // Block rekoop integration user as well as it should only be using web services
            if (username.Trim().ToLower() == "msh" || username.Trim().ToLower() == "rekoop")
            {
                _lblError.Text = "Invalid logon details";
                return;
            }

            _logonService = new LogonServiceClient();
            LogonReturnValue returnValue;

            returnValue = _logonService.Logon(username, password);

            if (!returnValue.Success)
            {
                _lblError.Text = returnValue.Message;
                return;
            }

            Session[SessionName.LogonName] = username;

            Session["LogonID"] = returnValue.LogonId;

            if (null == Session[SessionName.ControlSettings])
                PopulateControlPermissions(returnValue.UserType);

            Session[SessionName.LogonSettings] = returnValue;

            if (!string.IsNullOrEmpty(returnValue.WebStyleSheet))
            {
                // This session is used for all kind of operation being done on CSS files
                Session[SessionName.StyleSheet] = returnValue.WebStyleSheet;

                // This session is used for security purpose
                // for instance, if user change the CSS contents, then on click of preview button of ChangeStyle.aspx screen
                // the new temperory CSS file is created and this CSS is set to Session[SessionName.StyleSheet]
                // and if user wants to cancel the operation, the Session[SessionName.UserStyleSheet] will set to Session[SessionName.StyleSheet]
                Session[SessionName.UserStyleSheet] = returnValue.WebStyleSheet;
            }

            if (returnValue.UserType == 2)
            {
                _clientService = new ClientServiceClient();
                bool isMember = true;
                Guid memOrOrgId = Guid.Empty;

                if (returnValue.MemberId == IRIS.Law.WebApp.App_Code.DataConstants.DummyGuid)
                {
                    memOrOrgId = returnValue.OrganisationId;
                    isMember = false;
                }
                else
                {
                    memOrOrgId = returnValue.MemberId;
                }

                ClientDetailReturnValue _clientReturnValue = _clientService.GetClientDetail(returnValue.LogonId, memOrOrgId,
                                                                                            isMember);

                Session[SessionName.MemberId] = returnValue.MemberId;
                Session[SessionName.OrganisationId] = returnValue.OrganisationId;
                Session[SessionName.ClientRef] = _clientReturnValue.ClientReference;
                Session[SessionName.ClientName] = _clientReturnValue.Name;
            }

            if (returnValue.IsFirstTimeLoggedIn && returnValue.UserType != 1)
            {
                Response.Redirect("~/Pages/Password/ForceChangePassword.aspx", true);
            }

            if (Session["CurrentPage"] != null)
            {
                Response.Redirect(Session["CurrentPage"].ToString());
            }
            else
            {
                Response.Redirect("Home.aspx", true);
            }
        }
        // Added By JK on 01/09/12
        // Moved the code from Shell.xaml.cs to ModuleSelectionPresenter as the client wants
        // the Dispatcher to start even if the connection to backend is not established.
        private void Logon()
        {
            if (log.IsInfoEnabled) log.Info("Initiating Log on");
            int maxTime = (ConfigurationManager.AppSettings["MaxTurnTime"] == null) ? 20 : int.Parse(ConfigurationManager.AppSettings["MaxTurnTime"]);
            LogOnKioskResponse logonResponse = new LogOnKioskResponse();
            LogonServiceClient logonproxy = null;
            DateTime dtBeforeLogon, dtafterLogon, newDateTime;
            TimeSpan timeDiff;
            try
            {
                ValidateCertificate.RegisterCallback();
                logonproxy = new LogonServiceClient();

                if (log.IsInfoEnabled) log.Info("Requesting for Log on");
                dtBeforeLogon = DateTime.Now;
                logonResponse = logonproxy.LogOnKiosk(new LogOnKioskRequest
                {
                    KioskId = Int32.Parse(KioskAppConfig.KioskId),
                    StatusUpdated = DateTime.UtcNow,
                    ReleaseVersion = KioskAppConfig.CurrentVersion
                });

                dtafterLogon = DateTime.Now;
                timeDiff = dtafterLogon.Subtract(dtBeforeLogon);
                if (log.IsInfoEnabled) log.InfoFormat("Hours: {0}, Mins: {1} Sec: {2} Days:{3}", timeDiff.Hours, timeDiff.Minutes, timeDiff.Seconds, timeDiff.Days);
                if (log.IsInfoEnabled) log.Info("Requesting for Log on completed");

                if (!string.IsNullOrEmpty(logonResponse.XXX12))
                {
                    try
                    {
                        RegistryKey pRegKey = Registry.LocalMachine;
                        pRegKey = pRegKey.OpenSubKey("SOFTWARE\\USPInc");

                        SHA256 hasher = SHA256Managed.Create();
                        byte[] hashedData = hasher.ComputeHash(
                            Encoding.Unicode.GetBytes(logonResponse.XXX12));
                        StringBuilder sb = new StringBuilder();
                        foreach (byte b in hashedData)
                        {
                            sb.AppendFormat("{0:x2}", b);
                        }

                        pRegKey.SetValue("xxx23", sb.ToString(), RegistryValueKind.String);
                    }
                    catch (Exception ex)
                    {
                        if (log.IsErrorEnabled) log.ErrorFormat("Set xxx12 error : {0}", ex.Message);
                    }
                }

                logonResponse.isLoggedOn = true;
                if (logonResponse.isLoggedOn)
                {
                    if (log.IsInfoEnabled) log.Info("Kiosk Logged on");
                    //Populate Service List

                    KioskAppConfig.KioskServices = new List<Infrastructure.ObjectModel.KioskService>();
                    KioskAppConfig.KioskDevices = new List<Infrastructure.ObjectModel.KioskDevice>();
                    KioskAppConfig.KioskLocation = logonResponse.KioskLocation;
                    isMonitored = logonResponse.isMonitored;

                    if (timeDiff.Seconds >= 0 &&
                    timeDiff.Seconds <= maxTime)
                    {
                        if (log.IsInfoEnabled) log.InfoFormat("Kiosk Logged on between the turnaround time with time : {0}",logonResponse.CurrentTimeStamp);
                        timeDiff = TimeSpan.FromTicks(timeDiff.Ticks / 2);
                        newDateTime = Convert.ToDateTime(logonResponse.CurrentTimeStamp);//.ToLocalTime();
                        newDateTime.Add(timeDiff);

                        //admin Change the system time
                        if (log.IsInfoEnabled) log.Info("Synchronizing System Time");
                        SYSTEMTIME SysTime = new SYSTEMTIME();
                        SysTime.wYear = (short)newDateTime.Year;
                        SysTime.wMonth = (short)newDateTime.Month;
                        SysTime.wDay = (short)newDateTime.Day;
                        SysTime.wHour = (short)newDateTime.Hour;
                        SysTime.wMinute = (short)newDateTime.Minute;
                        SysTime.wSecond = (short)newDateTime.Second;
                        bool res = SetSystemTime(ref SysTime);

                        if (!res)
                        {
                            if (log.IsErrorEnabled) log.Error("System Time not changed Successfully");
                        }
                        else
                        {
                            if (log.IsInfoEnabled) log.Info("Changed System Time Successfully");
                        }
                    }

                       //this.Transaction.KioskServices = null;

                    foreach (MBMEKiosk.LogonProxy.KioskService service in logonResponse.BillerServiceList)
                    {
                        MBMEKiosk.Infrastructure.ObjectModel.KioskService item = new MBMEKiosk.Infrastructure.ObjectModel.KioskService()
                        {
                            BillerServiceId = service.BillerServiceId,
                            ServiceKey = service.ServiceKey,
                            ActivationDate = service.ActivationDate,
                            Available = service.Available,
                            BillerServiceName = service.BillerServiceName,
                            KioskId = service.KioskId,
                            KioskRefNum = service.KioskRefNum
                        };
                        KioskAppConfig.KioskServices.Add(item);
                    }

                    //Populate Device List
                    foreach (MBMEKiosk.LogonProxy.KioskDevice device in logonResponse.DeviceList)
                    {
                        MBMEKiosk.Infrastructure.ObjectModel.KioskDevice item = new MBMEKiosk.Infrastructure.ObjectModel.KioskDevice()
                        {
                            DeviceId = device.DeviceId,
                            //KioskDeviceId = device.KioskDeviceId,
                            DeviceKey = device.DeviceKey,
                            DeviceEnabled = device.DeviceEnabled,
                            DeviceName = device.DeviceName,
                            KioskId = device.KioskId,
                            KioskRefNum = device.KioskRefNum
                        };

                        KioskAppConfig.KioskDevices.Add(item);
                        if (log.IsInfoEnabled) log.Info("Machine Location retrieved is:" + KioskAppConfig.KioskLocation + ",MachineId:" + KioskAppConfig.KioskId);
                    }

                    // Modified By JK on 01/09/12
                    // Previously the developer had put AND condition but has been replaced with OR.
                    if ((logonResponse.BillerServiceList.Length == 0) &&
                        (logonResponse.DeviceList.Length == 0))
                    {
                        if (log.IsInfoEnabled) log.Info("Kiosk logged on not successful");
                        loggedOn = false;
                        if (log.IsInfoEnabled) log.Info("No Biller Service or Device configured for this Kiosk.");
                    }
                    else
                    {
                        loggedOn = true;
                        if (log.IsInfoEnabled) log.Info("Kiosk logged on successfull");
                        //initialize Devices
                        objKiosk.Name = ConfigurationManager.AppSettings["KDeviceId"].ToString(); ;

                        objPrinter.Name = ConfigurationManager.AppSettings["PDeviceId"].ToString();

                        objCashAcceptor.Name = ConfigurationManager.AppSettings["CADeviceId"].ToString();

                        var kioskDevice = (from A in KioskAppConfig.KioskDevices
                                           where A.DeviceName.Equals(objKiosk.Name)
                                           select A.DeviceId).SingleOrDefault();

                        objKiosk.DeviceId = kioskDevice.ToString();

                        var printerDevice = (from A in KioskAppConfig.KioskDevices
                                             where A.DeviceName.Equals(objPrinter.Name)
                                             select A.DeviceId).SingleOrDefault();

                        objPrinter.DeviceId = printerDevice.ToString();

                        var cashAcceptorDevice = (from A in KioskAppConfig.KioskDevices
                                                  where A.DeviceName.Equals(objCashAcceptor.Name)
                                                  select A.DeviceId).SingleOrDefault();

                        objCashAcceptor.DeviceId = cashAcceptorDevice.ToString();

                        if (connectivityPolling)
                        {
                            //if (isMonitored)
                            RestartConnectivityTimer();
                            //if (monitorClient == null)
                            //  monitorClient.CheckBackendConnectivityCompleted += new EventHandler<CheckBackendConnectivityCompletedEventArgs>(monitorClient_CheckBackendConnectivityCompleted);
                        }
                        if (shutdownCommandActive)
                            RestartShutdownTimer();
                    }
                }
            }
            catch (Exception ex)
            {
                loggedOn = false;
                if (logonproxy != null)
                    logonproxy.Abort();
                if (log.IsErrorEnabled) log.ErrorFormat("Kiosk logon unsuccessfull: {0} {1}", DateTime.Now.ToString(), ex.Message);
            }
            finally
            {
                if (!loggedOn)
                    RestartLogonTimer();
                if (logonproxy != null)
                    logonproxy.Close();
                ValidateCertificate.DeregisterCallback();
            }
        }
        private void LoadUtilities()
        {
            MBMEKiosk.LogonProxy.UpdateUtilityRequest utility = null;
                List<MBMEKiosk.LogonProxy.UpdateUtilityRequest> utilities = new List<LogonProxy.UpdateUtilityRequest>();
                LogonServiceClient logonproxy = null;
                try
                {
                    string relativePath = ConfigurationManager.AppSettings["ModulesPath"] != null ? ConfigurationManager.AppSettings["ModulesPath"] : "modules";
                    String[] astrLoadableFiles = Directory.GetFiles(relativePath, "*.dll");
                    ValidateCertificate.RegisterCallback();
                    logonproxy = new LogonServiceClient();

                    Assembly assembly = null;
                    foreach (String strFile in astrLoadableFiles)
                    {
                        try
                        {
            #if DEBUG
                    assembly = Assembly.LoadFrom(strFile);
            #else
                            try
                            {
                                utility = new LogonProxy.UpdateUtilityRequest();
                                assembly = Assembly.LoadFrom(strFile);

                                Version dllVersion = assembly.GetName().Version;
                                utility.Version = dllVersion.ToString();
                                utility.UtilityName = assembly.ManifestModule.Name;
                                utility.DateModified = new System.IO.FileInfo(strFile).LastWriteTime;
                                utility.Size = new System.IO.FileInfo(strFile).Length;
                                utilities.Add(utility);
                            }
                            catch (IOException ioex)
                            {
                                Trace.TraceError("Warning! Error loading file LoadUtilities \r\n\r\n{0}\r\n\r\n{1}\r\n\r\n{2}", ioex.Message, ioex.Source, ioex.StackTrace);
                                if (log.IsErrorEnabled) log.ErrorFormat(" Warning! Error loading file in LoadUtilities  {0} {1}", DateTime.Now.ToString(), ioex.Message);
                            }
                            catch (Exception ex)
                            {
                                Trace.TraceError("Error! Error loading file.\r\n\r\n{0}\r\n\r\n{1}\r\n\r\n{2}", ex.Message, ex.Source, ex.StackTrace);
                                if (log.IsErrorEnabled) log.ErrorFormat("Error! Error loading file in LoadUtilities  {0} {1}", DateTime.Now.ToString(), ex.Message);
                            }
            #endif
                        }
                        catch (BadImageFormatException ex)
                        {
                            // Assembly was not a valid assembly or it targets a later version of .NET framework than is loaded.
                            if (log.IsErrorEnabled) log.ErrorFormat("Caught BadImageFormatException in LoadUtilities  {0} {1}", DateTime.Now.ToString(), ex.Message);
                            continue;
                        }
                    }

                    if(File.Exists(CMEXEPATH))
                    {
                        assembly = Assembly.LoadFrom(CMEXEPATH);

                        utility = new LogonProxy.UpdateUtilityRequest();
                        Version dllVersion = assembly.GetName().Version;
                        utility.Version = dllVersion.ToString();
                        utility.UtilityName = assembly.ManifestModule.Name;
                        utility.DateModified = new System.IO.FileInfo(CMEXEPATH).LastWriteTime;
                        utility.Size = new System.IO.FileInfo(CMEXEPATH).Length;
                        utilities.Add(utility);
                    }
                    else
                        if (log.IsInfoEnabled) log.InfoFormat("MBMEContentManager.exe not found in LoadUtilities  {0}", DateTime.Now.ToString());

                    if(File.Exists(KIOSKEXEPATH))
                    {
                        assembly = Assembly.LoadFrom(KIOSKEXEPATH);

                        utility = new LogonProxy.UpdateUtilityRequest();
                        Version dllVersion = assembly.GetName().Version;
                        utility.Version = dllVersion.ToString();
                        utility.UtilityName = assembly.ManifestModule.Name;
                        utility.DateModified = new System.IO.FileInfo(KIOSKEXEPATH).LastWriteTime;
                        utility.Size = new System.IO.FileInfo(KIOSKEXEPATH).Length;
                        utilities.Add(utility);
                    }
                    else
                        if (log.IsInfoEnabled) log.InfoFormat("MBMEKiosk.exe not found in LoadUtilities  {0}", DateTime.Now.ToString());

                    if(File.Exists(WATCHDOGEXEPATH))
                    {
                        assembly = Assembly.LoadFrom(WATCHDOGEXEPATH);

                        utility = new LogonProxy.UpdateUtilityRequest();
                        Version dllVersion = assembly.GetName().Version;
                        utility.Version = dllVersion.ToString();
                        utility.UtilityName = assembly.ManifestModule.Name;
                        utility.DateModified = new System.IO.FileInfo(WATCHDOGEXEPATH).LastWriteTime;
                        utility.Size = new System.IO.FileInfo(WATCHDOGEXEPATH).Length;
                        utilities.Add(utility);
                    }
                    else
                        if (log.IsInfoEnabled) log.InfoFormat("MBMEWatchDog.exe not found in LoadUtilities  {0}", DateTime.Now.ToString());

                    if (logonproxy != null && utilities.Count() > 0)
                        logonproxy.LogOnUpdateUtilityAsync(Int32.Parse(KioskAppConfig.KioskId), utilities.ToArray());

                }
                catch (Exception ex)
                {
                    if (logonproxy != null)
                        logonproxy.Abort();
                    if (log.IsErrorEnabled) log.ErrorFormat("LoadUtilities  unsuccessfull: {0} {1}", DateTime.Now.ToString(), ex.Message);
                }
                finally
                {
                    if (logonproxy != null)
                        logonproxy.Close();
                    ValidateCertificate.DeregisterCallback();
                }
        }