Ejemplo n.º 1
0
        public IEnumerator GetEnumerator()
        {
            List <string> batch = new List <string>();

            for (int index = 0; index < m_barcodes.Count; index++)
            {
                string s = m_barcodes[index];

                if (string.IsNullOrEmpty(s) == true)
                {
                    throw new Exception("册条码号字符串不允许为空 (index=" + index.ToString() + ")");
                }

                batch.Add(s);

                // 每100个一批,或者最后一次
                if (batch.Count >= 100 ||
                    (index == m_barcodes.Count - 1 && batch.Count > 0))
                {
REDO_GETITEMINFO:
                    string strBiblio = "";
                    string strResult = "";
                    string strError  = "";
                    long   lRet      = this.Channel.GetItemInfo(
                        this.Stop,
                        "@barcode-list:" + StringUtil.MakePathList(batch),
                        "get-path-list",
                        out strResult,
                        "", // strBiblioType,
                        out strBiblio,
                        out strError);
                    if (lRet == -1)
                    {
                        if (this.Prompt != null)
                        {
                            MessagePromptEventArgs e = new MessagePromptEventArgs();
                            e.MessageText = "通过册条码号获得记录路径时发生错误: " + strError;
                            e.Actions     = "yes,no,cancel";
                            this.Prompt(this, e);
                            if (e.ResultAction == "cancel")
                            {
                                throw new Exception(strError);
                            }
                            else if (e.ResultAction == "yes")
                            {
                                if (this.Stop != null)
                                {
                                    this.Stop.Continue();
                                }
                                goto REDO_GETITEMINFO;
                            }
                            else
                            {
                            }
                        }
                        else
                        {
                            throw new ChannelException(Channel.ErrorCode, strError);
                        }
                    }

                    List <string> recpaths = StringUtil.SplitList(strResult);

                    if (batch.Count != recpaths.Count)
                    {
                        strError = "batch.Count != recpaths.Count";
                        throw new Exception(strError);
                    }
                    Debug.Assert(batch.Count == recpaths.Count, "");

                    int i = 0;
                    foreach (string recpath in recpaths)
                    {
                        EntityItem item = new EntityItem();
                        item.Barcode = batch[i];

                        if (string.IsNullOrEmpty(recpath) == false &&
                            recpath[0] == '!')
                        {
                            item.ErrorInfo = recpath.Substring(1);
                        }
                        else
                        {
                            item.RecPath = recpath;
                        }
                        i++;

                        yield return(item);
                    }

                    batch.Clear();
                }
            }
        }
Ejemplo n.º 2
0
        public IEnumerator GetEnumerator()
        {

            List<string> batch = new List<string>();
            for (int index = 0; index < m_barcodes.Count; index++)
            {
                string s = m_barcodes[index];

                if (string.IsNullOrEmpty(s) == true)
                    throw new Exception("册条码号字符串不允许为空 (index="+index.ToString()+")");

                batch.Add(s);

                // 每100个一批,或者最后一次
                if (batch.Count >= 100 ||
                    (index == m_barcodes.Count - 1 && batch.Count > 0))
                {
                REDO_GETITEMINFO:
                    string strBiblio = "";
                    string strResult = "";
                    string strError = "";
                    long lRet = this.Channel.GetItemInfo(
                        this.Stop,
                        "@barcode-list:" + StringUtil.MakePathList(batch),
                        "get-path-list",
                        out strResult,
                        "", // strBiblioType,
                        out strBiblio,
                        out strError);
                    if (lRet == -1)
                    {
                        if (this.Prompt != null)
                        {
                            MessagePromptEventArgs e = new MessagePromptEventArgs();
                            e.MessageText = "通过册条码号获得记录路径时发生错误: " + strError;
                            e.Actions = "yes,no,cancel";
                            this.Prompt(this, e);
                            if (e.ResultAction == "cancel")
                                throw new Exception(strError);
                            else if (e.ResultAction == "yes")
                            {
                                if (this.Stop != null)
                                    this.Stop.Continue();
                                goto REDO_GETITEMINFO;
                            }
                            else
                            {
                            }
                        }
                        else
                            throw new ChannelException(Channel.ErrorCode, strError);
                    }

                    List<string> recpaths = StringUtil.SplitList(strResult);

                    if (batch.Count != recpaths.Count)
                    {
                        strError = "batch.Count != recpaths.Count";
                        throw new Exception(strError);
                    }
                    Debug.Assert(batch.Count == recpaths.Count, "");

                    int i = 0;
                    foreach (string recpath in recpaths)
                    {
                        EntityItem item = new EntityItem();
                        item.Barcode = batch[i];

                        if (string.IsNullOrEmpty(recpath) == false
                            && recpath[0] == '!')
                            item.ErrorInfo = recpath.Substring(1);
                        else
                            item.RecPath = recpath;
                        i++;

                        yield return item;
                    }

                    batch.Clear();
                }
            }
        }