示例#1
0
        public string Log(string username, string pass)
        {
            //from android comes like this - ?-360
            CallContext resultContext = new UserBL().Login(username, pass, null);
            UserProps userProps = new UserProps();

            if (resultContext.ResultCode == ETEMEnums.ResultEnum.Success)
            {

                User currentUser = new UserBL().GetUserByUserID(resultContext.EntityID);

                if (currentUser != null)
                {

                    Person person = new PersonBL().GetPersonByPersonID(currentUser.idPerson.ToString());
                    userProps.PersonNamePlusTitle = person.FullNamePlusTitle;
                    userProps.PersonNameNoTitle = person.FullName;
                    userProps.PersonTwoNamePlusTitle = person.TwoNamesPlusTitle;
                    userProps.PersonID = person.idPerson.ToString();

                    userProps.LoginDateTime = DateTime.Now;
                    
                    
                    
                    userProps.idStudent = Constants.INVALID_ID;

                }

            }

            var jsonSerialiser = new JavaScriptSerializer();
            var json = jsonSerialiser.Serialize(userProps);

            return json;
        }
示例#2
0
        public UserProps MakeLoginByUserID(string UserID)
        {
            UserProps userProps = new UserProps();

            ETEMModel.Models.User currentUser = AdminClientRef.GetUserByUserID(UserID);

            if (currentUser != null)
            {
                userProps.Roles = AdminClientRef.GetAllRolesByUser(currentUser.idUser.ToString(), null, null);

                for (int i = 0; i < userProps.Roles.Count; i++)
                {
                    List <int> currentRolePermmitedActionsIds = AdminClientRef.
                                                                GetAllPermittedActionsByRole(userProps.Roles[i].idRole.ToString(), null, null)
                                                                .Select(r => r.idPermittedAction).ToList();
                    for (int j = 0; j < currentRolePermmitedActionsIds.Count; j++)
                    {
                        bool isDuplicate = userProps.ListUserPermittedActionsID.Any(p => p == currentRolePermmitedActionsIds[j]);
                        if (!isDuplicate)
                        {
                            userProps.ListUserPermittedActionsID.Add(currentRolePermmitedActionsIds[j]);
                        }
                    }
                }

                //userProps.ListUserPermittedActionsID = AdminClientRef.getallp
                userProps.IdUser   = currentUser.idUser.ToString();
                userProps.UserName = currentUser.UserName;

                Person person = this.AdminClientRef.GetPersonByPersonID(currentUser.idPerson.ToString());
                userProps.PersonNamePlusTitle    = person.FullNamePlusTitle;
                userProps.PersonNameNoTitle      = person.FullName;
                userProps.PersonNameAndFamily    = person.FullNameTwo;
                userProps.PersonTwoNamePlusTitle = person.TwoNamesPlusTitle;
                userProps.PersonID      = person.idPerson.ToString();
                userProps.SessionID     = this.Session.SessionID;
                userProps.IPAddress     = Request.UserHostAddress;
                userProps.LoginDateTime = DateTime.Now;
                this.Session.Timeout    = Convert.ToInt32(BasicPage.GetValueFromWebConfig("SessionTimeOut"));
                userProps.idStudent     = Constants.INVALID_ID;

                userProps.IsCheckDomain = currentUser.idCheckDomain == GetKeyValueByIntCode("YES_NO", "Yes").idKeyValue;
                userProps.IsKilled      = false;

                this.Session.Add(ETEMModel.Helpers.Constants.SESSION_USER_PROPERTIES, userProps);
                this.Session.Timeout = Int32.Parse(GetSettingByCode(ETEMEnums.AppSettings.WebSessionTimeOut).SettingValue);

                Dictionary <string, HttpSessionState> sessionData =
                    (Dictionary <string, HttpSessionState>)Application[Constants.APPLICATION_ALL_SESSIONS];

                if (sessionData.Keys.Contains(HttpContext.Current.Session.SessionID))
                {
                    sessionData.Remove(HttpContext.Current.Session.SessionID);
                    sessionData.Add(HttpContext.Current.Session.SessionID, HttpContext.Current.Session);
                }
            }

            return(userProps);
        }
