Пример #1
0
        public void ToXml(RIRecordModel record)
        {
            try
            {
                //Record转xml描述文件
                WrapXml obj = new WrapXml();
                obj.filename = record.EntityID + "_" + record.Version;
                obj.filepath = "crcd";
                obj._head    = new head()
                {
                    documentID    = record.DocID,
                    contentFormat = "doc",
                    contentType   = "JP3_RI",
                    documentType  = "crcd",
                    effectiveDate = DateTime.Now.ToString("yyyy-MM-dd"),
                    elementID     = "1",
                    entityID      = record.EntityID,
                    expiredDate   = "9999-12-31"
                    ,
                    subContentFormat = "snapshotFullDocument"
                };

                List <paragraph> _p = new List <paragraph>();
                foreach (var item in record.CheckItem)
                {
                    _p.Add(new paragraph()
                    {
                        Attr_type = "checkitem", checkitemID = item.DocID
                    });
                }
                obj._wrapbody = new WrapBody()
                {
                    _paragraph = _p
                };
                RIRecordXMLService.Instance.Toxml(obj);

                // //Record转xml数据文件
                MetaXml obj2 = new MetaXml();
                obj2.filename = record.EntityID + "_" + record.Version + "_META";
                obj2.filepath = "crcd";
                obj2._head    = new head()
                {
                    documentID       = record.DocID + "_META",
                    contentFormat    = "doc",
                    contentType      = "JP3_RI",
                    documentType     = "crcd",
                    effectiveDate    = DateTime.Now.ToString("yyyy-MM-dd"),
                    elementID        = "1",
                    entityID         = record.EntityID,
                    expiredDate      = "9999-12-31",
                    subContentFormat = "snapshotFullDocument"
                };

                List <Metadata> _p2  = new List <Metadata>();
                Metadata_Main   meta = new Metadata_Main();
                _p2.Add(new Metadata()
                {
                    Attr_type = "packageID", ObjSub = new Metadata_Sub()
                    {
                        text = StringHelper.XMLSpecialCharToConvert(record.PackageID)
                    }
                });
                _p2.Add(new Metadata()
                {
                    Attr_type = "class", ObjSub = new Metadata_Sub()
                    {
                        text = StringHelper.XMLSpecialCharToConvert(record.Topic)
                    }
                });
                _p2.Add(new Metadata()
                {
                    Attr_type = "subclass", ObjSub = new Metadata_Sub()
                    {
                        text = StringHelper.XMLSpecialCharToConvert(record.SubTopic)
                    }
                });
                _p2.Add(new Metadata()
                {
                    Attr_type = "packageIDwithSuffix", ObjSub = new Metadata_Sub()
                    {
                        text = record.PackageID + ";riallmodule"
                    }
                });
                _p2.Add(new Metadata()
                {
                    Attr_type = "documentTitle", ObjSub = new Metadata_Sub()
                    {
                        text = StringHelper.XMLSpecialCharToConvert(record.Title)
                    }
                });
                _p2.Add(new Metadata()
                {
                    Attr_type = "documentNumber", ObjSub = new Metadata_Sub()
                    {
                        text = "30001010010010"
                    }
                });
                _p2.Add(new Metadata()
                {
                    Attr_type = "abstract", ObjSub = new Metadata_Sub()
                    {
                        text = StringHelper.XMLSpecialCharToConvert(record.Summary)
                    }
                });
                _p2.Add(new Metadata()
                {
                    Attr_type = "riskAbstract", ObjSub = new Metadata_Sub()
                    {
                        text = StringHelper.XMLSpecialCharToConvert(record.Risk)
                    }
                });
                _p2.Add(new Metadata()
                {
                    Attr_type = "author", ObjSub = new Metadata_Sub()
                    {
                        text = StringHelper.XMLSpecialCharToConvert(record.Author)
                    }
                });
                foreach (var item in record.CheckItem)
                {
                    _p2.Add(new Metadata()
                    {
                        Attr_type = "importance", Attr_citm_id = item.DocID, ObjSub = new Metadata_Sub()
                        {
                            text = item.Importance.ToString()
                        }
                    });
                    _p2.Add(new Metadata()
                    {
                        Attr_type = "hasMeta", Attr_citm_id = item.DocID, ObjSub = new Metadata_Sub()
                        {
                            text = item.HasMeta
                        }
                    });
                    _p2.Add(new Metadata()
                    {
                        Attr_type = "body", Attr_citm_id = item.DocID, Attr_hasMeta = "Y", ObjMain = new Metadata_Main()
                        {
                            _paragraph = new Metadata_paragraph()
                            {
                                Attr_num = "1", markupText = StringHelper.XMLSpecialCharToConvert(item.CheckItemContent), Attr_type = "body"
                            }
                        }
                    });
                    _p2.Add(new Metadata()
                    {
                        Attr_type = "penalty", Attr_citm_id = item.DocID, ObjSub = new Metadata_Sub()
                        {
                            text = StringHelper.XMLSpecialCharToConvert(item.Penalty)
                        }
                    });
                    _p2.Add(new Metadata()
                    {
                        Attr_type = "reasonCode", Attr_citm_id = item.DocID, ObjSub = new Metadata_Sub()
                        {
                            text = StringHelper.XMLSpecialCharToConvert(item.ReasonCodes)
                        }
                    });
                }
                var _listFile = _fileService.GetFilesById(record.DocID);
                foreach (var temp in _listFile)
                {
                    if (temp.MimeType.Equals("url"))
                    {
                        _p2.Add(new Metadata()
                        {
                            Attr_type = "referenceDocuments", Attr_citm_id = record.CheckItem[0].DocID, Attr_doc_id = temp.DocID, Attr_url = temp.Path, Attr_content = "URL", ObjSub = new Metadata_Sub()
                            {
                                text = StringHelper.XMLSpecialCharToConvert(temp.Path)
                            }
                        });
                    }
                    if (temp.MimeType.Contains("application"))
                    {
                        var _spt      = temp.MimeType.Split('/');
                        var _mimeType = _spt[_spt.Length - 1].ToUpper();
                        _p2.Add(new Metadata()
                        {
                            Attr_type = "referenceDocuments", Attr_citm_id = record.CheckItem[0].DocID, Attr_doc_id = temp.DocID, Attr_content = _mimeType, ObjSub = new Metadata_Sub()
                            {
                                text = StringHelper.XMLSpecialCharToConvert(temp.Title)
                            }
                        });
                    }
                }

                obj2._meta = new Meta()
                {
                    _metadata = _p2
                };
                RIRecordXMLService.Instance.Toxml_Meta(obj2);
                var _userName     = new HttpContextWrapper(HttpContext.Current).User.Identity.Name;
                var _listFileZero = _fileService.GetFilesById("-1", _userName);
                if (_listFileZero != null && _listFileZero.Count > 0)
                {
                    _iRlFileDataProvider.DelFileByDocmentIdForZero(_userName);
                }
                //CheckItem转xml
                foreach (var item in record.CheckItem)
                {
                    //CheckItem描述文件
                    Sub_Xml obj1 = new Sub_Xml();
                    obj1.filename = (Convert.ToInt64(item.EntityID)).ToString() + "_" + item.Version;
                    obj1.filepath = "citm";
                    obj1._head    = new head()
                    {
                        documentID       = item.DocID,
                        contentFormat    = "doc",
                        contentType      = "JP3_RI",
                        documentType     = "citm",
                        effectiveDate    = DateTime.Now.ToString("yyyy-MM-dd"),
                        elementID        = "1",
                        entityID         = (Convert.ToInt64(item.EntityID)).ToString(),
                        expiredDate      = "9999-12-31",
                        subContentFormat = "snapshotFullDocument"
                    };

                    obj1._sub_body = new sub_body()
                    {
                        Attr_type  = "body",
                        Attr_num   = "1",
                        markupText = item.CheckItemContent
                    };

                    RIRecordXMLService.Instance.Toxml_Sub(obj1);

                    //CheckItem数据文件
                    MetaXml obj3 = new MetaXml();
                    obj3.filename = (Convert.ToInt64(item.EntityID)).ToString() + "_" + item.Version + "_META";
                    obj3.filepath = "citm";
                    obj3._head    = new head()
                    {
                        documentID       = item.DocID,
                        contentFormat    = "doc",
                        contentType      = "JP3_RI",
                        documentType     = "citm",
                        effectiveDate    = DateTime.Now.ToString("yyyy-MM-dd"),
                        elementID        = "1",
                        entityID         = (Convert.ToInt64(item.EntityID)).ToString(),
                        expiredDate      = "9999-12-31",
                        subContentFormat = "snapshotFullDocument"
                    };
                    List <Metadata> _p3 = new List <Metadata>();
                    _p3.Add(new Metadata()
                    {
                        Attr_type = "importance", ObjSub = new Metadata_Sub()
                        {
                            text = item.Importance.ToString()
                        }
                    });
                    _p3.Add(new Metadata()
                    {
                        Attr_type = "hasMeta", ObjSub = new Metadata_Sub()
                        {
                            text = item.HasMeta
                        }
                    });
                    _p3.Add(new Metadata()
                    {
                        Attr_type = "penalty", ObjSub = new Metadata_Sub()
                        {
                            text = StringHelper.XMLSpecialCharToConvert(item.Penalty)
                        }
                    });
                    _p3.Add(new Metadata()
                    {
                        Attr_type = "reasonCode", ObjSub = new Metadata_Sub()
                        {
                            text = StringHelper.XMLSpecialCharToConvert(item.ReasonCodes)
                        }
                    });
                    obj3._meta = new Meta()
                    {
                        _metadata = _p3
                    };
                    RIRecordXMLService.Instance.Toxml_Meta(obj3);
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error <lnRIRecordService>("XML Convert Failed! \n", ex);
                throw new RequestErrorException("Model to XMl is failed__" + ex.Message);
            }
        }
Пример #2
0
 public void DelFileByDocmentIdForZero(string _userName)
 {
     _iRlFileDataProvider.DelFileByDocmentIdForZero(_userName);
 }