private int compareByCount(DBCrawlerGitDetailDataModel compareModel)
 {
     if (this.impressionCount > compareModel.impressionCount)
     {
         return(-1);
     }
     else if (this.impressionCount < compareModel.impressionCount)
     {
         return(1);
     }
     else
     {
         if (this.clickCount > compareModel.clickCount)
         {
             return(-1);
         }
         else if (this.clickCount < compareModel.clickCount)
         {
             return(1);
         }
         else
         {
             return(0);
         }
     }
 }
        public int CompareTo(object obj)
        {
            DBCrawlerGitDetailDataModel compareModel = (DBCrawlerGitDetailDataModel)obj;

            if (DBCrawlerGitDetailDataModelData.IndexRepositoryContentList == null || DBCrawlerGitDetailDataModelData.IndexRepositoryContentList.Count == 0)
            {
                return(compareByCount(compareModel));
            }
            else
            {
                int maxLen = DBCrawlerGitDetailDataModelData.IndexRepositoryContentList.Count;
                for (int len = maxLen; len > 0; len--)
                {
                    List <string> IndexRepositoryContentListCurrent = new List <string>();
                    for (int startIndex = 0; startIndex <= maxLen - len; startIndex++)
                    {
                        string indexRepositoryContentCurrentElement = "";
                        for (int curIndex = 0; curIndex < len; curIndex++)
                        {
                            if (curIndex > 0)
                            {
                                indexRepositoryContentCurrentElement += " ";
                            }
                            indexRepositoryContentCurrentElement += DBCrawlerGitDetailDataModelData.IndexRepositoryContentList[startIndex + curIndex];
                        }
                        IndexRepositoryContentListCurrent.Add(indexRepositoryContentCurrentElement);
                    }
                    int thisContainConut    = 0;
                    int compareContainConut = 0;
                    foreach (string indexRepositoryContentElement in IndexRepositoryContentListCurrent)
                    {
                        if (this.repositoryContent.Contains(indexRepositoryContentElement))
                        {
                            thisContainConut++;
                        }
                        if (compareModel.repositoryContent.Contains(indexRepositoryContentElement))
                        {
                            compareContainConut++;
                        }
                    }
                    if (compareContainConut != thisContainConut)
                    {
                        return(compareContainConut - thisContainConut);
                    }
                    if (compareContainConut > 0)
                    {
                        return(compareByCount(compareModel));
                    }
                }
                return(compareByCount(compareModel));
            }
        }
Exemplo n.º 3
0
        private void ExecuteReaderByText(ref List <DBCrawlerGitDetailDataModel> readmeDBList, ref HashSet <string> repositoryPathFromDBSet, ref SqlConnection Connection, string dbQueryContentSql)
        {
            SqlCommand cmdContent = new SqlCommand(dbQueryContentSql, Connection);

            cmdContent.CommandType = CommandType.Text;

            SqlDataReader contentReader = cmdContent.ExecuteReader();

            while (contentReader.Read())
            {
                string repositoryPathFromDB = contentReader["repositoryPath"].ToString();
                if (repositoryPathFromDBSet.Contains(repositoryPathFromDB))
                {
                    continue;
                }
                string        downloadURLFromDB       = contentReader["downloadURL"].ToString();
                int           impressionCountFromDB   = Convert.ToInt32(contentReader["impressionCount"].ToString());
                int           clickCountFromDB        = Convert.ToInt32(contentReader["clickCount"].ToString());
                string        repositoryContentFromDB = contentReader["repositoryContent"].ToString();
                List <string> topicsListFromDB        = new List <string>(contentReader["topicsList"].ToString().Split(';'));
                string        readmeFileContent       = contentReader["readmeContent"].ToString();
                DBCrawlerGitDetailDataModel model     = new DBCrawlerGitDetailDataModel(repositoryPathFromDB,
                                                                                        downloadURLFromDB,
                                                                                        impressionCountFromDB,
                                                                                        clickCountFromDB,
                                                                                        repositoryContentFromDB,
                                                                                        topicsListFromDB,
                                                                                        readmeFileContent);
                readmeDBList.Add(model);
                repositoryPathFromDBSet.Add(repositoryPathFromDB);
                if (readmeDBList.Count >= Configuration.IndexLineCountMax)
                {
                    contentReader.Close();
                    return;
                }
            }
            contentReader.Close();
        }