欢迎您来到 数字平台。 您尚未登录。[登录] [注册新用户]
当前位置: 论坛首页 / 栏目 产品与服务 / 文章 598

点击:17361[回复顶层] [树状] [详细]
[回复留言] [回复(需要先登录)] [引用(需要先登录)]普通文章第 1 楼
文章id: 446
加四角号功能较完整代码(可自由配置取号规则)

作者: Harry


完整的功能需要加入4块代码到不同的位置:

一、

using System.Xml.XPath;

二、

  actions.NewItem("加入四角号", "根据701/711$a内容, 创建905$e", "AddFourAngle", false);

三、

 void AddFourAngle()
        {
            string[] cfgsjh = new string[] { "1234", "1313", "1311", "1111" }; //在此配置取号规则
            string author = "";
            string sijiaohao = "";
            string first = "";
            string second = "";
            string third = "";
            string forth = "";
            string author1 = this.DetailForm.MarcEditor.Record.Fields.GetFirstSubfield("701", "a");
            string author2 = this.DetailForm.MarcEditor.Record.Fields.GetFirstSubfield("711", "a");
            getSiJiaoHao getsjh = new getSiJiaoHao();
            if (author1 != "")
            {
                author = author1;
                if (author.Length == 1)
                {
                    first = cfgsjh[0].Substring(0,1);
                    second = cfgsjh[0].Substring(1, 1);
                    third = cfgsjh[0].Substring(2, 1);
                    forth = cfgsjh[0].Substring(3, 1);
                    getsjh.authorchar = author[0];
                    getsjh.QuHao();
                    sijiaohao += getsjh.hao[Convert.ToInt32(first)-1];
                    sijiaohao += getsjh.hao[Convert.ToInt32(second)-1];
                    sijiaohao += getsjh.hao[Convert.ToInt32(third)-1];
                    sijiaohao += getsjh.hao[Convert.ToInt32(forth)-1];
                }
                if (author.Length == 2)
                {
                    first = cfgsjh[1].Substring(0, 1);
                    second = cfgsjh[1].Substring(1, 1);
                    third = cfgsjh[1].Substring(2, 1);
                    forth = cfgsjh[1].Substring(3, 1);
                    for (int i = 0; i <= 1; i++)
                    {
                        getsjh.authorchar=author[i];
                        getsjh.QuHao();
                        if (i == 0)
                        {
                            sijiaohao += getsjh.hao[Convert.ToInt32(first) - 1];
                            sijiaohao += getsjh.hao[Convert.ToInt32(second) - 1];
                        }
                        if (i == 1)
                        {
                            sijiaohao += getsjh.hao[Convert.ToInt32(third)-1];
                            sijiaohao+=getsjh.hao[Convert.ToInt32(forth)-1];
                        }
                    }
                }
                if (author.Length >= 3)
                {
                    first = cfgsjh[2].Substring(0, 1);
                    second = cfgsjh[2].Substring(1, 1);
                    third = cfgsjh[2].Substring(2, 1);
                    forth = cfgsjh[2].Substring(3, 1);
                    author = author.Substring(0, 3);
                    for (int i = 0; i <= 2; i++)
                    {
                        getsjh.authorchar = author[i];
                        getsjh.QuHao();
                        if (i == 0)
                        {
                            sijiaohao += getsjh.hao[Convert.ToInt32(first) - 1];
                            sijiaohao += getsjh.hao[Convert.ToInt32(second) - 1];
                        }                        
                        if (i == 1)
                            sijiaohao += getsjh.hao[Convert.ToInt32(third) - 1];
                        if (i == 2)
                            sijiaohao += getsjh.hao[Convert.ToInt32(forth) - 1];
                    }
                }
            }
            else if (author2 != "")
            {
                author = author2;
                if (author.Length == 1)
                {
                    first = cfgsjh[0].Substring(0, 1);
                    second = cfgsjh[0].Substring(1, 1);
                    third = cfgsjh[0].Substring(2, 1);
                    forth = cfgsjh[0].Substring(3, 1);
                    getsjh.authorchar = author[0];
                    getsjh.QuHao();
                    sijiaohao += getsjh.hao[Convert.ToInt32(first) - 1];
                    sijiaohao += getsjh.hao[Convert.ToInt32(second) - 1];
                    sijiaohao += getsjh.hao[Convert.ToInt32(third) - 1];
                    sijiaohao += getsjh.hao[Convert.ToInt32(forth) - 1];
                }
                if (author.Length == 2)
                {
                    first = cfgsjh[1].Substring(0, 1);
                    second = cfgsjh[1].Substring(1, 1);
                    third = cfgsjh[1].Substring(2, 1);
                    forth = cfgsjh[1].Substring(3, 1);
                    for (int i = 0; i <= 1; i++)
                    {
                        getsjh.authorchar = author[i];
                        getsjh.QuHao();
                        if (i == 0)
                        {
                            sijiaohao += getsjh.hao[Convert.ToInt32(first) - 1];
                            sijiaohao += getsjh.hao[Convert.ToInt32(second) - 1];
                        }
                        if (i == 1)
                        {
                            sijiaohao += getsjh.hao[Convert.ToInt32(third) - 1];
                            sijiaohao += getsjh.hao[Convert.ToInt32(forth) - 1];
                        }
                    }
                }
                if (author.Length == 3)
                {
                    first = cfgsjh[2].Substring(0, 1);
                    second = cfgsjh[2].Substring(1, 1);
                    third = cfgsjh[2].Substring(2, 1);
                    forth = cfgsjh[2].Substring(3, 1);
                    for (int i = 0; i <= 2; i++)
                    {
                        getsjh.authorchar = author[i];
                        getsjh.QuHao();
                        if (i == 0)
                        {
                            sijiaohao += getsjh.hao[Convert.ToInt32(first) - 1];
                            sijiaohao += getsjh.hao[Convert.ToInt32(second) - 1];
                        }
                        if (i == 1)
                            sijiaohao += getsjh.hao[Convert.ToInt32(third) - 1];
                        if (i == 2)
                            sijiaohao += getsjh.hao[Convert.ToInt32(forth) - 1];
                    }
                }
                else if (author.Length>=4)
                {
                    first = cfgsjh[3].Substring(0, 1);
                    second = cfgsjh[3].Substring(1, 1);
                    third = cfgsjh[3].Substring(2, 1);
                    forth = cfgsjh[3].Substring(3, 1);
                    author = author.Substring(0, 4);
                    for (int i = 0; i <= 3; i++)
                    {
                        getsjh.authorchar = author[i];
                        getsjh.QuHao();
                        if (i == 0)
                            sijiaohao += getsjh.hao[Convert.ToInt32(first) - 1];
                        if (i == 1)
                            sijiaohao += getsjh.hao[Convert.ToInt32(second) - 1];
                        if (i == 2)
                            sijiaohao += getsjh.hao[Convert.ToInt32(third) - 1];
                        if (i == 3)
                            sijiaohao += getsjh.hao[Convert.ToInt32(forth) - 1];
                    }
                }
            }
            else
            {
                MessageBox.Show(this.DetailForm, "701/711中均未发现$a,无法处理");
                return;
             }
            this.DetailForm.MarcEditor.Record.Fields.SetFirstSubfield("905", "e", sijiaohao);
        }

