Пример #1
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);
                }
            }


        }
Пример #2
0
 public void getProfileCount()
 {
     SocioBoard.Domain.User user = (User)Session["LoggedUser"];
     SocialProfilesRepository objProfile=new SocialProfilesRepository();
     List<SocialProfile> lstProfile= objProfile.getAllSocialProfilesOfUser(user.Id);
     strProfileCOunt = lstProfile.Count().ToString();
 }
Пример #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {

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

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

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

                var strgenderTwt = Session["twtGender"].ToString().Split(',');
                divtwtMale.InnerHtml = strgenderTwt[0] +"%";
                divtwtfeMale.InnerHtml = strgenderTwt[1]+"%";
            }
        }
Пример #4
0
        public void ProcessRequest()
        {
            SocialProfilesRepository socio = new SocialProfilesRepository();
            List<SocialProfile> alstsocioprofiles = new List<SocialProfile>();
            if (!string.IsNullOrEmpty(Request.QueryString["op"]))
            {
                SocioBoard.Domain.User user = (SocioBoard.Domain.User)Session["LoggedUser"];

                if (Request.QueryString["op"] == "social_connectivity")
                {

                    alstsocioprofiles = socio.getAllSocialProfilesOfUser(user.Id);

                    string profiles = string.Empty;
                    profiles += "<ul class=\"rsidebar-profile\">";
                    foreach (SocialProfile item in alstsocioprofiles)
                    {
                        try
                        {
                            if (item.ProfileType == "facebook")
                            {
                                try
                                {
                                    FacebookAccountRepository facerepo = new FacebookAccountRepository();
                                    FacebookAccount faceaccount = facerepo.getFacebookAccountDetailsById(item.ProfileId, user.Id);

                                    if (faceaccount != null)
                                    {
                                        profiles += "<li id=\"so_" + item.ProfileId + "\"><div id=\"" + item.ProfileId + "\" class=\"userpictiny\"><div class=\"delet_icon\" onclick=\"confirmDel('" + item.ProfileId + "','fb');\"></div><a href=\"http://www.facebook.com/" + faceaccount.FbUserId + "\" target=\"_blank\"><img src=\"http://graph.facebook.com/" + item.ProfileId + "/picture?type=small\" height=\"48\" width=\"48\" alt=\"\" title=\"" + faceaccount.FbUserName + "\" /></a>" +
                                                    "<a href=\"#\" class=\"userurlpic\" title=\"\"><img src=\"../Contents/img/fb_icon.png\" width=\"16\" height=\"16\" alt=\"\"></a></div></li>";
                                    }
                                }
                                catch (Exception ex)
                                {
                                    Console.WriteLine(ex.Message);
                                    logger.Error(ex.Message);
                                }

                            }
                            else if (item.ProfileType == "twitter")
                            {
                                try
                                {
                                    TwitterAccountRepository twtrepo = new TwitterAccountRepository();
                                    SocioBoard.Domain.TwitterAccount twtaccount = twtrepo.getUserInformation(user.Id, item.ProfileId);
                                    if (twtaccount != null)
                                    {
                                        profiles += "<li id=\"so_" + item.ProfileId + "\"><div id=\"" + item.ProfileId + "\" class=\"userpictiny\"><div class=\"delet_icon\" onClick=\"confirmDel('" + item.ProfileId + "','twt')\"></div><a href=\"http://twitter.com/" + twtaccount.TwitterScreenName + "\" target=\"_blank\"><img src=\"" + twtaccount.ProfileImageUrl + "\" height=\"48\" width=\"48\" alt=\"\" title=\"" + twtaccount.TwitterScreenName + "\" /></a>" +
                                                    "<a href=\"#\" class=\"userurlpic\" title=\"\"><img src=\"../Contents/img/twticon.png\" width=\"16\" height=\"16\" alt=\"\"></a></div></li>";
                                    }

                                }
                                catch (Exception ex)
                                {
                                    Console.WriteLine(ex.Message);
                                    logger.Error(ex.Message);
                                }
                            }
                            else if (item.ProfileType == "linkedin")
                            {
                                try
                                {

                                    LinkedInAccountRepository liRepo = new LinkedInAccountRepository();
                                    string access = string.Empty, tokenSecrate = string.Empty, LdprofileName = string.Empty, LdPreofilePic = string.Empty;
                                    LinkedInAccount liaccount = liRepo.getUserInformation(user.Id, item.ProfileId);

                                    if (liaccount != null)
                                    {
                                        if (!string.IsNullOrEmpty(liaccount.ProfileImageUrl))
                                        {
                                            LdPreofilePic = liaccount.ProfileImageUrl;
                                        }
                                        else
                                        {
                                            LdPreofilePic = "../../Contents/img/blank_img.png";
                                        }

                                        profiles += "<li id=\"so_" + item.ProfileId + "\"><div id=\"" + item.ProfileId + "\" class=\"userpictiny\"><div class=\"delet_icon\" onClick=\"confirmDel('" + item.ProfileId + "','linkedin')\"></div><a href=\"" + liaccount.ProfileUrl + "\" target=\"_blank\"><img src=\"" + LdPreofilePic + "\" height=\"48\" width=\"48\" alt=\"\" title=\"" + liaccount.LinkedinUserName + "\" /></a>" +
                                                   "<a href=\"#\" class=\"userurlpic\" title=\"\"><img src=\"../Contents/img/link_icon.png\" width=\"16\" height=\"16\" alt=\"\"></a></div></li>";
                                    }
                                }
                                catch (Exception ex)
                                {
                                    Console.WriteLine(ex.Message);
                                    logger.Error(ex.Message);
                                }

                            }

                            else if (item.ProfileType == "instagram")
                            {
                                try
                                {
                                    InstagramAccountRepository objInsAccRepo = new InstagramAccountRepository();
                                    InstagramAccount objInsAcc = objInsAccRepo.getInstagramAccountDetailsById(item.ProfileId, user.Id);
                                    string accessToken = string.Empty;
                                    if (objInsAcc != null)
                                    {
                                        profiles += "<li id=\"so_" + item.ProfileId + "\"><div id=\"" + item.ProfileId + "\" class=\"userpictiny\"><div class=\"delet_icon\" onClick=\"confirmDel('" + item.ProfileId + "','instagram')\"></div><a href=\"http://instagram.com/" + objInsAcc.InsUserName + "\" target=\"_blank\"><img src=\"" + objInsAcc.ProfileUrl + "\" height=\"48\" width=\"48\" alt=\"\" title=\"" + objInsAcc.InsUserName + "\" /></a>" +
                                                    "<a href=\"#\" class=\"userurlpic\" title=\"\"><img src=\"../Contents/img/instagram_24X24.png\" width=\"16\" height=\"16\" alt=\"\"></a></div></li>";
                                    }
                                }
                                catch (Exception ex)
                                {
                                    Console.WriteLine(ex.Message);
                                    logger.Error(ex.Message);
                                }
                            }
                            else if (item.ProfileType == "googleplus")
                            {
                                try
                                {

                                    //GooglePlusAccountRepository objgpAccRepo = new GooglePlusAccountRepository();
                                    //GooglePlusAccount objgpAcc = objgpAccRepo.getGooglePlusAccountDetailsById(item.ProfileId, user.Id);
                                    //string accessToken = string.Empty;

                                    //profiles += "<li id=\"so_" + item.ProfileId + "\"><div id=\"" + item.ProfileId + "\" class=\"userpictiny\"><div class=\"delet_icon\" onClick=\"confirmDel('" + item.ProfileId + "','googleplus')\"></div><a href=\"http://plus.google.com/" + item.ProfileId + "\" target=\"_blank\"><img src=\"" + objgpAcc.GpProfileImage + "\" height=\"48\" width=\"48\" alt=\"\" title=\"" + objgpAcc.GpUserName + "\" /></a>" +
                                    //            "<a href=\"#\" class=\"userurlpic\" title=\"\"><img src=\"../Contents/img/google_plus.png\" width=\"16\" height=\"16\" alt=\"\"></a></div></li>";

                                }
                                catch (Exception ex)
                                {
                                    Console.WriteLine(ex.Message);
                                    logger.Error(ex.Message);
                                }
                            }
                            else if (item.ProfileType == "googleanalytics")
                            {
                                try
                                {

                                    //GoogleAnalyticsAccountRepository objgaAccRepo = new GoogleAnalyticsAccountRepository();
                                    //GoogleAnalyticsAccount objgaAcc = objgaAccRepo.getGoogelAnalyticsAccountHomeDetailsById(user.Id,item.ProfileId);
                                    //string accessToken = string.Empty;

                                    //profiles += "<li id=\"so_" + item.ProfileId + "\"><div id=\"" + item.ProfileId + "\" class=\"userpictiny\"><div class=\"delet_icon\" onClick=\"confirmDel('" + item.ProfileId + "','googleanalytics')\"></div><a href=\"http://plus.google.com/" + item.ProfileId + "\" target=\"_blank\"><img src=\"../Contents/img/google_analytics.png\" height=\"48\" width=\"48\" alt=\"\" title=\"" + objgaAcc.GaAccountName + "\" /></a>" +
                                    //            "<a href=\"#\" class=\"userurlpic\" title=\"\"><img src=\"\" width=\"16\" height=\"16\" alt=\"\"></a></div></li>";

                                }
                                catch (Exception ex)
                                {
                                    Console.WriteLine(ex.Message);
                                    logger.Error(ex.Message);
                                }
                            }

                        }
                        catch (Exception ex)
                        {
                            logger.Error(ex.Message);

                        }
                    } profiles += "</ul>";
                    Response.Write(profiles);
                }
                else if (Request.QueryString["op"] == "woodrafts")
                {
                    string message = string.Empty;
                    try
                    {
                        DraftsRepository draftsRepository = new DraftsRepository();
                        List<Drafts> lstDrafts = draftsRepository.getAllDrafts(user.Id);
                        string profurl = string.Empty;
                        if (string.IsNullOrEmpty(user.ProfileUrl))
                        {
                            profurl = "../Contents/img/blank_img.png";
                        }
                        else
                        {
                            profurl = user.ProfileUrl;
                        }
                        if (lstDrafts.Count != 0)
                        {
                            foreach (Drafts item in lstDrafts)
                            {
                                message += "<section class=\"section\" style=\"width:648px;\">" +
                                           "<div class=\"js-task-cont read\"><section class=\"task-owner\">" +
                                "<img width=\"32\" height=\"32\" border=\"0\" class=\"avatar\" src=\"../Contents/img/task_pin.png\">" +
                                "</section><section class=\"task-activity third\" style=\"width: 19.6%;\"><p>" + user.UserName + "</p><div>" + item.CreatedDate + " </div><p>" +
                                    //"</p></section><section style=\"margin-right: 6px; height: auto; width: 35%;\" class=\"task-message font-13 third\"><a onclick=\"writemessage(this.innerHTML);\" class=\"tip_left\">" + item.Message + "</a></section>" +
                                 "</p></section><section style=\"margin-right: 6px; height: auto; width: 31%;\" class=\"task-message font-13 third\"><span class=\"tip_left\">" + item.Message + "</span></section>" +
                                    "<div class=\"userpictiny\" style=\"height:70px; margin-top: 0;\"><img alt=\"\" src=\"" + profurl + "\" />" +
                                 "</div>" +
                                 "<a class=\"small_remove icon publish_delete\" href=\"#\" style=\"top: 7px; float: right; margin-top: 13px; margin-right: 10px;\" title=\"Delete\" onclick=\"deleteDraftMessage('" + item.Id + "')\"></a>" +
                                "<section style=\"margin-top: 18px; width: 45px; margin-right: 17px;\" class=\"task-status\"><div class=\"ui_light floating task_status_change\"><a class=\"ui-sproutmenu\" href=\"#nogo\">" +
                                    "<span onclick=\"editDraftsMessage('" + item.Id + "');\" class=\"ui-sproutmenu-status\">" +
                                "<img class=\"edit_button\" src=\"../Contents/img/icon_edit.png\" alt=\"\" />" +
                                "</span>" +
                                "</a></div></section></div></section>";

                            }
                        }
                        else
                        {
                            //message += "<section class=\"section\"><div class=\"js-task-cont read\"><section class=\"task-owner\">" +
                            //      "<img width=\"32\" height=\"32\" border=\"0\" class=\"avatar\" src=\"" + profurl + "\">" +
                            //      "</section><section class=\"task-activity third\"><p>" + user.UserName + "</p><div></div><p></p></section><section style=\"margin-right: 6px; width: 31%; height: auto;\" class=\"task-message font-13 third\">" +
                            //      "<a class=\"tip_left\">No Messages in Drafts</a></section><section style=\"width:113px;\" class=\"task-status\"><span class=\"ficon task_active\"></span>" +
                            //      "<div class=\"ui_light floating task_status_change\"><a class=\"ui-sproutmenu\" href=\"#nogo\">" +
                            //      "<span class=\"ui-sproutmenu-status\"></span></a></div></section></div></section>";

                            message += "<section class=\"section\"><div class=\"js-task-cont read\"><section style=\"margin-right: 6px; width: 31%; height: auto;\" class=\"task-message font-13 third\">" +
                                "<a class=\"tip_left\">No Messages in Drafts</a></section><section style=\"width:113px;\" class=\"task-status\"><span class=\"ficon task_active\"></span>" +
                                "<div class=\"ui_light floating task_status_change\"><a class=\"ui-sproutmenu\" href=\"#nogo\">" +
                                "<span class=\"ui-sproutmenu-status\"></span></a></div></section></div></section>";
                        }
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.Message);
                    }
                    Response.Write(message);
                }
                else if (Request.QueryString["op"] == "savedrafts")
                {
                    try
                    {
                        string message = Request.QueryString["message"];
                        Drafts d = new Drafts();
                        d.CreatedDate = DateTime.Now;
                        d.Message = message;
                        d.ModifiedDate = DateTime.Now;
                        d.UserId = user.Id;
                        d.Id = Guid.NewGuid();
                        DraftsRepository dRepo = new DraftsRepository();
                        if (!dRepo.IsDraftsMessageExist(user.Id, message))
                        {
                            dRepo.AddDrafts(d);
                        }
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.Message);
                    }
                }
                else if (Request.QueryString["op"] == "midsnaps")
                {
                    try
                    {
                        Random rNum = new Random();
                        string loadtype = Request.QueryString["loadtype"];
                        string midsnaps = string.Empty;
                        if (loadtype == "load")
                            profilelimit = 0;

                        if (profilelimit != -1)
                        {
                            ArrayList alst = socio.getLimitProfilesOfUser(user.Id, profilelimit);

                            if (alst.Count == 0)
                                profilelimit = -1;
                            else if (profilelimit == 0)
                                profilelimit += 2;
                            else
                                profilelimit += 3;

                            midsnaps += "<div class=\"row-fluid\" >";
                            if (loadtype == "load")
                            {
                                AdsRepository objAdsRepo = new AdsRepository();
                                ArrayList lstads = objAdsRepo.getAdsForHome();

                                int i = 0;
                                if (lstads.Count <= 1)
                                {
                                    midsnaps += "<div class=\"span4 rounder recpro\"><button data-dismiss=\"alert\" class=\"close pull-right\" type=\"button\">×</button>" +
                                         "<a href=\"#\"><img src=\"../Contents/img/admin/ads.png\"  alt=\"\" style=\"width:246px;height:331px\"></a></div>";
                                }
                                else
                                {
                                    foreach (var item in lstads)
                                    {
                                        Array temp = (Array)item;
                                        i++;
                                        if (temp != null)
                                        {
                                            if (i == 2)
                                            {
                                                midsnaps += "<div class=\"span4 rounder recpro\"><button data-dismiss=\"alert\" class=\"close pull-right\" type=\"button\">×</button>" +
                                               "<a href=\"#\"><img src=\"" + temp.GetValue(2).ToString() + "\"  alt=\"\" style=\"width:246px;height:331px\"></a></div>";
                                            }
                                        }
                                    }
                                }

                            }
                            foreach (SocialProfile item in alst)
                            {
                                if (item.ProfileType == "facebook")
                                {
                                    try
                                    {
                                        FacebookAccountRepository fbrepo = new FacebookAccountRepository();
                                        FacebookFeedRepository facefeedrepo = new FacebookFeedRepository();
                                        List<FacebookFeed> fbmsgs = facefeedrepo.getAllFacebookUserFeeds(item.ProfileId);
                                        FacebookAccount fbaccount = fbrepo.getFacebookAccountDetailsById(item.ProfileId, user.Id);

                                        midsnaps += "<div id=\"mid_" + item.ProfileId + "\" style=\"height:333px;\" class=\"span4 rounder recpro\"><div class=\"concotop\">" +
                                                   "<div onclick=\"detailsdiscoveryfacebook('" + fbaccount.FbUserId + "');\"  class=\"userpictiny\"><img width=\"56\" height=\"56\" title=\"" + fbaccount.FbUserName + "\" alt=\"\" src=\"http://graph.facebook.com/" + item.ProfileId + "/picture?type=small\"\">" +
                                                   "<a title=\"\" class=\"userurlpic\" href=\"#\"><img alt=\"\" src=\"../Contents/img/fb_icon.png\" width=\"16\" height=\"16\"></a></div>" +
                                                   "<div onclick=\"detailsdiscoveryfacebook('" + fbaccount.FbUserId + "');\" class=\"useraccname\">" + fbaccount.FbUserName + "</div><div class=\"usercounter\">" +
                                                   "<div class=\"userfoll\">" + fbaccount.Friends;

                                        if (fbaccount.Type == "page")
                                        {
                                            midsnaps += "<a>Fans</a>";
                                        }
                                        else
                                        {
                                            midsnaps += "<a>Friends</a>";

                                        }
                                        midsnaps += "</div>" +
                                                   "<div class=\"userppd\">" + Math.Round(rNum.NextDouble(), 2) + "<span>Avg. Post <br> Per Day</span></div></div></div>" +
                                                   "<div class=\"concoteng\"><h5>recent message</h5> <ul class=\"mess\">";

                                        if (fbmsgs.Count != 0)
                                        {
                                            int msgcount = 0;
                                            foreach (FacebookFeed child in fbmsgs)
                                            {
                                                string mess = string.Empty;
                                                if (msgcount < 2)
                                                {
                                                    if (child.FeedDescription.Length > 40)
                                                    {
                                                        mess = child.FeedDescription.Substring(0, 39);
                                                        mess = mess + "...........";
                                                    }
                                                    else
                                                    {
                                                        mess = child.FeedDescription;
                                                    }

                                                    midsnaps += "<li><div class=\"messpic\"><img title=\"\" alt=\"\" src=\"http://graph.facebook.com/" + child.FromId + "/picture?type=small\"></div>" +
                                                              "<div class=\"messtext\">" + mess + "</div></li>";
                                                    //  midsnaps += "<strong><img src=\"http://graph.facebook.com/" + child.FromId + "/picture?type=small\" />" + mess + "</strong><br/>";
                                                }
                                                else
                                                {
                                                    break;
                                                }
                                                msgcount++;
                                            }
                                        }
                                        else
                                        {
                                            midsnaps += "<strong>No messages were found within the past few days.</strong> \"Messages will be displayed once there is activity in this date range.\"";
                                        }

                                        midsnaps += "</ul></div></div>";
                                    }
                                    catch (Exception ex)
                                    {
                                        logger.Error(ex.Message);
                                    }
                                }
                                if (item.ProfileType == "googleplus")
                                {
                                    // try
                                    //{
                                    //    GooglePlusAccountRepository objgpAccRepo = new GooglePlusAccountRepository();
                                    //    GooglePlusActivitiesRepository objgpActRepo = new GooglePlusActivitiesRepository();

                                    //    GooglePlusAccount gaaccount = objgpAccRepo.getGooglePlusAccountDetailsById(item.ProfileId, user.Id);
                                    //    List<GooglePlusActivities> gpmsgs = objgpActRepo.getAllgoogleplusActivityOfUser(user.Id, item.ProfileId);

                                    //    midsnaps += "<div id=\"mid_" + item.ProfileId + "\" style=\"height:333px;\" class=\"span4 rounder recpro\"><div class=\"concotop\">" +
                                    //               "<div class=\"userpictiny\"><img width=\"56\" height=\"56\" title=\"" + gaaccount.GpUserName + "\" alt=\"\" src='" + gaaccount.GpProfileImage + "'>" +
                                    //               "<a title=\"\" class=\"userurlpic\" href=\"#\"><img alt=\"\" src=\"../Contents/img/google_plus.png\" width=\"16\" height=\"16\"></a></div>" +
                                    //               "<div class=\"useraccname\">" + gaaccount.GpUserName + "</div><div class=\"usercounter\">" +
                                    //               "<div class=\"userfoll\">" + gaaccount.PeopleCount + "<span>Friends</span></div>" +
                                    //               "<div class=\"userppd\">" + Math.Round(rNum.NextDouble(), 2) + "<span>Avg. Post Per Day</span></div></div></div>" +
                                    //               "<div class=\"concoteng\"><h5>recent message</h5> <ul class=\"mess\">";
                                    //    if (gpmsgs.Count() != 0)
                                    //    {
                                    //        try
                                    //        {
                                    //            int msgcount = 0;
                                    //            foreach (GooglePlusActivities child in gpmsgs)
                                    //            {
                                    //                string mess = string.Empty;
                                    //                if (msgcount < 2)
                                    //                {
                                    //                    if (child.Content.Length > 40)
                                    //                    {
                                    //                        mess = child.Content.Substring(0, 39);
                                    //                        mess = mess + "...........";
                                    //                    }
                                    //                    else
                                    //                    {
                                    //                        mess = child.Content;
                                    //                    }

                                    //                    midsnaps += "<li><div class=\"messpic\"><img title=\"\" width=\"24px\" height=\"24px\" alt=\"\" src=\"" + child.FromProfileImage + "\"></div>" +
                                    //                              "<div class=\"messtext\">" + mess + "</div></li>";
                                    //                    //  midsnaps += "<strong><img src=\"http://graph.facebook.com/" + child.FromId + "/picture?type=small\" />" + mess + "</strong><br/>";
                                    //                }
                                    //                else
                                    //                {
                                    //                    break;
                                    //                }
                                    //                msgcount++;
                                    //            }
                                    //        }
                                    //        catch (Exception exx)
                                    //        {
                                    //            Console.WriteLine(exx.Message);
                                    //            logger.Error(exx.Message);
                                    //        }
                                    //    }
                                    //    else
                                    //    {
                                    //        midsnaps += "<strong>No messages were found within the past few days.</strong> \"Messages will be displayed once there is activity in this date range.\"";
                                    //    }

                                    //    midsnaps += "</ul></div></div>";

                                    //}
                                    //catch (Exception ex)
                                    //{
                                    //    Console.WriteLine(ex.Message);
                                    //    logger.Error(ex.Message);
                                    //}

                                }
                                else if (item.ProfileType == "twitter")
                                {
                                    TwitterAccountRepository twtrepo = new TwitterAccountRepository();
                                    SocioBoard.Domain.TwitterAccount twtaccount = twtrepo.getUserInformation(user.Id, item.ProfileId);
                                    TwitterMessageRepository twtmsgrepo = new TwitterMessageRepository();
                                    List<TwitterMessage> lsttwtmsgs = twtmsgrepo.getAllTwitterMessagesOfProfile(item.ProfileId);
                                    int tweetcount = 0;

                                    midsnaps += "<div id=\"mid_" + item.ProfileId + "\" style=\"height:333px;\" class=\"span4 rounder recpro\"><div class=\"concotop\">" +
                                     "<div onclick=\"detailsdiscoverytwitter('" + twtaccount.TwitterUserId + "');\" class=\"userpictiny\"><img width=\"56\" height=\"56\" title=\"" + twtaccount.TwitterName + "\" alt=\"\" src=\"" + twtaccount.ProfileImageUrl + "\">" +
                                     "<a title=\"\" class=\"userurlpic\" href=\"#\"><img alt=\"\" src=\"../Contents/img/twticon.png\" width=\"16\" height=\"16\"></a></div>" +
                                     "<div onclick=\"detailsdiscoverytwitter('" + twtaccount.TwitterUserId + "');\" class=\"useraccname\">" + twtaccount.TwitterScreenName + "</div><div class=\"usercounter\">" +
                                     "<div class=\"userfoll\">" + twtaccount.FollowersCount + "<a>Followers</a></div>" +
                                     "<div class=\"userppd\">" + Math.Round(rNum.NextDouble(), 2) + "<span>Avg. Post <br> Per Day</span></div></div></div>" +
                                     "<div class=\"concoteng\"><h5>recent message</h5> <ul class=\"mess\">";
                                    try
                                    {
                                        if (lsttwtmsgs.Count == 0)
                                        {
                                            midsnaps += "<strong>No messages were found within the past few days.</strong> \"Messages will be displayed once there is activity in this date range.\"";
                                        }
                                        else
                                        {
                                            foreach (TwitterMessage msg in lsttwtmsgs)
                                            {
                                                if (tweetcount < 2)
                                                {
                                                    try
                                                    {
                                                        string ms = string.Empty;
                                                        if (msg.TwitterMsg.Length > 20)
                                                        {
                                                            ms = msg.TwitterMsg.Substring(0, 20) + "...";

                                                        }
                                                        else
                                                        {
                                                            ms = msg.TwitterMsg;
                                                        }
                                                        midsnaps += "<li><div class=\"messpic\"><img title=\"\" alt=\"\" src=\"" + msg.FromProfileUrl + "\"></div>" +
                                                        "<div class=\"messtext\">" + ms + "</div></li>";
                                                    }
                                                    catch (Exception ex)
                                                    {
                                                        Console.WriteLine(ex.Message);

                                                    }
                                                }
                                                else
                                                {
                                                    break;
                                                }
                                                tweetcount++;
                                            }
                                        }
                                    }
                                    catch (Exception ex)
                                    {

                                        Console.WriteLine(ex.Message);
                                        logger.Error(ex.Message);
                                    }
                                    midsnaps += "</ul></div></div>";
                                }
                                else if (item.ProfileType == "linkedin")
                                {
                                    try
                                    {
                                        string access = string.Empty, tokenSecrate = string.Empty, LdprofileName = string.Empty, LdPreofilePic = string.Empty;
                                        LinkedInAccountRepository objLiRepo = new LinkedInAccountRepository();
                                        LinkedInFeedRepository objliFeedRepo = new LinkedInFeedRepository();
                                        LinkedInAccount liAccount = objLiRepo.getUserInformation(user.Id, item.ProfileId);
                                        LinkedInFeedRepository lifeedrepo = new LinkedInFeedRepository();
                                        List<LinkedInFeed> alstliaccount = lifeedrepo.getAllLinkedInFeedsOfProfile(item.ProfileId);
                                        if (liAccount != null)
                                        {
                                            LdprofileName = liAccount.LinkedinUserName;
                                            LdPreofilePic = liAccount.ProfileImageUrl;
                                        }

                                        if (string.IsNullOrEmpty(LdPreofilePic))
                                        {
                                            LdPreofilePic = "../../Contents/img/blank_img.png";
                                        }
                                        int linkedinConcount = 0;
                                        try
                                        {
                                            linkedinConcount = liAccount.Connections;
                                        }
                                        catch (Exception ex)
                                        {
                                            Console.WriteLine(ex.Message);
                                        }

                                        midsnaps += "<div id=\"mid_" + item.ProfileId + "\" style=\"height:333px;\" class=\"span4 rounder recpro\"><div class=\"concotop\">" +
                                           "<div class=\"userpictiny\"><img width=\"56\" height=\"56\" title=\"" + LdprofileName + "\" alt=\"\" src=\"" + LdPreofilePic + "\">" +
                                           "<a title=\"\" class=\"userurlpic\" href=\"#\"><img alt=\"\" src=\"../Contents/img/link_icon.png\" width=\"16\" height=\"16\"></a></div>" +
                                           "<div class=\"useraccname\">" + LdprofileName + "</div><div class=\"usercounter\">" +
                                           "<div class=\"userfoll\">" + linkedinConcount + "<span>Connections</span></div>" +
                                           "<div class=\"userppd\">" + Math.Round(rNum.NextDouble(), 2) + "<span>Avg. Post <br> Per Day</span></div></div></div>" +
                                           "<div class=\"concoteng\"><h5>recent message</h5> <ul class=\"mess\">";
                                        int link = 0;
                                        if (alstliaccount.Count == 0)
                                        {
                                            midsnaps += "<strong>No messages were found within the past 14 days.</strong> \"Messages will be displayed once there is activity in this date range.\"";
                                        }
                                        else
                                        {

                                            try
                                            {

                                                foreach (LinkedInFeed liFeed in alstliaccount)
                                                {
                                                    try
                                                    {
                                                        if (link < 2)
                                                        {
                                                            string ms = string.Empty;
                                                            if (liFeed.Feeds.Length > 20)
                                                            {
                                                                ms = liFeed.Feeds.Substring(0, 20) + "...";

                                                            }
                                                            else
                                                            {
                                                                ms = liFeed.Feeds;
                                                            }
                                                            midsnaps += "<li><div class=\"messpic\"><img title=\"\" alt=\"\" src=\"" + liFeed.FromPicUrl + "\"></div>" +
                                                           "<div class=\"messtext\">" + ms + "</div></li>";
                                                            link++;
                                                        }
                                                        else
                                                        {
                                                            break;
                                                        }
                                                    }
                                                    catch (Exception ex)
                                                    {
                                                        logger.Error(ex.Message);
                                                    }
                                                }
                                            }
                                            catch (Exception ex)
                                            {
                                                logger.Error(ex.Message);
                                            }

                                        }
                                        midsnaps += "</ul></div></div>";
                                    }
                                    catch (Exception ex)
                                    {
                                        Console.WriteLine(ex.Message);
                                        logger.Error(ex.Message);
                                    }
                                }
                                else if (item.ProfileType == "instagram")
                                {
                                    try
                                    {
                                        InstagramAccountRepository objInsAccRepo = new InstagramAccountRepository();
                                        InstagramAccount objInsAcc = objInsAccRepo.getInstagramAccountDetailsById(item.ProfileId, user.Id);

                                        midsnaps += "<div id=\"mid_" + item.ProfileId + "\" style=\"height:333px;\" class=\"span4 rounder recpro\"><div class=\"concotop\">" +
                                               "<div class=\"userpictiny\"><img width=\"56\" height=\"56\" title=\"" + objInsAcc.InsUserName + "\" alt=\"\" src=\"" + objInsAcc.ProfileUrl + "\">" +
                                               "<a title=\"\" class=\"userurlpic\" href=\"#\"><img alt=\"\" src=\"../Contents/img/instagram_24X24.png\" width=\"16\" height=\"16\"></a></div>" +
                                               "<div class=\"useraccname\">" + objInsAcc.InsUserName + "</div></div>" +
                                               "<div class=\"concoteng\"><div class=\"pillow_fade\">" +
                                               " <div class=\"fb_notifications\">" +
                                               "<ul class=\"user-stats\"> " +
                                                    "<li><div class=\"photo_stat\">  photos</div>  <div class=\"number-stat\">" + objInsAcc.TotalImages + "</div></li>" +
                                                    "<li><div class=\"photo_stat\">following</div><div class=\"number-stat\">" + objInsAcc.Followers + "</div></li>" +
                                                    "<li><div class=\"photo_stat\">followers</div><div class=\"number-stat\">" + objInsAcc.FollowedBy + "</div></li>" +
                                                "</ul></div></div></div></div>";
                                    }
                                    catch (Exception ex)
                                    {
                                        Console.WriteLine(ex.Message);
                                        logger.Error(ex.Message);
                                    }
                                    //       midsnaps += " <div class=\"col_seven_instagram\">" +
                                    //                "<div class=\"col_seven_instagram_link_my_accounts\">" +
                                    //                  "<div class=\"dt\"><a class=\"img\">" +
                                    //                    "<img src=\"" + objInsAcc.ProfileUrl + "\" width=\"48\" height=\"48\" alt=\"\" /></a>" +
                                    //                  "<span class=\"icon\"></span></div><div class=\"dd\">" +
                                    //                "<h5>" + objInsAcc.InsUserName + "</h5><div class=\"friends_avg\">" +

                                    //        "</div>" +
                                    //    "</div>" +
                                    //"</div>" +
                                    //    "<div class=\"pillow_fade\">" +
                                    //        "<div class=\"fb_notifications\">" +
                                    //            "<ul class=\"user-stats\">" +
                                    //                       "<li>" +
                                    //                          "<div class=\"photo_stat\">  photos" +
                                    //                          "</div>" +
                                    //                          "<div class=\"number-stat\">" + objInsAcc.TotalImages +
                                    //                          "</div>" +
                                    //                       "</li>" +
                                    //                       "<li>" +
                                    //                           "<div class=\"photo_stat\"> followers" +
                                    //                          "</div>" +
                                    //                          "<div class=\"number-stat\">" + objInsAcc.FollowedBy +
                                    //                          "</div>" +
                                    //                       "</li>" +
                                    //                       "<li>" +
                                    //                           "<div class=\"photo_stat\"> following" +
                                    //                          "</div>" +
                                    //                          "<div class=\"number-stat\">" + objInsAcc.Followers +
                                    //                          "</div>" +
                                    //                       "</li>" +
                                    //                    "</ul>" +
                                    //            "</div>" +
                                    //    "</div>" +
                                    //"</div>";
                                }
                                else if (item.ProfileType == "googleanalytics")
                                {
                                    //try
                                    //{
                                    //    GoogleAnalyticsAccountRepository objGaAccRepo = new GoogleAnalyticsAccountRepository();
                                    //    GoogleAnalyticsAccount objGaAcc = objGaAccRepo.getGoogelAnalyticsAccountHomeDetailsById(user.Id, item.ProfileId);
                                    //    ArrayList arrlist = objGaAccRepo.getMaxGAStats(item.ProfileId);
                                    //    int dayvisit = 0, monthvisit = 0, yearvisit = 0;
                                    //    foreach (var itemData in arrlist)
                                    //    {
                                    //        Array temp = (Array)itemData;
                                    //        if (temp.GetValue(0).ToString() == "year")
                                    //            yearvisit = int.Parse(temp.GetValue(2).ToString());
                                    //        else if (temp.GetValue(0).ToString() == "month")
                                    //            monthvisit = int.Parse(temp.GetValue(2).ToString());
                                    //        else if (temp.GetValue(0).ToString() == "day")
                                    //            dayvisit = int.Parse(temp.GetValue(2).ToString());
                                    //    }
                                    //    midsnaps += "<div class=\"span4 rounder recpro\" style=\"height:333px;\"><div class=\"col_five_ga_my_accounts\"><div class=\"dt\">" +
                                    //        "<a class=\"img\"><img src=\"../Contents/img/google_analytics.png\" width=\"48\" height=\"48\" alt=\"\" /></a></div>" +
                                    //    "<div class=\"dd\"><div class=\"useraccname\" style=\"margin-left:0px;\">" + objGaAcc.GaAccountName + "</div><div class=\"friends_avg\"><div class=\"ga_content\">Google Analytics</div></div></div></div>" +
                                    //"<div class=\"pillow_fade\">" +
                                    //  "<div class=\"ga_trafic_number_graph\"><div class=\"ga_trafic\">Year</div><div class=\"ga_number\">" + yearvisit + "</div><div class=\"ga_graph\"></div></div>" +
                                    //  "<div class=\"ga_trafic_number_graph\"><div class=\"ga_trafic\">Month</div><div class=\"ga_number\">" + monthvisit + "</div><div class=\"ga_graph\"></div></div>" +
                                    //  "<div class=\"ga_trafic_number_graph\"><div class=\"ga_trafic\">Day</div><div class=\"ga_number\">" + dayvisit + "</div><div class=\"ga_graph\"></div></div></div></div>";
                                    //}
                                    //catch (Exception ex)
                                    //{
                                    //    Console.WriteLine(ex.Message);
                                    //    logger.Error(ex.Message);
                                    //}
                                }
                            }
                            midsnaps += "</div>";
                            Response.Write(midsnaps);
                        }
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.Message);
                    }

                }
                else if (Request.QueryString["op"] == "accountdelete")
                {
                    Session["facebooktotalprofiles"] = null;
                    SocialProfilesRepository socioprofilerepo = new SocialProfilesRepository();
                    string Profiletype = Request.QueryString["profile"];
                    string profileid = Request.QueryString["profileid"];

                    if (Profiletype == "fb")
                    {
                        try
                        {
                            FacebookAccountRepository fbrepo = new FacebookAccountRepository();
                            int delacc = fbrepo.deleteFacebookUser(profileid, user.Id);
                            if (delacc != 0)
                            {

                                socioprofilerepo.deleteProfile(user.Id, profileid);
                                List<SocialProfile> lstsocioprofile = socioprofilerepo.checkProfileExistsMoreThanOne(profileid);
                                if (lstsocioprofile.Count == 0)
                                {
                                    FacebookMessageRepository fbmsgrepo = new FacebookMessageRepository();
                                    fbmsgrepo.deleteAllMessagesOfUser(profileid, user.Id);
                                    FacebookFeedRepository fbfeedrepo = new FacebookFeedRepository();
                                    fbfeedrepo.deleteAllFeedsOfUser(profileid, user.Id);
                                    FacebookStatsRepository fbstatsrepo = new FacebookStatsRepository();
                                    fbstatsrepo.deleteFacebookStats(profileid, user.Id);
                                }
                            }

                        }
                        catch (Exception exx)
                        {
                            Console.WriteLine(exx.Message);
                            logger.Error(exx.Message);
                        }
                    }
                    else if (Profiletype == "twt")
                    {
                        try
                        {
                            TwitterAccountRepository twtaccountrepo = new TwitterAccountRepository();
                            int deltwtacc = twtaccountrepo.deleteTwitterUser(user.Id, profileid);
                            if (deltwtacc != 0)
                            {
                                socioprofilerepo.deleteProfile(user.Id, profileid);
                                List<SocialProfile> lstsocioprofile = socioprofilerepo.checkProfileExistsMoreThanOne(profileid);
                                if (lstsocioprofile.Count == 0)
                                {
                                    TwitterMessageRepository twtmsgrepo = new TwitterMessageRepository();
                                    int d = twtmsgrepo.deleteTwitterMessage(profileid, user.Id);
                                    TwitterFeedRepository twtfeedrepo = new TwitterFeedRepository();
                                    int s = twtfeedrepo.deleteTwitterFeed(profileid, user.Id);
                                    TwitterStatsRepository twtstatsrepo = new TwitterStatsRepository();
                                    int a = twtstatsrepo.deleteTwitterStats(user.Id, profileid);
                                    TwitterDirectMessageRepository twtdirectmsgrepo = new TwitterDirectMessageRepository();
                                    int f = twtdirectmsgrepo.deleteDirectMessage(user.Id, profileid);
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            logger.Error(ex.Message);
                            Console.WriteLine(ex.Message);
                        }
                    }
                    else if (Profiletype == "linkedin")
                    {
                        try
                        {
                            LinkedInAccountRepository linkedaccrepo = new LinkedInAccountRepository();
                            int dellinacc = linkedaccrepo.deleteLinkedinUser(profileid, user.Id);
                            if (dellinacc != 0)
                            {

                                socioprofilerepo.deleteProfile(user.Id, profileid);

                                List<SocialProfile> lstsocioprofile = socioprofilerepo.checkProfileExistsMoreThanOne(profileid);

                                if (lstsocioprofile.Count == 0)
                                {
                                    LinkedInFeedRepository linkedfeedrepo = new LinkedInFeedRepository();
                                    int s = linkedfeedrepo.deleteAllFeedsOfUser(profileid, user.Id);

                                }

                            }
                        }
                        catch (Exception ex)
                        {
                            logger.Error(ex.Message);
                        }

                    }
                    else if (Profiletype == "instagram")
                    {
                        try
                        {
                            InstagramAccountRepository insaccrepo = new InstagramAccountRepository();
                            int insacc = insaccrepo.deleteInstagramUser(profileid, user.Id);
                            if (insacc != 0)
                            {

                                socioprofilerepo.deleteProfile(user.Id, profileid);

                                List<SocialProfile> lstsocioprofile = socioprofilerepo.checkProfileExistsMoreThanOne(profileid);

                                if (lstsocioprofile.Count == 0)
                                { }

                            }
                        }
                        catch (Exception ex)
                        {
                            logger.Error(ex.Message);

                        }
                    }
                    else if (Profiletype == "googleplus")
                    {
                        try
                        {
                            GooglePlusAccountRepository googleplusaccrepo = new GooglePlusAccountRepository();
                            int gplusacc = googleplusaccrepo.deleteGooglePlusUser(profileid, user.Id);
                            if (gplusacc != 0)
                            {

                                socioprofilerepo.deleteProfile(user.Id, profileid);

                                List<SocialProfile> lstsocioprofile = socioprofilerepo.checkProfileExistsMoreThanOne(profileid);

                                if (lstsocioprofile.Count == 0)
                                {
                                }

                            }
                        }
                        catch (Exception ex)
                        {
                            logger.Error(ex.Message);

                        }
                    }

                    string profiles = string.Empty;
                    profiles += "<div class=\"drop_top\"></div><div class=\"drop_mid\">";

                    /*facebook users binding*/
                    FacebookAccountRepository fbprepo = new FacebookAccountRepository();
                    ArrayList lstfbaccounts = fbprepo.getFacebookAccountsOfUser(user.Id);

                    profiles += "<div class=\"twitte_text\">FACEBOOK</div><div class=\"teitter\"><ul>";

                    if (lstfbaccounts.Count == 0)
                    {
                        profiles += "<li>No Records Found</li>";
                    }
                    else
                    {
                        foreach (FacebookAccount fbacc in lstfbaccounts)
                        {
                            profiles += "<li id=\"liid_" + fbacc.FbUserId + "\"   onclick=\"composemessage(this.id,'fb')\"><a><img id=\"img_" + fbacc.FbUserId + "\" src=\"../Contents/img/facebook.png\" alt=\"" + fbacc.AccessToken + "\" border=\"none\" width=\"18\" style=\"float:left;\" /><span id=\"composename_" + fbacc.FbUserId + "\" style=\"float:left;margin: 3px 0 0 5px;\">" + fbacc.FbUserName + "</span><span id=\"imgurl_" + fbacc.FbUserId + "\" style=\"display:none;\">http://graph.facebook.com/" + fbacc.FbUserId + "/picture?type=small</span></a></li>";
                        }
                    }
                    profiles += "</ul> </div>";

                    /*twitter users binding*/
                    TwitterAccountRepository twtpaccountrepo = new TwitterAccountRepository();
                    ArrayList alsttwtaccounts = twtpaccountrepo.getAllTwitterAccountsOfUser(user.Id);
                    profiles += "<div class=\"twitte_text\">TWITTER</div><div class=\"teitter\"><ul>";

                    if (alsttwtaccounts.Count == 0)
                    {
                        profiles += "<li>No Records Found</li>";
                    }
                    else
                    {
                        foreach (SocioBoard.Domain.TwitterAccount item in alsttwtaccounts)
                        {
                            profiles += "<li id=\"liid_" + item.TwitterUserId + "\"   onclick=\"composemessage(this.id,'twt')\"><a><img id=\"img_" + item.TwitterUserId + "\" src=\"../Contents/img/twitter.png\" alt=\"" + item.OAuthToken + "\" border=\"none\" width=\"18\" style=\"float:left;\" /><span id=\"imgurl_" + item.TwitterUserId + "\" style=\"display:none;\">" + item.ProfileImageUrl + "</span><span id=\"composename_" + item.TwitterUserId + "\" style=\"float:left;margin: 3px 0 0 5px;\">" + item.TwitterScreenName + "</span></a></li>";
                        }
                    }
                    profiles += "</ul> </div>";

                    /*linkedinuserbinding*/
                    LinkedInAccountRepository linkaccountrepo = new LinkedInAccountRepository();
                    ArrayList alstlinkacc = linkaccountrepo.getAllLinkedinAccountsOfUser(user.Id);
                    profiles += "<div class=\"twitte_text\">LINKEDIN</div><div class=\"teitter\"><ul>";

                    if (alstlinkacc.Count == 0)
                    {
                        profiles += "<li>No Records Found</li>";
                    }
                    else
                    {

                        foreach (LinkedInAccount item in alstlinkacc)
                        {
                            string profileurl = string.Empty;

                            if (!string.IsNullOrEmpty(item.ProfileImageUrl))
                            {
                                profileurl = item.ProfileImageUrl;
                            }
                            else
                            {
                                profileurl = "../../Contents/img/blank_img.png";
                            }
                            profiles += "<li id=\"liid_" + item.LinkedinUserId + "\"   onclick=\"composemessage(this.id,'lin')\"><a><img id=\"img_" + item.LinkedinUserId + "\" src=\"../Contents/img/link.png\" alt=\"" + item.OAuthToken + "\" border=\"none\" width=\"18\" style=\"float:left;\" /><span id=\"imgurl_" + item.LinkedinUserId + "\" style=\"display:none;\">" + profileurl + "</span><span id=\"composename_" + item.LinkedinUserId + "\" style=\"float:left;margin: 3px 0 0 5px;\">" + item.LinkedinUserName + "</span></a></li>";
                        }
                    }
                    profiles += "</ul> </div>";
                    Session["profilesforcomposemessage"] = profiles;

                }
                else if (Request.QueryString["op"] == "MasterCompose")
                {
                    string profiles = string.Empty;

                    if (Session["profilesforcomposemessage"] == null)
                    {
                        profiles += "<div class=\"drop_top\"></div><div class=\"drop_mid\">";

                        /*facebook users binding*/
                        FacebookAccountRepository fbrepo = new FacebookAccountRepository();
                        ArrayList lstfbaccounts = fbrepo.getFacebookAccountsOfUser(user.Id);

                        profiles += "<div class=\"twitte_text\">FACEBOOK</div><div class=\"teitter\"><ul>";

                        if (lstfbaccounts.Count == 0)
                        {
                            profiles += "<li>No Records Found</li>";
                        }
                        else
                        {
                            foreach (FacebookAccount fbacc in lstfbaccounts)
                            {
                                profiles += "<li nwtk='fb' class=\"getAllNetworkProfile\" id=\"liid_" + fbacc.FbUserId + "\"   onclick=\"composemessage(this.id,'fb')\"><a><img id=\"img_" + fbacc.FbUserId + "\" src=\"../Contents/img/facebook.png\" alt=\"" + fbacc.AccessToken + "\" border=\"none\" width=\"18\" style=\"float:left;\" /><span id=\"composename_" + fbacc.FbUserId + "\" style=\"float:left;margin: 3px 0 0 5px;\">" + fbacc.FbUserName + "</span><span id=\"imgurl_" + fbacc.FbUserId + "\" style=\"display:none;\">http://graph.facebook.com/" + fbacc.FbUserId + "/picture?type=small</span></a></li>";
                            }
                        }
                        profiles += "</ul> </div>";

                        /*twitter users binding*/
                        TwitterAccountRepository twtaccountrepo = new TwitterAccountRepository();
                        ArrayList alsttwtaccounts = twtaccountrepo.getAllTwitterAccountsOfUser(user.Id);
                        profiles += "<div class=\"twitte_text\">TWITTER</div><div class=\"teitter\"><ul>";

                        if (alsttwtaccounts.Count == 0)
                        {
                            profiles += "<li>No Records Found</li>";
                        }
                        else
                        {
                            foreach (SocioBoard.Domain.TwitterAccount item in alsttwtaccounts)
                            {
                                profiles += "<li nwtk='twt' class=\"getAllNetworkProfile\" id=\"liid_" + item.TwitterUserId + "\"   onclick=\"composemessage(this.id,'twt')\"><a><img id=\"img_" + item.TwitterUserId + "\" src=\"../Contents/img/twitter.png\" alt=\"" + item.OAuthToken + "\" border=\"none\" width=\"18\" style=\"float:left;\" /><span id=\"imgurl_" + item.TwitterUserId + "\" style=\"display:none;\">" + item.ProfileImageUrl + "</span><span id=\"composename_" + item.TwitterUserId + "\" style=\"float:left;margin: 3px 0 0 5px;\">" + item.TwitterScreenName + "</span></a></li>";
                            }
                        }
                        profiles += "</ul> </div>";

                        /*linkedinuserbinding*/
                        LinkedInAccountRepository linkaccountrepo = new LinkedInAccountRepository();
                        ArrayList alstlinkacc = linkaccountrepo.getAllLinkedinAccountsOfUser(user.Id);
                        profiles += "<div class=\"twitte_text\">LINKEDIN</div><div class=\"teitter\"><ul>";

                        if (alstlinkacc.Count == 0)
                        {
                            profiles += "<li>No Records Found</li>";
                        }
                        else
                        {

                            foreach (LinkedInAccount item in alstlinkacc)
                            {
                                string profileurl = string.Empty;

                                if (!string.IsNullOrEmpty(item.ProfileImageUrl))
                                {
                                    profileurl = item.ProfileImageUrl;
                                }
                                else
                                {
                                    profileurl = "../../Contents/img/blank_img.png";
                                }
                                profiles += "<li nwtk='lin' class=\"getAllNetworkProfile\" id=\"liid_" + item.LinkedinUserId + "\"   onclick=\"composemessage(this.id,'lin')\"><a><img id=\"img_" + item.LinkedinUserId + "\" src=\"../Contents/img/link.png\" alt=\"" + item.OAuthToken + "\" border=\"none\" width=\"18\" style=\"float:left;\" /><span id=\"imgurl_" + item.LinkedinUserId + "\" style=\"display:none;\">" + profileurl + "</span><span id=\"composename_" + item.LinkedinUserId + "\" style=\"float:left;margin: 3px 0 0 5px;\">" + item.LinkedinUserName + "</span></a></li>";
                            }
                        }
                        profiles += "</ul> </div>";
                        Session["profilesforcomposemessage"] = profiles;
                    }
                    else
                    {
                        profiles = (string)Session["profilesforcomposemessage"];
                    }
                    Response.Write(profiles);
                }
                else if (Request.QueryString["op"] == "sendmessage")
                {

                    string message = Request.QueryString["message"];
                    var userid = Request.QueryString["userid[]"].Split(',');
                    var files = Request.Files.Count;
                    var fi = Request.Files["file"];
                    string file = string.Empty;
                    try
                    {

                        if (Request.Files.Count > 0)
                        {
                            if (fi != null)
                            {
                                var path = Server.MapPath("~/Contents/img/upload");
                                file = path + "/" + fi.FileName;
                                if (!Directory.Exists(path))
                                {
                                    Directory.CreateDirectory(path);
                                }
                                fi.SaveAs(file);
                            }
                        }

                    }
                    catch (Exception ex)
                    {

                        logger.Error(ex.Message);

                    }

                    foreach (var item in userid)
                    {
                        string[] networkingwithid = item.Split('_');
                        if (networkingwithid[0] == "fb")
                        {
                            try
                            {
                                FacebookAccountRepository fbaccountrepo = new FacebookAccountRepository();
                                FacebookAccount fbaccount = fbaccountrepo.getFacebookAccountDetailsById(networkingwithid[1], user.Id);
                                var args = new Dictionary<string, object>();

                                args["message"] = message;

                                if (Request.Files.Count > 0)
                                {
                                    string strPathAndQuery = HttpContext.Current.Request.Url.PathAndQuery;
                                    string strUrl = HttpContext.Current.Request.Url.AbsoluteUri.Replace(strPathAndQuery, "/");
                                    string filepath = strUrl + "/Contents/img/upload/" + fi.FileName;
                                    args["picture"] = filepath;
                                }
                                FacebookClient fc = new FacebookClient(fbaccount.AccessToken);

                                string facebookpost = string.Empty;
                                if (fbaccount.Type == "page")
                                {
                                    facebookpost=fc.Post("/" + fbaccount.FbUserId + "/feed", args).ToString();
                                }
                                else
                                {
                                    facebookpost = fc.Post("/me/feed", args).ToString();
                                }

                                if (facebookpost.ToString() != string.Empty)
                                {
                                    Response.Write("Succesfully posted");
                                }
                                else
                                {
                                    Response.Write("Not posted");
                                }

                            }
                            catch (Exception ex)
                            {
                                logger.Error(ex.Message);

                                Console.WriteLine(ex.Message);
                            }

                        }
                        else if (networkingwithid[0] == "twt")
                        {
                            try
                            {
                                TwitterAccountRepository twtaccountrepo = new TwitterAccountRepository();
                                SocioBoard.Domain.TwitterAccount twtaccount = twtaccountrepo.getUserInformation(user.Id, networkingwithid[1]);

                                TwitterHelper twthelper = new TwitterHelper();

                                oAuthTwitter OAuthTwt = new oAuthTwitter();
                                OAuthTwt.AccessToken = twtaccount.OAuthToken;
                                OAuthTwt.AccessTokenSecret = twtaccount.OAuthSecret;
                                OAuthTwt.TwitterScreenName = twtaccount.TwitterScreenName;
                                OAuthTwt.TwitterUserId = twtaccount.TwitterUserId;

                                twthelper.SetCofigDetailsForTwitter(OAuthTwt);

                                #region For Testing
                                // For Testing

                                //OAuthTwt.ConsumerKey = "udiFfPxtCcwXWl05wTgx6w";
                                //OAuthTwt.ConsumerKeySecret = "jutnq6N32Rb7cgbDSgfsrUVgRQKMbUB34yuvAfCqTI";
                                //OAuthTwt.AccessToken = "1453351098-Lz4H7cHKp26pXarF6l9zEwdiHDnwH7D0H4zteH3";
                                //OAuthTwt.AccessTokenSecret = "dGBPxR9wxhQMioIcj5P4Wemxo5EZIZ8wlvDz7i39lSNFg";
                                //OAuthTwt.TwitterScreenName = "";
                                //OAuthTwt.TwitterUserId = "";
                                #endregion

                                Tweet twt = new Tweet();
                                if (Request.Files.Count > 0)
                                {

                                    PhotoUpload ph = new PhotoUpload();
                                    //ph.Tweet(file, message, OAuthTwt);
                                    string res = string.Empty;
                                    ph.NewTweet(file, message, OAuthTwt, ref res);

                                    // for testing

                                    Response.Write(res);
                                    Console.WriteLine(res);
                                }
                                else
                                {
                                    JArray post = twt.Post_Statuses_Update(OAuthTwt, message);
                                }
                            }
                            catch (Exception ex)
                            {
                                Console.WriteLine(ex.Message);
                                logger.Error(ex.Message);

                            }
                        }
                        else if (networkingwithid[0] == "lin")
                        {
                            try
                            {
                                LinkedInAccountRepository linkedinaccrepo = new LinkedInAccountRepository();
                                LinkedInAccount linkedaccount = linkedinaccrepo.getUserInformation(user.Id, networkingwithid[1]);
                                oAuthLinkedIn Linkedin_oauth = new oAuthLinkedIn();

                                Linkedin_oauth.Verifier = linkedaccount.OAuthVerifier;
                                Linkedin_oauth.TokenSecret = linkedaccount.OAuthSecret;
                                Linkedin_oauth.Token = linkedaccount.OAuthToken;
                                Linkedin_oauth.Id = linkedaccount.LinkedinUserId;
                                Linkedin_oauth.FirstName = linkedaccount.LinkedinUserName;
                                SocialStream sociostream = new SocialStream();
                                string res = sociostream.SetStatusUpdate(Linkedin_oauth, message);
                            }
                            catch (Exception ex)
                            {
                                Console.WriteLine(ex.Message);
                                logger.Error(ex.Message);

                            }
                        }
                    }
                }
                else if (Request.QueryString["op"] == "wooqueue_messages")
                {
                    ScheduledMessageRepository schmsgrepo = new ScheduledMessageRepository();
                }
                else if (Request.QueryString["op"] == "schedulemessage")
                {

                    var userid = Request.QueryString["users[]"].Split(',');
                    var datearr = Request.QueryString["datearr[]"].Split(',');
                    string message = Request.QueryString["message"];
                    ScheduledMessageRepository schmsgrepo = new ScheduledMessageRepository();
                    string time = Request.QueryString["time"];
                    string clienttime = Request.QueryString["clittime"];

                    foreach (var item in userid)
                    {
                        if (!string.IsNullOrEmpty(item.ToString()))
                        {
                            foreach (var child in datearr)
                            {

                                ScheduledMessage schmessage = new ScheduledMessage();
                                string[] networkingwithid = item.Split('_');

                                if (networkingwithid[0] == "fbscheduler")
                                {
                                    schmessage.CreateTime = DateTime.Now;
                                    schmessage.ProfileType = "facebook";
                                    schmessage.ProfileId = networkingwithid[1];
                                    schmessage.Id = Guid.NewGuid();
                                    schmessage.PicUrl = string.Empty;
                                    schmessage.ClientTime = Convert.ToDateTime(clienttime);
                                    string servertime = this.CompareDateWithServer(clienttime, child + " " + time);
                                    schmessage.ScheduleTime = Convert.ToDateTime(servertime);
                                    schmessage.ShareMessage = message;
                                    schmessage.UserId = user.Id;
                                    schmessage.Status = false;

                                }
                                else if (networkingwithid[0] == "twtscheduler")
                                {

                                    schmessage.CreateTime = DateTime.Now;
                                    schmessage.ProfileType = "twitter";
                                    schmessage.ProfileId = networkingwithid[1];
                                    schmessage.Id = Guid.NewGuid();
                                    schmessage.PicUrl = string.Empty;
                                    schmessage.ClientTime = Convert.ToDateTime(clienttime);
                                    string servertime = this.CompareDateWithServer(clienttime, child + " " + time);
                                    schmessage.ScheduleTime = Convert.ToDateTime(servertime);
                                    schmessage.ShareMessage = message;
                                    schmessage.UserId = user.Id;
                                    schmessage.Status = false;

                                }
                                else if (networkingwithid[0] == "linscheduler")
                                {
                                    schmessage.ClientTime = Convert.ToDateTime(clienttime);
                                    schmessage.CreateTime = DateTime.Now;
                                    schmessage.ProfileType = "linkedin";
                                    schmessage.ProfileId = networkingwithid[1];
                                    schmessage.Id = Guid.NewGuid();
                                    schmessage.PicUrl = string.Empty;
                                    string servertime = this.CompareDateWithServer(clienttime, child + " " + time);
                                    schmessage.ScheduleTime = Convert.ToDateTime(servertime);
                                    schmessage.ShareMessage = message;
                                    schmessage.UserId = user.Id;
                                    schmessage.Status = false;

                                }
                                if (!string.IsNullOrEmpty(message))
                                {
                                    if (!schmsgrepo.checkMessageExistsAtTime(user.Id, schmessage.ShareMessage, schmessage.ScheduleTime, schmessage.ProfileId))
                                    {
                                        schmsgrepo.addNewMessage(schmessage);
                                    }
                                }
                            }
                        }
                    }
                }
                else if (Request.QueryString["op"] == "insight")
                {
                    FacebookAccount objFacebookAccount = (FacebookAccount)Session["fbpagedetail"];
                    FacebookHelper objFbHelper = new FacebookHelper();
                    SocialProfile socioprofile = new SocialProfile();
                    SocialProfilesRepository socioprofilerepo = new SocialProfilesRepository();
                    FacebookAccountRepository fbrepo = new FacebookAccountRepository();
                    FacebookClient fbClient = new FacebookClient(objFacebookAccount.AccessToken);
                    int fancountPage = 0;
                    dynamic fancount = fbClient.Get("fql", new { q = " SELECT fan_count FROM page WHERE page_id =" + Request["id"].ToString() });
                    foreach (var friend in fancount.data)
                    {
                        fancountPage = Convert.ToInt32(friend.fan_count);
                    }
                    objFacebookAccount.Friends = Convert.ToInt32(fancountPage);
                    objFacebookAccount.FbUserId = Request["id"].ToString();
                    objFacebookAccount.FbUserName = Request["name"].ToString();
                    objFacebookAccount.Type = "page";
                    objFacebookAccount.UserId = user.Id;
                    socioprofile.Id = Guid.NewGuid();
                    socioprofile.ProfileDate = DateTime.Now;
                    socioprofile.ProfileId = Request["id"].ToString();
                    socioprofile.ProfileStatus = 1;
                    socioprofile.ProfileType = "facebook";
                    socioprofile.UserId = user.Id;
                    if (!fbrepo.checkFacebookUserExists(objFacebookAccount.FbUserId, user.Id))
                    {
                        fbrepo.addFacebookUser(objFacebookAccount);
                        if (!socioprofilerepo.checkUserProfileExist(socioprofile))
                        {
                            socioprofilerepo.addNewProfileForUser(socioprofile);
                        }
                        else
                        {
                            socioprofilerepo.updateSocialProfile(socioprofile);
                        }
                    }
                    else
                    {
                        fbrepo.updateFacebookUser(objFacebookAccount);
                        if (!socioprofilerepo.checkUserProfileExist(socioprofile))
                        {
                            socioprofilerepo.addNewProfileForUser(socioprofile);
                        }
                        else
                        {
                            socioprofilerepo.updateSocialProfile(socioprofile);
                        }
                    }
                    Session["fbSocial"] = null;
                }
                else if (Request.QueryString["op"] == "countmessages")
                {
                    try
                    {
                        int val = 0;
                        /*facebook*/
                        FacebookAccountRepository fbAccoutsRepo = new FacebookAccountRepository();
                        ArrayList lstfacebookAccounts = fbAccoutsRepo.getAllFacebookAccountsOfUser(user.Id);
                        foreach (FacebookAccount item in lstfacebookAccounts)
                        {
                            try
                            {
                                FacebookClient fb = new FacebookClient(item.AccessToken);
                                dynamic unreadcount = fb.Get("fql", new { q = "SELECT unread_count FROM mailbox_folder WHERE folder_id = 0 AND viewer_id = " + item.FbUserId + "" });
                                foreach (var chile in unreadcount.data)
                                {
                                    var count = chile.unread_count;
                                    int countable = Convert.ToInt32(count.ToString());
                                    val = val + countable;

                                }
                            }
                            catch (Exception ex)
                            {
                                logger.Error(ex.Message);
                                Console.WriteLine(ex.Message);
                            }
                        }
                        /*Twitter*/
                        Session["CountMessages"] = val;
                        Response.Write(val);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }

                }

                else if (Request.QueryString["op"] == "recentfollowers")
                {
                    string recentfollowers = string.Empty;
                    #region RecentFollowers
                    Users twtUsers = new Users();
                    TwitterAccountRepository twtAccRepo = new TwitterAccountRepository();
                    ArrayList lstAccRepo = twtAccRepo.getAllTwitterAccountsOfUser(user.Id);
                    oAuthTwitter oauth = null;
                    foreach (TwitterAccount itemTwt in lstAccRepo)
                    {
                        oauth = new oAuthTwitter();
                        oauth.AccessToken = itemTwt.OAuthToken;
                        oauth.AccessTokenSecret = itemTwt.OAuthSecret;
                        oauth.ConsumerKey = ConfigurationManager.AppSettings["consumerKey"];
                        oauth.ConsumerKeySecret = ConfigurationManager.AppSettings["consumerSecret"];
                        oauth.TwitterScreenName = itemTwt.TwitterScreenName;
                        oauth.TwitterUserId = itemTwt.TwitterUserId;
                        JArray jarresponse = twtUsers.Get_Followers_ById(oauth, itemTwt.TwitterUserId);
                        foreach (var item in jarresponse)
                        {
                            int resposecount = 0;
                            if (item["ids"] != null)
                            {
                                foreach (var child in item["ids"])
                                {
                                    if (resposecount < 2)
                                    {
                                        JArray userprofile = twtUsers.Get_Users_LookUp(oauth, child.ToString());

                                        foreach (var items in userprofile)
                                        {
                                            resposecount++;
                                            try
                                            {
                                                recentfollowers += "<li><a href=\"https://twitter.com/" + items["screen_name"] + "\" target=\"_blank\"><img style=\"border:3px solid #FCFCFC;\" title=\"" + items["name"] + "\" width=\"48\" height=\"48\" alt=\"\" src=\"" + items["profile_image_url"] + "\"></a></li>";
                                            }
                                            catch (Exception ex)
                                            {
                                                Console.WriteLine(ex.Message);
                                            }

                                        }
                                    }
                                }
                            }
                        }
                    }

                    Response.Write(recentfollowers);

                    #endregion

                }
                else if (Request.QueryString["op"] == "removefollowers")
                {
                    string removeid = Request.QueryString["removeid"];
                    string userid = Request.QueryString["userid"];
                    Friendship friendship = new Friendship();
                    oAuthTwitter oauth = new oAuthTwitter();
                    TwitterAccountRepository twtaccrepo = new TwitterAccountRepository();
                    TwitterAccount twtAccount = twtaccrepo.getUserInformation(user.Id, userid);
                    oauth.TwitterUserId = twtAccount.TwitterUserId;
                    oauth.TwitterScreenName = twtAccount.TwitterScreenName;
                    oauth.ConsumerKey = ConfigurationManager.AppSettings["consumerKey"];
                    oauth.ConsumerKeySecret = ConfigurationManager.AppSettings["consumerSecret"];
                    oauth.AccessToken = twtAccount.OAuthToken;
                    oauth.AccessTokenSecret = twtAccount.OAuthSecret;
                    JArray responseremove = friendship.Post_Friendship_Destroy(oauth, removeid);

                }
                else if (Request.QueryString["op"] == "wooqueuemessages")
                {
                    ScheduledMessageRepository schmsgRepo = new ScheduledMessageRepository();
                    List<ScheduledMessage> lstschMsg = schmsgRepo.getAllMessagesOfUser(user.Id);
                    string schmessages = string.Empty;
                    string profurl = string.Empty;
                    if (string.IsNullOrEmpty(user.ProfileUrl))
                    {
                        profurl = "../Contents/img/blank_img.png";
                    }
                    else
                    {
                        // profurl = "../Contents/img/blank_img.png";
                        profurl = user.ProfileUrl;
                    }
                    if (lstschMsg.Count != 0)
                    {
                        foreach (ScheduledMessage item in lstschMsg)
                        {

                            schmessages += "<section class=\"section\"><div  class=\"js-task-cont read\">" +
                                                     "<section class=\"task-owner\">" +
                                                         "<img width=\"32\" height=\"32\" border=\"0\" src=\"" + profurl + "\" class=\"avatar\">" +
                                                     "</section>" +
                                                     "<section class=\"task-activity third\">" +
                                                         "<p>" + user.UserName + "</p>" +
                                                         "<div>" + item.CreateTime + "</div>" +
                                                         "<input type=\"hidden\" value=\"#\" id=\"hdntaskid_1\">" +
                                                         "<p></p>" +
                                                   "</section>" +
                                                   "<section class=\"task-message font-13 third\" style=\"height: auto; width: 31%; margin-right: 9px;\"><a class=\"tip_left\">" + item.ShareMessage + "</a></section>";

                            if (item.ProfileType == "facebook")
                            {
                                schmessages += "<div style=\"height:70px; margin-top: 0;\" class=\"userpictiny\">" +
                                                    "<img width=\"48\" height=\"48\" src=\"http://graph.facebook.com/" + item.ProfileId + "/picture?type=small\" alt=\"\">" +
                                                    "<a style=\"right: 2px; top: 40px;\" title=\"\" class=\"userurlpic\" href=\"#\">" +
                                                        "<img  alt=\"\" src=\"../Contents/img/facebook.png\" style=\"height: 16px;width: 16x;\"></a></div>";
                            }
                            else if (item.ProfileType == "twitter")
                            {
                                TwitterAccountRepository twtAccRepo = new TwitterAccountRepository();
                                TwitterAccount twtAccount = twtAccRepo.getUserInformation(user.Id, item.ProfileId);
                                if (twtAccount != null)
                                {
                                    schmessages += "<div style=\"height:70px; margin-top: 0;\" class=\"userpictiny\">" +
                                                    "<img width=\"48\" height=\"48\" src=\"" + twtAccount.ProfileImageUrl + "\" alt=\"\">" +
                                                    "<a style=\"right: 2px; top: 40px;\" title=\"\" class=\"userurlpic\" href=\"#\">" +
                                                        "<img  alt=\"\" src=\"../Contents/img/twitter.png\" style=\"height: 16px;width: 16x;\"></a></div>";
                                }
                            }
                            else if (item.ProfileType == "linkedin")
                            {
                                LinkedInAccountRepository linkAccRepo = new LinkedInAccountRepository();
                                LinkedInAccount linkedAccount = linkAccRepo.getUserInformation(user.Id, item.ProfileId);
                                if (linkedAccount != null)
                                {
                                    schmessages += "<div style=\"height:70px; margin-top: 0;\" class=\"userpictiny\">" +
                                                        "<img width=\"48\" height=\"48\" src=\"" + linkedAccount.ProfileImageUrl + "\" alt=\"\">" +
                                                        "<a style=\"right: 2px; top: 40px;\" title=\"\" class=\"userurlpic\" href=\"#\">" +
                                                            "<img  alt=\"\" src=\"../Contents/img/link.png\" style=\"height: 16px;width: 16x;\"></a></div>";
                                }

                            }
                            schmessages += "<section class=\"task-status\" style=\"width:34px;\"><div class=\"ui_light floating task_status_change\">" +
                                           "<a href=\"#nogo\" class=\"ui-sproutmenu\"><span class=\"ui-sproutmenu-status\"><img title=\"Edit Status\" onclick=\"PerformClick(this.id)\" src=\"../Contents/img/icon_edit.png\" class=\"edit_button\" id=\"img_" + item.Id + "_" + item.Status + "\"></span></a></div></section>" +
                                           "<section class=\"task-status\" style=\"width: 65px; margin-right: 39px;\">" +
                                //"<span class=\"ficon task_active\" id=\"taskcomment\">" +
                                // "<img width=\"14\" height=\"17\" alt=\"\" src=\"../Contents/img/task/task_pin.png\" onclick=\"getmemberdata('7fd5773f-c5b0-4624-bba1-b8a6c0fbd56d');\">" +
                                //"</span>" +
                                          "<div class=\"ui_light floating task_status_change\">" +
                                               "<a href=\"#nogo\" class=\"ui-sproutmenu\">" +
                                                   "<span class=\"ui-sproutmenu-status\">" + item.Status + "</span>" +
                                              "</a>" +
                                          "</div>" +
                                      "</section>" +
                                   "</div></section>";
                        }
                    }
                    else
                    {
                        schmessages = "<section class=\"section\"><div class=\"js-task-cont read\"><section class=\"task-owner\">" +
                          "<img width=\"32\" height=\"32\" border=\"0\" class=\"avatar\" src=\"" + profurl + "\">" +
                          "</section><section class=\"task-activity third\"><p>" + user.UserName + "</p><div></div><p></p></section><section style=\"margin-right: 6px; width: 31%; height: auto;\" class=\"task-message font-13 third\">" +
                          "<a class=\"tip_left\">No Schduled Messages</a></section><section style=\"width:113px;\" class=\"task-status\"><span class=\"ficon task_active\"></span>" +
                          "<div class=\"ui_light floating task_status_change\"><a class=\"ui-sproutmenu\" href=\"#nogo\">" +
                          "<span class=\"ui-sproutmenu-status\"></span></a></div></section></div></section>";
                    }
                    Response.Write(schmessages);

                }
                else if (Request.QueryString["op"] == "drafts_messages")
                {

                }
                else if (Request.QueryString["op"] == "updatequeue")
                {

                    updatequeue(Request.QueryString["id"], Request.QueryString["status"]);

                }

                else if (Request.QueryString["op"] == "messagechk")
                {
                    SocioBoard.Domain.Messages mstable = new SocioBoard.Domain.Messages();
                    string[] types = Request.QueryString["type[]"].Split(',');
                    DataSet ds = (DataSet)Session["MessageDataTable"];
                    DataSet dss = DataTableGenerator.CreateDataSetForTable(mstable);
                    DataTable dtt = dss.Tables[0];
                    DataView dv = new DataView(dtt);
                    AjaxMessage ajxfed = new AjaxMessage();
                    string message = string.Empty;
                    foreach (var item in types)
                    {
                        try
                        {
                            DataRow[] foundRows = ds.Tables[0].Select("Type = '" + item + "'");
                            foreach (var child in foundRows)
                            {
                                dtt.ImportRow(child);
                            }
                        }
                        catch (Exception ex)
                        {
                            logger.Error(ex.Message);
                            Console.WriteLine(ex.Message);
                        }
                    }
                    message = ajxfed.BindData(dtt);
                    Response.Write(message);
                }
            }
        }
