using System;
using System.Collections.Generic;
using System.Text;

using DigitalPlatform.Z3950;

namespace dp2Catalog
{
    /// <summary>
    /// ¸÷ÖÖ¼ìË÷´°µÄ¹«¹²³éÏó½Ó¿Ú
    /// ±ãÓÚÍâ²¿Í¨¹ýÒ»ÖÂµÄ½Ó¿Ú»ñÈ¡Êý¾Ý
    /// </summary>
    public interface ISearchForm
    {
        string CurrentProtocol
        {
            get;
        }

        string CurrentResultsetPath
        {
            get;
        }

        // »ñµÃÒ»ÌõMARC/XML¼ÇÂ¼
        // parameters:
        //      index   ×¢Òâ£¬¿ÉÄÜÔÚµ÷ÓÃºó·¢ÏÖÎªÐèÒªÌø¹ýµÄ·Ö¸îÌõÎ»ÖÃ
        // return:
        //      -1  error
        //      0   suceed
        //      1   ÎªÕï¶Ï¼ÇÂ¼
        //      2   ·Ö¸îÌõ£¬ÐèÒªÌø¹ýÕâÌõ¼ÇÂ¼
        int GetOneRecord(
            string strStyle,
            int nTest,  // ÔÝÊ±Ê¹ÓÃ
            string strPathParam, // int index,
            string strParameters,   // bool bHilightBrowseLine,
            out string strSavePath,
            out string strMARC,
            out string strXmlFragment,
            out string strOutStyle,
            out byte[] baTimestamp,
            out long lVersion,
            out DigitalPlatform.Z3950.Record record,
            out Encoding currrentEncoding,
            out LoginInfo logininfo, 
            out string strError);

        // Ë¢ÐÂÒ»ÌõMARC¼ÇÂ¼
        // parameters:
        //      strAction   refresh / delete
        // return:
        //      -2  ²»Ö§³Ö
        //      -1  error
        //      0   Ïà¹Ø´°¿ÚÒÑ¾­Ïú»Ù£¬Ã»ÓÐ±ØÒªË¢ÐÂ
        //      1   ÒÑ¾­Ë¢ÐÂ
        //      2   ÔÚ½á¹û¼¯ÖÐÃ»ÓÐÕÒµ½ÒªË¢ÐÂµÄ¼ÇÂ¼
        int RefreshOneRecord(
            string strPathParam,
            string strAction,
            out string strError);

        // ¶ÔÏó¡¢´°¿ÚÊÇ·ñ»¹ÓÐÐ§?
        bool IsValid();

        // TODO: »Øµ÷º¯Êý£¬ÀïÃæ¿ÉÒÔ³öÏÖ¶Ô»°¿òÑ¯ÎÊ
        // Í¬²½Ò»Ìõ MARC/XML ¼ÇÂ¼
        // Èç¹û Lversion ±È¼ìË÷´°ÖÐµÄ¼ÇÂ¼ÐÂ£¬ÔòÓÃ strMARC ÄÚÈÝ¸üÐÂ¼ìË÷´°ÄÚµÄ¼ÇÂ¼
        // Èç¹û lVersion ±È¼ìË÷´°ÖÐµÄ¼ÇÂ¼¾É(Ò²¾ÍÊÇËµ Lverion µÄÖµÆ«Ð¡)£¬ÄÇÃ´´Ó strMARC ÖÐÈ¡³ö¼ÇÂ¼¸üÐÂµ½¼ÇÂ¼´°
        // parameters:
        //      lVersion    [in]¼ÇÂ¼´°µÄ Version [out] ¼ìË÷´°µÄ¼ÇÂ¼ Version
        // return:
        //      -1  ³ö´í
        //      0   Ã»ÓÐ±ØÒª¸üÐÂ
        //      1   ÒÑ¾­¸üÐÂµ½ ¼ìË÷´°
        //      2   ÐèÒª´Ó strMARC ÖÐÈ¡³öÄÚÈÝ¸üÐÂµ½¼ÇÂ¼´°
        int SyncOneRecord(string strPath,
            ref long lVersion,
            ref string strSyntax,
            ref string strMARC,
            out string strError);
    }

    public class LoginInfo
    {
        public string UserName = "";
        public string Password = "";
    }
}
