public IHttpActionResult AddGroupProfile(string profileid, string network, string groupid, string userid,string profileName) 
        {
            try 
            {
                Domain.Socioboard.Domain.GroupProfile objGroupProfile = new Domain.Socioboard.Domain.GroupProfile();
                objGroupProfile = new Domain.Socioboard.Domain.GroupProfile();
                objGroupProfile.Id = Guid.NewGuid();
                objGroupProfile.GroupId = Guid.Parse(groupid);
                objGroupProfile.ProfileId = profileid;
                objGroupProfile.GroupOwnerId = Guid.Parse(userid);
                objGroupProfile.ProfileType = network;
                objGroupProfile.EntryDate = DateTime.UtcNow;
                objGroupProfile.ProfileName = profileName;
                grpProfilesRepo.AddGroupProfile(objGroupProfile);
                return Ok("GroupProfile Added");
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message);
                logger.Error(ex.StackTrace);
                return BadRequest("Invalid Inputs");
            }
            

        }
Пример #2
0
        public IHttpActionResult TeamProfileTOGroupProfileService()
        {
            TeamRepository              Tr   = new TeamRepository();
            GroupProfileRepository      GpR  = new GroupProfileRepository();
            TeamMemberProfileRepository TMPR = new TeamMemberProfileRepository();

            List <Domain.Socioboard.Domain.Team> lstTeam = Tr.GetAllActiveTeam();

            foreach (var item in lstTeam)
            {
                List <Domain.Socioboard.Domain.TeamMemberProfile> lstTeamMemberprofiles = TMPR.getAllTeamMemberProfilesOfTeam(item.Id);
                foreach (var memProfile in lstTeamMemberprofiles)
                {
                    Domain.Socioboard.Domain.GroupProfile grpProfile = new Domain.Socioboard.Domain.GroupProfile();
                    grpProfile.Id           = Guid.NewGuid();
                    grpProfile.EntryDate    = memProfile.StatusUpdateDate;
                    grpProfile.GroupId      = item.GroupId;
                    grpProfile.GroupOwnerId = item.UserId;
                    grpProfile.ProfileId    = memProfile.ProfileId;
                    grpProfile.ProfileName  = memProfile.ProfileName;
                    grpProfile.ProfileType  = memProfile.ProfileType;
                    grpProfile.ProfilePic   = memProfile.ProfilePicUrl;
                    if (!GpR.checkProfileExistsingroup(grpProfile.GroupId, grpProfile.ProfileId))
                    {
                        GpR.AddGroupProfile(grpProfile);
                    }
                }
            }

            return(Ok());
        }
        public string AddProfileToGroup(string profileid, string network, string groupid, string userid)
        {
            objGroupProfile = new Domain.Socioboard.Domain.GroupProfile();
            objGroupProfile.Id = Guid.NewGuid();
            objGroupProfile.GroupId = Guid.Parse(groupid);
            objGroupProfile.ProfileId = profileid;
            objGroupProfile.GroupOwnerId = Guid.Parse(userid);
            objGroupProfile.ProfileType = network;
            objGroupProfile.EntryDate = DateTime.Now;
            objGroupProfileRepository.AddGroupProfile(objGroupProfile);

            //Domain.Socioboard.Domain.TeamMemberProfile _TeamMemberProfile = objTeamMemberProfileRepository.GetMemberdata(profileid, network);

            //objTeam = new Domain.Socioboard.Domain.Team();
            //objTeam = objTeamRepository.GetAllTeam(Guid.Parse(groupid), Guid.Parse(userid));
            //objTeamMemberProfile = new Domain.Socioboard.Domain.TeamMemberProfile();
            //objTeamMemberProfile.Id = Guid.NewGuid();
            //objTeamMemberProfile.TeamId = objTeam.Id;
            //objTeamMemberProfile.ProfileId = profileid;
            //objTeamMemberProfile.ProfileType = network;
            //objTeamMemberProfile.Status = 1;
            //objTeamMemberProfile.ProfilePicUrl = _TeamMemberProfile.ProfilePicUrl;
            //objTeamMemberProfile.ProfileName = _TeamMemberProfile.ProfileName;
            //objTeamMemberProfile.StatusUpdateDate = DateTime.Now;
            //objTeamMemberProfileRepository.addNewTeamMember(objTeamMemberProfile);
            return "";
        }
