Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        private void getTwitterUserProfile()
        {
            var requestToken    = (String)Request.QueryString["oauth_token"];
            var requestSecret   = (String)Session["requestSecret"];
            var requestVerifier = (String)Request.QueryString["oauth_verifier"];


            OAuth.AccessToken       = requestToken;
            OAuth.AccessTokenSecret = requestVerifier;
            OAuth.AccessTokenGet(requestToken, requestVerifier);

            JArray profile = userinfo.Get_Users_LookUp_ByScreenName(OAuth, OAuth.TwitterScreenName);
            User   user    = (User)Session["LoggedUser"];
            SocialProfilesRepository socioprofilerepo = new SocialProfilesRepository();
            SocialProfile            socioprofile     = new SocialProfile();

            #region for managing referrals
            ManageReferrals(OAuth);
            #endregion

            foreach (var item in profile)
            {
                try
                {
                    twitterAccount.FollowingCount = Convert.ToInt32(item["friends_count"].ToString());
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);
                }
                try
                {
                    twitterAccount.FollowersCount = Convert.ToInt32(item["followers_count"].ToString());
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);
                }
                twitterAccount.Id          = Guid.NewGuid();
                twitterAccount.IsActive    = true;
                twitterAccount.OAuthSecret = OAuth.AccessTokenSecret;
                twitterAccount.OAuthToken  = OAuth.AccessToken;
                try
                {
                    twitterAccount.ProfileImageUrl = item["profile_image_url"].ToString().TrimStart('"').TrimEnd('"');
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);
                }
                try
                {
                    twitterAccount.ProfileUrl = string.Empty;
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);
                }
                try
                {
                    twitterAccount.TwitterUserId = item["id_str"].ToString().TrimStart('"').TrimEnd('"');
                }
                catch (Exception er)
                {
                    try
                    {
                        twitterAccount.TwitterUserId = item["id"].ToString().TrimStart('"').TrimEnd('"');
                    }
                    catch (Exception err)
                    {
                        Console.WriteLine(err.StackTrace);
                    }
                    Console.WriteLine(er.StackTrace);
                }

                try
                {
                    twitterAccount.TwitterScreenName = item["screen_name"].ToString().TrimStart('"').TrimEnd('"');
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);
                }
                twitterAccount.UserId = user.Id;

                socioprofile.Id          = Guid.NewGuid();
                socioprofile.ProfileDate = DateTime.Now;
                socioprofile.ProfileId   = twitterAccount.TwitterUserId;
                socioprofile.ProfileType = "twitter";
                socioprofile.UserId      = user.Id;

                if (HttpContext.Current.Session["login"] != null)
                {
                    if (HttpContext.Current.Session["login"].ToString().Equals("twitter"))
                    {
                        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    = twitterAccount.TwitterName;
                        usr.Password    = regObject.MD5Hash(twitterAccount.TwitterName);
                        usr.EmailId     = "";
                        usr.UserStatus  = 1;
                        if (!userrepo.IsUserExist(usr.EmailId))
                        {
                            UserRepository.Add(usr);
                        }
                    }
                }

                TwitterStatsRepository objTwtstats = new TwitterStatsRepository();
                TwitterStats           objStats    = new TwitterStats();
                Random rNum = new Random();
                objStats.Id             = Guid.NewGuid();
                objStats.TwitterId      = twitterAccount.TwitterUserId;
                objStats.UserId         = user.Id;
                objStats.FollowingCount = twitterAccount.FollowingCount;
                objStats.FollowerCount  = twitterAccount.FollowersCount;
                objStats.Age1820        = rNum.Next(twitterAccount.FollowersCount);
                objStats.Age2124        = rNum.Next(twitterAccount.FollowersCount);
                objStats.Age2534        = rNum.Next(twitterAccount.FollowersCount);
                objStats.Age3544        = rNum.Next(twitterAccount.FollowersCount);
                objStats.Age4554        = rNum.Next(twitterAccount.FollowersCount);
                objStats.Age5564        = rNum.Next(twitterAccount.FollowersCount);
                objStats.Age65          = rNum.Next(twitterAccount.FollowersCount);
                objStats.EntryDate      = DateTime.Now;
                if (!objTwtstats.checkTwitterStatsExists(twitterAccount.TwitterUserId, user.Id))
                {
                    objTwtstats.addTwitterStats(objStats);
                }
                if (!twtrepo.checkTwitterUserExists(twitterAccount.TwitterUserId, user.Id))
                {
                    twtrepo.addTwitterkUser(twitterAccount);
                    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        = twitterAccount.TwitterUserId;
                            teammemberprofile.ProfileType      = "twitter";
                            teammemberprofile.StatusUpdateDate = DateTime.Now;

                            objTeamMemberProfileRepository.addNewTeamMember(teammemberprofile);
                        }
                    }
                    else
                    {
                        socioprofilerepo.updateSocialProfile(socioprofile);
                    }
                }
                else
                {
                    HttpContext.Current.Session["alreadyexist"] = twitterAccount;
                    twtrepo.updateTwitterUser(twitterAccount);
                    TwitterMessageRepository twtmsgreponew = new TwitterMessageRepository();
                    twtmsgreponew.updateScreenName(twitterAccount.TwitterUserId, twitterAccount.TwitterScreenName);
                    if (!socioprofilerepo.checkUserProfileExist(socioprofile))
                    {
                        socioprofilerepo.addNewProfileForUser(socioprofile);
                    }
                    else
                    {
                        socioprofilerepo.updateSocialProfile(socioprofile);
                    }
                }
                if (Session["UserAndGroupsForTwitter"] != null)
                {
                    if (Session["UserAndGroupsForTwitter"].ToString() == "twitter")
                    {
                        try
                        {
                            if (Session["GroupName"] != null)
                            {
                                Groups                 group            = (Groups)Session["GroupName"];
                                GroupProfile           groupprofile     = new GroupProfile();
                                GroupProfileRepository groupprofilerepo = new GroupProfileRepository();
                                groupprofile.Id           = Guid.NewGuid();
                                groupprofile.ProfileId    = socioprofile.ProfileId;
                                groupprofile.ProfileType  = "twitter";
                                groupprofile.GroupOwnerId = user.Id;
                                groupprofile.EntryDate    = DateTime.Now;
                                groupprofile.GroupId      = group.Id;
                                if (!groupprofilerepo.checkGroupProfileExists(user.Id, group.Id, groupprofile.ProfileId))
                                {
                                    groupprofilerepo.AddGroupProfile(groupprofile);
                                }
                            }
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine(e.StackTrace);
                        }
                    }
                }
            }
        }
        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();
        }
Exemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                UserRefRelationRepository objUserRefRelationRepository = new UserRefRelationRepository();
                UserRepository            userrepo                         = new UserRepository();
                Registration                regObject                      = new Registration();
                TeamRepository              objTeamRepo                    = new TeamRepository();
                NewsRepository              objNewsRepo                    = new NewsRepository();
                AdsRepository               objAdsRepo                     = new AdsRepository();
                UserActivation              objUserActivation              = new UserActivation();
                UserActivationRepository    objUserActivationRepository    = new UserActivationRepository();
                SocialProfilesRepository    objSocioRepo                   = new SocialProfilesRepository();
                GroupRepository             objGroupRepository             = new GroupRepository();
                TeamMemberProfileRepository objTeamMemberProfileRepository = new TeamMemberProfileRepository();
                Team team = new Team();


                SocioBoard.Domain.User user = (User)Session["LoggedUser"];

                try
                {
                    if (Session["GroupName"] == null)
                    {
                        Groups objGroupDetails = objGroupRepository.getGroupDetail(user.Id);
                        team = objTeamRepo.getAllDetails(objGroupDetails.Id, user.EmailId);
                        Session["GroupName"] = team;
                    }

                    else
                    {
                        team = (SocioBoard.Domain.Team)Session["GroupName"];
                    }
                }
                catch (Exception ex)
                {
                    logger.Error("Error: " + ex.Message);
                }
                Session["facebooktotalprofiles"] = null;

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

                #region Days remaining
                if (Session["days_remaining"] == null)
                {
                    if (user.PaymentStatus == "unpaid" && user.AccountType != "Free")
                    {
                        int daysremaining = (user.ExpiryDate.Date - DateTime.Now.Date).Days;
                        if (daysremaining < 0)
                        {
                            daysremaining = -1;
                        }
                        Session["days_remaining"] = daysremaining;
                        //ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('You are using '" + user.AccountType + "' account only '" + daysremaining + "' days is remaining !');", true);
                        if (daysremaining <= -1)
                        {
                        }
                        else if (daysremaining == 0)
                        {
                            ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Your trial " + user.AccountType + " account will expire end of the day, please upgrade to paid plan.');", true);
                        }
                        else
                        {
                            ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Your trial " + user.AccountType + " account will expire in " + daysremaining + " days, please upgrade to paid plan.');", true);
                        }
                    }
                }

                #endregion

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

                if (user.PaymentStatus.ToLower() == "unpaid" && user.AccountType != "Free")
                {
                    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");
                    }
                }

                Session["GreaterThan30Days"] = null;
                #endregion

                if (!IsPostBack)
                {
                    try
                    {
                        if (user == null)
                        {
                            Response.Redirect("Default.aspx");
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                        logger.Error(ex.StackTrace);
                    }


                    try
                    {
                        objUserActivation = objUserActivationRepository.GetUserActivationStatus(user.Id.ToString());
                    }
                    catch (Exception ex)
                    {
                        Session["objUserActivationException"] = "objUserActivationException";

                        Console.WriteLine(ex.Message);
                        logger.Error(ex.StackTrace);
                    }


                    #region Count Used Accounts
                    try
                    {
                        if (user.AccountType.ToString().ToLower() == AccountType.Deluxe.ToString().ToLower())
                        {
                            tot_acc = 50;
                        }
                        else if (user.AccountType.ToString().ToLower() == AccountType.Standard.ToString().ToLower())
                        {
                            tot_acc = 10;
                        }
                        else if (user.AccountType.ToString().ToLower() == AccountType.Premium.ToString().ToLower())
                        {
                            tot_acc = 20;
                        }
                        else if (user.AccountType.ToString().ToLower() == AccountType.Free.ToString().ToLower())
                        {
                            tot_acc = 5;
                        }

                        else if (user.AccountType.ToString().ToLower() == AccountType.SocioBasic.ToString().ToLower())
                        {
                            tot_acc = 100;
                        }
                        else if (user.AccountType.ToString().ToLower() == AccountType.SocioStandard.ToString().ToLower())
                        {
                            tot_acc = 200;
                        }
                        else if (user.AccountType.ToString().ToLower() == AccountType.SocioPremium.ToString().ToLower())
                        {
                            tot_acc = 500;
                        }
                        else if (user.AccountType.ToString().ToLower() == AccountType.SocioDeluxe.ToString().ToLower())
                        {
                            tot_acc = 1000;
                        }


                        profileCount            = objSocioRepo.getAllSocialProfilesOfUser(user.Id).Count;
                        Session["ProfileCount"] = profileCount;
                        Session["TotalAccount"] = tot_acc;

                        try
                        {
                            Groups lstDetail = objGroupRepository.getGroupName(team.GroupId);
                            if (lstDetail.GroupName == "Socioboard")
                            {
                                usedAccount.InnerHtml = " using " + profileCount + " of " + tot_acc;
                            }
                        }
                        catch (Exception ex)
                        {
                            logger.Error(ex.StackTrace);
                        }
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.StackTrace);
                    }
                    #endregion



                    try
                    {
                        Groups lstDetails = objGroupRepository.getGroupName(team.GroupId);
                        if (lstDetails.GroupName != "Socioboard")
                        {
                            expander.Attributes.CssStyle.Add("display", "none");
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                    }


                    //this is used to check whether facebok account Already Exist
                    if (Session["alreadyexist"] != null)
                    {
                        ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('This Profile is Already Added please add aother Account!');", true);
                        Session["alreadyexist"] = null;
                    }
                    if (Session["alreadypageexist"] != null)
                    {
                        ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('This Page is Already Added please add aother Page!');", true);
                        Session["alreadypageexist"] = null;
                    }



                    if (!string.IsNullOrEmpty(Request.QueryString["type"]))
                    {
                        try
                        {
                            userrepo.UpdateAccountType(user.Id, Request.QueryString["type"]);
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                            logger.Error(ex.StackTrace);
                        }
                    }

                    //acrossProfile.InnerHtml = "Across " + user.UserName + "'s Twitter and Facebook accounts";
                    teamMem.InnerHtml = "managing " + user.UserName;
                    try
                    {
                        News nws = objNewsRepo.getNewsForHome();
                        //divNews.InnerHtml = nws.NewsDetail;
                    }
                    catch (Exception Err)
                    {
                        Console.Write(Err.StackTrace);
                        logger.Error(Err.StackTrace);
                    }
                    try
                    {
                        ArrayList lstads = objAdsRepo.getAdsForHome();
                        if (lstads.Count < 1)
                        {
                            if (user.PaymentStatus.ToUpper() == "PAID")
                            {
                                bindads.InnerHtml = "<img src=\"../Contents/img/admin/ads.png\"  alt=\"\" >";
                            }
                            else
                            {
                                #region ADS Script
                                bindads.InnerHtml = "<script async src=\"//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js\"></script>" +
                                                    "<!-- socioboard -->" +
                                                    "<ins class=\"adsbygoogle\"" +
                                                    "style=\"display:inline-block;width:250px;height:250px\"" +
                                                    "data-ad-client=\"ca-pub-7073257741073458\"" +
                                                    "data-ad-slot=\"9533254693\"></ins>" +
                                                    "<script>" +
                                                    "(adsbygoogle = window.adsbygoogle || []).push({});" +
                                                    "</script>";
                                #endregion
                            }
                        }


                        foreach (var item in lstads)
                        {
                            Array temp = (Array)item;
                            //imgAds.ImageUrl = temp.GetValue(2).ToString();
                            if (user.PaymentStatus.ToUpper() == "PAID")
                            {
                                bindads.InnerHtml = "<img src=\"" + temp.GetValue(2).ToString() + "\"  alt=\"\" style=\"width:246px;height:331px\">";
                            }
                            else
                            {
                                #region ADS Script
                                bindads.InnerHtml = "<script async src=\"//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js\"></script>" +
                                                    "<!-- socioboard -->" +
                                                    "<ins class=\"adsbygoogle\"" +
                                                    "style=\"display:inline-block;width:250px;height:250px\"" +
                                                    "data-ad-client=\"ca-pub-7073257741073458\"" +
                                                    "data-ad-slot=\"9533254693\"></ins>" +
                                                    "<script>" +
                                                    "(adsbygoogle = window.adsbygoogle || []).push({});" +
                                                    "</script>";
                                #endregion
                            }
                            break;
                            // ads.ImageUrl;
                        }
                    }
                    catch (Exception Err)
                    {
                        Console.Write(Err.StackTrace);
                        logger.Error(Err.StackTrace);
                    }
                    #region Team Member Count
                    try
                    {
                        GroupRepository grouprepo    = new GroupRepository();
                        string          groupsofhome = string.Empty;
                        List <Groups>   lstgroups    = grouprepo.getAllGroups(user.Id);
                        if (lstgroups.Count != 0)
                        {
                            foreach (Groups item in lstgroups)
                            {
                                groupsofhome += "<li><a href=\"../Settings/InviteMember.aspx?q=" + item.Id + "\"><img src=\"../Contents/img/groups_.png\" alt=\"\" style=\" margin-right:5px;\"> " + item.GroupName + "</a></li>";
                            }
                            getAllGroupsOnHome.InnerHtml = groupsofhome;
                        }
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.StackTrace);
                    }
                    #endregion

                    try
                    {
                        string      strTeam = string.Empty;
                        List <Team> teams   = objTeamRepo.getAllTeamsOfUser(user.Id, team.GroupId, user.EmailId);
                        foreach (Team item in teams)
                        {
                            strTeam += "<div class=\"userpictiny\"><a target=\"_blank\" href=\"#\">" +
                                       "<img width=\"48\" height=\"48\" title=\"" + item.FirstName + "\" alt=\"\" src=\"../Contents/img/blank_img.png\">" +
                                       "</a></div>";
                        }
                        team_member.InnerHtml = strTeam;
                    }
                    catch (Exception Err)
                    {
                        Console.Write(Err.StackTrace);
                    }

                    #region Add Fan Page
                    try
                    {
                        if (Session["fbSocial"] != null)
                        {
                            if (Session["fbSocial"] == "p")
                            {
                                FacebookAccount objFacebookAccount = (FacebookAccount)Session["fbpagedetail"];

                                //    string strpageUrl = "https://graph.facebook.com/" + objFacebookAccount.FacebookId + "/accounts";
                                // objFacebookUrlBuilder = (FacebookUrlBuilder)Session["FacebookInsightUser"];
                                //    string strData = objAuthentication.RequestUrl(strpageUrl, objFacebookAccount.Token);
                                //    JObject output = objWebRequest.FacebookRequest(strData, "Get");
                                FacebookClient fb = new FacebookClient();
                                fb.AccessToken = objFacebookAccount.AccessToken;
                                dynamic output = fb.Get("/me/accounts");
                                //  JArray data = (JArray)output["data"];
                                DataTable dtFbPage = new DataTable();
                                dtFbPage.Columns.Add("Email");
                                dtFbPage.Columns.Add("PageId");
                                dtFbPage.Columns.Add("PageName");
                                dtFbPage.Columns.Add("status");
                                dtFbPage.Columns.Add("customer_id");
                                string strPageDiv = string.Empty;
                                if (output != null)
                                {
                                    foreach (var item in output["data"])
                                    {
                                        if (item.category.ToString() != "Application")
                                        {
                                            strPageDiv      += "<div><a id=\"A1\"  onclick=\"getInsights('" + item["id"].ToString() + "','" + item["name"].ToString() + "')\"><span>" + item["name"].ToString() + "</span> </a></div>";
                                            fbpage.InnerHtml = strPageDiv;
                                        }
                                    }
                                }
                                else
                                {
                                    strPageDiv += "<div>No Pages Found</div>";
                                }
                                Page.ClientScript.RegisterStartupScript(Page.GetType(), "my", " ShowDialogHome(false);", true);
                                Session["fbSocial"] = null;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                        logger.Error(ex.StackTrace);
                    }
                    #endregion

                    #region InsightsData
                    try
                    {
                        decimal malecount = 0, femalecount = 0, cnt = 0;

                        FacebookStatsRepository objfbStatsRepo = new FacebookStatsRepository();
                        double daysSub = (DateTime.Now - user.CreateDate).TotalDays;

                        int userdays;
                        if (daysSub > 0 && daysSub <= 1)
                        {
                            userdays = 1;
                        }
                        else
                        {
                            userdays = (int)daysSub;
                        }
                        ArrayList arrFbStats = objfbStatsRepo.getAllFacebookStatsOfUser(user.Id, userdays);
                        //ArrayList arrFbStats = objfbStatsRepo.getTotalFacebookStatsOfUser(user.Id);

                        Random rNum = new Random();
                        foreach (var item in arrFbStats)
                        {
                            Array temp = (Array)item;
                            cnt         += int.Parse(temp.GetValue(3).ToString()) + int.Parse(temp.GetValue(4).ToString());
                            malecount   += int.Parse(temp.GetValue(3).ToString());
                            femalecount += int.Parse(temp.GetValue(4).ToString());
                        }
                        try
                        {
                            decimal mc = (malecount / cnt) * 100;
                            male = Convert.ToInt16(mc);
                        }
                        catch (Exception Err)
                        {
                            Console.Write(Err.StackTrace);
                            logger.Error(Err.StackTrace);
                        }
                        try
                        {
                            decimal fc = (femalecount / cnt) * 100;
                            female = Convert.ToInt16(fc);
                        }
                        catch (Exception Err)
                        {
                            Console.Write(Err.StackTrace);
                            logger.Error(Err.StackTrace);
                        }
                        int twtAccCount = objSocioRepo.getAllSocialProfilesTypeOfUser(user.Id, "twitter").Count;
                        if (twtAccCount > 1)
                        {
                            twtmale   = rNum.Next(100);
                            twtfemale = 100 - twtmale;
                        }
                        else if (twtAccCount == 1)
                        {
                            twtmale   = 100;
                            twtfemale = 0;
                        }
                        Session["twtGender"] = twtmale + "," + twtfemale;
                    }
                    catch (Exception Err)
                    {
                        Console.Write(Err.Message.ToString());
                        logger.Error(Err.StackTrace);
                    }
                    //getgrphData();
                    // getNewFriends(7);
                    //  getNewFriends();
                    //  getNewFollowers();
                    #endregion

                    #region GetFollower


                    try
                    {
                        String TwtProfileId = string.Empty;

                        TwitterStatsRepository objtwtStatsRepo = new TwitterStatsRepository();

                        List <TeamMemberProfile> objTeamMemberProfile = objTeamMemberProfileRepository.getTwtTeamMemberProfileData(team.Id);
                        foreach (TeamMemberProfile item in objTeamMemberProfile)
                        {
                            TwtProfileId += item.ProfileId + ',';
                        }
                        TwtProfileId = TwtProfileId.Substring(0, TwtProfileId.Length - 1);

                        List <TwitterStats> arrTwtStats = objtwtStatsRepo.getAllAccountDetail(TwtProfileId);

                        //strTwtArray = "[";
                        int    NewTweet_Count = 0;
                        string TotalFollower  = string.Empty;
                        foreach (TwitterStats item in arrTwtStats)
                        {
                            NewTweet_Count += item.FollowerCount;
                        }
                        if (NewTweet_Count >= 100000)
                        {
                            TotalFollower = (System.Math.Round(((float)NewTweet_Count / 1000000), 2)) + "M";
                        }
                        else if (NewTweet_Count > 1000 && NewTweet_Count < 100000)
                        {
                            TotalFollower = (System.Math.Round(((float)NewTweet_Count / 1000), 2)) + "K";
                        }
                        else
                        {
                            TotalFollower = NewTweet_Count.ToString();
                        }

                        spanNewTweets.InnerHtml = TotalFollower;
                    }
                    catch (Exception Err)
                    {
                        Console.Write(Err.Message.ToString());
                        logger.Error(Err.StackTrace);
                    }


                    #endregion

                    #region GetFacebookFanPage

                    try
                    {
                        String FbProfileId = string.Empty;

                        FacebookStatsRepository objFacebookStatsRepository = new FacebookStatsRepository();

                        List <TeamMemberProfile> objTeamMemberProfile = objTeamMemberProfileRepository.getTeamMemberProfileData(team.Id);
                        foreach (TeamMemberProfile item in objTeamMemberProfile)
                        {
                            FbProfileId += item.ProfileId + ',';
                        }
                        FbProfileId = FbProfileId.Substring(0, FbProfileId.Length - 1);

                        List <FacebookStats> arrFbStats = objFacebookStatsRepository.getAllAccountDetail(FbProfileId);

                        //strTwtArray = "[";
                        int    NewFbFan_Count = 0;
                        string TotalFriends   = string.Empty;
                        foreach (FacebookStats item in arrFbStats)
                        {
                            NewFbFan_Count += item.FanCount;
                        }
                        if (NewFbFan_Count >= 100000)
                        {
                            TotalFriends = (System.Math.Round(((float)NewFbFan_Count / 1000000), 2)) + "M";
                        }
                        else if (NewFbFan_Count > 1000 && NewFbFan_Count < 100000)
                        {
                            TotalFriends = (System.Math.Round(((float)NewFbFan_Count / 1000), 2)) + "K";
                        }
                        else
                        {
                            TotalFriends = NewFbFan_Count.ToString();
                        }

                        spanFbFans.InnerHtml = TotalFriends;
                    }
                    catch (Exception Err)
                    {
                        Console.Write(Err.Message.ToString());
                        logger.Error(Err.StackTrace);
                    }

                    #endregion



                    #region IncomingMessages
                    try
                    {
                        FacebookFeedRepository fbFeedRepo = new FacebookFeedRepository();
                        int fbmessagescout = fbFeedRepo.countUnreadMessages(user.Id);
                        TwitterMessageRepository twtMsgRepo = new TwitterMessageRepository();
                        int twtcount = twtMsgRepo.getCountUnreadMessages(user.Id);
                        Session["CountMessages"] = fbmessagescout + twtcount;
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.StackTrace);
                    }
                    #endregion



                    #region NewIncomingMessage

                    try
                    {
                        String FbProfileId  = string.Empty;
                        String TwtProfileId = string.Empty;
                        List <TeamMemberProfile> objTeamMemberProfile = objTeamMemberProfileRepository.getAllTeamMemberProfilesOfTeam(team.Id);
                        foreach (TeamMemberProfile item in objTeamMemberProfile)
                        {
                            try
                            {
                                if (item.ProfileType == "facebook")
                                {
                                    FbProfileId += item.ProfileId + ',';
                                }

                                else if (item.ProfileType == "twitter")
                                {
                                    TwtProfileId += item.ProfileId + ',';
                                }
                            }
                            catch (Exception Err)
                            {
                                Console.Write(Err.StackTrace);
                                logger.Error(Err.StackTrace);
                            }
                        }

                        try
                        {
                            FbProfileId = FbProfileId.Substring(0, FbProfileId.Length - 1);
                        }
                        catch (Exception Err)
                        {
                            Console.Write(Err.StackTrace);
                            logger.Error(Err.StackTrace);
                        }

                        try
                        {
                            TwtProfileId = TwtProfileId.Substring(0, TwtProfileId.Length - 1);
                        }
                        catch (Exception Err)
                        {
                            Console.Write(Err.StackTrace);
                            logger.Error(Err.StackTrace);
                        }

                        FacebookFeedRepository objFacebookFeedRepository = new FacebookFeedRepository();
                        List <FacebookFeed>    alstfb = objFacebookFeedRepository.getAllFeedDetail(FbProfileId);
                        // FacebookMessageRepository objFacebookMessageRepository = new FacebookMessageRepository();
                        TwitterMessageRepository objtwttatsRepo = new TwitterMessageRepository();
                        // List<FacebookMessage> alstfb = objFacebookMessageRepository.getAllMessageDetail(FbProfileId);
                        List <TwitterMessage> alstTwt = objtwttatsRepo.getAlltwtMessages(TwtProfileId);

                        int TotalFbMsgCount  = 0;
                        int TotalTwtMsgCount = 0;

                        try
                        {
                            TotalFbMsgCount = alstfb.Count;
                        }
                        catch (Exception Err)
                        {
                            Console.Write(Err.StackTrace);
                            logger.Error(Err.StackTrace);
                        }

                        try
                        {
                            TotalTwtMsgCount = alstTwt.Count;
                        }
                        catch (Exception Err)
                        {
                            Console.Write(Err.StackTrace);
                            logger.Error(Err.StackTrace);
                        }



                        spanIncoming.InnerHtml = (TotalFbMsgCount + TotalTwtMsgCount).ToString();

                        string profileid = string.Empty;
                        ScheduledMessageRepository objScheduledMessageRepository = new ScheduledMessageRepository();
                        foreach (TeamMemberProfile item in objTeamMemberProfile)
                        {
                            profileid += item.ProfileId + ',';
                        }

                        profileid = profileid.Substring(0, profileid.Length - 1);

                        spanSent.InnerHtml = objScheduledMessageRepository.getAllSentMessageDetails(profileid).Count().ToString();
                    }

                    catch (Exception Err)
                    {
                        Console.Write(Err.StackTrace);
                        logger.Error(Err.StackTrace);
                    }
                }


                #endregion
            }

            catch (Exception Err)
            {
                Console.Write(Err.StackTrace);
            }
        }
