/// <summary>
        /// 그리드의 Item 중 선택된 항목의 dataKey ("Id" 또는 "Code") 값을 추출해서, 해당 엔티티를 삭제합니다.
        /// </summary>
        protected virtual void DoRemoveEntity(string dataKey)
        {
            var idsToRemove = new List <object>();

            foreach (GridDataItem item in EntityGrid.SelectedItems)
            {
                if (item.ItemIndex >= 0)
                {
                    var id = item.OwnerTableView.DataKeyValues[item.ItemIndex][dataKey].AsText();
                    if (id.IsNotWhiteSpace())
                    {
                        idsToRemove.Add(id);
                    }
                }
            }

            if (idsToRemove.Count == 0)
            {
                WebAppTool.MessageBox(@"삭제할 엔티티를 선택하세요.", this);
                return;
            }

            RemoveEntitiesById(idsToRemove);
            LoadAndBindEntity(null);
        }
示例#2
0
        /// <summary>
        ///  엔티티를 로드하고, IRadTreeNodeContainer에 자식노드로 추가한다.
        /// </summary>
        /// <param name="node">선택된 IRadTreeNodeContainer</param>
        /// <param name="exceptionAction">예외발생 시 수행할 Action</param>
        protected virtual void LoadAndAddEntity(IRadTreeNodeContainer node, Action <Exception> exceptionAction)
        {
            if (IsDebugEnabled)
            {
                log.Debug(@"==>S 엔티티[{0}] 목록을 로드하여, TreeView에 바인딩 시킵니다...", ConcreteType.Name);
            }

            node.ShouldNotBeNull("선택된 IRadTreeNodeContainer정보가 없습니다.");

            try
            {
                LoadEntity(node);
                AddEntity(node);
            }
            catch (Exception ex)
            {
                var errorMsg = string.Format(@"엔티티[{0}]를 로드하고, Binding 시에 예외가 발생했습니다.", ConcreteType.Name);

                if (log.IsErrorEnabled)
                {
                    log.ErrorException(errorMsg, ex);
                }

                if (exceptionAction != null)
                {
                    exceptionAction(ex);
                }
                else
                {
                    WebAppTool.MessageBox(errorMsg, this);
                }
            }
        }
        /// <summary>
        ///  엔티티를 로드하고, UI Control에 바인딩 합니다.
        /// </summary>
        /// <param name="exceptionAction">예외발생 시 수행할 Action</param>
        public virtual void LoadAndBindEntity(Action <Exception> exceptionAction)
        {
            if (IsDebugEnabled)
            {
                log.Debug(@"엔티티[{0}] 목록을 로드하여, Grid에 바인딩 시킵니다...", ConcreteType.Name);
            }
            try
            {
                LoadEntity();
                BindEntity();
            }
            catch (Exception ex)
            {
                var errorMsg = string.Format(@"엔티티[{0}]를 로드하고, Binding 시에 예외가 발생했습니다.", ConcreteType.Name);

                if (log.IsErrorEnabled)
                {
                    log.ErrorException(errorMsg, ex);
                }

                if (exceptionAction != null)
                {
                    exceptionAction(ex);
                }
                else
                {
                    WebAppTool.MessageBox(errorMsg, this);
                }
            }
        }
示例#4
0
        /// <summary>
        /// 로그인 페이지로 이동
        /// </summary>
        /// <param name="endReponse">프로세스 종료</param>
        public virtual void RedirectToLoginPage(bool endReponse)
        {
            if (log.IsDebugEnabled)
            {
                log.Debug("==>>S 로그인 페이지로 이동작업을 시작합니다.");
            }

            var returnPathAndQuery = HttpContext.Current.Request.RawUrl == WebAppTool.ResolveUrl(AppSettings.LogoutUrl)
                                         ? AppSettings.DefaultUrl
                                         : HttpContext.Current.Request.Url.PathAndQuery;

            string url = WebAppTool.UrlParamConcat(LoginUrl, string.Format("ReturnUrl=[{0}]", returnPathAndQuery.UrlEncode()));

            if (log.IsDebugEnabled)
            {
                log.Debug("{0}로 이동합니다.", url);
            }

            HttpContext.Current.Response.Redirect(url, endReponse);

            if (log.IsDebugEnabled)
            {
                log.Debug("==>>E 로그인 페이지로 이동작업을 완료합니다.");
            }
        }
