示例#1
0
        public void getStories(string pageId, Guid UserId, int days)
        {
            try
            {
                string                    strStories = "https://graph.facebook.com/" + pageId + "/insights/post_stories";
                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());
                FacebookInsightStats           objFbi     = new FacebookInsightStats();
                FacebookInsightStatsRepository objfbiRepo = new FacebookInsightStatsRepository();
                foreach (var item in data)
                {
                    var values = item["values"];
                    foreach (var age in values)
                    {
                        objFbi.EntryDate    = DateTime.Now;
                        objFbi.FbUserId     = pageId;
                        objFbi.Id           = Guid.NewGuid();
                        objFbi.StoriesCount = int.Parse(age["value"].ToString());
                        objFbi.UserId       = UserId;
                        objFbi.CountDate    = age["end_time"].ToString();
                        objfbiRepo.addFacebookInsightStats(objFbi);
                    }
                }
            }
            catch (Exception Err)
            {
                Console.Write(Err.StackTrace);
            }
        }
        public void DeleteFacebookUser(string UserId, string FacebookId)
        {
            Guid userid = Guid.Parse(UserId);
            FacebookAccountRepository fbAccRepo = new FacebookAccountRepository();
            int i = fbAccRepo.deleteFacebookUser(FacebookId, userid);

            if (i != 0)
            {
                FacebookFeedRepository fbfeedRepo = new FacebookFeedRepository();
                try
                {
                    fbfeedRepo.deleteAllFeedsOfUser(FacebookId, userid);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);
                }

                FacebookMessageRepository fbmsgRepo = new FacebookMessageRepository();
                try
                {
                    fbmsgRepo.deleteAllMessagesOfUser(FacebookId, userid);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);
                }
            }
        }
示例#3
0
        public void getFanPageLikesByGenderAge(string pageId, Guid UserId, int days)
        {
            try
            {
                string                    strAge    = "https://graph.facebook.com/" + pageId + "/insights/page_fans_gender_age";
                FacebookClient            fb        = new FacebookClient();
                FacebookAccountRepository fbAccRepo = new FacebookAccountRepository();
                FacebookAccount           acc       = fbAccRepo.getUserDetails(pageId);
                fb.AccessToken = acc.AccessToken;
                ///////////////////////////////////////////////////
                // string codedataurlgraphic = objAuthentication.RequestUrl(strAge, strToken);
                //if (txtDateSince.Text != "")
                //    strAge = strAge + "&since=" + txtDateSince.Text;
                //if (txtDateUntill.Text != "")
                //    strAge = strAge + "&until=" + txtDateUntill.Text;

                JsonObject                     outputreg  = (JsonObject)fb.Get(strAge);
                JArray                         data       = (JArray)JsonConvert.DeserializeObject(outputreg["data"].ToString());
                FacebookInsightStats           objFbi     = new FacebookInsightStats();
                FacebookInsightStatsRepository objfbiRepo = new FacebookInsightStatsRepository();
                foreach (var item in data)
                {
                    var values = item["values"];
                    foreach (var age in values)
                    {
                        var ageVal      = age["value"];
                        var agevalarray = ageVal.ToString().Substring(1, ageVal.ToString().Length - 2).Split(',');
                        for (int i = 0; i < agevalarray.Count(); i++)
                        {
                            var genderagearray = agevalarray[i].Split(':');
                            var gender         = genderagearray[0].Split('.');
                            objFbi.AgeDiff     = gender[1].Trim();
                            objFbi.Gender      = gender[0].Trim();
                            objFbi.EntryDate   = DateTime.Now;
                            objFbi.FbUserId    = pageId;
                            objFbi.Id          = Guid.NewGuid();
                            objFbi.PeopleCount = int.Parse(genderagearray[1]);
                            objFbi.UserId      = UserId;
                            objFbi.CountDate   = age["end_time"].ToString();
                            if (!objfbiRepo.checkFacebookInsightStatsExists(pageId, UserId, age["end_time"].ToString(), gender[1].Trim()))
                            {
                                objfbiRepo.addFacebookInsightStats(objFbi);
                            }
                            else
                            {
                                objfbiRepo.updateFacebookInsightStats(objFbi);
                            }
                        }
                        // strFbAgeArray=strFbAgeArray+
                    }
                }
            }
            catch (Exception Err)
            {
                Console.Write(Err.StackTrace);
            }
        }
        public IHttpActionResult FacebookPostsCommentsService()
        {
            Facebook.FacebookClient   fb        = new Facebook.FacebookClient();
            UserRepository            userRepo  = new UserRepository();
            FacebookAccountRepository fbAccRepo = new FacebookAccountRepository();

            Api.Socioboard.Services.Facebook     fbService = new Api.Socioboard.Services.Facebook();
            List <Domain.Socioboard.Domain.User> lstUser   = new List <Domain.Socioboard.Domain.User>();

            lstUser = userRepo.getAllUsers();
            foreach (var user in lstUser)
            {
                List <Domain.Socioboard.Domain.FacebookAccount> lstFacebookAccount = fbAccRepo.GetAllFacebookAccountByUserId(user.Id);

                foreach (var fbAcc in lstFacebookAccount)
                {
                    if (!string.IsNullOrEmpty(fbAcc.AccessToken))
                    {
                        fb.AccessToken = fbAcc.AccessToken;
                        MongoRepository boardrepo = new MongoRepository("MongoFacebookFeed");
                        try
                        {
                            var result = boardrepo.Find <MongoFacebookFeed>(x => x.ProfileId.Equals(fbAcc.FbUserId) && x.UserId.Equals(user.Id.ToString())).ConfigureAwait(false);

                            var task = Task.Run(async() =>
                            {
                                return(await result);
                            });
                            IList <MongoFacebookFeed> objfbfeeds = task.Result;
                            if (objfbfeeds.Count() == 0)
                            {
                                result = boardrepo.Find <MongoFacebookFeed>(x => x.ProfileId.Equals(fbAcc.FbUserId)).ConfigureAwait(false);

                                task = Task.Run(async() =>
                                {
                                    return(await result);
                                });
                            }
                            List <MongoFacebookFeed> fbfeeds = objfbfeeds.ToList();
                            foreach (var post in fbfeeds)
                            {
                                fbService.AddFbPostComments(post.FeedId, fb, user.Id.ToString());
                            }
                        }
                        catch (Exception ex)
                        {
                            logger.Error(ex.Message);
                            logger.Error(ex.StackTrace);
                            return(BadRequest("Something Went Wrong"));
                        }
                    }
                }
            }


            return(Ok());
        }
示例#5
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);
                }
            }
        }
 public string UserInformation(string UserId, string FacebookId)
 {
     try
     {
         Guid userid = Guid.Parse(UserId);
         FacebookAccountRepository facebookAccountRepo = new FacebookAccountRepository();
         FacebookAccount           facebook            = facebookAccountRepo.getFacebookAccountDetailsById(FacebookId, userid);
         return(new JavaScriptSerializer().Serialize(facebook));
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.StackTrace);
         return(new JavaScriptSerializer().Serialize("Please try Again"));
     }
 }
 public string getfacebookActiveAceessTokenFromDb()
 {
     FacebookAccountRepository fbAccRepo = new FacebookAccountRepository();
     ArrayList asltFbAccount = fbAccRepo.getAllFacebookAccounts();
     string accesstoken = string.Empty;
     foreach (Domain.Myfashion.Domain.FacebookAccount item in asltFbAccount)
     {
         accesstoken = item.AccessToken;
         if (this.CheckFacebookToken(accesstoken, "globussoft"))
         {
             break;
         }
     }
     return accesstoken;
 }
        public int UpdateFbToken(string fbUserId, string fbAccessToken)
        {
            int res = 0;

            try
            {
                FacebookAccountRepository objfbAR = new FacebookAccountRepository();

                res = objfbAR.UpdateFBAccessTokenByFBUserId(fbUserId, fbAccessToken);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error : " + ex.StackTrace);
            }
            return(res);
        }
示例#9
0
 public void getLocation(string pageId, Guid UserId, int days)
 {
     try
     {
         string                    strStories = "https://graph.facebook.com/" + pageId + "/insights/page_fans_country";
         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());
         FacebookInsightStats           objFbi     = new FacebookInsightStats();
         FacebookInsightStatsRepository objfbiRepo = new FacebookInsightStatsRepository();
         foreach (var item in data)
         {
             var values = item["values"];
             foreach (var loc in values)
             {
                 var locVal      = loc["value"];
                 var locvalarray = locVal.ToString().Substring(1, locVal.ToString().Length - 2).Split(',');
                 for (int i = 0; i < locvalarray.Count(); i++)
                 {
                     var locationarr = locvalarray[i].Split(':');
                     objFbi.EntryDate   = DateTime.Now;
                     objFbi.FbUserId    = pageId;
                     objFbi.Id          = Guid.NewGuid();
                     objFbi.Location    = locationarr[0].ToString();
                     objFbi.PeopleCount = int.Parse(locationarr[1].ToString());
                     objFbi.UserId      = UserId;
                     objFbi.CountDate   = loc["end_time"].ToString();
                     if (!objfbiRepo.checkFbILocationStatsExists(pageId, UserId, loc["end_time"].ToString(), locationarr[0].ToString()))
                     {
                         objfbiRepo.addFacebookInsightStats(objFbi);
                     }
                     else
                     {
                         objfbiRepo.updateFacebookInsightStats(objFbi);
                     }
                 }
             }
         }
     }
     catch (Exception Err)
     {
         Console.Write(Err.StackTrace);
     }
 }
 public void FacebookUserHomeAPI(string UserId, string FacebookId)
 {
     try
     {
         Guid                      userid    = Guid.Parse(UserId);
         FacebookHelper            fbhelper  = new FacebookHelper();
         FacebookAccountRepository fbAccRepo = new FacebookAccountRepository();
         FacebookAccount           fbAccount = fbAccRepo.getFacebookAccountDetailsById(FacebookId, userid);
         Facebook.FacebookClient   fb        = new Facebook.FacebookClient(fbAccount.AccessToken);
         var     home    = fb.Get("/me/home");
         dynamic profile = fb.Get("me");
         fbhelper.getFacebookUserHome(home, profile);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.StackTrace);
     }
 }
示例#11
0
        protected void fbProfileDetails(string fbid)
        {
            FacebookAccountRepository objtwtAccRepo = new FacebookAccountRepository();
            FacebookAccount           arrFbAcc      = objtwtAccRepo.getUserDetails(fbid);

            divPageName.InnerHtml = arrFbAcc.FbUserName;
            //string src = "http://graph.facebook.com/" + arrFbAcc.FbUserId + "/picture";
            string fbpgid = arrFbAcc.FbUserId;

            fbProfileImg.Src = "http://graph.facebook.com/" + fbpgid + "/picture";
            //fbProfileImg.Src = src;
            fbpageaccesstkn = arrFbAcc.AccessToken;
            FacebookClient fb = new FacebookClient();

            fb.AccessToken = fbpageaccesstkn;
            dynamic pagelikes = fb.Get(fbid);

            divPageLikes.InnerHtml = pagelikes.likes.ToString() + " Total Likes " + pagelikes.talking_about_count + " People talking about this.";
            spanTalking.InnerHtml  = pagelikes.talking_about_count.ToString();
        }
示例#12
0
        public IHttpActionResult GetGroupFacebookProfiles(string GroupId, string UserId)
        {
            Guid grpId = Guid.Empty;

            try
            {
                grpId = Guid.Parse(GroupId);
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message);
                logger.Error(ex.StackTrace);
                return(BadRequest("Invalid GroupId"));
            }
            List <Domain.Socioboard.Domain.GroupProfile>    lstGroupProfiles = grpProfilesRepo.GetAllGroupProfilesByProfileType(grpId, "facebook");
            List <Domain.Socioboard.Domain.FacebookAccount> lstFbAccounts    = new List <Domain.Socioboard.Domain.FacebookAccount>();
            FacebookAccountRepository objFacebookAccountRepository           = new FacebookAccountRepository();

            foreach (var profile in lstGroupProfiles)
            {
                try
                {
                    //if (objFacebookAccountRepository.checkFacebookUserExists(profile.ProfileId, Guid.Parse(UserId)))
                    //{
                    //    lstFbAccounts.Add(objFacebookAccountRepository.getFacebookAccountDetailsById(profile.ProfileId, Guid.Parse(UserId)));
                    //}
                    //else
                    //{
                    lstFbAccounts.Add(objFacebookAccountRepository.getFacebookAccountDetailsById(profile.ProfileId));
                    //}
                }
                catch (Exception ex)
                {
                    logger.Error(ex.Message);
                    logger.Error(ex.StackTrace);
                }
            }
            return(Ok(lstFbAccounts));
        }
示例#13
0
        public void getNewFriends(int days)
        {
            try
            {
                SocioBoard.Domain.User  user           = (User)Session["LoggedUser"];
                FacebookStatsRepository objfbStatsRepo = new FacebookStatsRepository();
                ArrayList arrFbStats = objfbStatsRepo.getAllFacebookStatsOfUser(user.Id, days);
                strFBArray = "[";
                int intdays = 1;

                // Get facebook page like ...
                FacebookAccountRepository ObjAcFbAccount = new FacebookAccountRepository();
                int TotalLikes = ObjAcFbAccount.getPagelikebyUserId(user.Id);

                foreach (var item in arrFbStats)
                {
                    Array temp = (Array)item;
                    strFBArray += int.Parse(temp.GetValue(3).ToString()) + int.Parse(temp.GetValue(4).ToString()) + ",";
                    //spanFbFriends.InnerHtml = (int.Parse(temp.GetValue(3).ToString()) + int.Parse(temp.GetValue(4).ToString())).ToString();
                    spanFbFriends.InnerHtml = (TotalLikes).ToString();
                    intdays++;
                }
                if (intdays < 7)
                {
                    for (int j = 0; j < 7 - intdays; j++)
                    {
                        strFBArray = strFBArray + "0,";
                    }
                }
                strFBArray = strFBArray.Substring(0, strFBArray.Length - 1) + "]";
                // strFBArray += "]";
            }
            catch (Exception Err)
            {
                Response.Write(Err.Message.ToString());
            }
        }
示例#14
0
        public IHttpActionResult GetGroupFacebookPage(string GroupId, string UserId)
        {
            Guid grpId = Guid.Empty;

            try
            {
                grpId = Guid.Parse(GroupId);
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message);
                logger.Error(ex.StackTrace);
                return(BadRequest("Invalid GroupId"));
            }
            List <Domain.Socioboard.Domain.GroupProfile>    lstGroupProfiles   = grpProfilesRepo.GetAllGroupProfilesByProfileType(grpId, "facebook_page");
            List <Domain.Socioboard.Domain.FacebookAccount> lstFacebookAccount = new List <Domain.Socioboard.Domain.FacebookAccount>();
            FacebookAccountRepository _FacebookAccountRepository = new FacebookAccountRepository();

            foreach (var profile in lstGroupProfiles)
            {
                try
                {
                    Domain.Socioboard.Domain.FacebookAccount _FacebookAccount = _FacebookAccountRepository.getFacebookAccountDetailsById(profile.ProfileId, Guid.Parse(UserId));
                    if (_FacebookAccount.Type.ToLower() == "page" && !string.IsNullOrEmpty(_FacebookAccount.AccessToken))
                    {
                        lstFacebookAccount.Add(_FacebookAccount);
                    }
                }
                catch (Exception ex)
                {
                    logger.Error(ex.Message);
                    logger.Error(ex.StackTrace);
                }
            }
            return(Ok(lstFacebookAccount));
        }
示例#15
0
        protected void Page_Load(object sender, EventArgs e)
        {
            User user = (User)Session["LoggedUser"];

            try
            {
                #region for You can use only 30 days as Unpaid User

                //SocioBoard.Domain.User user = (User)Session["LoggedUser"];
                if (user.PaymentStatus.ToLower() == "unpaid")
                {
                    if (!SBUtils.IsUserWorkingDaysValid(user.ExpiryDate))
                    {
                        // ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('You can use only 30 days as Unpaid User !');", true);

                        Session["GreaterThan30Days"] = "GreaterThan30Days";

                        Response.Redirect("../Settings/Billing.aspx");
                    }
                }
                #endregion
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error : " + ex.StackTrace);
            }

            if (!IsPostBack)
            {
                if (user == null)
                {
                    Response.Redirect("/Default.aspx");
                }
                try
                {
                    getgrphData(7);
                }
                catch (Exception Err)
                {
                    Console.Write(Err.StackTrace);
                }

                try
                {
                    getNewFriends(7);
                }
                catch (Exception Err)
                {
                    Console.Write(Err.StackTrace);
                }
                try
                {
                    getNewFollowers(7);
                }
                catch (Exception Err)
                {
                    Console.Write(Err.StackTrace);
                }
                try
                {
                    GetFollowersAgeWise(7);
                }
                catch (Exception Err)
                {
                    Console.Write(Err.StackTrace);
                }
                try
                {
                    getFollowFollowersMonth();
                }
                catch (Exception Err)
                {
                    Console.Write(Err.StackTrace);
                }
                try
                {
                    FacebookAccountRepository fbAccRepo  = new FacebookAccountRepository();
                    FacebookFeedRepository    fbFeedRepo = new FacebookFeedRepository();
                    ArrayList arrfbProfile = fbAccRepo.getAllFacebookPagesOfUser(user.Id);
                    long      talking      = 0;
                    foreach (FacebookAccount item in arrfbProfile)
                    {
                        FacebookClient fb = new FacebookClient();
                        fb.AccessToken = item.AccessToken;
                        pagelikes      = pagelikes + fbFeedRepo.countInteractions(item.UserId, item.FbUserId, 7);
                        dynamic talkingabout = fb.Get(item.FbUserId);
                        talking = talking + talkingabout.talking_about_count;
                        // strinteractions = pagelikes.Count(); //(long.Parse(strinteractions) + pagelikes.talking_about_count).ToString();
                    }
                    talkingabtcount = (talking / 100) * arrfbProfile.Count;
                }
                catch (Exception Err)
                {
                    Console.Write(Err.StackTrace);
                }
                try
                {
                    SocialProfilesRepository objsocioRepo = new SocialProfilesRepository();
                    profileCount = objsocioRepo.getAllSocialProfilesOfUser(user.Id).Count();
                }
                catch (Exception Err)
                {
                    Console.Write(Err.StackTrace);
                }

                var strgenderTwt = Session["twtGender"].ToString().Split(',');
                divtwtMale.InnerHtml   = strgenderTwt[0] + "%";
                divtwtfeMale.InnerHtml = strgenderTwt[1] + "%";
            }
        }
