public string retrievefan_60(string id)
        {
            string ret_string = string.Empty;
            Domain.Socioboard.Domain.TopFiveFans_60 ret = new Domain.Socioboard.Domain.TopFiveFans_60();
            List<Domain.Socioboard.Domain.TopFiveFans_60> ret_list = new List<Domain.Socioboard.Domain.TopFiveFans_60>();

            using (NHibernate.ISession session = SessionFactory.GetNewSession())
            {

                try
                {

                    ret_list = session.CreateQuery("from TopFiveFans_60 where ProfileId =: id").SetParameter("id", id).List<Domain.Socioboard.Domain.TopFiveFans_60>().ToList().OrderByDescending(x => x.Rank).ToList();
                    if (ret_list == null)
                    {
                        ret_list = new List<Domain.Socioboard.Domain.TopFiveFans_60>();
                    }
                    ret_string = new JavaScriptSerializer().Serialize(ret_list);

                }
                catch (Exception e)
                {
                    logger.Error("noretrievedata>>");
                    Console.WriteLine(e.StackTrace);
                    logger.Error(e.Message);
                    logger.Error(e.StackTrace);

                    ret_list = new List<Domain.Socioboard.Domain.TopFiveFans_60>();
                    ret_string = new JavaScriptSerializer().Serialize(ret_list);
                }

            }
            return ret_string;
        }
        public void top_five_fans(string profileid)
        {

            List<Domain.Socioboard.Domain.TopFiveFans_15> topfans_15 = new List<Domain.Socioboard.Domain.TopFiveFans_15>();
            List<Domain.Socioboard.Domain.TopFiveFans_30> topfans_30 = new List<Domain.Socioboard.Domain.TopFiveFans_30>();
            List<Domain.Socioboard.Domain.TopFiveFans_60> topfans_60 = new List<Domain.Socioboard.Domain.TopFiveFans_60>();
            List<Domain.Socioboard.Domain.TopFiveFans_90> topfans_90 = new List<Domain.Socioboard.Domain.TopFiveFans_90>();
           
            List<Domain.Socioboard.Domain.InboxMessages> mention_retweets_15 = new List<Domain.Socioboard.Domain.InboxMessages>();
            List<Domain.Socioboard.Domain.InboxMessages> mention_retweets_30 = new List<Domain.Socioboard.Domain.InboxMessages>();
            List<Domain.Socioboard.Domain.InboxMessages> mention_retweets_60 = new List<Domain.Socioboard.Domain.InboxMessages>();
            List<Domain.Socioboard.Domain.InboxMessages> mention_retweets_90 = new List<Domain.Socioboard.Domain.InboxMessages>();
            
            Domain.Socioboard.Domain.TopFiveFans_15 first_15 = new Domain.Socioboard.Domain.TopFiveFans_15();
            Domain.Socioboard.Domain.TopFiveFans_15 second_15 = new Domain.Socioboard.Domain.TopFiveFans_15();
            Domain.Socioboard.Domain.TopFiveFans_15 third_15 = new Domain.Socioboard.Domain.TopFiveFans_15();
            Domain.Socioboard.Domain.TopFiveFans_15 fourth_15 = new Domain.Socioboard.Domain.TopFiveFans_15();
            Domain.Socioboard.Domain.TopFiveFans_15 fifth_15 = new Domain.Socioboard.Domain.TopFiveFans_15();

            Domain.Socioboard.Domain.TopFiveFans_30 first_30 = new Domain.Socioboard.Domain.TopFiveFans_30();
            Domain.Socioboard.Domain.TopFiveFans_30 second_30 = new Domain.Socioboard.Domain.TopFiveFans_30();
            Domain.Socioboard.Domain.TopFiveFans_30 third_30 = new Domain.Socioboard.Domain.TopFiveFans_30();
            Domain.Socioboard.Domain.TopFiveFans_30 fourth_30 = new Domain.Socioboard.Domain.TopFiveFans_30();
            Domain.Socioboard.Domain.TopFiveFans_30 fifth_30 = new Domain.Socioboard.Domain.TopFiveFans_30();
            
            Domain.Socioboard.Domain.TopFiveFans_60 first_60 = new Domain.Socioboard.Domain.TopFiveFans_60();
            Domain.Socioboard.Domain.TopFiveFans_60 second_60 = new Domain.Socioboard.Domain.TopFiveFans_60();
            Domain.Socioboard.Domain.TopFiveFans_60 third_60 = new Domain.Socioboard.Domain.TopFiveFans_60();
            Domain.Socioboard.Domain.TopFiveFans_60 fourth_60 = new Domain.Socioboard.Domain.TopFiveFans_60();
            Domain.Socioboard.Domain.TopFiveFans_60 fifth_60 = new Domain.Socioboard.Domain.TopFiveFans_60();

            Domain.Socioboard.Domain.TopFiveFans_90 first_90 = new Domain.Socioboard.Domain.TopFiveFans_90();
            Domain.Socioboard.Domain.TopFiveFans_90 second_90 = new Domain.Socioboard.Domain.TopFiveFans_90();
            Domain.Socioboard.Domain.TopFiveFans_90 third_90 = new Domain.Socioboard.Domain.TopFiveFans_90();
            Domain.Socioboard.Domain.TopFiveFans_90 fourth_90 = new Domain.Socioboard.Domain.TopFiveFans_90();
            Domain.Socioboard.Domain.TopFiveFans_90 fifth_90 = new Domain.Socioboard.Domain.TopFiveFans_90();
        
            try
            {
                using (NHibernate.ISession session = SessionFactory.GetNewSession())
                {
                    deletefans_90(profileid);
                    mention_retweets_90 = session.Query<Domain.Socioboard.Domain.InboxMessages>().Where(x => x.CreatedTime <= DateTime.Now.AddDays(1).Date.AddSeconds(-1) && x.CreatedTime > (DateTime.Now.AddDays(-90).Date) && x.ProfileId == profileid && (x.MessageType == "twt_mention" || x.MessageType == "twt_retweets")).ToList();
                    
                    dynamic list_90 = mention_retweets_90.GroupBy(n => n.FromId).Select(group => new Domain.Socioboard.Domain.TopFiveFans_90(group.Count(), group.First().FromId, profileid,group.First().FromName)).ToList();
                    topfans_90 = (List<Domain.Socioboard.Domain.TopFiveFans_90>)list_90;
                    first_90 = topfans_90.OrderByDescending(r => r.Count).FirstOrDefault();
                    if (first_90 != null)
                    {

                        int mentions = mention_retweets_90.Where(x => x.FromId == first_90.FromId && x.MessageType == "twt_mention").ToList().Count;
                        int retweets = mention_retweets_90.Where(x => x.FromId == first_90.FromId && x.MessageType == "twt_retweet").ToList().Count;
                        string image_url = mention_retweets_90.Where(a => a.FromId == first_90.FromId).Select(x => x.FromImageUrl).ToList().First().ToString();

                        insertfans_90(first_90, 1, mentions, retweets, image_url);
                       
                    }

                    
                    second_90 = topfans_90.OrderByDescending(r => r.Count).Skip(1).FirstOrDefault();
                    if (second_90 != null)
                    {
                        int mentions = mention_retweets_90.Where(x => x.FromId == second_90.FromId && x.MessageType == "twt_mention").ToList().Count;
                        int retweets = mention_retweets_90.Where(x => x.FromId == second_90.FromId && x.MessageType == "twt_retweet").ToList().Count;
                        string image_url = mention_retweets_90.Where(a => a.FromId == second_90.FromId).Select(x => x.FromImageUrl).ToList().First().ToString();

                        insertfans_90(second_90, 2, mentions, retweets, image_url);
                    }

                    third_90 = topfans_90.OrderByDescending(r => r.Count).Skip(2).FirstOrDefault();
                    if(third_90 != null)
                    {
                        int mentions = mention_retweets_90.Where(x => x.FromId == third_90.FromId && x.MessageType == "twt_mention").ToList().Count;
                        int retweets = mention_retweets_90.Where(x => x.FromId == third_90.FromId && x.MessageType == "twt_retweet").ToList().Count;
                        string image_url = mention_retweets_90.Where(a => a.FromId == third_90.FromId).Select(x => x.FromImageUrl).ToList().First().ToString();

                        insertfans_90(third_90, 3, mentions, retweets, image_url);
                    }

                    fourth_90 = topfans_90.OrderByDescending(r => r.Count).Skip(3).FirstOrDefault();
                    if(fourth_90 != null)
                    {
                        int mentions = mention_retweets_90.Where(x => x.FromId == fourth_90.FromId && x.MessageType == "twt_mention").ToList().Count;
                        int retweets = mention_retweets_90.Where(x => x.FromId == fourth_90.FromId && x.MessageType == "twt_retweet").ToList().Count;
                        string image_url = mention_retweets_90.Where(a => a.FromId == fourth_90.FromId).Select(x => x.FromImageUrl).ToList().First().ToString();

                        insertfans_90(fourth_90, 4, mentions, retweets, image_url);
                    }
                    fifth_90= topfans_90.OrderByDescending(r => r.Count).Skip(4).FirstOrDefault();
                    if(fifth_90 !=null)
                    {
                        int mentions = mention_retweets_90.Where(x => x.FromId == fifth_90.FromId && x.MessageType == "twt_mention").ToList().Count;
                        int retweets = mention_retweets_90.Where(x => x.FromId == fifth_90.FromId && x.MessageType == "twt_retweet").ToList().Count;
                        string image_url = mention_retweets_90.Where(a => a.FromId == fifth_90.FromId).Select(x => x.FromImageUrl).ToList().First().ToString();

                        insertfans_90(fifth_90, 5, mentions, retweets, image_url);
                    }


                    deletefans_60(profileid);
                    mention_retweets_60 = session.Query<Domain.Socioboard.Domain.InboxMessages>().Where(x => x.CreatedTime <= DateTime.Now.AddDays(1).Date.AddSeconds(-1) && x.CreatedTime > (DateTime.Now.AddDays(-90).Date) && x.ProfileId == profileid && (x.MessageType == "twt_mention" || x.MessageType == "twt_retweets")).ToList();
                    dynamic list_60 = mention_retweets_60.GroupBy(n => n.FromId).Select(group => new Domain.Socioboard.Domain.TopFiveFans_60(group.Count(), group.First().FromId, profileid, group.First().FromName)).ToList();
                    topfans_60 = (List<Domain.Socioboard.Domain.TopFiveFans_60>)list_60;


                    first_60 = topfans_60.OrderByDescending(r => r.Count).FirstOrDefault();
                    if (first_60 != null)
                    {
                        int mentions = mention_retweets_60.Where(x => x.FromId == first_60.FromId && x.MessageType == "twt_mention").ToList().Count;
                        int retweets = mention_retweets_60.Where(x => x.FromId == first_60.FromId && x.MessageType == "twt_retweet").ToList().Count;
                        string image_url = mention_retweets_60.Where(a => a.FromId == first_60.FromId).Select(x => x.FromImageUrl).ToList().First().ToString();

                        insertfans_60(first_60, 1, mentions, retweets, image_url);
                    }


                    second_60 = topfans_60.OrderByDescending(r => r.Count).Skip(1).FirstOrDefault();
                    if (second_60 != null)
                    {
                        int mentions = mention_retweets_60.Where(x => x.FromId == second_60.FromId && x.MessageType == "twt_mention").ToList().Count;
                        int retweets = mention_retweets_60.Where(x => x.FromId == second_60.FromId && x.MessageType == "twt_retweet").ToList().Count;
                        string image_url = mention_retweets_60.Where(a => a.FromId == second_60.FromId).Select(x => x.FromImageUrl).ToList().First().ToString();

                        insertfans_60(second_60, 2, mentions, retweets, image_url);
                    }

                    third_60 = topfans_60.OrderByDescending(r => r.Count).Skip(2).FirstOrDefault();
                    if (third_60 != null)
                    {
                        int mentions = mention_retweets_60.Where(x => x.FromId == third_60.FromId && x.MessageType == "twt_mention").ToList().Count;
                        int retweets = mention_retweets_60.Where(x => x.FromId == third_60.FromId && x.MessageType == "twt_retweet").ToList().Count;
                        string image_url = mention_retweets_60.Where(a => a.FromId == third_60.FromId).Select(x => x.FromImageUrl).ToList().First().ToString();

                        insertfans_60(third_60, 3, mentions, retweets, image_url);
                    }

                    fourth_60 = topfans_60.OrderByDescending(r => r.Count).Skip(3).FirstOrDefault();
                    if (fourth_60 != null)
                    {
                        int mentions = mention_retweets_60.Where(x => x.FromId == fourth_60.FromId && x.MessageType == "twt_mention").ToList().Count;
                        int retweets = mention_retweets_60.Where(x => x.FromId == fourth_60.FromId && x.MessageType == "twt_retweet").ToList().Count;
                        string image_url = mention_retweets_60.Where(a => a.FromId == fourth_60.FromId).Select(x => x.FromImageUrl).ToList().First().ToString();

                        insertfans_60(fourth_60, 4, mentions, retweets, image_url);
                    }

                    fifth_60 = topfans_60.OrderByDescending(r => r.Count).Skip(4).FirstOrDefault();
                    if (fifth_60 != null)
                    {
                        int mentions = mention_retweets_60.Where(x => x.FromId == fifth_60.FromId && x.MessageType == "twt_mention").ToList().Count;
                        int retweets = mention_retweets_60.Where(x => x.FromId == fifth_60.FromId && x.MessageType == "twt_retweet").ToList().Count;
                        string image_url = mention_retweets_60.Where(a => a.FromId == fifth_60.FromId).Select(x => x.FromImageUrl).ToList().First().ToString();

                        insertfans_60(fifth_60, 5, mentions, retweets, image_url);
                    }


                    deletefans_30(profileid);
                    mention_retweets_30 = session.Query<Domain.Socioboard.Domain.InboxMessages>().Where(x => x.CreatedTime <= DateTime.Now.AddDays(1).Date.AddSeconds(-1) && x.CreatedTime > (DateTime.Now.AddDays(-90).Date) && x.ProfileId == profileid && (x.MessageType == "twt_mention" || x.MessageType == "twt_retweets")).ToList();
                    dynamic list_30 = mention_retweets_30.GroupBy(n => n.FromId).Select(group => new Domain.Socioboard.Domain.TopFiveFans_30(group.Count(), group.First().FromId, profileid, group.First().FromName)).ToList();
                    topfans_30 = (List<Domain.Socioboard.Domain.TopFiveFans_30>)list_30;


                    first_30 = topfans_30.OrderByDescending(r => r.Count).FirstOrDefault();
                    if (first_30 != null)
                    {
                        int mentions = mention_retweets_30.Where(x => x.FromId == first_30.FromId && x.MessageType == "twt_mention").ToList().Count;
                        int retweets = mention_retweets_30.Where(x => x.FromId == first_30.FromId && x.MessageType == "twt_retweet").ToList().Count;
                        string image_url = mention_retweets_30.Where(a => a.FromId == first_30.FromId).Select(x => x.FromImageUrl).ToList().First().ToString();

                        insertfans_30(first_30, 1, mentions, retweets, image_url);
                    }


                    second_30 = topfans_30.OrderByDescending(r => r.Count).Skip(1).FirstOrDefault();
                    if (second_30 != null)
                    {
                        int mentions = mention_retweets_30.Where(x => x.FromId == second_30.FromId && x.MessageType == "twt_mention").ToList().Count;
                        int retweets = mention_retweets_30.Where(x => x.FromId == second_30.FromId && x.MessageType == "twt_retweet").ToList().Count;
                        string image_url = mention_retweets_30.Where(a => a.FromId == second_30.FromId).Select(x => x.FromImageUrl).ToList().First().ToString();

                        insertfans_30(second_30, 2, mentions, retweets, image_url);
                    }

                    third_30 = topfans_30.OrderByDescending(r => r.Count).Skip(2).FirstOrDefault();
                    if (third_30 != null)
                    {
                        int mentions = mention_retweets_30.Where(x => x.FromId == third_30.FromId && x.MessageType == "twt_mention").ToList().Count;
                        int retweets = mention_retweets_30.Where(x => x.FromId == third_30.FromId && x.MessageType == "twt_retweet").ToList().Count;
                        string image_url = mention_retweets_30.Where(a => a.FromId == third_30.FromId).Select(x => x.FromImageUrl).ToList().First().ToString();

                        insertfans_30(third_30, 3, mentions, retweets, image_url);
                    }

                    fourth_30 = topfans_30.OrderByDescending(r => r.Count).Skip(3).FirstOrDefault();
                    if (fourth_30 != null)
                    {
                        int mentions = mention_retweets_30.Where(x => x.FromId == fourth_30.FromId && x.MessageType == "twt_mention").ToList().Count;
                        int retweets = mention_retweets_30.Where(x => x.FromId == fourth_30.FromId && x.MessageType == "twt_retweet").ToList().Count;
                        string image_url = mention_retweets_30.Where(a => a.FromId == fourth_30.FromId).Select(x => x.FromImageUrl).ToList().First().ToString();

                        insertfans_30(fourth_30, 4, mentions, retweets, image_url);
                    }

                    fifth_30 = topfans_30.OrderByDescending(r => r.Count).Skip(4).FirstOrDefault();
                    if (fifth_30 != null)
                    {
                        int mentions = mention_retweets_30.Where(x => x.FromId == fifth_30.FromId && x.MessageType == "twt_mention").ToList().Count;
                        int retweets = mention_retweets_30.Where(x => x.FromId == fifth_30.FromId && x.MessageType == "twt_retweet").ToList().Count;
                        string image_url = mention_retweets_30.Where(a => a.FromId == fifth_30.FromId).Select(x => x.FromImageUrl).ToList().First().ToString();

                        insertfans_30(fifth_30, 5, mentions, retweets, image_url);
                    }


                    deletefans_15(profileid);
                    mention_retweets_15 = session.Query<Domain.Socioboard.Domain.InboxMessages>().Where(x => x.CreatedTime <= DateTime.Now.AddDays(1).Date.AddSeconds(-1) && x.CreatedTime > (DateTime.Now.AddDays(-90).Date) && x.ProfileId == profileid && (x.MessageType == "twt_mention" || x.MessageType == "twt_retweets")).ToList();
                    dynamic list_15 = mention_retweets_15.GroupBy(n => n.FromId).Select(group => new Domain.Socioboard.Domain.TopFiveFans_15(group.Count(), group.First().FromId, profileid, group.First().FromName)).ToList();
                    topfans_15 = (List<Domain.Socioboard.Domain.TopFiveFans_15>)list_15;


                    first_15 = topfans_15.OrderByDescending(r => r.Count).FirstOrDefault();
                    if (first_15 != null)
                    {
                        int mentions = mention_retweets_15.Where(x => x.FromId == first_15.FromId && x.MessageType == "twt_mention").ToList().Count;
                        int retweets = mention_retweets_15.Where(x => x.FromId == first_15.FromId && x.MessageType == "twt_retweet").ToList().Count;
                        string image_url = mention_retweets_15.Where(a => a.FromId == first_15.FromId).Select(x => x.FromImageUrl).ToList().First().ToString();

                        insertfans_15(first_15, 1, mentions, retweets, image_url);
                    }


                    second_15 = topfans_15.OrderByDescending(r => r.Count).Skip(1).FirstOrDefault();
                    if (second_15 != null)
                    {
                        int mentions = mention_retweets_15.Where(x => x.FromId == second_15.FromId && x.MessageType == "twt_mention").ToList().Count;
                        int retweets = mention_retweets_15.Where(x => x.FromId == second_15.FromId && x.MessageType == "twt_retweet").ToList().Count;
                        string image_url = mention_retweets_15.Where(a => a.FromId == second_15.FromId).Select(x => x.FromImageUrl).ToList().First().ToString();

                        insertfans_15(second_15, 2, mentions, retweets, image_url);
                    }

                    third_15 = topfans_15.OrderByDescending(r => r.Count).Skip(2).FirstOrDefault();
                    if (third_15 != null)
                    {
                        int mentions = mention_retweets_15.Where(x => x.FromId == third_15.FromId && x.MessageType == "twt_mention").ToList().Count;
                        int retweets = mention_retweets_15.Where(x => x.FromId == third_15.FromId && x.MessageType == "twt_retweet").ToList().Count;
                        string image_url = mention_retweets_15.Where(a => a.FromId == third_15.FromId).Select(x => x.FromImageUrl).ToList().First().ToString();

                        insertfans_15(third_15, 3, mentions, retweets, image_url);
                    }

                    fourth_15 = topfans_15.OrderByDescending(r => r.Count).Skip(3).FirstOrDefault();
                    if (fourth_15 != null)
                    {
                        int mentions = mention_retweets_15.Where(x => x.FromId == fourth_15.FromId && x.MessageType == "twt_mention").ToList().Count;
                        int retweets = mention_retweets_15.Where(x => x.FromId == fourth_15.FromId && x.MessageType == "twt_retweet").ToList().Count;
                        string image_url = mention_retweets_15.Where(a => a.FromId == fourth_15.FromId).Select(x => x.FromImageUrl).ToList().First().ToString();

                        insertfans_15(fourth_15, 4, mentions, retweets, image_url);
                    }
                    fifth_15 = topfans_15.OrderByDescending(r => r.Count).Skip(4).FirstOrDefault();
                    if (fifth_15 != null)
                    {
                        int mentions = mention_retweets_15.Where(x => x.FromId == fifth_15.FromId && x.MessageType == "twt_mention").ToList().Count;
                        int retweets = mention_retweets_15.Where(x => x.FromId == fifth_15.FromId && x.MessageType == "twt_retweet").ToList().Count;
                        string image_url = mention_retweets_15.Where(a => a.FromId == fifth_15.FromId).Select(x => x.FromImageUrl).ToList().First().ToString();

                        insertfans_15(fifth_15, 5, mentions, retweets, image_url);
                    }




                }

            }
            catch { 
            }
        }