Exemplo n.º 1
0
 public void LoadSettings()
 {
     _mSerializer = new YAXSerializer(typeof(FrameSettings), 
                                     YAXExceptionHandlingPolicies.ThrowErrorsOnly, 
                                     YAXExceptionTypes.Warning);
     _mFrameSettings = (FrameSettings)_mSerializer.DeserializeFromFile("data\\settings.xml");
     FrameworkSettings.Load(_mFrameSettings);
 }
Exemplo n.º 2
0
        private void Create(FrameworkSettings settings, string assetPath)
        {
            var resource = ScriptableObject.CreateInstance(settings.ResourceType);

            //todo Merge
            DirectoryHelper.DirectoryMustExist(Path.GetDirectoryName(assetPath));
            AssetDatabase.CreateAsset(resource, assetPath);
            AssetDatabase.SaveAssets();
            AssetDatabase.Refresh();
        }
Exemplo n.º 3
0
        //=====================================================================

        /// <summary>
        /// This is used to convert old SHFB project framework version values to the new framework version values
        /// </summary>
        /// <param name="oldValue">The old value to convert</param>
        /// <returns>The equivalent new value</returns>
        internal static string ConvertFromOldValue(string oldValue)
        {
            FrameworkSettings fs = null;

            if (String.IsNullOrWhiteSpace(oldValue))
            {
                return(FrameworkDictionary.DefaultFrameworkTitle);
            }

            oldValue = oldValue.Trim();

            if (oldValue.IndexOf(".NET ", StringComparison.OrdinalIgnoreCase) != -1 || Char.IsDigit(oldValue[0]))
            {
                oldValue = oldValue.ToUpperInvariant().Replace(".NET ", String.Empty).Trim();

                if (oldValue.Length == 0)
                {
                    oldValue = "4.0";
                }
                else
                if (oldValue.Length > 3)
                {
                    oldValue = oldValue.Substring(0, 3);
                }

                oldValue = ".NET Framework " + oldValue;
            }
            else
            if (oldValue.IndexOf("Silverlight ", StringComparison.OrdinalIgnoreCase) != -1)
            {
                oldValue = oldValue.ToUpperInvariant().Trim();

                if (oldValue.EndsWith(".0", StringComparison.Ordinal))
                {
                    oldValue = oldValue.Substring(0, oldValue.Length - 2);
                }
            }
            else
            if (oldValue.IndexOf("Portable ", StringComparison.OrdinalIgnoreCase) != -1)
            {
                oldValue = ".NET Portable Library 4.0 (Legacy)";
            }

            // If not found, default to .NET 4.0
            if (!FrameworkDictionary.AllFrameworks.TryGetValue(oldValue, out fs))
            {
                return(FrameworkDictionary.DefaultFrameworkTitle);
            }

            return(fs.Title);
        }
Exemplo n.º 4
0
 internal void AddReference()
 {
     _references++;
     if (!_frameworksSettings.Contains(_framework.Definition.Uid))
     {
         if (_frameworkSettings == null)
         {
             _frameworkSettings = _frameworksSettings.GetOrCreate(_framework.Definition.Uid);
         }
         else
         {
             _frameworksSettings.Add(_frameworkSettings);
         }
     }
 }
Exemplo n.º 5
0
        public static void RedirectToAdminUrl(long mediaTypeId, long selectedMediaId, long?parentMediaId = null, Language language = null, IMediaDetail detail = null, long historyVersion = 0)
        {
            if (language != null)
            {
                FrameworkSettings.SetCurrentLanguage(language);
            }

            var url = GetAdminUrl(mediaTypeId, selectedMediaId, parentMediaId, historyVersion);

            if (!string.IsNullOrEmpty(HttpContext.Current.Request["masterFilePath"]))
            {
                url = url + "&masterFilePath=" + HttpContext.Current.Request["masterFilePath"];
            }

            HttpContext.Current.Response.Redirect(url, true);
        }