四、

    class getSiJiaoHao
    {
        public string hao;
        public char authorchar;
        public void QuHao()
        {
            XPathDocument doc = new XPathDocument("http://localhost/Dp2LibraryWs/sijiaohao.xml");
            XPathNavigator nav = ((IXPathNavigable)doc).CreateNavigator();
            XPathNodeIterator iter = nav.Select("/Collection/Character[@char='" + authorchar + "']");
            while (iter.MoveNext())
            {
                hao = iter.Current.Value;
            }
        }
    }

说明:

1、配置字符串数组中分别对应责任者为:1字(如1234)、2字(如1313)、3字(如1311)、团体(如前四字1111);

2、个人责任者多于4字、只取前3字 ;

3、团体责任者少于4字,按个人责任者的规则取号。

4、两字每个字取两位号。

5、三个字首字取两位号,2、3字各取一位号。

5、四个字各字取一位号。

这是普遍应用的规则,在这大规则下,具体取号位可以自行配置,比如我碰到过的有:{1234,1313,1311,1111}或{1234,1414,1411,1111}等,都是在这个原则下。

当然,也不排除有特殊嗜好的图书馆,非要把首字只取一位,尾字取三位,那以上代码就没办法了,只能请数字平台的老师们来量身定做代码了。



发表时间: 2009-03-10 19:44:09
[回复留言] [回复(需要先登录)] [引用(需要先登录)]普通文章第 2 楼
文章id: 598

作者: paul2008


该怎么加?



发表时间: 2010-04-28 13:59:41
[回复留言] [回复(需要先登录)] [引用(需要先登录)]普通文章第 3 楼
文章id: 599
回复:

作者: xietao


==========

以下是引用 paul2008 于 2010-4-28 13:59:41 发表的文字:

该怎么加?

==========

这是网友在探讨利用dp2circulation配置文件脚本进行二次开发时候的实验代码。

如果对四角号码作著者号课题感兴趣,我们还可以继续探讨。



发表时间: 2010-04-30 08:37:39



页 1 / 1
 

在线用户
(无) 
当前栏目在线用户数 0, 总在线用户数 0