示例#16
0
        public void getgrphData(int days)
        {
            try
            {
                SocioBoard.Domain.User    user           = (User)Session["LoggedUser"];
                FacebookAccountRepository objfb          = new FacebookAccountRepository();
                TwitterMessageRepository  objtwttatsRepo = new TwitterMessageRepository();
                ArrayList alstfb  = objfb.getFbMessageStats(user.Id, days);
                ArrayList alstTwt = objtwttatsRepo.gettwtMessageStats(user.Id, days);
                strArray = "[";
                int _spanIncoming = 0;
                for (int i = 0; i < 7; i++)
                {
                    string strTwtCnt = string.Empty;
                    string strFbCnt  = string.Empty;
                    if (alstTwt.Count <= i)
                    {
                        strTwtCnt = "0";
                    }
                    else
                    {
                        strTwtCnt = alstTwt[i].ToString();
                    }
                    if (alstfb.Count <= i)
                    {
                        strFbCnt = "0";
                    }
                    else
                    {
                        strFbCnt = alstfb[i].ToString();
                    }
                    strArray = strArray + "[" + strFbCnt + "," + strTwtCnt + "],";
                    //spanIncoming.InnerHtml = (int.Parse(strTwtCnt) + int.Parse(strFbCnt)).ToString();
                    _spanIncoming = (int.Parse(strTwtCnt) + int.Parse(strFbCnt));
                }
                spanIncoming.InnerHtml = _spanIncoming.ToString();
                strArray = strArray.Substring(0, strArray.Length - 1) + "]";

                ArrayList alstTwtFeed = objtwttatsRepo.gettwtFeedsStats(user.Id, days);
                ArrayList alstFBFeed  = objfb.getFbFeedsStats(user.Id, days);
                strSentArray = "[";
                int _spanSent = 0;
                if (alstFBFeed.Count > 0 && alstTwtFeed.Count > 0)
                {
                    int alstSentCount = 0;
                    for (int i = 0; i < 7; i++)
                    {
                        string strTwtFeedCnt = string.Empty;
                        string strFbFeedCnt  = string.Empty;
                        if (alstTwtFeed.Count <= i)
                        {
                            strTwtFeedCnt = "0";
                        }
                        else
                        {
                            strTwtFeedCnt = alstTwtFeed[i].ToString();
                        }
                        if (alstFBFeed.Count <= i)
                        {
                            strFbFeedCnt = "0";
                        }
                        else
                        {
                            strFbFeedCnt = alstFBFeed[i].ToString();
                        }
                        strSentArray = strSentArray + "[" + strFbFeedCnt + "," + strTwtFeedCnt + "],";
                        //spanSent.InnerHtml = (int.Parse(strFbFeedCnt) + int.Parse(strTwtFeedCnt)).ToString();
                        _spanSent = (int.Parse(strFbFeedCnt) + int.Parse(strTwtFeedCnt));
                    }
                    spanSent.InnerHtml = (_spanSent).ToString();
                }
                if (alstFBFeed.Count == 0 || alstTwtFeed.Count == 0)
                {
                    for (int i = 0; i < 7; i++)
                    {
                        strSentArray += strSentArray + "[0,0],";
                    }
                }

                strSentArray = strSentArray.Substring(0, strSentArray.Length - 1) + "]";

                TwitterStatsRepository objtwtStatsRepo = new TwitterStatsRepository();
                ArrayList alstEng = objtwtStatsRepo.getAllTwitterStatsOfUser(user.Id, days);
                int       ii      = 1;
                strEng = "[";
                foreach (var item in alstEng)
                {
                    Array temp = (Array)item;
                    strEng = strEng + "{ x: new Date(2012, " + ii + ", " + ii + "), y:" + temp.GetValue(7) + "},";
                    ii++;
                }
                if (alstEng.Count == 0)
                {
                    for (int i = 0; i < 10; i++)
                    {
                        strEng = strEng + "{ x: new Date(2012, " + ii + ", " + ii + "), y:0},";
                    }
                }
                strEng = strEng.Substring(0, strEng.Length - 1) + "]";

                hmsgsent.InnerHtml = alstTwtFeed.Count.ToString();
                hretweet.InnerHtml = objtwttatsRepo.getUserRetweetCount(user.Id).ToString();
            }
            catch (Exception Err)
            {
                Response.Write(Err.StackTrace);
            }
        }
        public void ProfilesAvailabeforuser(Guid UserId)
        {
            string bindprofiles = string.Empty;

            SocialProfilesRepository socioprofilerepo = new SocialProfilesRepository();
            List <SocialProfile>     lstsocialprofile = socioprofilerepo.getAllSocialProfilesOfUser(UserId);

            foreach (SocialProfile item in lstsocialprofile)
            {
                if (item.ProfileType == "facebook")
                {
                    if (!SelectedGroupProfiles.InnerHtml.Contains("facebook_" + item.ProfileId))
                    {
                        FacebookAccountRepository fbaccreop       = new FacebookAccountRepository();
                        FacebookAccount           facebookaccount = fbaccreop.getFacebookAccountDetailsById(item.ProfileId, UserId);

                        bindprofiles +=
                            "<div onclick=\"transfertoGroup('facebook','" + item.ProfileId + "')\" id=\"usergroups_" + item.ProfileId + "\" class=\"ws_conct active\"> <span class=\"img\"><img width=\"48\" height=\"48\" src=\"http://graph.facebook.com/" + item.ProfileId + "/picture?type=small\" alt=\"\"><i><img width=\"16\" height=\"16\" src=\"../Contents/img/fb_icon.png\" alt=\"\"></i></span><div class=\"fourfifth\">" +
                            "<div class=\"location-container\">" + facebookaccount.FbUserName + "</div><span class=\"add remove\">✖</span></div></div>";
                    }
                }
                else if (item.ProfileType == "twitter")
                {
                    if (!SelectedGroupProfiles.InnerHtml.Contains("twitter_" + item.ProfileId))
                    {
                        string profileimgurl = string.Empty;
                        TwitterAccountRepository twtaccountrepo = new TwitterAccountRepository();
                        TwitterAccount           twtacco        = twtaccountrepo.getUserInformation(UserId, item.ProfileId);
                        if (twtacco.ProfileImageUrl == string.Empty)
                        {
                            profileimgurl = "../../Contents/img/blank_img.png";
                        }
                        else
                        {
                            profileimgurl = twtacco.ProfileImageUrl;
                        }
                        bindprofiles +=
                            "<div onclick=\"transfertoGroup('twitter','" + item.ProfileId + "')\" id=\"usergroups_" + item.ProfileId + "\" class=\"ws_conct active\"> <span class=\"img\"><img width=\"48\" height=\"48\" src=\"" + profileimgurl + "\" alt=\"\"><i><img width=\"16\" height=\"16\" src=\"../Contents/img/twticon.png\" alt=\"\"></i></span><div class=\"fourfifth\">" +
                            "<div class=\"location-container\">" + twtacco.TwitterScreenName + "</div><span class=\"add remove\">✖</span></div></div>";
                    }
                }
                else if (item.ProfileType == "linkedin")
                {
                    if (!SelectedGroupProfiles.InnerHtml.Contains("linkedin_" + item.ProfileId))
                    {
                        LinkedInAccountRepository linkedaccrepo = new LinkedInAccountRepository();
                        LinkedInAccount           linkedaccount = linkedaccrepo.getUserInformation(UserId, item.ProfileId);
                        string profileimgurl = string.Empty;
                        if (linkedaccount.ProfileUrl == string.Empty)
                        {
                            profileimgurl = "../../Contents/img/blank_img.png";
                        }
                        else
                        {
                            profileimgurl = linkedaccount.ProfileImageUrl;
                        }
                        bindprofiles += "<div onclick=\"transfertoGroup('linkedin','" + item.ProfileId + "')\" id=\"usergroups_" + item.ProfileId + "\" class=\"ws_conct active\"><span class=\"img\"><img width=\"48\" height=\"48\" alt=\"\" src=\"" + profileimgurl + "\" ><i>" +
                                        "<img width=\"16\" height=\"16\" alt=\"\" src=\"../Contents/img/link_icon.png\"></i></span>" +
                                        "<div class=\"fourfifth\"><div class=\"location-container\">" + linkedaccount.LinkedinUserName + "</div>" +
                                        "<span class=\"add remove\">✖</span></div></div>";
                    }
                }
                else if (item.ProfileType == "instagram")
                {
                    if (!SelectedGroupProfiles.InnerHtml.Contains("instagram_" + item.ProfileId))
                    {
                        string profileimgurl = string.Empty;
                        InstagramAccountRepository instagramrepo = new InstagramAccountRepository();
                        InstagramAccount           instaaccount  = instagramrepo.getInstagramAccountDetailsById(item.ProfileId, UserId);
                        if (instaaccount.ProfileUrl == string.Empty)
                        {
                            profileimgurl = "../../Contents/img/blank_img.png";
                        }
                        else
                        {
                            profileimgurl = instaaccount.ProfileUrl;
                        }

                        bindprofiles += "<div onclick=\"transfertoGroup('instagram','" + item.ProfileId + "')\" id=\"usergroups_" + item.ProfileId + "\" class=\"ws_conct active\"><span class=\"img\"><img width=\"48\" height=\"48\" src=\"" + profileimgurl + "\" alt=\"\"><i>" +
                                        "<img width=\"16\" height=\"16\" alt=\"\" src=\"../Contents/img/instagram_24X24.png\"></i></span><div class=\"fourfifth\"><div class=\"location-container\">" + instaaccount.InsUserName + "</div>" +
                                        "<span class=\"add remove\">✖</span></div></div>";
                    }
                }
                else if (item.ProfileType == "tumblr")
                {
                    if (!SelectedGroupProfiles.InnerHtml.Contains("tumblr_" + item.ProfileId))
                    {
                        string profileimgurl = string.Empty;
                        TumblrAccountRepository tumblrrepo    = new TumblrAccountRepository();
                        TumblrAccount           tumblraccount = tumblrrepo.getTumblrAccountDetailsById(item.ProfileId, UserId);
                        if (tumblraccount.tblrProfilePicUrl == string.Empty)
                        {
                            profileimgurl = "../../Contents/img/blank_img.png";
                        }
                        else
                        {
                            profileimgurl = "http://api.tumblr.com/v2/blog/" + tumblraccount.tblrUserName + ".tumblr.com/avatar";
                        }

                        bindprofiles += "<div onclick=\"transfertoGroup('tumblr','" + item.ProfileId + "')\" id=\"usergroups_" + item.ProfileId + "\" class=\"ws_conct active\"><span class=\"img\"><img width=\"48\" height=\"48\" src=\"http://api.tumblr.com/v2/blog/" + tumblraccount.tblrUserName + ".tumblr.com/avatar\" alt=\"\"><i>" +
                                        "<img width=\"16\" height=\"16\" alt=\"\" src=\"../Contents/img/tumblr.png\"></i></span><div class=\"fourfifth\"><div class=\"location-container\">" + tumblraccount.tblrUserName + "</div>" +
                                        "<span class=\"add remove\">✖</span></div></div>";
                    }
                }
            }
            AllGroupProfiles.InnerHtml = bindprofiles;
        }
示例#18
0
        public string SheduleFacebookMessage(string FacebookId, string UserId, string sscheduledmsgguid)
        {
            string str = string.Empty;
            try
            {
                objScheduledMessage = objScheduledMessageRepository.GetScheduledMessageDetails(Guid.Parse(sscheduledmsgguid));

                if (objFacebookAccountRepository.checkFacebookUserExists(FacebookId, Guid.Parse(UserId)))
                {
                    objFacebookAccount = objFacebookAccountRepository.getFacebookAccountDetailsById(FacebookId, Guid.Parse(UserId));
                }
                else
                {
                    objFacebookAccount = objFacebookAccountRepository.getFacebookAccountDetailsById(FacebookId);
                }
                if (objFacebookAccount != null)
                {
                    FacebookClient fbclient = new FacebookClient(objFacebookAccount.AccessToken);
                    var args = new Dictionary<string, object>();
                    args["message"] = objScheduledMessage.ShareMessage;
                    string imagepath = objScheduledMessage.PicUrl;

                    var facebookpost = "";
                    try
                    {


                        if (!string.IsNullOrEmpty(imagepath))
                        {
                            try
                            {
                                Uri u = new Uri(imagepath);
                                string filename = string.Empty;
                                string extension = string.Empty;
                                extension = Path.GetExtension(u.AbsolutePath).Replace(".", "");
                                var media = new FacebookMediaObject
                                {
                                    FileName = "filename",
                                    ContentType = "image/" + extension
                                };
                                //byte[] img = System.IO.File.ReadAllBytes(imagepath);
                                var webClient = new WebClient();
                                byte[] img = webClient.DownloadData(imagepath);
                                media.SetValue(img);
                                args["source"] = media;
                                facebookpost = fbclient.Post("v2.0/" + objFacebookAccount.FbUserId + "/photos", args).ToString();
                            }
                            catch (Exception ex)
                            {
                                Console.WriteLine(imagepath + "not Found");
                                if (!string.IsNullOrEmpty(objScheduledMessage.Url))
                                {
                                    args["link"] = objScheduledMessage.Url;
                                }
                                facebookpost = fbclient.Post("v2.0/" + objFacebookAccount.FbUserId + "/feed", args).ToString();
                            }
                        }
                        else
                        {
                            facebookpost = fbclient.Post("v2.0/" + objFacebookAccount.FbUserId + "/feed", args).ToString();
                        }
                    }

                    catch (Exception ex)
                    {
                        //FacebookAccount ObjFacebookAccount = new FacebookAccount();
                        //objFacebookAccount = new Domain.Socioboard.Domain.FacebookAccount();
                        objFacebookAccountRepository = new FacebookAccountRepository();
                        //objFacebookAccount.IsActive = 2;
                        objFacebookAccountRepository.updateFacebookUserStatus(objFacebookAccount);
                        Domain.Socioboard.Domain.SocialProfile objSocialProfile = new Domain.Socioboard.Domain.SocialProfile();
                        SocialProfilesRepository objSocialProfilesRepository = new SocialProfilesRepository();
                        //logger.Error(ex.Message);
                        string errormsg = ex.Message;
                        if (errormsg.Contains("access token"))
                        {
                            objSocialProfile.UserId = objFacebookAccount.UserId;
                            objSocialProfile.ProfileId = objFacebookAccount.FbUserId;
                            objSocialProfile.ProfileStatus = 2;
                            objSocialProfilesRepository.updateSocialProfileStatus(objSocialProfile);
                        }
                        Console.WriteLine(ex.Message);
                        str = ex.Message;
                    }

                    if (!string.IsNullOrEmpty(facebookpost))
                    {
                        str = "Message post on facebook for Id :" + objFacebookAccount.FbUserId + " and Message: " + objScheduledMessage.ShareMessage;
                        ScheduledMessage schmsg = new ScheduledMessage();
                        schmsg.UpdateScheduledMessageByMsgId(Guid.Parse(sscheduledmsgguid));
                    }
                }
                else
                {
                    str = "facebook account not found for id" + objScheduledMessage.ProfileId;
                }
            }
            catch (Exception ex)
            {
                str = ex.Message;
            }
            return str;
        }
示例#19
0
        public string ProfilesConnected(string UserId, string access_token)
        {
            //if (!User.Identity.IsAuthenticated)
            //{
            //    return "Unauthorized access";
            //}
            try
            {

                Guid userid = Guid.Parse(UserId);
                SocialProfilesRepository socialRepo = new SocialProfilesRepository();
                List<Domain.Socioboard.Domain.SocialProfile> lstsocioprofile = socialRepo.getAllSocialProfilesOfUser(userid);
                List<profileConnected> lstProfile = new List<profileConnected>();
                foreach (Domain.Socioboard.Domain.SocialProfile sp in lstsocioprofile)
                {
                    profileConnected pc = new profileConnected();
                    pc.Id = sp.Id;
                    pc.ProfileDate = sp.ProfileDate;
                    pc.ProfileId = sp.ProfileId;
                    pc.ProfileStatus = sp.ProfileStatus;
                    pc.ProfileType = sp.ProfileType;
                    pc.UserId = sp.UserId;
                    if (sp.ProfileType == "facebook")
                    {
                        try
                        {
                            FacebookAccountRepository objFbAccRepo = new FacebookAccountRepository();
                            Domain.Socioboard.Domain.FacebookAccount objFbAcc = objFbAccRepo.getUserDetails(sp.ProfileId);
                            pc.ProfileName = objFbAcc.FbUserName;
                            pc.ProfileImgUrl = "http://graph.facebook.com/" + sp.ProfileId + "/picture?type=small";
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }
                    }
                    else if (sp.ProfileType == "twitter")
                    {
                        try
                        {
                            TwitterAccountRepository objTwtAccRepo = new TwitterAccountRepository();
                            Domain.Socioboard.Domain.TwitterAccount objTwtAcc = objTwtAccRepo.getUserInfo(sp.ProfileId);
                            pc.ProfileName = objTwtAcc.TwitterScreenName;
                            pc.ProfileImgUrl = objTwtAcc.ProfileImageUrl;
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }
                    }
                    else if (sp.ProfileType == "instagram")
                    {
                        try
                        {
                            InstagramAccountRepository objInsAccRepo = new InstagramAccountRepository();
                            Domain.Socioboard.Domain.InstagramAccount objInsAcc = objInsAccRepo.getInstagramAccountById(sp.ProfileId);
                            pc.ProfileName = objInsAcc.InsUserName;
                            pc.ProfileImgUrl = objInsAcc.ProfileUrl;
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }
                    }
                    else if (sp.ProfileType == "linkedin")
                    {
                        try
                        {
                            LinkedInAccountRepository objLiAccRepo = new LinkedInAccountRepository();
                            Domain.Socioboard.Domain.LinkedInAccount objLiAcc = objLiAccRepo.getLinkedinAccountDetailsById(sp.ProfileId);
                            pc.ProfileName = objLiAcc.LinkedinUserName;
                            pc.ProfileImgUrl = objLiAcc.ProfileImageUrl;
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }
                    }
                    else if (sp.ProfileType == "googleplus")
                    {
                        try
                        {
                            GooglePlusAccountRepository objGpAccRepo = new GooglePlusAccountRepository();
                            Domain.Socioboard.Domain.GooglePlusAccount objGpAcc = objGpAccRepo.getUserDetails(sp.ProfileId);
                            pc.ProfileName = objGpAcc.GpUserName;
                            pc.ProfileImgUrl = objGpAcc.GpProfileImage;
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }
                    }
                    else if (sp.ProfileType == "tumblr")
                    {
                        try
                        {
                            TumblrAccountRepository objTumblrAccountRepository = new TumblrAccountRepository();
                            Domain.Socioboard.Domain.TumblrAccount objTumblrAccount = objTumblrAccountRepository.getTumblrAccountDetailsById(sp.ProfileId);
                            pc.ProfileName = objTumblrAccount.tblrUserName;
                            pc.ProfileImgUrl = objTumblrAccount.tblrProfilePicUrl;
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }
                    }
                    else if (sp.ProfileType == "youtube")
                    {
                        try
                        {
                            YoutubeAccountRepository objYoutubeAccountRepository = new YoutubeAccountRepository();
                            Domain.Socioboard.Domain.YoutubeAccount objYoutubeAccount = objYoutubeAccountRepository.getYoutubeAccountDetailsById(sp.ProfileId);
                            pc.ProfileName = objYoutubeAccount.Ytusername;
                            pc.ProfileImgUrl = objYoutubeAccount.Ytprofileimage;
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }
                    }
                    lstProfile.Add(pc);
                }
                return new JavaScriptSerializer().Serialize(lstProfile);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
                return new JavaScriptSerializer().Serialize("Please Try Again");
            }
        }
示例#20
0
        public string contactSearchFacebook(string keyword)
        {
            List<Domain.Socioboard.Domain.DiscoverySearch> lstDiscoverySearch = new List<Domain.Socioboard.Domain.DiscoverySearch>();
            string profileid = string.Empty;
            try
            {
                FacebookAccountRepository fbAccRepo = new FacebookAccountRepository();
                ArrayList asltFbAccount = fbAccRepo.getAllFacebookAccounts();
                string accesstoken = string.Empty;
                foreach (Domain.Socioboard.Domain.FacebookAccount item in asltFbAccount)
                {
                    if (item.AccessToken != "")
                    {
                        accesstoken = item.AccessToken;
                        if (this.CheckFacebookToken(accesstoken, keyword))
                        {
                            break;
                        }
                    }

                }
                //string facebookSearchUrl = "https://graph.facebook.com/search?q=" + keyword + " &type=post&access_token=" + accesstoken + "&limit=100";
                string facebookSearchUrl = "https://graph.facebook.com/search?q=" + keyword + " &limit=20&type=user&access_token=" + accesstoken;
                var facerequest = (HttpWebRequest)WebRequest.Create(facebookSearchUrl);
                facerequest.Method = "GET";
                string outputface = string.Empty;
                using (var response = facerequest.GetResponse())
                {
                    using (var stream = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding(1252)))
                    {
                        outputface = stream.ReadToEnd();
                    }
                }
                if (!outputface.StartsWith("["))
                    outputface = "[" + outputface + "]";
                JArray facebookSearchResult = JArray.Parse(outputface);
                foreach (var item in facebookSearchResult)
                {
                    var data = item["data"];

                    foreach (var chile in data)
                    {
                        try
                        {
                            objDiscoverySearch = new Domain.Socioboard.Domain.DiscoverySearch();
                            objDiscoverySearch.FromId = chile["id"].ToString();
                            objDiscoverySearch.FromName = chile["name"].ToString();
                            lstDiscoverySearch.Add(objDiscoverySearch);
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }
                    }
                }

                return new JavaScriptSerializer().Serialize(lstDiscoverySearch);

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
                return new JavaScriptSerializer().Serialize("Please try Again");
            }
        }
示例#21
0
        public override void PostScheduleMessage(dynamic data)
        {
            try
            {
                FacebookAccountRepository fbaccrepo = new FacebookAccountRepository();
                //IEnumerable<FacebookAccount> lstfbaccount = fbaccrepo.getUserDetails(data.ProfileId);
                FacebookAccount fbaccount = fbaccrepo.getUserDetails(data.ProfileId);
                if (fbaccount != null)
                {
                    //FacebookAccount fbaccount = null;
                    //foreach (FacebookAccount item in lstfbaccount)
                    //{
                    //    fbaccount = item;
                    //    break;
                    //}

                    FacebookClient fbclient = new FacebookClient(fbaccount.AccessToken);
                    var            args     = new Dictionary <string, object>();
                    args["message"] = data.ShareMessage;

                    //var facebookpost = fbclient.Post("/me/feed", args);
                    var facebookpost = "";
                    try
                    {
                        if (fbaccount.Type == "account")
                        {
                            facebookpost = fbclient.Post("/me/feed", args).ToString();
                        }
                        else
                        {
                            facebookpost = fbclient.Post("/" + fbaccount.FbUserId + "/feed", args).ToString();
                        }
                    }
                    catch (Exception ex)
                    {
                        FacebookAccount           objFacebookAccount           = new FacebookAccount();
                        FacebookAccountRepository objFacebookAccountRepository = new FacebookAccountRepository();
                        objFacebookAccount.FbUserId = data.ProfileId;
                        objFacebookAccount.UserId   = fbaccount.UserId;
                        objFacebookAccount.IsActive = 2;
                        objFacebookAccountRepository.updateFacebookUserStatus(objFacebookAccount);
                        SocialProfile            objSocialProfile            = new SocialProfile();
                        SocialProfilesRepository objSocialProfilesRepository = new SocialProfilesRepository();
                        //logger.Error(ex.Message);
                        string errormsg = ex.Message;
                        if (errormsg.Contains("access token"))
                        {
                            objSocialProfile.UserId        = fbaccount.UserId;
                            objSocialProfile.ProfileId     = data.ProfileId;
                            objSocialProfile.ProfileStatus = 2;
                            objSocialProfilesRepository.updateSocialProfileStatus(objSocialProfile);
                        }
                        Console.WriteLine(ex.Message);
                    }

                    Console.WriteLine("Message post on facebook for Id :" + fbaccount.FbUserId + " and Message: " + data.ShareMessage);

                    ScheduledMessageRepository schrepo = new ScheduledMessageRepository();
                    ScheduledMessage           schmsg  = new ScheduledMessage();
                    schmsg.Id           = data.Id;
                    schmsg.ProfileId    = data.ProfileId;
                    schmsg.ProfileType  = "";
                    schmsg.Status       = true;
                    schmsg.UserId       = data.UserId;
                    schmsg.ShareMessage = data.ShareMessage;
                    schmsg.ScheduleTime = data.ScheduleTime;
                    schmsg.ClientTime   = data.ClientTime;
                    schmsg.CreateTime   = data.CreateTime;
                    schmsg.PicUrl       = data.PicUrl;

                    schrepo.updateMessage(data.Id);
                }
                else
                {
                    Console.WriteLine("facebook account not found for id" + data.ProfileId);
                }
            }
            catch (FacebookApiLimitException ex)
            {
                Console.WriteLine(ex.StackTrace);
            }
        }