Пример #5
0
        public void ProcessRequest()
        {
            SocialProfilesRepository socio = new SocialProfilesRepository();
            List<SocialProfile> alstsocioprofiles = new List<SocialProfile>();
            if (!string.IsNullOrEmpty(Request.QueryString["op"]))
            {
                Domain.User user = (Domain.User)Session["LoggedUser"];

                if (Request.QueryString["op"] == "social_connectivity")
                {

                    #region social connectivity
                    alstsocioprofiles = socio.getAllSocialProfilesOfUser(user.Id);

                    string profiles = string.Empty;

                    foreach (SocialProfile item in alstsocioprofiles)
                    {
                        if (item.ProfileType == "facebook")
                        {
                            try
                            {
                                FacebookAccountRepository facereop = new FacebookAccountRepository();
                                FacebookAccount faceaccount = facereop.getFacebookAccountDetailsById(item.ProfileId, user.Id);
                                profiles += "<div id=\"" + item.ProfileId + "\" class=\"ws_conct\"><span class=\"img\">" +
                                   "<div id='fb_del' onClick=\"confirmDel('" + item.ProfileId + "','fb')\"><span class=\"delete\"></span></div>" +
                                    "<a href=\"" + faceaccount.ProfileUrl + "\" target=\"_blank\" ><img src=\"http://graph.facebook.com/" + item.ProfileId + "/picture?type=small\" width=\"48\" height=\"48\" alt=\"\" /></a>" +
                                          "<i>" +
                                              "<img src=\"../Contents/Images/fb_icon.png\" width=\"16\" height=\"16\" alt=\"\" /></i>" +
                                      "</span>" +
                                  "</div>";
                            }
                            catch (Exception ex)
                            {
                                Console.WriteLine(ex.StackTrace);
                            }
                        }
                        else if (item.ProfileType == "twitter")
                        {
                            try
                            {
                                TwitterAccountRepository twtrepo = new TwitterAccountRepository();
                                TwitterAccount twtaccount = twtrepo.getUserInformation(user.Id, item.ProfileId);

                                profiles += "<div id=\"" + item.ProfileId + "\" class=\"ws_conct\">" +
                                                          "<span class=\"img\"><div id='twt_del' onClick=\"confirmDel('" + item.ProfileId + "','twt')\"><span class=\"delete\"></span></div>" +
                                                              "<img width=\"48\" height=\"48\" alt=\"\" src=\"" + twtaccount.ProfileImageUrl + "\">" +
                                                              "<i><img src=\"../Contents/Images/twticon.png\" width=\"16\" height=\"16\" alt=\"\" /></i>" +
                                                          "</span>" +
                                                     "</div>";
                            }
                            catch (Exception ex)
                            {
                                Console.WriteLine(ex.StackTrace);
                            }

                        }
                        else if (item.ProfileType == "linkedin")
                        {

                            LinkedInAccountRepository liRepo = new LinkedInAccountRepository();
                            string access = string.Empty, tokenSecrate = string.Empty, LdprofileName = string.Empty, LdPreofilePic = string.Empty;
                            LinkedInAccount liaccount = liRepo.getUserInformation(user.Id, item.ProfileId);

                            if (liaccount != null)
                            {
                                try
                                {
                                    if (!string.IsNullOrEmpty(liaccount.ProfileImageUrl))
                                    {
                                        LdPreofilePic = liaccount.ProfileImageUrl;
                                    }
                                    else
                                    {
                                        LdPreofilePic = "../../Contents/Images/blank_img.png";
                                    }

                                    profiles += "<div id=\"" + item.ProfileId + "\" class=\"ws_conct\">" +
                                              "<span class=\"img\">" +
                                                   "<div id='fb_del' onClick=\"confirmDel('" + item.ProfileId + "','linkedin')\"><span class=\"delete\"></span></div>" +
                                                  "<a href=\"" + liaccount.ProfileUrl + "\" target=\"_blank\"><img width=\"48\" height=\"48\"  src=\"" + LdPreofilePic + "\"  alt=\"\"></a>" +
                                                  "<i><img src=\"../Contents/Images/link_icon.png\" width=\"16\" height=\"16\" alt=\"\" /></i>" +
                                              "</span>" +
                                         "</div>";
                                }
                                catch (Exception ex)
                                {
                                    Console.WriteLine(ex.StackTrace);
                                }

                            }
                        }
                        else if (item.ProfileType == "instagram")
                        {
                            try
                            {
                                InstagramAccountRepository objInsAccRepo = new InstagramAccountRepository();
                                InstagramAccount objInsAcc = objInsAccRepo.getInstagramAccountDetailsById(item.ProfileId, user.Id);
                                string accessToken = string.Empty;

                                profiles += "<div id=\"" + item.ProfileId + "\" class=\"ws_conct\">" +
                                  "<span class=\"img\">" +
                                       "<div id='fb_del' onClick=\"confirmDel('" + item.ProfileId + "','instagram')\"><span class=\"delete\"></span></div>" +
                                      "<img width=\"48\" height=\"48\" alt=\"\" src=\"" + objInsAcc.ProfileUrl + "\">" +
                                      "<i><img src=\"../Contents/Images/instagram_24X24.png\" width=\"16\" height=\"16\" alt=\"\" /></i>" +
                                  "</span>" +
                             "</div>";
                            }
                            catch (Exception ex)
                            {
                                Console.WriteLine(ex.StackTrace);
                            }
                        }
                    }
                    Response.Write(profiles);
                    #endregion
                }

                else if (Request.QueryString["op"] == "midsnaps")
                {
                    #region midsnaps
                    Random rNum = new Random();
                    string loadtype = Request.QueryString["loadtype"];
                    string midsnaps = string.Empty;
                    if (loadtype == "load")
                        profilelimit = 0;

                    if (profilelimit != -1)
                    {
                        ArrayList alst = socio.getLimitProfilesOfUser(user.Id, profilelimit);

                        if (alst.Count == 0)
                            profilelimit = -1;
                        else
                            profilelimit += 3;

                        foreach (SocialProfile item in alst)
                        {
                            if (item.ProfileType == "facebook")
                            {
                                FacebookAccountRepository fbrepo = new FacebookAccountRepository();
                                FacebookMessageRepository fbmsgrepo = new FacebookMessageRepository();
                                FacebookAccount fbaccount = fbrepo.getFacebookAccountDetailsById(item.ProfileId, user.Id);
                                List<FacebookMessage> fbmsgs = fbmsgrepo.getAllFacebookMessagesOfUser(user.Id, item.ProfileId);

                                midsnaps += "<div id=\"midsnap_" + item.ProfileId + "\" class=\"col_two_fb\"> " +
                                                    "<div class=\"col_two_fb_my_accounts\">" +
                                                     "<div class=\"dt\"><a class=\"img\"><img src=\"http://graph.facebook.com/" + item.ProfileId + "/picture?type=small\" width=\"48\" height=\"48\" alt=\"\" /></a>" +
                                                    "<span class=\"icon\"></span></div><div class=\"dd\"><h5>" + fbaccount.FbUserName + "</h5><div class=\"friends_avg\"><div class=\"article_friends\">" +
                                                    "<div class=\"facebook_blue\">" + fbaccount.Friends +
                                                    "</div>" +
                                                   "<div class=\"font-10\">Friends</div></div>" +
                                                       "<div class=\"article_avg\"><div class=\"facebook_blue\">" + Math.Round(rNum.NextDouble(), 2) + "</div><div class=\"font-10\">Avg. Posts per Day</div>" +
                                                     "</div>    </div></div> </div>" +
                                                      "<div class=\"pillow_fade\">" +
                                                        "<div class=\"fb_notifications\">" +
                                                                     "Recent Messages</div>" +
                                                               "<div class=\"empty-state\">";

                                if (fbmsgs.Count != 0)
                                {
                                    try
                                    {
                                        int msgcount = 0;
                                        foreach (FacebookMessage child in fbmsgs)
                                        {
                                            string mess = string.Empty;
                                            if (msgcount < 2)
                                            {
                                                if (child.Message.Length > 40)
                                                {
                                                    mess = child.Message.Substring(0, 39);
                                                    mess = mess + "...........";
                                                }
                                                else
                                                {
                                                    mess = child.Message;
                                                }

                                                midsnaps += "<strong><img src=\"http://graph.facebook.com/" + child.FromId + "/picture?type=small\" />" + mess + "</strong><br/>";
                                            }
                                            else
                                            {
                                                break;
                                            }
                                            msgcount++;
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                        Console.WriteLine(ex.StackTrace);
                                    }
                                }
                                else
                                {
                                    midsnaps += "<strong>No messages were found within the past few days.</strong> \"Messages will be displayed once there is activity in this date range.\"";
                                }

                                midsnaps += "</div></div></div>";
                            }
                            else if (item.ProfileType == "twitter")
                            {
                                TwitterAccountRepository twtrepo = new TwitterAccountRepository();
                                TwitterAccount twtaccount = twtrepo.getUserInformation(user.Id, item.ProfileId);
                                TwitterMessageRepository twtmsgrepo = new TwitterMessageRepository();
                                List<TwitterMessage> lsttwtmsgs = twtmsgrepo.getAllTwitterMessagesOfUser(user.Id, item.ProfileId);
                                int tweetcount = 0;
                                midsnaps += "<div id=\"midsnap_" + item.ProfileId + "\" class=\"col_four_twitter\"><div class=\"col_four_twitter_my_accounts\">" +
                                                          "<div class=\"dt\"><a class=\"img\"><img src=\"" + twtaccount.ProfileImageUrl + "\" width=\"48\" height=\"48\" alt=\"\" /></a>" +
                                                          "<span class=\"icon\"></span></div><div class=\"dd\"><h5>" + twtaccount.TwitterScreenName + "</h5>" +
                                                            "<div class=\"friends_avg\"><div class=\"article_friends\"><div class=\"facebook_blue\">" + twtaccount.FollowersCount + "</div>" +
                                                           "<div class=\"font-10\">Followers</div></div><div class=\"article_avg\"><div class=\"facebook_blue\">" +
                                                              " " + Math.Round(rNum.NextDouble(), 2) + "</div><div class=\"font-10\">Avg. Posts per Day</div></div></div></div></div><div class=\"pillow_fade\">" +
                                                            "<div class=\"fb_notifications\"> Recent Messages</div><div class=\"empty-state\">";

                                try
                                {
                                    if (lsttwtmsgs.Count == 0)
                                    {
                                        midsnaps += "<strong>No messages were found within the past few days.</strong> \"Messages will be displayed once there is activity in this date range.\"";
                                    }
                                    else
                                    {
                                        foreach (TwitterMessage msg in lsttwtmsgs)
                                        {
                                            if (tweetcount < 2)
                                            {
                                                try
                                                {
                                                    midsnaps += "<strong><img src=\"" + msg.FromProfileUrl + "\" />" + msg.TwitterMsg + "</strong><br/>";
                                                }
                                                catch (Exception ex)
                                                {
                                                    Console.WriteLine(ex.StackTrace);

                                                }
                                            }
                                            else
                                            {
                                                break;
                                            }
                                            tweetcount++;
                                        }
                                    }
                                }
                                catch (Exception ex)
                                {

                                    Console.WriteLine(ex.StackTrace);
                                }
                                midsnaps += "</div></div> </div>";
                            }
                            else if (item.ProfileType == "linkedin")
                            {
                                string access = string.Empty, tokenSecrate = string.Empty, LdprofileName = string.Empty, LdPreofilePic = string.Empty;
                                LinkedInAccountRepository objLiRepo = new LinkedInAccountRepository();
                                LinkedInFeedRepository objliFeedRepo = new LinkedInFeedRepository();
                                LinkedInAccount liAccount = objLiRepo.getUserInformation(user.Id, item.ProfileId);
                                // IEnumerable<dynamic> data = linkdrepo.GetAccessToken(item.profile_id, loginInfoEmail.Customer_Id);
                                //foreach (var child in data)
                                //{
                                if (liAccount != null)
                                {
                                    LdprofileName = liAccount.LinkedinUserName;
                                    LdPreofilePic = liAccount.ProfileImageUrl;
                                }
                                // }

                                if (string.IsNullOrEmpty(LdPreofilePic))
                                {
                                    LdPreofilePic = "../../Contents/Images/blank_img.png";
                                }
                                int linkedinConcount = liAccount.Connections;

                                midsnaps += " <div id=\"midsnap_" + item.ProfileId + "\" class=\"col_three_linkedin\">" +
                                           "<div class=\"col_three_link_my_accounts\">" +
                                             "<div class=\"dt\"><a class=\"img\">" +
                                               "<img src=\"" + LdPreofilePic + "\" width=\"48\" height=\"48\" alt=\"\" /></a>" +
                                             "<span class=\"icon\"></span></div><div class=\"dd\">" +
                                           "<h5>" + LdprofileName + "</h5><div class=\"friends_avg\">" +
                                       "<div class=\"article_friends\">" +
                                        "   <div class=\"facebook_blue\">" +
                                         "   " + linkedinConcount + "</div>" +
                                          " <div class=\"font-10\">" +
                                           "    Friends</div>" +
                                       "</div>" +
                                       "<div class=\"article_avg\">" +
                                         " <div class=\"facebook_blue\">" +
                                          " " + Math.Round(rNum.NextDouble(), 2) + "</div>" +
                                           "<div class=\"font-10\">" +
                                               "Avg. Posts per Day</div>" +
                                       "</div>" +
                                   "</div>" +
                               "</div>" +
                           "</div>" +
                               "<div class=\"pillow_fade\">" +

                                    "<div class=\"fb_notifications\">Recent Messages</div>" +
                                     "<div class=\"empty-state\">";

                                IEnumerable<dynamic> linkfed = objliFeedRepo.getAllLinkedInFeedsOfUser(user.Id, item.ProfileId);// = facerepo.GetMessages(item.profile_id, loginInfoEmail.Customer_Id);//linkdrepo.GetAllLinkedinFeeds(loginInfoEmail.Customer_Id, item.ToString());
                                int link = 0;

                                if (linkfed.Count() == 0)
                                {
                                    midsnaps += "<strong>No messages were found within the past 14 days.</strong> \"Messages will be displayed once there is activity in this date range.\"";
                                }
                                else
                                {

                                    try
                                    {

                                        foreach (var l in linkfed)
                                        {
                                            try
                                            {
                                                if (link < 2)
                                                {
                                                    string ms = string.Empty;
                                                    if (l.Feeds.Length > 20)
                                                    {
                                                        ms = l.Feeds.Substring(0, 20) + "..."; ;

                                                    }
                                                    else
                                                    {
                                                        ms = l.Feeds;
                                                    }
                                                    midsnaps += "<strong><img src=\"" + l.FromPicUrl + "\">" + ms + " </strong><br/>";
                                                    link++;
                                                }
                                                else
                                                {
                                                    break;
                                                }
                                            }
                                            catch
                                            {
                                            }
                                        }
                                    }
                                    catch { }

                                }

                                midsnaps += "</div></div> </div>";

                            }
                            else if (item.ProfileType == "instagram")
                            {
                                InstagramAccountRepository objInsAccRepo = new InstagramAccountRepository();
                                InstagramAccount objInsAcc = objInsAccRepo.getInstagramAccountDetailsById(item.ProfileId, user.Id);

                                midsnaps += " <div class=\"col_seven_instagram\">" +
                                         "<div class=\"col_seven_instagram_link_my_accounts\">" +
                                           "<div class=\"dt\"><a class=\"img\">" +
                                             "<img src=\"" + objInsAcc.ProfileUrl + "\" width=\"48\" height=\"48\" alt=\"\" /></a>" +
                                           "<span class=\"icon\"></span></div><div class=\"dd\">" +
                                         "<h5>" + objInsAcc.InsUserName + "</h5><div class=\"friends_avg\">" +

                                 "</div>" +
                             "</div>" +
                         "</div>" +
                             "<div class=\"pillow_fade\">" +
                                 "<div class=\"fb_notifications\">" +
                                     "<ul class=\"user-stats\">" +
                                                "<li>" +
                                                   "<div class=\"photo_stat\">  photos" +
                                                   "</div>" +
                                                   "<div class=\"number-stat\">" + objInsAcc.TotalImages +
                                                   "</div>" +
                                                "</li>" +
                                                "<li>" +
                                                    "<div class=\"photo_stat\"> followers" +
                                                   "</div>" +
                                                   "<div class=\"number-stat\">" + objInsAcc.FollowedBy +
                                                   "</div>" +
                                                "</li>" +
                                                "<li>" +
                                                    "<div class=\"photo_stat\"> following" +
                                                   "</div>" +
                                                   "<div class=\"number-stat\">" + objInsAcc.Followers +
                                                   "</div>" +
                                                "</li>" +
                                             "</ul>" +
                                     "</div>" +
                             "</div>" +
                         "</div>";
                            }

                        }

                        Response.Write(midsnaps);
                    }
                    #endregion

                }
                else if (Request.QueryString["op"] == "accountdelete")
                {
                    #region accountdelete

                    string Profiletype = Request.QueryString["profile"];
                    string profileid = Request.QueryString["profileid"];

                    if (Profiletype == "fb")
                    {
                        try
                        {
                            FacebookAccountRepository fbrepo = new FacebookAccountRepository();
                            int delacc = fbrepo.deleteFacebookUser(profileid, user.Id);
                            if (delacc != 0)
                            {
                                SocialProfilesRepository socioprofile = new SocialProfilesRepository();
                                socioprofile.deleteProfile(user.Id, profileid);
                                FacebookMessageRepository fbmsgrepo = new FacebookMessageRepository();
                                fbmsgrepo.deleteAllMessagesOfUser(profileid, user.Id);
                                FacebookFeedRepository fbfeedrepo = new FacebookFeedRepository();
                                fbfeedrepo.deleteAllFeedsOfUser(profileid, user.Id);
                            }

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

                        }
                    }
                    else if (Profiletype == "twt")
                    {
                        TwitterAccountRepository twtaccountrepo = new TwitterAccountRepository();
                        int deltwtacc = twtaccountrepo.deleteTwitterUser(user.Id, profileid);
                        if (deltwtacc != 0)
                        {
                            SocialProfilesRepository socioprofile = new SocialProfilesRepository();
                            socioprofile.deleteProfile(user.Id, profileid);

                        }
                    }

                    #endregion
                }
                else if (Request.QueryString["op"] == "MasterCompose")
                {
                    #region mastercompose
                    string profiles = string.Empty;

                    if (Session["profilesforcomposemessage"] == null)
                    {
                        profiles += "<div class=\"drop_top\"></div><div class=\"drop_mid\">";

                        /*facebook users binding*/
                        FacebookAccountRepository fbrepo = new FacebookAccountRepository();
                        ArrayList lstfbaccounts = fbrepo.getAllFacebookAccountsOfUser(user.Id);

                        profiles += "<div class=\"twitte_text\">FACEBOOK</div><div class=\"teitter\"><ul>";
                        if (lstfbaccounts.Count == 0)
                        {
                            profiles += "<li>No Records Found</li>";
                        }
                        else
                        {
                            foreach (FacebookAccount fbacc in lstfbaccounts)
                            {
                                profiles += "<li id=\"liid_" + fbacc.FbUserId + "\"   onclick=\"composemessage(this.id,'fb')\"><a href=\"#\"><img id=\"img_" + fbacc.FbUserId + "\" src=\"../Contents/Images/facebook.png\" alt=\"" + fbacc.AccessToken + "\" border=\"none\" width=\"18\" style=\"float:left;\" /><span id=\"composename_" + fbacc.FbUserId + "\" style=\"float:left;margin: 3px 0 0 5px;\">" + fbacc.FbUserName + "</span><span id=\"imgurl_" + fbacc.FbUserId + "\" style=\"display:none;\">http://graph.facebook.com/" + fbacc.FbUserId + "/picture?type=small</span></a></li>";
                            }
                        }
                        profiles += "</ul> </div>";

                        /*twitter users binding*/
                        TwitterAccountRepository twtaccountrepo = new TwitterAccountRepository();
                        ArrayList alsttwtaccounts = twtaccountrepo.getAllTwitterAccountsOfUser(user.Id);
                        profiles += "<div class=\"twitte_text\">TWITTER</div><div class=\"teitter\"><ul>";
                        if (alsttwtaccounts.Count == 0)
                        {
                            profiles += "<li>No Records Found</li>";
                        }
                        else
                        {
                            foreach (TwitterAccount item in alsttwtaccounts)
                            {
                                profiles += "<li id=\"liid_" + item.TwitterUserId + "\"   onclick=\"composemessage(this.id,'twt')\"><a href=\"#\"><img id=\"img_" + item.TwitterUserId + "\" src=\"../Contents/Images/twitter.png\" alt=\"" + item.OAuthToken + "\" border=\"none\" width=\"18\" style=\"float:left;\" /><span id=\"imgurl_" + item.TwitterUserId + "\" style=\"display:none;\">" + item.ProfileImageUrl + "</span><span id=\"composename_" + item.TwitterUserId + "\" style=\"float:left;margin: 3px 0 0 5px;\">" + item.TwitterScreenName + "</span></a></li>";
                            }
                        }
                        profiles += "</ul> </div>";

                        /*linkedinuserbinding*/
                        LinkedInAccountRepository linkaccountrepo = new LinkedInAccountRepository();
                        ArrayList alstlinkacc = linkaccountrepo.getAllLinkedinAccountsOfUser(user.Id);
                        profiles += "<div class=\"twitte_text\">LinkedIn</div><div class=\"teitter\"><ul>";

                        if (alstlinkacc.Count == 0)
                        {
                            profiles += "<li>No Records Found</li>";
                        }
                        else
                        {

                            foreach (LinkedInAccount item in alstlinkacc)
                            {
                                string profileurl = string.Empty;

                                if (!string.IsNullOrEmpty(item.ProfileUrl))
                                {
                                    profileurl = item.ProfileUrl;
                                }
                                else
                                {
                                    profileurl = "../../Contents/Images/blank_img.png";
                                }
                                profiles += "<li id=\"liid_" + item.LinkedinUserId + "\"   onclick=\"composemessage(this.id,'lin')\"><a href=\"#\"><img id=\"img_" + item.LinkedinUserId + "\" src=\"../Contents/Images/link.png\" alt=\"" + item.OAuthToken + "\" border=\"none\" width=\"18\" style=\"float:left;\" /><span id=\"imgurl_" + item.LinkedinUserId + "\" style=\"display:none;\">" + profileurl + "</span><span id=\"composename_" + item.LinkedinUserId + "\" style=\"float:left;margin: 3px 0 0 5px;\">" + item.LinkedinUserName + "</span></a></li>";
                            }
                        }
                        profiles += "</ul> </div>";
                        Session["profilesforcomposemessage"] = profiles;
                    }
                    else
                    {
                        profiles = (string)Session["profilesforcomposemessage"];
                    }
                    Response.Write(profiles);
                    #endregion
                }
                else if (Request.QueryString["op"] == "sendmessage")
                {

                    #region sendmessage
                    string message = Request.QueryString["message"];
                    var userid = Request.QueryString["userid[]"].Split(',');

                    foreach (var item in userid)
                    {
                        string[] networkingwithid = item.Split('_');
                        if (networkingwithid[0] == "fb")
                        {
                            FacebookAccountRepository fbaccountrepo = new FacebookAccountRepository();
                            FacebookAccount fbaccount = fbaccountrepo.getFacebookAccountDetailsById(networkingwithid[1], user.Id);
                            var args = new Dictionary<string, object>();
                            args["message"] = message;
                            FacebookClient fc = new FacebookClient(fbaccount.AccessToken);
                            var facebookpost = fc.Post("/me/feed", args);
                            if (facebookpost.ToString() != string.Empty)
                            {
                                Response.Write("Succesfully posted");
                            }
                            else
                            {
                                Response.Write("Not posted");
                            }

                        }
                        else if (networkingwithid[0] == "twt")
                        {
                            TwitterAccountRepository twtaccountrepo = new TwitterAccountRepository();
                            TwitterAccount twtaccount = twtaccountrepo.getUserInformation(user.Id, networkingwithid[1]);
                            oAuthTwitter OAuthTwt = new oAuthTwitter();
                            TwitterHelper twthelper = new TwitterHelper();
                            OAuthTwt.AccessToken = twtaccount.OAuthToken;
                            OAuthTwt.AccessTokenSecret = twtaccount.OAuthSecret;
                            OAuthTwt.TwitterScreenName = twtaccount.TwitterScreenName;
                            twthelper.SetCofigDetailsForTwitter(OAuthTwt);
                            TwitterUser twtuser = new TwitterUser();
                            JArray post = twtuser.Post_Status_Update(OAuthTwt, message);
                            if (post.ToString() != string.Empty)
                            {
                                Response.Write("Succesfully posted");
                            }
                            else
                            {
                                Response.Write("Not posted");
                            }
                        }
                        else if (networkingwithid[0] == "lin")
                        {
                            LinkedInAccountRepository linkedinaccrepo = new LinkedInAccountRepository();
                            LinkedInAccount linkedaccount = linkedinaccrepo.getUserInformation(user.Id, networkingwithid[1]);
                            oAuthLinkedIn Linkedin_oauth = new oAuthLinkedIn();

                            Linkedin_oauth.Verifier = linkedaccount.OAuthVerifier;
                            Linkedin_oauth.TokenSecret = linkedaccount.OAuthSecret;
                            Linkedin_oauth.Token = linkedaccount.OAuthToken;
                            Linkedin_oauth.Id = linkedaccount.LinkedinUserId;
                            Linkedin_oauth.FirstName = linkedaccount.LinkedinUserName;
                            SocialStream sociostream = new SocialStream();
                            string res = sociostream.SetStatusUpdate(Linkedin_oauth, message);
                        }
                    }
                    #endregion
                }
                else if (Request.QueryString["op"] == "wooqueuemessages")
                {
                    ScheduledMessageRepository schmsgRepo = new ScheduledMessageRepository();
                    List<ScheduledMessage> lstschMsg = schmsgRepo.getAllMessagesOfUser(user.Id);
                    string schmessages = string.Empty;
                    string profurl = string.Empty;
                    if (string.IsNullOrEmpty(user.ProfileUrl))
                    {
                        profurl = "../Contents/img/blank_img.png";
                    }
                    else
                    {
                        profurl = user.ProfileUrl;
                    }

                    foreach (ScheduledMessage item in lstschMsg)
                    {
                        schmessages += "<div  class=\"js-task-cont read\">" +
                                                 "<section class=\"task-owner\">" +
                                                     "<img width=\"32\" height=\"32\" border=\"0\" src=\""+profurl+"\" class=\"avatar\">" +
                                                 "</section>" +
                                                 "<section class=\"task-activity third\">" +
                                                     "<p>"+user.UserName+"</p>" +
                                                     "<div>"+item.CreateTime+"</div>" +
                                                     "<input type=\"hidden\" value=\"#\" id=\"hdntaskid_1\">" +
                                                     "<p></p>" +
                                               "</section>" +
                                               "<section class=\"task-message font-13 third\"><a class=\"tip_left\">"+item.ShareMessage+"</a></section>" +
                                               "<section class=\"task-status\">" +
                                                 "<span class=\"ficon task_active\" id=\"taskcomment\">" +
                                                    // "<img width=\"14\" height=\"17\" alt=\"\" src=\"../Contents/img/task/task_pin.png\" onclick=\"getmemberdata('7fd5773f-c5b0-4624-bba1-b8a6c0fbd56d');\">" +
                                                "</span>" +
                                                "<div class=\"ui_light floating task_status_change\">" +
                                                     "<a href=\"#nogo\" class=\"ui-sproutmenu\">" +
                                                         "<span class=\"ui-sproutmenu-status\">True" +
                                                            // "<img title=\"Edit Status\" onclick=\"PerformClick(this.id)\" src=\"../Contents/img/icon_edit.png\" class=\"edit_button\" id=\"img_7fd5773f-c5b0-4624-bba1-b8a6c0fbd56d_True\">
                                                            "</span>" +
                                                    "</a>" +
                                                "</div>" +
                                            "</section>" +
                                         "</div>";
                    }
                    Response.Write(schmessages);

                }
                else if (Request.QueryString["op"] == "schedulemessage")
                {

                    var userid = Request.QueryString["users[]"].Split(',');
                    var datearr = Request.QueryString["datearr[]"].Split(',');
                    string message = Request.QueryString["message"];
                    ScheduledMessageRepository schmsgrepo = new ScheduledMessageRepository();
                    string time = Request.QueryString["time"];
                    string clienttime = Request.QueryString["clittime"];

                    foreach (var item in userid)
                    {
                        if (!string.IsNullOrEmpty(item.ToString()))
                        {
                            foreach (var child in datearr)
                            {

                                ScheduledMessage schmessage = new ScheduledMessage();
                                string[] networkingwithid = item.Split('_');

                                if (networkingwithid[0] == "fbscheduler")
                                {
                                    schmessage.CreateTime = DateTime.Now;
                                    schmessage.ProfileType = "facebook";
                                    schmessage.ProfileId = networkingwithid[1];
                                    schmessage.Id = Guid.NewGuid();
                                    schmessage.PicUrl = string.Empty;
                                    schmessage.ClientTime = Convert.ToDateTime(clienttime);
                                    string servertime = this.CompareDateWithServer(clienttime, child + " " + time);
                                    schmessage.ScheduleTime = Convert.ToDateTime(servertime);
                                    schmessage.ShareMessage = message;
                                    schmessage.UserId = user.Id;
                                    schmessage.Status = false;

                                }
                                else if (networkingwithid[0] == "twtscheduler")
                                {

                                    schmessage.CreateTime = DateTime.Now;
                                    schmessage.ProfileType = "twitter";
                                    schmessage.ProfileId = networkingwithid[1];
                                    schmessage.Id = Guid.NewGuid();
                                    schmessage.PicUrl = string.Empty;
                                    schmessage.ClientTime = Convert.ToDateTime(clienttime);
                                    string servertime = this.CompareDateWithServer(clienttime, child + " " + time);
                                    schmessage.ScheduleTime = Convert.ToDateTime(servertime);
                                    schmessage.ShareMessage = message;
                                    schmessage.UserId = user.Id;
                                    schmessage.Status = false;

                                }
                                else if (networkingwithid[0] == "linscheduler")
                                {
                                    schmessage.ClientTime = Convert.ToDateTime(clienttime);
                                    schmessage.CreateTime = DateTime.Now;
                                    schmessage.ProfileType = "linkedin";
                                    schmessage.ProfileId = networkingwithid[1];
                                    schmessage.Id = Guid.NewGuid();
                                    schmessage.PicUrl = string.Empty;
                                    string servertime = this.CompareDateWithServer(clienttime, child + " " + time);
                                    schmessage.ScheduleTime = Convert.ToDateTime(servertime);
                                    schmessage.ShareMessage = message;
                                    schmessage.UserId = user.Id;
                                    schmessage.Status = false;

                                }

                                if (!string.IsNullOrEmpty(message))
                                {
                                    if (!schmsgrepo.checkMessageExistsAtTime(user.Id, schmessage.ShareMessage, schmessage.ScheduleTime, schmessage.ProfileId))
                                    {
                                        schmsgrepo.addNewMessage(schmessage);
                                    }
                                }
                            }

                        }
                    }
                }
            }
        }
Пример #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            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();
            SocioBoard.Domain.User user = (User)Session["LoggedUser"];
            Session["facebooktotalprofiles"] = null;

            if (!IsPostBack)
            {

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

                    if (Request.QueryString["paymentTransaction"] == "Success")
                    {
                        ScriptManager.RegisterStartupScript(this, GetType(), "Paypall Success", "alert('Your transaction has been Suceeded !');", true);
                    }

                    if (Request.QueryString["paymentTransaction"] == "Cancel")
                    {
                        ScriptManager.RegisterStartupScript(this, GetType(), "Paypall Cancel", "<script type=\"text/javascript\">alert('Your transaction has been cancel !');</script>", true);
                    }

                    if (Request.QueryString["paymentTransaction"] == "Failed")
                    {
                        ScriptManager.RegisterStartupScript(this, GetType(), "Paypall Failed", "alert('Your transaction has been failed !');", true);
                    }

                    #region check user Activation
                    try
                    {
                        objUserActivation = objUserActivationRepository.GetUserActivationStatus(user.Id.ToString());
                        if (objUserActivation.ActivationStatus == "0")
                        {
                            if (Request.QueryString["stat"] == "activate")
                            {
                               // if (Request.QueryString["id"] != null)
                                {
                                    //objUserActivation = objUserActivationRepository.GetUserActivationStatusbyid(Request.QueryString["id"].ToString());
                                   // if (objUserActivation.Id.ToString() == Request.QueryString["id"].ToString())
                                    {
                                        objUserActivation.Id = objUserActivation.Id;//Guid.Parse(Request.QueryString["id"]);
                                        objUserActivation.UserId = objUserActivation.UserId;
                                        objUserActivation.ActivationStatus = "1";
                                        UserActivationRepository.Update(objUserActivation);
                                    }
                                    //else
                                    //{
                                    //    Session["ActivationError"] = "Wrong Activation Link please contact Admin!";
                                    //    //ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Wrong Activation Link please contact Admin!');", true);
                                    //    Response.Redirect("ActivationLink.aspx");
                                    //}
                                }
                                //else
                                //{
                                //    Session["ActivationError"] = "Wrong Activation Link please contact Admin!";
                                //    //ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Wrong Activation Link please contact Admin!');", true);
                                //    Response.Redirect("ActivationLink.aspx");
                                //}

                            }
                            else
                            {
                                Response.Redirect("ActivationLink.aspx");
                            }

                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                        logger.Error(ex.StackTrace);
                    }
                    #endregion

                    #region day count
                    chkdate = user.CreateDate;
                    DateTime curDate = DateTime.Now;
                    TimeSpan ts = curDate - chkdate;
                    datediff = ts.TotalDays;

                    if (datediff > 30)
                    {
                        Response.Redirect("Settings/Billing.aspx");
                    }
                    #endregion
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    logger.Error(ex.StackTrace);
                }

                #region Count Used Accounts
                try
                {
                    if (user.AccountType.ToString().ToUpper() == "SMALL BUSINESS".ToUpper())
                        tot_acc = 25;
                    else if (user.AccountType.ToString().ToUpper() == "CORPORATION".ToUpper())
                        tot_acc = 60;
                    else if (user.AccountType.ToString().ToUpper() == "INDIVIDUAL".ToUpper())
                        tot_acc = 10;
                    profileCount = objSocioRepo.getAllSocialProfilesOfUser(user.Id).Count;
                    Session["ProfileCount"] = profileCount;
                    Session["TotalAccount"] = tot_acc;
                    usedAccount.InnerHtml = " using " + profileCount + " of " + tot_acc;
                }
                catch (Exception ex)
                {
                    logger.Error(ex.StackTrace);
                }
                #endregion

                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();
                    foreach (var item in lstads)
                    {
                        Array temp = (Array)item;
                        imgAds.ImageUrl = temp.GetValue(2).ToString();
                        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> team = objTeamRepo.getAllTeamsOfUser(user.Id);
                    foreach (Team item in team)
                    {
                        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 = (int)daysSub;
                    ArrayList arrFbStats = objfbStatsRepo.getAllFacebookStatsOfUser(user.Id, userdays);
                    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);
                getNewFollowers(7);
                #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

            }
        }
Пример #7
0
        private string RemainingAccount(SocioBoard.Domain.User user)
        {
            string res = "using " + Session["ProfileCount"].ToString() + " of " + Session["TotalAccount"].ToString();
            try
            {
                SocialProfilesRepository objSocioRepo = new SocialProfilesRepository();
                Session["ProfileCount"] = objSocioRepo.getAllSocialProfilesOfUser(user.Id).Count;

                res = "using " + Session["ProfileCount"].ToString() + " of " + Session["TotalAccount"].ToString();
            }
            catch (Exception ex)
            {

                logger.Error(ex.Message);
                Console.WriteLine(ex.Message);
            }
            return res;
        }
Пример #8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            #region Varibles Initialize
            UserRepository userrepo = new UserRepository();
            Registration regObject = new Registration();
            TeamRepository objTeamRepo = new TeamRepository();
            NewsRepository objNewsRepo = new NewsRepository();
            AdsRepository objAdsRepo = new AdsRepository();
            SocialProfilesRepository objSocioRepo = new SocialProfilesRepository();
            #endregion
            SocioBoard.Domain.User user = (User)Session["LoggedUser"];
            if (!IsPostBack)
            {
                try
                {
                   if (user == null)
                        Response.Redirect("Default.aspx");
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    logger.Error(ex.StackTrace);
                }

                if (!string.IsNullOrEmpty(Request.QueryString["type"]))
                {
                    try
                    {
                        userrepo.UpdateAccountType(user.Id, Request.QueryString["type"]);

                        User newUser = (User)Session["LoggedUser"];
                        newUser.Id = user.Id;
                        newUser.Password = user.Password;
                        newUser.PaymentStatus = user.PaymentStatus;
                        newUser.ProfileUrl = user.ProfileUrl;
                        newUser.TimeZone = user.TimeZone;
                        newUser.UserName = user.UserName;
                        newUser.UserStatus = user.UserStatus;
                        newUser.AccountType = Request.QueryString["type"];
                        newUser.CreateDate = user.CreateDate;
                        newUser.ExpiryDate = user.ExpiryDate;
                        newUser.EmailId = user.EmailId;
                        Session["LoggedUser"] = null;
                        Session["LoggedUser"] = newUser;
                        user.AccountType  = newUser.AccountType;

                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.StackTrace);
                        logger.Error(ex.StackTrace);
                    }
                }
                #region Count Used Accounts
                try
                {

                    PackageRepository packageRepo = new PackageRepository();
                    List<Package> lstPackage = packageRepo.getAllPackage();

                    foreach (Package item in lstPackage)
                    {
                        if (user.AccountType.ToLower() == item.PackageName.ToLower())
                        {
                            tot_acc = item.TotalProfiles;
                            break;
                        }
                    }

                    profileCount = objSocioRepo.getAllSocialProfilesOfUser(user.Id).Count;
                    Session["ProfileCount"] = profileCount;
                    Session["TotalAccount"] = tot_acc;
                    usedAccount.InnerHtml = " using " + profileCount + " of " + tot_acc;
                }
                catch(Exception ex)
                {
                    logger.Error(ex.StackTrace);
                }
                #endregion
                #region News

                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();
                    foreach (var item in lstads)
                    {
                        Array temp = (Array)item;
                        imgAds.ImageUrl = temp.GetValue(2).ToString();
                        break;
                        // ads.ImageUrl;
                    }
                }
                catch (Exception Err)
                {
                    Console.Write(Err.StackTrace);
                    logger.Error(Err.StackTrace);
                }
                #endregion
                #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> team = objTeamRepo.getAllTeamsOfUser(user.Id);
                        foreach (Team item in team)
                        {
                            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 = (int)daysSub;
                    ArrayList arrFbStats = objfbStatsRepo.getAllFacebookStatsOfUser(user.Id, userdays);
                    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);
                getNewFollowers(7);
                #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

            }
        }