Exemplo n.º 6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SystemManifest"/> class.
 /// </summary>
 public SystemManifest()
 {
     Settings            = new FrameworkSettings();
     WcfHosts            = new WcfHostSettings();
     PluginDefinitions   = new Collection <PluginDefinition>();
     Resources           = new ResourceDetailCollection();
     AllAssets           = new Collection <AssetInfo>();
     ActivityAssets      = new Dictionary <Guid, AssetIdCollection>();
     Documents           = new Collection <Document>();
     ActivityDocuments   = new Dictionary <Guid, DocumentIdCollection>();
     Servers             = new Collection <ServerInfo>();
     ActivityServers     = new Dictionary <Guid, ServerIdCollection>();
     ActivityPrintQueues = new Dictionary <Guid, PrintQueueInfoCollection>();
     Assets                = new AvailableDeviceSet <AssetDetail>();
     SoftwareInstallers    = new Collection <SoftwareInstallerDetail>();
     ActivityRetrySettings = new Dictionary <Guid, Plugin.PluginRetrySettingDictionary>();
 }
Exemplo n.º 7
0
    private void Init()
    {
        if (connectionSettings == null)
        {
            throw new Exception("You must call FrameworkBaseMedia.InitConnectionSettings first");
        }

        defaultLanguage = LanguagesMapper.GetDefaultLanguage();
        currentLanguage = FrameworkSettings.GetCurrentLanguage();

        if (currentLanguage == null)
        {
            throw new Exception("Error loading default language");
        }

        /*rootMedia = FrameworkSettings.RootMedia;
         *
         * if (rootMedia != null)
         *  rootMediaDetail = FrameworkSettings.RootMediaDetail;*/
    }
Exemplo n.º 8
0
        private void OnEnable()
        {
            _settings = EditorFramework.FrameworkSetting;

            if (_settings == null)
            {
                return;
            }

            _root = new ScrollView();
            rootVisualElement.Add(_root);

            InitSerializedObjects();

            InitMainPage();
            InitSettingPage();


            LayoutMainPage();
            LayoutSettingPage();
        }
Exemplo n.º 9
0
    public void LoadByVirtualPath(string virtualPath)
    {
        if ((!virtualPath.StartsWith("http")) && System.IO.File.Exists(HttpContext.Current.Server.MapPath(virtualPath)))
        {
            return;
        }

        currentVirtualPath = virtualPath;

        if (currentLanguage == null)
        {
            throw new Exception("Error loading default language");
        }

        if ((currentVirtualPath == "~/") || currentVirtualPath == URIHelper.ConvertAbsUrlToTilda(URIHelper.ConvertToAbsUrl(currentLanguage.UriSegment)))
        {
            long version = 0;
            long.TryParse(HttpContext.Current.Request["version"], out version);

            currentMediaDetail = WebsitesMapper.GetWebsite(version);
        }
        else
        {
            currentMediaDetail = MediaDetailsMapper.GetByVirtualPath(currentVirtualPath);
        }

        if (currentMediaDetail == null)
        {
            return;
        }

        currentLanguage = currentMediaDetail.Language;
        FrameworkSettings.SetCurrentLanguage(currentMediaDetail.Language);

        //rootMedia = FrameworkSettings.RootMedia;
        //rootMediaDetail = FrameworkSettings.RootMediaDetail;

        currentMedia = currentMediaDetail.Media;
    }
