Exemple #1
0
        override protected void ExtractMetaData(Gsf.Input sumStream, Gsf.Input docSumStream)
        {
            int     count = 0;
            DocProp prop  = null;

            if (sumMeta != null)
            {
                prop = sumMeta.Lookup("gsf:word-count");
                if (prop != null)
                {
                    count = (int)prop.Val;
                }
                if (count > 0)
                {
                    AddProperty(Beagle.Property.NewUnsearched("fixme:word-count", count));
                }

                count = 0;
                prop  = sumMeta.Lookup("gsf:page-count");
                if (prop != null)
                {
                    count = (int)prop.Val;
                }
                if (count > 0)
                {
                    AddProperty(Beagle.Property.NewUnsearched("fixme:page-count", count));
                }
            }
        }
Exemple #2
0
        override protected void ExtractMetaData(Input sumStream, Input docSumStream)
        {
            int     slide_count = 0;
            DocProp prop        = null;

            if (docSumMeta != null)
            {
                prop = docSumMeta.Lookup("gsf:slide-count");
                if (prop != null)
                {
                    slide_count = (int)prop.Val;
                }
                if (slide_count > 0)
                {
                    AddProperty(Beagle.Property.NewUnsearched("fixme:slide-count", slide_count));
                }
            }
        }
Exemple #3
0
        void PullMetaData(Gsf.Input sum_stream, Gsf.Input doc_stream)
        {
            DocProp prop = null;

            sumMeta = new DocMetaData();
            if (sum_stream != null)
            {
                Msole.MetadataRead(sum_stream, sumMeta);
            }
            else
            {
                Logger.Log.Warn("SummaryInformationStream not found in {0}", FileName);
            }

            docSumMeta = new DocMetaData();
            if (doc_stream != null)
            {
                Msole.MetadataRead(doc_stream, docSumMeta);
            }
            else
            {
                Logger.Log.Warn("DocumentSummaryInformationStream not found in {0}", FileName);
            }

            if (sumMeta != null)
            {
                prop = sumMeta.Lookup("dc:title");
                if (prop != null)
                {
                    AddProperty(Beagle.Property.New("dc:title", prop.Val as string));
                }

                prop = sumMeta.Lookup("dc:subject");
                if (prop != null)
                {
                    AddProperty(Beagle.Property.New("dc:subject", prop.Val as string));
                }

                prop = sumMeta.Lookup("dc:description");
                if (prop != null)
                {
                    AddProperty(Beagle.Property.New("dc:description", prop.Val as string));
                }

                prop = sumMeta.Lookup("gsf:keywords");
                if (prop != null)
                {
                    AddProperty(Beagle.Property.New("fixme:keywords", prop.Val as string));
                }

                prop = sumMeta.Lookup("gsf:creator");
                if (prop != null)
                {
                    AddProperty(Beagle.Property.New("fixme:author", prop.Val as string));
                }

                prop = sumMeta.Lookup("gsf:last-saved-by");
                if (prop != null)
                {
                    AddProperty(Beagle.Property.New("fixme:last-saved-by", prop.Val as string));
                }

                prop = sumMeta.Lookup("gsf:generator");
                if (prop != null)
                {
                    AddProperty(Beagle.Property.New("fixme:generator", prop.Val as string));
                }

                prop = sumMeta.Lookup("gsf:template");
                if (prop != null)
                {
                    AddProperty(Beagle.Property.New("fixme:template", prop.Val as string));
                }
            }

            if (docSumMeta != null)
            {
                prop = docSumMeta.Lookup("gsf:company");
                if (prop != null)
                {
                    AddProperty(Beagle.Property.New("fixme:company", prop.Val as string));
                }

                prop = docSumMeta.Lookup("gsf:category");
                if (prop != null)
                {
                    AddProperty(Beagle.Property.New("fixme:category", prop.Val as string));
                }

                prop = docSumMeta.Lookup("CreativeCommons_LicenseURL");
                if (prop != null)
                {
                    AddProperty(Beagle.Property.New("fixme:license", prop.Val as string));
                }
            }

            ExtractMetaData(sum_stream, doc_stream);

            if (sumMeta != null)
            {
                sumMeta.Dispose();
            }

            if (docSumMeta != null)
            {
                docSumMeta.Dispose();
            }
        }
        private void RunParseCdw()
        {
            if (_xDoc == null)
            {
                return;
            }

            Drawing = new Drawing();
            Prop    = new List <DocProp>();

            var properties = _xDoc.Descendants("property");

            foreach (var prop in properties)
            {
                string id = null, val = null, source = null;
                foreach (var attr in prop.Attributes())
                {
                    if (attr.Name == "id")
                    {
                        id = attr.Value;
                    }
                    if (attr.Name == "value")
                    {
                        val = attr.Value;
                    }
                    if (attr.Name == "source")
                    {
                        source = attr.Value;
                    }
                }
                var propertyDescriptions = _xDoc.Descendants("propertyDescription");
                foreach (var propertyDescription in propertyDescriptions)
                {
                    string id2 = null, name = null, typeValue = null,
                             natureId = null, unitId = null;
                    foreach (var attr in propertyDescription.Attributes())
                    {
                        if (attr.Name == "id")
                        {
                            id2 = attr.Value;
                        }
                        if (attr.Name == "name")
                        {
                            name = attr.Value;
                        }
                        if (attr.Name == "typeValue")
                        {
                            typeValue = attr.Value;
                        }
                        if (attr.Name == "natureId")
                        {
                            natureId = attr.Value;
                        }
                        if (attr.Name == "unitId")
                        {
                            unitId = attr.Value;
                        }
                    }
                    if (id == null || id != id2)
                    {
                        continue;
                    }
                    var spcProp = new DocProp
                    {
                        Name      = name,
                        Value     = val,
                        TypeValue = typeValue,
                        NatureId  = natureId,
                        UnitId    = unitId,
                        Source    = source
                    };
                    Prop.Add(spcProp);
                }
            }

            var sheets = _xDoc.Descendants("sheets");

            foreach (var sheet in sheets)
            {
                var ds = new DrawingSheet();
                // Возможная ошибка в строке  foreach (var attr in sheet.Attributes()).
                //Внутрь цикла попасть не можем потому что мы не учли, что тип xml узла может быть не только XElement, но и XComment.

                /*
                 * foreach (var attr in sheet.Attributes())
                 * {
                 *  string strnum;
                 *  int number;
                 *  if (attr.Name == "format")
                 *  {
                 *      ds.Format = attr.Value;
                 *  }
                 *  if (attr.Name == "orientation")
                 *  {
                 *      strnum = attr.Value;
                 *      if (int.TryParse(strnum, out number))
                 *          ds.Orientation = number;
                 *  }
                 *  if (attr.Name == "height")
                 *  {
                 *      strnum = attr.Value;
                 *      if (int.TryParse(strnum, out number))
                 *          ds.Height = number;
                 *  }
                 *  if (attr.Name != "width") continue;
                 *  strnum = attr.Value;
                 *  if (int.TryParse(strnum, out number))
                 *      ds.Width = number;
                 * }*/
                // Код исправляющий ошибку:
                foreach (XNode attrs in sheet.Nodes())
                {
                    XElement elm = attrs as XElement;

                    if (elm != null)
                    {
                        string strnum;
                        int    number;
                        foreach (XAttribute attr in elm.Attributes())
                        {
                            if (attr.Name == "format")
                            {
                                ds.Format = attr.Value;
                            }
                            if (attr.Name == "orientation")
                            {
                                strnum = attr.Value;
                                if (int.TryParse(strnum, out number))
                                {
                                    ds.Orientation = number;
                                }
                            }
                            if (attr.Name == "height")
                            {
                                strnum = attr.Value;
                                if (int.TryParse(strnum, out number))
                                {
                                    ds.Height = number;
                                }
                            }
                            if (attr.Name != "width")
                            {
                                continue;
                            }
                            strnum = attr.Value;
                            if (int.TryParse(strnum, out number))
                            {
                                ds.Width = number;
                            }
                        }
                    }
                }
                Drawing.Sheets.Add(ds);
            }
            // все циклы завершены
            Drawing.ListSpcProps = Prop;
            IsCompleted          = true;
        }
