Esempio n. 1
0
        /// <summary>
        /// Обработчик события изменения элемента списка
        /// Считываем данные по файлу из списка.
        /// </summary>
        private void listBoxDocuments_SelectedIndexChanged(object sender, EventArgs e)
        {
            var listBox = (ListBox)sender;

            //Проверяем, чтобы список был не пустой
            if (listBox.Items == null || listBox.Items.Count == 0 || listBox.SelectedItem == null)
            {
                return;
            }

            var value = listBox.SelectedItem.ToString();
            var path  = GetFullPathStoryFileByFileName(value);

            //Получаем расширение из имени файла
            HelperFileName.ParsePath(path, out var _, out var __, out var ext);
            //Получаем нужный объект для считывания документа (зависит от расширения)
            IDocumentReader reader = HelperDocumentReader.CreateReader(ext);

            if (reader == null)
            {
                this.TextContainerDocumentContent.TextField.Text = "Не удалось считать данные из документа!";
                return;
            }

            reader.OpenDocument(path);
            if (reader.ReadAllTextData(out var data))
            {
                this.TextContainerDocumentContent.TextField.Text = data;
            }
            reader.CloseDocument();
        }
Esempio n. 2
0
        public override void InternalParse(Container container, IDocumentReader reader, Func <string, bool> predicate, ref List <string> buffer,
                                           ref AttributeList attributes)
        {
            var match = PatternMatcher.Admonition.Match(reader.Line);

            if (!match.Success)
            {
                throw new ArgumentException("not an admonition");
            }

            buffer.Add(match.Groups["text"].Value);
            reader.ReadLine();
            while (reader.Line != null && !PatternMatcher.BlankCharacters.IsMatch(reader.Line))
            {
                buffer.Add(reader.Line);
                reader.ReadLine();
            }

            var admonition = new Admonition(match.Groups["style"].Value.ToEnum <AdmonitionStyle>());

            admonition.Attributes.Add(attributes);
            ProcessParagraph(admonition, ref buffer);
            container.Add(admonition);
            attributes = null;

            reader.ReadLine();
        }
Esempio n. 3
0
        public void Parse(
            Container container,
            IDocumentReader reader,
            Func <string, bool> predicate,
            ref List <string> buffer,
            ref AttributeList attributes)
        {
            var match = PatternMatcher.Anchor.Match(reader.Line);

            if (!match.Success)
            {
                throw new ArgumentException("not an anchor");
            }

            var id = match.Groups["id"].Value;

            var reference = !string.IsNullOrEmpty(match.Groups["reference"].Value)
                ? match.Groups["reference"].Value
                : null;

            var anchor = new Anchor(id, reference);

            if (attributes != null)
            {
                attributes.Add(anchor);
            }
            else
            {
                attributes = new AttributeList {
                    anchor
                };
            }

            reader.ReadLine();
        }
Esempio n. 4
0
        public static async Task <TView> GetOrNewAsync <TView>(this IDocumentReader <unit, TView> reader)
            where TView : new()
        {
            var entityMaybe = await reader.GetAsync(unit.it).ConfigureAwait(false);

            return(entityMaybe.GetValue(new TView()));
        }
Esempio n. 5
0
 /* ----------------------------------------------------------------- */
 ///
 /// Save
 ///
 /// <summary>
 /// Saves the PDF document to the specified file path.
 /// </summary>
 ///
 /// <param name="src">Source reader.</param>
 /// <param name="options">Save options.</param>
 /// <param name="prev">Action to be invoked before saving.</param>
 /// <param name="next">Action to be invoked after saving.</param>
 ///
 /* ----------------------------------------------------------------- */
 public void Save(IDocumentReader src, SaveOption options, Action <Entity> prev, Action <Entity> next) => Invoke(() =>
 {
     Value.Set(Properties.Resources.MessageSaving, options.Destination);
     var itext = src ?? Value.Source.GetItext(Value.Query, Value.IO, false);
     Value.Set(itext.Metadata, itext.Encryption);
     using (var dest = new SaveAction(itext, Value.Images, options)) dest.Invoke(prev, next);
 });
Esempio n. 6
0
        private void Parse(Container parent, IDocumentReader reader, Regex delimiterRegex)
        {
            var           buffer     = new List <string>(8);
            AttributeList attributes = null;

            DescendingParse(parent, reader, delimiterRegex.IsMatch, ref buffer, ref attributes);
        }
Esempio n. 7
0
        public override void Read(IDocumentReader reader)
        {
            if (!CanOpenContent)
                return;

            using (Stream str = m_fileData.BinaryFileData.AsStream())
            {
                EmailFormatHandler handler = EmailFormatHandler.ReadEmail(str);
                if (null == handler)
                    return;

                bool cancel = false;
                reader.OnContentData("Subject", handler.Subject, ref cancel);

                if (Utils.IsStringHTML(handler.Body))
                {
                    byte[] bytes = Encoding.Unicode.GetBytes(handler.Body);
                    ReadContent(reader, new HtmlReader(bytes));
                }
                else
                    reader.OnContentData("Body", handler.Body, ref cancel);

                foreach (string attachment in handler)
                {
                    reader.OnContentData("Attachments", attachment, ref cancel);
                }
            }
        }
Esempio n. 8
0
        public override void InternalParse(Container container, IDocumentReader reader, Func <string, bool> predicate, ref List <string> buffer,
                                           ref AttributeList attributes)
        {
            var match = PatternMatcher.Title.Match(reader.Line);

            if (!match.Success)
            {
                throw new ArgumentException("not a block title");
            }

            var title = new Title(match.Groups["title"].Value);

            if (attributes != null)
            {
                attributes.Add(title);
            }
            else
            {
                attributes = new AttributeList {
                    title
                }
            };

            reader.ReadLine();
        }
    }
Esempio n. 9
0
 public AddQuestionProcessor(IDocumentReader <QuestionDto> reader, IDocumentWriter <QuestionDto> writer)
 {
     _reader          = reader;
     _writer          = writer;
     _dtoParser       = new QuestionDtoParser();
     _domainValidator = new DomainValidator();
 }