Exemplo n.º 10
0
        public IHttpHandler GetHttpHandler(RequestContext requestContext)
        {
            RedisCacheHelper.SetRedisCacheConnectionString(AppSettings.RedisCacheConnectionString);
            FileCacheHelper.SetFileSystemCacheDirPath(AppSettings.FileSystemCacheDirPath);

            virtualPath = URIHelper.GetCurrentVirtualPath().ToLower();

            var queryString = HttpContext.Current.Request.QueryString.ToString();

            queryString = System.Web.HttpUtility.UrlDecode(queryString);


            if (!Request.Path.EndsWith("/") || ((virtualPath != "~/") && (!virtualPath.EndsWith("/"))))
            {
                var path = Request.Path + "/";

                if (!string.IsNullOrEmpty(queryString))
                {
                    path = path + "?" + queryString;
                }

                HttpContext.Current.Response.RedirectPermanent(path);
            }

            Settings cmsSettings            = null;
            bool     isAttemptingAdminLogin = false;

            if ((virtualPath != "~/login/") && (virtualPath != "~/admin/") && string.IsNullOrEmpty(Request.QueryString["format"]))
            {
                cmsSettings = SettingsMapper.GetSettings();

                if (cmsSettings != null)
                {
                    var isSiteOnline = cmsSettings.IsSiteOnline();

                    if (isSiteOnline)
                    {
                        if (virtualPath.Contains(cmsSettings.SiteOfflineUrl))
                        {
                            Response.Redirect("~/");
                        }

                        AttemptToLoadFromCache();
                    }
                    else
                    {
                        if (!virtualPath.Contains(cmsSettings.SiteOfflineUrl))
                        {
                            Response.Redirect(cmsSettings.SiteOfflineUrl);
                        }
                    }
                }
                else
                {
                    AttemptToLoadFromCache();
                }
            }
            else
            {
                isAttemptingAdminLogin = true;
            }

            var languageSegment = FrameworkSettings.GetCurrentLanguage().UriSegment;

            if (LanguagesMapper.GetAllActive().Count() > 1 && !Request.Url.PathAndQuery.Contains($"/{languageSegment}/"))
            {
                var url = URIHelper.ConvertToAbsUrl("/" + languageSegment + Request.Url.PathAndQuery);
                Response.RedirectPermanent(url, true);
            }

            var segments = URIHelper.GetUriSegments(virtualPath).ToList();

            string firstSegment = "";

            if (segments.Count > 0)
            {
                firstSegment = segments[0];

                var language = LanguagesMapper.GetAllActive().SingleOrDefault(i => i.UriSegment == firstSegment);

                if (language != null)
                {
                    FrameworkSettings.SetCurrentLanguage(language);
                }
            }

            if (!isAttemptingAdminLogin && AppSettings.EnableUrlRedirectRules)
            {
                var path = virtualPath;

                if (!string.IsNullOrEmpty(queryString))
                {
                    path = path + "?" + queryString;
                }

                var redirectRule = UrlRedirectRulesMapper.GetRuleForUrl(path);

                if (redirectRule != null)
                {
                    var newUrl = redirectRule.RedirectToUrl;

                    if (newUrl.Contains("{"))
                    {
                        newUrl = MediaDetailsMapper.ParseSpecialTags(redirectRule, newUrl);
                    }

                    newUrl = URIHelper.ConvertToAbsUrl(newUrl);

                    var possibleLoopRules      = UrlRedirectRulesMapper.GetRulesFromUrl(URIHelper.ConvertAbsUrlToTilda(newUrl));
                    var foundActiveVirtualPath = MediaDetailsMapper.GetByVirtualPath(path);

                    if (possibleLoopRules.Any())
                    {
                        foreach (var rule in possibleLoopRules)
                        {
                            var returnObj = MediaDetailsMapper.DeletePermanently(rule);
                        }
                    }

                    if (foundActiveVirtualPath != null)
                    {
                        var returnObj = MediaDetailsMapper.DeletePermanently(redirectRule);
                    }

                    if (Request.QueryString.Count > 0)
                    {
                        newUrl += "?" + Request.QueryString;
                    }

                    if (redirectRule.Is301Redirect)
                    {
                        Response.RedirectPermanent(newUrl);
                    }
                    else
                    {
                        Response.Redirect(newUrl);
                    }
                }
            }

            if (!File.Exists(HttpContext.Current.Server.MapPath(virtualPath)) && !virtualPath.Contains(ParserHelper.OpenToken) && !virtualPath.Contains(ParserHelper.CloseToken))
            {
                string viewPath = "";

                long mediaDetailId = 0;
                long.TryParse(requestContext.HttpContext.Request["MediaDetailID"], out mediaDetailId);

                long mediaId = 0;
                long.TryParse(requestContext.HttpContext.Request["MediaID"], out mediaId);

                MediaDetail detail = null;

                if (mediaDetailId == 0 && mediaId == 0)
                {
                    FrameworkSettings.Current = FrameworkBaseMedia.GetInstanceByVirtualPath(virtualPath, true);
                    detail = (MediaDetail)FrameworkSettings.Current.CurrentMediaDetail;
                }
                else if (mediaDetailId != 0)
                {
                    var mediaDetail = MediaDetailsMapper.GetByID(mediaDetailId);

                    FrameworkSettings.Current = FrameworkBaseMedia.GetInstanceByMediaDetail(mediaDetail);
                    detail = (MediaDetail)FrameworkSettings.Current.CurrentMediaDetail;
                }
                else if (mediaId != 0)
                {
                    var media = MediasMapper.GetByID(mediaId);

                    FrameworkSettings.Current = FrameworkBaseMedia.GetInstanceByMedia(media);
                    detail = (MediaDetail)FrameworkSettings.Current.CurrentMediaDetail;
                }

                /*if (detail != null && !detail.CanUserAccessSection(FrameworkSettings.CurrentUser))
                 * {
                 *  FormsAuthentication.RedirectToLoginPage();
                 * }*/

                /*if (detail != null)
                 * {
                 *  var absUrlBase = URIHelper.ConvertAbsUrlToTilda(detail.AbsoluteUrl).Replace("~", "");
                 *  var absPathBase = URIHelper.ConvertAbsUrlToTilda(Request.Url.AbsolutePath).Replace("~", "");
                 *
                 *  if (absUrlBase != absPathBase)
                 *  {
                 *      Response.Redirect(detail.AbsoluteUrl + Request.Url.Query);
                 *  }
                 * }*/

                if (detail != null)
                {
                    if (detail.ForceSSL || AppSettings.ForceSSL)
                    {
                        URIHelper.ForceSSL();
                    }
                }
                else
                {
                    var currentLanguageId = FrameworkSettings.GetCurrentLanguage().ID;

                    var historyVersion = BaseMapper.GetDataModel().MediaDetails.FirstOrDefault(i => i.LanguageID == currentLanguageId && i.CachedVirtualPath == virtualPath && i.MediaType.ShowInSiteTree && i.HistoryVersionNumber != 0 && i.HistoryForMediaDetail != null);

                    if (historyVersion != null && historyVersion.VirtualPath != historyVersion.HistoryForMediaDetail.VirtualPath)
                    {
                        var foundRedirectUrl = UrlRedirectRulesMapper.GetRuleForUrl(virtualPath);

                        if (foundRedirectUrl == null)
                        {
                            var urlRedirectRule = UrlRedirectRulesMapper.CreateUrlRedirect(virtualPath, historyVersion.HistoryForMediaDetail.Media);

                            if (urlRedirectRule != null)
                            {
                                var returnObj = UrlRedirectRulesMapper.Insert(urlRedirectRule);
                                HttpContext.Current.Response.RedirectPermanent(historyVersion.HistoryForMediaDetail.CachedVirtualPath);
                            }
                            else
                            {
                                HttpContext.Current.Response.RedirectPermanent("/");
                            }
                        }
                    }
                    else
                    {
                        HttpContext.Current.Response.RedirectPermanent("/");
                    }
                }

                if ((detail == null) || (!IsValidRequest(detail)))
                {
                    detail = null;
                    if (cmsSettings != null)
                    {
                        if (!string.IsNullOrEmpty(cmsSettings.PageNotFoundUrl))
                        {
                            ErrorHelper.LogException(new Exception($"Page Not Found: {virtualPath}"));

                            Response.Redirect(cmsSettings.PageNotFoundUrl);

                            /*FrameworkSettings.CurrentFrameworkBaseMedia = null;
                             *
                             * FrameworkSettings.CurrentFrameworkBaseMedia = FrameworkBaseMedia.GetInstanceByVirtualPath(cmsSettings.PageNotFoundUrl, true);
                             * detail = (MediaDetail)FrameworkSettings.CurrentFrameworkBaseMedia.CurrentMediaDetail;
                             *
                             * ErrorHelper.LogException(new Exception($"Page Not Found: {virtualPath}"));*/

                            //Response.StatusCode = 301;
                        }
                    }
                }

                if (detail != null)
                {
                    var draft = detail.GetLatestDraft();

                    if (draft != null && (draft.PublishDate - detail.PublishDate) > TimeSpan.FromSeconds(10) && draft.CanRender)
                    {
                        var returnObj = draft.PublishLive();

                        if (!returnObj.IsError)
                        {
                            detail.RemoveFromCache();
                            draft.RemoveFromCache();

                            FrameworkSettings.Current = FrameworkBaseMedia.GetInstanceByMediaDetail(draft);
                            detail = (MediaDetail)FrameworkSettings.Current.CurrentMediaDetail;
                        }
                    }

                    if (detail.RedirectToFirstChild)
                    {
                        var child = detail.ChildMediaDetails.FirstOrDefault();

                        if (child != null)
                        {
                            var redirectPath = child.AutoCalculatedVirtualPath;

                            if (!string.IsNullOrEmpty(queryString))
                            {
                                redirectPath = redirectPath + "?" + queryString;
                            }

                            HttpContext.Current.Response.Redirect(redirectPath);
                        }
                    }

                    viewPath = FrameworkSettings.Current.CurrentMediaDetail.Handler;

                    if ((viewPath == null) || (viewPath.Trim() == ""))
                    {
                        viewPath = MediaTypesMapper.GetByID(FrameworkSettings.Current.CurrentMediaDetail.MediaTypeID).MediaTypeHandler;
                    }

                    viewPath = URIHelper.ConvertAbsUrlToTilda(viewPath);

                    if (!string.IsNullOrEmpty(Request.QueryString["format"]))
                    {
                        FrontEndBasePage.HandleFormatQueryString(detail, Request.QueryString["format"], Request.QueryString["depth"]);
                    }

                    return(CreateInstanceFromVirtualPath(viewPath, typeof(BasePage)));
                }
            }

            return(new DefaultHttpHandler());
        }