Пример #9
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;

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

                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"];
                }

                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;
                        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);

                    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;
                   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);
            }
        }
Пример #10
0
        public string ProfilesConnected(string UserId)
        {
            try
            {

                Guid userid = Guid.Parse(UserId);
                SocialProfilesRepository socialRepo = new SocialProfilesRepository();
                List<SocialProfile> lstsocioprofile = socialRepo.getAllSocialProfilesOfUser(userid);
                List<profileConnected> lstProfile = new List<profileConnected>();
                foreach (SocialProfile sp in lstsocioprofile)
                {
                    profileConnected pc = new profileConnected();
                    pc.Id = sp.Id;
                    pc.ProfileDate = sp.ProfileDate;
                    pc.ProfileId = sp.ProfileId;
                    pc.ProfileStatus = sp.ProfileStatus;
                    pc.ProfileType = sp.ProfileType;
                    pc.UserId = sp.UserId;
                    if (sp.ProfileType == "facebook")
                    {
                        try
                        {
                            FacebookAccountRepository objFbAccRepo = new FacebookAccountRepository();
                            FacebookAccount objFbAcc = objFbAccRepo.getUserDetails(sp.ProfileId);
                            pc.ProfileName = objFbAcc.FbUserName;
                            pc.ProfileImgUrl = "http://graph.facebook.com/" + sp.ProfileId + "/picture?type=small";
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }
                    }
                    else if (sp.ProfileType == "twitter")
                    {
                        try
                        {
                            TwitterAccountRepository objTwtAccRepo = new TwitterAccountRepository();
                            TwitterAccount objTwtAcc = objTwtAccRepo.getUserInfo(sp.ProfileId);
                            pc.ProfileName = objTwtAcc.TwitterScreenName;
                            pc.ProfileImgUrl = objTwtAcc.ProfileImageUrl;
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }
                    }
                    else if (sp.ProfileType == "instagram")
                    {
                        try
                        {
                            InstagramAccountRepository objInsAccRepo = new InstagramAccountRepository();
                            InstagramAccount objInsAcc = objInsAccRepo.getInstagramAccountById(sp.ProfileId);
                            pc.ProfileName = objInsAcc.InsUserName;
                            pc.ProfileImgUrl = objInsAcc.ProfileUrl;
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }
                    }
                    else if (sp.ProfileType == "linkedin")
                    {
                        try
                        {
                            LinkedInAccountRepository objLiAccRepo = new LinkedInAccountRepository();
                            LinkedInAccount objLiAcc = objLiAccRepo.getLinkedinAccountDetailsById(sp.ProfileId);
                            pc.ProfileName = objLiAcc.LinkedinUserName;
                            pc.ProfileImgUrl = objLiAcc.ProfileImageUrl;
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }
                    }
                    else if (sp.ProfileType == "googleplus")
                    {
                        try
                        {
                            GooglePlusAccountRepository objGpAccRepo = new GooglePlusAccountRepository();
                            GooglePlusAccount objGpAcc = objGpAccRepo.getUserDetails(sp.ProfileId);
                            pc.ProfileName = objGpAcc.GpUserName;
                            pc.ProfileImgUrl = objGpAcc.GpProfileImage;
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }
                    }
                    lstProfile.Add(pc);
                }
                return new JavaScriptSerializer().Serialize(lstProfile);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
                return new JavaScriptSerializer().Serialize("Please Try Again");
            }
        }