Esempio n. 10
0
        public HashSet <string> Process(IDocumentReader reader)
        {
            var res = new HashSet <string>();

            while (!reader.EndOfFile())
            {
                var line = reader.ReadLine().ToLower();
                if (line != string.Empty)
                {
                    //split line into sentences
                    var sent = textProcessor.GetSentences(line);
                    foreach (var s in sent)
                    {
                        //tokenize
                        var toks = textProcessor.Tokenize(s);
                        foreach (var t in toks)
                        {
                            //add full word
                            if (!res.Contains(t) && !stopwords.Exists(t))
                            {
                                res.Add(t);
                            }
                            //add stemmed word
                            var st = textProcessor.Stem(t);
                            if (!res.Contains(st) && !stopwords.Exists(st))
                            {
                                res.Add(st);
                            }
                        }
                    }
                }
            }
            return(res);
        }
        public static bool IsErrorsDocument(this IDocumentReader documentReader)
        {
            Contract.Requires(documentReader != null);

            var documentType = documentReader.GetDocumentType();

            return(documentType.IsErrorsDocument());
        }
Esempio n. 12
0
        public override void InternalParse(Container container, IDocumentReader reader, Func <string, bool> predicate, ref List <string> buffer,
                                           ref AttributeList attributes)
        {
            var match = PatternMatcher.Include.Match(reader.Line);

            if (!match.Success)
            {
                throw new ArgumentException("not an include");
            }

            var include         = new Include(match.Groups["path"].Value);
            var attributesValue = match.Groups["attributes"].Value;

            if (!string.IsNullOrEmpty(attributesValue))
            {
                var attributeValues = SplitOnCharacterOutsideQuotes(attributesValue);
                foreach (var attributeValue in attributeValues)
                {
                    var attributeMatch = PatternMatcher.AttributeNameValue.Match(attributeValue);
                    if (attributeMatch.Success)
                    {
                        switch (attributeMatch.Groups["name"].Value.ToLowerInvariant())
                        {
                        case "leveloffset":
                            if (int.TryParse(attributeMatch.Groups["value"].Value, out var offset))
                            {
                                include.LevelOffset = offset;
                            }
                            break;

                        case "lines":
                            include.Lines = attributeMatch.Groups["value"].Value;
                            break;

                        case "tag":
                        case "tags":
                            include.Tags = attributeMatch.Groups["value"].Value;
                            break;

                        case "indent":
                            if (int.TryParse(attributeMatch.Groups["value"].Value, out var indent))
                            {
                                include.Indent = indent;
                            }
                            break;

                        default:
                            throw new NotImplementedException("TODO: add attribute to include attribute list");
                        }
                    }
                }
            }

            container.Add(include);
            attributes = null;

            reader.ReadLine();
        }
        public override void InternalParse(Container container, IDocumentReader reader, Func <string, bool> predicate, ref List <string> buffer,
                                           ref AttributeList attributes)
        {
            var comment = new Comment(reader.Line.Substring(2));

            container.Add(comment);

            reader.ReadLine();
        }
        public static bool IsValidDocument(this IDocumentReader documentReader)
        {
            Contract.Requires(documentReader != null);

            var documentType = documentReader.GetDocumentType();
            var documentMeta = documentReader.GetDocumentMeta();

            return(documentType.IsValidDocument(documentMeta));
        }
Esempio n. 15
0
 public DocumentWriter(DocumentDbConfiguration docDbConfiguration, IDocumentReader <T> documentReader, ICollectionNameResolver collectionNameResolver)
 {
     _docDbConfiguration     = docDbConfiguration;
     _documentClient         = new DocumentClient(new Uri(_docDbConfiguration.Endpoint), _docDbConfiguration.PrimaryKey);
     _documentReader         = documentReader;
     _collectionNameResolver = collectionNameResolver;
     _collectionName         = _collectionNameResolver.Resolve(typeof(T));
     Init().Wait();
 }
Esempio n. 16
0
 public BufferedDocumentWriter(IDocumentReader <TKey, TEntity> reader, IDocumentWriter <TKey, TEntity> writer, IDocumentStrategy strategy)
 {
     this._reader        = reader;
     this._writer        = writer;
     this._strategy      = strategy;
     this._viewsCache    = new ConcurrentDictionary <string, TEntity>();
     this._viewsToDelete = new ConcurrentDictionary <string, bool>();
     this._keys          = new ConcurrentDictionary <string, TKey>();
 }
Esempio n. 17
0
        public override void InternalParse(Container container, IDocumentReader reader, Func <string, bool> predicate, ref List <string> buffer,
                                           ref AttributeList attributes)
        {
            var match = PatternMatcher.ElementAttribute.Match(reader.Line);

            if (!match.Success)
            {
                throw new ArgumentException("not a block attribute");
            }

            var attributesValue = match.Groups["attributes"].Value.Trim();

            if (attributes == null)
            {
                attributes = new AttributeList();
            }

            if (attributesValue.IndexOf(",", StringComparison.Ordinal) == -1)
            {
                switch (attributesValue)
                {
                case "float":
                    attributes.IsFloating = true;
                    reader.ReadLine();
                    return;

                case "discrete":
                    attributes.IsDiscrete = true;
                    reader.ReadLine();
                    return;

                default:
                    attributes.Add(ParseElementAttributesWithPosition(attributesValue, 0));
                    reader.ReadLine();
                    return;
                }
            }

            var inputs = SplitOnCharacterOutsideQuotes(attributesValue);

            if (inputs[0] == "quote" || inputs[0] == "verse")
            {
                for (var index = 0; index < inputs.Length; index++)
                {
                    var i = inputs[index];
                    attributes.Add(new Attribute(i, true));
                }
                reader.ReadLine();
                return;
            }

            var attributeLists = inputs.Select(ParseElementAttributesWithPosition);

            attributes = attributeLists.Aggregate(attributes, (first, second) => first.Add(second));

            reader.ReadLine();
        }
Esempio n. 18
0
        /// <summary>
        /// Parses text from <see cref="IDocumentReader"/> into an <see cref="Document"/>
        /// </summary>
        /// <param name="reader">The reader.</param>
        /// <returns>An new instance of <see cref="Document"/></returns>
        public Document Parse(IDocumentReader reader)
        {
            var           document   = new Document(reader.Path);
            var           buffer     = new List <string>(8);
            AttributeList attributes = null;

            Parse(document, reader, null, ref buffer, ref attributes);
            return(document);
        }
