Exemplo n.º 1
0
        private void button_amazonSearch_openDialog_Click(object sender, EventArgs e)
        {
            AmazonSearchForm dlg = new AmazonSearchForm();

            MainForm.SetControlFont(dlg, this.Font, false);
            dlg.TempFileDir = this.MainForm.UserTempDir;
            dlg.AutoSearch = true;

            dlg.UiState = this.MainForm.AppInfo.GetString(
"TestForm",
"AmazonSearchForm_uiState",
"");
            //dlg.QueryWord = "7-02-003343-1";
            //dlg.From = "isbn";
            // TODO: 保存窗口内的尺寸状态
            this.MainForm.AppInfo.LinkFormState(dlg, "TestForm_AmazonSearchForm_state");

            dlg.ShowDialog(this);

            this.MainForm.AppInfo.UnlinkFormState(dlg);

            this.MainForm.AppInfo.SetString(
"TestForm",
"AmazonSearchForm_uiState",
dlg.UiState);

        }
Exemplo n.º 2
0
    // 加入封面图像 URL
    void AddCoverImageUrl()
    {
        string strError = "";
        string strISBN = "";
        int nRet = 0;

        MainForm main_form = this.DetailForm.MainForm;

        strISBN = this.DetailForm.MarcEditor.Record.Fields.GetFirstSubfield("010", "a");

        if (strISBN.Trim() == "")
        {
            strError = "记录中不存在 010$a 子字段, 因此无法加入封面图片 URL";
            goto ERROR1;
        }

        nRet = main_form.LoadIsbnSplitter(true, out strError);
        if (nRet == -1)
            goto ERROR1;

        AmazonSearchForm dlg = new AmazonSearchForm();

        string strOutputISBN = "";
        Debug.Assert(main_form != null, "1");
        Debug.Assert(main_form.IsbnSplitter != null, "2");

        nRet = main_form.IsbnSplitter.IsbnInsertHyphen(strISBN, "force10", out strOutputISBN, out strError);
        if (nRet != -1)
        {
            string strHead = "";
            string strOther = "";

            StringUtil.ParseTwoPart(strOutputISBN, "-", out strHead, out strOther);

            if (strHead == "7")
                dlg.ServerUrl = "webservices.amazon.cn";  // 中国
            else
                dlg.ServerUrl = "webservices.amazon.com";  // 美国
        }
        else
            dlg.ServerUrl = "webservices.amazon.cn";  // 中国

        MainForm.SetControlFont(dlg, this.DetailForm.Font, false);
        dlg.TempFileDir = main_form.DataDir;
        dlg.AutoSearch = true;

        dlg.UiState = main_form.AppInfo.GetString(
"TestForm",
"AmazonSearchForm_uiState",
"");
        dlg.QueryWord = strISBN;
        dlg.From = "ISBN";

        main_form.AppInfo.LinkFormState(dlg, "TestForm_AmazonSearchForm_state");

        dlg.ShowDialog(this.DetailForm);

        main_form.AppInfo.UnlinkFormState(dlg);
        main_form.AppInfo.SetString(
"TestForm",
"AmazonSearchForm_uiState",
dlg.UiState);
        if (dlg.DialogResult == DialogResult.Cancel)
            return;

        Hashtable table = dlg.GetImageUrls(dlg.SelectedItem.Xml);
        foreach (string name in table.Keys)
        {
            AmazonSearch.ImageInfo info = table[name] as AmazonSearch.ImageInfo;

            Field field_856 = this.DetailForm.MarcEditor.Record.Fields.Add("856",
                "4 ",
                "",
                true);

            NewSubfield(field_856, "3", "Cover image");
            NewSubfield(field_856, "u", info.Url);
            NewSubfield(field_856, "q", AmazonSearch.GetMime(info.Url));

            NewSubfield(field_856, "x", "type:FrontCover." + name + ";size:" + info.Size + ";source:Amazon:" + dlg.SelectedItem.ASIN);
        }

        return;
    ERROR1:
        MessageBox.Show(this.DetailForm, strError);
    }