Пример #11
0
        public void ProfilesAvailabeforuser(Guid UserId)
        {
            string bindprofiles = string.Empty;

            SocialProfilesRepository socioprofilerepo = new SocialProfilesRepository();
            List<SocialProfile> lstsocialprofile = socioprofilerepo.getAllSocialProfilesOfUser(UserId);
            foreach (SocialProfile item in lstsocialprofile)
            {

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

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

                        bindprofiles += "<div onclick=\"transfertoGroup('instagram','" + item.ProfileId + "')\" id=\"usergroups_" + item.ProfileId + "\" class=\"ws_conct active\"><span class=\"img\"><img width=\"48\" height=\"48\" src=\"" + profileimgurl + "\" alt=\"\"><i>" +
                                          "<img width=\"16\" height=\"16\" alt=\"\" src=\"../Contents/img/instagram_24X24.png\"></i></span><div class=\"fourfifth\"><div class=\"location-container\">" + instaaccount.InsUserName + "</div>" +
                            "<span class=\"add remove\">✖</span></div></div>";
                    }
                }

            }
            AllGroupProfiles.InnerHtml = bindprofiles;


        }
Пример #12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {


                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();
                SocioBoard.Domain.User user = (User)Session["LoggedUser"];
                Session["facebooktotalprofiles"] = null;



                if (user.Password == null)
                {

                    Response.Redirect("/Pricing.aspx");
                }



                #region Days remaining
                if (Session["days_remaining"] == null)
                {
                    if (user.PaymentStatus == "unpaid")
                    {
                        int daysremaining = (user.ExpiryDate.Date - DateTime.Now.Date).Days;
                        if (daysremaining < 0)
                        {
                            daysremaining = 0;
                        }
                        Session["days_remaining"] = daysremaining;
                        //ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('You are using '" + user.AccountType + "' account only '" + daysremaining + "' days is remaining !');", true);
                        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")
                {
                    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 check user Activation

                    //try
                    //{
                    //    if (objUserActivation != null)
                    //    {
                    //        if (objUserActivation.ActivationStatus == "0")
                    //        {
                    //            if (Request.QueryString["stat"] == "activate")
                    //            {
                    //                if (Request.QueryString["id"] != null)
                    //                {
                    //                    //objUserActivation = objUserActivationRepository.GetUserActivationStatusbyid(Request.QueryString["id"].ToString());
                    //                    if (objUserActivation.UserId.ToString() == Request.QueryString["id"].ToString())
                    //                    {
                    //                        objUserActivation.Id = objUserActivation.Id; //Guid.Parse(Request.QueryString["id"]);
                    //                        objUserActivation.UserId = Guid.Parse(Request.QueryString["id"]);// objUserActivation.UserId;
                    //                        objUserActivation.ActivationStatus = "1";
                    //                        UserActivationRepository.Update(objUserActivation);



                    //                    }
                    //                    else
                    //                    {
                    //                        Session["ActivationError"] = "Wrong Activation Link please contact Admin!";
                    //                        //ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Wrong Activation Link please contact Admin!');", true);
                    //                        //Response.Redirect("ActivationLink.aspx");
                    //                    }
                    //                }
                    //                else
                    //                {
                    //                    Session["ActivationError"] = "Wrong Activation Link please contact Admin!";
                    //                    //ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Wrong Activation Link please contact Admin!');", true);
                    //                    //Response.Redirect("ActivationLink.aspx");
                    //                }

                    //            }
                    //            else
                    //            {
                    //               // Response.Redirect("ActivationLink.aspx");
                    //            }


                    //        }
                    //    }
                    //}
                    //catch (Exception ex)
                    //{
                    //    Console.WriteLine(ex.Message);
                    //    logger.Error(ex.StackTrace);
                    //}
                    //#endregion



                    #region Count Used Accounts
                    try
                    {
                        if (user.AccountType.ToString().ToLower() == AccountType.Deluxe.ToString().ToLower())
                            tot_acc = 20;
                        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 = 50;
                        else if (user.AccountType.ToString().ToLower() == AccountType.Free.ToString().ToLower())
                            tot_acc = 5;
                        profileCount = objSocioRepo.getAllSocialProfilesOfUser(user.Id).Count;
                        Session["ProfileCount"] = profileCount;
                        Session["TotalAccount"] = tot_acc;
                        usedAccount.InnerHtml = " using " + profileCount + " of " + tot_acc;
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.StackTrace);
                    }
                    #endregion




                    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> team = objTeamRepo.getAllTeamsOfUser(user.Id);
                        foreach (Team item in team)
                        {
                            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 = (int)daysSub;
                        ArrayList arrFbStats = objfbStatsRepo.getAllFacebookStatsOfUser(user.Id, userdays);
                        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);
                    getNewFollowers(7);
                    #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


                }
            }
            catch (Exception Err)
            {
                Console.Write(Err.StackTrace);
            }
        }