Esempio n. 19
0
        /// <summary>
        /// Gets the single CLR resource by resource identifier lookup.
        /// </summary>
        /// <typeparam name="TResource">Type of CLR resource to find.</typeparam>
        /// <typeparam name="TResourceId">Type of CLR resource identifier.</typeparam>
        /// <param name="clrResourceId">CLR resource identifier value to lookup the single CLR resource with.</param>
        /// <returns>Returns the single CLR resource if found, null otherwise.</returns>
        /// <exception cref="DocumentReadException">Is thrown if there are
        /// multiple CLR resources with the same resource identifier for the given CLR resource type.</exception>
        public static TResource GetResource <TResource, TResourceId>(this IDocumentReader documentReader, TResourceId clrResourceId)
            where TResource : class
        {
            Contract.Requires(documentReader != null);

            var clrResourceType = typeof(TResource);
            var clrResource     = (TResource)documentReader.GetResource(clrResourceType, clrResourceId);

            return(clrResource);
        }
Esempio n. 20
0
        /// <summary>
        /// Gets the multiple CLR resources for the given CLR resource type.
        /// </summary>
        /// <typeparam name="TResource">Type of CLR resource to get.</typeparam>
        /// <returns>Returns the LINQ-to-objects collection of CLR resources if they exist,
        /// empty collection otherwise.</returns>
        public static IEnumerable <TResource> GetResourceCollection <TResource>(this IDocumentReader documentReader)
            where TResource : class
        {
            Contract.Requires(documentReader != null);

            var clrResourceType       = typeof(TResource);
            var clrResourceCollection = documentReader.GetResourceCollection(clrResourceType).Cast <TResource>();

            return(clrResourceCollection);
        }
Esempio n. 21
0
        public static Maybe <TEntity> Get <TKey, TEntity>(this IDocumentReader <TKey, TEntity> self, TKey key)
        {
            TEntity entity;

            if (self.TryGet(key, out entity))
            {
                return(entity);
            }
            return(Maybe <TEntity> .Empty);
        }
Esempio n. 22
0
        public static Maybe <TSingleton> Get <TSingleton>(this IDocumentReader <unit, TSingleton> reader)
        {
            TSingleton singleton;

            if (reader.TryGet(unit.it, out singleton))
            {
                return(singleton);
            }
            return(Maybe <TSingleton> .Empty);
        }
        /// <summary>
        /// Gets the single CLR resource identifier for the given CLR resource type.
        /// </summary>
        /// <remarks>
        /// The CLR based resource identifier can come from either a json:api resource object or
        /// a resource identifier.
        /// </remarks>
        /// <typeparam name="TResource">Type of CLR resource to find.</typeparam>
        /// <typeparam name="TResourceId">Type of CLR resource identifier.</typeparam>
        /// <returns>Returns the single CLR resource identifier if it exists, null otherwise.</returns>
        /// <exception cref="DocumentReadException">Is thrown if there are
        /// multiple CLR resource identifiers for the given CLR resource type.</exception>
        public static TResourceId GetResourceId <TResource, TResourceId>(this IDocumentReader documentReader)
            where TResource : class, IResource
        {
            Contract.Requires(documentReader != null);

            var clrResourceType = typeof(TResource);
            var clrResourceId   = documentReader.GetResourceId <TResourceId>(clrResourceType);

            return(clrResourceId);
        }
        /// <summary>
        /// Gets the single resource or resource identifier json:api meta object for the given CLR resource type.
        /// </summary>
        /// <typeparam name="TResource">Type of CLR resource or resource identifier to get meta for.</typeparam>
        /// <returns>Returns the single <c>Meta</c> object if the CLR resource or resource identifier exists, null otherwise.</returns>
        /// <exception cref="DocumentReadException">Is thrown if there are
        /// multiple CLR resources or resource identifiers for the given CLR resource type.</exception>
        public static Meta GetResourceMeta <TResource>(this IDocumentReader documentReader)
            where TResource : class, IResource
        {
            Contract.Requires(documentReader != null);

            var clrResourceType = typeof(TResource);
            var apiResourceMeta = documentReader.GetResourceMeta(clrResourceType);

            return(apiResourceMeta);
        }
        /// <summary>
        /// Gets the single resource json:api links object by resource identifier lookup.
        /// </summary>
        /// <typeparam name="TResource">Type of CLR resource.</typeparam>
        /// <typeparam name="TResourceId">Type of CLR resource identifier.</typeparam>
        /// <param name="clrResourceId">CLR resource identifier value to lookup the single json:api links object with.</param>
        /// <returns>Returns the single json:api links object if found, null otherwise.</returns>
        /// <exception cref="DocumentReadException">Is thrown if there are
        /// multiple CLR resources with the same resource identifier for the given CLR resource type.</exception>
        public static Links GetResourceLinks <TResource, TResourceId>(this IDocumentReader documentReader, TResourceId clrResourceId)
            where TResource : class, IResource
        {
            Contract.Requires(documentReader != null);

            var clrResourceType  = typeof(TResource);
            var apiResourceLinks = documentReader.GetResourceLinks(clrResourceType, clrResourceId);

            return(apiResourceLinks);
        }
Esempio n. 26
0
 public CountIt(IDocumentReader documentReader, IDocumentDictionary documentDictionary,
                IView userView, IWordEncoder wordEncoder, IWordFilter[] filters, IWordFormatter[] formatters)
 {
     _documentReader     = documentReader;
     _documentDictionary = documentDictionary;
     _userView           = userView;
     _wordEncoder        = wordEncoder;
     _filters            = filters;
     _formatters         = formatters;
 }
        /// <summary>
        /// Gets all resource json:api links objects for the given CLR resource type.
        /// </summary>
        /// <typeparam name="TResource">Type of CLR resource or resource identifier to get links collection for.</typeparam>
        /// <returns>Collection of <c>Links</c> objects in document order.</returns>
        public static IEnumerable <Links> GetResourceLinksCollection <TResource>(this IDocumentReader documentReader)
            where TResource : class, IResource
        {
            Contract.Requires(documentReader != null);

            var clrResourceType            = typeof(TResource);
            var apiResourceLinksCollection = documentReader.GetResourceLinksCollection(clrResourceType);

            return(apiResourceLinksCollection);
        }
        /// <summary>
        /// Gets the single resource json:api relationships object for the given CLR resource type.
        /// </summary>
        /// <typeparam name="TResource">Type of CLR resource or resource identifier to get relationships for.</typeparam>
        /// <returns>Returns the single <c>Meta</c> object if the CLR resource exists, null otherwise.</returns>
        /// <exception cref="DocumentReadException">Is thrown if there are
        /// multiple CLR resources for the given CLR resource type.</exception>
        public static Relationships GetResourceRelationships <TResource>(this IDocumentReader documentReader)
            where TResource : class, IResource
        {
            Contract.Requires(documentReader != null);

            var clrResourceType          = typeof(TResource);
            var apiResourceRelationships = documentReader.GetResourceRelationships(clrResourceType);

            return(apiResourceRelationships);
        }
