Example #1
0
        // 针对亚马逊服务器检索,装入一个浏览行的回调函数
        int appendBrowseLine(string strRecPath,
                             string strRecord,
                             object param,
                             bool bAutoSetFocus,
                             out string strError)
        {
            strError = "";

            XmlDocument dom = new XmlDocument();

            dom.LoadXml(strRecord);

            XmlNamespaceManager nsmgr = new XmlNamespaceManager(new NameTable());

            nsmgr.AddNamespace("amazon", AmazonSearch.NAMESPACE);

            List <string> cols             = null;
            string        strASIN          = "";
            string        strCoverImageUrl = "";
            int           nRet             = AmazonSearch.ParseItemXml(dom.DocumentElement,
                                                                       nsmgr,
                                                                       out strASIN,
                                                                       out strCoverImageUrl,
                                                                       out cols,
                                                                       out strError);

            if (nRet == -1)
            {
                return(-1);
            }

#if NO
            string strMARC = "";
            // 将亚马逊 XML 格式转换为 UNIMARC 格式
            nRet = AmazonSearch.AmazonXmlToUNIMARC(dom.DocumentElement,
                                                   out strMARC,
                                                   out strError);
            if (nRet == -1)
            {
                return(-1);
            }
#endif

            AmazonBiblioInfo info = new AmazonBiblioInfo();
            info.Xml        = dom.DocumentElement.OuterXml;
            info.Timestamp  = null;
            info.ASIN       = strASIN + "@" + this.ServerUrl;
            info.MarcSyntax = "amazon"; // 表示 XML 尚未转换
            info.ImageUrl   = strCoverImageUrl;
            this.AddBiblioBrowseLine(
                info.ASIN,
                StringUtil.MakePathList(cols, "\t"),
                info);

            return(0);
        }
Example #2
0
        void AddTraceItem(DpRow row)
        {
            AmazonBiblioInfo info = row.Tag as AmazonBiblioInfo;

            if (info != null && string.IsNullOrEmpty(info.ImageUrl) == false)
            {
                TraceImage trace = new TraceImage();
                trace.ImageUrl = info.ImageUrl;
                trace.Row      = row;
                lock (_trace_images)
                {
                    _trace_images.Add(trace);
                }
            }
        }
Example #3
0
        // 加入一个浏览行
        public void AddBiblioBrowseLine(
            string strBiblioRecPath,
            string strBrowseText,
            AmazonBiblioInfo info)
        {
            if (this.dpTable_items.InvokeRequired)
            {
                // 事件是在多线程上下文中触发的,需要 Invoke 显示信息
                this.BeginInvoke(new Action<string, string, AmazonBiblioInfo>(AddBiblioBrowseLine),
                    strBiblioRecPath,
                    strBrowseText,
                    info);
                return;
            }

            // 检查已经存在的最后一行是否为命令行
            if (this.dpTable_items.Rows.Count > 0)
            {
                DpRow tail = this.dpTable_items.Rows[this.dpTable_items.Rows.Count - 1];
                if (string.IsNullOrEmpty(tail[0].Text) == true)
                    this.dpTable_items.Rows.RemoveAt(this.dpTable_items.Rows.Count - 1);
            }

            List<string> columns = StringUtil.SplitList(strBrowseText, '\t');
            DpRow row = new DpRow();
            row.LineAlignment = StringAlignment.Center;

            DpCell cell = new DpCell();
            cell.Text = (this.dpTable_items.Rows.Count + 1).ToString();
            cell.Font = this._idFont;
            cell.ForeColor = SystemColors.GrayText;
            row.Add(cell);

#if NO
            cell = new DpCell();
            cell.Text = strBiblioRecPath;
            row.Add(cell);
#endif

            cell = new DpCell();
            // cell.Text = info.ImageUrl;
            // cell.Text = "正在加载图片 ...";
            row.Add(cell);

            int i = 0;
            foreach (string s in columns)
            {
                cell = new DpCell();
                cell.Text = s;
                if (i == 0)
                    cell.Font = this._titleFont;

                row.Add(cell);
                i++;
            }

            row.Tag = info;
            // row[COLUMN_IMAGE].OwnerDraw = true;

            this.dpTable_items.Rows.Add(row);

#if NO
            if (string.IsNullOrEmpty(info.ImageUrl) == false)
            {
                TraceImage trace = new TraceImage();
                trace.ImageUrl = info.ImageUrl;
                trace.Row = row;
                lock (_trace_images)
                {
                    _trace_images.Add(trace);
                }
            }
#endif
            AddTraceItem(row);
        }
