Пример #1
0
        static private TagCombination createTctDataToInsert(long id, long tagId, long countryId, long tagCount, double average, String[] topNtags)
        {
            TagCombination tagCombination = new TagCombination();

            tagCombination.Id                = id;
            tagCombination.TagId             = tagId;
            tagCombination.CountryId         = countryId;
            tagCombination.TagCount          = tagCount;
            tagCombination.AverageCorrosTags = average;
            tagCombination.TopTags           = topNtags;
            return(tagCombination);
        }
Пример #2
0
        static public void checkDbRawQuery()
        {
            cleanDatabase();
            String         tag_counts = "";
            long           TC_ID      = 1;
            long           TCD_ID     = 1;
            List <Country> countries  = getAllCountriesFromDB();

            foreach (Country country in countries)
            {
                Console.WriteLine("COUNTRY : " + country.Name);
                List <TagsKeyValue> tagsList = getAllTagsFromDB();
                Console.WriteLine("Length of tags " + tagsList.Count);
                foreach (TagsKeyValue tag in tagsList)
                {
                    String tag_key   = tag.Key;
                    String tag_value = tag.Value;
                    Console.WriteLine("Key : " + tag_key + " and Value: " + tag_value);
                    long tagTotalCount = getTagCount(country.Db, tag_key, tag_value);
                    if (tagTotalCount == -1)
                    {
                        Console.WriteLine("ERROR. ABORT");
                        //Break, there is something wrong.
                    }
                    tag_counts = tagTotalCount.ToString();
                    List <TagAggregation> listOfTags = getAllTagsRespectively(country.Db, tag_key, tag_value, tag_counts);
                    Console.WriteLine("List Size " + listOfTags.Count);

                    Double        average  = getAverageNumberOfTags(country.Db, tag_key, tag_value);
                    List <String> topNtags = new List <string>();
                    int           temp     = 0;
                    foreach (TagAggregation tagAggregation in listOfTags)
                    {
                        topNtags.Add(tagAggregation.tag);
                    }

                    TagCombination tagCombination = createTctDataToInsert(TC_ID, tag.Id, country.Id, tagTotalCount, average, topNtags.ToArray());
                    insertTagCombinationData(tagCombination);
                    foreach (TagAggregation tags in listOfTags)
                    {
                        TagCombinationDetail tagCombinationDetail = createTcdtDataToInsert(TCD_ID, TC_ID, tags.tag, tags.count, Math.Round(tags.percent, 2));
                        insertTagCombinationDetailData(tagCombinationDetail);
                        TCD_ID++;
                    }
                    TC_ID++;
                }
            }
        }
Пример #3
0
        static private void insertTagCombinationData(TagCombination tagCombination)
        {
            using (tag_qualityContext db = new tag_qualityContext())
            {
                db.Set <TagCombination>().Add(tagCombination);

                try
                {
                    int records = db.SaveChanges();
                    Console.WriteLine("Saved {0} Tag Combination to DB", records);
                }
                catch (DbUpdateException e)
                {
                    Console.WriteLine(e.Message);
                    Console.WriteLine(e.StackTrace);
                    Console.WriteLine(e.InnerException);
                }
            }
        }