Example #1
0
        public Domain.Myfashion.Domain.TwitterFeed getTwitterFeed(string id)
        {
            //Creates a database connection and opens up a session
            using (NHibernate.ISession session = SessionFactory.GetNewSession())
            {
                //After Session creation, start Transaction.
                using (NHibernate.ITransaction transaction = session.BeginTransaction())
                {
                    try
                    {
                        //Proceed action, to get feeds of twitter account by profile id.
                        Domain.Myfashion.Domain.TwitterFeed lstmsg = session.CreateQuery("from TwitterFeed where Id = :id")
                                                                     .SetParameter("id", id).UniqueResult <Domain.Myfashion.Domain.TwitterFeed>();


                        //List<TwitterFeed> lstmsg = new List<TwitterFeed>();
                        //foreach (TwitterFeed item in query.Enumerable<TwitterFeed>().OrderByDescending(x => x.FeedDate))
                        //{
                        //    lstmsg.Add(item);
                        //}
                        return(lstmsg);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                        return(null);
                    }
                } //End Transaction
            }     //End Session
        }
Example #2
0
        // Edited by Antima[20/12/2014]

        public Domain.Myfashion.Domain.TwitterFeed getTwitterFeedByProfileId(string ProfileId, string MessageId)
        {
            //Creates a database connection and opens up a session
            using (NHibernate.ISession session = SessionFactory.GetNewSession())
            {
                //After Session creation, start Transaction.
                using (NHibernate.ITransaction transaction = session.BeginTransaction())
                {
                    try
                    {
                        //Proceed action, to get feeds of twitter account by profile id.
                        Domain.Myfashion.Domain.TwitterFeed msg = session.CreateQuery("from TwitterFeed where ProfileId = :ProfileId and MessageId =:MessageId")
                                                                  .SetParameter("ProfileId", ProfileId)
                                                                  .SetParameter("MessageId", MessageId).UniqueResult <Domain.Myfashion.Domain.TwitterFeed>();

                        return(msg);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                        return(null);
                    }
                } //End Transaction
            }     //End Session
        }
Example #3
0
 /// <deleteTwitterFeed>
 /// Delete Twitter Feed
 /// </summary>
 /// <param name="twtfeed">Set Values of twitter profile id and user id in a TwitterFeed Class Property and Pass the Object of TwitterFeed Class.(Domein.TwitterFeed)</param>
 /// <returns>Return 1 for success and 0 for failure.(int) </returns>
 public int deleteTwitterFeed(Domain.Myfashion.Domain.TwitterFeed twtfeed)
 {
     //Creates a database connection and opens up a session
     using (NHibernate.ISession session = SessionFactory.GetNewSession())
     {
         //After Session creation, start Transaction.
         using (NHibernate.ITransaction transaction = session.BeginTransaction())
         {
             try
             {
                 //Proceed action, to delete feeds by profile id and user id.
                 NHibernate.IQuery query = session.CreateQuery("delete from TwitterFeed where ProfileId = :twtuserid and UserId = :userid")
                                           .SetParameter("twtuserid", twtfeed.ProfileId)
                                           .SetParameter("userid", twtfeed.UserId);
                 int isUpdated = query.ExecuteUpdate();
                 transaction.Commit();
                 return(isUpdated);
             }
             catch (Exception ex)
             {
                 Console.WriteLine(ex.StackTrace);
                 return(0);
             }
         } //End Transaction
     }     //End Session
 }
Example #4
0
 /// <addTwitterFeed>
 /// Add Twitter Feed
 /// </summary>
 /// <param name="twtfeed">Set Values in a TwitterFeed Class Property and Pass the Object of TwitterFeed Class.(Domein.TwitterFeed)</param>
 public void addTwitterFeed(Domain.Myfashion.Domain.TwitterFeed twtfeed)
 {
     //Creates a database connection and opens up a session
     using (NHibernate.ISession session = SessionFactory.GetNewSession())
     {
         //After Session creation, start Transaction.
         using (NHibernate.ITransaction transaction = session.BeginTransaction())
         {
             //Proceed action, to save data.
             session.Save(twtfeed);
             transaction.Commit();
         } //End Transaction
     }     //End Session
 }