示例#5
0
        /// <summary>
        /// 로그인 처리한다.
        /// </summary>
        /// <param name="userName">로그인Id</param>
        public virtual void ProcessingLogin(string userName)
        {
            if (log.IsDebugEnabled)
            {
                log.Debug("==>>S 로그인 처리합니다. enterpriseName:{0}, userName:{1}",
                          AppSettings.EnterpriseName, userName);
            }

            var identity = AppSettings.Impersonate ? CreateIdentityAsImpersonate(userName) : CreateIdentity(userName);

            if (identity == null)
            {
                throw new InvalidOperationException(WebAppTool.GetGlobalResourceString(AppSettings.ResourceMessages,
                                                                                       "NotExistLoginInfo", "로그인 정보가 없습니다."));
            }

            SetIdentity(identity);
            SetAuthData(identity.LoginId);

            if (log.IsDebugEnabled)
            {
                log.Debug("==>>E 로그인 처리하였습니다. enterpriseName:{0}, userName:{1}",
                          AppSettings.EnterpriseName, userName);
            }
        }
示例#6
0
        /// <summary>
        /// 로그인 처리한다.
        /// </summary>
        /// <param name="userName">로그인Id</param>
        /// <param name="password">비밀번호</param>
        public virtual void ProcessingLogin(string userName, string password)
        {
            if (log.IsDebugEnabled)
            {
                log.Debug("==>>S 로그인 처리합니다. enterpriseName:{0}, userName:{1}, password:{2}",
                          AppSettings.EnterpriseName, userName, password);
            }

            if (AppSettings.Impersonate == false)
            {
                bool isVerified = VerifyUser(userName, password);

                if (isVerified == false)
                {
                    throw new InvalidOperationException(WebAppTool.GetGlobalResourceString(
                                                            AppSettings.ResourceMessages,
                                                            "LoginDifferentInfo", "로그인 정보가 일치하지 않습니다."));
                }
            }

            var identity = AppSettings.Impersonate ? CreateIdentityAsImpersonate(userName) : CreateIdentity(userName);

            SetIdentity(identity);
            SetAuthData(identity.LoginId);

            if (log.IsDebugEnabled)
            {
                log.Debug("==>>E 로그인 처리하였습니다. enterpriseName:{0}, userName:{1}, password:{2}",
                          AppSettings.EnterpriseName, userName, password);
            }
        }
示例#7
0
        /// <summary>
        /// 상태 메시지 출력
        /// </summary>
        protected static string GetStatusMessage(int offset, int total)
        {
            if (total > 0)
            {
                return(string.Format(WebAppTool.GetGlobalResourceString(AppSettings.ResourceMessages, "Msg_Query_Items_Item"), total, offset + 1));
            }

            return(WebAppTool.GetGlobalResourceString(AppSettings.ResourceMessages, "Msg_Query_Items_NoItem"));
        }
        /// <summary>
        /// Grid를 정렬합니다.
        /// </summary>
        protected virtual void DoGridSortCommand(string sortExpression, bool?sortAscending)
        {
            GridSortExpr = sortExpression;
            GridSortAsc  = sortAscending.GetValueOrDefault(true);

            if (IsDebugEnabled)
            {
                log.Debug(@"EntityGrid의 정렬을 수행합니다. GridSortExpr={0}, GridSortAsc={1}", GridSortExpr, GridSortAsc);
            }

            LoadAndBindEntity(ex => WebAppTool.MessageBox(@"정렬을 수행하는 중에 예외가 발생했습니다.", this));
        }
        /// <summary>
        /// 검색 작업 시
        /// </summary>
        /// <param name="key"></param>
        /// <param name="value"></param>
        protected virtual void DoSearchEntity(string key, object value)
        {
            if (IsDebugEnabled)
            {
                log.Debug(@"엔티티를 조회하려고 합니다. key={0}, value={1}", key, value);
            }

            SearchKey   = key;
            SearchValue = value.AsText();

            ResetPageIndex(0);
            LoadAndBindEntity(ex => WebAppTool.MessageBox(@"검색 시 예외가 발생했습니다. message=" + ex.Message, this));
        }
示例#10
0
 /// <summary>
 /// 사용자 인증정보인 Identity에 사용자 객체 정보를 지운다.
 /// </summary>
 protected virtual void ClearIdentity()
 {
     if (WebTool.IsWebContext)
     {
         HttpContext.Current.User = null;
         WebAppTool.DeleteValue(ApplicationKey);
     }
     else
     {
         Thread.CurrentPrincipal    = null;
         Local.Data[ApplicationKey] = null;
     }
 }