Exemplo n.º 11
0
        /// <summary>
        /// This is the method that indexes the comments files
        /// </summary>
        /// <remarks>Rather than a partial build, we'll just index the comments files.</remarks>
        private IndexedCommentsCache IndexComments()
        {
            HashSet <string>     projectDictionary = new HashSet <string>();
            IndexedCommentsCache cache             = new IndexedCommentsCache(100);
            MSBuildProject       projRef;
            string lastSolution = null;

            currentProject.EnsureProjectIsCurrent(false);

            // Index the framework comments based on the framework version in the project
            FrameworkSettings frameworkSettings = FrameworkDictionary.AllFrameworks.GetFrameworkWithRedirect(
                currentProject.FrameworkVersion);

            if (frameworkSettings == null)
            {
                throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture,
                                                                  "Unable to locate information for a framework version or its redirect: {0}",
                                                                  currentProject.FrameworkVersion));
            }

            foreach (var location in frameworkSettings.CommentsFileLocations(currentProject.Language))
            {
                indexTokenSource.Token.ThrowIfCancellationRequested();

                cache.IndexCommentsFiles(Path.GetDirectoryName(location), Path.GetFileName(location),
                                         false, null);
            }

            // Index the comments file documentation sources
            foreach (string file in currentProject.DocumentationSources.CommentsFiles)
            {
                indexTokenSource.Token.ThrowIfCancellationRequested();

                cache.IndexCommentsFiles(Path.GetDirectoryName(file), Path.GetFileName(file), false, null);
            }

            // Also, index the comments files in project documentation sources
            foreach (DocumentationSource ds in currentProject.DocumentationSources)
            {
                foreach (var sourceProject in DocumentationSource.Projects(ds.SourceFile, ds.IncludeSubFolders,
                                                                           !String.IsNullOrEmpty(ds.Configuration) ? ds.Configuration : currentProject.Configuration,
                                                                           !String.IsNullOrEmpty(ds.Platform) ? ds.Platform : currentProject.Platform))
                {
                    indexTokenSource.Token.ThrowIfCancellationRequested();

                    // NOTE: This code should be similar to the code in BuildProcess.ValidateDocumentationSources!

                    // Solutions are followed by the projects that they contain
                    if (sourceProject.ProjectFileName.EndsWith(".sln", StringComparison.OrdinalIgnoreCase))
                    {
                        lastSolution = sourceProject.ProjectFileName;
                        continue;
                    }

                    // Ignore projects that we've already seen
                    if (projectDictionary.Add(sourceProject.ProjectFileName))
                    {
                        using (projRef = new MSBuildProject(sourceProject.ProjectFileName))
                        {
                            // Use the project file configuration and platform properties if they are set.  If
                            // not, use the documentation source values.  If they are not set, use the SHFB
                            // project settings.
                            projRef.SetConfiguration(
                                !String.IsNullOrEmpty(sourceProject.Configuration) ? sourceProject.Configuration :
                                !String.IsNullOrEmpty(ds.Configuration) ? ds.Configuration : currentProject.Configuration,
                                !String.IsNullOrEmpty(sourceProject.Platform) ? sourceProject.Platform :
                                !String.IsNullOrEmpty(ds.Platform) ? ds.Platform : currentProject.Platform,
                                currentProject.MSBuildOutDir, false);

                            // Add Visual Studio solution macros if necessary
                            if (lastSolution != null)
                            {
                                projRef.SetSolutionMacros(lastSolution);
                            }

                            if (!String.IsNullOrEmpty(projRef.XmlCommentsFile))
                            {
                                cache.IndexCommentsFiles(Path.GetDirectoryName(projRef.XmlCommentsFile),
                                                         Path.GetFileName(projRef.XmlCommentsFile), false, null);
                            }
                        }
                    }
                }
            }

            return(cache);
        }