Exemplo n.º 4
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");
            }
        }
Exemplo n.º 5
0
        public void ProcessRequest()
        {
            if (Request.QueryString["op"] == "login")
            {
                try
                {
                    string       email    = Request.QueryString["username"];
                    string       password = Request.QueryString["password"];
                    Registration regpage  = new Registration();
                    password = regpage.MD5Hash(password);
                    SocioBoard.Helper.SessionFactory.configfilepath = Server.MapPath("~/hibernate.cfg.xml");
                    UserRepository      userrepo               = new UserRepository();
                    LoginLogs           objLoginLogs           = new LoginLogs();
                    LoginLogsRepository objLoginLogsRepository = new LoginLogsRepository();
                    User user = userrepo.GetUserInfo(email, password);
                    if (user == null)
                    {
                        Response.Write("Invalid Email or Password");
                    }
                    else
                    {
                        if (user.UserStatus == 1)
                        {
                            Session["LoggedUser"] = user;
                            // List<User> lstUser = new List<User>();
                            if (Session["LoggedUser"] != null)
                            {
                                //SocioBoard.Domain.User.lstUser.Add((User)Session["LoggedUser"]);
                                //Application["OnlineUsers"] = SocioBoard.Domain.User.lstUser;
                                //objLoginLogs.Id = new Guid();
                                //objLoginLogs.UserId = user.Id;
                                //objLoginLogs.UserName = user.UserName;
                                //objLoginLogs.LoginTime = DateTime.Now.AddHours(11.50);
                                //objLoginLogsRepository.Add(objLoginLogs);
                                Groups          objGroups          = new Groups();
                                GroupRepository objGroupRepository = new GroupRepository();
                                Team            objteam            = new Team();
                                TeamRepository  objTeamRepository  = new TeamRepository();
                                objGroups = objGroupRepository.getGroupDetail(user.Id);
                                if (objGroups == null)
                                {
                                    //================================================================================
                                    //Insert into group

                                    try
                                    {
                                        objGroups           = new Groups();
                                        objGroups.Id        = Guid.NewGuid();
                                        objGroups.GroupName = ConfigurationManager.AppSettings["DefaultGroupName"];
                                        objGroups.UserId    = user.Id;
                                        objGroups.EntryDate = DateTime.Now;
                                        objGroupRepository.AddGroup(objGroups);

                                        objteam.Id      = Guid.NewGuid();
                                        objteam.GroupId = objGroups.Id;
                                        objteam.UserId  = user.Id;
                                        objteam.EmailId = user.EmailId;
                                        // teams.FirstName = user.UserName;
                                        objTeamRepository.addNewTeam(objteam);

                                        SocialProfile            objSocialProfile            = new SocialProfile();
                                        SocialProfilesRepository objSocialProfilesRepository = new SocialProfilesRepository();

                                        List <SocialProfile> lstSocialProfile = objSocialProfilesRepository.getAllSocialProfilesOfUser(user.Id);
                                        if (lstSocialProfile != null)
                                        {
                                            if (lstSocialProfile.Count > 0)
                                            {
                                                foreach (SocialProfile item in lstSocialProfile)
                                                {
                                                    try
                                                    {
                                                        TeamMemberProfile           objTeamMemberProfile           = new TeamMemberProfile();
                                                        TeamMemberProfileRepository objTeamMemberProfileRepository = new TeamMemberProfileRepository();
                                                        objTeamMemberProfile.Id               = Guid.NewGuid();
                                                        objTeamMemberProfile.TeamId           = objteam.Id;
                                                        objTeamMemberProfile.ProfileId        = item.ProfileId;
                                                        objTeamMemberProfile.ProfileType      = item.ProfileType;
                                                        objTeamMemberProfile.Status           = item.ProfileStatus;
                                                        objTeamMemberProfile.StatusUpdateDate = DateTime.Now;
                                                        objTeamMemberProfileRepository.addNewTeamMember(objTeamMemberProfile);
                                                    }
                                                    catch (Exception ex)
                                                    {
                                                        Console.WriteLine(ex.Message);
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                        Console.WriteLine(ex.Message);
                                        logger.Error("Error : " + ex.Message);
                                        logger.Error("Error : " + ex.StackTrace);
                                    }

                                    //==========================================================================================================
                                }

                                BusinessSetting           objBusinessSetting           = new BusinessSetting();
                                BusinessSettingRepository objBusinessSettingRepository = new BusinessSettingRepository();
                                List <BusinessSetting>    lstBusinessSetting           = objBusinessSettingRepository.GetBusinessSettingByUserId(user.Id);
                                if (lstBusinessSetting.Count == 0)
                                {
                                    try
                                    {
                                        List <Groups> lstGroups = objGroupRepository.getAllGroups(user.Id);
                                        foreach (Groups item in lstGroups)
                                        {
                                            objBusinessSetting              = new BusinessSetting();
                                            objBusinessSetting.Id           = Guid.NewGuid();
                                            objBusinessSetting.BusinessName = item.GroupName;
                                            //objbsnssetting.GroupId = team.GroupId;
                                            objBusinessSetting.GroupId          = item.Id;
                                            objBusinessSetting.AssigningTasks   = false;
                                            objBusinessSetting.AssigningTasks   = false;
                                            objBusinessSetting.TaskNotification = false;
                                            objBusinessSetting.TaskNotification = false;
                                            objBusinessSetting.FbPhotoUpload    = 0;
                                            objBusinessSetting.UserId           = user.Id;
                                            objBusinessSetting.EntryDate        = DateTime.Now;
                                            objBusinessSettingRepository.AddBusinessSetting(objBusinessSetting);
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                        Console.WriteLine(ex.StackTrace);
                                    }
                                }
                            }
                            Response.Write("user");
                        }

                        else
                        {
                            Response.Write("You are Blocked by Admin Please contact Admin!");
                        }
                    }
                }
                catch (Exception ex)
                {
                    Response.Write("Error: " + ex.Message);
                    Console.WriteLine(ex.StackTrace);
                    logger.Error(ex.StackTrace);
                }
            }
            else if (Request.QueryString["op"] == "register")
            {
                User           user = new User();
                UserActivation objUserActivation = new UserActivation();
                UserRepository userrepo          = new UserRepository();
                SocioBoard.Helper.SessionFactory.configfilepath = Server.MapPath("~/hibernate.cfg.xml");
                Session["AjaxLogin"] = "******";
                try
                {
                    System.IO.StreamReader sr = new System.IO.StreamReader(Request.InputStream);
                    string line = "";
                    line = sr.ReadToEnd();
                    JObject jo = JObject.Parse(line);
                    user.PaymentStatus = "unpaid";
                    if (!string.IsNullOrEmpty(Request.QueryString["type"]))
                    {
                        user.AccountType = Request.QueryString["type"];
                    }
                    else
                    {
                        user.AccountType = "deluxe";
                    }
                    user.CreateDate = DateTime.Now;
                    user.ExpiryDate = DateTime.Now.AddMonths(1);
                    user.Id         = Guid.NewGuid();
                    user.UserName   = Server.UrlDecode((string)jo["firstname"]) + " " + Server.UrlDecode((string)jo["lastname"]);
                    user.EmailId    = Server.UrlDecode((string)jo["email"]);
                    user.Password   = Server.UrlDecode((string)jo["password"]);
                    user.UserStatus = 1;
                    if (!userrepo.IsUserExist(user.EmailId))
                    {
                        UserRepository.Add(user);
                        Session["LoggedUser"] = user;
                        Response.Write("user");

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

                        //add value in userpackage
                        UserPackageRelation           objUserPackageRelation           = new UserPackageRelation();
                        UserPackageRelationRepository objUserPackageRelationRepository = new UserPackageRelationRepository();
                        PackageRepository             objPackageRepository             = new PackageRepository();

                        Package objPackage = objPackageRepository.getPackageDetails(user.AccountType);
                        objUserPackageRelation.Id            = new Guid();
                        objUserPackageRelation.PackageId     = objPackage.Id;
                        objUserPackageRelation.UserId        = user.Id;
                        objUserPackageRelation.PackageStatus = true;

                        objUserPackageRelationRepository.AddUserPackageRelation(objUserPackageRelation);


                        SocioBoard.Helper.MailSender.SendEMail(user.UserName, user.Password, user.EmailId, user.AccountType.ToString(), user.Id.ToString());



                        //MailSender.SendEMail(user.UserName, user.Password, user.EmailId);
                        // lblerror.Text = "Registered Successfully !" + "<a href=\"login.aspx\">Login</a>";
                    }
                    else
                    {
                        Response.Write("Email Already Exists !");
                    }
                }


                catch (Exception ex)
                {
                    logger.Error(ex.StackTrace);


                    Console.WriteLine(ex.StackTrace);
                }
            }
            else if (Request.QueryString["op"] == "facebooklogin")
            {
                SessionFactory.configfilepath = Server.MapPath("~/hibernate.cfg.xml");

                string redi = "http://www.facebook.com/dialog/oauth/?scope=publish_stream,read_stream,read_insights,manage_pages,user_checkins,user_photos,read_mailbox,manage_notifications,read_page_mailboxes,email,user_videos,offline_access&client_id=" + ConfigurationManager.AppSettings["ClientId"] + "&redirect_uri=" + ConfigurationManager.AppSettings["RedirectUrl"] + "&response_type=code";
                Session["login"] = "******";
                Response.Write(redi);
            }
            else if (Request.QueryString["op"] == "googlepluslogin")
            {
                Session["login"] = "******";
                oAuthToken objToken = new oAuthToken();
                Response.Write(objToken.GetAutherizationLink("https://www.googleapis.com/auth/userinfo.email+https://www.googleapis.com/auth/userinfo.profile+https://www.googleapis.com/auth/plus.me+https://www.googleapis.com/auth/plus.login"));
            }
            else if (Request.QueryString["op"] == "removeuser")
            {
                try
                {
                    if (Session["LoggedUser"] != null)
                    {
                        SocioBoard.Domain.User.lstUser.Remove((User)Session["LoggedUser"]);
                    }
                }
                catch (Exception Err)
                {
                    logger.Error(Err.StackTrace);
                    Response.Write(Err.StackTrace);
                }
            }
        }
Exemplo n.º 6
0
        public void GetLinkedInUserProfile(dynamic data, oAuthLinkedIn _oauth, Guid user, string LinkedinUserId)
        {
            SocialProfile             socioprofile       = new SocialProfile();
            SocialProfilesRepository  socioprofilerepo   = new SocialProfilesRepository();
            LinkedInAccount           objLinkedInAccount = new LinkedInAccount();
            LinkedInAccountRepository objLiRepo          = new LinkedInAccountRepository();

            try
            {
                objLinkedInAccount.UserId         = user;
                objLinkedInAccount.LinkedinUserId = data.id.ToString();
                try
                {
                    objLinkedInAccount.EmailId = data.email.ToString();
                }
                catch { }
                objLinkedInAccount.LinkedinUserName = data.first_name.ToString() + data.last_name.ToString();
                objLinkedInAccount.OAuthToken       = _oauth.Token;
                objLinkedInAccount.OAuthSecret      = _oauth.TokenSecret;
                objLinkedInAccount.OAuthVerifier    = _oauth.Verifier;
                try
                {
                    objLinkedInAccount.ProfileImageUrl = data.picture_url.ToString();
                }
                catch { }
                try
                {
                    objLinkedInAccount.ProfileUrl = data.profile_url.ToString();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);
                }
                objLinkedInAccount.Connections = data.connections;
                objLinkedInAccount.IsActive    = true;

                socioprofile.UserId        = user;
                socioprofile.ProfileType   = "linkedin";
                socioprofile.ProfileId     = LinkedinUserId;
                socioprofile.ProfileStatus = 1;
                socioprofile.ProfileDate   = DateTime.Now;
                socioprofile.Id            = Guid.NewGuid();
            }
            catch
            {
            }
            try
            {
                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        = socioprofile.ProfileId;
                        teammemberprofile.ProfileType      = "linkedin";
                        teammemberprofile.StatusUpdateDate = DateTime.Now;

                        objTeamMemberProfileRepository.addNewTeamMember(teammemberprofile);
                    }
                }
                else
                {
                    socioprofile.ProfileId = data.id.ToString();
                    socioprofilerepo.updateSocialProfile(socioprofile);
                }
                if (!objLiRepo.checkLinkedinUserExists(LinkedinUserId, user))
                {
                    objLiRepo.addLinkedinUser(objLinkedInAccount);
                }
                else
                {
                    objLinkedInAccount.LinkedinUserId = LinkedinUserId;
                    objLiRepo.updateLinkedinUser(objLinkedInAccount);
                }
                // GetLinkedInFeeds(_oauth, data.id, user.Id);
            }
            catch
            {
            }
        }
Exemplo n.º 7
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);
            }
        }