示例#22
0
        protected void btnRegister_Click(object sender, ImageClickEventArgs e)
        {
            User           user     = new User();
            UserRepository userrepo = new UserRepository();

            SocioBoard.Helper.SessionFactory.configfilepath = Server.MapPath("~/hibernate.cfg.xml");
            try
            {
                if (txtPassword.Text == txtConfirmPassword.Text)
                {
                    user.PaymentStatus = "unpaid";
                    user.AccountType   = Request.QueryString["type"];
                    if (user.AccountType == string.Empty)
                    {
                        user.AccountType = AccountType.Deluxe.ToString();
                    }
                    user.CreateDate = DateTime.Now;
                    user.ExpiryDate = DateTime.Now.AddMonths(1);
                    user.Id         = Guid.NewGuid();
                    user.UserName   = txtFirstName.Text + " " + txtLastName.Text;
                    user.Password   = this.MD5Hash(txtPassword.Text);
                    user.EmailId    = txtEmail.Text;
                    user.UserStatus = 1;
                    if (!userrepo.IsUserExist(user.EmailId))
                    {
                        UserRepository.Add(user);
                        SocioBoard.Helper.MailSender.SendEMail(txtFirstName.Text + " " + txtLastName.Text, txtPassword.Text, txtEmail.Text);

                        TeamRepository teamRepo = new TeamRepository();
                        Team           team     = teamRepo.getTeamByEmailId(txtEmail.Text);
                        if (team != null)
                        {
                            Guid teamid = Guid.Parse(Request.QueryString["tid"]);
                            teamRepo.updateTeamStatus(teamid);


                            TeamMemberProfileRepository teamMemRepo   = new TeamMemberProfileRepository();
                            List <TeamMemberProfile>    lstteammember = teamMemRepo.getAllTeamMemberProfilesOfTeam(team.Id);
                            foreach (TeamMemberProfile item in lstteammember)
                            {
                                try
                                {
                                    SocialProfilesRepository socialRepo   = new SocialProfilesRepository();
                                    SocialProfile            socioprofile = new SocialProfile();
                                    socioprofile.Id          = Guid.NewGuid();
                                    socioprofile.ProfileDate = DateTime.Now;
                                    socioprofile.ProfileId   = item.ProfileId;
                                    socioprofile.ProfileType = item.ProfileType;
                                    socioprofile.UserId      = user.Id;
                                    socialRepo.addNewProfileForUser(socioprofile);

                                    if (item.ProfileType == "facebook")
                                    {
                                        try
                                        {
                                            FacebookAccount           fbAccount     = new FacebookAccount();
                                            FacebookAccountRepository fbAccountRepo = new FacebookAccountRepository();
                                            FacebookAccount           userAccount   = fbAccountRepo.getUserDetails(item.ProfileId);
                                            fbAccount.AccessToken = userAccount.AccessToken;
                                            fbAccount.EmailId     = userAccount.EmailId;
                                            fbAccount.FbUserId    = item.ProfileId;
                                            fbAccount.FbUserName  = userAccount.FbUserName;
                                            fbAccount.Friends     = userAccount.Friends;
                                            fbAccount.Id          = Guid.NewGuid();
                                            fbAccount.IsActive    = true;
                                            fbAccount.ProfileUrl  = userAccount.ProfileUrl;
                                            fbAccount.Type        = userAccount.Type;
                                            fbAccount.UserId      = user.Id;
                                            fbAccountRepo.addFacebookUser(fbAccount);
                                        }
                                        catch (Exception ex)
                                        {
                                            Console.WriteLine(ex.Message);
                                            logger.Error(ex.Message);
                                        }
                                    }
                                    else if (item.ProfileType == "twitter")
                                    {
                                        try
                                        {
                                            TwitterAccount           twtAccount = new TwitterAccount();
                                            TwitterAccountRepository twtAccRepo = new TwitterAccountRepository();
                                            TwitterAccount           twtAcc     = twtAccRepo.getUserInfo(item.ProfileId);
                                            twtAccount.FollowersCount    = twtAcc.FollowersCount;
                                            twtAccount.FollowingCount    = twtAcc.FollowingCount;
                                            twtAccount.Id                = Guid.NewGuid();
                                            twtAccount.IsActive          = true;
                                            twtAccount.OAuthSecret       = twtAcc.OAuthSecret;
                                            twtAccount.OAuthToken        = twtAcc.OAuthToken;
                                            twtAccount.ProfileImageUrl   = twtAcc.ProfileImageUrl;
                                            twtAccount.ProfileUrl        = twtAcc.ProfileUrl;
                                            twtAccount.TwitterName       = twtAcc.TwitterName;
                                            twtAccount.TwitterScreenName = twtAcc.TwitterScreenName;
                                            twtAccount.TwitterUserId     = twtAcc.TwitterUserId;
                                            twtAccount.UserId            = user.Id;
                                            twtAccRepo.addTwitterkUser(twtAccount);
                                        }
                                        catch (Exception ex)
                                        {
                                            Console.WriteLine(ex.StackTrace);
                                            logger.Error(ex.Message);
                                        }
                                    }
                                    else if (item.ProfileType == "instagram")
                                    {
                                        try
                                        {
                                            InstagramAccount           insAccount = new InstagramAccount();
                                            InstagramAccountRepository insAccRepo = new InstagramAccountRepository();
                                            InstagramAccount           InsAcc     = insAccRepo.getInstagramAccountById(item.ProfileId);
                                            insAccount.AccessToken = InsAcc.AccessToken;
                                            insAccount.FollowedBy  = InsAcc.FollowedBy;
                                            insAccount.Followers   = InsAcc.Followers;
                                            insAccount.Id          = Guid.NewGuid();
                                            insAccount.InstagramId = item.ProfileId;
                                            insAccount.InsUserName = InsAcc.InsUserName;
                                            insAccount.IsActive    = true;
                                            insAccount.ProfileUrl  = InsAcc.ProfileUrl;
                                            insAccount.TotalImages = InsAcc.TotalImages;
                                            insAccount.UserId      = user.Id;
                                            insAccRepo.addInstagramUser(insAccount);
                                        }
                                        catch (Exception ex)
                                        {
                                            Console.WriteLine(ex.StackTrace);
                                            logger.Error(ex.Message);
                                        }
                                    }
                                    else if (item.ProfileType == "linkedin")
                                    {
                                        try
                                        {
                                            LinkedInAccount           linkAccount       = new LinkedInAccount();
                                            LinkedInAccountRepository linkedAccountRepo = new LinkedInAccountRepository();
                                            LinkedInAccount           linkAcc           = linkedAccountRepo.getLinkedinAccountDetailsById(item.ProfileId);
                                            linkAccount.Id               = Guid.NewGuid();
                                            linkAccount.IsActive         = true;
                                            linkAccount.LinkedinUserId   = item.ProfileId;
                                            linkAccount.LinkedinUserName = linkAcc.LinkedinUserName;
                                            linkAccount.OAuthSecret      = linkAcc.OAuthSecret;
                                            linkAccount.OAuthToken       = linkAcc.OAuthToken;
                                            linkAccount.OAuthVerifier    = linkAcc.OAuthVerifier;
                                            linkAccount.ProfileImageUrl  = linkAcc.ProfileImageUrl;
                                            linkAccount.ProfileUrl       = linkAcc.ProfileUrl;
                                            linkAccount.UserId           = user.Id;
                                            linkedAccountRepo.addLinkedinUser(linkAccount);
                                        }
                                        catch (Exception ex)
                                        {
                                            Console.WriteLine(ex.StackTrace);
                                            logger.Error(ex.Message);
                                        }
                                    }
                                }
                                catch (Exception ex)
                                {
                                    logger.Error(ex.Message);
                                }
                            }
                        }


                        lblerror.Text = "Registered Successfully !" + "<a href=\"Default.aspx\">Login</a>";
                    }
                    else
                    {
                        lblerror.Text = "Email Already Exists " + "<a href=\"Default.aspx\">login</a>";
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex.StackTrace);
                lblerror.Text = "Please Insert Correct Information";
                Console.WriteLine(ex.StackTrace);
            }
        }
        public string SheduleFacebookGroupMessage(string FacebookId, string UserId, string sscheduledmsgguid)
        {
            string str = string.Empty;
            int facint = 0;
            try
            {
                objScheduledMessage = objScheduledMessageRepository.GetScheduledMessageDetails(Guid.Parse(sscheduledmsgguid));
                GroupScheduleMessageRepository grpschedulemessagerepo = new GroupScheduleMessageRepository();
                Domain.Socioboard.Domain.GroupScheduleMessage _GroupScheduleMessage = grpschedulemessagerepo.GetScheduleMessageId(objScheduledMessage.Id);
                if (objFacebookAccountRepository.checkFacebookUserExists(FacebookId, Guid.Parse(UserId)))
                {
                    objFacebookAccount = objFacebookAccountRepository.getFacebookAccountDetailsById(FacebookId, Guid.Parse(UserId));
                }
                else
                {
                    objFacebookAccount = objFacebookAccountRepository.getFacebookAccountDetailsById(FacebookId);
                }
                if (objFacebookAccount != null)
                {
                    FacebookClient fbclient = new FacebookClient(objFacebookAccount.AccessToken);
                    var args = new Dictionary<string, object>();
                    args["message"] = objScheduledMessage.ShareMessage;
                    string imagepath = objScheduledMessage.PicUrl;

                    var facebookpost = "";
                    try
                    {
                        if (!string.IsNullOrEmpty(imagepath))
                        {
                            var media = new FacebookMediaObject
                            {
                                FileName = "filename",
                                ContentType = "image/jpeg"
                            };
                            byte[] img = System.IO.File.ReadAllBytes(imagepath);
                            media.SetValue(img);
                            args["source"] = media;
                            facebookpost = fbclient.Post("v2.0/" + _GroupScheduleMessage.GroupId + "/photos", args).ToString();
                        }
                        else
                        {
                            facebookpost = fbclient.Post("v2.0/" + _GroupScheduleMessage.GroupId + "/feed", args).ToString();
                        }
                    }
                    catch (Exception ex)
                    {
                        objFacebookAccountRepository = new FacebookAccountRepository();
                        objFacebookAccount.IsActive = 2;
                        objFacebookAccountRepository.updateFacebookUserStatus(objFacebookAccount);
                        Domain.Socioboard.Domain.SocialProfile objSocialProfile = new Domain.Socioboard.Domain.SocialProfile();
                        SocialProfilesRepository objSocialProfilesRepository = new SocialProfilesRepository();
                        string errormsg = ex.Message;
                        if (errormsg.Contains("access token"))
                        {
                            objSocialProfile.UserId = objFacebookAccount.UserId;
                            objSocialProfile.ProfileId = objFacebookAccount.FbUserId;
                            objSocialProfile.ProfileStatus = 2;
                            objSocialProfilesRepository.updateSocialProfileStatus(objSocialProfile);
                        }
                        Console.WriteLine(ex.Message);
                        str = ex.Message;
                    }

                    if (!string.IsNullOrEmpty(facebookpost))
                    {
                        facint++;
                        str = "Message post on facebook for Id :" + objFacebookAccount.FbUserId + " and Message: " + objScheduledMessage.ShareMessage;
                        ScheduledMessage schmsg = new ScheduledMessage();
                        schmsg.UpdateScheduledMessageByMsgId(Guid.Parse(sscheduledmsgguid));
                        logger.Error("SheduleFacebookGroupMessageCount" + facint);
                    }
                }
                else
                {
                    str = "facebook account not found for id" + objScheduledMessage.ProfileId;
                }
            }
            catch (Exception ex)
            {
                str = ex.Message;
            }
            return str;
        }
        public bool AddFacebookFriendsGender(string ProfileId, string FacebookUserId)
        {
            Api.Socioboard.Services.FacebookAccount _FacebookAccount = new FacebookAccount();
            Domain.Socioboard.Domain.FacebookAccount _facebookAccount = new Domain.Socioboard.Domain.FacebookAccount();

            _facebookAccount = (Domain.Socioboard.Domain.FacebookAccount)(new System.Web.Script.Serialization.JavaScriptSerializer().Deserialize(_FacebookAccount.getFacebookAccountDetailsById(ProfileId, FacebookUserId), typeof(Domain.Socioboard.Domain.FacebookAccount)));

            if (string.IsNullOrEmpty(_facebookAccount.AccessToken))
            {
                _facebookAccount = new Domain.Socioboard.Domain.FacebookAccount();
                FacebookAccountRepository _FacebookAccountRepository = new FacebookAccountRepository();

                System.Collections.ArrayList lstFacebookAccounts = _FacebookAccountRepository.getAllFacebookAccounts();

                Random _random = new Random();
                var rnum = _random.Next(0, lstFacebookAccounts.Count - 1);
                _facebookAccount = (Domain.Socioboard.Domain.FacebookAccount)lstFacebookAccounts[rnum];
            }
            int malecount = 0;
            int femalecount = 0;

            Domain.Socioboard.Domain.FacebookStats objfbStats = new Domain.Socioboard.Domain.FacebookStats();
            FacebookStatsRepository objFBStatsRepo = new FacebookStatsRepository();

            FacebookClient fb = new FacebookClient(); 
            fb.AccessToken = _facebookAccount.AccessToken;
            try
            {
                dynamic data = fb.Get("v2.0/me/friends?fields=gender");

                //dynamic data, dynamic profile, Guid userId


                foreach (var item in data["data"])
                {

                    try
                    {
                        if (item["gender"] == "male")
                            malecount++;
                        else if (item["gender"] == "female")
                            femalecount++;
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.Message);
                        logger.Error(ex.StackTrace);
                    }

                }
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message);
                logger.Error(ex.StackTrace);
                return false;
            }
            objfbStats.EntryDate = DateTime.Now;
            objfbStats.FbUserId = _facebookAccount.FbUserId;//profile["id"].ToString();
            objfbStats.FemaleCount = femalecount;
            objfbStats.Id = Guid.NewGuid();
            objfbStats.MaleCount = malecount;
            objfbStats.UserId = _facebookAccount.UserId;
            objfbStats.FanCount = getfanCount(objfbStats, _facebookAccount.AccessToken);

            if (objFBStatsRepo.checkFacebookStatsExists(objfbStats.FbUserId.ToString(), objfbStats.UserId, objfbStats.FanCount, objfbStats.MaleCount, objfbStats.FemaleCount))
            {
                objFBStatsRepo.addFacebookStats(objfbStats);
            }


            return true;
        }