示例#3
0
        protected List <UserProps> GetOnlineUsers()
        {
            List <UserProps> activeSessions = new List <UserProps>();


            #region OLD Version


            try
            {
                foreach (var ses in GetActiveSessions().ToList())
                {
                    UserProps up = ses["USER_PROPERTIES"] as UserProps;

                    if (up != null)
                    {
                        activeSessions.Add(up);
                    }
                }

                LogDebug("Load GetActiveSessions from CacheInternal");
            }
            catch
            {
                Dictionary <string, HttpSessionState> sessionData =
                    (Dictionary <string, HttpSessionState>)Application[Constants.APPLICATION_ALL_SESSIONS];


                foreach (var session in sessionData)
                {
                    HttpSessionState sessionState = (HttpSessionState)session.Value;

                    if (sessionState["USER_PROPERTIES"] != null)
                    {
                        UserProps userProps = sessionState["USER_PROPERTIES"] as UserProps;
                        if (userProps != null)
                        {
                            activeSessions.Add(userProps);
                        }
                    }
                }

                LogDebug("Load GetActiveSessions from APPLICATION_ALL_SESSIONS");
            }


            #endregion



            return(activeSessions);
        }
示例#4
0
        /// <summary>
        /// Върща системат информация на потребителя
        /// IP, Сесия, Име на потребител и т.н
        /// </summary>
        /// <returns></returns>
        private static string GetUserSystemInfo()
        {
            StringBuilder result = new StringBuilder();

            try
            {
                result.Append("\tIP:");
                if (CurrentHttpContext != null && CurrentHttpContext.Request != null && CurrentHttpContext.Request.UserHostAddress != null)
                {
                    result.Append(CurrentHttpContext.Request.UserHostAddress);
                }
                else
                {
                    result.Append("none");
                }

                result.Append("\tInternal IP:" + GetIPAddress());


                result.Append("\tSessionID:");
                if (CurrentHttpContext.Session != null)
                {
                    result.Append(CurrentHttpContext.Session.SessionID);
                }
                else
                {
                    result.Append("none");
                }


                UserProps userProps = CurrentHttpContext.Session[ETEMModel.Helpers.Constants.SESSION_USER_PROPERTIES] as UserProps;
                if (userProps != null)
                {
                    result.Append("\tUserName:"******"\tPersonName:");
                    result.Append(userProps.PersonNamePlusTitle);
                }
                else
                {
                    result.Append("\tUserName:"******"none");
                    result.Append("\tPersonName:");
                    result.Append("none");
                }
            }
            catch { }



            return(result.ToString());
        }
示例#5
0
        protected void btnLoginAS_Click(object sender, EventArgs e)
        {
            BasicPage currentPage = this.Page as BasicPage;
            currentPage.MakeLoginByUserID(this.hdnRowMasterKey.Value);
            UserProps userProps = new UserProps();

            BasicPage.LogDebug("Потребител " + userProps.UserName + " влезе в системата");

            Response.Redirect(Welcome.formResource.PagePath);
        }
示例#6
0
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);



            ///Страници, които не изискват login
            if (
                this.UserProps == null &&

                this.CurrentPageFullName() != Share.Login.formResource.PageFullName

                )
            {
                Response.Redirect(Share.Login.formResource.PagePath);
            }


            UserProps userProps = GetOnlineUsers().Where(s => s.SessionID == this.Session.SessionID).FirstOrDefault() as UserProps;

            if (userProps != null && userProps.IsKilled)
            {
                Session.RemoveAll();
                Session.Abandon();
                Response.Redirect(Share.Login.formResource.PagePath);
            }


            if (userProps != null && CurrentPagePath() != OnlineUsersList.formResource.PagePath)
            {
                userProps.LastPageName = CurrentPagePath();

                ModuleDataView module = DictionaryModules.Where(m => m.Key == CurrentModule()).FirstOrDefault().Value;

                MenuNodeDataView node = null;

                if (FormContext.QueryString["Node"] != null)
                {
                    node = DictionaryMenuNodes.Where(m => m.Key == FormContext.QueryString["Node"].ToString()).FirstOrDefault().Value;
                }

                if (module != null)
                {
                    userProps.LastModuleName = module.ModuleName;
                }

                if (node != null)
                {
                    userProps.LastPageName = node.name;
                }
            }

            #region filter by ip



            this.currentModuleObject = this.AdminClientRef.GetModuleBySysName(this.CurrentModule());

            if (this.CurrentPageFullName() != Share.Login.formResource.PageFullName &&
                this.currentModuleObject != null &&
                this.currentModuleObject.NeedCheck && !Request.UserHostAddress.Equals("::1"))
            {
                AllowIP allowIP = this.AdminClientRef.GetEntityByIPAddress(Request.UserHostAddress);

                if (allowIP == null || !allowIP.Allow)
                {
                    Response.Redirect("~/UI/InternalPageInfo.aspx");
                }
            }

            #endregion

            #region filter by modules

            List <string> listPermittedModules = new List <string>()
            {
                Constants.MODULE_NOMENCLATURES,
                Constants.MODULE_SUPPORT_HISTORY,
                Constants.MODULE_SETTINGS,
                Constants.MODULE_PERMISSION,
                Constants.MODULE_INOUTDOCUMENT,
            };

            if (this.CurrentPageFullName() != Share.Login.formResource.PageFullName &&

                currentModuleObject != null && this.UserProps.Roles.Any(a => a.Name == "VIEW") &&
                listPermittedModules.Any(s => s == currentModuleObject.ModuleSysName))
            {
                Response.Redirect("~/UI/InternalPageInfo.aspx");
            }


            #endregion


            if (!IsPostBack)
            {
                InitReloadParentPageControl();
            }

            AjaxControlToolkit.ToolkitScriptManager.RegisterClientScriptBlock(this,
                                                                              this.GetType(),
                                                                              "IsNumeric",
                                                                              BaseHelper.JS_SCRIPT_IS_NUMERIC,
                                                                              false);
        }