Exemplo n.º 8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                User user = (User)Session["LoggedUser"];
                SocioBoard.Domain.Team team = (SocioBoard.Domain.Team)Session["GroupName"];
                try
                {
                    #region for You can use only 30 days as Unpaid User

                    if (user.PaymentStatus.ToLower() == "unpaid")
                    {
                        if (!SBUtils.IsUserWorkingDaysValid(user.ExpiryDate))
                        {
                            Session["GreaterThan30Days"] = "GreaterThan30Days";
                            Response.Redirect("../Settings/Billing.aspx");
                        }
                    }
                    #endregion
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Error : " + ex.StackTrace);
                }

                //if (!IsPostBack)
                //{
                string profileid         = string.Empty;
                string LinkedINprofileid = string.Empty;
                if (user == null)
                {
                    Response.Redirect("/Default.aspx");
                }

                SocioBoard.Domain.FacebookAccount objFacebookAccount;
                TeamMemberProfileRepository       objTeamMemberProfileRepository = new TeamMemberProfileRepository();
                List <TeamMemberProfile>          allprofiles         = objTeamMemberProfileRepository.getTeamMemberProfileData(team.Id);
                List <TeamMemberProfile>          allLinkedInprofiles = objTeamMemberProfileRepository.getLinkedInTeamMemberProfileData(team.Id);
                oAuthLinkedIn objoAuthLinkedIn = new oAuthLinkedIn();
                try
                {
                    if (allLinkedInprofiles.Count != 0)
                    {
                        foreach (TeamMemberProfile item in allLinkedInprofiles)
                        {
                            LinkedINprofileid += item.ProfileId + ',';
                        }
                        LinkedINprofileid = LinkedINprofileid.Substring(0, LinkedINprofileid.Length - 1);
                        List <LinkedInAccount> arrLinkedInAccount = linkedrepo.getAllAccountDetail(LinkedINprofileid);

                        foreach (var item in arrLinkedInAccount)
                        {
                            objoAuthLinkedIn.Token       = item.OAuthToken;
                            objoAuthLinkedIn.Verifier    = item.OAuthVerifier;
                            objoAuthLinkedIn.TokenSecret = item.OAuthSecret;

                            //if (item.LinkedinUserName.Length > 15)
                            //{
                            //    item.LinkedinUserName = item.LinkedinUserName.Substring(0, 14);
                            //    item.LinkedinUserName = item.LinkedinUserName + "..";
                            //}
                            //else
                            //{
                            //    item.LinkedinUserName = item.LinkedinUserName;
                            //}

                            leftsidedata += "<div class=\"accordion-group\"><div class=\"accordion-heading\">"
                                            + "<a href=\"#" + item.Id + "\" data-parent=\"#accordion2\" data-toggle=\"collapse\" class=\"accordion-toggle\">"
                                            + "<img width=\"19\" class=\"fesim\" src=\"" + item.ProfileImageUrl + "\" /><span class=\"groupname\">" + item.LinkedinUserName + " </span><i class=\"icon-sort-down pull-right hidden\">"
                                            + "</i></a></div><div id=\"" + item.Id + "\" class=\"accordion-body collapse\" ><div class=\"accordion-inner\"><ul>";
                            List <GlobusLinkedinLib.App.Core.LinkedInGroup.Group_Updates> lstlinkedinGroup = GetGroupsName(objoAuthLinkedIn);
                            if (lstlinkedinGroup.Count == 0)
                            {
                                leftsidedata += "<li><a  linkedInUserId=\"" + item.LinkedinUserId + "\">No Group Found</a> </li>";
                            }
                            else
                            {
                                foreach (var item1 in lstlinkedinGroup)
                                {
                                    leftsidedata += "<li class=\"pull-left\"> <input style=\"float: left;\" type=\"checkbox\" id=\"" + item.LinkedinUserId + "_lin_" + item1.id + "\" value=\"lin_" + item.LinkedinUserId + "\"><a gid=\"" + item1.id + "\" onclick=\"linkedingroupdetails('" + item1.id + "','" + item.LinkedinUserId + "');\" linkedInUserId=\"" + item.LinkedinUserId + "\" style=\"margin-left: 20px;\" href=\"#\">" + item1.GroupName + "</a> </li>";
                                }
                            }
                            leftsidedata += "</ul></div></div></div>";
                        }
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);
                }

                if (allprofiles.Count != 0)
                {
                    foreach (TeamMemberProfile item in allprofiles)
                    {
                        profileid += item.ProfileId + ',';
                    }
                    profileid = profileid.Substring(0, profileid.Length - 1);
                    List <FacebookAccount> arrFacebookAccount = fbAccRepo.getAllAccountDetail(profileid);

                    foreach (var item in arrFacebookAccount)
                    {
                        objFacebookAccount = new FacebookAccount();
                        objFacebookAccount = (SocioBoard.Domain.FacebookAccount)item;

                        //if (objFacebookAccount.FbUserName.Length > 15)
                        //{
                        //    objFacebookAccount.FbUserName = objFacebookAccount.FbUserName.Substring(0, 14);
                        //    objFacebookAccount.FbUserName = objFacebookAccount.FbUserName + "..";
                        //}
                        //else
                        //{
                        //    objFacebookAccount.FbUserName = objFacebookAccount.FbUserName;
                        //}

                        if (objFacebookAccount.Type != "page")
                        {
                            leftsidedata += "<div class=\"accordion-group\"><div class=\"accordion-heading\">"
                                            + "<a href=\"#" + objFacebookAccount.Id + "\" data-parent=\"#accordion2\" data-toggle=\"collapse\" class=\"accordion-toggle\">"
                                            + "<img width=\"19\" class=\"fesim\" src=\"http://graph.facebook.com/" + objFacebookAccount.FbUserId + "/picture?type=small\" alt=\"\" /><span class=\"groupname\">" + objFacebookAccount.FbUserName + " </span><i class=\"icon-sort-down pull-right hidden\">"
                                            + "</i></a></div><div id=\"" + objFacebookAccount.Id + "\" class=\"accordion-body collapse\" ><div class=\"accordion-inner\"><ul>";

                            List <FacebookGroup> lstFacebookGroup = GetGroupName(objFacebookAccount.AccessToken);
                            if (lstFacebookGroup.Count == 0)
                            {
                                leftsidedata += "<li><a  fbUserId=\"" + objFacebookAccount.FbUserId + "\">No Group Found</a> </li>";
                            }
                            else
                            {
                                foreach (var item1 in lstFacebookGroup)
                                {
                                    //leftsidedata += "<li class=\"grpli\"><a gid=\"" + item1.GroupId + "\" onclick=\"facebookgroupdetails('" + item1.GroupId + "','" + objFacebookAccount.AccessToken + "');\" fbUserId=\"" + objFacebookAccount.FbUserId + "\" href=\"#\">" + item1.Name + "</a> </li>";

                                    leftsidedata += "<li class=\"pull-left\"><input style=\"float: left;\" type=\"checkbox\" id=\"" + objFacebookAccount.FbUserId + "_fb_" + item1.GroupId + "\" value=\"fb_" + objFacebookAccount.AccessToken + "\"><a gid=\"" + item1.GroupId + "\" onclick=\"facebookgroupdetails('" + item1.GroupId + "','" + objFacebookAccount.AccessToken + "');\" fbUserId=\"" + objFacebookAccount.FbUserId + "\" style=\"margin-left: 20px;\" href=\"#\">" + item1.Name + "</a> </li>";
                                }
                            }
                            leftsidedata += "</ul></div></div></div>";
                        }
                    }
                }
                accordion2.InnerHtml = leftsidedata;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
            }
        }
