Esempio n. 1
0
        public static Task Start(HttpContext context)
        {
            IUserInfo     info       = BaseGlobalVariable.Current.UserInfo;
            WebAppSetting appSetting = WebAppSetting.WebCurrent;

            string url;

            if (info.IsLogOn)
            {
                if (string.IsNullOrEmpty(appSetting.MainPath))
                {
                    url = appSetting.HomePath;
                }
                else
                {
                    url = HttpUtility.UrlEncode(AppUtil.ResolveUrl(appSetting.HomePath));
                    url = UriUtil.AppendQueryString(appSetting.MainPath, "StartUrl=" + url);
                }
            }
            else
            {
                url = appSetting.StartupPath;
            }
            url = AppUtil.ResolveUrl(url);
            context.Response.Redirect(url);

            return(Task.FromResult(0));
        }
Esempio n. 2
0
 private void CreateContent(OperatorConfig config, object source, IInputData input, string queryString)
 {
     if (config.Content != null)
     {
         Content = Expression.Execute(config.Content, source);
         if (config.UseKey)
         {
             Content = UriUtil.AppendQueryString(Content, queryString);
         }
     }
     else
     {
         //string sourceStr = input.SourceInfo.CcSource;
         //if (Info != null)
         //{
         //    if (Info.Contains(RightConst.INSERT))
         //        Content = string.Format(ObjectUtil.SysCulture,
         //            "insert/{0}.c", sourceStr).AppVirutalPath();
         //    else if (Info.Contains(RightConst.UPDATE))
         //        Content = string.Format(ObjectUtil.SysCulture,
         //            "update/{0}.c?{1}", sourceStr, queryString).AppVirutalPath();
         //    else if (Info.Contains(RightConst.DELETE))
         //        Content = string.Format(ObjectUtil.SysCulture,
         //            "delete/{0}.c?{1}", sourceStr, queryString).AppVirutalPath();
         //}
         string sourceStr = input.SourceInfo.Source;
         if (Info != null)
         {
             if (Info.Contains(RightConst.INSERT))
             {
                 Content = string.Format(ObjectUtil.SysCulture,
                                         "c/xml/insert/{0}", sourceStr).AppVirutalPath();
             }
             else if (Info.Contains(RightConst.UPDATE))
             {
                 Content = string.Format(ObjectUtil.SysCulture,
                                         "c/xml/update/{0}?{1}", sourceStr, queryString).AppVirutalPath();
             }
             else if (Info.Contains(RightConst.DELETE))
             {
                 Content = string.Format(ObjectUtil.SysCulture,
                                         "c/xml/delete/{0}?{1}", sourceStr, queryString).AppVirutalPath();
             }
         }
     }
     if (config.DialogTitle == null)
     {
         DialogTitle = Caption;
     }
     else
     {
         DialogTitle = Expression.Execute(config.DialogTitle, source);
     }
 }
Esempio n. 3
0
        public OutputData Insert(IInputData input, object instance)
        {
            LogOnData data = instance.Convert <LogOnData>();

            using (UserResolver resolver = new UserResolver(this))
            {
                IUserInfo userInfo = resolver.CheckUserLogOn(data.LogOnName, data.Password, 0);
                if (userInfo == null)
                {
                }

                var           response = WebGlobalVariable.Response;
                CookieOptions options  = new CookieOptions
                {
                    Expires = new DateTimeOffset(DateTime.Now.AddDays(30))
                };
                response.Cookies.Append(COOKIE_NAME, data.LogOnName, options);
                options = new CookieOptions
                {
                    Expires = new DateTimeOffset(JWTUtil.CalcValidTime())
                };
                string token = JWTUtil.CreateEncodingInfo(userInfo);
                response.Cookies.Append(JWTUtil.COOKIE_NAME, token, options);
                //CookieUserInfo cookieInfo = new CookieUserInfo(data, userInfo);
                //cookie = new HttpCookie(RightConst.USER_INFO_COOKIE_NAME, cookieInfo.Encode())
                //{
                //    Expires = GetExpireDate()
                //};
                //response.Cookies.Set(cookie);

                WebSuccessResult result;
                string           retUrl = input.QueryString["RetURL"];
                if (!string.IsNullOrEmpty(retUrl))
                {
                    result = new WebSuccessResult(retUrl);
                }
                else
                {
                    WebAppSetting appSetting = WebAppSetting.WebCurrent;
                    if (string.IsNullOrEmpty(appSetting.MainPath))
                    {
                        result = new WebSuccessResult(appSetting.HomePath);
                    }
                    else
                    {
                        string url     = HttpUtility.UrlEncode(appSetting.HomePath);
                        string mainUrl = UriUtil.AppendQueryString(appSetting.MainPath, "StartUrl=" + url);
                        result = new WebSuccessResult(mainUrl);
                    }
                }

                return(OutputData.CreateToolkitObject(result));
            }
        }
Esempio n. 4
0
        public override void CheckLogOn(object userId, Uri url)
        {
            string logOnPage = WebAppSetting.WebCurrent.LogOnPath;

            if (!string.IsNullOrEmpty(logOnPage) && !BaseGlobalVariable.Current.UserInfo.IsLogOn)
            {
                logOnPage = UriUtil.AppendQueryString(logOnPage,
                                                      "RetUrl=" + HttpUtility.UrlEncode(url.ToString()));
                throw new RedirectException(logOnPage);
            }
        }
