예제 #1
0
        public static void SetPath(this WebAppSetting appSetting, WebAppXml xml)
        {
            string resolveStartPath = AppUtil.ResolveUrl(appSetting.StartupPath);

            appSetting.LogOnPath = AppUtil.ResolveUrl(xml.Application.Url.LogOnPath);
            if (string.IsNullOrEmpty(appSetting.LogOnPath))
            {
                appSetting.LogOnPath = resolveStartPath;
            }
            appSetting.HomePath = AppUtil.ResolveUrl(xml.Application.Url.HomePath);
            if (string.IsNullOrEmpty(appSetting.HomePath))
            {
                appSetting.HomePath = resolveStartPath;
            }
            appSetting.MainPath = AppUtil.ResolveUrl(xml.Application.Url.MainPath);

            if (xml.Upload != null)
            {
                //if (!string.IsNullOrEmpty(fUploadVirtualPath))
                //    fUploadVirtualPath = VirtualPathUtility.AppendTrailingSlash(fUploadVirtualPath);
                //if (!string.IsNullOrEmpty(fUploadTempVirtualPath))
                //    fUploadTempVirtualPath = VirtualPathUtility.AppendTrailingSlash(fUploadTempVirtualPath);
            }
            // 假处理,以后需要考虑解决方案
            appSetting.AppVirtualPath = "/";
            //AppVirtualPath = HttpRuntime.AppDomainAppVirtualPath;
            //if (string.IsNullOrEmpty(AppVirtualPath))
            //    AppVirtualPath = "/";
            //AppVirtualPath = VirtualPathUtility.AppendTrailingSlash(AppVirtualPath);
        }
예제 #2
0
        //public IConfigCreator<IExceptionHandler> ExceptionHandler { get; private set; }

        //public IConfigCreator<IExceptionHandler> ReLogOnHandler { get; private set; }

        //public IConfigCreator<IExceptionHandler> ErrorPageHandler { get; private set; }

        //public IConfigCreator<IExceptionHandler> ToolkitHandler { get; private set; }

        //public IConfigCreator<IExceptionHandler> ErrorOpeartionHandler { get; private set; }

        private void ConfigDatabase(WebAppXml xml)
        {
            if (xml.Databases != null)
            {
                bool entity = false;
                foreach (var item in xml.Databases)
                {
                    if (item.Default)
                    {
                        TkDebug.Assert(fDefault == null, string.Format(ObjectUtil.SysCulture,
                                                                       "{0}的Default属性标识为True,而前面已经有配置Default为True了,配置错误", item.Name), this);
                        fDefault = item;
                    }
                    if (!string.IsNullOrEmpty(item.ProviderName))
                    {
                        entity = true;
                    }
                    fDictionary.Add(item.Name, item);
                }
                if (fDefault == null && xml.Databases.Count > 0)
                {
                    fDefault = xml.Databases[0];
                }

                if (entity)
                {
                    //Configuration config = WebConfigurationManager.OpenWebConfiguration(HttpRuntime.AppDomainAppVirtualPath);
                    //var connectionStrings = config.ConnectionStrings.ConnectionStrings;
                    //bool isModify = false;
                    //var entities = from item in xml.Databases
                    //               where !string.IsNullOrEmpty(item.ProviderName)
                    //               select item;
                    //foreach (var item in entities)
                    //{
                    //    ConnectionStringSettings setting = new ConnectionStringSettings(item.Name,
                    //        item.ConnectionString, item.ProviderName);
                    //    int index = connectionStrings.IndexOf(setting);
                    //    if (index == -1)
                    //    {
                    //        isModify = true;
                    //        connectionStrings.Remove(setting.Name);
                    //        connectionStrings.Add(setting);
                    //    }
                    //}
                    //if (isModify)
                    //    config.Save(ConfigurationSaveMode.Modified);
                }
            }
        }
