Пример #1
0
        internal void SetFormat(IObjectFormat format)
        {
            TkDebug.ThrowIfNoAppSetting();

            IsGZip    = format.GZip.Config(WebAppSetting.WebCurrent.OutputGZip);
            IsEncrypt = format.Encrypt.Config(WebAppSetting.WebCurrent.OutputEncrypt);
        }
Пример #2
0
        public static bool IsShowExcel(bool showSource, IPageData pageData)
        {
            TkDebug.ThrowIfNoAppSetting();

            WebAppSetting setting = WebAppSetting.WebCurrent;

            return((pageData.Style.Style == PageStyle.List || MetaDataUtil.StartsWith(pageData.Style, "DetailList")) &&
                   showSource && setting.IsShowExcel(pageData.QueryString));
        }
Пример #3
0
        private static bool IsShowMetaData(IPageData pageData)
        {
            TkDebug.ThrowIfNoAppSetting();

            WebAppSetting setting = WebAppSetting.WebCurrent;

            return(setting.IsDebug && !pageData.IsPost &&
                   setting.IsShowMetaData(pageData.QueryString));
        }
Пример #4
0
        public static bool IsShowMetaData(bool showSource, IPageData pageData)
        {
            TkDebug.ThrowIfNoAppSetting();

            WebAppSetting setting = WebAppSetting.WebCurrent;

            return(showSource && setting.IsDebug && !pageData.IsPost &&
                   setting.IsShowMetaData(pageData.QueryString));
        }
Пример #5
0
        private static ISupportDbContext GetSupport()
        {
            TkDebug.ThrowIfNoAppSetting();

            ISupportDbContext support = BaseAppSetting.Current as ISupportDbContext;

            TkDebug.AssertNotNull(support, "AppSetting不支持ISupportDbContext接口,无法创建DbContext",
                                  BaseAppSetting.Current);
            return(support);
        }
Пример #6
0
        public string Redirect(ISource source, IPageData pageData, OutputData data)
        {
            string retUrl = pageData.QueryString["RetUrl"];

            if (string.IsNullOrEmpty(retUrl))
            {
                TkDebug.ThrowIfNoAppSetting();
                retUrl = WebAppSetting.WebCurrent.StartupPath;
            }
            return(retUrl);
        }
Пример #7
0
        public IModule Create(string source)
        {
            TkDebug.AssertArgumentNullOrEmpty(source, "source", this);
            TkDebug.ThrowIfNoAppSetting();

            string       path = Path.Combine(BaseAppSetting.Current.XmlPath, "Module", source + ".xml");
            Tk5ModuleXml xml  = new Tk5ModuleXml();

            xml.ReadXmlFromFile(path);
            return(xml);
        }
Пример #8
0
 public ICacheDependency CreateObject(params object[] args)
 {
     if (SystemConfiged)
     {
         TkDebug.ThrowIfNoAppSetting();
         return(new TimeSpanDependency(BaseAppSetting.Current.CacheTime));
     }
     else
     {
         return(new TimeSpanDependency(Span));
     }
 }
Пример #9
0
 ICacheDependency IConfigCreator <ICacheDependency> .CreateObject(params object[] args)
 {
     if (SystemConfiged)
     {
         TkDebug.ThrowIfNoAppSetting();
         return(new ActiveTimeDependency(BaseAppSetting.Current.CacheTime));
     }
     else
     {
         return(new ActiveTimeDependency(Span));
     }
 }
Пример #10
0
 protected override ICacheDependency CreateCacheDependency()
 {
     if (fSystemConfiged)
     {
         TkDebug.ThrowIfNoAppSetting();
         return(new ActiveTimeDependency(BaseAppSetting.Current.CacheTime));
     }
     else
     {
         return(new ActiveTimeDependency(fTimeSpan));
     }
 }
