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");
            }
        }
Пример #2
0
        public void GetPageProfile(dynamic data, oAuthLinkedIn _OAuth, string UserId, string CompanyPageId, string GroupId)
        {
            Domain.Socioboard.Domain.SocialProfile socioprofile = new Domain.Socioboard.Domain.SocialProfile();
            SocialProfilesRepository socioprofilerepo           = new SocialProfilesRepository();

            Domain.Socioboard.Domain.LinkedinCompanyPage objLinkedincmpnypage = new Domain.Socioboard.Domain.LinkedinCompanyPage();
            LinkedinCompanyPageRepository objLinkedCmpnyPgeRepo = new LinkedinCompanyPageRepository();

            Domain.Socioboard.Domain.GroupProfile grpProfile = new Domain.Socioboard.Domain.GroupProfile();

            try
            {
                objLinkedincmpnypage.UserId = Guid.Parse(UserId);
                try
                {
                    objLinkedincmpnypage.LinkedinPageId = data.Pageid.ToString();
                }
                catch
                {
                }
                objLinkedincmpnypage.Id = Guid.NewGuid();
                try
                {
                    objLinkedincmpnypage.EmailDomains = data.EmailDomains.ToString();
                }
                catch { }
                objLinkedincmpnypage.LinkedinPageName = data.name.ToString();
                objLinkedincmpnypage.OAuthToken       = _OAuth.Token;
                objLinkedincmpnypage.OAuthSecret      = _OAuth.TokenSecret;
                objLinkedincmpnypage.OAuthVerifier    = _OAuth.Verifier;
                try
                {
                    objLinkedincmpnypage.Description = data.description.ToString();
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.FoundedYear = data.founded_year.ToString();
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.EndYear = data.end_year.ToString();
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.Locations = data.locations.ToString();
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.Specialties = data.Specialties.ToString();
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.WebsiteUrl = data.website_url.ToString();
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.Status = data.status.ToString();
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.EmployeeCountRange = data.employee_count_range.ToString();
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.Industries = data.industries.ToString();
                }
                catch { }
                try
                {
                    string NuberOfFollower = data.num_followers.ToString();
                    objLinkedincmpnypage.NumFollowers = Convert.ToInt16(NuberOfFollower);
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.CompanyType = data.company_type.ToString();
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.LogoUrl = data.logo_url.ToString();
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.SquareLogoUrl = data.square_logo_url.ToString();
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.BlogRssUrl = data.blog_rss_url.ToString();
                }
                catch { }
                try
                {
                    objLinkedincmpnypage.UniversalName = data.universal_name.ToString();
                }
                catch { }
                #region SocialProfiles
                socioprofile.UserId        = Guid.Parse(UserId);
                socioprofile.ProfileType   = "linkedincompanypage";
                socioprofile.ProfileId     = data.Pageid.ToString();;
                socioprofile.ProfileStatus = 1;
                socioprofile.ProfileDate   = DateTime.Now;
                socioprofile.Id            = Guid.NewGuid();
                #endregion

                #region TeamMemberProfile
                //Domain.Socioboard.Domain.Team objTeam = objTeamRepository.GetTeamByGroupId(Guid.Parse(GroupId));
                //objTeamMemberProfile = new Domain.Socioboard.Domain.TeamMemberProfile();
                //objTeamMemberProfile.Id = Guid.NewGuid();
                //objTeamMemberProfile.TeamId = objTeam.Id;
                //objTeamMemberProfile.Status = 1;
                //objTeamMemberProfile.ProfileType = "linkedincompanypage";
                //objTeamMemberProfile.StatusUpdateDate = DateTime.Now;
                //objTeamMemberProfile.ProfileId = socioprofile.ProfileId;


                grpProfile.Id           = Guid.NewGuid();
                grpProfile.EntryDate    = DateTime.UtcNow;
                grpProfile.GroupId      = Guid.Parse(GroupId);
                grpProfile.GroupOwnerId = Guid.Parse(UserId);
                grpProfile.ProfileId    = socioprofile.ProfileId;
                grpProfile.ProfileType  = "linkedincompanypage";
                // grpProfile.ProfilePic
                #endregion
            }
            catch
            {
            }
            try
            {
                if (!objSocialProfilesRepository.checkUserProfileExist(socioprofile))
                {
                    objSocialProfilesRepository.addNewProfileForUser(socioprofile);
                }
                //if (!objTeamMemberProfileRepository.checkTeamMemberProfile(objTeamMemberProfile.TeamId, objLinkedincmpnypage.LinkedinPageId))
                //{
                //    objTeamMemberProfileRepository.addNewTeamMember(objTeamMemberProfile);
                //}
                if (!grpProfileRepo.checkProfileExistsingroup(Guid.Parse(GroupId), socioprofile.ProfileId))
                {
                    //    objTeamMemberProfileRepository.addNewTeamMember(objTeamMemberProfile);
                    grpProfileRepo.AddGroupProfile(grpProfile);
                }

                if (!objLinkedCmpnyPgeRepo.checkLinkedinPageExists(CompanyPageId, Guid.Parse(UserId)))
                {
                    objLinkedCmpnyPgeRepo.addLinkenCompanyPage(objLinkedincmpnypage);
                }
                else
                {
                    objLinkedincmpnypage.LinkedinPageId = CompanyPageId;
                    objLinkedCmpnyPgeRepo.updateLinkedinPage(objLinkedincmpnypage);
                }
            }
            catch
            {
            }
        }
        public string GetTicketsofGroup(string GroupId, string UserId)
        {
            string AssignedUser = string.Empty;

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

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

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

                return(new JavaScriptSerializer().Serialize(objListFBTwitterFeeds));
            }
            catch (Exception ex)
            {
                logger.Error(ex.StackTrace);
                logger.Error(ex.Message);
                Console.WriteLine(ex.StackTrace);
                return("SomethingWentWrong");
            }
        }
        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");
        }