Exemplo n.º 9
0
        protected void btnSendInvite_Click(object sender, EventArgs e)
        {
            try
            {
                int      totalchkboxes      = Convert.ToInt32(totalaccountscheck.InnerHtml.ToString());
                string[] totalchkboxesArray = new string[totalchkboxes];


                int jj = 0;
                for (int i = 0; i < totalchkboxes; i++)
                {
                    if (Page.Request.Form["chkbox_" + i + ""] != null)
                    {
                        totalchkboxesArray[jj] = Page.Request.Form["chkbox_" + i + ""].ToString();
                        jj++;
                    }
                }

                if (jj > 0)
                {
                    if (!string.IsNullOrEmpty(txtEmail.Text) && !string.IsNullOrEmpty(txtFirstName.Text) && !string.IsNullOrEmpty(txtLastName.Text))
                    {
                        if (txtEmail.Text != "Enter Email Address" && txtFirstName.Text != "First Name" && txtLastName.Text != "Last Name")
                        {
                            // if (rbAdmin.Checked || rbUser.Checked)
                            // {
                            //if (rbAdmin.Checked)
                            //{
                            //    AccessLevel = "admin";
                            //}
                            //else if (rbUser.Checked)
                            //{
                            //    AccessLevel = "user";
                            //}

                            // if (AccessLevel != string.Empty)
                            // {
                            TeamRepository teamrepo = new TeamRepository();
                            Team           team     = null;
                            Guid           gpId     = (Guid)Session["GroupId"];
                            User           user     = (User)Session["LoggedUser"];
                            if (!teamrepo.checkTeamExists(txtEmail.Text, user.Id, gpId))
                            {
                                team                  = new Team();
                                team.Id               = Guid.NewGuid();
                                team.GroupId          = (Guid)Session["GroupId"];
                                team.FirstName        = txtFirstName.Text;
                                team.LastName         = txtLastName.Text;
                                team.StatusUpdateDate = DateTime.Now;
                                team.EmailId          = txtEmail.Text;
                                team.UserId           = user.Id;
                                team.InviteStatus     = 1;
                                team.InviteDate       = DateTime.Now;
                                // team.AccessLevel = AccessLevel;
                                teamrepo.addNewTeam(team);
                            }
                            else
                            {
                                // team = teamrepo.getMemberByEmailId(user.Id, txtEmail.Text);

                                Response.Write("<script>alert(\"Already invited in this group\");</script>");
                            }

                            MailSender.SendInvitationEmail(team.FirstName + " " + team.LastName, user.UserName, team.EmailId, team.Id);
                            if (totalchkboxesArray.Count() != 0)
                            {
                                TeamMemberProfileRepository teammemberprofilerepo = new TeamMemberProfileRepository();
                                foreach (var item in totalchkboxesArray)
                                {
                                    try
                                    {
                                        if (!string.IsNullOrEmpty(item))
                                        {
                                            string[]          itemarray  = item.Split('_');
                                            TeamMemberProfile teammember = new TeamMemberProfile();
                                            teammember.Id               = Guid.NewGuid();
                                            teammember.ProfileId        = itemarray[1];
                                            teammember.ProfileType      = itemarray[0];
                                            teammember.Status           = 1;
                                            teammember.StatusUpdateDate = DateTime.Now;
                                            teammember.TeamId           = team.Id;
                                            if (!teammemberprofilerepo.checkTeamMemberProfile(teammember.TeamId, teammember.ProfileId))
                                            {
                                                teammemberprofilerepo.addNewTeamMember(teammember);
                                            }
                                            else
                                            {
                                                teammemberprofilerepo.updateTeamMember(teammember);
                                            }
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                        Console.WriteLine(ex.StackTrace);
                                    }
                                }
                                Response.Redirect("InviteMember.aspx");
                            }
                            txtFirstName.Text = "";
                            txtLastName.Text  = "";
                            txtEmail.Text     = "";
                            //  rbAdmin.Checked = false;
                            // rbUser.Checked = false;
                            Label1.Text = "Invitation Sends";
                            //  }

                            // }

                            //else
                            //{
                            //    Response.Write("<script>alert(\"Please fill Group Name\");</script>");
                            //}
                        }
                    }
                }
                else
                {
                    ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "MyFun1", "disp_confirm();", true);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
            }
        }
Exemplo n.º 10
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);
        }