示例#25
0
        protected void btnRegister_Click(object sender, ImageClickEventArgs e)
        {
            try
            {
                User             user                = new User();
                UserRepository   userrepo            = new UserRepository();
                UserActivation   objUserActivation   = new UserActivation();
                Coupon           objCoupon           = new Coupon();
                CouponRepository objCouponRepository = new CouponRepository();
                Groups           groups              = new Groups();
                GroupRepository  objGroupRepository  = new GroupRepository();
                Team             teams               = new Team();
                TeamRepository   objTeamRepository   = new TeamRepository();


                SocioBoard.Helper.SessionFactory.configfilepath = Server.MapPath("~/hibernate.cfg.xml");
                try
                {
                    if (DropDownList1.SelectedValue == "Free" || DropDownList1.SelectedValue == "Standard" || DropDownList1.SelectedValue == "Deluxe" || DropDownList1.SelectedValue == "Premium" || DropDownList1.SelectedValue == "SocioBasic" || DropDownList1.SelectedValue == "SocioStandard" || DropDownList1.SelectedValue == "SocioPremium" || DropDownList1.SelectedValue == "SocioDeluxe")


                    {
                        if (TextBox1.Text.Trim() != "")
                        {
                            string resp = SBUtils.GetCouponStatus(TextBox1.Text).ToString();
                            if (resp != "valid")
                            {
                                ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('" + resp + "');", true);
                                return;
                            }
                        }



                        if (txtPassword.Text == txtConfirmPassword.Text)
                        {
                            user.PaymentStatus = "unpaid";
                            user.AccountType   = DropDownList1.SelectedValue.ToString();
                            if (string.IsNullOrEmpty(user.AccountType))
                            {
                                user.AccountType = AccountType.Free.ToString();
                            }


                            user.CreateDate       = DateTime.Now;
                            user.ExpiryDate       = DateTime.Now.AddDays(30);
                            user.Id               = Guid.NewGuid();
                            user.UserName         = txtFirstName.Text + " " + txtLastName.Text;
                            user.Password         = this.MD5Hash(txtPassword.Text);
                            user.EmailId          = txtEmail.Text;
                            user.UserStatus       = 1;
                            user.ActivationStatus = "0";

                            if (TextBox1.Text.Trim() != "")
                            {
                                user.CouponCode = TextBox1.Text.Trim().ToString();
                            }


                            if (!userrepo.IsUserExist(user.EmailId))
                            {
                                logger.Error("Before User reg");
                                UserRepository.Add(user);



                                try
                                {
                                    groups.Id        = Guid.NewGuid();
                                    groups.GroupName = ConfigurationManager.AppSettings["DefaultGroupName"];
                                    groups.UserId    = user.Id;
                                    groups.EntryDate = DateTime.Now;

                                    objGroupRepository.AddGroup(groups);


                                    teams.Id      = Guid.NewGuid();
                                    teams.GroupId = groups.Id;
                                    teams.UserId  = user.Id;
                                    teams.EmailId = user.EmailId;

                                    objTeamRepository.addNewTeam(teams);



                                    BusinessSettingRepository busnrepo = new BusinessSettingRepository();

                                    SocioBoard.Domain.BusinessSetting objbsnssetting = new SocioBoard.Domain.BusinessSetting();

                                    if (!busnrepo.checkBusinessExists(user.Id, groups.GroupName))
                                    {
                                        objbsnssetting.Id               = Guid.NewGuid();
                                        objbsnssetting.BusinessName     = groups.GroupName;
                                        objbsnssetting.GroupId          = groups.Id;
                                        objbsnssetting.AssigningTasks   = false;
                                        objbsnssetting.AssigningTasks   = false;
                                        objbsnssetting.TaskNotification = false;
                                        objbsnssetting.TaskNotification = false;
                                        objbsnssetting.FbPhotoUpload    = 0;
                                        objbsnssetting.UserId           = user.Id;
                                        objbsnssetting.EntryDate        = DateTime.Now;
                                        busnrepo.AddBusinessSetting(objbsnssetting);
                                    }
                                }
                                catch (Exception ex)
                                {
                                    Console.WriteLine(ex.Message);
                                    logger.Error("Error : " + ex.Message);
                                    logger.Error("Error : " + ex.StackTrace);
                                }


                                try
                                {
                                    logger.Error("1 Request.QueryString[refid]");
                                    if (Request.QueryString["refid"] != null)
                                    {
                                        logger.Error("3 Request.QueryString[refid]");
                                        User UserValid = null;
                                        if (IsUserValid(Request.QueryString["refid"].ToString(), ref UserValid))
                                        {
                                            logger.Error("Inside IsUserValid");
                                            user.RefereeStatus = "1";
                                            UpdateUserReference(UserValid);
                                            AddUserRefreeRelation(user, UserValid);

                                            logger.Error("IsUserValid");
                                        }
                                        else
                                        {
                                            user.RefereeStatus = "0";
                                        }
                                    }
                                    logger.Error("2 Request.QueryString[refid]");
                                }
                                catch (Exception ex)
                                {
                                    Console.WriteLine(ex.Message);
                                    logger.Error("btnRegister_Click" + ex.Message);
                                    logger.Error("btnRegister_Click" + ex.StackTrace);
                                }



                                if (TextBox1.Text.Trim() != "")
                                {
                                    objCoupon.CouponCode = TextBox1.Text.Trim();
                                    List <Coupon> lstCoupon = objCouponRepository.GetCouponByCouponCode(objCoupon);
                                    objCoupon.Id = lstCoupon[0].Id;
                                    objCoupon.EntryCouponDate = lstCoupon[0].EntryCouponDate;
                                    objCoupon.ExpCouponDate   = lstCoupon[0].ExpCouponDate;
                                    objCoupon.Status          = "1";
                                    objCouponRepository.SetCouponById(objCoupon);
                                }

                                Session["LoggedUser"]              = user;
                                objUserActivation.Id               = Guid.NewGuid();
                                objUserActivation.UserId           = user.Id;
                                objUserActivation.ActivationStatus = "0";
                                UserActivationRepository.Add(objUserActivation);

                                //add package start

                                UserPackageRelation           objUserPackageRelation           = new UserPackageRelation();
                                UserPackageRelationRepository objUserPackageRelationRepository = new UserPackageRelationRepository();
                                PackageRepository             objPackageRepository             = new PackageRepository();

                                try
                                {
                                    Package objPackage = objPackageRepository.getPackageDetails(user.AccountType);
                                    objUserPackageRelation.Id            = Guid.NewGuid();
                                    objUserPackageRelation.PackageId     = objPackage.Id;
                                    objUserPackageRelation.UserId        = user.Id;
                                    objUserPackageRelation.ModifiedDate  = DateTime.Now;
                                    objUserPackageRelation.PackageStatus = true;

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

                                //end package

                                SocioBoard.Helper.MailSender.SendEMail(txtFirstName.Text, txtPassword.Text, txtEmail.Text, user.AccountType.ToString(), user.Id.ToString());
                                TeamRepository teamRepo = new TeamRepository();
                                try
                                {
                                    Team team = teamRepo.getTeamByEmailId(txtEmail.Text);
                                    if (team != null)
                                    {
                                        Guid teamid = Guid.Parse(Request.QueryString["tid"]);
                                        teamRepo.updateTeamStatus(teamid);
                                        TeamMemberProfileRepository teamMemRepo   = new TeamMemberProfileRepository();
                                        List <TeamMemberProfile>    lstteammember = teamMemRepo.getAllTeamMemberProfilesOfTeam(team.Id);
                                        foreach (TeamMemberProfile item in lstteammember)
                                        {
                                            try
                                            {
                                                SocialProfilesRepository socialRepo   = new SocialProfilesRepository();
                                                SocialProfile            socioprofile = new SocialProfile();
                                                socioprofile.Id          = Guid.NewGuid();
                                                socioprofile.ProfileDate = DateTime.Now;
                                                socioprofile.ProfileId   = item.ProfileId;
                                                socioprofile.ProfileType = item.ProfileType;
                                                socioprofile.UserId      = user.Id;
                                                socialRepo.addNewProfileForUser(socioprofile);

                                                if (item.ProfileType == "facebook")
                                                {
                                                    try
                                                    {
                                                        FacebookAccount           fbAccount     = new FacebookAccount();
                                                        FacebookAccountRepository fbAccountRepo = new FacebookAccountRepository();
                                                        FacebookAccount           userAccount   = fbAccountRepo.getUserDetails(item.ProfileId);
                                                        fbAccount.AccessToken = userAccount.AccessToken;
                                                        fbAccount.EmailId     = userAccount.EmailId;
                                                        fbAccount.FbUserId    = item.ProfileId;
                                                        fbAccount.FbUserName  = userAccount.FbUserName;
                                                        fbAccount.Friends     = userAccount.Friends;
                                                        fbAccount.Id          = Guid.NewGuid();
                                                        fbAccount.IsActive    = 1;
                                                        fbAccount.ProfileUrl  = userAccount.ProfileUrl;
                                                        fbAccount.Type        = userAccount.Type;
                                                        fbAccount.UserId      = user.Id;
                                                        fbAccountRepo.addFacebookUser(fbAccount);
                                                    }
                                                    catch (Exception ex)
                                                    {
                                                        Console.WriteLine(ex.Message);
                                                        logger.Error(ex.Message);
                                                    }
                                                }
                                                else if (item.ProfileType == "twitter")
                                                {
                                                    try
                                                    {
                                                        TwitterAccount           twtAccount = new TwitterAccount();
                                                        TwitterAccountRepository twtAccRepo = new TwitterAccountRepository();
                                                        TwitterAccount           twtAcc     = twtAccRepo.getUserInfo(item.ProfileId);
                                                        twtAccount.FollowersCount    = twtAcc.FollowersCount;
                                                        twtAccount.FollowingCount    = twtAcc.FollowingCount;
                                                        twtAccount.Id                = Guid.NewGuid();
                                                        twtAccount.IsActive          = true;
                                                        twtAccount.OAuthSecret       = twtAcc.OAuthSecret;
                                                        twtAccount.OAuthToken        = twtAcc.OAuthToken;
                                                        twtAccount.ProfileImageUrl   = twtAcc.ProfileImageUrl;
                                                        twtAccount.ProfileUrl        = twtAcc.ProfileUrl;
                                                        twtAccount.TwitterName       = twtAcc.TwitterName;
                                                        twtAccount.TwitterScreenName = twtAcc.TwitterScreenName;
                                                        twtAccount.TwitterUserId     = twtAcc.TwitterUserId;
                                                        twtAccount.UserId            = user.Id;
                                                        twtAccRepo.addTwitterkUser(twtAccount);
                                                    }
                                                    catch (Exception ex)
                                                    {
                                                        Console.WriteLine(ex.StackTrace);
                                                        logger.Error(ex.Message);
                                                    }
                                                }
                                                else if (item.ProfileType == "instagram")
                                                {
                                                    try
                                                    {
                                                        InstagramAccount           insAccount = new InstagramAccount();
                                                        InstagramAccountRepository insAccRepo = new InstagramAccountRepository();
                                                        InstagramAccount           InsAcc     = insAccRepo.getInstagramAccountById(item.ProfileId);
                                                        insAccount.AccessToken = InsAcc.AccessToken;
                                                        insAccount.FollowedBy  = InsAcc.FollowedBy;
                                                        insAccount.Followers   = InsAcc.Followers;
                                                        insAccount.Id          = Guid.NewGuid();
                                                        insAccount.InstagramId = item.ProfileId;
                                                        insAccount.InsUserName = InsAcc.InsUserName;
                                                        insAccount.IsActive    = true;
                                                        insAccount.ProfileUrl  = InsAcc.ProfileUrl;
                                                        insAccount.TotalImages = InsAcc.TotalImages;
                                                        insAccount.UserId      = user.Id;
                                                        insAccRepo.addInstagramUser(insAccount);
                                                    }
                                                    catch (Exception ex)
                                                    {
                                                        Console.WriteLine(ex.StackTrace);
                                                        logger.Error(ex.Message);
                                                    }
                                                }
                                                else if (item.ProfileType == "linkedin")
                                                {
                                                    try
                                                    {
                                                        LinkedInAccount           linkAccount       = new LinkedInAccount();
                                                        LinkedInAccountRepository linkedAccountRepo = new LinkedInAccountRepository();
                                                        LinkedInAccount           linkAcc           = linkedAccountRepo.getLinkedinAccountDetailsById(item.ProfileId);
                                                        linkAccount.Id               = Guid.NewGuid();
                                                        linkAccount.IsActive         = true;
                                                        linkAccount.LinkedinUserId   = item.ProfileId;
                                                        linkAccount.LinkedinUserName = linkAcc.LinkedinUserName;
                                                        linkAccount.OAuthSecret      = linkAcc.OAuthSecret;
                                                        linkAccount.OAuthToken       = linkAcc.OAuthToken;
                                                        linkAccount.OAuthVerifier    = linkAcc.OAuthVerifier;
                                                        linkAccount.ProfileImageUrl  = linkAcc.ProfileImageUrl;
                                                        linkAccount.ProfileUrl       = linkAcc.ProfileUrl;
                                                        linkAccount.UserId           = user.Id;
                                                        linkedAccountRepo.addLinkedinUser(linkAccount);
                                                    }
                                                    catch (Exception ex)
                                                    {
                                                        Console.WriteLine(ex.StackTrace);
                                                        logger.Error(ex.Message);
                                                    }
                                                }
                                            }
                                            catch (Exception ex)
                                            {
                                                logger.Error(ex.Message);
                                            }
                                        }
                                    }
                                }
                                catch (Exception ex)
                                {
                                    Console.WriteLine(ex.StackTrace);
                                }

                                #region SetInvitationStatusAfterSuccessfulRegistration
                                try
                                {
                                    if (Request.QueryString["refid"] != null)
                                    {
                                        string refid = Request.QueryString["refid"];

                                        int res = SetInvitationStatusAfterSuccessfulRegistration(refid, txtEmail.Text);
                                    }
                                }
                                catch (Exception ex)
                                {
                                    logger.Error(ex.Message);
                                }
                                #endregion


                                try
                                {
                                    lblerror.Text = "Registered Successfully !" + "<a href=\"Default.aspx\">Login</a>";
                                    Response.Redirect("~/Home.aspx");
                                }
                                catch (Exception ex)
                                {
                                    Console.WriteLine(ex.StackTrace);
                                }
                            }
                            else
                            {
                                lblerror.Text = "Email Already Exists " + "<a id=\"loginlink\"  href=\"#\">login</a>";
                            }
                        }
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Please select Account Type!');", true);
                    }
                }

                catch (Exception ex)
                {
                    logger.Error(ex.StackTrace);
                    lblerror.Text = "Success!";
                    Console.WriteLine(ex.StackTrace);
                    //Response.Redirect("Home.aspx");
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex.StackTrace);

                Console.WriteLine(ex.StackTrace);
                //Response.Redirect("Home.aspx");
            }
        }
示例#26
0
        public void GetSearchData(object parameters)
        {
            #region Facebook
            try
            {
                Array arrayParams = (Array)parameters;

                DiscoverySearch           dissearch       = (DiscoverySearch)arrayParams.GetValue(0);
                DiscoverySearchRepository dissearchrepo   = (DiscoverySearchRepository)arrayParams.GetValue(1);
                DiscoverySearch           discoverySearch = (DiscoverySearch)arrayParams.GetValue(2);


                #region FacebookSearch

                string accesstoken = string.Empty;

                FacebookAccountRepository fbAccRepo = new FacebookAccountRepository();
                //ArrayList asltFbAccount = fbAccRepo.getAllFacebookAccounts();
                ArrayList asltFbAccount = fbAccRepo.getAllFacebookAccountsOfUser(discoverySearch.UserId);

                foreach (FacebookAccount item in asltFbAccount)
                {
                    accesstoken = item.AccessToken;
                    if (FacebookHelper.CheckFacebookToken(accesstoken, discoverySearch.SearchKeyword))
                    {
                        break;
                    }
                }

                string facebookSearchUrl = "https://graph.facebook.com/search?q=" + discoverySearch.SearchKeyword + " &type=post&access_token=" + accesstoken;
                var    facerequest       = (HttpWebRequest)WebRequest.Create(facebookSearchUrl);
                facerequest.Method = "GET";
                string outputface = string.Empty;
                using (var response = facerequest.GetResponse())
                {
                    using (var stream = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding(1252)))
                    {
                        outputface = stream.ReadToEnd();
                    }
                }
                if (!outputface.StartsWith("["))
                {
                    outputface = "[" + outputface + "]";
                }


                Newtonsoft.Json.Linq.JArray facebookSearchResult = Newtonsoft.Json.Linq.JArray.Parse(outputface);

                foreach (var item in facebookSearchResult)
                {
                    var data = item["data"];

                    foreach (var chile in data)
                    {
                        try
                        {
                            dissearch.CreatedTime = DateTime.Parse(chile["created_time"].ToString());

                            dissearch.EntryDate = DateTime.Now;

                            dissearch.FromId = chile["from"]["id"].ToString();

                            dissearch.FromName = chile["from"]["name"].ToString();

                            try
                            {
                                dissearch.ProfileImageUrl = "http://graph.facebook.com/" + chile["from"]["id"] + "/picture?type=small";
                            }
                            catch { }

                            dissearch.SearchKeyword = discoverySearch.SearchKeyword;

                            dissearch.Network = "facebook";

                            try
                            {
                                dissearch.Message = chile["message"].ToString();
                            }
                            catch { }
                            try
                            {
                                dissearch.Message = chile["story"].ToString();
                            }
                            catch { }

                            dissearch.MessageId = chile["id"].ToString();

                            dissearch.Id = Guid.NewGuid();

                            dissearch.UserId = discoverySearch.UserId;

                            if (!dissearchrepo.isKeywordPresent(dissearch.SearchKeyword, dissearch.MessageId))
                            {
                                dissearchrepo.addNewSearchResult(dissearch);
                            }
                        }
                        catch (Exception ex)
                        {
                            //logger.Error(ex.StackTrace);
                            Console.WriteLine(ex.StackTrace);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                //logger.Error(ex.StackTrace);
                Console.WriteLine(ex.StackTrace);
            }
            #endregion

            #endregion
        }
示例#27
0
        public void GetData(object userId)
        {
            Guid UserId = (Guid)userId;
            FacebookAccountRepository objFbRepo = new FacebookAccountRepository();
            FacebookHelper            fbhelper  = new FacebookHelper();
            ArrayList arrFbAcc = objFbRepo.getAllFacebookAccountsOfUser(UserId);

            foreach (FacebookAccount itemFb in arrFbAcc)
            {
                FacebookHelper             objFbHelper = new FacebookHelper();
                FacebookInsightStatsHelper fbiHelper   = new FacebookInsightStatsHelper();
                try
                {
                    FacebookClient fb = new FacebookClient();
                    fb.AccessToken = itemFb.AccessToken;

                    var feeds   = fb.Get("/me/feed");
                    var home    = fb.Get("me/home");
                    var profile = fb.Get("me");
                    getFacebookUserHome(home, profile, UserId);
                    getFacebookUserFeeds(feeds, profile, UserId);
                    getFacebookProfile(profile, UserId);
                    FacebookAccountRepository fbAccRepo = new FacebookAccountRepository();
                    try
                    {
                        int     fancountacc = 0;
                        dynamic fanacccount = fb.Get("fql", new { q = "SELECT friend_count FROM user WHERE uid=" + itemFb.FbUserId });
                        foreach (var friend in fanacccount.data)
                        {
                            fancountacc = Convert.ToInt32(friend.friend_count);
                        }

                        fbAccRepo.updateFriendsCount(itemFb.FbUserId, itemFb.UserId, fancountacc);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                    if (itemFb.Type == "page")
                    {
                        try
                        {
                            fbiHelper.getFanPageLikesByGenderAge(itemFb.FbUserId, UserId, 10);
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.Message);
                        }

                        try
                        {
                            fbiHelper.getPageImpresion(itemFb.FbUserId, UserId, 10);
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine(e.Message);
                        }
                        try
                        {
                            fbiHelper.getStories(itemFb.FbUserId, UserId, 10);
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.Message);
                        }
                        try
                        {
                            fbiHelper.getLocation(itemFb.FbUserId, UserId, 10);
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.Message);
                        }
                        try
                        {
                            fbiHelper.getFanPost(itemFb.FbUserId, UserId, 10);
                        }
                        catch (Exception ex)
                        {
                        }

                        try
                        {
                            int     fancountPage = 0;
                            dynamic fancount     = fb.Get("fql", new { q = " SELECT fan_count FROM page WHERE page_id =" + itemFb.FbUserId });
                            foreach (var friend in fancount.data)
                            {
                                fancountPage = Convert.ToInt32(friend.fan_count);
                            }
                            // FacebookAccountRepository fbAccRepo = new FacebookAccountRepository();
                            fbAccRepo.updateFansCount(itemFb.FbUserId, itemFb.UserId, fancountPage);
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.Message);
                        }
                    }
                    //  var friendsgenderstats = fb.Get("me/friends?fields=gender");
                    // fbhelper.getfbFriendsGenderStats(friendsgenderstats, profile, UserId);
                }
                catch (Exception Err)
                {
                    Console.Write(Err.Message);
                }
            }
        }
示例#28
0
        //protected void rbAdmin_CheckedChanged(object sender, EventArgs e)
        //{
        //    rbAdmin.Checked = true;
        //    rbUser.Checked = false;
        //    if (rbAdmin.Checked == true && rbUser.Checked == false)
        //    {
        //        AccessLevel = "admin";
        //    }
        //    else
        //    {
        //        AccessLevel = "user";
        //    }
        //}



        //protected void rbUser_CheckedChanged(object sender, EventArgs e)
        //{
        //    rbAdmin.Checked = false;
        //    rbUser.Checked = true;

        //    if (rbAdmin.Checked == false && rbUser.Checked == true)
        //    {
        //        AccessLevel = "user";
        //    }
        //    else
        //    {
        //        AccessLevel = "admin";
        //    }
        //}

        public void BindSocialProfiles()
        {
            User user = (User)Session["LoggedUser"];

            if (Session["GroupId"] != null)
            {
                Guid groupid = (Guid)Session["GroupId"];
                GroupProfileRepository groupprofilesrepo = new GroupProfileRepository();
                GroupRepository        grouprepo         = new GroupRepository();
                Groups groups = grouprepo.getGroupDetailsbyId(user.Id, groupid);

                List <GroupProfile> lstgroupprofile = groupprofilesrepo.getAllGroupProfiles(user.Id, groupid);

                string bindfacebookprofiles  = string.Empty;
                string bindtwitterprofiles   = string.Empty;
                string bindlinkedinprofiles  = string.Empty;
                string bindinstagramprofiles = string.Empty;
                string bindtumblrprofiles    = string.Empty;
                int    i = 0;

                foreach (GroupProfile item in lstgroupprofile)
                {
                    if (item.ProfileType == "facebook")
                    {
                        FacebookAccountRepository fbaccountrepo = new FacebookAccountRepository();
                        FacebookAccount           account       = fbaccountrepo.getFacebookAccountDetailsById(item.ProfileId, user.Id);

                        if (account != null)
                        {
                            bindfacebookprofiles += "<div class=\"ws_tm_network_one\"><div class=\"ws_tm_user_name\">" + account.FbUserName + "</div>" +
                                                    "<div class=\"ws_tm_chkbx\"><input type=\"checkbox\" value=\"facebook_" + item.ProfileId + "\" onclick=\"isProfileID('" + item.ProfileId + "')\" id=\"facebookcheck_" + i + "\" name=\"chkbox_" + i + "\"></div></div>";
                        }
                    }
                    else if (item.ProfileType == "twitter")
                    {
                        TwitterAccountRepository twtaccountrepo = new TwitterAccountRepository();
                        TwitterAccount           twtaccount     = twtaccountrepo.getUserInformation(user.Id, item.ProfileId);

                        if (twtaccount != null)
                        {
                            bindtwitterprofiles += "<div class=\"ws_tm_network_one\"><div class=\"ws_tm_user_name\">" + twtaccount.TwitterScreenName + "</div>" +
                                                   "<div class=\"ws_tm_chkbx\"><input type=\"checkbox\" value=\"twitter_" + item.ProfileId + "\" onclick=\"isProfileID('" + item.ProfileId + "')\" id=\"twittercheck_" + i + "\" name=\"chkbox_" + i + "\"></div></div>";
                        }
                    }
                    else if (item.ProfileType == "linkedin")
                    {
                        LinkedInAccountRepository linkedaccrepo = new LinkedInAccountRepository();
                        LinkedInAccount           linkedaccount = linkedaccrepo.getUserInformation(user.Id, item.ProfileId);
                        if (linkedaccount != null)
                        {
                            bindlinkedinprofiles += "<div class=\"ws_tm_network_one\"><div class=\"ws_tm_user_name\">" + linkedaccount.LinkedinUserName + "</div>" +
                                                    "<div class=\"ws_tm_chkbx\"><input type=\"checkbox\" value=\"linkedin_" + item.ProfileId + "\" onclick=\"isProfileID('" + item.ProfileId + "')\" id=\"linkedincheck_" + i + "\" name=\"chkbox_" + i + "\"></div></div>";
                        }
                    }


                    else if (item.ProfileType == "tumblr")
                    {
                        TumblrAccountRepository tumblraccrepo = new TumblrAccountRepository();
                        TumblrAccount           tumblraccount = tumblraccrepo.getTumblrAccountDetailsById(item.ProfileId, user.Id);
                        if (tumblraccount != null)
                        {
                            bindtumblrprofiles += "<div class=\"ws_tm_network_one\"><div class=\"ws_tm_user_name\">" + tumblraccount.tblrUserName + "</div>" +
                                                  "<div class=\"ws_tm_chkbx\"><input type=\"checkbox\" value=\"tumblr_" + item.ProfileId + "\" onclick=\"isProfileID('" + item.ProfileId + "')\" id=\"tumblrcheck_" + i + "\" name=\"chkbox_" + i + "\"></div></div>";
                        }
                    }

                    else if (item.ProfileType == "instagram")
                    {
                        InstagramAccountRepository instagramrepo = new InstagramAccountRepository();
                        InstagramAccount           instaaccount  = instagramrepo.getInstagramAccountDetailsById(item.ProfileId, user.Id);
                        if (instaaccount != null)
                        {
                            bindinstagramprofiles += "<div class=\"ws_tm_network_one\"><div class=\"ws_tm_user_name\">" + instaaccount.InsUserName + "</div>" +
                                                     "<div class=\"ws_tm_chkbx\"><input type=\"checkbox\" value=\"instagram_" + item.ProfileId + "\" onclick=\"isProfileID('" + item.ProfileId + "')\" id=\"instagramcheck_" + i + "\" name=\"chkbox_" + i + "\"></div></div>";
                        }
                    }
                    i++;
                }

                if (!string.IsNullOrEmpty(bindfacebookprofiles))
                {
                    FacebookAc.InnerHtml = bindfacebookprofiles;
                }
                else
                {
                    FacebookAc.InnerHtml = "No Facebook Profiles for " + groups.GroupName + " Group";
                }

                if (!string.IsNullOrEmpty(bindtwitterprofiles))
                {
                    TwitterAc.InnerHtml = bindtwitterprofiles;
                }
                else
                {
                    TwitterAc.InnerHtml = "No Twitter Profiles for " + groups.GroupName + " Group";
                }
                if (!string.IsNullOrEmpty(bindinstagramprofiles))
                {
                    InstagramAc.InnerHtml = bindinstagramprofiles;
                }
                else
                {
                    InstagramAc.InnerHtml = "No Instagram Profiles for " + groups.GroupName + " Group";
                }
                if (!string.IsNullOrEmpty(bindlinkedinprofiles))
                {
                    LinkedInAc.InnerHtml = bindlinkedinprofiles;
                }
                else
                {
                    LinkedInAc.InnerHtml = "No LinkedIn Profiles for " + groups.GroupName + " Group";
                }
                if (!string.IsNullOrEmpty(bindtumblrprofiles))
                {
                    TumblrAc.InnerHtml = bindtumblrprofiles;
                }
                else
                {
                    TumblrAc.InnerHtml = "No Tumblr Profiles for " + groups.GroupName + " Group";
                }
                totalaccountscheck.InnerHtml = i.ToString();
            }
        }