Пример #13
0
        protected void Page_Load(object sender, EventArgs e)
        {
            User user = (User)Session["LoggedUser"];

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

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

                        Session["GreaterThan30Days"] = "GreaterThan30Days";

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

            if (!IsPostBack)
            {





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

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

                var strgenderTwt = Session["twtGender"].ToString().Split(',');
                divtwtMale.InnerHtml = strgenderTwt[0] + "%";
                divtwtfeMale.InnerHtml = strgenderTwt[1] + "%";
            }

        }
Пример #14
0
        public DataSet bindSentMessagesToDataTable(User user, string network)
        {
            SocialProfilesRepository socioprofrepo = new SocialProfilesRepository();
            List<SocialProfile> alstprofiles = socioprofrepo.getAllSocialProfilesOfUser(user.Id);
            Messages mstable = new Messages();
            DataSet ds = DataTableGenerator.CreateDataSetForTable(mstable);
            foreach (SocialProfile item in alstprofiles)
            {
                if (item.ProfileType == "facebook")
                {
                    FacebookMessageRepository fbmsgrepo = new FacebookMessageRepository();
                    List<FacebookMessage> alstfbmsgs = fbmsgrepo.getAllSentMessages(item.ProfileId);

                    if (alstfbmsgs != null)
                    {
                        if (alstfbmsgs.Count != 0)
                        {
                            foreach (FacebookMessage facebookmsg in alstfbmsgs)
                            {
                                ds.Tables[0].Rows.Add(facebookmsg.ProfileId, "facebook", facebookmsg.FromId, facebookmsg.FromName, facebookmsg.FromProfileUrl, facebookmsg.MessageDate, facebookmsg.Message, facebookmsg.FbComment, facebookmsg.FbLike, facebookmsg.MessageId, facebookmsg.Type);

                            }

                        }
                    }
                }
                else if (item.ProfileType == "twitter")
                {
                    TwitterDirectMessageRepository twtmsgrepo = new TwitterDirectMessageRepository();
                    List<TwitterDirectMessages> lstmsgtwtuser = twtmsgrepo.getAllDirectMessagesById(item.ProfileId);
                    foreach (TwitterDirectMessages lst in lstmsgtwtuser)
                    {
                        ds.Tables[0].Rows.Add(lst.SenderId, "twitter", lst.SenderId, lst.SenderScreenName, lst.SenderProfileUrl, lst.CreatedDate, lst.Message, "", "", lst.MessageId, lst.Type);
                    }
                }
                else if (item.ProfileType == "googleplus")
                {

                }

            }
            return ds;
        }