Exemplo n.º 11
0
        public void getFacebookUserProfile(dynamic data, string accesstoken, long friends, Guid user)
        {
            SocialProfile socioprofile = new SocialProfile();
            //SocialProfilesRepository socioprofilerepo = new SocialProfilesRepository();
            Api.SocialProfile.SocialProfile ApiObjSocialProfile = new Api.SocialProfile.SocialProfile();
            FacebookAccount fbAccount = new FacebookAccount();
            //FacebookAccountRepository fbrepo = new FacebookAccountRepository();
            Api.FacebookFeed.FacebookFeed ApiObjFacebookFeed = new Api.FacebookFeed.FacebookFeed();
            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);
            }
        }
Exemplo n.º 12
0
        public void getFacebookUserProfile(dynamic data, string accesstoken, long friends, Guid user)
        {
            SocialProfile socioprofile = new SocialProfile();

            //SocialProfilesRepository socioprofilerepo = new SocialProfilesRepository();
            Api.SocialProfile.SocialProfile ApiObjSocialProfile = new Api.SocialProfile.SocialProfile();
            FacebookAccount fbAccount = new FacebookAccount();

            //FacebookAccountRepository fbrepo = new FacebookAccountRepository();
            Api.FacebookFeed.FacebookFeed ApiObjFacebookFeed = new Api.FacebookFeed.FacebookFeed();
            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);
            }
        }