예제 #3
0
        //private string fUploadVirtualPath;

        internal WebAppSetting(string basePath, WebAppXml xml)
        {
            fDictionary = new Dictionary <string, DbContextConfig>();

            SolutionPath = xml.Application.Path;
            if (!Path.IsPathRooted(SolutionPath))
            {
                SolutionPath = Path.GetFullPath(Path.Combine(basePath, SolutionPath));
            }
            AppPath = xml.Application.AppPath;
            if (string.IsNullOrEmpty(AppPath))
            {
                AppPath = "web/bin";
            }
            AppPath    = Path.GetFullPath(Path.Combine(SolutionPath, AppPath));
            PlugInPath = xml.Application.PlugInPath;
            if (string.IsNullOrEmpty(PlugInPath))
            {
                PlugInPath = "Modules";
            }
            PlugInPath = Path.GetFullPath(Path.Combine(AppPath, PlugInPath));
            if (!string.IsNullOrEmpty(xml.Application.ActionResultName))
            {
                ActionResultName = xml.Application.ActionResultName;
            }
            EnableCrossDomain = xml.Application.EnableCrossDomain;

            XmlPath           = Path.Combine(SolutionPath, "Xml");
            ErrorPath         = Path.Combine(SolutionPath, "Error");
            IsDebug           = xml.Debug.Debug;
            ShowException     = xml.Debug.ShowException;
            fQueryStringName  = xml.Debug.XmlQueryString;
            fQueryStringValue = xml.Debug.XmlValue;
            fMetaDataValue    = xml.Debug.MetaDataValue;
            fJsonValue        = xml.Debug.JsonValue;
            fExcelValue       = xml.Debug.ExcelValue;
            UseCache          = xml.Application.UseCache;
            Culture           = xml.Application.Culture;
            UseWorkThread     = xml.Application.UseWorkThread;
            CacheTime         = xml.Application.CacheTime;
            TimingInterval    = xml.Application.TimingInterval;
            CommandTimeout    = xml.Application.CommandTimeout;
            DefaultValueFile  = xml.Application.DefaultValueFile;
            ConfigFile        = xml.Application.ConfigFile;
            AppRightBuilder   = xml.Application.AppRightBuilder;
            SecretKey         = xml.SecretKey;
            StartupPath       = xml.Application.Url.StartupPath;
            //string resolveStartPath = WebUtil.ResolveUrl(StartupPath);
            //LogOnPath = WebUtil.ResolveUrl(xml.Application.Url.LogOnPath);
            //if (string.IsNullOrEmpty(LogOnPath))
            //    LogOnPath = resolveStartPath;
            //HomePath = WebUtil.ResolveUrl(xml.Application.Url.HomePath);
            //if (string.IsNullOrEmpty(HomePath))
            //    HomePath = resolveStartPath;
            //MainPath = WebUtil.ResolveUrl(xml.Application.Url.MainPath);
            string errorPage = xml.Application.Url.ErrorPage;

            if (!string.IsNullOrEmpty(errorPage))
            {
                ErrorPagePath = Path.GetFullPath(Path.Combine(AppPath, "..", errorPage));
                ErrorPageUri  = new Uri(errorPage, UriKind.Relative);
            }
            AppInfoConfigItem appInfo = xml.Application.Info;

            if (appInfo != null)
            {
                AppFullName    = appInfo.FullName.ToString();
                AppShortName   = appInfo.ShortName.ToString();
                AppDescription = appInfo.Description == null ? string.Empty : appInfo.Description.ToString();
            }
            else
            {
                AppFullName = AppShortName = AppDescription = string.Empty;
            }

            if (xml.IO != null)
            {
                InputGZip     = xml.IO.InputGZip;
                InputEncrypt  = xml.IO.InputEncrypt;
                OutputGZip    = xml.IO.OutputGZip;
                OutputEncrypt = xml.IO.OutputEncrypt;
            }
            if (xml.Upload != null)
            {
                string baseUploadPath = SolutionPath;
                fUploadTempPath = Path.Combine(baseUploadPath, xml.Upload.TempPath);
                //fUploadPath = Path.Combine(baseUploadPath, xml.Upload.Path);
                //if (!Directory.Exists(fUploadPath))
                //    Directory.CreateDirectory(fUploadPath);
                if (!Directory.Exists(fUploadTempPath))
                {
                    Directory.CreateDirectory(fUploadTempPath);
                }
                //fUploadVirtualPath = xml.Upload.VirtualPath;
                //if (!string.IsNullOrEmpty(fUploadVirtualPath))
                //    fUploadVirtualPath = VirtualPathUtility.AppendTrailingSlash(fUploadVirtualPath);
                fUploadTempVirtualPath = xml.Upload.TempVirtualPath;
                //if (!string.IsNullOrEmpty(fUploadTempVirtualPath))
                //    fUploadTempVirtualPath = VirtualPathUtility.AppendTrailingSlash(fUploadTempVirtualPath);
            }
            ConfigDatabase(xml);

            Current  = this;
            fCurrent = this;

            if (xml.Hosts != null)
            {
                foreach (var item in xml.Hosts)
                {
                    AddHost(item.Key, item.Value);
                }
            }

            InitialIndexer();

            // 假处理,以后需要考虑解决方案
            //AppVirtualPath = "/";
            //AppVirtualPath = HttpRuntime.AppDomainAppVirtualPath;
            //if (string.IsNullOrEmpty(AppVirtualPath))
            //    AppVirtualPath = "/";
            //AppVirtualPath = VirtualPathUtility.AppendTrailingSlash(AppVirtualPath);
        }