示例#7
0
        public UserProps MakeLoginByUserID(string UserID)
        {
            UserProps userProps = new UserProps();

            ETEMModel.Models.User currentUser = AdminClientRef.GetUserByUserID(UserID);

            if (currentUser != null)
            {
                userProps.Roles = AdminClientRef.GetAllRolesByUser(currentUser.idUser.ToString(), null, null);

                for (int i = 0; i < userProps.Roles.Count; i++)
                {
                    List<int> currentRolePermmitedActionsIds = AdminClientRef.
                                                               GetAllPermittedActionsByRole(userProps.Roles[i].idRole.ToString(), null, null)
                                                               .Select(r => r.idPermittedAction).ToList();
                    for (int j = 0; j < currentRolePermmitedActionsIds.Count; j++)
                    {
                        bool isDuplicate = userProps.ListUserPermittedActionsID.Any(p => p == currentRolePermmitedActionsIds[j]);
                        if (!isDuplicate)
                        {
                            userProps.ListUserPermittedActionsID.Add(currentRolePermmitedActionsIds[j]);
                        }
                    }
                }

                //userProps.ListUserPermittedActionsID = AdminClientRef.getallp
                userProps.IdUser = currentUser.idUser.ToString();
                userProps.UserName = currentUser.UserName;

                Person person = this.AdminClientRef.GetPersonByPersonID(currentUser.idPerson.ToString());
                userProps.PersonNamePlusTitle = person.FullNamePlusTitle;
                userProps.PersonNameNoTitle = person.FullName;
                userProps.PersonNameAndFamily = person.FullNameTwo;
                userProps.PersonTwoNamePlusTitle = person.TwoNamesPlusTitle;
                userProps.PersonID = person.idPerson.ToString();
                userProps.SessionID = this.Session.SessionID;
                userProps.IPAddress = Request.UserHostAddress;
                userProps.LoginDateTime = DateTime.Now;
                this.Session.Timeout = Convert.ToInt32(BasicPage.GetValueFromWebConfig("SessionTimeOut"));
                userProps.idStudent =  Constants.INVALID_ID;

                userProps.IsCheckDomain = currentUser.idCheckDomain == GetKeyValueByIntCode("YES_NO", "Yes").idKeyValue;
                userProps.IsKilled = false;

                this.Session.Add(ETEMModel.Helpers.Constants.SESSION_USER_PROPERTIES, userProps);
                this.Session.Timeout = Int32.Parse(GetSettingByCode(ETEMEnums.AppSettings.WebSessionTimeOut).SettingValue);

                Dictionary<string, HttpSessionState> sessionData =
                    (Dictionary<string, HttpSessionState>)Application[Constants.APPLICATION_ALL_SESSIONS];

                if (sessionData.Keys.Contains(HttpContext.Current.Session.SessionID))
                {
                    sessionData.Remove(HttpContext.Current.Session.SessionID);
                    sessionData.Add(HttpContext.Current.Session.SessionID, HttpContext.Current.Session);
                }
            }

            return userProps;
        }