Exemplo n.º 1
0
 public SearchDialog(ISearchForm searchForm) : base()
 {
     _searchForm = searchForm;
     InitializeComponent();
     btnSearch.Click += BtnSearch_Click;
     this.ApplyThemeRecursively(this.Controls);
 }
Exemplo n.º 2
0
 private void btnSearch_Click(object sender, EventArgs e)
 {
     if (this.SearchForm != null && !string.IsNullOrEmpty(this.DisplayMember))
     {
         ISearchForm <T> form = (ISearchForm <T>)Activator.CreateInstance(this.SearchForm.GetType());
         form.ParentSearchForm = this.ParentForm;
         form.PrepareSearchControls();
         ((Form)form).ShowDialog(this);
         this.Value = form.SearchResult;
         if (this.Value != null)
         {
             this.txtName.Text = this.Value.GetType()
                                 .GetProperty(this.DisplayMember).GetValue(this.Value, null).ToString();
         }
     }
 }
        private void InitializeControlControls()
        {
            if (LicenseManager.UsageMode != LicenseUsageMode.Designtime)
            {
                this.controlTenderLines.grdRelations.InitializeLayout
                    += new InitializeLayoutEventHandler(grdRelations_InitializeLayout);

                this.controlTenderLines.pscProduct.DisplayMember = "Name";

                Assembly assembly = Assembly.LoadFile(Application.StartupPath + @"\" + "Samsara.AlleatoERP.Forms.dll");
                Type     formType = assembly.GetType("Samsara.AlleatoERP.Forms.Forms.ProductForm");

                if (formType != null)
                {
                    ISearchForm <Product> formInstance = Activator.CreateInstance(formType) as ISearchForm <Product>;
                    this.controlTenderLines.pscProduct.SearchForm = formInstance;
                }
            }
        }
Exemplo n.º 4
0
        // 装载XML记录
        public int LoadRecord(ISearchForm searchform,
                              int index,
                              bool bForceFullElementSet = false)
        {
            string strError = "";
            string strMARC  = "";

            this.LinkedSearchForm = searchform;
            this.SavePath         = "";

            DigitalPlatform.OldZ3950.Record record = null;
            Encoding currentEncoding = null;

            this.CurrentRecord = null;

            byte[]    baTimestamp = null;
            string    strSavePath = "";
            string    strOutStyle = "";
            LoginInfo logininfo   = null;
            long      lVersion    = 0;

            string strXmlFragment = "";

            string strParameters = "hilight_browse_line";

            if (bForceFullElementSet == true)
            {
                strParameters += ",force_full";
            }

            int nRet = searchform.GetOneRecord(
                "xml",
                index,         // 即将废止
                "index:" + index.ToString(),
                strParameters, // true,
                out strSavePath,
                out strMARC,
                out strXmlFragment,
                out strOutStyle,
                out baTimestamp,
                out lVersion,
                out record,
                out currentEncoding,
                out logininfo,
                out strError);

            if (nRet == -1)
            {
                goto ERROR1;
            }


            this.LoginInfo = logininfo;

            this.CurrentTimestamp = baTimestamp;
            this.SavePath         = strSavePath;
            this.CurrentEncoding  = currentEncoding;


            // 替换单个0x0a
            strMARC = strMARC.Replace("\r", "");
            strMARC = strMARC.Replace("\n", "\r\n");

            // 装入XML编辑器
            // this.textBox_xml.Text = strMARC;
            this.PlainText = strMARC;   // 能自动缩进
            this.textBox_xml.Select(0, 0);

            // 装入XML只读Web控件
            {
                string strTempFileName = MainForm.DataDir + "\\xml.xml";

                // SUTRS
                if (record.m_strSyntaxOID == "1.2.840.10003.5.101")
                {
                    strTempFileName = MainForm.DataDir + "\\xml.txt";
                }

                using (Stream stream = File.Create(strTempFileName))
                {
                    // 写入xml内容
                    byte[] buffer = Encoding.UTF8.GetBytes(strMARC);
                    stream.Write(buffer, 0, buffer.Length);
                }

                this.webBrowser_xml.Navigate(strTempFileName);
            }

            this.CurrentRecord = record;
            if (this.CurrentRecord != null && this.DisplayOriginPage == true)
            {
                // 装入二进制编辑器
                this.binaryEditor_originData.SetData(
                    this.CurrentRecord.m_baRecord);

                // 装入原始文本
                nRet = this.SetOriginText(this.CurrentRecord.m_baRecord,
                                          this.CurrentEncoding,
                                          out strError);
                if (nRet == -1)
                {
                    this.textBox_originData.Text = strError;
                }

                // 数据库名
                this.textBox_originDatabaseName.Text = this.CurrentRecord.m_strDBName;

                // record syntax OID
                this.textBox_originMarcSyntaxOID.Text = this.CurrentRecord.m_strSyntaxOID;
            }

            // 构造路径
            string strPath = searchform.CurrentProtocol + ":"
                             + searchform.CurrentResultsetPath
                             + "/" + (index + 1).ToString();

            this.textBox_tempRecPath.Text = strPath;
            this.textBox_xml.Focus();
            return(0);

ERROR1:
            MessageBox.Show(this, strError);
            return(-1);
        }
 /// <summary>
 /// Searches the specfied queryable for entities using the provided search form.
 /// </summary>
 /// <typeparam name="TEntity">The type of entities to look for.</typeparam>
 /// <typeparam name="TQuerySearchProvider">The IQuerySearchProvider to use.</typeparam>
 /// <param name="query">The queryable that should be searched.</param>
 /// <param name="search">The search form that should be used to search the query.</param>
 /// <returns>A QuerySearchResult that contains the result of the search.</returns>
 public static QuerySearchResult <TEntity> Search <TEntity, TQuerySearchProvider>(this IQueryable <TEntity> query, ISearchForm search)
     where TQuerySearchProvider : IQuerySearchProvider <TEntity>
 {
     return(query.Search <TEntity, TQuerySearchProvider>(search, null));
 }
        /// <summary>
        /// Searches the specfied queryable for entities using the provided search form.
        /// </summary>
        /// <typeparam name="TEntity">The type of entities to look for.</typeparam>
        /// <param name="query">The queryable that should be searched.</param>
        /// <param name="search">The search form that should be used to search the query.</param>
        /// <param name="postCountProcessesing">Function to be called after processing the count portions of the query. Often used to add navigation inclusions.</param>
        /// <returns>A QuerySearchResult that contains the result of the search.</returns>
        public static QuerySearchResult <TEntity> Search <TEntity>(this IQueryable <TEntity> query, ISearchForm search, Func <IQueryable <TEntity>, IQueryable <TEntity> > postCountProcessesing)
        {
            if (query == null)
            {
                throw new ArgumentNullException(nameof(query));
            }
            if (search == null)
            {
                throw new ArgumentNullException(nameof(query));
            }

            var registry = DependencyResolver.Current;

            if (registry == null)
            {
                throw new QuerySearchException("No dependency resolver has been specified.");
            }

            var filterProvider = registry.Resolve <IQuerySearchProvider <TEntity> >() ?? registry.Resolve <IFilterProvider <TEntity> >();

            if (filterProvider == null)
            {
                throw new QuerySearchException($"No IFilterProvider has been registered for the type '{typeof( TEntity ).FullName}'.");
            }

            var paginationProvider = registry.Resolve <IQuerySearchProvider <TEntity> >() ?? registry.Resolve <IPaginationProvider <TEntity> >();

            if (paginationProvider == null)
            {
                throw new QuerySearchException($"No IPaginationProvider has been registered for the type '{typeof( TEntity ).FullName}'.");
            }

            query = filterProvider.ApplyWhere(query, search);

            var filteredCount = query.Count();

            if (postCountProcessesing != null)
            {
                query = postCountProcessesing(query);
            }

            var result = paginationProvider.ApplyPagination(query, search);

            var items = result.Query.ToList();

            return(new QuerySearchResult <TEntity>
            {
                FilteredCount = filteredCount,
                FilteredPageCount = PaginationHelper.GetPageCount(filteredCount, result.PageSize),
                Page = result.Page,
                Skip = result.Skip,
                Take = result.Take,
                Items = items
            });
        }
 /// <summary>
 /// Searches the specfied queryable for entities using the provided search form.
 /// </summary>
 /// <typeparam name="TEntity">The type of entities to look for.</typeparam>
 /// <param name="query">The queryable that should be searched.</param>
 /// <param name="search">The search form that should be used to search the query.</param>
 /// <returns>A QuerySearchResult that contains the result of the search.</returns>
 public static QuerySearchResult <TEntity> Search <TEntity>(this IQueryable <TEntity> query, ISearchForm search)
 {
     return(query.Search(search, null));
 }
Exemplo n.º 8
0
        // dp2library协议下 装载模板
        // parameters:
        //      strPath dp2library协议内路径。例如 中文图书/1@本地服务器
        public int LoadDp2libraryTemplate(string strPath)
        {
            try
            {
                string strError = "";
                int nRet = 0;

                // 按住 Shift 使用本功能,可重新出现对话框
                bool bShift = (Control.ModifierKeys == Keys.Shift);

                /*
                if (this.BiblioChanged == true
                    || this.ObjectChanged == true)
                {
                    // 警告尚未保存
                    DialogResult result = MessageBox.Show(this,
                        "当前有 " + GetCurrentChangedPartName() + " 被修改后尚未保存。若此时装载新内容,现有未保存信息将丢失。\r\n\r\n确实要装载新内容? ",
                        "MarcDetailForm",
                        MessageBoxButtons.YesNo,
                        MessageBoxIcon.Question,
                        MessageBoxDefaultButton.Button2);
                    if (result == DialogResult.No)
                        return 0;
                }*/


                dp2SearchForm dp2_searchform = this.GetDp2SearchForm();

                if (dp2_searchform == null)
                {
                    strError = "没有连接的或者打开的dp2检索窗,无法装载模板";
                    goto ERROR1;
                }

                string strSelectedDbName = this.MainForm.AppInfo.GetString(
         "entity_form",
         "selected_dbname_for_loadtemplate",
         "");
                SelectedTemplate selected = this.selected_templates.Find(strSelectedDbName);


                string strServerName = "";
                string strLocalPath = "";

                string strBiblioDbName = "";

                // 解析记录路径。
                // 记录路径为如下形态 "中文图书/1 @服务器"
                dp2SearchForm.ParseRecPath(string.IsNullOrEmpty(strSelectedDbName) == false ? strSelectedDbName : strPath,
                    out strServerName,
                    out strLocalPath);

                strBiblioDbName = dp2SearchForm.GetDbName(strLocalPath);


                /*
                if (this.LinkedSearchForm != null
                    && strProtocol != this.LinkedSearchForm.CurrentProtocol)
                {
                    strError = "检索窗的协议已经发生改变";
                    goto ERROR1;
                }*/

                string strStartPath = "";

                if (String.IsNullOrEmpty(strServerName) == false
                    && String.IsNullOrEmpty(strBiblioDbName) == false)
                    strStartPath = strServerName + "/" + strBiblioDbName;
                else if (String.IsNullOrEmpty(strServerName) == false)
                    strStartPath = strServerName;

                GetDp2ResDlg dbname_dlg = new GetDp2ResDlg();
                GuiUtil.SetControlFont(dbname_dlg, this.Font);
                if (selected != null)
                {
                    dbname_dlg.NotAsk = selected.NotAskDbName;
                    dbname_dlg.AutoClose = (bShift == true ? false : selected.NotAskDbName);
                }
                dbname_dlg.EnableNotAsk = true;

                dbname_dlg.Text = "装载书目模板 -- 请选择目标数据库";
                dbname_dlg.dp2Channels = dp2_searchform.Channels;
                dbname_dlg.Servers = this.MainForm.Servers;
                dbname_dlg.EnabledIndices = new int[] { dp2ResTree.RESTYPE_DB };
                dbname_dlg.Path = strStartPath;

                if (this.IsValid() == false)
                    return -1;
                    dbname_dlg.ShowDialog(this);    ////


                if (dbname_dlg.DialogResult != DialogResult.OK)
                    return 0;

                // 记忆
                this.MainForm.AppInfo.SetString(
                    "entity_form",
                    "selected_dbname_for_loadtemplate",
                    CanonicalizePath(dbname_dlg.Path));

                selected = this.selected_templates.Find(CanonicalizePath(dbname_dlg.Path));   // 

                // 将目标路径拆分为两个部分
                nRet = dbname_dlg.Path.IndexOf("/");
                if (nRet == -1)
                {
                    Debug.Assert(false, "");
                    strServerName = dbname_dlg.Path;
                    strBiblioDbName = "";
                    strError = "所选择目标(数据库)路径 '" + dbname_dlg.Path + "' 格式不正确";
                    goto ERROR1;
                }
                else
                {
                    strServerName = dbname_dlg.Path.Substring(0, nRet);
                    strBiblioDbName = dbname_dlg.Path.Substring(nRet + 1);

                    // 检查所选数据库的syntax,必须为marc

                    string strSyntax = "";
                    // 获得一个数据库的数据syntax
                    // parameters:
                    //      stop    如果!=null,表示使用这个stop,它已经OnStop +=
                    //              如果==null,表示会自动使用this.stop,并自动OnStop+=
                    // return:
                    //      -1  error
                    //      0   not found
                    //      1   found
                    nRet = dp2_searchform.GetDbSyntax(
                        null,
                        strServerName,
                        strBiblioDbName,
                        out strSyntax,
                        out strError);
                    if (nRet == -1)
                    {
                        strError = "获取书目库 '" + strBiblioDbName + "的数据格式时发生错误: " + strError;
                        goto ERROR1;
                    }

                    if (strSyntax != "unimarc"
                        && strSyntax != "usmarc")
                    {
                        strError = "所选书目库 '" + strBiblioDbName + "' 不是MARC格式的数据库";
                        goto ERROR1;
                    }
                }


                // 然后获得cfgs/template配置文件
                string strCfgFilePath = strBiblioDbName + "/cfgs/template" + "@" + strServerName;

                string strCode = "";
                byte[] baCfgOutputTimestamp = null;
                // return:
                //      -1  error
                //      0   not found
                //      1   found
                nRet = dp2_searchform.GetCfgFile(strCfgFilePath,
                    out strCode,
                    out baCfgOutputTimestamp,
                    out strError);
                if (nRet == -1 || nRet == 0)
                    goto ERROR1;

                SelectRecordTemplateDlg temp_dlg = new SelectRecordTemplateDlg();
                GuiUtil.SetControlFont(temp_dlg, this.Font);

                temp_dlg.Text = "请选择新记录模板 -- " + dbname_dlg.Path;

                string strSelectedTemplateName = "";
                bool bNotAskTemplateName = false;
                if (selected != null)
                {
                    strSelectedTemplateName = selected.TemplateName;
                    bNotAskTemplateName = selected.NotAskTemplateName;
                }

                temp_dlg.SelectedName = strSelectedTemplateName;
                temp_dlg.AutoClose = (bShift == true ? false : bNotAskTemplateName);
                temp_dlg.NotAsk = bNotAskTemplateName;
                temp_dlg.EnableNotAsk = true;    // 2015/5/11

                nRet = temp_dlg.Initial(
                    false,  // true 表示也允许删除
                    strCode,
                    out strError);
                if (nRet == -1)
                {
                    strError = "装载配置文件 '" + strCfgFilePath + "' 发生错误: " + strError;
                    goto ERROR1;
                }

                temp_dlg.ap = this.MainForm.AppInfo;
                temp_dlg.ApCfgTitle = "marcdetailform_selecttemplatedlg";
                if (this.IsValid() == false)
                    return -1;
                    temp_dlg.ShowDialog(this);  ////


                if (temp_dlg.DialogResult != DialogResult.OK)
                    return 0;

                // 记忆本次的选择,下次就不用再进入本对话框了
                this.selected_templates.Set(CanonicalizePath(dbname_dlg.Path),
                    dbname_dlg.NotAsk,
                    temp_dlg.SelectedName,
                    temp_dlg.NotAsk);

                string strMarcSyntax = "";
                string strOutMarcSyntax = "";
                string strRecord = "";

                // 从数据记录中获得MARC格式
                nRet = MarcUtil.Xml2Marc(temp_dlg.SelectedRecordXml,
                    true,
                    strMarcSyntax,
                    out strOutMarcSyntax,
                    out strRecord,
                    out strError);
                if (nRet == -1)
                {
                    strError = "XML转换到MARC记录时出错: " + strError;
                    goto ERROR1;
                }
                this.SavePath = "dp2library" + ":" + strBiblioDbName + "/?" + "@" + strServerName;

                if (this.IsValid() == false)
                    return -1;

                this.MarcEditor.ClearMarcDefDom();
                this.MarcEditor.Marc = strRecord;   ////
                this.CurrentTimestamp = baCfgOutputTimestamp;

                this.ObjectChanged = false;
                this.BiblioChanged = false;

                DisplayHtml(strRecord, GetSyntaxOID(strOutMarcSyntax));

                this.LinkedSearchForm = null;  // 切断和原来关联的检索窗的联系。这样就没法前后翻页了
                return 0;
            ERROR1:
                MessageBox.Show(this, strError);
                return -1;
            }
            catch (System.ObjectDisposedException)
            {
                return -1;
            }
        }
Exemplo n.º 9
0
        // DTLP协议下 装载模板
        // parameters:
        //      strPath DTLP协议内路径。例如 localhost/中文图书/ctlno/0000001
        public int LoadDtlpTemplate(string strPath)
        {
            int nRet = 0;
            string strError = "";

            DtlpSearchForm dtlp_searchform = this.GetDtlpSearchForm();

            if (dtlp_searchform == null)
            {
                strError = "没有连接的或者打开的DTLP检索窗,无法装载模板";
                goto ERROR1;
            }


            string strServerAddr = "";
            string strDbName = "";
            string strNumber = "";

            // 解析保存路径
            // return:
            //      -1  出错
            //      0   成功
            nRet = DtlpChannel.ParseWritePath(strPath,
                out strServerAddr,
                out strDbName,
                out strNumber,
                out strError);
            if (nRet == -1)
                goto ERROR1;

            string strStartPath = "";

            if (String.IsNullOrEmpty(strServerAddr) == false
                && String.IsNullOrEmpty(strDbName) == false)
                strStartPath = strServerAddr + "/" + strDbName;
            else if (String.IsNullOrEmpty(strServerAddr) == false)
                strStartPath = strServerAddr;

            GetDtlpResDialog dlg = new GetDtlpResDialog();
            GuiUtil.SetControlFont(dlg, this.Font);


            dlg.Text = "请选择目标数据库";
            dlg.Initial(dtlp_searchform.DtlpChannels,
                dtlp_searchform.DtlpChannel);
            dlg.EnabledIndices = new int[] { DtlpChannel.TypeStdbase };
            dlg.Path = strStartPath;
            dlg.StartPosition = FormStartPosition.CenterScreen;

            dlg.ShowDialog(this);

            if (dlg.DialogResult != DialogResult.OK)
                return 0;

            // 获得default.cfg配置文件
            string strCfgPath = dlg.Path + "/cfgs/default.cfg";
            string strContent = "";

            Cursor.Current = Cursors.WaitCursor;
            nRet = dtlp_searchform.DtlpChannel.GetCfgFile(strCfgPath,
                out strContent,
                out strError);
            Cursor.Current = Cursors.Default;

            if (nRet == -1)
                goto ERROR1;

            // 选择模板
            SelectRecordTemplateDialog tempdlg = new SelectRecordTemplateDialog();
            GuiUtil.SetControlFont(tempdlg, this.Font);

            tempdlg.Content = strContent;
            tempdlg.StartPosition = FormStartPosition.CenterScreen;

            tempdlg.ShowDialog(this);

            if (tempdlg.DialogResult != DialogResult.OK)
                return 0;

            this.SavePath = "DTLP" + ":" + dlg.Path + "/ctlno/?";

            // 自动识别MARC格式
            string strOutMarcSyntax = "";
            // 探测记录的MARC格式 unimarc / usmarc / reader
            nRet = MarcUtil.DetectMarcSyntax(tempdlg.SelectedRecordMarc,
                out strOutMarcSyntax);
            if (strOutMarcSyntax == "")
                strOutMarcSyntax = "unimarc";

            if (strOutMarcSyntax == "unimarc" || strOutMarcSyntax == "")
                this.AutoDetectedMarcSyntaxOID = "1.2.840.10003.5.1";
            else if (strOutMarcSyntax == "usmarc")
                this.AutoDetectedMarcSyntaxOID = "1.2.840.10003.5.10";
            else if (strOutMarcSyntax == "dt1000reader")
                this.AutoDetectedMarcSyntaxOID = "1.2.840.10003.5.dt1000reader";
            else
            {
                /*
                strError = "未知的MARC syntax '" + strOutMarcSyntax + "'";
                goto ERROR1;
                 * */
                // TODO: 可以出现菜单选择
            }

            this.MarcEditor.ClearMarcDefDom();
            this.MarcEditor.Marc = tempdlg.SelectedRecordMarc;
            this.CurrentTimestamp = null;

            this.ObjectChanged = false;
            this.BiblioChanged = false;

            DisplayHtml(tempdlg.SelectedRecordMarc, this.AutoDetectedMarcSyntaxOID);

            this.LinkedSearchForm = null;  // 切断和原来关联的检索窗的联系。这样就没法前后翻页了
            return 0;
        ERROR1:
            MessageBox.Show(this, strError);
            return -1;
        }
Exemplo n.º 10
0
        /*
操作类型 crashReport -- 异常报告 
主题 dp2catalog 
发送者 xxxx 
媒体类型 text 
内容 发生未捕获的界面线程异常: 
Type: System.ObjectDisposedException
Message: 无法访问已释放的对象。
对象名:“MarcEditor”。
Stack:
在 System.Windows.Forms.Control.CreateHandle()
在 System.Windows.Forms.Control.get_Handle()
在 DigitalPlatform.Marc.Field.CalculateHeight(Graphics g, Boolean bIgnoreEdit)
在 DigitalPlatform.Marc.FieldCollection.AddInternal(String strName, String strIndicator, String strValue, Boolean bFireTextChanged, Boolean bInOrder, Int32& nOutputPosition)
在 DigitalPlatform.Marc.Record.SetMarc(String strMarc, Boolean bCheckMarcDef, String& strError)
在 DigitalPlatform.Marc.MarcEditor.set_Marc(String value)
在 dp2Catalog.MarcDetailForm.LoadRecord(ISearchForm searchform, Int32 index, Boolean bForceFullElementSet, Boolean bReload)
在 dp2Catalog.dp2SearchForm.LoadDetail(Int32 index, Boolean bOpenNew)
在 dp2Catalog.dp2SearchForm.listView_browse_DoubleClick(Object sender, EventArgs e)
在 System.Windows.Forms.ListView.WndProc(Message& m)
在 DigitalPlatform.GUI.ListViewNF.WndProc(Message& m)
在 System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


dp2Catalog 版本: dp2Catalog, Version=2.4.5698.23777, Culture=neutral, PublicKeyToken=null
操作系统:Microsoft Windows NT 6.1.7601 Service Pack 1 
操作时间 2015/8/10 13:48:50 (Mon, 10 Aug 2015 13:48:50 +0800) 
前端地址 xxxx 经由 http://dp2003.com/dp2library 
         * */
        // 从检索窗装载MARC记录
        // parameters:
        //      bForceFullElementSet    是否强制用Full元素集。如果为false,表示无所谓,也就是说按照当前的元素集(有可能是Full,也有可能是Brief)
        //      bReload 是否确保从数据库装载
        // return:
        //      -1  出错
        //      0   成功
        //      2   需要跳过
        public int LoadRecord(ISearchForm searchform,
            int index,
            bool bForceFullElementSet = false,
            bool bReload = false)
        {
            string strError = "";

            this.stop.BeginLoop();  // 在这里启用 stop,可以防止在装载的中途 Form 被关闭、造成 MarcEditor 设置 MARC 字符串过程抛出异常
            this.EnableControls(false);
            try
            {
                string strMARC = "";

                this.LinkedSearchForm = searchform;
                // this.SavePath = "";  // 2011/5/5 去除

                DigitalPlatform.Z3950.Record record = null;
                Encoding currentEncoding = null;

                this.CurrentRecord = null;
                string strSavePath = "";
                byte[] baTimestamp = null;

                this.m_nDisableInitialAssembly++;   // 防止多次初始化Assembly
                try
                {
                    string strOutStyle = "";
                    LoginInfo logininfo = null;
                    string strXmlFragment = "";
                    long lVersion = 0;

                    string strParameters = "hilight_browse_line";
                    if (bForceFullElementSet == true)
                        strParameters += ",force_full";
                    if (bReload == true)
                        strParameters += ",reload";

                    // 获得一条MARC/XML记录
                    // return:
                    //      -1  error
                    //      0   suceed
                    //      1   为诊断记录
                    //      2   分割条,需要跳过这条记录
                    int nRet = searchform.GetOneRecord(
                        "marc",
                        index,  // 即将废止
                        "index:" + index.ToString(),
                        strParameters,  // true,
                        out strSavePath,
                        out strMARC,
                        out strXmlFragment,
                        out strOutStyle,
                        out baTimestamp,
                        out lVersion,
                        out record,
                        out currentEncoding,
                        out logininfo,
                        out strError);
                    if (nRet == -1)
                        goto ERROR1;
                    if (nRet == 2)
                        return 2;

                    nRet = this.LoadXmlFragment(strXmlFragment,
            out strError);
                    if (nRet == -1)
                        goto ERROR1;

                    this.LoginInfo = logininfo;

                    if (strOutStyle != "marc")
                    {
                        strError = "所获取的记录不是marc格式";
                        goto ERROR1;
                    }

                    this.RecordVersion = lVersion;

                    this.CurrentRecord = record;
                    if (this.m_currentRecord != null)
                    {
                        // 装入二进制编辑器
                        this.binaryEditor_originData.SetData(
                            this.m_currentRecord.m_baRecord);

                        // 装入ISO2709文本
                        nRet = this.Set2709OriginText(this.m_currentRecord.m_baRecord,
                            this.CurrentEncoding,
                            out strError);
                        if (nRet == -1)
                        {
                            this.textBox_originData.Text = strError;
                        }

                        // 数据库名
                        this.textBox_originDatabaseName.Text = this.m_currentRecord.m_strDBName;

                        // Marc syntax OID
                        this.textBox_originMarcSyntaxOID.Text = this.m_currentRecord.m_strSyntaxOID;

                        // 2014/5/18
                        if (this.UseAutoDetectedMarcSyntaxOID == true)
                        {
                            this.AutoDetectedMarcSyntaxOID = this.m_currentRecord.AutoDetectedSyntaxOID;
                            if (string.IsNullOrEmpty(this.AutoDetectedMarcSyntaxOID) == false)
                                this.textBox_originMarcSyntaxOID.Text = this.AutoDetectedMarcSyntaxOID;
                        }

#if NO
                    // 让确定的OID起作用 2008/3/25
                    if (String.IsNullOrEmpty(this.m_currentRecord.m_strSyntaxOID) == false)
                        this.AutoDetectedMarcSyntaxOID = "";
#endif
                    }
                    else
                    {
                        byte[] baMARC = this.CurrentEncoding.GetBytes(strMARC);
                        // 装入二进制编辑器
                        this.binaryEditor_originData.SetData(
                            baMARC);

                        // 装入ISO2709文本
                        nRet = this.Set2709OriginText(baMARC,
                            this.CurrentEncoding,
                            out strError);
                        if (nRet == -1)
                        {
                            this.textBox_originData.Text = strError;
                        }
                    }
                }
                finally
                {
                    this.m_nDisableInitialAssembly--;
                }

                this.SavePath = strSavePath;
                this.CurrentTimestamp = baTimestamp;
                this.CurrentEncoding = currentEncoding;

                // 装入MARC编辑器
                this.MarcEditor.Marc = strMARC;

                DisplayHtml(strMARC, this.textBox_originMarcSyntaxOID.Text);

                // 构造路径

                string strPath = searchform.CurrentProtocol + ":"
                    + searchform.CurrentResultsetPath
                    + "/" + (index + 1).ToString();

                this.textBox_tempRecPath.Text = strPath;

                this.MarcEditor.MarcDefDom = null; // 强制刷新字段名提示
                this.MarcEditor.RefreshNameCaption();

                this.BiblioChanged = false;

                if (this.MarcEditor.FocusedFieldIndex == -1)
                    this.MarcEditor.FocusedFieldIndex = 0;

                this.MarcEditor.Focus();
                return 0;
            }
            finally
            {
                this.stop.EndLoop();
                this.EnableControls(true);
            }
        ERROR1:
            MessageBox.Show(this, strError);
            return -1;
        }
Exemplo n.º 11
0
        // 装载MARC记录,根据记录路径
        // parameters:
        //      strPath 路径。例如 "localhost/图书总库/ctlno/1"
        public int LoadAmazonRecord(ISearchForm searchform,
            string strPath,
            string strDirection,
            bool bLoadResObject)
        {
            string strError = "";

            if (searchform == null)
            {
                strError = "searchform 参数不能为空";
                goto ERROR1;
            }

            Debug.Assert(searchform.CurrentProtocol == searchform.CurrentProtocol.ToLower(), "协议名应当采用小写");
#if NO
            if (dtlp_searchform.CurrentProtocol != "amazon")
            {
                strError = "所提供的检索窗不是dtlp协议";
                goto ERROR1;
            }
#endif

            DigitalPlatform.Z3950.Record record = null;
            Encoding currentEncoding = null;

            this.CurrentRecord = null;

            byte[] baTimestamp = null;
            string strOutStyle = "";

            string strSavePath = "";
            string strMARC;

            long lVersion = 0;
            LoginInfo logininfo = null;
            string strXmlFragment = "";

            int nRet = searchform.GetOneRecord(
                "marc",
                //strPath,
                //strDirection,
                0,  // test
                "path:" + strPath + ",direction:" + strDirection,
                "",
                out strSavePath,
                out strMARC,
                                out strXmlFragment,
                out strOutStyle,
                out baTimestamp,
                                out lVersion,
                out record,
                out currentEncoding,
                                out logininfo,
                out strError);
            if (nRet == -1)
                goto ERROR1;

            this.domXmlFragment = null;

            this.CurrentTimestamp = baTimestamp;
            // this.SavePath = searchform.CurrentProtocol + ":" + strOutputPath;
            this.SavePath = strSavePath;
            this.CurrentEncoding = currentEncoding;

            /*
            // 接着装入对象资源
            if (bLoadResObject == true)
            {
                this.binaryResControl1.Channel = dp2_searchform.GetChannel(dp2_searchform.GetServerUrl(strServerName));
                nRet = this.binaryResControl1.LoadObject(strLocalPath,
                    strRecordXml,
                    out strError);
                if (nRet == -1)
                {
                    MessageBox.Show(this, strError);
                    return -1;
                }
            }*/
            // 装入MARC编辑器
            this.MarcEditor.Marc = strMARC;


            this.CurrentRecord = record;
            if (this.m_currentRecord != null)
            {
                // 装入二进制编辑器
                this.binaryEditor_originData.SetData(
                    this.m_currentRecord.m_baRecord);

                // 装入ISO2709文本
                nRet = this.Set2709OriginText(this.m_currentRecord.m_baRecord,
                    this.CurrentEncoding,
                    out strError);
                if (nRet == -1)
                {
                    this.textBox_originData.Text = strError;
                }

                // 数据库名
                this.textBox_originDatabaseName.Text = this.m_currentRecord.m_strDBName;

                // Marc syntax OID
                this.textBox_originMarcSyntaxOID.Text = this.m_currentRecord.m_strSyntaxOID;

                // 让确定的OID起作用 2008/3/25
                if (String.IsNullOrEmpty(this.m_currentRecord.m_strSyntaxOID) == false)
                    this.AutoDetectedMarcSyntaxOID = "";
            }
            else
            {
                byte[] baMARC = this.CurrentEncoding.GetBytes(strMARC);
                // 装入二进制编辑器
                this.binaryEditor_originData.SetData(
                    baMARC);

                // 装入ISO2709文本
                nRet = this.Set2709OriginText(baMARC,
                    this.CurrentEncoding,
                    out strError);
                if (nRet == -1)
                {
                    this.textBox_originData.Text = strError;
                }
            }

            DisplayHtml(strMARC, this.textBox_originMarcSyntaxOID.Text);

            this.textBox_tempRecPath.Text = "";

            this.MarcEditor.MarcDefDom = null; // 强制刷新字段名提示
            this.MarcEditor.RefreshNameCaption();

            this.BiblioChanged = false;

            if (this.MarcEditor.FocusedFieldIndex == -1)
                this.MarcEditor.FocusedFieldIndex = 0;

            this.MarcEditor.Focus();
            return 0;
        ERROR1:
            MessageBox.Show(this, strError);
            return -1;
        }
Exemplo n.º 12
0
        // 装载XML记录
        public int LoadRecord(ISearchForm searchform,
            int index,
            bool bForceFullElementSet = false)
        {
            string strError = "";
            string strMARC = "";

            this.LinkedSearchForm = searchform;
            this.SavePath = "";

            DigitalPlatform.Z3950.Record record = null;
            Encoding currentEncoding = null;

            this.CurrentRecord = null;

            byte[] baTimestamp = null;
            string strSavePath = "";
            string strOutStyle = "";
            LoginInfo logininfo = null;
            long lVersion = 0;

            string strXmlFragment = "";

            string strParameters = "hilight_browse_line";
            if (bForceFullElementSet == true)
                strParameters += ",force_full";

            int nRet = searchform.GetOneRecord(
                "xml",
                index,  // 即将废止
                "index:" + index.ToString(),
                strParameters, // true,
                out strSavePath,
                out strMARC,
                out strXmlFragment,
                out strOutStyle,
                out baTimestamp,
                out lVersion,
                out record,
                out currentEncoding,
                out logininfo,
                out strError);
            if (nRet == -1)
                goto ERROR1;


            this.LoginInfo = logininfo;

            this.CurrentTimestamp = baTimestamp;
            this.SavePath = strSavePath;
            this.CurrentEncoding = currentEncoding;


            // 替换单个0x0a
            strMARC = strMARC.Replace("\r", "");
            strMARC = strMARC.Replace("\n", "\r\n");

            // 装入XML编辑器
            // this.textBox_xml.Text = strMARC;
            this.PlainText = strMARC;   // 能自动缩进
            this.textBox_xml.Select(0, 0);

            // 装入XML只读Web控件
            {
                string strTempFileName = MainForm.DataDir + "\\xml.xml";

                // SUTRS
                if (record.m_strSyntaxOID == "1.2.840.10003.5.101")
                    strTempFileName = MainForm.DataDir + "\\xml.txt";

                using (Stream stream = File.Create(strTempFileName))
                {
                    // 写入xml内容
                    byte[] buffer = Encoding.UTF8.GetBytes(strMARC);
                    stream.Write(buffer, 0, buffer.Length);
                }

                this.webBrowser_xml.Navigate(strTempFileName);
            }

            this.CurrentRecord = record;
            if (this.CurrentRecord != null && this.DisplayOriginPage == true)
            {
                // 装入二进制编辑器
                this.binaryEditor_originData.SetData(
                    this.CurrentRecord.m_baRecord);

                // 装入原始文本
                nRet = this.SetOriginText(this.CurrentRecord.m_baRecord,
                    this.CurrentEncoding,
                    out strError);
                if (nRet == -1)
                {
                    this.textBox_originData.Text = strError;
                }

                // 数据库名
                this.textBox_originDatabaseName.Text = this.CurrentRecord.m_strDBName;

                // record syntax OID
                this.textBox_originMarcSyntaxOID.Text = this.CurrentRecord.m_strSyntaxOID;
            }

            // 构造路径
            string strPath = searchform.CurrentProtocol + ":"
                + searchform.CurrentResultsetPath
                + "/" + (index + 1).ToString();

            this.textBox_tempRecPath.Text = strPath;
            this.textBox_xml.Focus();
            return 0;
        ERROR1:
            MessageBox.Show(this, strError);
            return -1;
        }
Exemplo n.º 13
0
        // 装载XML记录,根据结果集中位置
        public int LoadRecord(ISearchForm searchform,
            int index)
        {
            string strError = "";
            string strRecordXml = "";

            this.LinkedSearchForm = searchform;
            this.SavePath = "";

            DigitalPlatform.Z3950.Record record = null;
            Encoding currentEncoding = null;

            this.CurrentRecord = null;


            byte[] baTimestamp = null;
            string strSavePath = "";
            string strOutStyle = "";
            LoginInfo logininfo = null;
            long lVersion = 0;
            string strXmlFragment = "";

            int nRet = searchform.GetOneRecord(
                "xml",
                index,  // 即将废止
                "index:" + index.ToString(),
                "hilight_browse_line", // true,
                out strSavePath,
                out strRecordXml,
                out strXmlFragment,
                out strOutStyle,
                out baTimestamp,
                out lVersion,
                out record,
                out currentEncoding,
                out logininfo,
                out strError);
            if (nRet == -1)
                goto ERROR1;

            this.LoginInfo = logininfo;

            this.CurrentTimestamp = baTimestamp;
            this.SavePath = strSavePath;
            this.CurrentEncoding = currentEncoding;

            // dp2library协议
            if (searchform.CurrentProtocol == "dp2library")
            {
                dp2SearchForm dp2_searchform = this.GetDp2SearchForm();

                if (dp2_searchform == null)
                {
                    strError = "没有连接的或者打开的dp2检索窗,无法进行数据创建";
                    goto ERROR1;
                }

                string strProtocol = "";
                string strPath = "";
                nRet = Global.ParsePath(strSavePath,
                    out strProtocol,
                    out strPath,
                    out strError);
                if (nRet == -1)
                    goto ERROR1;

                string strServerName = "";
                string strLocalPath = "";
                // 解析记录路径。
                // 记录路径为如下形态 "中文图书/1 @服务器"
                dp2SearchForm.ParseRecPath(strPath,
                    out strServerName,
                    out strLocalPath);

                string strBiblioDbName = dp2SearchForm.GetDbName(strLocalPath);

                // 获得cfgs\dcdef
                string strCfgFileName = "dcdef";

                string strCfgPath = strBiblioDbName + "/cfgs/" + strCfgFileName + "@" + strServerName;

                // 和以前的不同,才有必要重新载入
                if (this.DcCfgFilename != strCfgPath)
                {
                    string strCode = "";
                    byte[] baCfgOutputTimestamp = null;
                    // return:
                    //      -1  error
                    //      0   not found
                    //      1   found
                    nRet = dp2_searchform.GetCfgFile(strCfgPath,
                        out strCode,
                        out baCfgOutputTimestamp,
                        out strError);
                    if (nRet == -1 || nRet == 0)
                        goto ERROR1;

                    nRet = this.DcEditor.LoadCfgCode(strCode,
                        out strError);
                    if (nRet == -1)
                        goto ERROR1;

                    this.DcCfgFilename = strCfgPath;
                }

                // 接着装入对象资源
                {
                    EnableStateCollection save = this.MainForm.DisableToolButtons();
                    try
                    {
                        // this.binaryResControl1.Channel = dp2_searchform.GetChannel(dp2_searchform.GetServerUrl(strServerName));
                        nRet = this.binaryResControl1.LoadObject(
                            dp2_searchform.GetChannel(dp2_searchform.GetServerUrl(strServerName)),
                            strLocalPath,
                            strRecordXml,
                            "0",  // TODO
                            out strError);
                        if (nRet == -1)
                        {
                            MessageBox.Show(this, strError);
                            return -1;
                        }
                    }
                    finally
                    {
                        save.RestoreAll();
                    }
                }
            }

            /*
            // 替换单个0x0a
            strMARC = strMARC.Replace("\r", "");
            strMARC = strMARC.Replace("\n", "\r\n");
             * */

            // TODO: 再次装入的时候有问题
            // 装入DC编辑器
            this.DcEditor.Xml = strRecordXml;


            /*
            // 装入XML只读Web控件
            {
                string strTempFileName = MainForm.DataDir + "\\xml.xml";

                // SUTRS
                if (record != null)
                {
                    if (record.m_strSyntaxOID == "1.2.840.10003.5.101")
                        strTempFileName = MainForm.DataDir + "\\xml.txt";
                }

                Stream stream = File.Create(strTempFileName);

                // 写入xml内容
                byte[] buffer = Encoding.UTF8.GetBytes(strRecordXml);

                stream.Write(buffer, 0, buffer.Length);

                stream.Close();

                this.webBrowser_xml.Navigate(strTempFileName);
            }
             * */


            this.CurrentRecord = record;

            /*
            if (this.CurrentRecord != null)
            {
                // 装入二进制编辑器
                this.binaryEditor_originData.SetData(
                    this.CurrentRecord.m_baRecord);

                // 装入原始文本
                nRet = this.SetOriginText(this.CurrentRecord.m_baRecord,
                    this.CurrentEncoding,
                    out strError);
                if (nRet == -1)
                {
                    this.textBox_originData.Text = strError;
                }

                // 数据库名
                this.textBox_originDatabaseName.Text = this.CurrentRecord.m_strDBName;

                // record syntax OID
                this.textBox_originMarcSyntaxOID.Text = this.CurrentRecord.m_strSyntaxOID;
            }*/


            // 构造结果集路径
            string strFullPath = searchform.CurrentProtocol + ":"
                + searchform.CurrentResultsetPath
                + "/" + (index + 1).ToString();

            this.textBox_tempRecPath.Text = strFullPath;


            this.BiblioChanged = false;

            this.DcEditor.Focus();
            return 0;
        ERROR1:
            MessageBox.Show(this, strError);
            return -1;
        }
Exemplo n.º 14
0
        // 装载模板
        public int LoadTemplate()
        {
            string strError = "";
            int nRet = 0;

            if (this.BiblioChanged == true
                || this.ObjectChanged == true)
            {
                // 警告尚未保存
                DialogResult result = MessageBox.Show(this,
                    "当前有 " + GetCurrentChangedPartName() + " 被修改后尚未保存。若此时装载新内容,现有未保存信息将丢失。\r\n\r\n确实要装载新内容? ",
                    "DcForm",
                    MessageBoxButtons.YesNo,
                    MessageBoxIcon.Question,
                    MessageBoxDefaultButton.Button2);
                if (result == DialogResult.No)
                    return 0;
            }


            dp2SearchForm dp2_searchform = this.GetDp2SearchForm();

            if (dp2_searchform == null)
            {
                strError = "没有连接的或者打开的dp2检索窗,无法装载模板";
                goto ERROR1;
            }

            string strProtocol = "";
            string strPath = "";

            string strServerName = "";
            string strLocalPath = "";

            string strBiblioDbName = "";

            if (String.IsNullOrEmpty(this.SavePath) == false)
            {
                // 分离出各个部分
                nRet = Global.ParsePath(this.SavePath,
                    out strProtocol,
                    out strPath,
                    out strError);
                if (nRet == -1)
                {
                    strError = "解析路径 '" + this.SavePath + "' 字符串过程中发生错误: " + strError;
                    goto ERROR1;
                }

                if (strProtocol == "dp2library")
                {
                    // 解析记录路径。
                    // 记录路径为如下形态 "中文图书/1 @服务器"
                    dp2SearchForm.ParseRecPath(strPath,
                        out strServerName,
                        out strLocalPath);

                    strBiblioDbName = dp2SearchForm.GetDbName(strLocalPath);
                }
                else
                {
                    strProtocol = "dp2library";
                    strPath = "";
                }
            }
            else
            {
                strProtocol = "dp2library";
            }

            /*
            if (this.LinkedSearchForm != null
                && strProtocol != this.LinkedSearchForm.CurrentProtocol)
            {
                strError = "检索窗的协议已经发生改变";
                goto ERROR1;
            }*/

            string strStartPath = "";

            if (String.IsNullOrEmpty(strServerName) == false
                && String.IsNullOrEmpty(strBiblioDbName) == false)
                strStartPath = strServerName + "/" + strBiblioDbName;
            else if (String.IsNullOrEmpty(strServerName) == false)
                strStartPath = strServerName;

            GetDp2ResDlg dlg = new GetDp2ResDlg();
            GuiUtil.SetControlFont(dlg, this.Font);

            dlg.Text = "请选择目标数据库";
            dlg.dp2Channels = dp2_searchform.Channels;
            dlg.Servers = this.MainForm.Servers;
            dlg.EnabledIndices = new int[] { dp2ResTree.RESTYPE_DB };
            dlg.Path = strStartPath;

            dlg.ShowDialog(this);

            if (dlg.DialogResult != DialogResult.OK)
                return 0;

            // 将目标路径拆分为两个部分
            nRet = dlg.Path.IndexOf("/");
            if (nRet == -1)
            {
                Debug.Assert(false, "");
                strServerName = dlg.Path;
                strBiblioDbName = "";
                strError = "所选择目标(数据库)路径 '" + dlg.Path + "' 格式不正确";
                goto ERROR1;
            }
            else
            {
                strServerName = dlg.Path.Substring(0, nRet);
                strBiblioDbName = dlg.Path.Substring(nRet + 1);

                // 检查所选数据库的syntax,必须为dc

                string strSyntax = "";
                // 获得一个数据库的数据syntax
                // parameters:
                //      stop    如果!=null,表示使用这个stop,它已经OnStop +=
                //              如果==null,表示会自动使用this.stop,并自动OnStop+=
                // return:
                //      -1  error
                //      0   not found
                //      1   found
                nRet = dp2_searchform.GetDbSyntax(
                    null,
                    strServerName,
                    strBiblioDbName,
                    out strSyntax,
                    out strError);
                if (nRet == -1)
                {
                    strError = "获取书目库 '" + strBiblioDbName + "的数据格式时发生错误: " + strError;
                    goto ERROR1;
                }

                if (strSyntax != "dc")
                {
                    strError = "所选书目库 '" + strBiblioDbName + "' 不是DC格式的数据库";
                    goto ERROR1;
                }
            }


            // 然后获得cfgs/template配置文件
            string strCfgFilePath = strBiblioDbName + "/cfgs/template" + "@" + strServerName;

            string strCode = "";
            byte[] baCfgOutputTimestamp = null;
            // return:
            //      -1  error
            //      0   not found
            //      1   found
            nRet = dp2_searchform.GetCfgFile(strCfgFilePath,
                out strCode,
                out baCfgOutputTimestamp,
                out strError);
            if (nRet == -1 || nRet == 0)
                goto ERROR1;

            SelectRecordTemplateDlg tempdlg = new SelectRecordTemplateDlg();
            GuiUtil.SetControlFont(tempdlg, this.Font);
            nRet = tempdlg.Initial(false,
                strCode,
                out strError);
            if (nRet == -1)
            {
                strError = "装载配置文件 '" + strCfgFilePath + "' 发生错误: " + strError;
                goto ERROR1;
            }

            tempdlg.ap = this.MainForm.AppInfo;
            tempdlg.ApCfgTitle = "dcform_selecttemplatedlg";
            tempdlg.ShowDialog(this);

            if (tempdlg.DialogResult != DialogResult.OK)
                return 0;

            // 获得cfgs\dcdef
            string strCfgFileName = "dcdef";

            string strCfgPath = strBiblioDbName + "/cfgs/" + strCfgFileName + "@" + strServerName;

            // 和以前的不同,才有必要重新载入
            if (this.DcCfgFilename != strCfgPath)
            {
                strCode = "";
                // byte[] baCfgOutputTimestamp = null;
                // return:
                //      -1  error
                //      0   not found
                //      1   found
                nRet = dp2_searchform.GetCfgFile(strCfgPath,
                    out strCode,
                    out baCfgOutputTimestamp,
                    out strError);
                if (nRet == -1 || nRet == 0)
                    goto ERROR1;

                nRet = this.DcEditor.LoadCfgCode(strCode,
                    out strError);
                if (nRet == -1)
                    goto ERROR1;

                this.DcCfgFilename = strCfgPath;
            }

            // 接着装入对象资源
            {
                this.binaryResControl1.Clear();
                // this.binaryResControl1.Channel = dp2_searchform.GetChannel(dp2_searchform.GetServerUrl(strServerName));
                this.binaryResControl1.BiblioRecPath = strBiblioDbName + "/?";
            }

            this.DcEditor.Xml = tempdlg.SelectedRecordXml;
            this.CurrentTimestamp = null;   // baCfgOutputTimestamp;

            this.SavePath = strProtocol + ":" + strBiblioDbName + "/?" + "@" + strServerName;

            this.ObjectChanged = false;
            this.BiblioChanged = false;

            this.LinkedSearchForm = null;  // 切断和原来关联的检索窗的联系。这样就没法前后翻页了
            return 0;
        ERROR1:
            MessageBox.Show(this, strError);
            return -1;
        }
Exemplo n.º 15
0
 /// <summary>
 /// Searches the specfied queryable for entities using the provided search form.
 /// </summary>
 /// <typeparam name="TEntity">The type of entities to look for.</typeparam>
 /// <param name="query">The queryable that should be searched.</param>
 /// <param name="search">The search form that should be used to search the query.</param>
 /// <returns>A QuerySearchResult that contains the result of the search.</returns>
 public static Task <QuerySearchResult <TEntity> > SearchAsync <TEntity>(this IQueryable <TEntity> query, ISearchForm search)
 {
     return(query.SearchAsync(search, null));
 }
Exemplo n.º 16
0
        /// <summary>
        /// Searches the specfied queryable for entities using the provided search form.
        /// </summary>
        /// <typeparam name="TEntity">The type of entities to look for.</typeparam>
        /// <typeparam name="TQuerySearchProvider">The IQuerySearchProvider to use.</typeparam>
        /// <param name="query">The queryable that should be searched.</param>
        /// <param name="search">The search form that should be used to search the query.</param>
        /// <param name="postCountProcessesing">Function to be called after processing the count portions of the query. Often used to add navigation inclusions.</param>
        /// <returns>A QuerySearchResult that contains the result of the search.</returns>
        public static async Task <QuerySearchResult <TEntity> > SearchAsync <TEntity, TQuerySearchProvider>(this IQueryable <TEntity> query, ISearchForm search, Func <IQueryable <TEntity>, IQueryable <TEntity> > postCountProcessesing)
            where TQuerySearchProvider : IQuerySearchProvider <TEntity>
        {
            if (query == null)
            {
                throw new ArgumentNullException(nameof(query));
            }
            if (search == null)
            {
                throw new ArgumentNullException(nameof(query));
            }

            var registry = DependencyResolver.Current;

            if (registry == null)
            {
                throw new QuerySearchException("No dependency resolver has been specified.");
            }

            var provider = registry.Resolve <TQuerySearchProvider>();

            if (provider == null)
            {
                throw new QuerySearchException($"No IQuerySearchProvider has been registered of the type '{typeof( TQuerySearchProvider ).FullName}'.");
            }

            var fullCount = await query.CountAsync().ConfigureAwait(false);

            query = provider.ApplyWhere(query, search);

            var filteredCount = await query.CountAsync().ConfigureAwait(false);

            if (postCountProcessesing != null)
            {
                query = postCountProcessesing(query);
            }

            var result = provider.ApplyPagination(query, search);

            var items = await result.Query.ToListAsync().ConfigureAwait(false);

            return(new QuerySearchResult <TEntity>
            {
                FilteredCount = filteredCount,
                FilteredPageCount = PaginationHelper.GetPageCount(filteredCount, result.PageSize),
                Page = result.Page,
                Skip = result.Skip,
                Take = result.Take,
                Items = items
            });
        }