Exemplo n.º 13
0
        private void GetAccessToken()
        {
            try
            {
                User user = (User)Session["LoggedUser"];
                if (user == null)
                {
                    Response.Redirect("Default.aspx");
                }
                oAuthTumbler requestHelper = new oAuthTumbler();



                string code = Request.QueryString["oauth_verifier"];
                string AccessTokenResponse = string.Empty;

                try
                {
                    AccessTokenResponse = requestHelper.GetAccessToken(oAuthTumbler.TumblrToken, code);
                }
                catch (Exception ex)
                {
                    logger.Error("AccessTokenResponse: " + ex.Message);
                    logger.Error("AccessTokenResponse: " + ex.StackTrace);
                }

                string[] tokens            = AccessTokenResponse.Split('&'); //extract access token & secret from response
                string   accessToken       = tokens[0].Split('=')[1];
                string   accessTokenSecret = tokens[1].Split('=')[1];

                KeyValuePair <string, string> LoginDetails = new KeyValuePair <string, string>(accessToken, accessTokenSecret);


                string sstr = string.Empty;

                try
                {
                    sstr = oAuthTumbler.OAuthData(Globals.UsersDashboardUrl, "GET", LoginDetails.Key, LoginDetails.Value, null);
                }
                catch (Exception ex)
                {
                    logger.Error("sstr: " + ex.Message);
                    logger.Error("sstr: " + ex.StackTrace);
                }

                JObject profile = new JObject();
                try
                {
                    profile = JObject.Parse(oAuthTumbler.OAuthData(Globals.UsersInfoUrl, "GET", LoginDetails.Key, LoginDetails.Value, null));
                }
                catch (Exception ex)
                {
                    logger.Error("profile: " + ex.Message);
                    logger.Error("profile: " + ex.StackTrace);
                }
                JObject                  UserDashboard               = JObject.Parse(oAuthTumbler.OAuthData(Globals.UsersDashboardUrl, "GET", LoginDetails.Key, LoginDetails.Value, null));
                TumblrAccount            objTumblrAccount            = new TumblrAccount();
                TumblrAccountRepository  objTumblrAccountRepository  = new TumblrAccountRepository();
                SocialProfile            objSocialProfile            = new SocialProfile();
                SocialProfilesRepository objSocialProfilesRepository = new SocialProfilesRepository();
                objSocialProfile.Id        = Guid.NewGuid();
                objSocialProfile.UserId    = user.Id;
                objSocialProfile.ProfileId = profile["response"]["user"]["name"].ToString();

                objSocialProfile.ProfileType   = "tumblr";
                objSocialProfile.ProfileDate   = DateTime.Now;
                objSocialProfile.ProfileStatus = 1;

                objTumblrAccount.Id                    = Guid.NewGuid();
                objTumblrAccount.tblrUserName          = profile["response"]["user"]["name"].ToString();
                objTumblrAccount.UserId                = user.Id;
                objTumblrAccount.tblrAccessToken       = accessToken;
                objTumblrAccount.tblrAccessTokenSecret = accessTokenSecret;


                objTumblrAccount.tblrProfilePicUrl = profile["response"]["user"]["name"].ToString();
                objTumblrAccount.IsActive          = 1;
                if (!objSocialProfilesRepository.checkUserProfileExist(objSocialProfile))
                {
                    objSocialProfilesRepository.addNewProfileForUser(objSocialProfile);
                    if (!objTumblrAccountRepository.checkTubmlrUserExists(objTumblrAccount))
                    {
                        TumblrAccountRepository.Add(objTumblrAccount);

                        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        = objTumblrAccount.tblrUserName;
                            teammemberprofile.ProfileType      = "tumblr";
                            teammemberprofile.StatusUpdateDate = DateTime.Now;

                            objTeamMemberProfileRepository.addNewTeamMember(teammemberprofile);
                        }
                    }
                }
                else
                {
                    if (!objTumblrAccountRepository.checkTubmlrUserExists(objTumblrAccount))
                    {
                        TumblrAccountRepository.Add(objTumblrAccount);
                    }
                    else
                    {
                        Response.Redirect("Home.aspx");
                    }
                }

                JArray objJarray = (JArray)UserDashboard["response"]["posts"];

                logger.Error("objJarray: " + objJarray);

                if (objJarray != null)
                {
                    logger.Error("objJarray lenght : " + objJarray.Count);
                }
                else
                {
                    logger.Error("objJarray is NULL");
                }

                TumblrFeed           objTumblrFeed           = new TumblrFeed();
                TumblrFeedRepository objTumblrFeedRepository = new TumblrFeedRepository();
                foreach (var item in objJarray)
                {
                    objTumblrFeed.Id     = Guid.NewGuid();
                    objTumblrFeed.UserId = user.Id;
                    try
                    {
                        objTumblrFeed.ProfileId = profile["response"]["user"]["name"].ToString();
                        logger.Error("objTumblrFeed.ProfileId : " + objTumblrFeed.ProfileId);
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.Message);
                        logger.Error(ex.StackTrace);
                        Console.WriteLine(ex.Message);
                    }
                    try
                    {
                        objTumblrFeed.blogname = item["blog_name"].ToString();
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.Message);
                        logger.Error(ex.StackTrace);
                        Console.WriteLine(ex.Message);
                    }
                    try
                    {
                        objTumblrFeed.blogId = item["id"].ToString();
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.Message);
                        logger.Error(ex.StackTrace);
                        Console.WriteLine(ex.Message);
                    }
                    try
                    {
                        objTumblrFeed.blogposturl = item["post_url"].ToString();
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.Message);
                        logger.Error(ex.StackTrace);
                        Console.WriteLine(ex.Message);
                    }
                    try
                    {
                        String result = item["caption"].ToString();
                        objTumblrFeed.description = Regex.Replace(result, @"<[^>]*>", String.Empty);
                    }
                    catch (Exception ex)
                    {
                        objTumblrFeed.description = null;
                        logger.Error(ex.Message);
                        logger.Error(ex.StackTrace);
                        Console.WriteLine(ex.Message);
                    }
                    try
                    {
                        objTumblrFeed.slug = item["slug"].ToString();
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.Message);
                        logger.Error(ex.StackTrace);
                        Console.WriteLine(ex.Message);
                    }
                    try
                    {
                        objTumblrFeed.type = item["type"].ToString();
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.Message);
                        logger.Error(ex.StackTrace);
                        Console.WriteLine(ex.Message);
                    }
                    try
                    {
                        string   test = item["date"].ToString();
                        DateTime dt;
                        if (test.Contains("GMT"))
                        {
                            test = test.Replace("GMT", "").Trim().ToString();
                            dt   = Convert.ToDateTime(test);
                        }
                        else
                        {
                            test = test.Replace("GMT", "").Trim().ToString();
                            dt   = Convert.ToDateTime(test);
                        }
                        objTumblrFeed.date = dt;
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.Message);
                        logger.Error(ex.StackTrace);
                        Console.WriteLine(ex.Message);
                    }
                    try
                    {
                        objTumblrFeed.reblogkey = item["reblog_key"].ToString();
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.Message);
                        logger.Error(ex.StackTrace);
                        Console.WriteLine(ex.Message);
                    }
                    try
                    {
                        string str = item["liked"].ToString();
                        if (str == "False")
                        {
                            objTumblrFeed.liked = 0;
                        }
                        else
                        {
                            objTumblrFeed.liked = 1;
                        }
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.Message);
                        logger.Error(ex.StackTrace);
                        Console.WriteLine(ex.Message);
                    }
                    try
                    {
                        string str = item["followed"].ToString();
                        if (str == "false")
                        {
                            objTumblrFeed.followed = 0;
                        }
                        else
                        {
                            objTumblrFeed.followed = 1;
                        }
                        // objTumblrDashboard.followed = Convert.ToInt16(item["followed"]);
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.Message);
                        logger.Error(ex.StackTrace);
                        Console.WriteLine(ex.Message);
                    }
                    try
                    {
                        objTumblrFeed.canreply = Convert.ToInt16(item["can_reply"]);
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.Message);
                        logger.Error(ex.StackTrace);
                        Console.WriteLine(ex.Message);
                    }
                    try
                    {
                        objTumblrFeed.sourceurl = item["source_url"].ToString();
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.Message);
                        logger.Error(ex.StackTrace);
                        Console.WriteLine(ex.Message);
                    }
                    try
                    {
                        objTumblrFeed.sourcetitle = item["source_title"].ToString();
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.Message);
                        logger.Error(ex.StackTrace);
                        Console.WriteLine(ex.Message);
                    }
                    try
                    {
                        JArray asdasd12 = (JArray)item["photos"];
                        foreach (var item1 in asdasd12)
                        {
                            objTumblrFeed.imageurl = item1["original_size"]["url"].ToString();
                        }
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.Message);
                        logger.Error(ex.StackTrace);
                        Console.WriteLine(ex.Message);
                    }
                    try
                    {
                        objTumblrFeed.videourl = item["permalink_url"].ToString();
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.Message);
                        logger.Error(ex.StackTrace);
                        Console.WriteLine(ex.Message);
                    }

                    try
                    {
                        string str = item["note_count"].ToString();
                        objTumblrFeed.notes = Convert.ToInt16(str);
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.Message);
                        logger.Error(ex.StackTrace);
                        Console.WriteLine(ex.Message);
                    }

                    objTumblrFeed.timestamp = DateTime.Now;
                    if (!objTumblrFeedRepository.checkTumblrMessageExists(objTumblrFeed))
                    {
                        try
                        {
                            logger.Error("objTumblrFeedRepository.checkTumblrMessageExists " + objTumblrAccount.Id);
                            TumblrFeedRepository.Add(objTumblrFeed);
                        }
                        catch (Exception ex)
                        {
                            logger.Error("Exception : objTumblrFeedRepository.checkTumblrMessageExists " + objTumblrAccount.Id);
                            logger.Error(ex.Message);
                            logger.Error(ex.StackTrace);
                        }
                    }
                }
                Response.Redirect("Home.aspx");
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message);
                logger.Error(ex.StackTrace);
            }
        }