Example #5
0
        // Edited by Antima[20/12/2014]

        public DataSet bindMyTickets(Guid UserId)
        {
            Messages mstable = new Messages();
            DataSet  ds      = DataTableGenerator.CreateDataSetForTable(mstable);

            Api.SentimentalAnalysis.SentimentalAnalysis            ApiobjSentimentalAnalysis = new Api.SentimentalAnalysis.SentimentalAnalysis();
            List <Domain.Myfashion.Domain.FeedSentimentalAnalysis> lstNegativeFeedsOfUser    = new List <Domain.Myfashion.Domain.FeedSentimentalAnalysis>();

            lstNegativeFeedsOfUser = (List <Domain.Myfashion.Domain.FeedSentimentalAnalysis>)(new JavaScriptSerializer().Deserialize(ApiobjSentimentalAnalysis.getNegativeFeedsOfUser(UserId.ToString()), typeof(List <Domain.Myfashion.Domain.FeedSentimentalAnalysis>)));
            if (lstNegativeFeedsOfUser != null)
            {
                foreach (var item in lstNegativeFeedsOfUser)
                {
                    string Network = item.Network;
                    if (Network == "facebook")
                    {
                        Api.FacebookFeed.FacebookFeed        ApiobjFacebookFeed = new Api.FacebookFeed.FacebookFeed();
                        Domain.Myfashion.Domain.FacebookFeed facebookfeed       = (Domain.Myfashion.Domain.FacebookFeed)(new JavaScriptSerializer().Deserialize(ApiobjFacebookFeed.getFacebookFeedByProfileId(item.ProfileId, item.FeedId), typeof(Domain.Myfashion.Domain.FacebookFeed)));
                        if (facebookfeed != null)
                        {
                            ds.Tables[0].Rows.Add(facebookfeed.ProfileId, "facebook", facebookfeed.FromId, facebookfeed.FromName, facebookfeed.FromProfileUrl, facebookfeed.FeedDate, facebookfeed.FeedDescription, facebookfeed.FbComment, facebookfeed.FbLike, facebookfeed.FeedId, facebookfeed.Type, "");
                        }
                    }
                    if (Network == "twitter")
                    {
                        Api.TwitterFeed.TwitterFeed         ApiobjTwitterFeed = new Api.TwitterFeed.TwitterFeed();
                        Domain.Myfashion.Domain.TwitterFeed twtfeed           = (Domain.Myfashion.Domain.TwitterFeed)(new JavaScriptSerializer().Deserialize(ApiobjTwitterFeed.getTwitterFeedByProfileId(item.ProfileId, item.FeedId), typeof(Domain.Myfashion.Domain.TwitterFeed)));
                        if (twtfeed != null)
                        {
                            ds.Tables[0].Rows.Add(twtfeed.ProfileId, item.Network, twtfeed.FromId, twtfeed.FromScreenName, twtfeed.FromProfileUrl, twtfeed.FeedDate, twtfeed.Feed, "", "", twtfeed.MessageId, twtfeed.Type, "");
                        }
                    }
                }
            }
            return(ds);
        }
        public string GetTicketsofGroup(string GroupId, string UserId)
        {
            string AssignedUser = string.Empty;

            try
            {
                GroupProfileRepository objGroupProfileRepository = new GroupProfileRepository();
                FacebookFeedRepository objFacebookFeedRepository = new FacebookFeedRepository();
                TwitterFeedRepository  objTwitterFeedRepository  = new TwitterFeedRepository();
                List <Domain.Myfashion.Domain.FeedSentimentalAnalysis> lstNegativeFeedsOfUser = new List <Domain.Myfashion.Domain.FeedSentimentalAnalysis>();
                List <Domain.Myfashion.Domain.GroupProfile>            objGroupProfile        = new List <Domain.Myfashion.Domain.GroupProfile>();
                List <FBTwitterFeeds> objListFBTwitterFeeds = new List <FBTwitterFeeds>();

                objGroupProfile = objGroupProfileRepository.getAllGroupProfiles(Guid.Parse(UserId), Guid.Parse(GroupId));

                if (objGroupProfile.Count > 0)
                {
                    lstNegativeFeedsOfUser = _FeedSentimentalAnalysisRepository.getAllNegativeFeedsOfUser(Guid.Parse(UserId));
                }
                else
                {
                    lstNegativeFeedsOfUser = _FeedSentimentalAnalysisRepository.getNegativeFeedsOfUser(Guid.Parse(UserId));
                }
                if (lstNegativeFeedsOfUser != null)
                {
                    foreach (var item in lstNegativeFeedsOfUser)
                    {
                        FBTwitterFeeds objFBTwitterFeeds  = new FBTwitterFeeds();
                        UserRepository objUserRepository  = new UserRepository();
                        Domain.Myfashion.Domain.User user = objUserRepository.getUsersById(item.AssigneUserId);
                        if (objGroupProfileRepository.checkProfileExistsingroup(Guid.Parse(GroupId), item.ProfileId))
                        {
                            string Network = item.Network;
                            if (Network == "facebook")
                            {
                                Domain.Myfashion.Domain.FacebookFeed facebookfeed = objFacebookFeedRepository.getFacebookFeedByProfileId(item.ProfileId, item.FeedId);
                                if (facebookfeed != null)
                                {
                                    objFBTwitterFeeds.FacebookFeed = facebookfeed;
                                }
                            }
                            if (Network == "twitter")
                            {
                                Domain.Myfashion.Domain.TwitterFeed twtfeed = objTwitterFeedRepository.getTwitterFeedByProfileId(item.ProfileId, item.FeedId);
                                if (twtfeed != null)
                                {
                                    objFBTwitterFeeds.TwitterFeed = twtfeed;
                                }
                            }
                            if (objFBTwitterFeeds.TwitterFeed != null)
                            {
                                try
                                {
                                    objFBTwitterFeeds.TicketNo = item.TicketNo;
                                    if (user != null)
                                    {
                                        objFBTwitterFeeds.AssignedUser = user.UserName;
                                    }
                                    else
                                    {
                                        objFBTwitterFeeds.AssignedUser = "";
                                    }
                                    objListFBTwitterFeeds.Add(objFBTwitterFeeds);
                                }
                                catch (Exception ex)
                                {
                                    Console.WriteLine(ex.StackTrace);
                                }
                            }
                            if (objFBTwitterFeeds.FacebookFeed != null)
                            {
                                try
                                {
                                    objFBTwitterFeeds.TicketNo = item.TicketNo;
                                    if (user != null)
                                    {
                                        objFBTwitterFeeds.AssignedUser = user.UserName;
                                    }
                                    else
                                    {
                                        objFBTwitterFeeds.AssignedUser = "";
                                    }
                                    objListFBTwitterFeeds.Add(objFBTwitterFeeds);
                                }
                                catch (Exception ex)
                                {
                                    Console.WriteLine(ex.StackTrace);
                                }
                            }
                        }
                    }
                }

                return(new JavaScriptSerializer().Serialize(objListFBTwitterFeeds));
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
                return("SomethingWentWrong");
            }
        }