Пример #15
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["LoggedUser"] == null)
                Response.Redirect("/Login.aspx");

            if (!IsPostBack)
            {
                User user = (User)Session["LoggedUser"];
                profiles.InnerText = "Connected To "+user.UserName+ "";

                #region Home
                SocialProfilesRepository socioprofilerepo = new SocialProfilesRepository();
                List<SocialProfile> lstsocio = socioprofilerepo.getAllSocialProfilesOfUser(user.Id);
                usedAccount.InnerHtml = lstsocio.Count + " of 20";
                #endregion

                #region Team

                try
                {

                    //GroupRepository grouprepo = new GroupRepository();
                    //string groupsofhome = string.Empty;
                    //List<Groups> lstgroups = grouprepo.getAllGroups(user.Id);

                }
                catch
                {
                }

                #endregion

                #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);
                }
                #endregion

                try
                {
                    decimal malecount = 0, femalecount = 0, cnt = 0;

                    FacebookStatsRepository objfbStatsRepo = new FacebookStatsRepository();
                    double daysSub = (DateTime.Now - user.CreateDate).TotalDays;
                    int userdays = (int)daysSub;
                    ArrayList arrFbStats = objfbStatsRepo.getAllFacebookStatsOfUser(user.Id, userdays);
                    Random rNum = new Random();
                    foreach (FacebookStats item in arrFbStats)
                    {
                        cnt += item.FemaleCount + item.MaleCount;
                        malecount += item.MaleCount;
                        femalecount += item.FemaleCount;
                    }
                    try
                    {
                        decimal mc = (malecount / cnt) * 100;
                        male = Convert.ToInt16(mc);
                    }
                    catch (Exception Err)
                    {
                        Console.Write(Err.StackTrace);
                    }
                    try
                    {
                        decimal fc = (femalecount / cnt) * 100;
                        female = Convert.ToInt16(fc);
                    }
                    catch (Exception Err)
                    {
                        Console.Write(Err.StackTrace);
                    }
                    twtmale = rNum.Next(100);
                    twtfemale = 100 - twtmale;
                    Session["twtGender"] = male + "," + female;
                }
                catch (Exception Err)
                {
                    Console.Write(Err.Message.ToString());
                }
                getgrphData();

                getNewFriends(7);
                getNewFollowers(7);
            }
        }
