コード例 #1
0
        public string ReadDefaultPresentation(int formatId)
        {
            var format     = ObjectFormatRepository.ReadObjectFormat(formatId, true);
            var obj        = ObjectRepository.GetObjectPropertiesById(format.ParentEntityId);
            var pathToCopy = SitePathRepository.GetDirectoryPathToCopy() + Path.DirectorySeparatorChar + "default" + Path.DirectorySeparatorChar;

            return(obj.IsObjectContainerType ? ReadFileAsString($"{pathToCopy}container_presentation.txt") : string.Empty);
        }
コード例 #2
0
        public string ReadDefaultCode(int formatId)
        {
            var format            = ObjectFormatRepository.ReadObjectFormat(formatId, true);
            var obj               = ObjectRepository.GetObjectPropertiesById(format.ParentEntityId);
            var netLanguagePrefix = GetLangPrefix(format.NetLanguageId);
            var pathToCopy        = SitePathRepository.GetDirectoryPathToCopy() + Path.DirectorySeparatorChar + "default" + Path.DirectorySeparatorChar;

            return(ReadFileAsString(obj.IsObjectContainerType ? $"{pathToCopy}container_code_{netLanguagePrefix}.txt" : $"{pathToCopy}generic_code_{netLanguagePrefix}.txt"));
        }
コード例 #3
0
ファイル: FormatService.cs プロジェクト: QuantumArt/QP
        public ObjectFormatVersion GetMergedObjectFormatVersion(int[] ids, int parentId, bool pageOrTemplate)
        {
            if (ids == null)
            {
                throw new ArgumentNullException(nameof(ids));
            }

            if (ids.Length != 2)
            {
                throw new ArgumentException("Wrong ids length");
            }

            var result   = GetOrderedIds(ids);
            var version1 = PageTemplateRepository.ReadFormatVersion(result.Item1);

            if (version1 == null)
            {
                throw new Exception(string.Format(TemplateStrings.FormatVersionNotFoundForFormat, result.Item1, parentId));
            }

            ObjectFormatVersion version2;

            if (result.Item2 == ObjectFormatVersion.CurrentVersionId)
            {
                var parent = ObjectFormatRepository.ReadObjectFormat(parentId, pageOrTemplate);
                if (parent == null)
                {
                    throw new Exception(string.Format(TemplateStrings.FormatNotFound, parentId));
                }

                version2 = new ObjectFormatVersion
                {
                    Name               = parent.Name,
                    NetFormatName      = parent.NetFormatName,
                    Description        = parent.Description,
                    NetLanguage        = parent.NetLanguageId.HasValue ? PageTemplateRepository.GetNetLanguageById(parent.NetLanguageId.Value) : null,
                    FormatBody         = parent.FormatBody,
                    CodeBehind         = parent.CodeBehind,
                    LastModifiedByUser = parent.LastModifiedByUser,
                    Modified           = parent.Modified
                };
            }
            else
            {
                version2 = PageTemplateRepository.ReadFormatVersion(result.Item2);
                if (version2 == null)
                {
                    throw new Exception(string.Format(TemplateStrings.FormatVersionNotFoundForFormat, result.Item2, parentId));
                }
            }

            version1.MergeToVersion(version2);
            return(version1);
        }
コード例 #4
0
ファイル: FormatService.cs プロジェクト: QuantumArt/QP
        public void CancelFormat(int id, bool pageOrTemplate)
        {
            var format = ObjectFormatRepository.ReadObjectFormat(id, pageOrTemplate);

            if (format == null)
            {
                throw new ApplicationException(string.Format(TemplateStrings.FormatNotFound, id));
            }

            format.AutoUnlock();
        }
コード例 #5
0
ファイル: FormatService.cs プロジェクト: QuantumArt/QP
        public void CaptureLockPageObjectFormat(int id)
        {
            var format = ObjectFormatRepository.ReadObjectFormat(id, false);

            if (format == null)
            {
                throw new Exception(string.Format(TemplateStrings.FormatNotFound, id));
            }

            if (format.CanBeUnlocked)
            {
                EntityObjectRepository.CaptureLock(format);
            }
        }
コード例 #6
0
        public ObjectFormat ReadFormatProperties(int id, bool pageOrTemplate, bool withAutoLock = true)
        {
            var format = ObjectFormatRepository.ReadObjectFormat(id, pageOrTemplate);

            if (format == null)
            {
                throw new ApplicationException(string.Format(TemplateStrings.FormatNotFound, id));
            }

            if (withAutoLock)
            {
                format.AutoLock();
            }
            format.LoadLockedByUser();
            format.PageOrTemplate = pageOrTemplate;
            format.ReplacePlaceHoldersToUrls();
            return(format);
        }
コード例 #7
0
        private static void ManageFormatSearchItemsDescription(IEnumerable <ObjectFormatSearchResultListItem> data, string filter)
        {
            if (string.IsNullOrWhiteSpace(filter))
            {
                return;
            }

            foreach (var item in data)
            {
                var format = ObjectFormatRepository.ReadObjectFormat(item.Id, true);
                if (!string.IsNullOrWhiteSpace(format.CodeBehind) && format.CodeBehind.Contains(filter))
                {
                    item.Description = FoundTextMarker.GetSimpleRelevantMarkedText(WebUtility.HtmlEncode(format.CodeBehind), filter, 20, "<span class='seachResultHighlight'>", "</span>");
                    continue;
                }

                if (!string.IsNullOrWhiteSpace(format.FormatBody) && format.FormatBody.Contains(filter))
                {
                    item.Description = FoundTextMarker.GetSimpleRelevantMarkedText(WebUtility.HtmlEncode(format.FormatBody), filter, 20, "<span class='seachResultHighlight'>", "</span>");
                }
            }
        }
コード例 #8
0
ファイル: FormatService.cs プロジェクト: QuantumArt/QP
        public MessageResult RemoveObjectFormat(int id, bool pageOrTemplate)
        {
            var format = ObjectFormatRepository.ReadObjectFormat(id, pageOrTemplate);

            if (format == null)
            {
                throw new ApplicationException(string.Format(TemplateStrings.FormatNotFound, id));
            }

            if (format.LockedByAnyoneElse)
            {
                return(MessageResult.Error(string.Format(TemplateStrings.LockedByAnyoneElse, format.LockedByDisplayName)));
            }
            if (format.Notifications.Any())
            {
                return(MessageResult.Error(TemplateStrings.UnableToDeleteFormat));
            }

            ManagePageAndObjectModified(format);
            PageTemplateRepository.DeleteObjectFormat(id);
            return(null);
        }