protected void ValidateToken(BaseDC bdc, string userid, string returnurl) { if (bdc == null) { throw new ApplicationException(GeneralConstants.UserNotExist); } else if (bdc.IsActive.HasValue && !bdc.IsActive.Value) { throw new ApplicationException(GeneralConstants.Useractive); } else if (bdc.IsLocked.HasValue && !bdc.IsLocked.Value) { throw new ApplicationException(GeneralConstants.Userlocked); } else { Label lblName = (Label)this.Page.Master.FindControl(UCConstants.UserName); if (lblName != null) { lblName.Text = bdc.Username; } if (GMConvert.GetString(userid).Length > 0) { System.Web.Security.FormsAuthentication.RedirectFromLoginPage(userid, false); } GMReflectionUtils.InvokeMember(this.Page, ReflectionConstants.Redirect, (bdc.IsChangePasssword.HasValue && bdc.IsChangePasssword.Value == true) ? new object[] { UIConstants.ChangePwdAspx, QueryStringConstants.UserID, bdc.ID } : new object[] { returnurl }, EnumConstants.InvokeMethod); } }
public DCUser2 AuthenticateUser(string sessionid, string username, string pwd, string pwdattempts) { UserBiz m_ubiz = new UserBiz(); User2Detail dtuser = null; DCUser2 dcusr = null; GroupBiz m_gbiz = new GroupBiz(); try { dtuser = m_ubiz.AuthenticateUser(CryptoUtils.DecryptTripleDES(username), CryptoUtils.DecryptTripleDES(pwd), GMConvert.GetInt16(CryptoUtils.DecryptTripleDES(pwdattempts))); if (dtuser != null && dtuser.LastLogon.HasValue) { dtuser.Permissions = new List <int>(); List <Int32> groups = m_ubiz.GetGroups(dtuser.ID); foreach (int group in groups) { dtuser.Permissions.AddRange(m_gbiz.GetPermissions(group)); } dcusr = new DCUser2(); GMReflectionUtils.Copy(dtuser, dcusr); SetCache(sessionid, dcusr); } } catch (Exception exp) { throw exp; } finally { m_ubiz.Dispose(); m_gbiz.Dispose(); } return(dcusr); }
protected void OnSearch(object sender, EventArgs ea) { ControlCollection cc = divSearch.Controls; StringBuilder sbSearch = new StringBuilder(); string spropname = string.Empty, stype = string.Empty, svalue = string.Empty; sbSearch.Append(" 1=1"); foreach (Control c in cc) { if (c.ID != null) { svalue = string.Empty; spropname = c.ID.Substring(3); stype = c.GetType().BaseType.Name; if (stype.Equals(ControlTypeConstants.TextboxType) || stype.Equals(ControlTypeConstants.DropdownListType)) { svalue = GMReflectionUtils.InvokeMember(c, ReflectionConstants.Value, null, EnumConstants.GetProperty); } if (!String.IsNullOrEmpty(svalue)) { if (!(stype.Equals(ControlTypeConstants.DropdownListType) && svalue == "0")) { sbSearch.Append(" AND B." + spropname + " like '" + svalue + "'"); } } } } hdnSearch.Value = sbSearch.ToString(); grvDataTable.PageIndex = 0; grvDataTable.DataBind(); }
public void LogOut() { GMReflectionUtils.InvokeMember(GMReflectionUtils.GetInstance(UIBinderHandlerConstants.AuthenticationUB), ReflectionConstants.ClearCache, new object[] { this.SessionID }); FormsAuthentication.SignOut(); HttpContext.Current.Session.Remove(ViewStateConstants.SessionID); GMUtilities.Logger.LogMessage(ErrorConstants.ClearCache); Response.Redirect(FormsAuthentication.LoginUrl); }
public static void BindList(dynamic ctl, dynamic options, string DataTextField, string DataValueField) { ListControl lstctl = (ListControl)(GMReflectionUtils.InvokeMember(ctl, ReflectionConstants.Instance, null, EnumConstants.GetProperty)); lstctl.DataSource = options; lstctl.DataTextField = DataTextField; lstctl.DataValueField = DataValueField; lstctl.DataBind(); }
dynamic ExecuteAction(string actionname, BaseDC bdc, object param) { dynamic di = GMReflectionUtils.GetInstance(GMReflectionUtils.GetHandler <Handler>(bdc.GetType()).TypeH); di.GetHeaderToken(bdc); dynamic rv = GMReflectionUtils.InvokeMember(di, actionname, new object[] { param }); di.Dispose(); return(rv); }
protected void OnSign_In(object sender, System.EventArgs e) { try { BasePage bp = (BasePage)this.Page; bp.PasswordAttempt = ((Int16)(bp.PasswordAttempt + 1)); ValidateUser(bp.PasswordAttempt, UIConstants.DefaultAspx); } catch (Exception ex) { GMReflectionUtils.InvokeMember(this.Page, ReflectionConstants.MasterDisplayError, new object[] { ex }, EnumConstants.InvokeMethod); } }
private static void ManageValues(ControlCollection cc, dynamic[] instances, bool isgetctl) { string spropname = string.Empty, stype = string.Empty; bool isbaseuc = false; foreach (Control c in cc) { if (c.ID != null) { spropname = c.ID.Substring(3); isbaseuc = (c is BaseGMUC); foreach (dynamic ob in instances) { try { if (!isgetctl) { stype = c.GetType().BaseType.Name; if (stype.Equals(ControlTypeConstants.ListboxType) || stype.Equals(ControlTypeConstants.DropdownListType)) { UIUtilities.BindList(c, GMReflectionUtils.InvokeMember(ob, string.Format("{0}{1}", ReflectionConstants.DataSource, spropname), null, EnumConstants.GetProperty)); } else if (stype.Equals(ControlTypeConstants.GridViewType)) { UIUtilities.BindGridView(c, GMReflectionUtils.InvokeMember(ob, spropname, null, EnumConstants.GetProperty)); } else if (stype.Equals(ControlTypeConstants.TwolistType)) { UIUtilities.BindTwolist(c, GMReflectionUtils.InvokeMember(ob, string.Format("{0}{1}", ReflectionConstants.DataSource, ReflectionConstants.Selected), null, EnumConstants.GetProperty), GMReflectionUtils.InvokeMember(ob, string.Format("{0}{1}", ReflectionConstants.DataSource, ReflectionConstants.UNSelected), null, EnumConstants.GetProperty)); } GMReflectionUtils.InvokeProperty(c, ReflectionConstants.Value, new object[] { GMReflectionUtils.InvokeMember(ob, spropname, null, EnumConstants.GetProperty) }); } else if (isgetctl && isbaseuc) { GMReflectionUtils.InvokeProperty(ob, spropname, new object[] { GMReflectionUtils.InvokeMember(c, ReflectionConstants.Value, null, EnumConstants.GetProperty) }); } } catch (EndUserException ex) { Logger.LogMessage(ex.Message); throw ex; } catch (Exception ex) { Logger.LogMessage(ex.Message); } } } if (!isbaseuc && c.Controls.Count > 0) { ManageValues(c.Controls, instances, isgetctl); } } }
private void ValidateUser(Int16 PasswordAttempt, string returnURL) { AuthenticationUB auth = new AuthenticationUB(); DCUser2 dcuser = null; try { dcuser = auth.AuthenticateUser(this.Page.Session.SessionID, txtUserID.Value, txtPassword.Value, PasswordAttempt); GMReflectionUtils.InvokeMember(this.Page, ReflectionConstants.ValidateToken, new object[] { dcuser, txtUserID.Value, returnURL }, EnumConstants.InvokeMethod); } catch (Exception ex) { throw ex; } finally { auth = null; dcuser = null; } }
protected void DisableControls(ControlCollection cc) { foreach (Control c in cc) { try { if (c.HasControls()) { DisableControls(c.Controls); } else { GMReflectionUtils.InvokeProperty(c, ReflectionConstants.Enabled, new object[] { false }); } } catch { } } }
private void ProcessCall(string ns, HttpContext context) { try { Type nstype = Assembly.Load(ns.Substring(0, ns.LastIndexOf(GeneralConstants.DotOperator))).GetType(ns); string callmethod = context.Request.Form[QueryStringConstants.MethodAjax]; if (callmethod == null) { return; } MethodInfo mdinfo = nstype.GetMethod(callmethod); if (mdinfo == null) { return; } object[] args = new object[mdinfo.GetParameters().Length]; object param = null; string value = string.Empty; int i = 0; foreach (ParameterInfo pInfo in mdinfo.GetParameters()) { param = null; value = context.Request.Form[string.Format("{0}{1}", QueryStringConstants.ArgumentsAjax, i)]; if (value != null) { param = Convert.ChangeType(value, pInfo.ParameterType); } args[i] = param; ++i; } dynamic val = mdinfo.Invoke(GMReflectionUtils.GetInstance(ns), args); if (val != null) { context.Response.Write(val); context.Response.Flush(); } } catch (Exception exp) { Logger.LogException(exp, ns); } }
BaseDC GetDCInstance() { Handler hr = GMReflectionUtils.GetHandler <Handler>(this.GetType()); return((BaseDC)GMReflectionUtils.GetInstance(hr.TypeH)); }
protected void DisplayError(string errmsg) { GMReflectionUtils.InvokeMember(this.Master, ReflectionConstants.MasterDisplayError, new object[] { errmsg }, EnumConstants.InvokeMethod); }
public static void BindTwolist(dynamic ctl, dynamic selected, dynamic unselected) { BindList(GMReflectionUtils.InvokeMember(ctl, ReflectionConstants.SelectedInstance, null, EnumConstants.GetProperty), selected); BindList(GMReflectionUtils.InvokeMember(ctl, ReflectionConstants.UnSelectedInstance, null, EnumConstants.GetProperty), unselected); }
public BasePage() { m_authub = GMReflectionUtils.GetInstance(UIBinderHandlerConstants.AuthenticationUB); }
protected bool HasPermission(Permission pn) { return(GMReflectionUtils.InvokeMember(m_authub, ReflectionConstants.HasPermission, new object[] { pn })); }
public bool HasToken() { return(Request.Cookies[System.Web.Security.FormsAuthentication.FormsCookieName] != null && GMReflectionUtils.InvokeMember(m_authub, ReflectionConstants.HasToken, new object[] { this.SessionID })); }