Пример #16
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                try
                {
                    if (Session["LoggedUser"] == null)
                    {
                        Response.Redirect("/Default.aspx");
                        return;
                    }

                    SocioBoard.Domain.User user = (User)Session["LoggedUser"];
                    SocialProfilesRepository objSocioRepo = new SocialProfilesRepository();
                    profileName.InnerHtml = user.UserName;
                    if(user.ProfileUrl!=null)
                        profileImg.Src= user.ProfileUrl;
                    else
                        profileImg.Src="~/Contents/img/blank_user.png";
                    try
                    {
                        if (Session["IncomingTasks"] != null)
                        {
                            incom_tasks.InnerHtml = "You have " + Convert.ToString((int)Session["IncomingTasks"]) + " Tasks";
                           // incom_tasks.InnerHtml = Convert.ToString((int)Session["IncomingTasks"]);
                        }
                        else
                        {
                            TaskRepository taskRepo = new TaskRepository();
                            ArrayList alst = taskRepo.getAllIncompleteTasksOfUser(user.Id);
                            incom_tasks.InnerHtml = "You have " + alst.Count + " Tasks";
                            Session["IncomingTasks"] = alst.Count;
                        }
                    }
                    catch (Exception es)
                    {
                        logger.Error(es.Message);
                        Console.WriteLine(es.Message);
                    }
                    try
                    {
                        if (Session["CountMessages"] != null)
                        {
                            incom_messages.InnerHtml = "You have " +  Convert.ToString((int)Session["CountMessages"]) + " Messages";
                            //incomMessages.InnerHtml = Convert.ToString((int)Session["CountMessages"]);
                        }
                        else
                        {
                            incom_messages.InnerHtml = "You have 0 Messages";
                           // incomMessages.InnerHtml = "0";
                        }
                    }
                    catch (Exception sx)
                    {
                        logger.Error(sx.Message);
                        Console.WriteLine(sx.Message);
                    }

                    #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 Count Used Accounts
                    try
                    {
                        if (user.AccountType.ToString().ToLower() == AccountType.Deluxe.ToString().ToLower())
                            tot_acc = 20;
                        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 = 50;
                        profileCount = objSocioRepo.getAllSocialProfilesOfUser(user.Id).Count;
                        Session["ProfileCount"] = profileCount;
                        Session["TotalAccount"] = tot_acc;
                        usedAccount.InnerHtml = " using " + profileCount + " of " + tot_acc;
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex.StackTrace);
                    }
                    #endregion
                }
                catch (Exception ex)
                {
                }
            }
        }