Esempio n. 5
0
        public OutputData Insert(IInputData input, object instance)
        {
            LogOnData data = instance.Convert <LogOnData>();

            using (UserResolver resolver = new UserResolver(this))
            {
                IUserInfo userInfo = resolver.CheckUserLogOn(data.LogOnName, data.Password, 0);
                if (userInfo == null)
                {
                }
                WebGlobalVariable.SessionGbl.AppRight.Initialize(userInfo);

                var        response = WebGlobalVariable.Response;
                HttpCookie cookie   = new HttpCookie(COOKIE_NAME, data.LogOnName)
                {
                    Expires = DateTime.Now.AddDays(30)
                };
                response.Cookies.Set(cookie);
                CookieUserInfo cookieInfo = new CookieUserInfo(data, userInfo);
                cookie = new HttpCookie(RightConst.USER_INFO_COOKIE_NAME, cookieInfo.Encode())
                {
                    Expires = GetExpireDate()
                };
                response.Cookies.Set(cookie);

                WebSuccessResult result;
                var    request = WebGlobalVariable.Request;
                string retUrl  = request.QueryString["RetURL"];
                if (!string.IsNullOrEmpty(retUrl))
                {
                    result = new WebSuccessResult(retUrl);
                }
                else
                {
                    WebAppSetting appSetting = WebAppSetting.WebCurrent;
                    if (string.IsNullOrEmpty(appSetting.MainPath))
                    {
                        result = new WebSuccessResult(appSetting.HomePath);
                    }
                    else
                    {
                        string url     = HttpUtility.UrlEncode(appSetting.HomePath);
                        string mainUrl = UriUtil.AppendQueryString(appSetting.MainPath, "StartUrl=" + url);
                        result = new WebSuccessResult(mainUrl);
                    }
                }

                return(OutputData.CreateToolkitObject(result));
            }
        }
Esempio n. 6
0
        public OutputData DoAction(IInputData input)
        {
            IUserInfo userInfo = BaseGlobalVariable.Current.UserInfo;

            Dictionary <string, string> result = new Dictionary <string, string>();
            string mainPage = WebAppSetting.WebCurrent.MainPath;

            result["Menu"]     = WebGlobalVariable.SessionGbl.AppRight.CreateMenu(userInfo);
            result["UserName"] = userInfo.UserName;
            result["StartUrl"] = WebUtil.ResolveUrl(input.QueryString["StartUrl"]);
            result["HomeUrl"]  = WebUtil.ResolveUrl(UriUtil.AppendQueryString(mainPage, "StartUrl="
                                                                              + HttpUtility.UrlEncode(WebAppSetting.WebCurrent.HomePath)));
            result["FullName"]  = WebAppSetting.WebCurrent.AppFullName;
            result["ShortName"] = WebAppSetting.WebCurrent.AppShortName;

            return(OutputData.CreateObject(result));
        }
Esempio n. 7
0
        protected override string GetDefaultUrl(ISource source, IPageData pageData, OutputData outputData)
        {
            string  url     = string.Empty;
            KeyData keyData = outputData.Data.Convert <KeyData>();

            //string pageSource = pageData.SourceInfo.Source;
            switch (DestUrl)
            {
            case PageStyle.Custom:
                TkDebug.AssertNotNull(CustomUrl,
                                      "配置了DestUrl为Custom,却没有配置CustomUrl", this);
                url = Expression.Execute(CustomUrl, source);
                url = AppUtil.ResolveUrl(url);
                if (CustomUrl.UseKeyData)
                {
                    url = UriUtil.AppendQueryString(url, keyData.ToString());
                }
                break;

            case PageStyle.Insert:
            case PageStyle.Update:
            case PageStyle.Delete:
                url = WebUtil.GetTemplateUrl(DestUrl, pageData);
                url = UriUtil.AppendQueryString(url, keyData.ToString()).AppVirutalPath();
                break;

            case PageStyle.Detail:
            case PageStyle.List:
                string initValue = keyData.IsSingleValue ? keyData.SingleValue : string.Empty;
                url = WebUtil.GetTemplateUrl((PageStyleClass)string.Empty, pageData);
                url = UriUtil.AppendQueryString(url, "InitValue=" + initValue).AppVirutalPath();
                break;

            default:
                TkDebug.ThrowImpossibleCode(this);
                break;
            }

            return(url);
        }
Esempio n. 8
0
        private static Uri GetDefaultStyleUrl(PageStyle style, IPageData input)
        {
            string result;
            string queryString;

            switch (style)
            {
            case PageStyle.Insert:
            case PageStyle.List:
                result = "~/" + WebUtil.GetTemplateUrl(style, input);
                break;

            case PageStyle.Update:
            case PageStyle.Detail:
                queryString = WebUtil.GetQueryString(input.QueryString);
                result      = "~/" + WebUtil.GetTemplateUrl(style, input);
                result      = UriUtil.AppendQueryString(result, queryString);
                break;

            default:
                return(null);
            }
            return(new Uri(WebUtil.ResolveUrl(result), UriKind.RelativeOrAbsolute));
        }