示例#29
0
        public string getresults(string keyword)
        {
            User   user      = (User)Session["LoggedUser"];
            int    i         = 0;
            string searchRes = string.Empty;

            if (!string.IsNullOrEmpty(keyword))
            {
                DiscoverySearch           dissearch     = new DiscoverySearch();
                DiscoverySearchRepository dissearchrepo = new DiscoverySearchRepository();

                //Get data from Database if present, against the specified keyword
                List <DiscoverySearch> discoveryList = dissearchrepo.getResultsFromKeyword(keyword);

                if (discoveryList.Count == 0) //if no data, get the data for specified keyword from social media apis
                {
                    #region Twitter

                    try
                    {
                        oAuthTwitter oauth = new oAuthTwitter();
                        oauth.ConsumerKey       = ConfigurationManager.AppSettings["consumerKey"].ToString();
                        oauth.ConsumerKeySecret = ConfigurationManager.AppSettings["consumerSecret"].ToString();
                        oauth.CallBackUrl       = ConfigurationManager.AppSettings["callbackurl"].ToString();
                        TwitterAccountRepository twtAccRepo = new TwitterAccountRepository();
                        ArrayList alst = twtAccRepo.getAllTwitterAccounts();
                        foreach (TwitterAccount item in alst)
                        {
                            oauth.AccessToken       = item.OAuthToken;
                            oauth.AccessTokenSecret = item.OAuthSecret;
                            oauth.TwitterUserId     = item.TwitterUserId;
                            oauth.TwitterScreenName = item.TwitterScreenName;
                            if (TwitterHelper.CheckTwitterToken(oauth, keyword))
                            {
                                break;
                            }
                            else
                            {
                            }
                        }

                        Search search = new Search();
                        JArray twitterSearchResult = search.Get_Search_Tweets(oauth, keyword);

                        foreach (var item in twitterSearchResult)
                        {
                            var results = item["statuses"];

                            foreach (var chile in results)
                            {
                                try
                                {
                                    dissearch.CreatedTime     = SocioBoard.Helper.Extensions.ParseTwitterTime(chile["created_at"].ToString().TrimStart('"').TrimEnd('"'));;
                                    dissearch.EntryDate       = DateTime.Now;
                                    dissearch.FromId          = chile["user"]["id_str"].ToString().TrimStart('"').TrimEnd('"');
                                    dissearch.FromName        = chile["user"]["screen_name"].ToString().TrimStart('"').TrimEnd('"');
                                    dissearch.ProfileImageUrl = chile["user"]["profile_image_url"].ToString().TrimStart('"').TrimEnd('"');
                                    dissearch.SearchKeyword   = txtSearchText.Text;
                                    dissearch.Network         = "twitter";
                                    dissearch.Message         = chile["text"].ToString().TrimStart('"').TrimEnd('"');
                                    dissearch.MessageId       = chile["id_str"].ToString().TrimStart('"').TrimEnd('"');
                                    dissearch.Id     = Guid.NewGuid();
                                    dissearch.UserId = user.Id;

                                    string postID  = chile["id"].ToString();
                                    string postURL = "https://twitter.com/" + dissearch.FromName + "/status/" + postID;

                                    if (!dissearchrepo.isKeywordPresent(dissearch.SearchKeyword, dissearch.MessageId))
                                    {
                                        dissearchrepo.addNewSearchResult(dissearch);
                                    }

                                    searchRes += this.BindData(dissearch, i, postURL);


                                    i++;
                                }
                                catch (Exception ex)
                                {
                                    logger.Error(ex.StackTrace);
                                    Console.WriteLine(ex.StackTrace);
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.StackTrace);
                        Console.WriteLine(ex.StackTrace);
                    }
                    #endregion
                    #region Facebook
                    try
                    {
                        #region FacebookSearch
                        int    j           = 0;
                        string accesstoken = string.Empty;
                        FacebookAccountRepository fbAccRepo = new FacebookAccountRepository();
                        ArrayList asltFbAccount             = fbAccRepo.getAllFacebookAccounts();
                        foreach (FacebookAccount item in asltFbAccount)
                        {
                            accesstoken = item.AccessToken;
                            if (FacebookHelper.CheckFacebookToken(accesstoken, txtSearchText.Text))
                            {
                                break;
                            }
                        }

                        string facebookSearchUrl = "https://graph.facebook.com/search?q=" + txtSearchText.Text + " &type=post&access_token=" + accesstoken;
                        var    facerequest       = (HttpWebRequest)WebRequest.Create(facebookSearchUrl);
                        facerequest.Method = "GET";
                        string outputface = string.Empty;
                        using (var response = facerequest.GetResponse())
                        {
                            using (var stream = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding(1252)))
                            {
                                outputface = stream.ReadToEnd();
                            }
                        }
                        if (!outputface.StartsWith("["))
                        {
                            outputface = "[" + outputface + "]";
                        }


                        JArray facebookSearchResult = JArray.Parse(outputface);

                        foreach (var item in facebookSearchResult)
                        {
                            var data = item["data"];

                            foreach (var chile in data)
                            {
                                try
                                {
                                    dissearch.CreatedTime     = DateTime.Parse(chile["created_time"].ToString());
                                    dissearch.EntryDate       = DateTime.Now;
                                    dissearch.FromId          = chile["from"]["id"].ToString();
                                    dissearch.FromName        = chile["from"]["name"].ToString();
                                    dissearch.ProfileImageUrl = "http://graph.facebook.com/" + chile["from"]["id"] + "/picture?type=small";
                                    dissearch.SearchKeyword   = txtSearchText.Text;
                                    dissearch.Network         = "facebook";
                                    dissearch.Message         = chile["message"].ToString();
                                    dissearch.MessageId       = chile["id"].ToString();
                                    dissearch.Id     = Guid.NewGuid();
                                    dissearch.UserId = user.Id;

                                    string postURL = "https://www.facebook.com/" + dissearch.MessageId;

                                    if (!dissearchrepo.isKeywordPresent(dissearch.SearchKeyword, dissearch.MessageId))
                                    {
                                        dissearchrepo.addNewSearchResult(dissearch);
                                    }
                                    searchRes += this.BindData(dissearch, i, postURL);
                                }
                                catch (Exception ex)
                                {
                                    logger.Error(ex.StackTrace);
                                    Console.WriteLine(ex.StackTrace);
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.StackTrace);
                        Console.WriteLine(ex.StackTrace);
                    }
                    #endregion

                    #endregion
                }
                else // if data is there, bind data from databse
                {
                    foreach (DiscoverySearch item in discoveryList)
                    {
                        string postURL = string.Empty;
                        if (item.Network == "facebook")
                        {
                            postURL = "https://www.facebook.com/" + item.MessageId;;
                        }
                        else if (item.Network == "twitter")
                        {
                            postURL = "https://twitter.com/" + item.FromName + "/status/" + item.MessageId;
                        }

                        searchRes += this.BindData(item, i, postURL);
                        i++;
                    }
                }
            }
            return(searchRes);
        }
 public IHttpActionResult DeleteUserDetails(string user)
 {
     GroupsRepository _GroupsRepository=new GroupsRepository();
     GroupMembersRepository _GroupMembersRepository = new GroupMembersRepository();
     GroupProfileRepository _GroupProfileRepository = new GroupProfileRepository();
     TaskRepository _TaskRepository = new TaskRepository();
     TaskCommentRepository _TaskCommentRepository = new TaskCommentRepository();
     InboxMessagesRepository _InboxMessagesRepository=new InboxMessagesRepository();
     FacebookAccountRepository _FacebookAccountRepository=new FacebookAccountRepository();
     GoogleAnalyticsAccountRepository _GoogleAnalyticsAccountRepository=new GoogleAnalyticsAccountRepository();
     GooglePlusAccountRepository _GooglePlusAccountRepository=new GooglePlusAccountRepository();
     InstagramAccountRepository _InstagramAccountRepository=new InstagramAccountRepository();
     LinkedInAccountRepository _LinkedInAccountRepository=new LinkedInAccountRepository();
     LinkedinCompanyPageRepository _LinkedinCompanyPageRepository=new LinkedinCompanyPageRepository();
     ScheduledMessageRepository _ScheduledMessageRepository=new ScheduledMessageRepository();
     SocialProfilesRepository _SocialProfilesRepository = new SocialProfilesRepository();
     TwitterAccountRepository _TwitterAccountRepository=new TwitterAccountRepository();
     TumblrAccountRepository _TumblrAccountRepository = new TumblrAccountRepository();
     YoutubeAccountRepository _YoutubeAccountRepository = new YoutubeAccountRepository();
     YoutubeChannelRepository _YoutubeChannelRepository = new YoutubeChannelRepository();
     try
     {
         Domain.Socioboard.Domain.User _User = userrepo.getUserInfoByEmail(user);
         if (_User != null)
         {
             List<Domain.Socioboard.Domain.Groups> lstGroups = _GroupsRepository.getAllGroups(_User.Id);
             foreach (Domain.Socioboard.Domain.Groups item_group in lstGroups)
             {
                 int i = _GroupMembersRepository.DeleteGroupMember(item_group.Id.ToString());
                 int j = _GroupProfileRepository.DeleteAllGroupProfile(item_group.Id);
                 bool rt = _GroupProfileRepository.DeleteGroupReport(item_group.Id);
                 int k = _TaskRepository.DeleteTaskOfGroup(item_group.Id);
             }
             int g = _GroupMembersRepository.DeleteGroupMemberByUserId(user);
             int h = _GroupsRepository.DeleteGroupsByUserid(_User.Id);
             int l = _TaskCommentRepository.DeleteTaskCommentByUserid(_User.Id);
             int m = _InboxMessagesRepository.DeleteInboxMessages(_User.Id);
             int n = _FacebookAccountRepository.DeleteAllFacebookAccount(_User.Id);
             int o = _GoogleAnalyticsAccountRepository.DeleteGoogleAnalyticsAccountByUserid(_User.Id);
             int p = _GooglePlusAccountRepository.DeleteGooglePlusAccountByUserid(_User.Id);
             int q = _InstagramAccountRepository.DeleteInstagramAccountByUserid(_User.Id);
             int r = _LinkedInAccountRepository.DeleteLinkedInAccountByUserid(_User.Id);
             int s = _LinkedinCompanyPageRepository.DeleteLinkedinCompanyPage(_User.Id);
             int t = _ScheduledMessageRepository.DeleteScheduledMessageByUserid(_User.Id);
             int u = _SocialProfilesRepository.DeleteSocialProfileByUserid(_User.Id);
             int v = _TwitterAccountRepository.DeleteTwitterAccountByUserid(_User.Id);
             int w = _TumblrAccountRepository.DeletetumblraccountByUserid(_User.Id);
             int x = _YoutubeAccountRepository.DeleteYoutubeAccount(_User.Id);
             int y = _YoutubeChannelRepository.DeleteYoutubeChannelByUserid(_User.Id);
             int z = userrepo.DeleteUser(_User.Id);
         }
         else {
             return Ok(false);
         }
     }
     catch (Exception ex)
     {
         return BadRequest(ex.StackTrace);
     }
     return Ok(true);
 }
示例#31
0
        public DataSet bindFeedsIntoDataTable(User user, string network)
        {
            Messages mstable = new Messages();
            DataSet  ds      = DataTableGenerator.CreateDataSetForTable(mstable);



            if (!string.IsNullOrEmpty(network))
            {
                /*Facebook region*/
                if (network == "facebook")
                {
                    FacebookAccountRepository fbaccount = new FacebookAccountRepository();
                    FacebookMessageRepository fbmsg     = new FacebookMessageRepository();
                    ArrayList alstfbaccount             = fbaccount.getAllFacebookAccountsOfUser(user.Id);
                    foreach (FacebookAccount item in alstfbaccount)
                    {
                        List <FacebookMessage> lstfbmsg = fbmsg.getAllFacebookMessagesOfUser(user.Id, item.FbUserId);
                        foreach (FacebookMessage facebookmsg in lstfbmsg)
                        {
                            ds.Tables[0].Rows.Add(facebookmsg.ProfileId, "facebook", facebookmsg.FromId, facebookmsg.FromName, facebookmsg.FromProfileUrl, facebookmsg.MessageDate, facebookmsg.Message, facebookmsg.FbComment, facebookmsg.FbLike, facebookmsg.MessageId, facebookmsg.Type);
                        }
                    }
                }
                else if (network == "twitter")
                {
                    TwitterAccountRepository twtaccountrepo = new TwitterAccountRepository();
                    TwitterFeedRepository    twtfeedrepo    = new TwitterFeedRepository();
                    ArrayList alsttwtaccount = twtaccountrepo.getAllTwitterAccountsOfUser(user.Id);
                    foreach (TwitterAccount item in alsttwtaccount)
                    {
                        List <TwitterFeed> lsttwtmsg = twtfeedrepo.getAllTwitterFeedOfUsers(user.Id, item.TwitterUserId);
                        foreach (TwitterFeed twtmsg in lsttwtmsg)
                        {
                            ds.Tables[0].Rows.Add(twtmsg.ProfileId, "twitter", twtmsg.FromId, twtmsg.FromScreenName, twtmsg.FromProfileUrl, twtmsg.FeedDate, twtmsg.Feed, "", "", twtmsg.MessageId, twtmsg.Type);
                        }
                    }
                }
                else if (network == "linkedin")
                {
                    LinkedInAccountRepository liaccountrepo = new LinkedInAccountRepository();
                    LinkedInFeedRepository    lifeedrepo    = new LinkedInFeedRepository();
                    ArrayList alstliaccount = liaccountrepo.getAllLinkedinAccountsOfUser(user.Id);
                    foreach (LinkedInAccount item in alstliaccount)
                    {
                        List <LinkedInFeed> lsttwtmsg = lifeedrepo.getAllLinkedInFeedsOfUser(user.Id, item.LinkedinUserId);
                        foreach (LinkedInFeed limsg in lsttwtmsg)
                        {
                            ds.Tables[0].Rows.Add(limsg.ProfileId, "linkedin", limsg.FromId, limsg.FromName, limsg.FromPicUrl, limsg.FeedsDate, limsg.Feeds, "", "", "", limsg.Type);
                        }
                    }
                }
                else if (network == "instagram")
                {
                    InstagramAccountRepository insAccRepo  = new InstagramAccountRepository();
                    InstagramFeedRepository    insFeedRepo = new InstagramFeedRepository();
                    ArrayList alstlistaccount = insAccRepo.getAllInstagramAccountsOfUser(user.Id);
                    foreach (InstagramAccount item in alstlistaccount)
                    {
                        List <InstagramFeed> lstFeeed = insFeedRepo.getAllInstagramFeedsOfUser(user.Id, item.InstagramId);
                        foreach (InstagramFeed insFeed in lstFeeed)
                        {
                            ds.Tables[0].Rows.Add(insFeed.InstagramId, "instagram", "", "", "", insFeed.FeedDate, insFeed.FeedImageUrl, "", "", insFeed.FeedId, "");
                        }
                    }
                }
            }
            return(ds);
        }
 public string GetAllFacebookAccounts()
 {
     JavaScriptSerializer serializer = new JavaScriptSerializer();
     serializer.MaxJsonLength = 2147483647;
     try
     {
         FacebookAccountRepository objFbRepo = new FacebookAccountRepository();
         List<Domain.Socioboard.Domain.FacebookAccount> lstFBAcc = objFbRepo.GetAllFacebookAccounts();
         return serializer.Serialize(lstFBAcc);
         
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.StackTrace);
         return serializer.Serialize(new List<Domain.Socioboard.Domain.FacebookAccount>());
     }
 }
示例#33
0
 public string ProfilesConnected(string UserId)
 {
     try
     {
         Guid userid = Guid.Parse(UserId);
         SocialProfilesRepository socialRepo      = new SocialProfilesRepository();
         List <SocialProfile>     lstsocioprofile = socialRepo.getAllSocialProfilesOfUser(userid);
         List <profileConnected>  lstProfile      = new List <profileConnected>();
         foreach (SocialProfile sp in lstsocioprofile)
         {
             profileConnected pc = new profileConnected();
             pc.Id            = sp.Id;
             pc.ProfileDate   = sp.ProfileDate;
             pc.ProfileId     = sp.ProfileId;
             pc.ProfileStatus = sp.ProfileStatus;
             pc.ProfileType   = sp.ProfileType;
             pc.UserId        = sp.UserId;
             if (sp.ProfileType == "facebook")
             {
                 try
                 {
                     FacebookAccountRepository objFbAccRepo = new FacebookAccountRepository();
                     FacebookAccount           objFbAcc     = objFbAccRepo.getUserDetails(sp.ProfileId);
                     pc.ProfileName   = objFbAcc.FbUserName;
                     pc.ProfileImgUrl = "http://graph.facebook.com/" + sp.ProfileId + "/picture?type=small";
                 }
                 catch (Exception ex)
                 {
                     Console.WriteLine(ex.StackTrace);
                 }
             }
             else if (sp.ProfileType == "twitter")
             {
                 try
                 {
                     TwitterAccountRepository objTwtAccRepo = new TwitterAccountRepository();
                     TwitterAccount           objTwtAcc     = objTwtAccRepo.getUserInfo(sp.ProfileId);
                     pc.ProfileName   = objTwtAcc.TwitterScreenName;
                     pc.ProfileImgUrl = objTwtAcc.ProfileImageUrl;
                 }
                 catch (Exception ex)
                 {
                     Console.WriteLine(ex.StackTrace);
                 }
             }
             else if (sp.ProfileType == "instagram")
             {
                 try
                 {
                     InstagramAccountRepository objInsAccRepo = new InstagramAccountRepository();
                     InstagramAccount           objInsAcc     = objInsAccRepo.getInstagramAccountById(sp.ProfileId);
                     pc.ProfileName   = objInsAcc.InsUserName;
                     pc.ProfileImgUrl = objInsAcc.ProfileUrl;
                 }
                 catch (Exception ex)
                 {
                     Console.WriteLine(ex.StackTrace);
                 }
             }
             else if (sp.ProfileType == "linkedin")
             {
                 try
                 {
                     LinkedInAccountRepository objLiAccRepo = new LinkedInAccountRepository();
                     LinkedInAccount           objLiAcc     = objLiAccRepo.getLinkedinAccountDetailsById(sp.ProfileId);
                     pc.ProfileName   = objLiAcc.LinkedinUserName;
                     pc.ProfileImgUrl = objLiAcc.ProfileImageUrl;
                 }
                 catch (Exception ex)
                 {
                     Console.WriteLine(ex.StackTrace);
                 }
             }
             else if (sp.ProfileType == "googleplus")
             {
                 try
                 {
                     GooglePlusAccountRepository objGpAccRepo = new GooglePlusAccountRepository();
                     GooglePlusAccount           objGpAcc     = objGpAccRepo.getUserDetails(sp.ProfileId);
                     pc.ProfileName   = objGpAcc.GpUserName;
                     pc.ProfileImgUrl = objGpAcc.GpProfileImage;
                 }
                 catch (Exception ex)
                 {
                     Console.WriteLine(ex.StackTrace);
                 }
             }
             lstProfile.Add(pc);
         }
         return(new JavaScriptSerializer().Serialize(lstProfile));
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.StackTrace);
         return(new JavaScriptSerializer().Serialize("Please Try Again"));
     }
 }
示例#34
0
        public string DiscoverySearchFacebook(string UserId, string keyword)
        {
            List<Domain.Socioboard.Domain.DiscoverySearch> lstDiscoverySearch = new List<Domain.Socioboard.Domain.DiscoverySearch>();
            string profileid = string.Empty;
            try
            {
                //  lstDiscoverySearch = dissearchrepo.GetAllSearchKeywordsByUserId(Guid.Parse(UserId), keyword, "facebook");

                FacebookAccountRepository fbAccRepo = new FacebookAccountRepository();
                ArrayList asltFbAccount = fbAccRepo.getAllFacebookAccounts();
                string accesstoken = string.Empty;

                #region Added Sumit Gupta [27/01/15]
                foreach (Domain.Socioboard.Domain.FacebookAccount item in asltFbAccount)
                {
                    accesstoken = item.AccessToken;
                    if (this.CheckFacebookToken(accesstoken, keyword))
                    {
                        break;
                    }
                } 
                #endregion

                ////Access Token HARD CODED temporarily
                //accesstoken = "CAAKMrAl97iIBAD9MqfWtfjIxwFVteGCLVZBsoHpc1TZCH8Kf3KQuMebkbNYLb282cUTisu6iGZBiZAzzwxWvDhh20vCzs5mZCFZBblZBXu40BQisUjoOCZARUQklHBiK3Cx7DOgdXtbvupC4xJ1VpPjKspwiZBRzNYncjgQAyUqd5sGsXUDHcqKy0UBYkmbfq7QZCFgpyG5icOPeMhRb4TXJaic7UF7B1WHLhw2A5EW0kb3AZDZD";

                string facebookSearchUrl = "https://graph.facebook.com/search?q=" + keyword + " &type=post&access_token=" + accesstoken + "&limit=100";
                var facerequest = (HttpWebRequest)WebRequest.Create(facebookSearchUrl);
                facerequest.Method = "GET";
                string outputface = string.Empty;
                using (var response = facerequest.GetResponse())
                {
                    using (var stream = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding(1252)))
                    {
                        outputface = stream.ReadToEnd();
                    }
                }
                if (!outputface.StartsWith("["))
                    outputface = "[" + outputface + "]";
                JArray facebookSearchResult = JArray.Parse(outputface);
                foreach (var item in facebookSearchResult)
                {
                    var data = item["data"];

                    foreach (var chile in data)
                    {
                        try
                        {
                            objDiscoverySearch = new Domain.Socioboard.Domain.DiscoverySearch();
                            objDiscoverySearch.SearchKeyword = keyword;
                            objDiscoverySearch.Network = "facebook";
                            objDiscoverySearch.Id = Guid.NewGuid();
                            objDiscoverySearch.UserId = Guid.Parse(UserId);

                            if (!dissearchrepo.isKeywordPresentforNetwork(objDiscoverySearch.SearchKeyword, objDiscoverySearch.Network))
                            {
                                dissearchrepo.addNewSearchResult(objDiscoverySearch);
                            }
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }
                        try
                        {
                            Domain.Socioboard.Domain.DiscoverySearch objSearchHistory = new Domain.Socioboard.Domain.DiscoverySearch();
                            objSearchHistory.CreatedTime = DateTime.Parse(chile["created_time"].ToString());
                            objSearchHistory.EntryDate = DateTime.Now;
                            objSearchHistory.FromId = chile["from"]["id"].ToString();
                            try
                            {
                                objSearchHistory.FromName = chile["from"]["name"].ToString();
                            }
                            catch { }
                            try
                            {
                                objSearchHistory.ProfileImageUrl = "http://graph.facebook.com/" + chile["from"]["id"] + "/picture?type=small";
                            }
                            catch { }
                            objSearchHistory.SearchKeyword = keyword;
                            objSearchHistory.Network = "facebook";
                            try
                            {
                                objSearchHistory.Message = chile["message"].ToString();
                            }
                            catch { }
                            try
                            {
                                objSearchHistory.MessageId = chile["id"].ToString();
                            }
                            catch { }
                            objSearchHistory.Id = Guid.NewGuid();
                            objSearchHistory.UserId = Guid.Parse(UserId);
                            lstDiscoverySearch.Add(objSearchHistory);
                        }
                        catch { }
                    }
                }
                return new JavaScriptSerializer().Serialize(lstDiscoverySearch);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
                return new JavaScriptSerializer().Serialize("Please try Again");
            }
        }