Пример #4
0
        public string AddProfileToGroup(string profileid, string network, string groupid, string userid)
        {
            objGroupProfile              = new Domain.Socioboard.Domain.GroupProfile();
            objGroupProfile.Id           = Guid.NewGuid();
            objGroupProfile.GroupId      = Guid.Parse(groupid);
            objGroupProfile.ProfileId    = profileid;
            objGroupProfile.GroupOwnerId = Guid.Parse(userid);
            objGroupProfile.ProfileType  = network;
            objGroupProfile.EntryDate    = DateTime.Now;
            objGroupProfileRepository.AddGroupProfile(objGroupProfile);

            //Domain.Socioboard.Domain.TeamMemberProfile _TeamMemberProfile = objTeamMemberProfileRepository.GetMemberdata(profileid, network);

            //objTeam = new Domain.Socioboard.Domain.Team();
            //objTeam = objTeamRepository.GetAllTeam(Guid.Parse(groupid), Guid.Parse(userid));
            //objTeamMemberProfile = new Domain.Socioboard.Domain.TeamMemberProfile();
            //objTeamMemberProfile.Id = Guid.NewGuid();
            //objTeamMemberProfile.TeamId = objTeam.Id;
            //objTeamMemberProfile.ProfileId = profileid;
            //objTeamMemberProfile.ProfileType = network;
            //objTeamMemberProfile.Status = 1;
            //objTeamMemberProfile.ProfilePicUrl = _TeamMemberProfile.ProfilePicUrl;
            //objTeamMemberProfile.ProfileName = _TeamMemberProfile.ProfileName;
            //objTeamMemberProfile.StatusUpdateDate = DateTime.Now;
            //objTeamMemberProfileRepository.addNewTeamMember(objTeamMemberProfile);
            return("");
        }
Пример #5
0
 public IHttpActionResult AddGroupProfile(string profileid, string network, string groupid, string userid, string profileName)
 {
     try
     {
         Domain.Socioboard.Domain.GroupProfile objGroupProfile = new Domain.Socioboard.Domain.GroupProfile();
         objGroupProfile              = new Domain.Socioboard.Domain.GroupProfile();
         objGroupProfile.Id           = Guid.NewGuid();
         objGroupProfile.GroupId      = Guid.Parse(groupid);
         objGroupProfile.ProfileId    = profileid;
         objGroupProfile.GroupOwnerId = Guid.Parse(userid);
         objGroupProfile.ProfileType  = network;
         objGroupProfile.EntryDate    = DateTime.UtcNow;
         objGroupProfile.ProfileName  = profileName;
         grpProfilesRepo.AddGroupProfile(objGroupProfile);
         return(Ok("GroupProfile Added"));
     }
     catch (Exception ex)
     {
         logger.Error(ex.Message);
         logger.Error(ex.StackTrace);
         return(BadRequest("Invalid Inputs"));
     }
 }
        public string AddTwitterAccountFromTweetBoard(string UserId, string GroupId, string OAuthToken, string OAuthSecret, string ProfileId, string ScreenName, string FollowingCount, string FollowerCount, string ProfilePicUrl)
        {
            if (objUserRepository.IsUserExist(Guid.Parse(UserId)))
            {
                if (objTwitterAccountRepository.checkTwitterUserExists(ProfileId, Guid.Parse(UserId)))
                {
                    Domain.Socioboard.Domain.TwitterAccount _TwitterAccount = new Domain.Socioboard.Domain.TwitterAccount();
                    _TwitterAccount.Id                = Guid.NewGuid();
                    _TwitterAccount.IsActive          = true;
                    _TwitterAccount.UserId            = Guid.Parse(UserId);
                    _TwitterAccount.TwitterUserId     = ProfileId;
                    _TwitterAccount.TwitterScreenName = ScreenName;
                    _TwitterAccount.OAuthToken        = OAuthToken;
                    _TwitterAccount.OAuthSecret       = OAuthSecret;
                    _TwitterAccount.ProfileImageUrl   = ProfilePicUrl;
                    objTwitterAccountRepository.addTwitterkUser(_TwitterAccount);

                    //Domain.Socioboard.Domain.Team _Team = objTeamRepository.GetTeamByGroupId(Guid.Parse(GroupId));
                    //Domain.Socioboard.Domain.TeamMemberProfile _TeamMemberProfile = new Domain.Socioboard.Domain.TeamMemberProfile();
                    //if (objTeamMemberProfileRepository.checkTeamMemberProfile(_Team.Id, ProfileId))
                    //{
                    //    _TeamMemberProfile.Id = Guid.NewGuid();
                    //    _TeamMemberProfile.TeamId = _Team.Id;
                    //    _TeamMemberProfile.ProfileId = ProfileId;
                    //    _TeamMemberProfile.ProfileName = ScreenName;
                    //    _TeamMemberProfile.Status = 1;
                    //    _TeamMemberProfile.ProfileType = "twitter";
                    //    _TeamMemberProfile.StatusUpdateDate = DateTime.Now;
                    //    _TeamMemberProfile.ProfilePicUrl = ProfilePicUrl;
                    //    objTeamMemberProfileRepository.addNewTeamMember(_TeamMemberProfile);
                    //}

                    if (!grpProfileRepo.checkProfileExistsingroup(Guid.Parse(GroupId), ProfileId))
                    {
                        Domain.Socioboard.Domain.GroupProfile grpProfile = new Domain.Socioboard.Domain.GroupProfile();
                        grpProfile.Id           = Guid.NewGuid();
                        grpProfile.EntryDate    = DateTime.UtcNow;
                        grpProfile.GroupId      = Guid.Parse(GroupId);
                        grpProfile.GroupOwnerId = Guid.Parse(UserId);
                        grpProfile.ProfileId    = ProfileId;
                        grpProfile.ProfileType  = "twitter";
                        grpProfileRepo.AddGroupProfile(grpProfile);
                    }



                    Domain.Socioboard.Domain.SocialProfile objSocialProfile = new Domain.Socioboard.Domain.SocialProfile();
                    objSocialProfile.Id            = Guid.NewGuid();
                    objSocialProfile.ProfileType   = "twitter";
                    objSocialProfile.ProfileId     = ProfileId;
                    objSocialProfile.UserId        = Guid.Parse(UserId);
                    objSocialProfile.ProfileDate   = DateTime.Now;
                    objSocialProfile.ProfileStatus = 1;
                    if (!objSocialProfilesRepository.checkUserProfileExist(objSocialProfile))
                    {
                        objSocialProfilesRepository.addNewProfileForUser(objSocialProfile);
                    }
                    return("account added");
                }
                else
                {
                    return("account already exist");
                }
            }
            else
            {
                return("user not exist");
            }
        }