Esempio n. 29
0
        public IEnumerable <FileExtension> Convert(string inputExtension, Stream inputStream, Dictionary <string, Stream> outputStreams)
        {
            IDocumentReader reader = ReaderCatalog.BestMatch(inputExtension);

            if (reader == null)
            {
                return(Enumerable.Empty <FileExtension>());
            }

            (IDocumentWriter writer, Stream stream)[] writers = outputStreams.Select(e => (WriterCatalog.BestMatch(e.Key), e.Value)).ToArray();
        public DocumentGenerator(string name, IDocumentReader reader, IDataGenerationJobService jobService,
                                 IDocumentMetadataService metadataService, AnmatConfiguration configuration)
        {
            this.reader          = reader;
            this.jobService      = jobService;
            this.metadataService = metadataService;
            this.configuration   = configuration;

            this.Name     = name;
            this.Metadata = this.GetMetadata();
        }
Esempio n. 31
0
        /* ----------------------------------------------------------------- */
        ///
        /// Restruct
        ///
        /// <summary>
        /// Restructs some properties with the specified new PDF document.
        /// </summary>
        ///
        /// <param name="src">Facade object.</param>
        /// <param name="doc">New PDF document.</param>
        ///
        /* ----------------------------------------------------------------- */
        public static void Restruct(this MainFacade src, IDocumentReader doc)
        {
            var items = doc.Pages.Select((v, i) => new { Value = v, Index = i });

            foreach (var e in items)
            {
                src.Bindable.Images[e.Index].RawObject = e.Value;
            }
            src.Bindable.Source.Value = doc.File;
            src.Bindable.History.Clear();
        }
 public EventStoreToQueueDistributor(
     string queueName,
     IQueueFactory queueFactory,
     IEventStore eventStore,
     IDocumentStore projectionStore,
     ISerializer serializer)
 {
     _markerReader = projectionStore.GetReader<string, EventStoreMarker>();
     _markerWriter = projectionStore.GetWriter<string, EventStoreMarker>();
     _queueName = queueName;
     _eventStore = eventStore;
     _queueWriter = queueFactory.CreateWriter(queueName);
     _serializer = new QueueMessageSerializer(serializer);
 }
Esempio n. 33
0
        public override void Read(IDocumentReader reader)
        {
            if (!CanOpenContent)
                return;

            foreach (IContainer container in Files)
            {
                IFile file = container as IFile;
                if (null == file)
                    continue;

                file.Read(reader);
            }
        }
Esempio n. 34
0
        private static void bulkTransfer(IDocumentReader reader, IDocumentWriter writer)
        {
            using (reader)
            {
                using (writer)
                {
                    writer.Schema = reader.Schema;

                    while (reader.Read())
                    {
                        var doc = reader.Current;
                        writer.Write(doc);
                    }
                }
            }
        }
Esempio n. 35
0
        public override void Read(IDocumentReader reader)
        {
            return;
            // Just return, don't read the children of the folder. Same logic applies as
            // with the ExpandContainer argument above.
            // If we ever expose a folder type as file type in policy design then this must be revisited
            // and the code below may be uncommented again. Laku 19/1/2009.
            // PS: folder type removed from designer with this integration as well.

            //if (!CanOpenContent)
            //    return;

            //foreach (IContainer container in Files)
            //{
            //    IFile file = container as IFile;
            //    if (null == file)
            //        continue;

            //    file.Read(reader);
            //}
        }
Esempio n. 36
0
        private static void HiddenSheet(IDocumentReader reader, string typeText, IAbstractTextType textType)
        {
            List<string> list = _typeList2List(textType);

            foreach (string item in list)
            {
                string builtString = item;

                reader.OnContentData(typeText, builtString, ref MetadataProcessor._cancel);
            }

        }
Esempio n. 37
0
        private static void AutoVersion(IDocumentReader reader, string typeText, IAbstractTextType textType)
        {
            string builtString = _typeList2String(textType);

            reader.OnContentData(typeText, builtString, ref MetadataProcessor._cancel);
        }
Esempio n. 38
0
        private static void DocumentStatistics(
                                        IDocumentReader reader, string typeText, IAbstractTextType textType)
        {
            List<KeyValuePair<string, string>> pairList = _typeList2Pair("Name", "Value", textType);

            try
            {

                for (int i = 0; i < pairList.Count; ++i)
                {
                    KeyValuePair<string, string> pair = pairList[i];

                    string builtString = @"";
                    builtString += @"<" + typeText;
                    builtString += @" Name=""";
                    builtString += pair.Key;
                    builtString += @"""";
                    builtString += @" Value=""";
                    builtString += pair.Value;
                    builtString += @"""";
                    builtString += @" />";

                    reader.OnContentData(typeText, builtString, ref MetadataProcessor._cancel);
                }
            }
            catch (System.Exception e)
            {
				Logger.LogError("Exception within MetadataProcessor::DocumentStatistics for " + typeText + ", " + textType);
				Logger.LogError(e);

            }
        }
Esempio n. 39
0
        private static void RedactedText(IDocumentReader reader, string typeText, IAbstractTextType textType)
        {
            /*
            textNode.GetInfo(0)
                name: "Content"
                type: String
                value: "http://www.csub.edu/"
            textNode.GetInfo(1)
                name: "SheetName"
                type: String
                value: "Sheet1"
            textNode.GetInfo(2)
                name: "Row"
                type: Long
                value: "67"
            textNode.GetInfo(3)
                name: "Column"
                type: Long
                value: "1"
            */
            for (int i = 0; i < textType.GetChildCount(); ++i)
            {
                IAbstractTextNode textNode = textType.GetChild(i);

                string content = _nodeValueFromName(textNode, "Content");
                string sheet = _nodeValueFromName(textNode, "SheetName");
                string row = _nodeValueFromName(textNode, "Row");
                string column = _nodeValueFromName(textNode, "Column");

                StringBuilder builtString = new StringBuilder(@"");               
                builtString.Append(@"<" + typeText);
                builtString.Append(@" Row=""");
                builtString.Append(row);
                builtString.Append(@"""");
                builtString.Append(@" Column=""");
                builtString.Append(column);
                builtString.Append(@""">");

                builtString.Append(@"<Content>");
                builtString.Append(content);
                builtString.Append(@"</Content>");

                builtString.Append(@"<Sheet>");
                builtString.Append(sheet);
                builtString.Append(@"</Sheet>");

                builtString.Append(@"</" + typeText + @">");

                reader.OnContentData(typeText, builtString.ToString(), ref MetadataProcessor._cancel);
            }
        }
Esempio n. 40
0
        /// -----------------------------------------------------------------------------
        public static void ProcessType(IDocumentReader reader, string typeText, IAbstractTextType textType)
        {
            try
            {
                switch (textType.GetContentType())
                {
                    case ContentType.Paragraph:
                        MetadataProcessor.Paragraphs(reader, "Paragraph", textType);
                        break;
                    case ContentType.Header:
                        MetadataProcessor.Headers(reader, "Header", textType);
                        break;
                    case ContentType.Footer:
                        MetadataProcessor.Footers(reader, "Footer", textType);
                        break;
                    case ContentType.Comment:
                        MetadataProcessor.Comments(reader, "Comment", textType);
                        break;
                    case ContentType.TrackChange:
                        MetadataProcessor.TrackChanges(reader, "TrackChange", textType);
                        break;
                    case ContentType.Reviewer:
                        MetadataProcessor.Reviewers(reader, "Reviewer", textType);
                        break;
                    case ContentType.HiddenText:
                        MetadataProcessor.HiddenTexts(reader, "HiddenText", textType);
                        break;
                    case ContentType.SmallText:
                        MetadataProcessor.SmallTexts(reader, "SmallText", textType);
                        break;
                    case ContentType.WhiteText:
                        MetadataProcessor.WhiteTexts(reader, "WhiteText", textType);
                        break;
                    case ContentType.AttachedTemplate:
                        MetadataProcessor.AttachedTemplate(reader, "AttachedTemplate", textType);
                        break;
                    case ContentType.Version:
                        MetadataProcessor.Versions(reader, "Version", textType);
                        break;
                    case ContentType.AutoVersion:
                        MetadataProcessor.AutoVersion(reader, "AutoVersion", textType);
                        break;
                    case ContentType.Field:
                        MetadataProcessor.Fields(reader, "Field", textType);
                        break;
                    case ContentType.Hyperlink:
                        MetadataProcessor.HyperLinks(reader, "Hyperlink", textType);
                        break;
                    case ContentType.RoutingSlip:
                        MetadataProcessor.RoutingSlip(reader, "RoutingSlip", textType);
                        break;
                    case ContentType.Variable:
                        MetadataProcessor.Variables(reader, "Variable", textType);
                        break;
                    case ContentType.HiddenSlide:
                        MetadataProcessor.HiddenSlide(reader, "HiddenSlide", textType);
                        break;
                    case ContentType.SpeakerNote:
                        MetadataProcessor.SpeakerNote(reader, "SpeakerNote", textType);
                        break;
                    case ContentType.Links:
                        MetadataProcessor.Links(reader, "Link", textType);
                        break;
                    case ContentType.HiddenSheet:
                        MetadataProcessor.HiddenSheet(reader, "HiddenSheet", textType);
                        break;
                    case ContentType.HiddenRow:
                        MetadataProcessor.HiddenRow(reader, "HiddenRow", textType);
                        break;
                    case ContentType.HiddenColumn:
                        MetadataProcessor.HiddenColumn(reader, "HiddenColumn", textType);
                        break;
                    case ContentType.RedactedText:
                        MetadataProcessor.RedactedText(reader, "RedactedText", textType);
                        break;
                    case ContentType.CustomProperty:
                        MetadataProcessor.CustomProperties(reader, "CustomProperty", textType);
                        break;
                    case ContentType.Macro:
                        MetadataProcessor.Macros(reader, "Macro", textType);
                        break;
                    case ContentType.BuiltInProperty:
                        MetadataProcessor.BuildInProperties(reader, "BuiltInProperty", textType);
                        break;
                    case ContentType.DocumentStatistic:
                        MetadataProcessor.DocumentStatistics(reader, "DocumentStatistic", textType);
                        break;
                    case ContentType.Footnote:
                    case ContentType.Endnote:
                        MetadataProcessor.Footnotes(reader, "Footnote", textType);
                        break;
                    case ContentType.TextBox:
                        /// ProcessTextType(reader, "TextBox", textType);
                        break;
                    case ContentType.CellText:
                        //ProcessTextType(reader, "CellText", textType);
                        break;
                    case ContentType.WorkshareProperty:
                        /// ProcessTextType(reader, "WorkshareProperty", textType);
                        break;
                    case ContentType.SmartTag:
                        /// ProcessTextType(reader, "SmartTag", textType);
                        break;
					case ContentType.WorkshareStyle:
						MetadataProcessor.WhiteTexts(reader, "WorkshareStyle", textType);
						break;
                    default:
                        /// throw new ApplicationException("Invalid Content Type in DocumentText! Enums out of date.");
                        break;
                }
            }
            catch (System.Exception e)
            {
				Logger.LogError("Exception within MetadataProcessor::ProcessType for " + textType.GetContentType());
				Logger.LogError(e);
            }
        }
Esempio n. 41
0
        public static void Paragraphs(IDocumentReader reader, string typeText, IAbstractTextType textType)
        {
            List<string> list = _typeList2List(textType);

            foreach (string item in list)
            {
                if (!_isCommentOrParagraphMarker(item))
                {
                    string builtString = _putCDataSection(item);

                    reader.OnContentData(typeText, builtString, ref MetadataProcessor._cancel);
                }
            }
        }
Esempio n. 42
0
        public static void TrackChanges(IDocumentReader reader, string typeText, IAbstractTextType textType)
        {
            int trackChangeLimit = MetadataProcessor._TrackChangeLimit;

            for (int i = 0; i < textType.GetChildCount() && i < trackChangeLimit; ++i)
            {
                IAbstractTextNode textNode = textType.GetChild(i);

                string content = _nodeValueFromName(textNode, "Content");
                string author = _nodeValueFromName(textNode, "Author");
                string type = _nodeValueFromName(textNode, "Type");

                if (!_isCommentOrParagraphMarker(content))
                {
                    string builtString = @"";
                    builtString += @"<" + typeText;
                    builtString += @" Author=""";
                    builtString += author;
                    builtString += @"""";
                    builtString += @" Type=""";
                    builtString += type;
                    builtString += @""">";
                    builtString += _putCDataSection(content);
                    builtString += @"</" + typeText + @">";

                    reader.OnContentData(typeText, builtString, ref MetadataProcessor._cancel);
                }
            }
        }
Esempio n. 43
0
        public static void WhiteTexts(IDocumentReader reader, string typeText, IAbstractTextType textType)
        {
            List<string> list = _typeList2List(textType);

            try
            {

                foreach (string item in list)
                {
                    if (!_isCommentOrParagraphMarker(item) && !_isCommentMarker(item))
                    {
                        string builtString = @"";
                        builtString += @"<" + typeText + @">";
                        builtString += _putCDataSection(item);
                        builtString += @"</" + typeText + @">";

                        reader.OnContentData(typeText, builtString, ref MetadataProcessor._cancel);
                    }
                }
            }
            catch (System.Exception e)
            {
				Logger.LogError("Exception within MetadataProcessor::WhiteTexts for " + typeText + ", " + textType);
				Logger.LogError(e);
            }
        }
Esempio n. 44
0
        public static void HiddenTexts(IDocumentReader reader, string typeText, IAbstractTextType textType)
        {
            try
            {
                for (int loopi = 0; loopi < textType.GetChildCount(); ++loopi)
                {
                    IAbstractTextNode textNode = textType.GetChild(loopi);
                    string content = _nodeValueFromName(textNode, "Content");
                    if (!_isCommentOrParagraphMarker(content))
                    {
                        string builtString = @"";
                        builtString += @"<" + typeText;

                        for (int loopj = 0; loopj < textNode.GetInfoCount(); ++loopj)
                        {
                            NodeInfo nodeInfo = textNode.GetInfo(loopj);
                            string nodeValue = (nodeInfo != null) ? nodeInfo.value : "";
                            string nodeKey = (nodeInfo != null) ? nodeInfo.name : "";

                            if (!nodeKey.Equals("Content"))
                            {
                                builtString += @" ";
                                builtString += nodeKey;
                                builtString += @"=""";
                                builtString += nodeValue;
                                builtString += @"""";
                            }
                        }
                        builtString += @">";
                        builtString += _putCDataSection(content);
                        builtString += @"</" + typeText + @">";
                        reader.OnContentData(typeText, builtString, ref MetadataProcessor._cancel);
                    }
                }
            }
            catch (System.Exception e)
            {
				Logger.LogError("Exception within MetadataProcessor::HiddenTexts for " + typeText + ", " + textType);
				Logger.LogError(e);
            }
        }
Esempio n. 45
0
        private static void AttachedTemplate(IDocumentReader reader, string typeText, IAbstractTextType textType)
        {
            if (textType.GetChildCount() > 0)
            {
                IAbstractTextNode textNode = textType.GetChild(0);

                string path = _nodeValueFromName(textNode, "Path");
                string name = _nodeValueFromName(textNode, "Name");

                string builtString = @"";
                builtString += @"<" + typeText;
                builtString += @" Name=""";
                builtString += name;
                builtString += @"""";
                builtString += @" Path=""";
                builtString += path;
                builtString += @"""";
                builtString += @" />";

                reader.OnContentData(typeText, builtString, ref MetadataProcessor._cancel);
            }
        }
Esempio n. 46
0
        private static void Fields(IDocumentReader reader, string typeText, IAbstractTextType textType)
        {
            List<KeyValuePair<string, string>> pairList = _typeList2Pair("Instruction", "Content", textType);

            try
            {
                for (int i = 0; i < pairList.Count; ++i)
                {
                    KeyValuePair<string, string> pair = pairList[i];

                    // if (!_isCommentOrParagraphMarker(pair.Value))
					if (!_isHyperlink(pair.Value))	// hyperlinks added separately
                    {
                        string builtString = @"";
                        builtString += @"<" + typeText;
                        builtString += @" Instruction=""";
                        builtString += pair.Key;
                        builtString += @""">";
                        builtString += pair.Value;
                        builtString += @"</" + typeText + @">";

                        reader.OnContentData(typeText, builtString, ref MetadataProcessor._cancel);
                    }
                }
            }
            catch (System.Exception e)
            {
				Logger.LogError("Exception within MetadataProcessor::Fields for " + typeText + ", " + textType);
				Logger.LogError(e);
            }
        }
Esempio n. 47
0
        private static void Macros(IDocumentReader reader, string typeText, IAbstractTextType textType)
        {
            List<string> list = _typeList2List(textType);

            try
            {
                foreach (string item in list)
                {
                    string builtString = item;
                    reader.OnContentData(typeText, builtString, ref MetadataProcessor._cancel);
                }
            }
            catch (System.Exception e)
            {
				Logger.LogError("Exception within MetadataProcessor::Macros for " + typeText + ", " + textType);
				Logger.LogError(e);
            }
        }
Esempio n. 48
0
        private static void HiddenColumn(IDocumentReader reader, string typeText, IAbstractTextType textType)
        {
            List<KeyValuePair<string, string>> pairList = _typeList2Pair("SheetName", "Column", textType);

            for (int i = 0; i < pairList.Count; ++i)
            {
                KeyValuePair<string, string> pair = pairList[i];

                string builtString = @"";
                builtString += @"<" + typeText;
                builtString += @" Column=""";
                builtString += pair.Value;
                builtString += @""">";
                builtString += pair.Key;
                builtString += @"</" + typeText + @">";

                reader.OnContentData(typeText, builtString, ref MetadataProcessor._cancel);
            }
        }
Esempio n. 49
0
        /// <summary>
        /// Converts a <see cref="IODocument"/> to a <see cref="CircuitDocument"/>.
        /// </summary>
        /// <param name="document">The IODocument to convert.</param>
        /// <returns>A CircuitDocument constructed from the IODocument.</returns>
        public static CircuitDocument ToCircuitDocument(this IODocument document, IDocumentReader reader, out List<IOComponentType> unavailableComponents)
        {
            CircuitDocument circuitDocument = new CircuitDocument();
            circuitDocument.Size = document.Size;

            // Set metadata
            circuitDocument.Metadata = new CircuitDocumentMetadata(null, null, document.Metadata);

            // Add components
            unavailableComponents = new List<IOComponentType>();
            foreach (IOComponent component in document.Components)
            {
                ComponentIdentifier identifier = null;

                // Find description
                if (component.Type.GUID != Guid.Empty && ComponentHelper.IsDescriptionAvailable(component.Type.GUID))
                    identifier = new ComponentIdentifier(ComponentHelper.FindDescription(component.Type.GUID));
                if (identifier == null && reader.IsDescriptionEmbedded(component.Type))
                    identifier = LoadDescription(reader.GetEmbeddedDescription(component.Type), component.Type);
                if (identifier == null && component.Type.IsStandard)
                    identifier = ComponentHelper.GetStandardComponent(component.Type.Collection, component.Type.Item);

                if (identifier != null)
                {
                    // Add full component

                    Dictionary<string, object> properties = new Dictionary<string,object>();
                    foreach(var property in component.Properties)
                        properties.Add(property.Key, property.Value);

                    Component addComponent = Component.Create(identifier, properties);
                    addComponent.Layout(component.Location.Value.X, component.Location.Value.Y, (component.Size.HasValue ? component.Size.Value : identifier.Description.MinSize), component.Orientation.Value, component.IsFlipped == true);
                    addComponent.ImplementMinimumSize(addComponent.Description.MinSize);
                    FlagOptions flagOptions = ComponentHelper.ApplyFlags(addComponent);
                    if ((flagOptions & FlagOptions.HorizontalOnly) == FlagOptions.HorizontalOnly && component.Orientation == Orientation.Vertical)
                        addComponent.Orientation = Orientation.Horizontal;
                    else if ((flagOptions & FlagOptions.VerticalOnly) == FlagOptions.VerticalOnly && component.Orientation == Orientation.Horizontal)
                        addComponent.Orientation = Orientation.Vertical;
                    circuitDocument.Elements.Add(addComponent);
                }
                else
                {
                    // Add disabled component

                    if (!unavailableComponents.Contains(component.Type))
                        unavailableComponents.Add(component.Type);

                    DisabledComponent addComponent = new DisabledComponent();

                    Dictionary<string, object> properties = new Dictionary<string,object>();
                    foreach(var property in component.Properties)
                        addComponent.Properties.Add(property.Key, property.Value);

                    addComponent.ImplementationCollection = component.Type.Collection;
                    addComponent.ImplementationItem = component.Type.Item;
                    addComponent.Name = component.Type.Name;
                    addComponent.GUID = component.Type.GUID;
                    if (component.Location.HasValue)
                        addComponent.Location = new Vector(component.Location.Value.X, component.Location.Value.Y);
                    addComponent.Size = component.Size;
                    addComponent.Orientation = component.Orientation;

                    circuitDocument.DisabledComponents.Add(addComponent);
                }
            }

            // Add wires
            IOComponentType wireType = new IOComponentType("wire");
            if (ComponentHelper.WireDescription == null)
            {
                unavailableComponents.Add(wireType);
            }
            else
            {
                foreach (IOWire wire in document.Wires)
                {
                    Dictionary<string, object> properties = new Dictionary<string, object>(4);
                    properties.Add("@x", wire.Location.X);
                    properties.Add("@y", wire.Location.Y);
                    properties.Add("@orientation", wire.Orientation == Orientation.Horizontal);
                    properties.Add("@size", wire.Size);

                    Component wireComponent = Component.Create(ComponentHelper.WireDescription, properties);
                    wireComponent.Layout(wire.Location.X, wire.Location.Y, wire.Size, wire.Orientation, false);
                    wireComponent.ApplyConnections(circuitDocument);
                    circuitDocument.Elements.Add(wireComponent);
                }
            }

            // Connections
            foreach (Component component in circuitDocument.Components)
                component.ApplyConnections(circuitDocument);

            return circuitDocument;
        }
Esempio n. 50
0
        private static void RoutingSlip(IDocumentReader reader, string typeText, IAbstractTextType textType)
        {
            for (int i = 0; i < textType.GetChildCount(); ++i)
            {
                IAbstractTextNode textNode = textType.GetChild(i);

                string message = _nodeValueFromName(textNode, "Message");
                string subject = _nodeValueFromName(textNode, "Subject");

                string builtString = @"";
                builtString += @"<" + typeText;
                builtString += @" Message=""";
                builtString += message;
                builtString += @"""";
                builtString += @" Subject=""";
                builtString += subject;
                builtString += @""">";

                builtString += @"<Recipients>";
                List<NodeInfo> nodeRecipients = textNode.GetInfo("Recipient");
                List<string> recipients = new List<string>();

                foreach (NodeInfo nodeRecipi in nodeRecipients)
                {
                    builtString += @"<Recipient>";
                    builtString += nodeRecipi.value;
                    builtString += @"</Recipient>";
                }

                builtString += @"</Recipients>";
                builtString += @"</" + typeText + @">";

                reader.OnContentData(typeText, builtString, ref MetadataProcessor._cancel);
            }
        }
Esempio n. 51
0
        private static void Footnotes(IDocumentReader reader, string typeText, IAbstractTextType textType)
        {
            List<string> list = _typeList2List(textType);
            foreach (string item in list)
            {
                if (!_isCommentOrParagraphMarker(item) && !_isCommentMarker(item))
                {
                    string builtString = @"";
                    builtString += @"<" + typeText + @">";
                    builtString += _putCDataSection(item);
                    builtString += @"</" + typeText + @">";

                    reader.OnContentData(typeText, builtString, ref MetadataProcessor._cancel);
                }
            }

        }
Esempio n. 52
0
        private static void Versions(IDocumentReader reader, string typeText, IAbstractTextType textType)
        {
            List<KeyValuePair<string, string>> pairList = _typeList2Pair("Saved By", "Comment", textType);

            for (int i = 0; i < pairList.Count; ++i)
            {
                KeyValuePair<string, string> pair = pairList[i];

                string builtString = @"";
                builtString += @"<" + typeText;
                builtString += @" SavedBy=""";
                builtString += pair.Key;
                builtString += @"""";
                builtString += @" Comment=""";
                builtString += pair.Value;
                builtString += @"""";
                builtString += @" />";

                reader.OnContentData(typeText, builtString, ref MetadataProcessor._cancel);
            }

            MetadataProcessor.Authors(pairList);
        }
 public LoginIndexLookupService(IDocumentStore storeFactory)
 {
     if (storeFactory == null) throw new ArgumentNullException("storeFactory");
     _reader = storeFactory.GetReader<byte, LoginIndexLookup>();
 }
Esempio n. 54
0
        private static void HyperLinks(IDocumentReader reader, string typeText, IAbstractTextType textType)
        {
            /*
            DOC
            textNode.GetInfo(0)
                name: "Content"
                type: String
                value: "HYPERLINK"
            XLS
            textNode.GetInfo(0)
                name: "Description"
                type: String
                value: "www.bbc.co.uk/news"
            textNode.GetInfo(1)
                name: "Path"
                type: String
                value: "http://www.bbc.co.uk/news"
            PPT
            textNode.GetInfo(0)
                name: "Content"
                type: String
                value: "HL 1"
            textNode.GetInfo(1)
                name: "Path"
                type: String
                value: "http://www.btyahoo.com/welcome2"
            */
            /// List<KeyValuePair<string, string>> pairList = _typeList2Pair(textType);

            for (int i = 0; i < textType.GetChildCount(); ++i)
            {
                IAbstractTextNode textNode = textType.GetChild(i);

                string keyStr = textNode.GetInfo(0).name;
                string valStr = (textNode.GetInfoCount() > 1) ?
                    textNode.GetInfo(1).value : textNode.GetInfo(0).value;

                string builtString = @"";
                builtString += @"<" + typeText;
                builtString += @" Type=""";
                builtString += keyStr;
                builtString += @""">";
                builtString += _putCDataSection(valStr);
                builtString += @"</" + typeText + @">";

                reader.OnContentData(typeText, builtString, ref MetadataProcessor._cancel);
            }
        }
Esempio n. 55
0
 public void Read(IDocumentReader reader)
 {
     throw new NotImplementedException();
 }
Esempio n. 56
0
        private static void Links(IDocumentReader reader, string typeText, IAbstractTextType textType)
        {
            List<KeyValuePair<string, string>> pairList = _typeList2Pair("Type", "Path", textType);

            for (int i = 0; i < pairList.Count; ++i)
            {
                KeyValuePair<string, string> pair = pairList[i];

                string builtString = @"";
                builtString += @"<" + typeText;
                builtString += @" Type=""";
                builtString += pair.Key;
                builtString += @""">";
                builtString += _putCDataSection(pair.Value);
                builtString += @"</" + typeText + @">";

                reader.OnContentData(typeText, builtString, ref MetadataProcessor._cancel);
            }
        }
Esempio n. 57
0
        private static void SpeakerNote(IDocumentReader reader, string typeText, IAbstractTextType textType)
        {
            List<KeyValuePair<string, string>> pairList = _typeList2Pair("SlideId", "SpeakerNote", textType);

            for (int i = 0; i < pairList.Count; ++i)
            {
                KeyValuePair<string, string> pair = pairList[i];               

                reader.OnContentData(typeText, pair.Value, ref MetadataProcessor._cancel);
            }
        }
Esempio n. 58
0
        /// -----------------------------------------------------------------------------
        private static void BuildInProperties(IDocumentReader reader, string typeText, IAbstractTextType textType)
        {
            try
            {
                List<KeyValuePair<string, string>> pairList = _typeList2Pair("Name", "Value", textType);

                for (int i = 0; i < pairList.Count; ++i)
                {
                    KeyValuePair<string, string> pair = pairList[i];

                    if (!_isCommentOrParagraphMarker(pair.Value))
                    {
                        string builtString = @"";
                        builtString += @"<" + typeText;
                        builtString += @" Name=""";
                        builtString += pair.Key;
                        builtString += @""">";
                        builtString += _putCDataSection(pair.Value);
                        builtString += @"</" + typeText + @">";

                        reader.OnContentData(typeText, builtString, ref MetadataProcessor._cancel);
                    }
                }
            }
            catch (System.Exception e)
            {
				Logger.LogError("Exception within MetadataProcessor::BuildInProperties for " + typeText + ", " + textType);
				Logger.LogError(e);
            }
        }
 public UserGoalIndex(IDocumentReader<GoalId, UserGoalsView> reader)
 {
     _reader = reader;
 }
Esempio n. 60
0
        private static void HiddenSlide(IDocumentReader reader, string typeText, IAbstractTextType textType)
        {
            // ppt we get "SlideId" and "Title"
            List<KeyValuePair<string, string>> pairList = _typeList2Pair("SlideId", "Title", textType);
            // pptx we get "SlideNumber" and "Content"
            if (pairList.Count != 0)
                CheckForPPTx(ref pairList, "SlideNumber", "Content", textType);

            for (int i = 0; i < pairList.Count; ++i)
            {
                KeyValuePair<string, string> pair = pairList[i];

                string builtString = @"";
                builtString += @"<" + typeText;
                builtString += @" SlideId=""";
                builtString += pair.Key;
                builtString += @""">";
                builtString += _putCDataSection(pair.Value);
                builtString += @"</" + typeText + @">";

                reader.OnContentData(typeText, builtString, ref MetadataProcessor._cancel);
            }
        }