示例#1
0
        // 在当前集合中每个元素的DOM位置 下级开头 插入新元素
        // 参见 MarcQuery::prepend() 函数的注释
        // 最后返回当前集合
        /// <summary>
        /// 在当前集合的每个元素的 DOM 位置的下级开头插入根据指定的源字符串构造的新元素
        /// </summary>
        /// <param name="strSourceText">源字符串</param>
        /// <returns>当前集合</returns>
        public MarcNodeList prepend(string strSourceText)
        {
            if (this.count == 0 || string.IsNullOrEmpty(strSourceText))
            {
                return(this);
            }

            if (this[0].NodeType == NodeType.None)
            {
                throw new ArgumentException("不允许在 None 节点的 下级开头 添加任何节点");
            }
            if (this[0].NodeType == NodeType.Subfield)
            {
                throw new ArgumentException("不允许在 子字段 节点的 下级开头 添加任何节点。因为子字段本身就是末级节点,不允许出现下级节点");
            }

            MarcNodeList source_nodes = null;
            string       strLeading   = "";

            if (this[0].NodeType == NodeType.Record)
            {
                source_nodes = MarcQuery.createFields(strSourceText);
            }
            else if (this[0].NodeType == NodeType.Field)
            {
                source_nodes = MarcQuery.createSubfields(strSourceText, out strLeading);
                // leading要追加到目标集合的最后一个元素的Content末尾
                if (string.IsNullOrEmpty(strLeading) == false)
                {
                    this.last()[0].Content += strLeading;
                }
            }
            else
            {
                throw new Exception("未知的对象类型 '" + this[0].NodeType.ToString() + "'");
            }

            MarcQuery.prepend(source_nodes, this);
            return(this);
        }
示例#2
0
        void setContent(string strValue)
        {
            // 拆分为字段
            this.ChildNodes.clearAndDetach();
            this.m_strContent = "";

            if (String.IsNullOrEmpty(strValue) == true)
            {
                return;
            }

            // 整理尾部字符
            char tail = strValue[strValue.Length - 1];

            if (tail == 29)
            {
                strValue = strValue.Substring(0, strValue.Length - 1);

                if (String.IsNullOrEmpty(strValue) == true)
                {
                    return;
                }
            }

            this.Header[0, Math.Min(strValue.Length, 24)] = strValue;

            if (strValue.Length <= 24)
            {
                // 只有头标区,没有任何字段
                return;
            }
            this.ChildNodes.add(MarcQuery.createFields(
                                    // this,
                                    strValue.Substring(24),
                                    this.OuterFieldDef));
        }
示例#3
0
        // 在当前集合中每个元素的DOM位置后面插入新元素
        // 参见 MarcQuery::insertAfter() 函数的注释
        // 最后返回当前集合
        /// <summary>
        /// 在当前集合中每个元素的 DOM 位置后面插入新元素,新元素由指定的源字符串构造
        /// </summary>
        /// <param name="strSourceText">源字符串</param>
        /// <returns>当前集合</returns>
        public MarcNodeList after(string strSourceText)
        {
            if (this.count == 0 || string.IsNullOrEmpty(strSourceText))
            {
                return(this);
            }

            if (this[0].NodeType == NodeType.None)
            {
                throw new ArgumentException("不允许在 None 对象的后面添加任何对象");
            }
            if (this[0].NodeType == NodeType.Record)
            {
                throw new ArgumentException("不允许在 记录 对象的后面添加任何对象");
            }

            MarcNodeList source_nodes = null;
            string       strLeading   = "";

            if (this[0].NodeType == NodeType.Field)
            {
                source_nodes = MarcQuery.createFields(strSourceText);
            }
            else
            {
                source_nodes = MarcQuery.createSubfields(strSourceText, out strLeading);
                // leading要追加到目标集合的最后一个元素的Content末尾
                if (string.IsNullOrEmpty(strLeading) == false)
                {
                    this.last()[0].Content += strLeading;
                }
            }

            MarcQuery.insertAfter(source_nodes, this);
            return(this);
        }