Пример #11
0
        public AliyunOSSUploadInfo(IFormFile file)
        {
            TkDebug.ThrowIfNoAppSetting();

            FileSize    = (int)file.Length;
            ContentType = file.ContentType;
            FileName    = Path.GetFileName(file.FileName);
            WebAppSetting appsetting  = WebAppSetting.WebCurrent;
            string        newFileName = Guid.NewGuid().ToString();

            TempFile   = new FileConfig(AliyunOSSSetting.Current.TempBucketName, newFileName);
            ServerPath = TempFile.ToString();
            WebPath    = WebUtil.ResolveUrl(TempFile.AccessUrl);
        }
Пример #12
0
        public WebUploadInfo(IFormFile file)
        {
            TkDebug.ThrowIfNoAppSetting();

            FileSize    = (int)file.Length;
            ContentType = file.ContentType;
            FileName    = Path.GetFileName(file.FileName);
            WebAppSetting appsetting  = WebAppSetting.WebCurrent;
            string        newFileName = Guid.NewGuid() + Path.GetExtension(FileName);

            ServerPath = Path.Combine(appsetting.UploadTempPath, newFileName);
            string urlPath = UriUtil.TextCombine(appsetting.UploadTempVirtualPath, newFileName);

            WebPath = AppUtil.ResolveUrl(urlPath);
        }
Пример #13
0
        public static BaseSendMessage Execute(Action <bool, string> processor, bool subscrible, string data)
        {
            TkDebug.ThrowIfNoAppSetting();
            TkDebug.ThrowIfNoGlobalVariable();

            if (BaseAppSetting.Current.UseWorkThread)
            {
                BaseGlobalVariable.Current.BeginInvoke(processor, subscrible, data);
            }
            else
            {
                processor(subscrible, data);
            }

            return(null);
        }
        public object Read(IInputData input, Stream stream)
        {
            DataSet ds = new DataSet(ToolkitConst.TOOLKIT)
            {
                Locale = ObjectUtil.SysCulture
            };

            ds.ReadXml(CreateReader(stream));
            TkDebug.ThrowIfNoAppSetting();
            if (BaseAppSetting.Current.IsDebug)
            {
                string file = Path.Combine(BaseAppSetting.Current.XmlPath, "Post.xml");
                FileUtil.WriteFileUseWorkThread(file, ds.GetXml());
            }
            return(ds);
        }
Пример #15
0
        internal void Log(ReceiveMessage message)
        {
            if (fLog != null)
            {
                TkDebug.ThrowIfNoGlobalVariable();
                TkDebug.ThrowIfNoAppSetting();

                if (BaseAppSetting.Current.UseWorkThread)
                {
                    BaseGlobalVariable.Current.BeginInvoke(new Action <ReceiveMessage>(ExecuteLog), message);
                }
                else
                {
                    ExecuteLog(message);
                }
            }
        }
Пример #16
0
        static ToolkitRazorProject()
        {
            TkDebug.ThrowIfNoAppSetting();

            fRazorRoot = Path.Combine(BaseAppSetting.Current.XmlPath, "razor");
            if (!Directory.Exists(fRazorRoot))
            {
                Directory.CreateDirectory(fRazorRoot);
            }
            fRazorFileProvider = new PhysicalFileProvider(fRazorRoot);
            fTemplateRoot      = Path.Combine(BaseAppSetting.Current.XmlPath, "razortemplate");
            if (!Directory.Exists(fTemplateRoot))
            {
                Directory.CreateDirectory(fTemplateRoot);
            }
            fTemplateFileProvider = new PhysicalFileProvider(fTemplateRoot);
        }
