public override void Initialize(string name, System.Collections.Specialized.NameValueCollection config) { base.Initialize(name, config); var latchConfig = (LatchSettingsSection)System.Configuration.ConfigurationManager.GetSection("latchSettings"); this.innerMembershipProviderName = latchConfig.InnerMembershipProvider; this.appId = latchConfig.AppId; this.appSecret = latchConfig.AppSecret; if (!string.IsNullOrEmpty(latchConfig.ApiHost)) { this.apiHost = latchConfig.ApiHost; } this.loginOperation = string.IsNullOrEmpty(latchConfig.LoginOperation) ? appId : latchConfig.LoginOperation; this.defaultStorageXmlFile = Path.Combine(System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath, latchConfig.DefaultStorageXmlFile); this.latchAPI = new LatchSDK.Latch(this.appId, this.appSecret); LatchSDK.Latch.SetHost(this.apiHost); this.defaultStorage = new LatchDefaultStorage(); if (File.Exists(this.defaultStorageXmlFile)) { try { this.defaultStorage.ReadXml(this.defaultStorageXmlFile); } catch (Exception) { } } }
private bool IsLatchOperationOpen(string username, string operationId) { bool isOpen = true; try { if (string.IsNullOrEmpty(lb_account_id.Text)) { lb_account_id.Text = ConfigurationManager.AppSettings["latchAccountId"]; LatchSDK.Latch latchComm = new LatchSDK.Latch(ConfigurationManager.AppSettings["latchAppId"], ConfigurationManager.AppSettings["latchAppSecret"]); LatchSDK.LatchResponse response = latchComm.OperationStatus(lb_account_id.Text, operationId); //isOpen = response.Error == null && ((string)(((Dictionary<string, object>)((Dictionary<string, object>)response.Data["operations"])[operationId])["status"])).Equals("on", StringComparison.InvariantCultureIgnoreCase); if (response.Error == null && response.Data["operations"] is Dictionary <string, object> ) { Dictionary <string, object> operations = response.Data["operations"] as Dictionary <string, object>; if (operations[operationId] is Dictionary <string, object> ) { Dictionary <string, object> currentOperation = operations[operationId] as Dictionary <string, object>; isOpen = (currentOperation["status"] as string).Equals("on", StringComparison.InvariantCultureIgnoreCase); } } } } catch (Exception) { } return(isOpen); }
protected void Page_Load(object sender, EventArgs e) { instanciaLatch = new LatchSDK.Latch(ConfigurationManager.AppSettings["appId"], ConfigurationManager.AppSettings["appSecret"]); string username = ""; if (this.Context.User.Identity.IsAuthenticated) { username = this.Context.User.Identity.Name; } if (IsLatchOperationOpen(username, ConfigurationManager.AppSettings["Login"])) { lb_login.Text = "El LATCH de la operación LOGIN está abierto"; lb_login.ForeColor = System.Drawing.Color.Blue; lb_login.Font.Bold = true; this.LoginUser.Enabled = true; } else { lb_login.Text = "El LATCH de la operación LOGIN está cerrado"; lb_login.ForeColor = System.Drawing.Color.Red; lb_login.Font.Bold = true; this.LoginUser.Enabled = false; } RegisterHyperLink.NavigateUrl = "Register.aspx?ReturnUrl=" + HttpUtility.UrlEncode(Request.QueryString["ReturnUrl"]); }
protected void Page_Load(object sender, EventArgs e) { //if (!Page.IsPostBack) //{ instanciaLatch = new LatchSDK.Latch(ConfigurationManager.AppSettings["latchAppId"], ConfigurationManager.AppSettings["latchAppSecret"]); //instanciaLatch = new LatchSDK.Latch(ConfigurationManager.AppSettings["appId"], ConfigurationManager.AppSettings["appSecret"]); lb_account_id.Text = ConfigurationManager.AppSettings["latchAccountId"]; string username = ""; if (this.Context.User.Identity.IsAuthenticated) { username = this.Context.User.Identity.Name; } if (IsLatchOperationOpen(username, ConfigurationManager.AppSettings["ChangePassword"])) { lb_changepassword.Text = "El LATCH de la operación Cambio de contraseña está abierto"; lb_changepassword.ForeColor = System.Drawing.Color.Blue; lb_changepassword.Font.Bold = true; this.ChangeUserPassword.Enabled = true; } else { lb_changepassword.Text = "El LATCH de la operación Cambio de contraseña está cerrado"; lb_changepassword.ForeColor = System.Drawing.Color.Red; lb_changepassword.Font.Bold = true; this.ChangeUserPassword.Enabled = false; } }
protected void Page_Load(object sender, EventArgs e) { instanciaLatch = new LatchSDK.Latch(ConfigurationManager.AppSettings["latchAppId"], ConfigurationManager.AppSettings["latchAppSecret"]); }