예제 #1
0
        public unsafe SearchResult SearchNewMems(DateTime startDate1,
                                                 DateTime startDate2,
                                                 DateTime endDate2)
        {
            var result = new SearchResult();

            IntPtr pRelevantResult = searchNewMemsDLL(InstanceNumber,
                                                      (uint)startDate1.Year,
                                                      (uint)startDate1.Month,
                                                      (uint)startDate2.Year,
                                                      (uint)startDate2.Month,
                                                      (uint)startDate2.Day,
                                                      (uint)endDate2.Year,
                                                      (uint)endDate2.Month,
                                                      (uint)endDate2.Day,
                                                      (uint)endDate2.Subtract(startDate2).TotalDays + 1);

            if (pRelevantResult.ToInt32() > 0)
            {
                RelevantResultDLL relevantResultDLL = (RelevantResultDLL)Marshal.PtrToStructure(pRelevantResult, typeof(RelevantResultDLL));

                result.MatchWords = relevantResultDLL.MatchWords;

                releaseRelevantResultDLL(InstanceNumber, pRelevantResult);
            }

            //Marshal.Release(pRelevantResult);


            return(result);
        }
예제 #2
0
        public unsafe List <uint> SearchIDByPhrase(string phrase, string templateName, uint minPage, uint maxPage)
        {
            List <uint> results = new List <uint>();

            byte[] nameBytes = new byte[DOC_NAME_LENGTH];

            fixed(Byte *pPhrase = Encoding.GetBytes(phrase),
                  pTemplateName = Encoding.GetBytes(templateName),
                  pName         = nameBytes)
            {
                IntPtr pRelevantResult = searchPhraseDLL(InstanceNumber,
                                                         pPhrase,
                                                         (System.UInt32)phrase.Length,
                                                         pTemplateName,
                                                         (System.UInt32)templateName.Length,
                                                         minPage,
                                                         maxPage,
                                                         0);

                RelevantResultDLL relevantResultDLL = (RelevantResultDLL)Marshal.PtrToStructure(pRelevantResult, typeof(RelevantResultDLL));

                for (uint i = 0; i < relevantResultDLL.CountMatches; i++)
                {
                    //NOT IMPLEMENTED
                    //results.Add(relevantResultDLL.Matches[i]);
                }

                releaseRelevantResultDLL(InstanceNumber, pRelevantResult);

                //Marshal.Release(pRelevantResult);
            }

            return(results);
        }
예제 #3
0
        public unsafe SearchResult SearchPhraseRel(string phrase,
                                                   int minPage,
                                                   int maxPage)
        {
            SearchResult result = new SearchResult();

            //byte[] nameBytes = new byte[DOC_NAME_LENGTH];

            fixed(Byte *pPhrase = Encoding.GetBytes(phrase))
            {
                IntPtr pRelevantResult = searchPhraseRelDLL(InstanceNumber,
                                                            pPhrase,
                                                            Convert.ToUInt32(phrase.Length),
                                                            Convert.ToUInt32(minPage),
                                                            Convert.ToUInt32(maxPage));

                RelevantResultDLL relevantResultDLL = (RelevantResultDLL)Marshal.PtrToStructure(pRelevantResult, typeof(RelevantResultDLL));

                result.MatchWords = relevantResultDLL.MatchWords;

                for (uint i = 0; i < relevantResultDLL.CountMatches; i++)
                {
                    //get name of document
                    //getDocumentNameByIDDLL(InstanceNumber, relevantResultDLL.Matches[i], pName, DOC_NAME_LENGTH);

                    result.Results.Add(new Result {
                        Name = relevantResultDLL.Matches[i].Name
                    });
                }

                releaseRelevantResultDLL(InstanceNumber, pRelevantResult);

                //Marshal.Release(pRelevantResult);
            }

            return(result);
        }
예제 #4
0
        public unsafe SearchResult SearchPhrase(string phrase,
                                                string templateName,
                                                int minPage,
                                                int maxPage,
                                                int skip)
        {
            SearchResult sr = new SearchResult();

            fixed(Byte *pPhrase = Encoding.GetBytes(phrase),
                  pTemplateName = Encoding.GetBytes(templateName))
            {
                IntPtr pRelevantResult = searchPhraseDLL(InstanceNumber,
                                                         pPhrase,
                                                         Convert.ToUInt32(phrase.Length),
                                                         pTemplateName,
                                                         Convert.ToUInt32(templateName.Length),
                                                         Convert.ToUInt32(minPage),
                                                         Convert.ToUInt32(maxPage),
                                                         Convert.ToUInt32(skip));

                RelevantResultDLL relevantResultDLL = (RelevantResultDLL)Marshal.PtrToStructure(pRelevantResult, typeof(RelevantResultDLL));

                sr.FullCountMatches = relevantResultDLL.FullCountMatches;

                for (uint i = 0; i < relevantResultDLL.CountMatches; i++)
                {
                    //get name of document
                    Result result = new Result();
                    //if (true)
                    //{
                    result.Name = relevantResultDLL.Matches[i].Name;
                    //*result.Positions = new ResultPosition[0]; //empty
                    //}
                    //else
                    //{
                    //    string[] nameAndPart = tempName.ToString().Split(new string[] { "=>" }, StringSplitOptions.None);

                    //    result.Name = nameAndPart[0];

                    //    //get positions
                    //    MatchPositionsDLL matchPositionsDLL = (MatchPositionsDLL)Marshal.PtrToStructure(relevantResultDLL.BestMatchPositions[i], typeof(MatchPositionsDLL));

                    //    byte[] matchPositions = new byte[matchPositionsDLL.CountPositions];

                    //    Marshal.Copy(matchPositionsDLL.Positions, matchPositions, 0, matchPositionsDLL.CountPositions);
                    //    Marshal.Release(matchPositionsDLL.Positions);
                    //    Marshal.Release(relevantResultDLL.BestMatchPositions[i]);

                    //    result.Positions = new ResultPosition[matchPositions.Length];
                    //    for (int j = 0; j < result.Positions.Length; j++)
                    //    {
                    //        result.Positions[j].StartPosition = int.Parse(nameAndPart[1]) * 65536 + matchPositions[j] * DOC_NAME_LENGTH;
                    //        result.Positions[j].Length = 512;
                    //    }
                    //}

                    sr.Results.Add(result);
                }

                //if (false)
                //{
                //    for (uint i = 0; i < relevantResultDLL.CountOtherMatches; i++)
                //    {
                //        getDocumentNameByIDDLL(relevantResultDLL.OtherMatches[i], tempName, 1024);
                //        relevantResult.OtherMatches.Add(tempName.ToString());
                //    }
                //}

                releaseRelevantResultDLL(InstanceNumber, pRelevantResult);

                //Marshal.Release(pRelevantResult);
            }

            return(sr);
        }