Пример #17
0
        private static Task WriteContent(HttpRequest request, HttpResponse response, IContent content)
        {
            TkDebug.ThrowIfNoAppSetting();
            if (WebAppSetting.WebCurrent.EnableCrossDomain)
            {
                string originHeader = WebGlobalVariable.Request.Headers["Origin"];
                if (!string.IsNullOrEmpty(originHeader))
                {
                    response.Headers["Access-Control-Allow-Origin"] = originHeader;
                }
                response.Headers["Access-Control-Allow-Credentials"] = "true";
            }

            response.ContentType = content.ContentType;
            string resp = content.Content;

            WriteJwt(request, response);

            if (string.IsNullOrEmpty(resp))
            {
                return(content.WritePage(response));
            }
            else
            {
                if (content.Headers != null)
                {
                    foreach (var item in content.Headers)
                    {
                        response.Headers[item.Key] = item.Value;
                    }
                }
                Encoding encoding = content.ContentEncoding;
                if (encoding != null)
                {
                    return(response.WriteAsync(content.Content, encoding));
                }
                else
                {
                    return(response.WriteAsync(content.Content));
                }
            }
            //response.End();
        }
Пример #18
0
        private static XslCompiledTransform GetTransformFromType(Type type, TransformSetting setting)
        {
            TkDebug.ThrowIfNoAppSetting();

            XslCompiledTransform result = null;
            bool cache = setting.UseCache && BaseAppSetting.Current.UseCache;

            if (cache)
            {
                XsltTransformCacheData data = CacheManager.GetItem("XsltTransformType",
                                                                   type.ToString(), type, setting).Convert <XsltTransformCacheData>();
                result = data.Transform;
            }
            else
            {
                result = new XslCompiledTransform();
                result.Load(type);
            }
            return(result);
        }
Пример #19
0
        protected virtual void PreparePostData()
        {
            MemoryStream stream = new MemoryStream();

            byte[] data = null;
            try
            {
                IPostObjectCreator creator = PostObjectCreator;
                if (creator == null)
                {
                    PostObject = null;
                }
                else
                {
                    //FileUtil.CopyStream(Request.Body, stream);
                    Request.Body.CopyToAsync(stream).GetAwaiter().GetResult();
                    if (BaseAppSetting.Current.IsDebug)
                    {
                        data            = stream.ToArray();
                        stream.Position = 0;
                    }
                    PostObject = creator.Read(this, stream);
                }
            }
            catch (Exception ex)
            {
                TkDebug.ThrowIfNoAppSetting();
                if (BaseAppSetting.Current.IsDebug)
                {
                    string file    = Path.Combine(BaseAppSetting.Current.XmlPath, "Post.txt");
                    string content = Encoding.UTF8.GetString(data);

                    FileUtil.WriteFileUseWorkThread(file, content);
                }
                TkDebug.ThrowToolkitException("提交上来的数据不是XML,如果Debug开启,可以查看Post.txt中的内容", ex, this);
            }
            finally
            {
                stream.Dispose();
            }
        }
Пример #20
0
        public string Execute(string parameter)
        {
            TkDebug.ThrowIfNoAppSetting();

            if (string.IsNullOrEmpty(parameter))
            {
                return(string.Empty);
            }
            Uri result = BaseAppSetting.Current.GetHost(parameter);

            if (result == null)
            {
                return(string.Empty);
            }
            string url = result.ToString();

            if (url.EndsWith("/", StringComparison.Ordinal))
            {
                return(url);
            }
            return(url + "/");
        }
Пример #21
0
        private static XslCompiledTransform GetTransformFromFile(string xslFile, TransformSetting setting)
        {
            TkDebug.ThrowIfNoAppSetting();

            XslCompiledTransform result = null;
            bool cache = setting.UseCache && BaseAppSetting.Current.UseCache;

            if (cache)
            {
                XsltTransformCacheData data = CacheManager.GetItem("XsltTransformFile",
                                                                   xslFile, setting).Convert <XsltTransformCacheData>();
                result = data.Transform;
            }
            else
            {
                result = new XslCompiledTransform();
                XsltSettings xsltSetting = setting.NeedEvidence ? XsltSettings.TrustedXslt
                    : XsltSettings.Default;
                result.Load(new Uri(xslFile).ToString(), xsltSetting, fResolver);
            }

            return(result);
        }