Beispiel #1
0
 /// <getInsightStatsPostDetails>
 /// Get Details of Insight Stats Post.
 /// </summary>
 /// <param name="PostId">Post id(String)</param>
 /// <returns>FacebookInsightPostStats class object (Domain.FacebookInsightPostStats) </returns>
 public FacebookInsightPostStats getInsightStatsPostDetails(string PostId)
 {
     //Creates a database connection and opens up a session
     using (NHibernate.ISession session = SessionFactory.GetNewSession())
     {
         //Begin trasaction and opens up.
         using (NHibernate.ITransaction transaction = session.BeginTransaction())
         {
             try
             {
                 NHibernate.IQuery query = session.CreateQuery("from FacebookInsightPostStats where PostId = :postId");
                 query.SetParameter("postId", PostId);
                 List <FacebookInsightPostStats> lst = new List <FacebookInsightPostStats>();
                 foreach (FacebookInsightPostStats item in query.Enumerable())
                 {
                     lst.Add(item);
                     break;
                 }
                 FacebookInsightPostStats fbacc = lst[0];
                 return(fbacc);
             }
             catch (Exception ex)
             {
                 Console.WriteLine(ex.StackTrace);
                 return(null);
             }
         } //End Transaction
     }     //End Session
 }
Beispiel #2
0
        public void getFanPost(string pageId, Guid UserId, int days)
        {
            string                    strStories = "https://graph.facebook.com/" + pageId + "/feed";
            FacebookClient            fb         = new FacebookClient();
            FacebookAccountRepository fbAccRepo  = new FacebookAccountRepository();
            FacebookAccount           acc        = fbAccRepo.getUserDetails(pageId);

            fb.AccessToken = acc.AccessToken;
            JsonObject outputreg = (JsonObject)fb.Get(strStories);
            JArray     data      = (JArray)JsonConvert.DeserializeObject(outputreg["data"].ToString());
            FacebookInsightPostStats           objFbiPost     = new FacebookInsightPostStats();
            FacebookInsightPostStatsRepository objfbiPostRepo = new FacebookInsightPostStatsRepository();

            foreach (var item in data)
            {
                try
                {
                    objFbiPost.Id        = Guid.NewGuid();
                    objFbiPost.EntryDate = DateTime.Now;
                    objFbiPost.PageId    = pageId;
                    try
                    {
                        objFbiPost.PostMessage = item["story"].ToString();
                    }
                    catch (Exception Err)
                    {
                        objFbiPost.PostMessage = item["message"].ToString();
                    }
                    objFbiPost.PostDate = item["created_time"].ToString();
                    JArray arrComment = (JArray)item["comment"];
                    if (arrComment != null)
                    {
                        objFbiPost.PostComments = arrComment.Count;
                    }
                    else
                    {
                        objFbiPost.PostComments = 0;
                    }
                    objFbiPost.PostId = item["id"].ToString();
                    objFbiPost.UserId = UserId;
                    if (!objfbiPostRepo.checkFacebookInsightPostStatsExists(pageId, item["id"].ToString(), UserId, item["created_time"].ToString()))
                    {
                        objfbiPostRepo.addFacebookInsightPostStats(objFbiPost);
                    }
                    else
                    {
                        objfbiPostRepo.updateFacebookInsightPostStats(objFbiPost);
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
        }
Beispiel #3
0
 /// <addFacebookInsightPostStats>
 /// Add a new facebook insight post stats
 /// </summary>
 /// <param name="fbinsightstats">Set Values in a FacebookInsightPostStats Class Property and Pass the same Object of FacebookInsightPostStats Class as a parameter (SocioBoard.Domain.FacebookInsightPostStats).</param>
 public void addFacebookInsightPostStats(FacebookInsightPostStats fbinsightstats)
 {
     //Creates a database connection and opens up a session
     using (NHibernate.ISession session = SessionFactory.GetNewSession())
     {
         //Begin session trasaction and opens up.
         using (NHibernate.ITransaction transaction = session.BeginTransaction())
         {
             //Proceed action, to save a new data.
             session.Save(fbinsightstats);
             transaction.Commit();
         } //End Trsaction
     }     //End session
 }
 /// <addFacebookInsightPostStats>
 /// Add a new facebook insight post stats
 /// </summary>
 /// <param name="fbinsightstats">Set Values in a FacebookInsightPostStats Class Property and Pass the same Object of FacebookInsightPostStats Class as a parameter (SocioBoard.Domain.FacebookInsightPostStats).</param>
 public void addFacebookInsightPostStats(FacebookInsightPostStats fbinsightstats)
 {
     //Creates a database connection and opens up a session
     using (NHibernate.ISession session = SessionFactory.GetNewSession())
     {
         //Begin session trasaction and opens up.
         using (NHibernate.ITransaction transaction = session.BeginTransaction())
         {
             //Proceed action, to save a new data.
             session.Save(fbinsightstats);
             transaction.Commit();
         }//End Trsaction
     }//End session
 }
Beispiel #5
0
 public void updateFacebookInsightPostStats(FacebookInsightPostStats fbaccount)
 {
     throw new NotImplementedException();
 }
 public void updateFacebookInsightPostStats(FacebookInsightPostStats fbaccount)
 {
     throw new NotImplementedException();
 }