Exemple #5
0
        private void RunParsingSpw()
        {
            if (_xDoc == null)
            {
                return;
            }
            SpcSections    = new List <SpcSection>();
            ListSpcProps   = new List <DocProp>();
            ListSpcObjects = new List <SpcObject>();

            var properties = _xDoc.Descendants("property");

            foreach (var prop in properties)
            {
                string id = null, val = null;
                foreach (var attr in prop.Attributes())
                {
                    if (attr.Name == "id")
                    {
                        id = attr.Value;
                    }
                    if (attr.Name == "value")
                    {
                        val = attr.Value;
                    }
                }
                var propertyDescriptions = _xDoc.Descendants("propertyDescription");
                foreach (var propertyDescription in propertyDescriptions)
                {
                    string id2 = null, name = null, typeValue = null,
                             natureId = null, unitId = null;
                    foreach (var attr in propertyDescription.Attributes())
                    {
                        if (attr.Name == "id")
                        {
                            id2 = attr.Value;
                        }
                        if (attr.Name == "name")
                        {
                            name = attr.Value;
                        }
                        if (attr.Name == "typeValue")
                        {
                            typeValue = attr.Value;
                        }
                        if (attr.Name == "natureId")
                        {
                            natureId = attr.Value;
                        }
                        if (attr.Name == "unitId")
                        {
                            unitId = attr.Value;
                        }
                    }
                    if (id == null || id != id2)
                    {
                        continue;
                    }
                    var spcProp = new DocProp
                    {
                        Name      = name,
                        Value     = val,
                        TypeValue = typeValue,
                        NatureId  = natureId,
                        UnitId    = unitId
                    };
                    ListSpcProps.Add(spcProp);
                }
            }

            var style = _xDoc.Descendants("spcDescription")
                        .FirstOrDefault()?
                        .Descendants("style")
                        .FirstOrDefault();
            var strTmp = style?.Attributes().FirstOrDefault(x => x.Name == "id")?.Value.Replace(".", ",");

            if (decimal.TryParse(strTmp, out decimal resultTmp))
            {
                IdStyle = (int)resultTmp;
            }
            else
            {
                IdStyle = 0;
            }

            var  sections = _xDoc.Descendants("section");
            bool isName = false, isNumber = false;

            foreach (var section in sections)
            {
                var spcSection = new SpcSection();
                foreach (var attr in section.Attributes())
                {
                    if (attr.Name == "name")
                    {
                        spcSection.Name = attr.Value;
                        isName          = true;
                    }
                    if (attr.Name != "number")
                    {
                        continue;
                    }
                    var strnum = attr.Value;
                    if (int.TryParse(strnum, out var number))
                    {
                        spcSection.Number = number;
                    }
                    isNumber = true;
                }
                if (isName && isNumber)
                {
                    SpcSections.Add(spcSection);
                }
                isName   = false;
                isNumber = false;
            }

            var spcObjects = _xDoc.Descendants("spcObjects");

            foreach (var e in spcObjects)
            {
                foreach (var o in e.Elements())
                {
                    var spcObject = new SpcObject();
                    foreach (var attr in o.Attributes().Where(attr => attr.Name == "id"))
                    {
                        spcObject.Id = attr.Value;
                    }

                    foreach (var context in o.Elements())
                    {
                        if (context.Name.ToString() == "section")
                        {
                            foreach (var strnum in from attr in context.Attributes() where attr.Name == "number" select attr.Value)
                            {
                                if (int.TryParse(strnum, out var number))
                                {
                                    spcObject.SectionNumber = number;
                                }
                            }
                        }
                        if (context.Name.ToString() == "columns")
                        {
                            foreach (var column in context.Elements())
                            {
                                var col = new SpcColumn();
                                foreach (var attr in column.Attributes())
                                {
                                    if (attr.Name == "name")
                                    {
                                        col.Name = attr.Value;
                                    }
                                    if (attr.Name == "typeName")
                                    {
                                        col.TypeName = attr.Value;
                                    }
                                    if (attr.Name == "number")
                                    {
                                        col.Number = Convert.ToInt32(attr.Value);
                                    }
                                    if (attr.Name == "blockNumber")
                                    {
                                        col.BlockNumber = Convert.ToInt32(attr.Value);
                                    }
                                    if (attr.Name == "value")
                                    {
                                        col.Value = attr.Value;
                                    }
                                }
                                // добавляем колонку спецификации в объект
                                spcObject.Columns.Add(col);
                            }
                        }

                        if (context.Name.ToString() == "additionalColumns")
                        {
                            foreach (var column in context.Elements())
                            {
                                var col = new AddColumn();
                                foreach (var attr in column.Attributes())
                                {
                                    if (attr.Name == "name")
                                    {
                                        col.Name = attr.Value;
                                    }
                                    if (attr.Name == "typeName")
                                    {
                                        col.TypeName = attr.Value;
                                    }
                                    if (attr.Name == "number")
                                    {
                                        col.Number = Convert.ToInt32(attr.Value);
                                    }
                                    if (attr.Name == "blockNumber")
                                    {
                                        col.BlockNumber = Convert.ToInt32(attr.Value);
                                    }
                                    if (attr.Name == "value")
                                    {
                                        col.Value = attr.Value;
                                    }
                                }
                                // добавляем колонку спецификации в объект
                                spcObject.AColumns.Add(col);
                            }
                        }

                        if (context.Name.ToString() != "documents")
                        {
                            continue;
                        }
                        foreach (var document in context.Elements())
                        {
                            var doc = new SpcDocument();
                            foreach (var attr in document.Attributes().Where(attr => attr.Name == "fileName"))
                            {
                                doc.FileName = attr.Value;
                            }
                            // добавить документы связанные с объектом спецификации
                            spcObject.Documents.Add(doc);
                        }
                    }
                    // добавляем в список объект спецификации
                    ListSpcObjects.Add(spcObject);
                }
                // парсинг объектов завершён
            }
            // все циклы завершены
            JointSpcNameAndSpcObj();
            // вызываем событие о завершении парсинга.
            IsCompleted = true;
        }
        private void RunParseCdw()
        {
            if (_xDoc == null)
            {
                return;
            }

            Drawing = new Drawing();
            Prop    = new List <DocProp>();

            var properties = _xDoc.Descendants("property");

            foreach (var prop in properties)
            {
                string id = null, val = null, source = null;
                foreach (var attr in prop.Attributes())
                {
                    if (attr.Name == "id")
                    {
                        id = attr.Value;
                    }
                    if (attr.Name == "value")
                    {
                        val = attr.Value;
                    }
                    if (attr.Name == "source")
                    {
                        source = attr.Value;
                    }
                }
                var propertyDescriptions = _xDoc.Descendants("propertyDescription");
                foreach (var propertyDescription in propertyDescriptions)
                {
                    string id2 = null, name = null, typeValue = null,
                             natureId = null, unitId = null;
                    foreach (var attr in propertyDescription.Attributes())
                    {
                        if (attr.Name == "id")
                        {
                            id2 = attr.Value;
                        }
                        if (attr.Name == "name")
                        {
                            name = attr.Value;
                        }
                        if (attr.Name == "typeValue")
                        {
                            typeValue = attr.Value;
                        }
                        if (attr.Name == "natureId")
                        {
                            natureId = attr.Value;
                        }
                        if (attr.Name == "unitId")
                        {
                            unitId = attr.Value;
                        }
                    }
                    if (id == null || id != id2)
                    {
                        continue;
                    }
                    var spcProp = new DocProp
                    {
                        Name      = name,
                        Value     = val,
                        TypeValue = typeValue,
                        NatureId  = natureId,
                        UnitId    = unitId,
                        Source    = source
                    };
                    Prop.Add(spcProp);
                }
            }

            var sheets = _xDoc.Descendants("sheets");

            foreach (var sheet in sheets)
            {
                var ds = new DrawingSheet();
                foreach (var attrs in sheet.Nodes())
                {
                    if (attrs is XElement elm)
                    {
                        foreach (var attr in elm.Attributes())
                        {
                            if (attr.Name == "format")
                            {
                                ds.Format = attr.Value;
                            }
                            int number;
                            if (attr.Name == "orientation")
                            {
                                if (int.TryParse(attr.Value, out number))
                                {
                                    ds.Orientation = number;
                                }
                            }
                            if (attr.Name == "height")
                            {
                                if (int.TryParse(attr.Value, out number))
                                {
                                    ds.Height = number;
                                }
                            }
                            if (attr.Name != "width")
                            {
                                continue;
                            }
                            if (int.TryParse(attr.Value, out number))
                            {
                                ds.Width = number;
                            }
                        }
                    }
                }
                Drawing.Sheets.Add(ds);
            }
            Drawing.ListSpcProps = Prop;
            IsCompleted          = true;
        }