Example #7
0
 public int updateTwitterFeed(Domain.Myfashion.Domain.TwitterFeed twtfeed)
 {
     throw new NotImplementedException();
 }
        public void getTwitterFeeds(string UserId, oAuthTwitter OAuth)
        {
            TwitterUser twtuser;
            #region Add Twitter User Feed

            twtuser = new TwitterUser();
            try
            {
                JArray Home_Timeline = twtuser.GetStatuses_Home_Timeline(OAuth);
                objTwitterFeed = new Domain.Myfashion.Domain.TwitterFeed();
                foreach (var item in Home_Timeline)
                {
                    objTwitterFeed.UserId = Guid.Parse(UserId);
                    objTwitterFeed.Type = "twt_feeds";
                    try
                    {
                        objTwitterFeed.Feed = item["text"].ToString().TrimStart('"').TrimEnd('"');
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                    try
                    {
                        objTwitterFeed.SourceUrl = item["source"].ToString().TrimStart('"').TrimEnd('"');
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                    try
                    {
                        objTwitterFeed.ScreenName = objTwitterAccount.TwitterScreenName;
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                    try
                    {
                        objTwitterFeed.ProfileId = objTwitterAccount.TwitterUserId;
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                    try
                    {
                        objTwitterFeed.MessageId = item["id_str"].ToString().TrimStart('"').TrimEnd('"');
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                    try
                    {
                        objTwitterFeed.FeedDate = Utility.ParseTwitterTime(item["created_at"].ToString().TrimStart('"').TrimEnd('"'));
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                    try
                    {
                        objTwitterFeed.InReplyToStatusUserId = item["in_reply_to_status_id_str"].ToString().TrimStart('"').TrimEnd('"');
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                    try
                    {
                        objTwitterFeed.Id = Guid.NewGuid();
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                    try
                    {
                        objTwitterFeed.FromProfileUrl = item["user"]["profile_image_url"].ToString().TrimStart('"').TrimEnd('"');
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                    try
                    {
                        objTwitterFeed.FromName = item["user"]["name"].ToString().TrimStart('"').TrimEnd('"');
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                    try
                    {
                        objTwitterFeed.FromId = item["user"]["id_str"].ToString().TrimStart('"').TrimEnd('"');
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                    objTwitterFeed.EntryDate = DateTime.Now;
                    try
                    {
                        objTwitterFeed.FromScreenName = item["user"]["screen_name"].ToString().TrimStart('"').TrimEnd('"');
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                    if (!objTwitterFeedRepository.checkTwitterFeedExists(objTwitterFeed.MessageId))
                    {
                        try
                        {
                            objTwitterFeedRepository.addTwitterFeed(objTwitterFeed);
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.Message);
                            Console.WriteLine(ex.StackTrace);
                        }
                    }
                    // Edited by Antima[20/12/2014]

                    SentimentalAnalysis _SentimentalAnalysis = new SentimentalAnalysis();
                    FeedSentimentalAnalysisRepository _FeedSentimentalAnalysisRepository = new FeedSentimentalAnalysisRepository();
                    try
                    {
                        if (_FeedSentimentalAnalysisRepository.checkFeedExists(objTwitterFeed.ProfileId.ToString(), Guid.Parse(UserId), objTwitterFeed.Id.ToString()))
                        {
                            if (!string.IsNullOrEmpty(objTwitterFeed.Feed))
                            {
                                string Network = "twitter";
                                //_SentimentalAnalysis.GetPostSentimentsFromUclassify(Guid.Parse(UserId), objTwitterFeed.ProfileId, objTwitterFeed.MessageId, objTwitterFeed.Feed, Network);
                            }
                        }
                    }
                    catch (Exception)
                    {

                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
                logger.Error("twtuser.GetStatuses_Home_Timeline ex.StackTrace >> " + ex.StackTrace);
                logger.Error("twtuser.GetStatuses_Home_Timeline ex.Message >> " + ex.Message);
            }
            #endregion
        }
        public void getUserFeed(oAuthTwitter OAuth, string TwitterScreenName, string TwitterUserId, Guid userId)
        {
            int J = 0;
            try
            {
                //User user = (User)Session["LoggedUser"];
                TwitterUser twtuser = new TwitterUser();
                JArray data = twtuser.GetStatuses_Home_Timeline(OAuth);
                Domain.Myfashion.Domain.TwitterFeed objTwitterFeed;
                TwitterFeedRepository twtmsgrepo = new TwitterFeedRepository();
                //TwitterFeed twtmsg = new TwitterFeed();

                foreach (var item in data)
                {
                    objTwitterFeed = new Domain.Myfashion.Domain.TwitterFeed();
                    objTwitterFeed.UserId = userId;
                    objTwitterFeed.Type = "twt_feeds";
                    try
                    {
                        objTwitterFeed.Feed = item["text"].ToString().TrimStart('"').TrimEnd('"');
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                    try
                    {
                        objTwitterFeed.SourceUrl = item["source"].ToString().TrimStart('"').TrimEnd('"');
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                    try
                    {
                        objTwitterFeed.ScreenName = TwitterScreenName;
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                    try
                    {
                        objTwitterFeed.ProfileId = TwitterUserId;
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                    try
                    {
                        objTwitterFeed.MessageId = item["id_str"].ToString().TrimStart('"').TrimEnd('"');
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                    try
                    {
                        objTwitterFeed.FeedDate = Utility.ParseTwitterTime(item["created_at"].ToString().TrimStart('"').TrimEnd('"'));
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                    try
                    {
                        objTwitterFeed.InReplyToStatusUserId = item["in_reply_to_status_id_str"].ToString().TrimStart('"').TrimEnd('"');
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                    try
                    {
                        objTwitterFeed.Id = Guid.NewGuid();
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                    try
                    {
                        objTwitterFeed.FromProfileUrl = item["user"]["profile_image_url"].ToString().TrimStart('"').TrimEnd('"');
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                    try
                    {
                        objTwitterFeed.FromName = item["user"]["name"].ToString().TrimStart('"').TrimEnd('"');
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                    try
                    {
                        objTwitterFeed.FromId = item["user"]["id_str"].ToString().TrimStart('"').TrimEnd('"');
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                    objTwitterFeed.EntryDate = DateTime.Now;
                    try
                    {
                        objTwitterFeed.FromScreenName = item["user"]["screen_name"].ToString().TrimStart('"').TrimEnd('"');
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }

                    // Edited by Antima[20/12/2014]

                    SentimentalAnalysis _SentimentalAnalysis = new SentimentalAnalysis();
                    FeedSentimentalAnalysisRepository _FeedSentimentalAnalysisRepository = new FeedSentimentalAnalysisRepository();
                    try
                    {
                        if (_FeedSentimentalAnalysisRepository.checkFeedExists(objTwitterFeed.ProfileId.ToString(), userId, objTwitterFeed.Id.ToString()))
                        {
                            if (!string.IsNullOrEmpty(objTwitterFeed.Feed))
                            {
                                string Network = "twitter";
                               // _SentimentalAnalysis.GetPostSentimentsFromUclassify(userId, objTwitterFeed.ProfileId, objTwitterFeed.MessageId, objTwitterFeed.Feed, Network);
                            }
                        }
                    }
                    catch (Exception)
                    {

                    }

                    if (!twtmsgrepo.checkTwitterFeedExists(objTwitterFeed.ProfileId, objTwitterFeed.UserId, objTwitterFeed.MessageId))
                    {
                        J++;
                        twtmsgrepo.addTwitterFeed(objTwitterFeed);
                        logger.Error("getUserFeedCount>>>"+J);
                    }

                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
            }


        }