示例#35
0
        //public void getPageImpresion(string pageId, Guid UserId, int days)
        //{
        //    try
        //    {
        //        string strAge = "https://graph.facebook.com/" + pageId + "/insights/page_impressions/day";
        //        FacebookClient fb = new FacebookClient();
        //        FacebookAccountRepository fbAccRepo = new FacebookAccountRepository();
        //        FacebookAccount acc = fbAccRepo.getUserDetails(pageId);
        //        fb.AccessToken = acc.AccessToken;
        //        JsonObject outputreg = (JsonObject)fb.Get(strAge);
        //        JArray data = (JArray)JsonConvert.DeserializeObject(outputreg["data"].ToString());

        //        FacebookInsightStats objFbi = new FacebookInsightStats();
        //        FacebookInsightStatsRepository objfbiRepo = new FacebookInsightStatsRepository();
        //        foreach (var item in data)
        //        {
        //            var values = item["values"];
        //            foreach (var age in values)
        //            {
        //                objFbi.EntryDate = DateTime.Now;
        //                objFbi.FbUserId = pageId;
        //                objFbi.Id = Guid.NewGuid();
        //                objFbi.PageImpressionCount = int.Parse(age["value"].ToString());
        //                objFbi.UserId = UserId;
        //                objFbi.CountDate = age["end_time"].ToString();
        //                if (!objfbiRepo.checkFbIPageImprStatsExists(pageId, UserId, age["end_time"].ToString()))
        //                    objfbiRepo.addFacebookInsightStats(objFbi);
        //                else
        //                    objfbiRepo.updateFacebookInsightStats(objFbi);
        //            }
        //        }
        //    }
        //    catch (Exception Err)
        //    {
        //        Console.Write(Err.StackTrace);
        //    }
        //}


        public void getPageImpresion(string pageId, Guid UserId, int days)
        {
            JsonObject outputreg = new JsonObject();

            try
            {
                int    count    = 0;
                string nextpage = string.Empty;
                string prevpage = string.Empty;
                string strAge   = string.Empty;
                if (count == 0)
                {
                    strAge = "https://graph.facebook.com/" + pageId + "/insights/page_impressions/day";
                }
                else
                {
                    strAge = prevpage;
                }
                FacebookClient            fb        = new FacebookClient();
                FacebookAccountRepository fbAccRepo = new FacebookAccountRepository();

                for (int i = 0; i < 11; i++)
                {
                    if (count > 0)
                    {
                        strAge = prevpage;
                    }

                    FacebookAccount acc = fbAccRepo.getUserDetails(pageId);
                    fb.AccessToken = acc.AccessToken;
                    outputreg      = (JsonObject)fb.Get(strAge);
                    JArray data = (JArray)JsonConvert.DeserializeObject(outputreg["data"].ToString());
                    //code written by abhay
                    JObject data1 = (JObject)JsonConvert.DeserializeObject(outputreg["paging"].ToString());
                    if (count == 0)
                    {
                        prevpage = data1["previous"].ToString();
                        nextpage = data1["next"].ToString();
                        //End of block
                        FacebookInsightStats           objFbi     = new FacebookInsightStats();
                        FacebookInsightStatsRepository objfbiRepo = new FacebookInsightStatsRepository();
                        foreach (var item in data)
                        {
                            var values = item["values"];
                            foreach (var age in values)
                            {
                                //objFbi.EntryDate = DateTime.Now;
                                objFbi.EntryDate           = Convert.ToDateTime(age["end_time"].ToString());
                                objFbi.FbUserId            = pageId;
                                objFbi.Id                  = Guid.NewGuid();
                                objFbi.PageImpressionCount = int.Parse(age["value"].ToString());
                                objFbi.UserId              = UserId;
                                objFbi.CountDate           = age["end_time"].ToString();
                                if (!objfbiRepo.checkFbIPageImprStatsExists(pageId, UserId, age["end_time"].ToString()))
                                {
                                    objfbiRepo.addFacebookInsightStats(objFbi);
                                }
                                else
                                {
                                    objfbiRepo.updateFacebookInsightStats(objFbi);
                                }
                            }
                        }
                        count++;
                    }


                    else
                    {
                        count++;
                        prevpage = data1["previous"].ToString();
                        // nextpage = data1["next"].ToString();
                        //End of block
                        FacebookInsightStats           objFbi     = new FacebookInsightStats();
                        FacebookInsightStatsRepository objfbiRepo = new FacebookInsightStatsRepository();
                        foreach (var item in data)
                        {
                            var values = item["values"];
                            foreach (var age in values)
                            {
                                //objFbi.EntryDate = DateTime.Now;
                                objFbi.EntryDate           = Convert.ToDateTime(age["end_time"].ToString());
                                objFbi.FbUserId            = pageId;
                                objFbi.Id                  = Guid.NewGuid();
                                objFbi.PageImpressionCount = int.Parse(age["value"].ToString());
                                objFbi.UserId              = UserId;
                                objFbi.CountDate           = age["end_time"].ToString();
                                if (!objfbiRepo.checkFbIPageImprStatsExists(pageId, UserId, age["end_time"].ToString()))
                                {
                                    objfbiRepo.addFacebookInsightStats(objFbi);
                                }
                                else
                                {
                                    objfbiRepo.updateFacebookInsightStats(objFbi);
                                }
                            }
                        }
                    }
                }
                outputreg = (JsonObject)fb.Get(nextpage);
                JArray  newdata  = (JArray)JsonConvert.DeserializeObject(outputreg["data"].ToString());
                JObject newdata1 = (JObject)JsonConvert.DeserializeObject(outputreg["paging"].ToString());
                FacebookInsightStats           objFbi1     = new FacebookInsightStats();
                FacebookInsightStatsRepository objfbiRepo1 = new FacebookInsightStatsRepository();
                foreach (var item in newdata)
                {
                    var values = item["values"];
                    foreach (var age in values)
                    {
                        //objFbi1.EntryDate = DateTime.Now;
                        objFbi1.EntryDate           = Convert.ToDateTime(age["end_time"].ToString());
                        objFbi1.FbUserId            = pageId;
                        objFbi1.Id                  = Guid.NewGuid();
                        objFbi1.PageImpressionCount = int.Parse(age["value"].ToString());
                        objFbi1.UserId              = UserId;
                        objFbi1.CountDate           = age["end_time"].ToString();
                        if (Convert.ToDateTime(age["end_time"].ToString()) > DateTime.Now)
                        {
                            break;
                        }
                        if (!objfbiRepo1.checkFbIPageImprStatsExists(pageId, UserId, age["end_time"].ToString()))
                        {
                            objfbiRepo1.addFacebookInsightStats(objFbi1);
                        }
                        else
                        {
                            objfbiRepo1.updateFacebookInsightStats(objFbi1);
                        }
                    }
                }
            }
            catch (Exception Err)
            {
                Console.Write(Err.StackTrace);
            }
        }