示例#11
0
        /// <summary>
        /// 로그인 처리
        /// </summary>
        /// <returns>로그인 성공여부</returns>
        protected virtual bool LoginProcess()
        {
            if (IsDebugEnabled)
            {
                log.Debug("로그인 사용자 정보:{0}", WebAppContext.Current.Identity);
            }

            if (WebAppContext.Current.Identity != null || AppSettings.Impersonate)
            {
                WebAppContext.Services.Authentication.Login();
            }
            else
            {
                WebAppContext.Services.Authentication.RedirectToLoginPage(false);

                string currentPath = Request.Path;

                //로그인 Url이 없거나 요청페이지와 로그인 페이지가 동일하다면
                if ((string.IsNullOrEmpty(WebAppContext.Services.Authentication.LoginUrl)) || (WebAppContext.Services.Authentication.LoginUrl.IndexOf(currentPath) == 0))
                {
                    var msgt = WebAppTool.GetGlobalResourceString(AppSettings.ResourceGlossary, "LoginFailed", "로그인 실패");
                    var msg  = WebAppTool.GetGlobalResourceString(AppSettings.ResourceMessages, "NotExistLoginInfo", "로그인 정보가 없습니다");

                    WebAppTool.MessageBox(MessageBoxDisplayKind.Page,
                                          msgt,
                                          msg,
                                          MessageType.Warning,
                                          MessageButtons.Ok | MessageButtons.Login,
                                          endResponse: false);
                }
                else
                {
                    WebAppContext.Services.Authentication.RedirectToLoginPage(false);
                }
            }

            var isLoggined = WebAppContext.Current.Identity != null;

            if (IsDebugEnabled)
            {
                log.Debug("로그인 사용자 정보:{0}, 로그인 성공여부=[{1}]", WebAppContext.Current.Identity, isLoggined);
            }

            return(isLoggined);
        }
            /// <summary>
            /// Current를 셋팅한다.
            /// </summary>
            /// <param name="identity"></param>
            public static void SetCurrent(IAccessIdentity identity)
            {
                if (log.IsDebugEnabled)
                {
                    log.Debug("접속정보를 할당합니다. identity=[{0}]", identity);
                }

                identity.ShouldNotBeNull("identity");

                Identity = identity;

                ThemeName = WebAppTool.LoadValue(AppSettings.ApplicationName + @"_" + CurrentThemeKey, AppSettings.DefaultThemeAssemblyName);

                var principal = Services.Authentication.CreatePrincipal(Services.Authentication.Identity);

                if (Local.IsInWebContext)
                {
                    HttpContext.Current.User = principal;
                }
                Thread.CurrentPrincipal = principal;
            }
示例#13
0
        /// <summary>
        /// 기본 페이지로 이동
        /// </summary>
        /// <param name="endReponse">프로세스 종료</param>
        public virtual void RedirectToDefaultPage(bool endReponse)
        {
            if (log.IsDebugEnabled)
            {
                log.Debug("기본 페이지로 이동작업을 시작합니다...");
            }

            string currentPathAndQuery = HttpContext.Current.Request.Url.PathAndQuery;
            string url = WebAppTool.UrlParamConcat(DefaultUrl, currentPathAndQuery.UrlEncode());

            if (log.IsDebugEnabled)
            {
                log.Debug("페이지 이동... url=[{0}]", url);
            }

            HttpContext.Current.Response.Redirect(url, endReponse);

            if (log.IsDebugEnabled)
            {
                log.Debug("기본 페이지로 이동작업을 완료합니다.");
            }
        }
示例#14
0
        private bool CheckUserLogin()
        {
            bool isResponseEnd;

            try
            {
                isResponseEnd = LoginProcess() == false;

                //인증정보가 있다면 접권권한 체크
                if ((WebAppContext.Current.Identity != null) && (!string.IsNullOrEmpty(WebAppContext.Current.Identity.LoginId)))
                {
                    if (log.IsDebugEnabled)
                    {
                        log.Debug("접속자 정보. LoginId=" + WebAppContext.Current.Identity.LoginId);
                    }

                    if (IsPostBack == false && CanAccess == false)
                    {
                        WebAppTool.ShowMessageOfAccessDenied();
                        isResponseEnd = true;
                    }
                }
            }
            catch (Exception ex)
            {
                if (log.IsErrorEnabled)
                {
                    log.ErrorException(@"페이지 로드중 오류가 발생하였습니다.", ex);
                }

                WebAppTool.ShowMessageOfLoginFail();
                isResponseEnd = true;
            }

            return(isResponseEnd);
        }
示例#15
0
        /// <summary>
        /// 사용자 인증정보인 Identity에 사용자 객체 정보를 채운다.
        /// </summary>
        protected virtual void SetIdentity(IAccessIdentity rwIdentity)
        {
            WebAppContext.Current.SetCurrent(rwIdentity);

            WebAppTool.SetValue(ApplicationKey, rwIdentity, DateTime.MinValue, string.Empty);
        }