Example #4
0
        // 针对亚马逊服务器检索,装入一个浏览行的回调函数
        int appendBrowseLine(string strRecPath,
    string strRecord,
    object param,
            bool bAutoSetFocus,
    out string strError)
        {
            strError = "";

            XmlDocument dom = new XmlDocument();
            dom.LoadXml(strRecord);

            XmlNamespaceManager nsmgr = new XmlNamespaceManager(new NameTable());
            nsmgr.AddNamespace("amazon", AmazonSearch.NAMESPACE);

            List<string> cols = null;
            string strASIN = "";
            string strCoverImageUrl = "";
            int nRet = AmazonSearch.ParseItemXml(dom.DocumentElement,
                nsmgr,
                out strASIN,
                out strCoverImageUrl,
                out cols,
                out strError);
            if (nRet == -1)
                return -1;

#if NO
            string strMARC = "";
            // 将亚马逊 XML 格式转换为 UNIMARC 格式
            nRet = AmazonSearch.AmazonXmlToUNIMARC(dom.DocumentElement,
                out strMARC,
                out strError);
            if (nRet == -1)
                return -1;
#endif

            AmazonBiblioInfo info = new AmazonBiblioInfo();
            info.Xml = dom.DocumentElement.OuterXml;
            info.Timestamp = null;
            info.ASIN = strASIN + "@" + this.ServerUrl;
            info.MarcSyntax = "amazon"; // 表示 XML 尚未转换
            info.ImageUrl = strCoverImageUrl;
            this.AddBiblioBrowseLine(
                info.ASIN,
                StringUtil.MakePathList(cols, "\t"),
                info);

            return 0;
        }
Example #5
0
        // 加入一个浏览行
        public void AddBiblioBrowseLine(
            string strBiblioRecPath,
            string strBrowseText,
            AmazonBiblioInfo info)
        {
            if (this.dpTable_items.InvokeRequired)
            {
                // 事件是在多线程上下文中触发的,需要 Invoke 显示信息
                this.BeginInvoke(new Action <string, string, AmazonBiblioInfo>(AddBiblioBrowseLine),
                                 strBiblioRecPath,
                                 strBrowseText,
                                 info);
                return;
            }

            // 检查已经存在的最后一行是否为命令行
            if (this.dpTable_items.Rows.Count > 0)
            {
                DpRow tail = this.dpTable_items.Rows[this.dpTable_items.Rows.Count - 1];
                if (string.IsNullOrEmpty(tail[0].Text) == true)
                {
                    this.dpTable_items.Rows.RemoveAt(this.dpTable_items.Rows.Count - 1);
                }
            }

            List <string> columns = StringUtil.SplitList(strBrowseText, '\t');
            DpRow         row     = new DpRow();

            row.LineAlignment = StringAlignment.Center;

            DpCell cell = new DpCell();

            cell.Text      = (this.dpTable_items.Rows.Count + 1).ToString();
            cell.Font      = this._idFont;
            cell.ForeColor = SystemColors.GrayText;
            row.Add(cell);

#if NO
            cell      = new DpCell();
            cell.Text = strBiblioRecPath;
            row.Add(cell);
#endif

            cell = new DpCell();
            // cell.Text = info.ImageUrl;
            // cell.Text = "正在加载图片 ...";
            row.Add(cell);

            int i = 0;
            foreach (string s in columns)
            {
                cell      = new DpCell();
                cell.Text = s;
                if (i == 0)
                {
                    cell.Font = this._titleFont;
                }

                row.Add(cell);
                i++;
            }

            row.Tag = info;
            // row[COLUMN_IMAGE].OwnerDraw = true;

            this.dpTable_items.Rows.Add(row);

#if NO
            if (string.IsNullOrEmpty(info.ImageUrl) == false)
            {
                TraceImage trace = new TraceImage();
                trace.ImageUrl = info.ImageUrl;
                trace.Row      = row;
                lock (_trace_images)
                {
                    _trace_images.Add(trace);
                }
            }
#endif
            AddTraceItem(row);
        }