示例#36
0
        public void getFacebookUserProfile(dynamic data, string accesstoken, long friends, Guid user)
        {
            SocialProfile             socioprofile     = new SocialProfile();
            SocialProfilesRepository  socioprofilerepo = new SocialProfilesRepository();
            FacebookAccount           fbAccount        = new FacebookAccount();
            FacebookAccountRepository fbrepo           = new FacebookAccountRepository();

            try
            {
                try
                {
                    fbAccount.AccessToken = accesstoken;
                }
                catch
                {
                }
                try
                {
                    fbAccount.EmailId = data["email"].ToString();
                }
                catch
                {
                }
                try
                {
                    fbAccount.FbUserId = data["id"].ToString();
                }
                catch
                {
                }

                try
                {
                    fbAccount.ProfileUrl = data["link"].ToString();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);
                }


                try
                {
                    fbAccount.FbUserName = data["name"].ToString();
                }
                catch
                {
                }
                try
                {
                    fbAccount.Friends = Convert.ToInt32(friends);
                }
                catch
                {
                }
                try
                {
                    fbAccount.Id = Guid.NewGuid();
                }
                catch
                {
                }
                fbAccount.IsActive = 1;
                try
                {
                    if (HttpContext.Current.Session["fbSocial"] != null)
                    {
                        if (HttpContext.Current.Session["fbSocial"] == "p")
                        {
                            //FacebookClient fbClient = new FacebookClient(accesstoken);
                            //int fancountPage = 0;
                            //dynamic fancount = fbClient.Get("fql", new { q = " SELECT fan_count FROM page WHERE page_id =" + fbAccount.FbUserId });
                            //foreach (var friend in fancount.data)
                            //{
                            //    fancountPage = friend.fan_count;

                            //}
                            //fbAccount.Friends = Convert.ToInt32(fancountPage);
                            fbAccount.Type = "page";
                        }
                        else
                        {
                            fbAccount.Type = "account";
                        }
                        fbAccount.UserId = user;
                    }

                    if (HttpContext.Current.Session["UserAndGroupsForFacebook"] != null)
                    {
                        try
                        {
                            fbAccount.UserId = user;
                            fbAccount.Type   = "account";
                        }
                        catch (Exception ex)
                        {
                        }
                    }
                }
                catch
                {
                }

                #region unused
                //if (HttpContext.Current.Session["login"] != null)
                //{
                //    if (HttpContext.Current.Session["login"].ToString().Equals("facebook"))
                //    {
                //        User usr = new User();
                //        UserRepository userrepo = new UserRepository();
                //        Registration regObject = new Registration();
                //        usr.AccountType = "free";
                //        usr.CreateDate = DateTime.Now;
                //        usr.ExpiryDate = DateTime.Now.AddMonths(1);
                //        usr.Id = Guid.NewGuid();
                //        usr.UserName = data["name"].ToString();
                //        usr.Password = regObject.MD5Hash(data["name"].ToString());
                //        usr.EmailId = data["email"].ToString();
                //        usr.UserStatus = 1;
                //        if (!userrepo.IsUserExist(data["email"].ToString()))
                //        {
                //            UserRepository.Add(usr);
                //        }
                //    }
                //}
                #endregion
                try
                {
                    socioprofile.UserId = user;
                }
                catch
                {
                }
                try
                {
                    socioprofile.ProfileType = "facebook";
                }
                catch
                {
                }
                try
                {
                    socioprofile.ProfileId = data["id"].ToString();
                }
                catch
                {
                }
                try
                {
                    socioprofile.ProfileStatus = 1;
                }
                catch
                {
                }
                try
                {
                    socioprofile.ProfileDate = DateTime.Now;
                }
                catch
                {
                }
                try
                {
                    socioprofile.Id = Guid.NewGuid();
                }
                catch
                {
                }
                if (HttpContext.Current.Session["fbSocial"] != null)
                {
                    if (HttpContext.Current.Session["fbSocial"] == "p")
                    {
                        HttpContext.Current.Session["fbpagedetail"] = fbAccount;
                    }
                    else
                    {
                        if (!fbrepo.checkFacebookUserExists(fbAccount.FbUserId, user))
                        {
                            fbrepo.addFacebookUser(fbAccount);
                            if (!socioprofilerepo.checkUserProfileExist(socioprofile))
                            {
                                socioprofilerepo.addNewProfileForUser(socioprofile);

                                GroupRepository        objGroupRepository = new GroupRepository();
                                SocioBoard.Domain.Team team = (SocioBoard.Domain.Team)HttpContext.Current.Session["GroupName"];
                                Groups lstDetails           = objGroupRepository.getGroupName(team.GroupId);
                                if (lstDetails.GroupName == "Socioboard")
                                {
                                    TeamMemberProfileRepository objTeamMemberProfileRepository = new TeamMemberProfileRepository();
                                    TeamMemberProfile           teammemberprofile = new TeamMemberProfile();
                                    teammemberprofile.Id               = Guid.NewGuid();
                                    teammemberprofile.TeamId           = team.Id;
                                    teammemberprofile.ProfileId        = fbAccount.FbUserId;
                                    teammemberprofile.ProfileType      = "facebook";
                                    teammemberprofile.StatusUpdateDate = DateTime.Now;

                                    objTeamMemberProfileRepository.addNewTeamMember(teammemberprofile);
                                }
                            }
                            else
                            {
                                socioprofilerepo.updateSocialProfile(socioprofile);
                            }
                        }
                        else
                        {
                            HttpContext.Current.Session["alreadyexist"] = fbAccount;
                            fbrepo.updateFacebookUser(fbAccount);
                            if (!socioprofilerepo.checkUserProfileExist(socioprofile))
                            {
                                socioprofilerepo.addNewProfileForUser(socioprofile);
                            }
                            else
                            {
                                socioprofilerepo.updateSocialProfile(socioprofile);
                            }
                        }
                    }
                }

                if (HttpContext.Current.Session["UserAndGroupsForFacebook"] != null)
                {
                    if (HttpContext.Current.Session["UserAndGroupsForFacebook"].ToString() == "facebook")
                    {
                        try
                        {
                            if (!fbrepo.checkFacebookUserExists(fbAccount.FbUserId, user))
                            {
                                fbrepo.addFacebookUser(fbAccount);
                                if (!socioprofilerepo.checkUserProfileExist(socioprofile))
                                {
                                    socioprofilerepo.addNewProfileForUser(socioprofile);
                                }
                                else
                                {
                                    socioprofilerepo.updateSocialProfile(socioprofile);
                                }
                            }
                            else
                            {
                                fbrepo.updateFacebookUser(fbAccount);
                                if (!socioprofilerepo.checkUserProfileExist(socioprofile))
                                {
                                    socioprofilerepo.addNewProfileForUser(socioprofile);
                                }
                                else
                                {
                                    socioprofilerepo.updateSocialProfile(socioprofile);
                                }
                            }
                            if (HttpContext.Current.Session["GroupName"] != null)
                            {
                                GroupProfile           groupprofile     = new GroupProfile();
                                GroupProfileRepository groupprofilerepo = new GroupProfileRepository();
                                Groups group = (Groups)HttpContext.Current.Session["GroupName"];
                                groupprofile.Id           = Guid.NewGuid();
                                groupprofile.GroupOwnerId = user;
                                groupprofile.ProfileId    = socioprofile.ProfileId;
                                groupprofile.ProfileType  = "facebook";
                                groupprofile.GroupId      = group.Id;
                                groupprofile.EntryDate    = DateTime.Now;
                                if (!groupprofilerepo.checkGroupProfileExists(user, group.Id, groupprofile.ProfileId))
                                {
                                    groupprofilerepo.AddGroupProfile(groupprofile);
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
            }
        }
示例#37
0
        public string DeleteAllUsersByCreateDate(string date)
        {
            int                                i                                     = 0;
            int                                count                                 = 0;
            UserRepository                     objUserRepository                     = new UserRepository();
            List <User>                        lstuser                               = objUserRepository.GetAllUsersByCreateDate(date);
            ArchiveMessageRepository           objArchiveMessageRepository           = new ArchiveMessageRepository();
            DiscoverySearchRepository          objDiscoverySearchRepository          = new DiscoverySearchRepository();
            DraftsRepository                   objDraftsRepository                   = new DraftsRepository();
            FacebookAccountRepository          objFacebookAccountRepository          = new FacebookAccountRepository();
            FacebookFeedRepository             objFacebookFeedRepository             = new FacebookFeedRepository();
            FacebookInsightPostStatsRepository objFacebookInsightPostStatsRepository = new FacebookInsightPostStatsRepository();
            FacebookInsightStatsRepository     objFacebookInsightStatsRepository     = new FacebookInsightStatsRepository();
            FacebookMessageRepository          objFacebookMessageRepository          = new FacebookMessageRepository();
            FacebookStatsRepository            objFacebookStatsRepository            = new FacebookStatsRepository();
            GoogleAnalyticsAccountRepository   objGoogleAnalyticsAccountRepository   = new GoogleAnalyticsAccountRepository();
            GoogleAnalyticsStatsRepository     objGoogleAnalyticsStatsRepository     = new GoogleAnalyticsStatsRepository();
            GooglePlusAccountRepository        objGooglePlusAccountRepository        = new GooglePlusAccountRepository();
            GooglePlusActivitiesRepository     objGooglePlusActivitiesRepository     = new GooglePlusActivitiesRepository();
            GroupProfileRepository             objGroupProfileRepository             = new GroupProfileRepository();
            GroupRepository                    objGroupRepository                    = new GroupRepository();
            InstagramAccountRepository         objInstagramAccountRepository         = new InstagramAccountRepository();
            InstagramCommentRepository         objInstagramCommentRepository         = new InstagramCommentRepository();
            InstagramFeedRepository            objInstagramFeedRepository            = new InstagramFeedRepository();
            LinkedInAccountRepository          objLinkedInAccountRepository          = new LinkedInAccountRepository();
            LinkedInFeedRepository             objLinkedInFeedRepository             = new LinkedInFeedRepository();
            LogRepository                      objLogRepository                      = new LogRepository();
            RssFeedsRepository                 objRssFeedsRepository                 = new RssFeedsRepository();
            RssReaderRepository                objRssReaderRepository                = new RssReaderRepository();
            ScheduledMessageRepository         objScheduledMessageRepository         = new ScheduledMessageRepository();
            SocialProfilesRepository           objSocialProfilesRepository           = new SocialProfilesRepository();
            TaskCommentRepository              objTaskCommentRepository              = new TaskCommentRepository();
            TaskRepository                     objTaskRepository                     = new TaskRepository();
            TeamRepository                     objTeamRepository                     = new TeamRepository();
            TeamMemberProfileRepository        objTeamMemberProfileRepository        = new TeamMemberProfileRepository();
            TwitterAccountRepository           objTwitterAccountRepository           = new TwitterAccountRepository();
            TwitterDirectMessageRepository     objTwitterDirectMessageRepository     = new TwitterDirectMessageRepository();
            TwitterFeedRepository              objTwitterFeedRepository              = new TwitterFeedRepository();
            TwitterMessageRepository           objTwitterMessageRepository           = new TwitterMessageRepository();
            TwitterStatsRepository             objTwitterStatsRepository             = new TwitterStatsRepository();
            UserActivationRepository           objUserActivationRepository           = new UserActivationRepository();
            UserPackageRelationRepository      objUserPackageRelationRepository      = new UserPackageRelationRepository();



            count = lstuser.Count();


            foreach (var item in lstuser)
            {
                i++;
                try
                {
                    if (item.EmailId == "*****@*****.**" || item.EmailId == "*****@*****.**" || item.EmailId == "*****@*****.**" || item.EmailId == "*****@*****.**" || item.EmailId == "*****@*****.**" || item.EmailId == "*****@*****.**" || item.EmailId == "*****@*****.**" || item.EmailId == "*****@*****.**" || item.EmailId == "*****@*****.**" || item.EmailId == "*****@*****.**")
                    {
                    }
                    else
                    {
                        objArchiveMessageRepository.DeleteArchiveMessageByUserid(item.Id);
                        objDiscoverySearchRepository.DeleteDiscoverySearchByUserid(item.Id);
                        objDraftsRepository.DeleteDraftsByUserid(item.Id);
                        objFacebookAccountRepository.DeleteFacebookAccountByUserid(item.Id);
                        objFacebookFeedRepository.DeleteFacebookFeedByUserid(item.Id);
                        objFacebookInsightPostStatsRepository.DeleteFacebookInsightPostStatsByUserid(item.Id);
                        objFacebookInsightStatsRepository.DeleteFacebookInsightStatsByUserid(item.Id);
                        objFacebookMessageRepository.DeleteFacebookMessageByUserid(item.Id);
                        objFacebookStatsRepository.DeleteFacebookStatsByUserid(item.Id);
                        objGoogleAnalyticsAccountRepository.DeleteGoogleAnalyticsAccountByUserid(item.Id);
                        objGoogleAnalyticsStatsRepository.DeleteGoogleAnalyticsStatsByUserid(item.Id);
                        objGooglePlusAccountRepository.DeleteGooglePlusAccountByUserid(item.Id);
                        objGooglePlusActivitiesRepository.DeleteGooglePlusActivitiesByUserid(item.Id);
                        objGroupProfileRepository.DeleteGroupProfileByUserid(item.Id);
                        objGroupRepository.DeleteGroupsByUserid(item.Id);
                        objInstagramAccountRepository.DeleteInstagramAccountByUserid(item.Id);
                        objInstagramCommentRepository.DeleteInstagramCommentByUserid(item.Id);
                        objInstagramFeedRepository.DeleteInstagramFeedByUserid(item.Id);
                        objLinkedInAccountRepository.DeleteLinkedInAccountByUserid(item.Id);
                        objLinkedInFeedRepository.DeleteLinkedInFeedByUserid(item.Id);
                        objLogRepository.DeleteLogByUserid(item.Id);
                        objRssFeedsRepository.DeleteRssFeedsByUserid(item.Id);
                        objRssReaderRepository.DeleteRssReaderByUserid(item.Id);
                        objScheduledMessageRepository.DeleteScheduledMessageByUserid(item.Id);
                        objSocialProfilesRepository.DeleteSocialProfileByUserid(item.Id);
                        objTaskCommentRepository.DeleteTaskCommentByUserid(item.Id);
                        objTaskRepository.DeleteTasksByUserid(item.Id);
                        objTeamRepository.DeleteTeamByUserid(item.Id);
                        objTeamMemberProfileRepository.DeleteTeamMemberProfileByUserid(item.Id);
                        objTwitterAccountRepository.DeleteTwitterAccountByUserid(item.Id);
                        objTwitterDirectMessageRepository.DeleteTwitterDirectMessagesByUserid(item.Id);
                        objTwitterFeedRepository.DeleteTwitterFeedByUserid(item.Id);
                        objTwitterMessageRepository.DeleteTwitterMessageByUserid(item.Id);
                        objTwitterStatsRepository.DeleteTwitterStatsByUserid(item.Id);
                        objUserActivationRepository.DeleteUserActivationByUserid(item.Id);
                        objUserPackageRelationRepository.DeleteuserPackageRelationByUserid(item.Id);
                        objUserRepository.DeleteUserByUserid(item.Id);
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
            return(i + " " + count);
        }
        public IHttpActionResult GetGroupFacebookProfiles(string GroupId, string UserId) 
        {
            Guid grpId = Guid.Empty;
            try
            {
                grpId = Guid.Parse(GroupId);
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message);
                logger.Error(ex.StackTrace);
                return BadRequest("Invalid GroupId");
            }
            List<Domain.Socioboard.Domain.GroupProfile> lstGroupProfiles = grpProfilesRepo.GetAllGroupProfilesByProfileType(grpId, "facebook");
            List<Domain.Socioboard.Domain.FacebookAccount> lstFbAccounts = new List<Domain.Socioboard.Domain.FacebookAccount>();
            FacebookAccountRepository objFacebookAccountRepository = new FacebookAccountRepository();

            foreach (var profile in lstGroupProfiles) 
            {
                try
                {
                    //if (objFacebookAccountRepository.checkFacebookUserExists(profile.ProfileId, Guid.Parse(UserId)))
                    //{
                    //    lstFbAccounts.Add(objFacebookAccountRepository.getFacebookAccountDetailsById(profile.ProfileId, Guid.Parse(UserId)));
                    //}
                    //else
                    //{
                        lstFbAccounts.Add(objFacebookAccountRepository.getFacebookAccountDetailsById(profile.ProfileId));
                    //}
                }
                catch (Exception ex)
                {
                    logger.Error(ex.Message);
                    logger.Error(ex.StackTrace);
                }
            }
            return Ok(lstFbAccounts);
        }
示例#39
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (!IsPostBack)
                {
                    User user = (User)Session["LoggedUser"];

                    if (user == null)
                    {
                        Response.Redirect("/Default.aspx");
                    }

                    FacebookAccountRepository   objFbRepo = new FacebookAccountRepository();
                    TeamMemberProfileRepository objTeamMemberProfileRepository = new TeamMemberProfileRepository();

                    SocioBoard.Domain.Team   team        = (SocioBoard.Domain.Team)Session["GroupName"];
                    List <TeamMemberProfile> allprofiles = objTeamMemberProfileRepository.getTeamMemberProfileData(team.Id);

                    //List<FacebookAccount>arrfbPrfile=new List<FacebookAccount>();
                    ArrayList arrfbPrfile = new ArrayList();
                    try
                    {
                        foreach (TeamMemberProfile item in allprofiles)
                        {
                            //fbpId += item.ProfileId + ',';
                            FacebookAccount arrfbProfile = objFbRepo.getAllFbAccountDetail(item.ProfileId);
                            if (arrfbProfile.FbUserId != null)
                            {
                                arrfbPrfile.Add(arrfbProfile);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.Message);
                    }
                    //fbpId = fbpId.Substring(0, fbpId.Length - 1);

                    //List<FacebookAccount> arrfbProfile = objFbRepo.getAllFbAccountDetail(fbpId);

                    //ArrayList arrfbProfile = fbAccRepo.getAllFacebookPagesOfUser(user.Id);
                    spandiv.InnerHtml = "from " + DateTime.Now.AddDays(-15).ToShortDateString() + "-" + DateTime.Now.ToShortDateString();
                    try
                    {
                        foreach (FacebookAccount item in arrfbPrfile)
                        {
                            string imgPath = "http://graph.facebook.com/" + item.FbUserId + "/picture";
                            fbUser                 = fbUser + "<div  class=\"teitter\"><ul><li><a id=\"facebook_connect\" onclick='getProfilefbGraph(\"" + item.FbUserId + "\",\"" + item.FbUserName + "\",\"" + imgPath + "\",\"" + item.AccessToken + "\")'><span style=\"float:left;margin: 3px 0 0 5px;\" >" + item.FbUserName + "</span></a></li></ul></div>";
                            fbProfileId            = item.FbUserId;
                            Session["fbprofileId"] = fbProfileId;
                            divPageName.InnerHtml  = item.FbUserName;
                            fbProfileImg.Src       = "http://graph.facebook.com/" + item.FbUserId + "/picture";
                            strfbAccess            = item.AccessToken;
                            Session["acstknfnpg"]  = strfbAccess;
                        }
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.Message);
                    }
                    if (arrfbPrfile.Count > 0)
                    {
                        try
                        {
                            getAllGroupsOnHome.InnerHtml = fbUser;
                            strFbAgeArray     = fbiHelper.getLikesByGenderAge(fbProfileId, 15);
                            strPageImpression = fbiHelper.getPageImressions(fbProfileId, 15);
                            strLocationArray  = fbiHelper.getLocationInsight(fbProfileId, 15);
                            strstoriesArray   = fbiHelper.getStoriesCount(fbProfileId, 15);
                            //divpost.InnerHtml = fbiHelper.getPostDetails(fbProfileId, user.Id, 15);
                            likeunlikedate = objfbstatsHelper.getlikeUnlike(fbProfileId, 15);

                            FacebookClient fb = new FacebookClient();
                            fb.AccessToken = strfbAccess;

                            dynamic pagelikes = fb.Get(fbProfileId);
                            divPageLikes.InnerHtml = pagelikes.likes.ToString() + " Total Likes " + pagelikes.talking_about_count + " People talking about this.";
                            spanTalking.InnerHtml  = pagelikes.talking_about_count.ToString();

                            string fanpost = PageFeed(strfbAccess, fbProfileId);
                            divpost.InnerHtml = fanpost;
                        }
                        catch (Exception ex)
                        {
                            logger.Error(ex.Message);
                        }
                    }
                }
            }
            catch (Exception Err)
            {
                logger.Error(Err.Message);
                Response.Write(Err.Message);
            }
        }
        public string AddAllFbPagePost(string userid, string accesstoken, string profileid)
        {
            logger.Error("AddFbPagePost");
            logger.Error(userid + ", " + accesstoken + " , " + profileid);
            string ret = string.Empty;
            Api.Socioboard.Services.FacebookAccount _FacebookAccount = new FacebookAccount();
            Domain.Socioboard.Domain.FacebookAccount _facebookAccount = new Domain.Socioboard.Domain.FacebookAccount();

            try
            {
                string _nextPageDataUrl = string.Empty;
                FacebookClient fb = new FacebookClient();

                if (string.IsNullOrEmpty(accesstoken))
                {
                    try
                    {
                        _facebookAccount = (Domain.Socioboard.Domain.FacebookAccount)(new System.Web.Script.Serialization.JavaScriptSerializer().Deserialize(_FacebookAccount.getFacebookAccountDetailsById(userid, profileid), typeof(Domain.Socioboard.Domain.FacebookAccount)));

                        _facebookAccount = new Domain.Socioboard.Domain.FacebookAccount();
                        Api.Socioboard.Services.FacebookAccountRepository _FacebookAccountRepository = new FacebookAccountRepository();

                        System.Collections.ArrayList lstFacebookAccounts = _FacebookAccountRepository.getAllFacebookAccounts();

                        Random _random = new Random();
                        var rnum = _random.Next(0, lstFacebookAccounts.Count - 1);
                        _facebookAccount = (Domain.Socioboard.Domain.FacebookAccount)lstFacebookAccounts[rnum];
                        fb.AccessToken = _facebookAccount.AccessToken;
                    }
                    catch { };
                }
                else
                    fb.AccessToken = accesstoken;


                dynamic post = null;
                try
                {
                    post = fb.Get("v2.0/" + profileid + "/posts");
                }
                catch (Exception ex)
                {
                    logger.Error("profileid +posts");
                    logger.Error(ex.Message);
                    logger.Error(ex.StackTrace);
                }
            //dynamic post1 = fb.Get("me/posts");
            _NextPageDataUrl:

                if (!string.IsNullOrEmpty(_nextPageDataUrl))
                {
                    fb = new FacebookClient();
                    post = fb.Get(_nextPageDataUrl);
                    _nextPageDataUrl = string.Empty;
                }
                foreach (var item in post["data"])
                {
                    #region
                    objFbPagePost.Id = Guid.NewGuid();
                    objFbPagePost.UserId = Guid.Parse(userid);
                    objFbPagePost.PageId = profileid;
                    objFbPagePost.PostId = item["id"].ToString();

                    objFbPagePost.PostDate = Convert.ToDateTime(item["created_time"]);
                    objFbPagePost.EntryDate = DateTime.Now;
                    try
                    {
                        objFbPagePost.Post = item["message"].ToString();
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                    try
                    {
                        objFbPagePost.PictureUrl = item["picture"].ToString();
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }

                    try
                    {
                        objFbPagePost.LinkUrl = item["link"].ToString();
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                    try
                    {
                        objFbPagePost.IconUrl = item["icon"].ToString();
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                    try
                    {
                        objFbPagePost.StatusType = item["status_type"].ToString();
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                    try
                    {
                        objFbPagePost.Type = item["type"].ToString();
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                    try
                    {
                        objFbPagePost.FromId = item["from"]["id"];

                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                    try
                    {
                        objFbPagePost.FromName = item["from"]["name"];

                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                    try
                    {
                        dynamic like = fb.Get("v2.0/" + objFbPagePost.PostId + "/likes?summary=1&limit=0");

                        objFbPagePost.Likes = Convert.ToInt32(like["summary"]["total_count"]);

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

                    try
                    {
                        dynamic comment = fb.Get("v2.0/" + objFbPagePost.PostId + "/comments?summary=1&limit=0");

                        objFbPagePost.Comments = Convert.ToInt32(comment["summary"]["total_count"]);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                    try
                    {
                        dynamic shares = fb.Get("v2.0/" + objFbPagePost.PostId);
                        objFbPagePost.Shares = Convert.ToInt32(shares["shares"]["count"]);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                        logger.Error(ex.StackTrace);
                    }
                    try
                    {
                        if (!objFbPagePostRepository.IsPostExist(objFbPagePost))
                            objFbPagePostRepository.addFbPagePost(objFbPagePost);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                        logger.Error(ex.StackTrace);
                    }

                    try
                    {
                        AddAllFbPagePostComments(objFbPagePost.PostId, accesstoken, userid);
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.StackTrace);
                        Console.WriteLine(ex.StackTrace);
                    }
                    try
                    {
                        AddAllFbPagePostLiker(objFbPagePost.PostId, accesstoken, userid);
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.StackTrace);
                        Console.WriteLine(ex.StackTrace);
                    }
                    #endregion

                }


                try
                {
                    _nextPageDataUrl = post["paging"]["next"];
                    if (!string.IsNullOrEmpty(_nextPageDataUrl))
                        goto _NextPageDataUrl;

                }
                catch { };


            }
            catch (Exception ex)
            {
                logger.Error(ex.StackTrace);
                Console.WriteLine(ex.StackTrace);
            }
            return ret;
        }
 public IHttpActionResult GetGroupFacebookPage(string GroupId, string UserId)
 {
     Guid grpId = Guid.Empty;
     try
     {
         grpId = Guid.Parse(GroupId);
     }
     catch (Exception ex)
     {
         logger.Error(ex.Message);
         logger.Error(ex.StackTrace);
         return BadRequest("Invalid GroupId");
     }
     List<Domain.Socioboard.Domain.GroupProfile> lstGroupProfiles = grpProfilesRepo.GetAllGroupProfilesByProfileType(grpId, "facebook_page");
     List<Domain.Socioboard.Domain.FacebookAccount> lstFacebookAccount =new List<Domain.Socioboard.Domain.FacebookAccount>();
     FacebookAccountRepository _FacebookAccountRepository = new FacebookAccountRepository();
     foreach (var profile in lstGroupProfiles)
     {
         try
         {
             Domain.Socioboard.Domain.FacebookAccount _FacebookAccount = _FacebookAccountRepository.getFacebookAccountDetailsById(profile.ProfileId, Guid.Parse(UserId));
             if (_FacebookAccount.Type.ToLower()=="page" && !string.IsNullOrEmpty(_FacebookAccount.AccessToken))
             {
                 lstFacebookAccount.Add(_FacebookAccount);
             }
         }
         catch (Exception ex)
         {
             logger.Error(ex.Message);
             logger.Error(ex.StackTrace);
         }
     }
     return Ok(lstFacebookAccount);
 }
 public string GetAllFacebookAccounts()
 {
     try
     {
         FacebookAccountRepository objFbRepo = new FacebookAccountRepository();
         ArrayList lstFBAcc = objFbRepo.getAllFacebookAccounts();
         return new JavaScriptSerializer().Serialize(lstFBAcc);
         
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.StackTrace);
         return "Something Went Wrong";
     }
 }
示例#43
0
        public void ProcessRequest()
        {
            TeamRepository objTeamRepository = new TeamRepository();
            TeamMemberProfileRepository objTeamMemberProfileRepository = new TeamMemberProfileRepository();
            FacebookAccountRepository   fbaccountrepo    = new FacebookAccountRepository();
            TwitterAccountRepository    twtaccountrepo   = new TwitterAccountRepository();
            LinkedInAccountRepository   linkedaccrepo    = new LinkedInAccountRepository();
            InstagramAccountRepository  instagramrepo    = new InstagramAccountRepository();
            GroupProfileRepository      groupprofilerepo = new GroupProfileRepository();
            BusinessSettingRepository   objbsnsrepo      = new BusinessSettingRepository();
            TumblrAccountRepository     tumblrrepo       = new TumblrAccountRepository();



            User user = (User)Session["LoggedUser"];

            if (Request.QueryString["op"] != null)
            {
                if (Request.QueryString["op"] == "SaveGroupName")
                {
                    string          groupName = Request.QueryString["groupname"];
                    GroupRepository grouprepo = new GroupRepository();
                    Groups          group     = new Groups();
                    group.Id        = Guid.NewGuid();
                    group.GroupName = groupName;
                    group.UserId    = user.Id;
                    group.EntryDate = DateTime.Now;

                    if (!grouprepo.checkGroupExists(user.Id, groupName))
                    {
                        grouprepo.AddGroup(group);
                        Groups grou = grouprepo.getGroupDetails(user.Id, groupName);
                        Session["GroupName"] = grou;
                    }
                    else
                    {
                        Groups grou = grouprepo.getGroupDetails(user.Id, groupName);
                        Session["GroupName"] = grou;
                    }
                }
                else if (Request.QueryString["op"] == "bindGroupProfiles")
                {
                    string bindprofiles = string.Empty;
                    Guid   groupid      = Guid.Parse(Request.QueryString["groupId"]);
                    Session["GroupId"] = groupid;
                    GroupProfileRepository groupprofilesrepo = new GroupProfileRepository();
                    List <GroupProfile>    lstgroupprofile   = groupprofilesrepo.getAllGroupProfiles(user.Id, groupid);
                    foreach (GroupProfile item in lstgroupprofile)
                    {
                        if (item.ProfileType == "facebook")
                        {
                            FacebookAccount account = fbaccountrepo.getFacebookAccountDetailsById(item.ProfileId, user.Id);
                            if (account != null)
                            {
                                bindprofiles += "<div id=\"facebook_" + item.ProfileId + "\" class=\"ws_conct\"> <span class=\"img\"><img width=\"48\" height=\"48\" src=\"http://graph.facebook.com/" + item.ProfileId + "/picture?type=small\" alt=\"\"><i><img width=\"16\" height=\"16\" src=\"../Contents/img/fb_icon.png\" alt=\"\"></i></span><div class=\"fourfifth\">" +
                                                "<div class=\"location-container\">" + account.FbUserName + "</div><span onclick=\"AddProfileInInviteTeamMember('" + account.FbUserId + "','" + groupid + "','" + item.ProfileType + "')\" class=\"add remove\">+</span><span onclick=\"RemoveProfileFromGroup('" + item.ProfileId + "')\" class=\"add remove\">✖</span></div></div>";
                            }
                        }
                        else if (item.ProfileType == "twitter")
                        {
                            TwitterAccount twtaccount    = twtaccountrepo.getUserInformation(user.Id, item.ProfileId);
                            string         profileimgurl = string.Empty;
                            if (twtaccount != null)
                            {
                                if (twtaccount.ProfileImageUrl == string.Empty)
                                {
                                    profileimgurl = "../../Contents/img/blank_img.png";
                                }
                                else
                                {
                                    profileimgurl = twtaccount.ProfileImageUrl;
                                }

                                bindprofiles +=
                                    "<div id=\"twitter_" + item.ProfileId + "\" class=\"ws_conct active\"> <span class=\"img\"><img width=\"48\" height=\"48\" src=\"" + profileimgurl + "\" alt=\"\"><i><img width=\"16\" height=\"16\" src=\"../Contents/img/twticon.png\" alt=\"\"></i></span><div class=\"fourfifth\">" +
                                    "<div class=\"location-container\">" + twtaccount.TwitterScreenName + "</div><span onclick=\"AddProfileInInviteTeamMember('" + twtaccount.TwitterUserId + "','" + groupid + "','" + item.ProfileType + "')\" class=\"add remove\">+</span><span onclick=\"RemoveProfileFromGroup('" + item.ProfileId + "')\"  class=\"add remove\">✖</span></div></div>";
                            }
                        }
                        else if (item.ProfileType == "linkedin")
                        {
                            LinkedInAccount linkedaccount = linkedaccrepo.getUserInformation(user.Id, item.ProfileId);
                            string          profileimgurl = string.Empty;
                            if (linkedaccount != null)
                            {
                                if (linkedaccount.ProfileUrl == string.Empty)
                                {
                                    profileimgurl = "../../Contents/img/blank_img.png";
                                }
                                else
                                {
                                    profileimgurl = linkedaccount.ProfileImageUrl;
                                }
                                bindprofiles += "<div id=\"linkedin_" + item.ProfileId + "\" class=\"ws_conct active\"><span class=\"img\"><img width=\"48\" height=\"48\" alt=\"\" src=\"" + profileimgurl + "\" ><i>" +
                                                "<img width=\"16\" height=\"16\" alt=\"\" src=\"../Contents/img/link_icon.png\"></i></span>" +
                                                "<div class=\"fourfifth\"><div class=\"location-container\">" + linkedaccount.LinkedinUserName + "</div>" +
                                                "<span onclick=\"AddProfileInInviteTeamMember('" + linkedaccount.LinkedinUserId + "','" + groupid + "','" + item.ProfileType + "')\" class=\"add remove\">+</span><span onclick=\"RemoveProfileFromGroup('" + item.ProfileId + "')\" class=\"add remove\">✖</span></div></div>";
                            }
                        }

                        else if (item.ProfileType == "tumblr")
                        {
                            TumblrAccount tumblraccount = tumblrrepo.getTumblrAccountDetailsById(item.ProfileId, user.Id);
                            string        profileimgurl = string.Empty;
                            if (tumblraccount != null)
                            {
                                if (tumblraccount.tblrProfilePicUrl == string.Empty)
                                {
                                    profileimgurl = "../../Contents/img/blank_img.png";
                                }
                                else
                                {
                                    profileimgurl = "http://api.tumblr.com/v2/blog/" + tumblraccount.tblrUserName + ".tumblr.com/avatar";
                                }
                                bindprofiles += "<div id=\"tumblr_" + item.ProfileId + "\" class=\"ws_conct active\"><span class=\"img\"><img width=\"48\" height=\"48\" alt=\"\" src=\"http://api.tumblr.com/v2/blog/" + tumblraccount.tblrUserName + ".tumblr.com/avatar\" ><i>" +
                                                "<img width=\"16\" height=\"16\" alt=\"\" src=\"../Contents/img/tumblr.png\"></i></span>" +
                                                "<div class=\"fourfifth\"><div class=\"location-container\">" + tumblraccount.tblrUserName + "</div>" +
                                                "<span onclick=\"AddProfileInInviteTeamMember('" + tumblraccount.tblrUserName + "','" + groupid + "','" + item.ProfileType + "')\" class=\"add remove\">+</span><span onclick=\"RemoveProfileFromGroup('" + item.ProfileId + "')\" class=\"add remove\">✖</span></div></div>";
                            }
                        }



                        else if (item.ProfileType == "instagram")
                        {
                            string profileimgurl = string.Empty;

                            InstagramAccount instaaccount = instagramrepo.getInstagramAccountDetailsById(item.ProfileId, user.Id);
                            if (instaaccount != null)
                            {
                                if (instaaccount.ProfileUrl == string.Empty)
                                {
                                    profileimgurl = "../../Contents/img/blank_img.png";
                                }
                                else
                                {
                                    profileimgurl = instaaccount.ProfileUrl;
                                }

                                bindprofiles += "<div id=\"instagram_" + item.ProfileId + "\" class=\"ws_conct active\"><span class=\"img\"><img width=\"48\" height=\"48\" src=\"" + profileimgurl + "\" alt=\"\"><i>" +
                                                "<img width=\"16\" height=\"16\" alt=\"\" src=\"../Contents/img/instagram_24X24.png\"></i></span><div class=\"fourfifth\"><div class=\"location-container\">" + instaaccount.InsUserName + "</div>" +
                                                "<span onclick=\"AddProfileInInviteTeamMember('" + instaaccount.InstagramId + "','" + groupid + "','" + item.ProfileType + "')\" class=\"add remove\">+</span><span onclick=\"RemoveProfileFromGroup('" + item.ProfileId + "')\" class=\"add remove\">✖</span></div></div>";
                            }
                        }
                    }
                    Response.Write(bindprofiles);
                }
                else if (Request.QueryString["op"] == "deleteGroupName")
                {
                    Guid groupid = Guid.Parse(Request.QueryString["groupId"]);

                    GroupRepository grouprepo = new GroupRepository();
                    grouprepo.DeleteGroup(groupid);
                    int count = groupprofilerepo.DeleteAllGroupProfile(groupid);
                    int cnt   = objbsnsrepo.DeleteBusinessSettingByUserid(groupid);

                    List <Team> objTeamId = objTeamRepository.getAllDetailsUserEmail(groupid);
                    foreach (Team item in objTeamId)
                    {
                        int deteleTeamMember = objTeamMemberProfileRepository.deleteTeamMember(item.Id);
                    }
                    int deleteTeam = objTeamRepository.deleteGroupRelatedTeam(groupid);
                }
                else if (Request.QueryString["op"] == "addProfilestoGroup")
                {
                    string       network      = Request.QueryString["network"];
                    string       id           = Request.QueryString["profileid"];
                    Guid         groupid      = (Guid)Session["GroupId"];
                    GroupProfile groupprofile = new GroupProfile();
                    groupprofile.EntryDate    = DateTime.Now;
                    groupprofile.GroupId      = groupid;
                    groupprofile.Id           = Guid.NewGuid();
                    groupprofile.ProfileId    = id;
                    groupprofile.ProfileType  = network;
                    groupprofile.GroupOwnerId = user.Id;

                    GroupProfileRepository grouprepo = new GroupProfileRepository();

                    if (!grouprepo.checkGroupProfileExists(user.Id, groupid, id))
                    {
                        grouprepo.AddGroupProfile(groupprofile);
                    }

                    Response.Write(groupid);
                }
                else if (Request.QueryString["op"] == "deleteGroupProfiles")
                {
                    Guid groupid = (Guid)Session["GroupId"];
                    try
                    {
                        string profileid = Request.QueryString["profileid"];
                        GroupProfileRepository grouprepo = new GroupProfileRepository();
                        grouprepo.DeleteGroupProfile(user.Id, profileid, groupid);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                    Response.Write(groupid);
                }

                if (Request.QueryString["op"] == "GetInviteMember")
                {
                    string bindprofiles  = string.Empty;
                    string profileimgurl = string.Empty;

                    try
                    {
                        string gp      = Request.QueryString["groupId"];
                        Guid   GroupId = Guid.Parse(gp);
                        // TeamRepository objTeamRepository = new TeamRepository();
                        List <Team> objTeam = objTeamRepository.getAllDetailsUserEmail(GroupId);

                        if (objTeam.Count != 0)
                        {
                            foreach (Team item in objTeam)
                            {
                                UserRepository objUserRepository = new UserRepository();
                                User           ObjUserDetails    = objUserRepository.getUserInfoByEmail(item.EmailId);
                                if (ObjUserDetails != null)
                                {
                                    if (string.IsNullOrEmpty(ObjUserDetails.ProfileUrl))
                                    {
                                        profileimgurl = "../../Contents/img/blank_img.png";
                                    }
                                    else
                                    {
                                        profileimgurl = ObjUserDetails.ProfileUrl;
                                    }

                                    bindprofiles += "<div style=\"float:left; margin-right:18%\"id=\"" + item.Id + "\">" +
                                                    "<div style=\"float:left\"><span class=\"img\"><img width=\"48\" height=\"48\" src=\"" + profileimgurl + "\" alt=\"\"></span>" +
                                                    "</div><div style=\"float:left\" class=\"fourfifth\"><div style=\"font-size:small \">" + ObjUserDetails.UserName + "</div> </div><div style=\"float:left;margin-left:3px\" onclick=\"ShowInviteMemberProfileDetails('" + GroupId + "','" + ObjUserDetails.EmailId + "','" + user.Id + "')\"><input class=\"abc\" type=\"radio\" name=\"sex\" value=" + item.Id + "></div>" +
                                                    "<span onclick=\"RemoveInviteMemberFromGroup('" + item.Id + "')\" style=\"margin-left:25px;font-size:small;cursor:pointer;position: absolute; margin-top: 28px;margin-left:10px\">x</span></div>";

                                    //bindprofiles += "<div id=\"" + item.Id + "\" class=\"ws_conct active\"> <span class=\"img\"><img width=\"48\" height=\"48\" src=\"" + profileimgurl + "\" alt=\"\"><i><img width=\"16\" height=\"16\" src=\"../Contents/img/twticon.png\" alt=\"\"></i></span><div class=\"fourfifth\">" +
                                    //  "<div class=\"location-container\">" + ObjUserDetails.UserName + "</div><span class=\"add remove\" onclick=\"ShowInviteMemberProfileDetails('" + GroupId + "','" + ObjUserDetails.EmailId + "','" + user.Id + "')\"><input class=\"abc\" type=\"radio\" name=\"sex\" value=" + item.Id + "></span><span onclick=\"RemoveInviteMemberFromGroup('" + item.Id + "')\"  class=\"add remove\">✖</span></div></div>";
                                }
                            }
                        }

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

                if (Request.QueryString["op"] == "RemoveInviteMemberFromGroup")
                {
                    if (!string.IsNullOrEmpty(Request.QueryString["Id"]))
                    {
                        try
                        {
                            string ide            = Request.QueryString["Id"];
                            Guid   id             = Guid.Parse(ide);
                            int    deleteTeam     = objTeamRepository.deleteinviteteamMember(id);
                            int    deleteProfiles = objTeamMemberProfileRepository.DeleteTeamMemberProfileByTeamId(id);
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }
                    }
                }

                //modified by hozefa 4-7-2014
                if (Request.QueryString["op"] == "ShowInviteMemberProfileDetails")
                {
                    string bindprofiles = string.Empty;
                    string gpId         = Request.QueryString["groupId"];
                    Guid   gpid         = Guid.Parse(gpId);
                    string emailId      = Request.QueryString["emailid"];
                    string userId       = Request.QueryString["userid"];

                    Team teamdata = objTeamRepository.getAllDetails(gpid, emailId);

                    List <TeamMemberProfile> objTeamMemProfile = objTeamMemberProfileRepository.getAllTeamMemberProfilesOfTeam(teamdata.Id);
                    try
                    {
                        foreach (TeamMemberProfile item in objTeamMemProfile)
                        {
                            if (item.ProfileType == "facebook")
                            {
                                FacebookAccount account = fbaccountrepo.getFacebookAccountDetailsById(item.ProfileId);
                                if (account != null)
                                {
                                    bindprofiles += "<div id=\"item\" style=\"float:left;width:170px;margin-top:6px\"  id=\"facebook_" + item.ProfileId + "\"><div style=\"float:left\"<span class=\"img\">" +
                                                    "<img width=\"48\" height=\"48\" src=\"http://graph.facebook.com/" + item.ProfileId + "/picture?type=small\" alt=\"\"></img><i><img style=\"margin-left:-18px\" width=\"16\" height=\"16\" src=\"../Contents/img/fb_icon.png\" alt=\"\"></img></i>" +
                                                    "</span></div><div style=\"float:left\"><div style=\"font-size:small\">" + account.FbUserName + "</div></div>" +
                                                    "<span  onclick=\"RemoveInviteMemberProfileFromTeamMember('" + teamdata.Id + "','" + item.ProfileId + "','" + gpId + "','" + emailId + "','" + userId + "')\" style=\"margin-left:25px;font-size:small;cursor:pointer;position: absolute; margin-top: 28px;margin-left:10px\">x</span></div>";
                                }
                            }
                            else if (item.ProfileType == "twitter")
                            {
                                TwitterAccount twtaccount    = twtaccountrepo.getUserInformation(item.ProfileId);
                                string         profileimgurl = string.Empty;
                                if (twtaccount != null)
                                {
                                    if (twtaccount.ProfileImageUrl == string.Empty)
                                    {
                                        profileimgurl = "../../Contents/img/blank_img.png";
                                    }
                                    else
                                    {
                                        profileimgurl = twtaccount.ProfileImageUrl;
                                    }

                                    bindprofiles += "<div id=\"item\" style=\"float:left; width:170px;margin-top:6px\"   id=\"twitter_" + item.ProfileId + "\"><div style=\"float:left\"<span class=\"img\">" +
                                                    "<img width=\"48\" height=\"48\" src=\"" + profileimgurl + "\" alt=\"\"></img><i><img style=\"margin-left:-18px\" width=\"16\" height=\"16\" src=\"../Contents/img/twticon.png\" alt=\"\"></img></i>" +
                                                    "</span></div><div style=\"float:left\"><div style=\"font-size:small\">" + twtaccount.TwitterScreenName + "</div></div>" +
                                                    "<span onclick=\"RemoveInviteMemberProfileFromTeamMember('" + teamdata.Id + "','" + item.ProfileId + "','" + gpId + "','" + emailId + "','" + userId + "')\" style=\"margin-left:25px;font-size:small;cursor:pointer;position: absolute; margin-top: 28px;margin-left:10px\">x</span></div>";
                                }
                            }

                            else if (item.ProfileType == "linkedin")
                            {
                                LinkedInAccount linkedaccount = linkedaccrepo.getUserInformation(item.ProfileId);
                                string          profileimgurl = string.Empty;
                                if (linkedaccount != null)
                                {
                                    if (linkedaccount.ProfileUrl == string.Empty)
                                    {
                                        profileimgurl = "../../Contents/img/blank_img.png";
                                    }
                                    else
                                    {
                                        profileimgurl = linkedaccount.ProfileImageUrl;
                                    }

                                    bindprofiles += "<div id=\"item\" style=\"float:left;width:170px;margin-top:6px\"   id=\"linkedin_" + item.ProfileId + "\"><div style=\"float:left\"<span class=\"img\">" +
                                                    "<img width=\"48\" height=\"48\" src=\"" + profileimgurl + "\" alt=\"\"></img><i><img style=\"margin-left:-18px\" width=\"16\" height=\"16\" src=\"../Contents/img/link_icon.png\" alt=\"\"></img></i>" +
                                                    "</span></div><div style=\"float:left\"><div style=\"font-size:small\">" + linkedaccount.LinkedinUserName + "</div></div>" +
                                                    "<span onclick=\"RemoveInviteMemberProfileFromTeamMember('" + teamdata.Id + "','" + item.ProfileId + "','" + gpId + "','" + emailId + "','" + userId + "')\" style=\"margin-left:25px;font-size:small;cursor:pointer;position: absolute; margin-top: 28px;margin-left:10px\">x</span></div>";
                                }
                            }

                            else if (item.ProfileType == "instagram")
                            {
                                string profileimgurl = string.Empty;

                                InstagramAccount instaaccount = instagramrepo.getInstagramAccountDetailsById(item.ProfileId);
                                if (instaaccount != null)
                                {
                                    if (instaaccount.ProfileUrl == string.Empty)
                                    {
                                        profileimgurl = "../../Contents/img/blank_img.png";
                                    }
                                    else
                                    {
                                        profileimgurl = instaaccount.ProfileUrl;
                                    }

                                    bindprofiles += "<div id=\"item\" style=\"float:left;width:170px; margin-top:6px\"   id=\"instagram_" + item.ProfileId + "\"><div style=\"float:left\"<span class=\"img\">" +
                                                    "<img width=\"48\" height=\"48\" src=\"" + profileimgurl + "\" alt=\"\"></img><i><img style=\"margin-left:-18px\" width=\"16\" height=\"16\" src=\"../Contents/img/instagram_24X24.png\" alt=\"\"></img></i>" +
                                                    "</span></div><div style=\"float:left\"><div style=\"font-size:small\">" + instaaccount.InsUserName + "</div></div>" +
                                                    "<span onclick=\"RemoveInviteMemberProfileFromTeamMember('" + teamdata.Id + "','" + item.ProfileId + "','" + gpId + "','" + emailId + "','" + userId + "')\" style=\"margin-left:25px;font-size:small;cursor:pointer;position: absolute; margin-top: 28px;margin-left:10px\">x</span></div>";
                                }
                            }



                            else if (item.ProfileType == "tumblr")
                            {
                                string profileimgurl = string.Empty;

                                TumblrAccount tumblraccount = tumblrrepo.getTumblrAccountDetailsById(item.ProfileId);
                                if (tumblraccount != null)
                                {
                                    if (tumblraccount.tblrProfilePicUrl == string.Empty)
                                    {
                                        profileimgurl = "../../Contents/img/blank_img.png";
                                    }
                                    else
                                    {
                                        profileimgurl = "http://api.tumblr.com/v2/blog/" + tumblraccount.tblrUserName + ".tumblr.com/avatar";
                                    }

                                    bindprofiles += "<div id=\"item\" style=\"float:left;width:170px; margin-top:6px\"   id=\"tumblr_" + item.ProfileId + "\"><div style=\"float:left\"<span class=\"img\">" +
                                                    "<img width=\"48\" height=\"48\" src=\"" + profileimgurl + "\" alt=\"\"></img><i><img style=\"margin-left:-18px\" width=\"16\" height=\"16\" src=\"../Contents/img/tumblr.png\" alt=\"\"></img></i>" +
                                                    "</span></div><div style=\"float:left\"><div style=\"font-size:small\">" + tumblraccount.tblrUserName + "</div></div>" +
                                                    "<span onclick=\"RemoveInviteMemberProfileFromTeamMember('" + teamdata.Id + "','" + item.ProfileId + "','" + gpId + "','" + emailId + "','" + userId + "')\" style=\"margin-left:25px;font-size:small;cursor:pointer;position: absolute; margin-top: 28px;margin-left:10px\">x</span></div>";
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }

                    Response.Write(bindprofiles);
                }


                if (Request.QueryString["op"] == "RemoveInviteMemberProfileFromTeamMember")
                {
                    string profileId = Request.QueryString["ProfileId"];
                    Guid   teamid    = Guid.Parse(Request.QueryString["TeamId"]);
                    try
                    {
                        int deleteTeamMembeProfile = objTeamMemberProfileRepository.DeleteTeamMemberProfileByTeamIdProfileId(profileId, teamid);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                }

                if (Request.QueryString["op"] == "AddProfileInInviteTeamMember")
                {
                    try
                    {
                        string            EmailId = string.Empty;
                        string            Result  = string.Empty;
                        TeamMemberProfile objteam = new TeamMemberProfile();
                        objteam.ProfileId   = Request.QueryString["Profileid"];
                        objteam.ProfileType = Request.QueryString["Profiletype"];
                        string GrpId = Request.QueryString["Groupid"];
                        Guid   grpid = Guid.Parse(GrpId);

                        TeamRepository objTeamrepo = new TeamRepository();
                        Team           team        = new Team();
                        Guid           id          = Guid.NewGuid();
                        objteam.Id = id;
                        string teamid = Request.QueryString["Teamid"];
                        objteam.TeamId           = Guid.Parse(teamid);
                        objteam.StatusUpdateDate = DateTime.Now;
                        objteam.Status           = 0;
                        team    = objTeamrepo.getAllDetailsByTeamID(objteam.TeamId, grpid);
                        EmailId = team.EmailId;
                        try
                        {
                            if (!objTeamMemberProfileRepository.checkTeamMemberProfile(objteam.TeamId, objteam.ProfileId))
                            {
                                objTeamMemberProfileRepository.addNewTeamMember(objteam);
                                Result = "Success";
                            }
                            else
                            {
                                //ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('This Profile Already Added.');", true);
                                Result = "Fail";
                            }
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }
                        Response.Write(Result + "_" + EmailId);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }
                }
            }
        }