Exemplo n.º 14
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                SocioBoard.Domain.User user = (User)Session["LoggedUser"];
                if (user == null)
                {
                    Response.Redirect("/Default.aspx");
                }


                TwitterAccountRepository    objtwtAccRepo = new TwitterAccountRepository();
                TeamMemberProfileRepository objTeamMemberProfileRepository = new TeamMemberProfileRepository();


                SocioBoard.Domain.Team team = (SocioBoard.Domain.Team)Session["GroupName"];

                List <TeamMemberProfile> allprofiles = objTeamMemberProfileRepository.getTwtTeamMemberProfileData(team.Id);

                foreach (TeamMemberProfile item in allprofiles)
                {
                    TwtProfileId += item.ProfileId + ',';
                }
                TwtProfileId = TwtProfileId.Substring(0, TwtProfileId.Length - 1);


                List <TwitterAccount> arrTwtAcc = objtwtAccRepo.getAllAccountDetail(TwtProfileId);
                string twtUser      = string.Empty;
                string twtProfileId = string.Empty;

                spandiv.InnerHtml = "from " + DateTime.Now.AddDays(-15).ToShortDateString() + "-" + DateTime.Now.ToShortDateString();
                foreach (TwitterAccount item in arrTwtAcc)
                {
                    twtUser                 = twtUser + "<div  class=\"teitter\"><ul><li><a id=\"facebook_connect\" onclick='getProfileGraph(\"" + item.TwitterUserId + "\",\"" + item.TwitterScreenName + "\",\"" + item.ProfileImageUrl + "\",\"" + item.FollowersCount + "\")'><span style=\"float:left;margin: 3px 0 0 5px;\" >" + item.TwitterScreenName + "</span></a></li></ul></div>";
                    twtProfileId            = item.TwitterUserId;
                    divnameId.InnerHtml     = item.TwitterScreenName;
                    profileImg.ImageUrl     = item.ProfileImageUrl;
                    spanFollowers.InnerHtml = item.FollowersCount.ToString();
                    Session["twtProfileId"] = twtProfileId;
                }
                divtwtUser.InnerHtml = twtUser;
                try
                {
                    strTwtArray = objtwtStatsHelper.getNewFollowers(twtProfileId, 15);
                    int index = strTwtArray.LastIndexOf(',');
                    divnewFollower.InnerHtml = strTwtArray.Substring(index + 1);
                }
                catch (Exception Err)
                {
                    Console.Write(Err.StackTrace);
                }
                try
                {
                    strTwtFollowing = objtwtStatsHelper.getNewFollowing(twtProfileId, 15);
                    int index = strTwtFollowing.LastIndexOf(',');
                    divFollowed.InnerHtml = strTwtArray.Substring(index + 1);
                }
                catch (Exception Err)
                {
                    Console.Write(Err.StackTrace);
                }
                try
                {
                    strTwtAge = objtwtStatsRepo.getAgeDiffCount(twtProfileId, 15);
                }
                catch (Exception Err)
                {
                    Console.Write(Err.StackTrace);
                }
                try
                {
                    strIncomingMsg = objtwtStatsHelper.getIncomingMsg(twtProfileId, 15);
                }
                catch (Exception Err)
                {
                    Console.Write(Err.StackTrace);
                }
                try
                {
                    strDmRecieve = objtwtStatsHelper.getDirectMessageRecieve(twtProfileId, 15);
                }
                catch (Exception Err)
                {
                    Console.Write(Err.StackTrace);
                }
                try
                {
                    strDMSent = objtwtStatsHelper.getDirectMessageSent(twtProfileId, 15);
                }
                catch (Exception Err)
                {
                    Console.Write(Err.StackTrace);
                }
                try
                {
                    strSentMsg = objtwtStatsHelper.getSentMsg(twtProfileId, 15);
                }
                catch (Exception Err)
                {
                    Console.Write(Err.StackTrace);
                }
                try
                {
                    strRetweet = objtwtStatsHelper.getRetweets(twtProfileId, 15);
                }
                catch (Exception Err)
                {
                    Console.Write(Err.StackTrace);
                }
                try
                {
                    strEngInf = objtwtStatsHelper.getEngagements(twtProfileId, 15) + "@" + objtwtStatsHelper.getInfluence(twtProfileId, 15) + "@" + objtwtStatsHelper.getdate(twtProfileId, 15);
                }
                catch (Exception Err)
                {
                    Console.Write(Err.StackTrace);
                }
                try
                {
                    strAgeDiff = objtwtStatsRepo.getAgeDiffCount(twtProfileId, 15);
                }
                catch (Exception Err)
                {
                    Console.Write(Err.StackTrace);
                }

                try
                {
                    strTwtMention = objtwtStatsHelper.getTwtMention(twtProfileId, 15);
                }
                catch (Exception Err)
                {
                    Console.Write(Err.StackTrace);
                }


                var strgenderTwt = Session["twtGender"].ToString().Split(',');
                //divtwtMale.InnerHtml = strgenderTwt[0] + "%";
                // divtwtfeMale.InnerHtml = strgenderTwt[1] + "%";
            }
        }
Exemplo n.º 15
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);
                    }
                }
            }
        }