示例#4
0
        void DisplayFirstRecord(string strFileName,
                                Encoding encoding)
        {
            if (string.IsNullOrEmpty(strFileName) == true)
            {
                goto ERROR1;
            }
            if (File.Exists(strFileName) == false)
            {
                goto ERROR1;
            }
            if (encoding == null)
            {
                goto ERROR1;
            }

            string strMARC  = "";
            string strError = "";
            // return:
            //      -1  出错
            //      0   正常
            int nRet = LoadFirstRecord(strFileName,
                                       encoding,
                                       out strMARC,
                                       out strError);

            if (nRet == -1)
            {
                goto ERROR1;
            }

            if (this.Mode880 == true &&
                (this.comboBox_marcSyntax.Text == "USMARC" || this.comboBox_marcSyntax.Text == "<自动>"))
            {
                if (this.IsOutput == false)
                {
                    MarcRecord temp = new MarcRecord(strMARC);
                    MarcQuery.ToParallel(temp);
                    strMARC = temp.Text;
                }
            }

            string strHead = @"<head>
<style type='text/css'>
BODY {
	FONT-FAMILY: Microsoft YaHei, Verdana, 宋体;
	FONT-SIZE: 8pt;
}
TABLE.marc
{
    font-size: 8pt;
    width: auto;
}
TABLE.marc TD
{
   vertical-align:text-top;
}
TABLE.marc TR.header
{
    background-color: #eeeeee;
}
TABLE.marc TR.datafield
{
}
TABLE.marc TD.fieldname
{
    border: 0px;
    border-top: 1px;
    border-style: dotted;
    border-color: #cccccc;
}
TABLE.marc TD.fieldname, TABLE.marc TD.indicator, TABLE.marc TR.header TD.content, TABLE.marc SPAN
{
     font-family: Courier New, Tahoma, Arial, Helvetica, sans-serif;
     font-weight: bold;
}
TABLE.marc TD.indicator
{
    padding-left: 4px;
    padding-right: 4px;
    
    border: 0px;
    border-left: 1px;
    border-right: 1px;
    border-style: dotted;
    border-color: #eeeeee;
}
TABLE.marc SPAN.subfield
{
    margin: 2px;
    margin-left: 0px;
    line-height: 140%;
        
    border: 1px;
    border-style: solid;
    border-color: #cccccc;
    
    padding-top: 1px;
    padding-bottom: 1px;
    padding-left: 3px;
    padding-right: 3px;
    font-weight: bold;
    color: Blue;
    background-color: Yellow;
}
TABLE.marc SPAN.fieldend
{
    margin: 2px;
    margin-left: 4px;
    
    border: 1px;
    border-style: solid;
    border-color: #cccccc;
    
    padding-top: 1px;
    padding-bottom: 1px;
    padding-left: 3px;
    padding-right: 3px;
    font-weight: bold;
    color: White;
    background-color: #cccccc;
}
</style>
</head>";

            string strHtml = "<html>" +
                             strHead +
                             "<body>" +
                             MarcUtil.GetHtmlOfMarc(strMARC, false) +
                             "</body></html>";

            AppendHtml(this.webBrowser1, strHtml, true);

            if (this.IsOutput == false && this.Visible == true)
            {
                HideMessageTip();
                ShowMessageTip();
            }
            return;

ERROR1:
            ClearHtml();
        }
示例#5
0
 // 在当前集合中每个元素的DOM位置后面插入源集合内的元素
 // 参见 MarcQuery::insertAfter() 函数的注释
 // 最后返回当前集合
 /// <summary>
 /// 在当前集合中每个元素的 DOM 位置后面插入指定的源集合内的元素
 /// </summary>
 /// <param name="source_nodes">源集合</param>
 /// <returns>当前集合</returns>
 public MarcNodeList after(MarcNodeList source_nodes)
 {
     MarcQuery.insertAfter(source_nodes, this);
     return(this);
 }
示例#6
0
 /// <summary>
 /// 在当前集合中每个元素的 DOM 位置前面插入指定的源集合内的元素
 /// </summary>
 /// <param name="source_nodes">源集合</param>
 /// <returns>当前集合</returns>
 public MarcNodeList before(MarcNodeList source_nodes)
 {
     MarcQuery.insertBefore(source_nodes, this);
     return(this);
 }
示例#7
0
 /// <summary>
 /// 将当前集合内的全部元素插入到指定的目标集合的 DOM 位置下级开头
 /// </summary>
 /// <param name="target_nodes">目标集合</param>
 /// <returns>当前集合</returns>
 public MarcNodeList prependTo(MarcNodeList target_nodes)
 {
     MarcQuery.prepend(this, target_nodes);
     return(this);
 }
示例#8
0
 // 在当前集合中每个元素的DOM位置 下级开头 插入源集合内的元素
 // 参见 MarcQuery::prepend() 函数的注释
 // 最后返回当前集合
 /// <summary>
 /// 在当前集合的每个元素的 DOM 位置的下级开头插入源集合内的元素
 /// </summary>
 /// <param name="source_nodes">源集合</param>
 /// <returns>当前集合</returns>
 public MarcNodeList prepend(MarcNodeList source_nodes)
 {
     MarcQuery.prepend(source_nodes, this);
     return(this);
 }
示例#9
0
 // 把当前集合中的每个元素插入到目标集合的每个元素的DOM位置后面
 // 参见 MarcQuery::insertAfter() 函数的注释
 // 最后返回当前集合
 /// <summary>
 /// 将当前集合中的每个元素插入到指定的目标集合的每个元素的 DOM 位置后面
 /// </summary>
 /// <param name="target_nodes">目标集合</param>
 /// <returns>当前集合</returns>
 public MarcNodeList insertAfter(MarcNodeList target_nodes)
 {
     MarcQuery.insertAfter(this, target_nodes);
     return(this);
 }
示例#10
0
 /// <summary>
 /// 将当前集合中的每个元素插入到指定的目标集合的每个元素的 DOM 位置前面
 /// </summary>
 /// <param name="target_nodes">目标集合</param>
 /// <returns>当前集合</returns>
 public MarcNodeList insertBefore(MarcNodeList target_nodes)
 {
     MarcQuery.insertBefore(this, target_nodes);
     return(this);
 }