Пример #7
0
        public string AddGPlusAccount(string client_id, string client_secret, string redirect_uri, string UserId, string GroupId, string code)
        {
            string ret = string.Empty;
            string objRefresh = string.Empty;
            string refreshToken = string.Empty;
            string access_token = string.Empty;
            try
            {

                oAuthTokenGPlus ObjoAuthTokenGPlus = new oAuthTokenGPlus();
                oAuthToken objToken = new oAuthToken();
                objToken.ConsumerKey = client_id;
                objToken.ConsumerSecret = client_secret;

                try
                {
                    objRefresh = ObjoAuthTokenGPlus.GetRefreshToken(code, client_id, client_secret, redirect_uri);
                    logger.Error("vikash: ObjoAuthTokenGPlus()");
                }
                catch (Exception ex) { }
                JObject objaccesstoken = JObject.Parse(objRefresh);

                try
                {
                    refreshToken = objaccesstoken["refresh_token"].ToString();

                }
                catch (Exception ex)
                {
                    access_token = objaccesstoken["access_token"].ToString();
                    ObjoAuthTokenGPlus.RevokeToken(access_token);
                    Console.WriteLine(ex.StackTrace);
                    ret = "Refresh Token Not Found";
                    return ret;

                }

                try
                {
                    access_token = objaccesstoken["access_token"].ToString();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);

                }

                JArray userinfo = new JArray();
                try
                {
                    userinfo = objToken.GetUserInfo("self", access_token.ToString());
                }
                catch (Exception ex)
                {
                }
                Domain.Socioboard.Domain.GooglePlusAccount _GooglePlusAccount = new Domain.Socioboard.Domain.GooglePlusAccount();
                foreach (var itemuserinfo in userinfo)
                {

                    try
                    {
                        _GooglePlusAccount.Id = Guid.NewGuid();
                        _GooglePlusAccount.GpUserId = itemuserinfo["id"].ToString();
                        _GooglePlusAccount.GpUserName = itemuserinfo["name"].ToString();
                        _GooglePlusAccount.GpProfileImage = itemuserinfo["picture"].ToString();
                        _GooglePlusAccount.IsActive = 1;
                        _GooglePlusAccount.ProfileType = "gplus";
                        _GooglePlusAccount.AccessToken = access_token;
                        _GooglePlusAccount.RefreshToken = refreshToken;
                        _GooglePlusAccount.EmailId = itemuserinfo["email"].ToString();
                        _GooglePlusAccount.UserId = Guid.Parse(UserId);
                        _GooglePlusAccount.EntryDate = DateTime.Now;


                    }
                    catch (Exception ex)
                    {
                        logger.Error("AddGPlusAccount => GooglePlusAccount =>" + ex.Message);
                    }

                }
                #region Get_InYourCircles
                try
                {
                    string _InyourCircles = ObjoAuthTokenGPlus.APIWebRequestToGetUserInfo(Globals.strGetPeopleList.Replace("[userId]", _GooglePlusAccount.GpUserId).Replace("[collection]", "visible") + "?key=" + ConfigurationManager.AppSettings["Api_Key"].ToString(), access_token);
                    JObject J_InyourCircles = JObject.Parse(_InyourCircles);
                    _GooglePlusAccount.InYourCircles = Convert.ToInt32(J_InyourCircles["totalItems"].ToString());
                }
                catch (Exception ex)
                {
                    _GooglePlusAccount.InYourCircles = 0;
                }
                #endregion

                #region Get_HaveYouInCircles
                try
                {
                    string _HaveYouInCircles = ObjoAuthTokenGPlus.APIWebRequestToGetUserInfo(Globals.strGetPeopleProfile + _GooglePlusAccount.GpUserId + "?key=" + ConfigurationManager.AppSettings["Api_Key"].ToString(), access_token);
                    JObject J_HaveYouInCircles = JObject.Parse(_HaveYouInCircles);
                    _GooglePlusAccount.HaveYouInCircles = Convert.ToInt32(J_HaveYouInCircles["circledByCount"].ToString());
                }
                catch (Exception ex)
                {
                    _GooglePlusAccount.HaveYouInCircles = 0;
                }
                #endregion

                #region Add GPlusAccount
                if (!objGooglePlusAccountRepository.checkGooglePlusUserExists(_GooglePlusAccount.GpUserId, _GooglePlusAccount.UserId))
                {
                    objGooglePlusAccountRepository.addGooglePlusUser(_GooglePlusAccount);
                }
                
                #region Add TeamMemberProfile
                //Domain.Socioboard.Domain.Team objTeam = objTeamRepository.GetTeamByGroupId(Guid.Parse(GroupId));
                //Domain.Socioboard.Domain.TeamMemberProfile objTeamMemberProfile = new Domain.Socioboard.Domain.TeamMemberProfile();
                //objTeamMemberProfile.Id = Guid.NewGuid();
                //objTeamMemberProfile.TeamId = objTeam.Id;
                //objTeamMemberProfile.Status = 1;
                //objTeamMemberProfile.ProfileType = "gplus";
                //objTeamMemberProfile.StatusUpdateDate = DateTime.Now;
                //objTeamMemberProfile.ProfileId = _GooglePlusAccount.GpUserId;
                //objTeamMemberProfile.ProfilePicUrl = _GooglePlusAccount.GpProfileImage;
                //objTeamMemberProfile.ProfileName = _GooglePlusAccount.GpUserName;


                Domain.Socioboard.Domain.GroupProfile grpProfile = new Domain.Socioboard.Domain.GroupProfile();
                grpProfile.Id = Guid.NewGuid();
                grpProfile.EntryDate = DateTime.UtcNow;
                grpProfile.GroupId = Guid.Parse(GroupId);
                grpProfile.GroupOwnerId = Guid.Parse(UserId);
                grpProfile.ProfileId = _GooglePlusAccount.GpUserId;
                grpProfile.ProfileType = "gplus";
                grpProfile.ProfileName = _GooglePlusAccount.GpUserName;
                grpProfile.ProfilePic = _GooglePlusAccount.GpProfileImage;
               
                #endregion
                #region SocialProfile
                Domain.Socioboard.Domain.SocialProfile objSocialProfile = new Domain.Socioboard.Domain.SocialProfile();
                objSocialProfile.Id = Guid.NewGuid();
                objSocialProfile.ProfileType = "gplus";
                objSocialProfile.ProfileId = _GooglePlusAccount.GpUserId;
                objSocialProfile.UserId = Guid.Parse(UserId);
                objSocialProfile.ProfileDate = DateTime.Now;
                objSocialProfile.ProfileStatus = 1;
                if (!objSocialProfilesRepository.checkUserProfileExist(objSocialProfile))
                {
                    //objTeamMemberProfileRepository.addNewTeamMember(objTeamMemberProfile);
                    grpProfileRepo.AddGroupProfile(grpProfile);

                    objSocialProfilesRepository.addNewProfileForUser(objSocialProfile);
                    ret = "Account Added Successfully";
                }
                else
                {
                    ret = "Account already Exist !";
                }
                #endregion
                #endregion
                GetUserActivities(UserId, _GooglePlusAccount.GpUserId, access_token,1);
                return new JavaScriptSerializer().Serialize(_GooglePlusAccount);
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message);
                return "";
            }

        }
        public string AddAnalyticsProfiles(string GAProfiles, string UserId, string GroupId)
        {
            try
            {
                Analytics _Analytics = new Analytics();
                List<Domain.Socioboard.Helper.GoogleAnalyticsProfiles> lstGoogleAnalyticsProfiles = (List<Domain.Socioboard.Helper.GoogleAnalyticsProfiles>)new JavaScriptSerializer().Deserialize(GAProfiles, typeof(List<Domain.Socioboard.Helper.GoogleAnalyticsProfiles>));
                Domain.Socioboard.Domain.GoogleAnalyticsAccount _GoogleAnalyticsAccount;
                foreach (var item in lstGoogleAnalyticsProfiles)
                {
                    try
                    {
                        _GoogleAnalyticsAccount = new Domain.Socioboard.Domain.GoogleAnalyticsAccount();
                        _GoogleAnalyticsAccount.UserId = Guid.Parse(UserId);
                        _GoogleAnalyticsAccount.EmailId = item.EmailId;
                        _GoogleAnalyticsAccount.GaAccountId = item.AccountId;
                        _GoogleAnalyticsAccount.GaAccountName = item.AccountName;
                        _GoogleAnalyticsAccount.GaWebPropertyId = item.WebPropertyId;
                        _GoogleAnalyticsAccount.GaProfileId = item.ProfileId;
                        _GoogleAnalyticsAccount.GaProfileName = item.ProfileName;
                        _GoogleAnalyticsAccount.AccessToken = item.AccessToken;
                        _GoogleAnalyticsAccount.RefreshToken = item.RefreshToken;
                        _GoogleAnalyticsAccount.WebsiteUrl = item.WebsiteUrl;
                        string visits = string.Empty;
                        string pageviews = string.Empty;
                        try
                        {
                            string analytics = _Analytics.getAnalyticsData(item.ProfileId, "ga:visits,ga:pageviews", DateTime.UtcNow.AddDays(-7).ToString("yyyy-MM-dd"), DateTime.UtcNow.ToString("yyyy-MM-dd"), item.AccessToken);
                            JObject JData = JObject.Parse(analytics);
                            visits = JData["totalsForAllResults"]["ga:visits"].ToString();
                            pageviews = JData["totalsForAllResults"]["ga:pageviews"].ToString();
                        }
                        catch (Exception ex)
                        {
                            visits = "0";
                            pageviews = "0";
                        }
                        _GoogleAnalyticsAccount.Views = Double.Parse(pageviews);
                        _GoogleAnalyticsAccount.Visits = Double.Parse(visits);
                        _GoogleAnalyticsAccount.ProfilePicUrl = ConfigurationManager.AppSettings["DomainName"] + "/Themes/" + ConfigurationManager.AppSettings["DefaultGroupName"] + "/Contents/img/analytics_img.png";
                        _GoogleAnalyticsAccount.IsActive = true;
                        _GoogleAnalyticsAccount.EntryDate = DateTime.UtcNow;
                        if (!_GoogleAnalyticsAccountRepository.checkGoogelAnalyticsUserExists(item.ProfileId, item.AccountId, Guid.Parse(UserId)))
                        {
                            _GoogleAnalyticsAccountRepository.Add(_GoogleAnalyticsAccount);
                        }
                        #region  TeamMemberProfile
                        Domain.Socioboard.Domain.Team objTeam = objTeamRepository.GetTeamByGroupId(Guid.Parse(GroupId));
                        if (!grpProfileRepo.checkProfileExistsingroup(Guid.Parse(GroupId), item.ProfileId))
                        {
                            //Domain.Socioboard.Domain.TeamMemberProfile objTeamMemberProfile = new Domain.Socioboard.Domain.TeamMemberProfile();
                            //objTeamMemberProfile.ProfileId = item.ProfileId;
                            //objTeamMemberProfile.ProfileName = item.ProfileName;
                            //objTeamMemberProfile.ProfilePicUrl = ConfigurationManager.AppSettings["DomainName"] + "/Themes/Socioboard/Contents/img/analytics_img.png";
                            //objTeamMemberProfile.ProfileType = "googleanalytics";
                            //objTeamMemberProfile.Status = 1;
                            //objTeamMemberProfile.StatusUpdateDate = DateTime.Now;
                            //objTeamMemberProfile.TeamId = objTeam.Id;
                            //objTeamMemberProfileRepository.addNewTeamMember(objTeamMemberProfile);


                            Domain.Socioboard.Domain.GroupProfile grpProfile = new Domain.Socioboard.Domain.GroupProfile();
                            grpProfile.Id = Guid.NewGuid();
                            grpProfile.EntryDate = DateTime.UtcNow;
                            grpProfile.GroupId = Guid.Parse(GroupId);
                            grpProfile.GroupOwnerId = Guid.Parse(UserId);
                            grpProfile.ProfileId = item.ProfileId;
                            grpProfile.ProfileType = "googleanalytics";
                            grpProfile.ProfileName = item.ProfileName;
                            grpProfile.ProfilePic = ConfigurationManager.AppSettings["DomainName"] + "/Themes/" + ConfigurationManager.AppSettings["DefaultGroupName"] + "/Contents/img/analytics_img.png";
                            grpProfileRepo.AddGroupProfile(grpProfile);
                        }
                        #endregion
                        #region SocialProfile
                        Domain.Socioboard.Domain.SocialProfile objSocialProfile = new Domain.Socioboard.Domain.SocialProfile();
                        objSocialProfile.ProfileType = "googleanalytics";
                        objSocialProfile.ProfileId = item.ProfileId;
                        objSocialProfile.UserId = Guid.Parse(UserId);
                        objSocialProfile.ProfileDate = DateTime.Now;
                        objSocialProfile.ProfileStatus = 1;
                        if (!objSocialProfilesRepository.checkUserProfileExist(objSocialProfile))
                        {
                            objSocialProfilesRepository.addNewProfileForUser(objSocialProfile);
                        }
                        #endregion
                    }
                    catch (Exception ex)
                    {
                        logger.Error("AddAnalyticsProfiles = > " + ex.Message);
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error("AddAnalyticsProfiles = > " + ex.Message);
            }
            return "added successfully";
        }
        public IHttpActionResult TeamProfileTOGroupProfileService() 
        {
            TeamRepository Tr = new TeamRepository();
                GroupProfileRepository GpR = new GroupProfileRepository();
            TeamMemberProfileRepository TMPR = new TeamMemberProfileRepository();

            List<Domain.Socioboard.Domain.Team> lstTeam = Tr.GetAllActiveTeam();
            foreach(var item in lstTeam)
            {
                List<Domain.Socioboard.Domain.TeamMemberProfile> lstTeamMemberprofiles = TMPR.getAllTeamMemberProfilesOfTeam(item.Id);
                foreach (var memProfile in lstTeamMemberprofiles) 
                {
                    Domain.Socioboard.Domain.GroupProfile grpProfile = new Domain.Socioboard.Domain.GroupProfile();
                    grpProfile.Id = Guid.NewGuid();
                    grpProfile.EntryDate = memProfile.StatusUpdateDate;
                    grpProfile.GroupId = item.GroupId;
                    grpProfile.GroupOwnerId = item.UserId;
                    grpProfile.ProfileId = memProfile.ProfileId;
                    grpProfile.ProfileName = memProfile.ProfileName;
                    grpProfile.ProfileType = memProfile.ProfileType;
                    grpProfile.ProfilePic = memProfile.ProfilePicUrl;
                    if (!GpR.checkProfileExistsingroup(grpProfile.GroupId, grpProfile.ProfileId)) 
                    {
                        GpR.AddGroupProfile(grpProfile);
                    }
                }

            }

            return Ok();
        }
Пример #10
0
        public string AddGPlusAccount(string client_id, string client_secret, string redirect_uri, string UserId, string GroupId, string code)
        {
            string ret          = string.Empty;
            string objRefresh   = string.Empty;
            string refreshToken = string.Empty;
            string access_token = string.Empty;

            try
            {
                oAuthTokenGPlus ObjoAuthTokenGPlus = new oAuthTokenGPlus();
                oAuthToken      objToken           = new oAuthToken();
                objToken.ConsumerKey    = client_id;
                objToken.ConsumerSecret = client_secret;

                try
                {
                    objRefresh = ObjoAuthTokenGPlus.GetRefreshToken(code, client_id, client_secret, redirect_uri);
                    logger.Error("vikash: ObjoAuthTokenGPlus()");
                }
                catch (Exception ex) { }
                JObject objaccesstoken = JObject.Parse(objRefresh);

                try
                {
                    refreshToken = objaccesstoken["refresh_token"].ToString();
                }
                catch (Exception ex)
                {
                    access_token = objaccesstoken["access_token"].ToString();
                    ObjoAuthTokenGPlus.RevokeToken(access_token);
                    Console.WriteLine(ex.StackTrace);
                    ret = "Refresh Token Not Found";
                    return(ret);
                }

                try
                {
                    access_token = objaccesstoken["access_token"].ToString();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);
                }

                JArray userinfo = new JArray();
                try
                {
                    userinfo = objToken.GetUserInfo("self", access_token.ToString());
                }
                catch (Exception ex)
                {
                }
                Domain.Socioboard.Domain.GooglePlusAccount _GooglePlusAccount = new Domain.Socioboard.Domain.GooglePlusAccount();
                foreach (var itemuserinfo in userinfo)
                {
                    try
                    {
                        _GooglePlusAccount.Id             = Guid.NewGuid();
                        _GooglePlusAccount.GpUserId       = itemuserinfo["id"].ToString();
                        _GooglePlusAccount.GpUserName     = itemuserinfo["name"].ToString();
                        _GooglePlusAccount.GpProfileImage = itemuserinfo["picture"].ToString();
                        _GooglePlusAccount.IsActive       = 1;
                        _GooglePlusAccount.ProfileType    = "gplus";
                        _GooglePlusAccount.AccessToken    = access_token;
                        _GooglePlusAccount.RefreshToken   = refreshToken;
                        _GooglePlusAccount.EmailId        = itemuserinfo["email"].ToString();
                        _GooglePlusAccount.UserId         = Guid.Parse(UserId);
                        _GooglePlusAccount.EntryDate      = DateTime.Now;
                    }
                    catch (Exception ex)
                    {
                        logger.Error("AddGPlusAccount => GooglePlusAccount =>" + ex.Message);
                    }
                }
                #region Get_InYourCircles
                try
                {
                    string  _InyourCircles  = ObjoAuthTokenGPlus.APIWebRequestToGetUserInfo(Globals.strGetPeopleList.Replace("[userId]", _GooglePlusAccount.GpUserId).Replace("[collection]", "visible") + "?key=" + ConfigurationManager.AppSettings["Api_Key"].ToString(), access_token);
                    JObject J_InyourCircles = JObject.Parse(_InyourCircles);
                    _GooglePlusAccount.InYourCircles = Convert.ToInt32(J_InyourCircles["totalItems"].ToString());
                }
                catch (Exception ex)
                {
                    _GooglePlusAccount.InYourCircles = 0;
                }
                #endregion

                #region Get_HaveYouInCircles
                try
                {
                    string  _HaveYouInCircles  = ObjoAuthTokenGPlus.APIWebRequestToGetUserInfo(Globals.strGetPeopleProfile + _GooglePlusAccount.GpUserId + "?key=" + ConfigurationManager.AppSettings["Api_Key"].ToString(), access_token);
                    JObject J_HaveYouInCircles = JObject.Parse(_HaveYouInCircles);
                    _GooglePlusAccount.HaveYouInCircles = Convert.ToInt32(J_HaveYouInCircles["circledByCount"].ToString());
                }
                catch (Exception ex)
                {
                    _GooglePlusAccount.HaveYouInCircles = 0;
                }
                #endregion

                #region Add GPlusAccount
                if (!objGooglePlusAccountRepository.checkGooglePlusUserExists(_GooglePlusAccount.GpUserId, _GooglePlusAccount.UserId))
                {
                    objGooglePlusAccountRepository.addGooglePlusUser(_GooglePlusAccount);
                }

                #region Add TeamMemberProfile
                //Domain.Socioboard.Domain.Team objTeam = objTeamRepository.GetTeamByGroupId(Guid.Parse(GroupId));
                //Domain.Socioboard.Domain.TeamMemberProfile objTeamMemberProfile = new Domain.Socioboard.Domain.TeamMemberProfile();
                //objTeamMemberProfile.Id = Guid.NewGuid();
                //objTeamMemberProfile.TeamId = objTeam.Id;
                //objTeamMemberProfile.Status = 1;
                //objTeamMemberProfile.ProfileType = "gplus";
                //objTeamMemberProfile.StatusUpdateDate = DateTime.Now;
                //objTeamMemberProfile.ProfileId = _GooglePlusAccount.GpUserId;
                //objTeamMemberProfile.ProfilePicUrl = _GooglePlusAccount.GpProfileImage;
                //objTeamMemberProfile.ProfileName = _GooglePlusAccount.GpUserName;


                Domain.Socioboard.Domain.GroupProfile grpProfile = new Domain.Socioboard.Domain.GroupProfile();
                grpProfile.Id           = Guid.NewGuid();
                grpProfile.EntryDate    = DateTime.UtcNow;
                grpProfile.GroupId      = Guid.Parse(GroupId);
                grpProfile.GroupOwnerId = Guid.Parse(UserId);
                grpProfile.ProfileId    = _GooglePlusAccount.GpUserId;
                grpProfile.ProfileType  = "gplus";
                grpProfile.ProfileName  = _GooglePlusAccount.GpUserName;
                grpProfile.ProfilePic   = _GooglePlusAccount.GpProfileImage;

                #endregion
                #region SocialProfile
                Domain.Socioboard.Domain.SocialProfile objSocialProfile = new Domain.Socioboard.Domain.SocialProfile();
                objSocialProfile.Id            = Guid.NewGuid();
                objSocialProfile.ProfileType   = "gplus";
                objSocialProfile.ProfileId     = _GooglePlusAccount.GpUserId;
                objSocialProfile.UserId        = Guid.Parse(UserId);
                objSocialProfile.ProfileDate   = DateTime.Now;
                objSocialProfile.ProfileStatus = 1;
                if (!objSocialProfilesRepository.checkUserProfileExist(objSocialProfile))
                {
                    //objTeamMemberProfileRepository.addNewTeamMember(objTeamMemberProfile);
                    grpProfileRepo.AddGroupProfile(grpProfile);

                    objSocialProfilesRepository.addNewProfileForUser(objSocialProfile);
                    ret = "Account Added Successfully";
                }
                else
                {
                    ret = "Account already Exist !";
                }
                #endregion
                #endregion
                GetUserActivities(UserId, _GooglePlusAccount.GpUserId, access_token, 1);
                return(new JavaScriptSerializer().Serialize(_GooglePlusAccount));
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message);
                return("");
            }
        }
        public string AddAnalyticsProfiles(string GAProfiles, string UserId, string GroupId)
        {
            try
            {
                Analytics _Analytics = new Analytics();
                List <Domain.Socioboard.Helper.GoogleAnalyticsProfiles> lstGoogleAnalyticsProfiles = (List <Domain.Socioboard.Helper.GoogleAnalyticsProfiles>) new JavaScriptSerializer().Deserialize(GAProfiles, typeof(List <Domain.Socioboard.Helper.GoogleAnalyticsProfiles>));
                Domain.Socioboard.Domain.GoogleAnalyticsAccount         _GoogleAnalyticsAccount;
                foreach (var item in lstGoogleAnalyticsProfiles)
                {
                    try
                    {
                        _GoogleAnalyticsAccount                 = new Domain.Socioboard.Domain.GoogleAnalyticsAccount();
                        _GoogleAnalyticsAccount.UserId          = Guid.Parse(UserId);
                        _GoogleAnalyticsAccount.EmailId         = item.EmailId;
                        _GoogleAnalyticsAccount.GaAccountId     = item.AccountId;
                        _GoogleAnalyticsAccount.GaAccountName   = item.AccountName;
                        _GoogleAnalyticsAccount.GaWebPropertyId = item.WebPropertyId;
                        _GoogleAnalyticsAccount.GaProfileId     = item.ProfileId;
                        _GoogleAnalyticsAccount.GaProfileName   = item.ProfileName;
                        _GoogleAnalyticsAccount.AccessToken     = item.AccessToken;
                        _GoogleAnalyticsAccount.RefreshToken    = item.RefreshToken;
                        _GoogleAnalyticsAccount.WebsiteUrl      = item.WebsiteUrl;
                        string visits    = string.Empty;
                        string pageviews = string.Empty;
                        try
                        {
                            string  analytics = _Analytics.getAnalyticsData(item.ProfileId, "ga:visits,ga:pageviews", DateTime.UtcNow.AddDays(-7).ToString("yyyy-MM-dd"), DateTime.UtcNow.ToString("yyyy-MM-dd"), item.AccessToken);
                            JObject JData     = JObject.Parse(analytics);
                            visits    = JData["totalsForAllResults"]["ga:visits"].ToString();
                            pageviews = JData["totalsForAllResults"]["ga:pageviews"].ToString();
                        }
                        catch (Exception ex)
                        {
                            visits    = "0";
                            pageviews = "0";
                        }
                        _GoogleAnalyticsAccount.Views         = Double.Parse(pageviews);
                        _GoogleAnalyticsAccount.Visits        = Double.Parse(visits);
                        _GoogleAnalyticsAccount.ProfilePicUrl = ConfigurationManager.AppSettings["DomainName"] + "/Themes/" + ConfigurationManager.AppSettings["DefaultGroupName"] + "/Contents/img/analytics_img.png";
                        _GoogleAnalyticsAccount.IsActive      = true;
                        _GoogleAnalyticsAccount.EntryDate     = DateTime.UtcNow;
                        if (!_GoogleAnalyticsAccountRepository.checkGoogelAnalyticsUserExists(item.ProfileId, item.AccountId, Guid.Parse(UserId)))
                        {
                            _GoogleAnalyticsAccountRepository.Add(_GoogleAnalyticsAccount);
                        }
                        #region  TeamMemberProfile
                        Domain.Socioboard.Domain.Team objTeam = objTeamRepository.GetTeamByGroupId(Guid.Parse(GroupId));
                        if (!grpProfileRepo.checkProfileExistsingroup(Guid.Parse(GroupId), item.ProfileId))
                        {
                            //Domain.Socioboard.Domain.TeamMemberProfile objTeamMemberProfile = new Domain.Socioboard.Domain.TeamMemberProfile();
                            //objTeamMemberProfile.ProfileId = item.ProfileId;
                            //objTeamMemberProfile.ProfileName = item.ProfileName;
                            //objTeamMemberProfile.ProfilePicUrl = ConfigurationManager.AppSettings["DomainName"] + "/Themes/Socioboard/Contents/img/analytics_img.png";
                            //objTeamMemberProfile.ProfileType = "googleanalytics";
                            //objTeamMemberProfile.Status = 1;
                            //objTeamMemberProfile.StatusUpdateDate = DateTime.Now;
                            //objTeamMemberProfile.TeamId = objTeam.Id;
                            //objTeamMemberProfileRepository.addNewTeamMember(objTeamMemberProfile);


                            Domain.Socioboard.Domain.GroupProfile grpProfile = new Domain.Socioboard.Domain.GroupProfile();
                            grpProfile.Id           = Guid.NewGuid();
                            grpProfile.EntryDate    = DateTime.UtcNow;
                            grpProfile.GroupId      = Guid.Parse(GroupId);
                            grpProfile.GroupOwnerId = Guid.Parse(UserId);
                            grpProfile.ProfileId    = item.ProfileId;
                            grpProfile.ProfileType  = "googleanalytics";
                            grpProfile.ProfileName  = item.ProfileName;
                            grpProfile.ProfilePic   = ConfigurationManager.AppSettings["DomainName"] + "/Themes/" + ConfigurationManager.AppSettings["DefaultGroupName"] + "/Contents/img/analytics_img.png";
                            grpProfileRepo.AddGroupProfile(grpProfile);
                        }
                        #endregion
                        #region SocialProfile
                        Domain.Socioboard.Domain.SocialProfile objSocialProfile = new Domain.Socioboard.Domain.SocialProfile();
                        objSocialProfile.ProfileType   = "googleanalytics";
                        objSocialProfile.ProfileId     = item.ProfileId;
                        objSocialProfile.UserId        = Guid.Parse(UserId);
                        objSocialProfile.ProfileDate   = DateTime.Now;
                        objSocialProfile.ProfileStatus = 1;
                        if (!objSocialProfilesRepository.checkUserProfileExist(objSocialProfile))
                        {
                            objSocialProfilesRepository.addNewProfileForUser(objSocialProfile);
                        }
                        #endregion
                    }
                    catch (Exception ex)
                    {
                        logger.Error("AddAnalyticsProfiles = > " + ex.Message);
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error("AddAnalyticsProfiles = > " + ex.Message);
            }
            return("added successfully");
        }