Esempio n. 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);
                }
            }


        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                User user = (User)Session["LoggedUser"];
                #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
                SocioBoard.Domain.Team team = (SocioBoard.Domain.Team)Session["GroupName"];
                BusinessSettingRepository objBsnsSettingRepo = new BusinessSettingRepository();
                SocioBoard.Domain.BusinessSetting objbsns = objBsnsSettingRepo.IsAssignTaskEnable(team.GroupId);
                if (team.UserId == user.Id)
                {
                    GroupRepository objGroupRepo = new GroupRepository();
                    Groups grps = objGroupRepo.getGroupName(team.GroupId);
                    txtBusnName.Text = grps.GroupName;
                    memberName.Text = user.UserName;

                    if (objbsns.AssigningTasks == true)
                    {
                        rbEnableAssignTask.Checked = true;
                        rbDisableAssignTask.Checked = false;
                    }
                    else
                    {
                        rbEnableAssignTask.Checked = false;
                        rbDisableAssignTask.Checked = true;
                    }

                    if (objbsns.TaskNotification == true)
                    {
                        rbEnableTaskNoti.Checked = true;
                        rbDisableTaskNoti.Checked = false;
                    }
                    else
                    {
                        rbEnableTaskNoti.Checked = false;
                        rbDisableTaskNoti.Checked = true;
                    }
                }
                else
                {
                    GroupRepository objGroupRepo = new GroupRepository();
                    Groups grps = objGroupRepo.getGroupName(team.GroupId);
                    txtBusnName.Text = grps.GroupName;
                    memberName.Text = user.UserName;
                    txtBusnName.Enabled = false;
                    btnSubmit.Enabled = false;
                    rbDisableAssignTask.Enabled = false;
                    rbEnableAssignTask.Enabled = false;
                    rbDisableTaskNoti.Enabled = false;
                    rbEnableTaskNoti.Enabled = false;
                    //rbDoNotShowPromt.Enabled = false;
                    //rbShowPromt.Enabled = false;
                    //rbFbTimeLine.Enabled = false;
                    //rbFbWooSuitePhotos.Enabled = false;
                    if (objbsns.AssigningTasks == true)
                    {
                        rbEnableAssignTask.Checked = true;
                        rbDisableAssignTask.Checked = false;
                    }
                    else
                    {
                        rbEnableAssignTask.Checked = false;
                        rbDisableAssignTask.Checked = true;
                    }

                    if (objbsns.TaskNotification == true)
                    {
                        rbEnableTaskNoti.Checked = true;
                        rbDisableTaskNoti.Checked = false;
                    }
                    else
                    {
                        rbEnableTaskNoti.Checked = false;
                        rbDisableTaskNoti.Checked = true;
                    }
                }
            }
        }
Esempio n. 3
0
        protected void btnRegister_Click(object sender, ImageClickEventArgs e)
        {
            Groups groups = new Groups();
            GroupRepository objGroupRepository = new GroupRepository();
            Team teams = new Team();
            TeamRepository objTeamRepository = new TeamRepository();

            try
            {
                Session["login"] = null;
                Registration regpage = new Registration();
                User user = (User)Session["LoggedUser"];

                if (DropDownList1.SelectedValue == "Free" || DropDownList1.SelectedValue == "Standard" || DropDownList1.SelectedValue == "Deluxe" || DropDownList1.SelectedValue == "Premium")
                {

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

                    if (user != null)
                    {
                        user.EmailId = txtEmail.Text;
                        user.UserName = txtFirstName.Text + " " + txtLastName.Text;
                        UserActivation objUserActivation = new UserActivation();
                        UserRepository userrepo = new UserRepository();
                        Coupon objCoupon = new Coupon();
                        CouponRepository objCouponRepository = new CouponRepository();
                        if (userrepo.IsUserExist(user.EmailId))
                        {

                            try
                            {
                                string acctype = string.Empty;
                                if (Request.QueryString["type"] != null)
                                {
                                    if (Request.QueryString["type"] == "INDIVIDUAL" || Request.QueryString["type"] == "CORPORATION" || Request.QueryString["type"] == "SMALL BUSINESS")
                                    {
                                        acctype = Request.QueryString["type"];
                                    }
                                    else
                                    {
                                        acctype = "INDIVIDUAL";
                                    }
                                }
                                else
                                {
                                    acctype = "INDIVIDUAL";
                                }

                                user.AccountType = Request.QueryString["type"];
                            }
                            catch (Exception ex)
                            {
                                logger.Error(ex.StackTrace);
                                Console.WriteLine(ex.StackTrace);
                            }

                            user.AccountType = DropDownList1.SelectedValue.ToString();
                            if (string.IsNullOrEmpty(user.AccountType))
                            {
                                user.AccountType = AccountType.Free.ToString();
                            }

                            if (string.IsNullOrEmpty(user.Password))
                            {
                                user.Password = regpage.MD5Hash(txtPassword.Text);
                                // userrepo.UpdatePassword(user.EmailId, user.Password, user.Id, user.UserName, user.AccountType);
                                string couponcode = TextBox1.Text.Trim();
                                userrepo.SetUserByUserId(user.EmailId, user.Password, user.Id, user.UserName, user.AccountType, couponcode);

                                try
                                {
                                    if (TextBox1.Text.Trim() != "")
                                    {
                                        objCoupon.CouponCode = TextBox1.Text.Trim();
                                        List<Coupon> lstCoupon = objCouponRepository.GetCouponByCouponCode(objCoupon);
                                        objCoupon.Id = lstCoupon[0].Id;
                                        objCoupon.EntryCouponDate = lstCoupon[0].EntryCouponDate;
                                        objCoupon.ExpCouponDate = lstCoupon[0].ExpCouponDate;
                                        objCoupon.Status = "1";
                                        objCouponRepository.SetCouponById(objCoupon);
                                    }
                                }
                                catch (Exception ex)
                                {
                                    Console.WriteLine(ex.Message);
                                    logger.Error("Error : " + ex.Message);
                                    logger.Error("Error : " + ex.StackTrace);
                                }

                                //add userActivation

                                try
                                {
                                    objUserActivation.Id = Guid.NewGuid();
                                    objUserActivation.UserId = user.Id;
                                    objUserActivation.ActivationStatus = "0";
                                    UserActivationRepository.Add(objUserActivation);
                                }
                                catch (Exception ex)
                                {
                                    Console.WriteLine(ex.Message);
                                    logger.Error("Error : " + ex.Message);
                                    logger.Error("Error : " + ex.StackTrace);
                                }

                                //add package start

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

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

                                    objUserPackageRelationRepository.AddUserPackageRelation(objUserPackageRelation);

                                    //end package

                                    MailSender.SendEMail(txtFirstName.Text + " " + txtLastName.Text, txtPassword.Text, txtEmail.Text, user.AccountType.ToString(), user.Id.ToString());

                                }
                                catch (Exception ex)
                                {
                                    Console.WriteLine(ex.Message);
                                    logger.Error("Error : " + ex.Message);
                                    logger.Error("Error : " + ex.StackTrace);
                                }

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

                                    objGroupRepository.AddGroup(groups);

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

                                    BusinessSettingRepository busnrepo = new BusinessSettingRepository();
                                    //SocioBoard.Domain.Team team = (SocioBoard.Domain.Team)Session["GroupName"];
                                    SocioBoard.Domain.BusinessSetting objbsnssetting = new SocioBoard.Domain.BusinessSetting();

                                    if (!busnrepo.checkBusinessExists(user.Id, groups.GroupName))
                                    {
                                        objbsnssetting.Id = Guid.NewGuid();
                                        objbsnssetting.BusinessName = groups.GroupName;
                                        //objbsnssetting.GroupId = team.GroupId;
                                        objbsnssetting.GroupId = groups.Id;
                                        objbsnssetting.AssigningTasks = false;
                                        objbsnssetting.AssigningTasks = false;
                                        objbsnssetting.TaskNotification = false;
                                        objbsnssetting.TaskNotification = false;
                                        objbsnssetting.FbPhotoUpload = 0;
                                        objbsnssetting.UserId = user.Id;
                                        objbsnssetting.EntryDate = DateTime.Now;
                                        busnrepo.AddBusinessSetting(objbsnssetting);

                                    }

                                }
                                catch (Exception ex)
                                {
                                    Console.WriteLine(ex.Message);
                                    logger.Error("Error : " + ex.Message);
                                    logger.Error("Error : " + ex.StackTrace);
                                }

                            }
                        }
                        Session["LoggedUser"] = user;

                        Response.Redirect("Home.aspx");
                    }
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Please select Account Type!');", true);
                }
            }
            catch (Exception ex)
            {

                logger.Error(ex.StackTrace);
                Console.WriteLine(ex.StackTrace);
            }
        }
 protected void btnSubmit_Click(object sender, EventArgs e)
 {
     User user = (User)Session["LoggedUser"];
     SocioBoard.Domain.Team team = (SocioBoard.Domain.Team)Session["GroupName"];
     SocioBoard.Domain.BusinessSetting objbsnssetting = new SocioBoard.Domain.BusinessSetting();
     SocioBoard.Model.BusinessSettingRepository objbsnsrepo = new BusinessSettingRepository();
     objbsnssetting.Id = Guid.NewGuid();
     objbsnssetting.BusinessName = txtBusnName.Text;
     objbsnssetting.GroupId = team.GroupId;
     if(rbDisableAssignTask.Checked)
     {
         objbsnssetting.AssigningTasks = false;
     }
     if (rbEnableAssignTask.Checked)
     {
         objbsnssetting.AssigningTasks = true;
     }
     if (rbDisableTaskNoti.Checked)
     {
         objbsnssetting.TaskNotification = false;
     }
     if(rbEnableTaskNoti.Checked)
     {
         objbsnssetting.TaskNotification = true;
     }
     objbsnssetting.FbPhotoUpload=0;
     objbsnssetting.UserId = user.Id;
     objbsnssetting.EntryDate = DateTime.Now;
     objbsnsrepo.AddBusinessSetting(objbsnssetting);
     
 }
        public void ProcessRequest()
        {
           TeamRepository objTeamRepository = new TeamRepository();
           TeamMemberProfileRepository objTeamMemberProfileRepository=new TeamMemberProfileRepository();
           FacebookAccountRepository fbaccountrepo = new FacebookAccountRepository();
           TwitterAccountRepository twtaccountrepo = new TwitterAccountRepository();
           LinkedInAccountRepository linkedaccrepo = new LinkedInAccountRepository();
           InstagramAccountRepository instagramrepo = new InstagramAccountRepository();
           GroupProfileRepository groupprofilerepo = new GroupProfileRepository();
           BusinessSettingRepository objbsnsrepo = new BusinessSettingRepository();
           TumblrAccountRepository tumblrrepo = new TumblrAccountRepository();





            User user = (User)Session["LoggedUser"];
            if (Request.QueryString["op"] != null)
            {

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

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



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

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

                }
                else if (Request.QueryString["op"] == "deleteGroupName")
                {
                    Guid groupid = Guid.Parse(Request.QueryString["groupId"]);
                 
                    GroupRepository grouprepo = new GroupRepository();
                    grouprepo.DeleteGroup(groupid);                  
                    int count = groupprofilerepo.DeleteAllGroupProfile(groupid);
                    int cnt = objbsnsrepo.DeleteBusinessSettingByUserid(groupid);

                    List<Team> objTeamId = objTeamRepository.getAllDetailsUserEmail(groupid);
                    foreach (Team item in objTeamId)
                    {
                        int deteleTeamMember = objTeamMemberProfileRepository.deleteTeamMember(item.Id);
                        
                    }
                    int deleteTeam = objTeamRepository.deleteGroupRelatedTeam(groupid);

                }
                else if (Request.QueryString["op"] == "addProfilestoGroup")
                {
                    string network = Request.QueryString["network"];
                    string id = Request.QueryString["profileid"];
                    Guid groupid = (Guid)Session["GroupId"];
                    GroupProfile groupprofile = new GroupProfile();
                    groupprofile.EntryDate = DateTime.Now;
                    groupprofile.GroupId = groupid;
                    groupprofile.Id = Guid.NewGuid();
                    groupprofile.ProfileId = id;
                    groupprofile.ProfileType = network;
                    groupprofile.GroupOwnerId = user.Id;

                    GroupProfileRepository grouprepo = new GroupProfileRepository();

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

                    Response.Write(groupid);

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

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

                    try
                    {
                        string gp = Request.QueryString["groupId"];
                        Guid GroupId = Guid.Parse(gp);
                       // TeamRepository objTeamRepository = new TeamRepository();
                        List<Team> objTeam = objTeamRepository.getAllDetailsUserEmail(GroupId);
                      
                        if (objTeam.Count != 0)
                        {
                            foreach (Team item in objTeam)
                            {
                                UserRepository objUserRepository = new UserRepository();
                                User ObjUserDetails = objUserRepository.getUserInfoByEmail(item.EmailId);
                                if (ObjUserDetails != null)
                                {
                                    if (string.IsNullOrEmpty(ObjUserDetails.ProfileUrl))
                                    {
                                        profileimgurl = "../../Contents/img/blank_img.png";
                                    }
                                    else
                                    {
                                        profileimgurl = ObjUserDetails.ProfileUrl;
                                    }

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

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

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

                    }
                }

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

                        }
                    }
                }

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

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

                    List<TeamMemberProfile> objTeamMemProfile = objTeamMemberProfileRepository.getAllTeamMemberProfilesOfTeam(teamdata.Id);
                    try
                    {
                        foreach (TeamMemberProfile item in objTeamMemProfile)
                        {
                            if (item.ProfileType == "facebook")
                            {

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

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

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

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

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

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

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

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



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

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

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





                        }
                    }
                    catch (Exception ex)
                    {

                        Console.WriteLine(ex.StackTrace);
                    }

                    Response.Write(bindprofiles);

                }


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

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

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

                        Console.WriteLine(ex.StackTrace);
                    }                  
                }                    
            }
        }
Esempio n. 6
0
        void ProcessRequest()
        { 
            SocioBoard.Domain.Team team = (SocioBoard.Domain.Team)Session["GroupName"];
            TeamMemberProfileRepository objTeamMemberProfileRepository = new TeamMemberProfileRepository();
            TwitterAccountRepository twtaccountrepo = new TwitterAccountRepository();
            FacebookAccountRepository facerepo = new FacebookAccountRepository();
            LinkedInAccountRepository linkrepo = new LinkedInAccountRepository();
            clsFeedsAndMessages clsfeedsandmess = new clsFeedsAndMessages();    

            try
            {
                User user = (User)Session["LoggedUser"];
                if (Request.QueryString["op"] != null)
                {
                    

                    //if (Request.QueryString["op"] == "bindMessages")
                    //{
                    //    DataSet ds = null;
                    //    //if (Session["MessageDataTable"] == null)
                    //    //{
                    //        clsFeedsAndMessages clsfeedsandmess = new clsFeedsAndMessages();
                    //        ds = clsfeedsandmess.bindMessagesIntoDataTable(team.Id);
                    //        FacebookFeedRepository fbFeedRepo = new FacebookFeedRepository();
                    //        Session["MessageDataTable"] = ds;
                    //    //}
                    //    //else
                    //    //{
                    //        ds = (DataSet)Session["MessageDataTable"];
                    //  //  }
                    //    string message = this.BindData(ds.Tables[0]);

                    //    if (string.IsNullOrEmpty(message))
                    //    {
                    //        message = "Sorry no data !";
                    //    }

                    //    Response.Write(message);

                    //}


                    string[] profid = null;


                    if (Request.QueryString["op"] == "bindMessages")
                    {
                        try
                        {
                            string message = string.Empty;


                            try
                            {
                                profid = Request.QueryString["profileid[]"].Split(',');
                                if (Request.QueryString["type"] != null)
                                {
                                    Session["countMesageDataTable_" + profid] = null;
                                }



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

                            string facebook = string.Empty;

                            foreach (var item in profid)
                            {
                                if (string.IsNullOrEmpty(item))
                                {
                                    facebook = "emptyprofile";
                                }
                                else
                                {
                                    facebook = "profile";
                                }
                            }

                            if (facebook == "emptyprofile")
                            {
                                try
                                {
                                    DataSet ds = null;
                                    Session["countMesageDataTable_" + profid] = null;
                                    ds = clsfeedsandmess.bindMessagesIntoDataTable(team.Id);
                                    FacebookFeedRepository fbFeedRepo = new FacebookFeedRepository();
                                    Session["MessageDataTable"] = ds;

                                    ds = (DataSet)Session["MessageDataTable"];

                                    if (Session["countMessageDataTable"] == null)
                                    {
                                        Session["countMessageDataTable"] = 0;
                                    }
                                    int noOfDataToSkip = (int)Session["countMessageDataTable"];
                                    DataTable records = ds.Tables[0].Rows.Cast<System.Data.DataRow>().Skip(noOfDataToSkip).Take(noOfDataToSkip + 15).CopyToDataTable();
                                    Session["countMessageDataTable"] = noOfDataToSkip + 15;
                                    message = this.BindData(records);//this.BindData(ds.Tables[0]); 
                                }
                                catch (Exception ex)
                                {
                                    Console.WriteLine(ex.StackTrace);
                                }
                            }

                            else
                            {
                                try
                                {
                                    DataSet ds = null;
                                    Session["countMessageDataTable"] = null;

                                    ds = clsfeedsandmess.bindFeedMessageIntoDataTable(profid);
                                    Session["MessageDataTable"] = ds;

                                    ds = (DataSet)Session["MessageDataTable"];



                                    if (Session["countMesageDataTable_" + profid] == null)
                                    {
                                        Session["countMesageDataTable_" + profid] = 0;
                                    }

                                    int noOfDataToSkip = (int)Session["countMesageDataTable_" + profid];

                                 
                                    DataTable records = ds.Tables[0].Rows.Cast<System.Data.DataRow>().Skip(noOfDataToSkip).Take(noOfDataToSkip + 15).CopyToDataTable();
                                    Session["countMesageDataTable_" + profid] = noOfDataToSkip + 15;
                                    message = this.BindData(records);

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

                            if (string.IsNullOrEmpty(message))
                            {
                               
                            }

                            Response.Write(message);

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




                    else if (Request.QueryString["op"] == "inbox_messages")
                    {
                        DataSet ds = null;
                        if (Session["InboxMessages"] == null)
                        {
                            clsFeedsAndMessages clsfeedsandmessages = new clsFeedsAndMessages();
                            ds = clsfeedsandmessages.bindSentMessagesToDataTable(user, "");
                            Session["InboxMessages"] = ds;
                        }
                        else
                        {
                            ds = (DataSet)Session["InboxMessages"];
                        }
                        string message = this.BindData(ds.Tables[0]);
                        Response.Write(message);

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

                        string profiles = string.Empty;
                        int i = 0;
                       // profiles += "<ul class=\"options_list\">";
                        profiles += "<ul >";
                        /*Binding facebook profiles in Accordian*/
                       
                        List<TeamMemberProfile> alstprofiles = objTeamMemberProfileRepository.getAllTeamMemberProfilesOfTeam(team.Id);
                        foreach (TeamMemberProfile item in alstprofiles)
                        {
                            if (item.ProfileType == "facebook")
                            {
                                
                                FacebookAccount alstfacebookprofiles = facerepo.getUserDetails(item.ProfileId);
                                try
                                {
                                   // profiles += "<ul><li><a id=\"checkimg_" + i + "\" href=\"#\" onclick=\"checkprofile('checkimg_" + i + "','" + alstfacebookprofiles.FbUserId + "','message','facebook');\"><img src=\"../Contents/img/admin/fbicon.png\"  width=\"15\" height=\"15\" alt=\"\" >" + alstfacebookprofiles.FbUserName + "</a></li>";

                                    profiles += "<li class=\"messagetype\"><a href=\"#\"><img src=\"../Contents/img/admin/fbicon.png\"  width=\"15\" height=\"15\" alt=\"\"/>" + alstfacebookprofiles.FbUserName + "</a>" +
                                             "<img onclick=\"chkProfilemessage(this.id);\" id=\"fb_" + alstfacebookprofiles.FbUserId + "\" src=\"../Contents/img/uncheck_click.png\" alt=\"\" /></li>";
                                    
                                    
                                    i++;
                                }
                                catch (Exception ex)
                                {
                                    logger.Error(ex.Message);
                                    Console.WriteLine(ex.Message);
                                }

                            }


                            else if (item.ProfileType == "twitter")
                            {
                               
                                TwitterAccount alsttwt = twtaccountrepo.getUserInformation(item.ProfileId);
                                try
                                {
                                    //profiles += "<ul><li><a href=\"#\" id=\"checkimg_" + i + "\" onclick=\"checkprofile('checkimg_" + i + "','" + alsttwt.TwitterUserId + "','message','twitter');\"><img src=\"../Contents/img/admin/twittericon.png\"  width=\"15\" height=\"15\" alt=\"\" >" + alsttwt.TwitterScreenName + "</a></li>";

                                    profiles += "<li class=\"messagetype\"><a href=\"#\"><img src=\"../Contents/img/admin/twittericon.png\"  width=\"15\" height=\"15\" alt=\"\"/>" + alsttwt.TwitterScreenName + "</a>" +
                                                "<img onclick=\"chkProfilemessage(this.id);\" id=\"twt_" + alsttwt.TwitterUserId + "\" src=\"../Contents/img/uncheck_click.png\" alt=\"\" /></li>";
                                    
                                    i++;
                                }
                                catch (Exception ex)
                                {
                                    logger.Error(ex.Message);
                                    Console.WriteLine(ex.Message);
                                }
                            }
                            else if (item.ProfileType == "google")
                            {
                                GooglePlusAccountRepository gpAccRepo = new GooglePlusAccountRepository();
                                GooglePlusAccount alstgp = gpAccRepo.getUserDetails(item.ProfileId);
                                try
                                {
                                    profiles += "<ul><li><a href=\"#\" id=\"checkimg_" + i + "\" onclick=\"checkprofile('checkimg_" + i + "','" + alstgp.GpUserId + "','message','googleplus');\"><img src=\"../Contents/img/google_plus.png\"  width=\"15\" height=\"15\" alt=\"\" >" + alstgp.GpUserName + "</a></li>";
                                    i++;
                                }
                                catch (Exception esx)
                                {
                                    logger.Error(esx.Message);
                                    Console.WriteLine(esx.Message);
                                }

                            }
                            
                        }
                                                                  
                        profiles += "</ul><input type=\"hidden\" id=\"profilecounter\" value=\"" + i + "\">";
                        Response.Write(profiles);
                    }


                    else if (Request.QueryString["op"] == "changeTaskStatus")
                    {
                        Guid taskid = Guid.Parse(Request.QueryString["taskid"]);
                        bool status = bool.Parse(Request.QueryString["status"]);

                        if (status == true)
                            status = false;
                        else
                            status = true;
                        TaskRepository objTaskRepo = new TaskRepository();
                        objTaskRepo.updateTaskStatus(taskid, user.Id, status);

                    }




                    else if (Request.QueryString["op"] == "savetask")
                    {
                        string descritption = Request.QueryString["description"];
                        //string time = Request.QueryString["now"];

                       Guid idtoassign = Guid.Empty;
                        try
                        {
                            if (Request.QueryString["memberid"] != string.Empty)
                            {
                               idtoassign = Guid.Parse(Request.QueryString["memberid"]);
                            }
                        }
                        catch (Exception ex)
                        {
                            logger.Error(ex.Message);
                            // idtoassign = 0;
                        }
                        Tasks objTask = new Tasks();
                        TaskRepository objTaskRepo = new TaskRepository();
                        objTask.AssignDate = Request.QueryString["now"]; //DateTime.Now.ToString("yyyy-MM-dd H:mm:ss").ToString();
                        objTask.GroupId = team.GroupId;
                        objTask.AssignTaskTo = idtoassign;
                        objTask.TaskStatus = false;
                        objTask.TaskMessage = descritption;
                        objTask.UserId = user.Id;
                        Guid taskid = Guid.NewGuid();
                        objTask.Id = taskid;
                        objTaskRepo.addTask(objTask);

  
                        string comment = Request.QueryString["comment"];
                        if (!string.IsNullOrEmpty(comment))
                        {
                            string curdate = Request.QueryString["now"]; //DateTime.Now.ToString("yyyy-MM-dd H:mm:ss").ToString();
                            TaskComment objcmt = new TaskComment();
                            TaskCommentRepository objcmtRepo = new TaskCommentRepository();
                            objcmt.Comment = comment;
                            objcmt.CommentDate = DateTime.Now;
                            objcmt.EntryDate = DateTime.Now;
                            objcmt.Id = Guid.NewGuid();
                            objcmt.TaskId = objTask.Id;
                            objcmt.UserId = user.Id;
                            objcmtRepo.addTaskComment(objcmt);
                        }

                    }

                    else  if (Request.QueryString["op"] == "bindteam")
                    {
                        TeamRepository objTeam = new TeamRepository();
                        string message = string.Empty;
                        message += "<ul>";

                        //IEnumerable<dynamic> result = objTeam.getAllTeamsOfUser(user.Id,team.GroupId);
                        //IEnumerable<dynamic> result = objTeam.getAllTeamsOfUser(user.Id, team.GroupId);
                        BusinessSettingRepository objBsnsSettingRepo = new BusinessSettingRepository();
                        BusinessSetting objbsns = objBsnsSettingRepo.IsNotificationTaskEnable(team.GroupId);
                        if (objbsns.AssigningTasks == true || team.UserId == user.Id)
                        {
                            IEnumerable<dynamic> result = objTeam.getAllTeamsOfUser(user.Id, team.GroupId, user.EmailId);
                            foreach (Team item in result)
                            {
                                try
                                {
                                    //===========================new code added=========================

                                    UserRepository objUserRepository = new UserRepository();
                                    User objdetails = objUserRepository.getUserInfoByEmail(item.EmailId);
                                    if (objdetails != null)
                                    {
                                        message += "<li><a>";
                                        if (objdetails.ProfileUrl == null)
                                        {
                                            message += "<img src=\"../Contents/img/blank_img.png\" alt=\"\" />";
                                        }
                                        else
                                        {
                                            message += "<img src=\"" + objdetails.ProfileUrl + "\" alt=\"\" />";
                                        }


                                        message += "<span class=\"name\">" +
                                                                 objdetails.UserName +
                                                             "</span>" +
                                                          " <span>" +
                                                          "<input id=\"customerid_" + objdetails.Id + "\" type=\"radio\" name=\"team_members\" value=\"customerid_" + objdetails.Id + "\">" +
                                                          "</span>" +
                                                         "</a></li>";

                                        //message += "<li><a>";
                                    }
                                }
                                catch (Exception ex)
                                {
                                    Console.WriteLine("Error : " + ex.StackTrace);
                                }
                            }

                            //  message += "<li><a>";
                            if (string.IsNullOrEmpty(user.ProfileUrl))
                            {
                                message += "<li><a>";

                                message += "<img src=\"../Contents/img/blank_img.png\" alt=\"\" />";
                            }
                            else
                            {
                                message += "<img src=\"" + user.ProfileUrl + "\" alt=\"\" />";
                            }

                            message += "<span class=\"name\">" +
                                     user.UserName +
                                  "</span>" +
                               " <span>" +
                               "<input id=\"customerid_" + user.Id + "\" type=\"radio\" name=\"team_members\" value=\"customerid_" + user.Id + "\">" +
                               "</span></a></li>";

                        }
                        else
                        {
                            message += "<li><a>";

                            if (string.IsNullOrEmpty(user.ProfileUrl))
                            {

                                message += "<img src=\"../Contents/img/blank_img.png\" alt=\"\" />";
                            }
                            else
                            {
                                message += "<img src=\"" + user.ProfileUrl + "\" alt=\"\" />";
                            }



                            message += "<span class=\"name\">" +
                                                user.UserName +
                                             "</span>" +
                                          " <span>" +
                                          "<input id=\"customerid_" + user.Id + "\" type=\"radio\" name=\"team_members\" value=\"customerid_" + user.Id + "\">" +
                                          "</span>" +
                                         "</a></li>";

                        }
                        message += "</ul>";
                        Response.Write(message);
                    }


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

                       
                        ScheduledMessageRepository objScheduledMessageRepository = new ScheduledMessageRepository();
                    
                        string message = string.Empty;
                     //   message += "<ul  id=\"message-list\">";
                        try
                        {

                            List<TeamMemberProfile> alstprofiles = objTeamMemberProfileRepository.getAllTeamMemberProfilesOfTeam(team.Id);
                            foreach (TeamMemberProfile items in alstprofiles)
                            {
                                List<ScheduledMessage> result = objScheduledMessageRepository.getAllSentMessagesOfUser(items.ProfileId);
                                int sorteddatacount = 0;
                                if (result != null && result.Count > 0)
                                {
                                    foreach (ScheduledMessage item in result)
                                    {
                                        try
                                        {
                                            //message += "<ul  id=\"message-list\">";
                                            //message += "<li>";
                                            sorteddatacount++;
                                            if (item.ProfileType == "twitter")
                                            {
                                                message += "<ul  id=\"message-list\">";
                                                message += "<li>";


                                                TwitterAccountRepository objTwitterAccountRepository = new TwitterAccountRepository();
                                                TwitterAccount objTwitterAccount = objTwitterAccountRepository.getUserInformation(item.ProfileId);
                                                if (string.IsNullOrEmpty(item.PicUrl))
                                                {
                                                    message += "<div id=\"messagetaskable_" + sorteddatacount + "\" class=\"userpictiny\"><div style=\"width:60px;height:60px;float:left\"><img href=\"http://twitter.com/" + objTwitterAccount.TwitterScreenName + "\" target=\"_blank\" id=\"formprofileurl_" + sorteddatacount + "\" src=\"" + objTwitterAccount.ProfileImageUrl + "\" height=\"48\" width=\"48\" alt=\"\" title=\"\" />" +
                                                                 "<a href=\"http://twitter.com/" + objTwitterAccount.TwitterScreenName + "\" target=\"_blank\" class=\"userurlpic\" title=\"\"><img src=\"../Contents/img/twticon.png\" width=\"16\" height=\"16\" alt=\"\"></a></div>" +
                                                                 "</div><div id=\"messagedescription_" + sorteddatacount + "\" class=\"message-list-content\"><div  id=\"msgdescription_" + sorteddatacount + "\" style=\"width:500px;height:auto;float:left\"><p>" + item.ShareMessage + "</p>" +
                                                                     "<div class=\"message-list-info\"><span><a href=\"http://twitter.com/" + objTwitterAccount.TwitterScreenName + "\" target=\"_blank\" id=\"rowname_" + sorteddatacount + "\" >" + objTwitterAccount.TwitterScreenName + "</a> " + item.CreateTime + "</span>" +
                                                                     "<div class=\"scl\">" +
                                                        //"<a id=\"createtasktwt_" + sorteddatacount + "\" href=\"#\" onclick=\"createtask(this.id);\"><img title=\"Task\" src=\"../Contents/img/pin.png\" alt=\"\" width=\"14\" height=\"17\" border=\"none\"></a><a href=\"#\"><img title=\"Comment\" src=\"../Contents/img/admin/goto.png\" width=\"12\" height=\"12\" alt=\"\"/></a></div></div></div></div></li>";
                                                                      "</div></div></div></div></li>";
                                                }
                                                else if(!string.IsNullOrEmpty(item.PicUrl))
                                                {
                                                    string src = item.PicUrl;
                                                    message += "<div id=\"messagetaskable_" + sorteddatacount + "\" class=\"userpictiny\"><div style=\"width:60px;height:60px;float:left\"><img href=\"http://twitter.com/" + objTwitterAccount.TwitterScreenName + "\" target=\"_blank\" id=\"formprofileurl_" + sorteddatacount + "\" src=\"" + objTwitterAccount.ProfileImageUrl + "\" height=\"48\" width=\"48\" alt=\"\" title=\"\" />" +
                                                            "<a href=\"http://twitter.com/" + objTwitterAccount.TwitterScreenName + "\" target=\"_blank\" class=\"userurlpic\" title=\"\"><img src=\"../Contents/img/twticon.png\" width=\"16\" height=\"16\" alt=\"\"></a></div>" +
                                                            "</div><div id=\"messagedescription_" + sorteddatacount + "\" class=\"message-list-content\"><div  id=\"msgdescription_" + sorteddatacount + "\" style=\"width:500px;height:auto;float:left\"><p><img style=\"margin-right:10px;margin-top:10px\" width=\"80px;\" hight=\"80px;\" src=\"" + src + "\">" + item.ShareMessage + "</p>" +
                                                                "<div class=\"message-list-info\"><span><a href=\"http://twitter.com/" + objTwitterAccount.TwitterScreenName + "\" target=\"_blank\" id=\"rowname_" + sorteddatacount + "\" >" + objTwitterAccount.TwitterScreenName + "</a> " + item.CreateTime + "</span>" +
                                                                "<div class=\"scl\">" +
                                                     
                                                                 "</div></div></div></div></li>";
                                                }
                                               



                                                message += "</ul>";


                                            }
                                            else if (item.ProfileType == "facebook")
                                            {
                                                message += "<ul  id=\"message-list\">";
                                                message += "<li>";


                                                FacebookAccountRepository objFacebookAccountRepository = new FacebookAccountRepository();
                                                FacebookAccount objFacebookAccount = objFacebookAccountRepository.getFacebookAccountDetailsById(item.ProfileId);
                                                if (objFacebookAccount != null)
                                                {
                                                    if (string.IsNullOrEmpty(item.PicUrl))
                                                    {
                                                        message += "<div id=\"messagetaskable_" + sorteddatacount + "\" class=\"userpictiny\"><div style=\"width:60px;height:60px;float:left\"><img href=\"http://www.facebook.com/" + objFacebookAccount.FbUserId + "\" target=\"_blank\" id=\"formprofileurl_" + sorteddatacount + "\"  src=\"http://graph.facebook.com/" + objFacebookAccount.FbUserId + "/picture?type=small\" height=\"48\" width=\"48\" alt=\"\" title=\"\" />" +
                                                                    "<a href=\"http://www.facebook.com/" + objFacebookAccount.FbUserId + "\" target=\"_blank\" class=\"userurlpic\" title=\"\"><img src=\"../Contents/img/fb_icon.png\" width=\"16\" height=\"16\" alt=\"\"></a></div>" +
                                                                    "</div><div id=\"messagedescription_" + sorteddatacount + "\" class=\"message-list-content\"><div  id=\"msgdescription_" + sorteddatacount + "\" style=\"width:500px;height:auto;float:left\"><p>" + item.ShareMessage + "</p>" +
                                                                        "<div class=\"message-list-info\"><span><a href=\"http://www.facebook.com/" + objFacebookAccount.FbUserId + "\" target=\"_blank\" id=\"rowname_" + sorteddatacount + "\" >" + objFacebookAccount.FbUserName + "</a> " + item.CreateTime + "</span>" +
                                                                        "<div class=\"scl\">" +
                                                            //"<a id=\"createtasktwt_" + sorteddatacount + "\" href=\"#\" onclick=\"createtask(this.id);\"><img title=\"Task\" src=\"../Contents/img/pin.png\" alt=\"\" width=\"14\" height=\"17\" border=\"none\"></a><a href=\"#\"><img title=\"Comment\" src=\"../Contents/img/admin/goto.png\" width=\"12\" height=\"12\" alt=\"\"/></a></div></div></div></div></li>";
                                                                        "</div></div></div></div></li>";
                                                    }
                                                    else if (!string.IsNullOrEmpty(item.PicUrl))
                                                    {
                                                        string src = item.PicUrl;
                                                        message += "<div id=\"messagetaskable_" + sorteddatacount + "\" class=\"userpictiny\"><div style=\"width:60px;height:60px;float:left\"><img href=\"http://www.facebook.com/" + objFacebookAccount.FbUserId + "\" target=\"_blank\" id=\"formprofileurl_" + sorteddatacount + "\"  src=\"http://graph.facebook.com/" + objFacebookAccount.FbUserId + "/picture?type=small\" height=\"48\" width=\"48\" alt=\"\" title=\"\" />" +
                                                               "<a href=\"http://www.facebook.com/" + objFacebookAccount.FbUserId + "\" target=\"_blank\" class=\"userurlpic\" title=\"\"><img src=\"../Contents/img/fb_icon.png\" width=\"16\" height=\"16\" alt=\"\"></a></div>" +
                                                               "</div><div id=\"messagedescription_" + sorteddatacount + "\" class=\"message-list-content\"><div  id=\"msgdescription_" + sorteddatacount + "\" style=\"width:500px;height:auto;float:left\"><p><img style=\"margin-right:10px;margin-top:10px\" width=\"80px;\" hight=\"80px;\" src=\"" + src + "\">" + item.ShareMessage + "</p>" +
                                                                   "<div class=\"message-list-info\"><span><a href=\"http://www.facebook.com/" + objFacebookAccount.FbUserId + "\" target=\"_blank\" id=\"rowname_" + sorteddatacount + "\" >" + objFacebookAccount.FbUserName + "</a> " + item.CreateTime + "</span>" +
                                                                   "<div class=\"scl\">" +
                                                                   "</div></div></div></div></li>";
                                                    }

                                                    message += "</ul>";


                                                }

                                            }
                                            else if (item.ProfileType == "linkedin")
                                            {
                                                message += "<ul  id=\"message-list\">";
                                                message += "<li>";


                                                LinkedInAccountRepository objLinkedInAccountRepository = new LinkedInAccountRepository();
                                                LinkedInAccount objLinkedInAccount = objLinkedInAccountRepository.getLinkedinAccountDetailsById(item.ProfileId);
                                                if (objLinkedInAccount != null)
                                                {
                                                    if (string.IsNullOrEmpty(item.PicUrl))
                                                    {
                                                        message += "<div id=\"messagetaskable_" + sorteddatacount + "\" class=\"userpictiny\"><div style=\"width:60px;height:60px;float:left\"><img id=\"formprofileurl_" + sorteddatacount + "\"  src=\"" + objLinkedInAccount.ProfileImageUrl + "\" height=\"48\" width=\"48\" alt=\"\" title=\"\" />" +
                                                                    "<span class=\"userurlpic\" title=\"\"><img src=\"../Contents/img/link_icon.png\" width=\"16\" height=\"16\" alt=\"\" ></span></div>" +
                                                                    "</div><div id=\"messagedescription_" + sorteddatacount + "\" class=\"message-list-content\"><div  id=\"msgdescription_" + sorteddatacount + "\" style=\"width:500px;height:auto;float:left\"><p>" + item.ShareMessage + "</p>" +
                                                                        "<div class=\"message-list-info\"><span><a href=\"" + objLinkedInAccount.ProfileUrl + "\" target=\"_blank\" id=\"rowname_" + sorteddatacount + "\" >" + objLinkedInAccount.LinkedinUserName + "</a> " + item.CreateTime + "</span>" +
                                                                        "<div class=\"scl\">" +
                                                            //"<a id=\"createtasktwt_" + sorteddatacount + "\" href=\"#\" onclick=\"createtask(this.id);\"><img title=\"Task\" src=\"../Contents/img/pin.png\" alt=\"\" width=\"14\" height=\"17\" border=\"none\"></a><a href=\"#\"><img title=\"Comment\" src=\"../Contents/img/admin/goto.png\" width=\"12\" height=\"12\" alt=\"\"/></a></div></div></div></div></li>";
                                                                        "</div></div></div></div></li>";
                                                    }
                                                    else if (!string.IsNullOrEmpty(item.PicUrl))
                                                    {
                                                        string src = item.PicUrl;
                                                        message += "<div id=\"messagetaskable_" + sorteddatacount + "\" class=\"userpictiny\"><div style=\"width:60px;height:60px;float:left\"><img id=\"formprofileurl_" + sorteddatacount + "\"  src=\"" + objLinkedInAccount.ProfileImageUrl + "\" height=\"48\" width=\"48\" alt=\"\" title=\"\" />" +
                                                               "<span class=\"userurlpic\" title=\"\"><img src=\"../Contents/img/link_icon.png\" width=\"16\" height=\"16\" alt=\"\" ></span></div>" +
                                                               "</div><div id=\"messagedescription_" + sorteddatacount + "\" class=\"message-list-content\"><div  id=\"msgdescription_" + sorteddatacount + "\" style=\"width:500px;height:auto;float:left\"><p><img style=\"margin-right:10px;margin-top:10px\" width=\"80px;\" hight=\"80px;\" src=\"" + src + "\">" + item.ShareMessage + "</p>" +
                                                                   "<div class=\"message-list-info\"><span><a href=\"" + objLinkedInAccount.ProfileUrl + "\" target=\"_blank\" id=\"rowname_" + sorteddatacount + "\" >" + objLinkedInAccount.LinkedinUserName + "</a> " + item.CreateTime + "</span>" +
                                                                   "<div class=\"scl\">" +
                                                                   "</div></div></div></div></li>";
                                                    }
                                                    message += "</ul>";
                                                }

                                            }
                                        }
                                        catch (Exception ex)
                                        {
                                            Console.WriteLine("Error : " + ex.StackTrace);
                                        }
                                    }

                                   // message += "</ul>";
                                }
                                else
                                {
                                   // message = "Sorry no data !";
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine("Error : " + ex.StackTrace);
                        }
                       
                        Response.Write(message);
                    }
                    else if (Request.QueryString["op"] == "bindarchive")
                    {
                        ArchiveMessageRepository objArchiveRepo = new ArchiveMessageRepository();

                        string message = string.Empty;
                       

                        try
                        {
                            List<TeamMemberProfile> alstprofiles = objTeamMemberProfileRepository.getAllTeamMemberProfilesOfTeam(team.Id);
                            foreach (TeamMemberProfile items in alstprofiles)
                            {
                                List<ArchiveMessage> result = objArchiveRepo.getAllArchiveMessage(items.ProfileId);
                                int sorteddatacount = 0;
                                if (result != null && result.Count > 0)
                                {
                                    foreach (ArchiveMessage item in result)
                                    {
                                        try
                                        {
                                            message += "<ul  id=\"message-list\">";
                                            message += "<li>";
                                            sorteddatacount++;
                                            if (item.SocialGroup == "twitter")
                                            {
                                                message += "<div id=\"messagetaskable_" + sorteddatacount + "\" class=\"userpictiny\"><div style=\"width:60px;height:60px;float:left\"><img id=\"formprofileurl_" + sorteddatacount + "\" onclick=\"detailsdiscoverytwitter(" + item.ProfileId + ");\" src=\"" + item.ImgUrl + "\" height=\"48\" width=\"48\" alt=\"\" title=\"\" />" +
                                                             "<a href=\"#\" class=\"userurlpic\" title=\"\"><img src=\"../Contents/img/twticon.png\" width=\"16\" height=\"16\" alt=\"\" onclick=\"detailsdiscoverytwitter(\"item.ProfileId\");\"></a></div>" +
                                                             "</div><div id=\"messagedescription_" + sorteddatacount + "\" class=\"message-list-content\"><div  id=\"msgdescription_" + sorteddatacount + "\" style=\"width:500px;height:auto;float:left\"><p>" + item.Message + "</p>" +
                                                                 "<div class=\"message-list-info\"><span><a href=\"#\" id=\"rowname_" + sorteddatacount + "\" onclick=\"detailsdiscoverytwitter(" + item.ProfileId + ");\">" + item.UserName + "</a> " + item.CreatedDateTime + "</span>" +
                                                                 "<div class=\"scl\">" +
                                                    // "<a id=\"createtasktwt_" + sorteddatacount + "\" href=\"#\" onclick=\"createtask(this.id);\"><img title=\"Task\" src=\"../Contents/img/pin.png\" alt=\"\" width=\"14\" height=\"17\" border=\"none\"></a><a href=\"#\"><img title=\"Comment\" src=\"../Contents/img/admin/goto.png\" width=\"12\" height=\"12\" alt=\"\"/></a></div></div></div></div></li>";
                                                "<a><img onclick=replyfunction(" + sorteddatacount + ",'twitter','" + item.MessageId + "','" + item.ProfileId + "') title=\"Comment\" src=\"../Contents/img/admin/goto.png\" width=\"12\" height=\"12\" alt=\"\"/></a></div></div></div></div></li>";

                                            }
                                            else if (item.SocialGroup == "facebook")
                                            {
                                                message += "<div id=\"messagetaskable_" + sorteddatacount + "\" class=\"userpictiny\"><div style=\"width:60px;height:60px;float:left\"><img id=\"formprofileurl_" + sorteddatacount + "\" onclick=\"getFacebookProfiles(" + item.ProfileId + ");\" src=\"" + item.ImgUrl + "\" height=\"48\" width=\"48\" alt=\"\" title=\"\" />" +
                                                            "<a href=\"#\" class=\"userurlpic\" title=\"\"><img src=\"../Contents/img/fb_icon.png\" width=\"16\" height=\"16\" alt=\"\" onclick=\"getFacebookProfiles(\"item.ProfileId\");\"></a></div>" +
                                                            "</div><div id=\"messagedescription_" + sorteddatacount + "\" class=\"message-list-content\"><div  id=\"msgdescription_" + sorteddatacount + "\" style=\"width:500px;height:auto;float:left\"><p>" + item.Message + "</p>" +
                                                                "<div class=\"message-list-info\"><span><a href=\"#\" id=\"rowname_" + sorteddatacount + "\" onclick=\"getFacebookProfiles(" + item.ProfileId + ");\">" + item.UserName + "</a> " + item.CreatedDateTime + "</span>" +
                                                                "<div class=\"scl\">" +
                                                                "<a><img onclick=replyfunction(" + sorteddatacount + ",'facebook','" + item.MessageId + "','" + item.ProfileId + "') title=\"Comment\" src=\"../Contents/img/admin/goto.png\" width=\"12\" height=\"12\" alt=\"\"/></a></div></div></div></div></li>";
                                                //"<a id=\"createtasktwt_" + sorteddatacount + "\" href=\"#\" onclick=\"createtask(this.id);\"><img title=\"Task\" src=\"../Contents/img/pin.png\" alt=\"\" width=\"14\" height=\"17\" border=\"none\"></a><a href=\"#\"><img title=\"Comment\" src=\"../Contents/img/admin/goto.png\" width=\"12\" height=\"12\" alt=\"\"/></a></div></div></div></div></li>";


                                            }
                                            else if (item.SocialGroup == "googleplus")
                                            {
                                                message += "<div id=\"messagetaskable_" + sorteddatacount + "\" class=\"userpictiny\"><div style=\"width:60px;height:60px;float:left\"><img id=\"formprofileurl_" + sorteddatacount + "\" onclick=\"detailsprofile(this.alt);\" src=\"" + item.ImgUrl + "\" height=\"48\" width=\"48\" alt=\"\" title=\"\" />" +
                                                            "<a href=\"#\" class=\"userurlpic\" title=\"\"><img src=\"../Contents/img/google_plus.png\" width=\"16\" height=\"16\" alt=\"\" onclick=\"detailsprofile(this.alt);></a></div>" +
                                                            "</div><div id=\"messagedescription_" + sorteddatacount + "\" class=\"message-list-content\"><div  id=\"msgdescription_" + sorteddatacount + "\" style=\"width:500px;height:auto;float:left\"><p>" + item.Message + "</p>" +
                                                                "<div class=\"message-list-info\"><span><a href=\"#\" id=\"rowname_" + sorteddatacount + "\" onclick=\"detailsprofile(" + item.ProfileId + ");\">" + item.ProfileId + "</a> " + item.CreatedDateTime + "</span>" +
                                                                "<div class=\"scl\">" +
                                                                "<a href=\"#\"><img title=\"Comment\" src=\"../Contents/img/admin/goto.png\" width=\"12\" height=\"12\" alt=\"\"/></a></div></div></div></div></li>";
                                                //"<a id=\"createtasktwt_" + sorteddatacount + "\" href=\"#\" onclick=\"createtask(this.id);\"><img title=\"Task\" src=\"../Contents/img/pin.png\" alt=\"\" width=\"14\" height=\"17\" border=\"none\"></a></div></div></div></div></li>";


                                            }
                                            message += "</li>";
                                            message += "</ul>";
                                        }
                                        catch (Exception ex)
                                        {
                                            Console.WriteLine("Error : " + ex.StackTrace);
                                        }
                                    }

                                    //message += "</ul>";
                                }
                                else
                                {
                                  //  message = "Sorry no data !";
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine("Error : " + ex.StackTrace);
                        }
                        Response.Write(message);
                    }
                    else if (Request.QueryString["op"] == "savearchivemsg")
                    {
                        User use = (User)Session["LoggedUser"];
                        ArchiveMessage am = new ArchiveMessage();
                        ArchiveMessageRepository objArchiveRepo = new ArchiveMessageRepository();
                        am.UserId = user.Id;
                        am.ImgUrl = Request.QueryString["imgurl"];
                        //am.user_name = Request.QueryString["UserName"];
                        //am.msg = Request.QueryString["Msg"];
                        ////am.sociel_group = Request.QueryString["Network"];
                        //am.createdtime = Request.QueryString["CreatedTime"];

                        System.IO.StreamReader sr = new System.IO.StreamReader(Request.InputStream);
                        string line = "";
                        line = sr.ReadToEnd();
                        // JObject jo = JObject.Parse("[" + line + "]");
                        // am.UserName = Request.QueryString["UserName"];//Server.UrlDecode((string)jo["UserName"]);
                        //am.Message = Request.QueryString["Msg"];//Server.UrlDecode((string)jo["Msg"]);
                        JObject jo = JObject.Parse(line);
                        am.Message = Server.UrlDecode((string)jo["Msg"]);//Server.UrlDecode((string)jo["Msg"]);
                        am.SocialGroup = Request.QueryString["Network"];// Server.UrlDecode((string)jo["Network"]);
                        am.CreatedDateTime = Convert.ToDateTime(Request.QueryString["CreatedTime"]);
                        am.MessageId = Request.QueryString["MessageId"];
                        am.ProfileId = Request.QueryString["ProfileId"];
                        am.UserName = Request.QueryString["Username"];
                        am.UserId = use.Id;

                        // Server.UrlDecode((string)jo["CreatedTime"]);

                        if (am.UserName != string.Empty)
                        {
                            if (!objArchiveRepo.checkArchiveMessageExists(user.Id, am.MessageId))
                            {
                                objArchiveRepo.AddArchiveMessage(am);
                                Response.Write("Message Archive Successfully");
                            }
                            else
                            {
                                Response.Write("Message Already in Archive");
                            }
                        }
                    }
                    else if (Request.QueryString["op"] == "createfacebookcomments")
                    {
                        //FacebookAccountRepository facerepo = new FacebookAccountRepository();
                        string postid = Request.QueryString["replyid"];
                        string message = Request.QueryString["replytext"];
                        string userid = Request.QueryString["userid"];
                        FacebookAccount result = facerepo.getFacebookAccountDetailsById(userid, user.Id);

                        FacebookClient fc = new FacebookClient(result.AccessToken);
                        Dictionary<string, object> parameters = new Dictionary<string, object>();
                        parameters.Add("message", message);
                        JsonObject dyn = (JsonObject)fc.Post("/" + postid + "/comments", parameters);

                    }
                    else if (Request.QueryString["op"] == "getFacebookComments")
                    {
                       // FacebookAccountRepository facerepo = new FacebookAccountRepository();
                        string postid = Request.QueryString["postid"];
                        string userid = Request.QueryString["userid"];
                        FacebookAccount result = facerepo.getFacebookAccountDetailsById(userid, user.Id);

                        FacebookClient fc = new FacebookClient(result.AccessToken);
                        JsonObject dyn = (JsonObject)fc.Get("/" + postid + "/comments");
                        string mess = string.Empty;
                        dynamic jc = dyn["data"];
                        int iii = 0;
                        foreach (dynamic item in jc)
                        {
                            mess += "<div class=\"messages\"><section><aside><section class=\"js-avatar_tip\" data-sstip_class=\"twt_avatar_tip\">" +
                                    "<a class=\"avatar_link view_profile\">" +
                                    "<img width=\"54\" height=\"54\" border=\"0\" id=\"" + item["id"] + "\" class=\"avatar\" src=\"http://graph.facebook.com/" + item["from"]["id"] + "/picture?type=small\"><article class=\"message-type-icon\"></article>" +
                                     "</a></section><ul></ul></aside><article><div class=\"\"><a class=\"language\" href=\"\"></a></div>" +
                                     "<div class=\"message_actions\"><a class=\"gear_small\" href=\"#\"><span title=\"Options\" class=\"ficon\">?</span></a></div><div id=\"messagedescription_" + iii + "\" class=\"message-text font-14\">" + item["message"] + "</div><section class=\"bubble-meta\"><article class=\"threefourth text-overflow\"><section class=\"floatleft\"><a class=\"js-avatar_tip view_profile profile_link\" data-sstip_class=\"twt_avatar_tip\"><span id=\"rowname_" + iii + "\">" + item["from"]["name"] + "</span></a>&nbsp;<a data-msg-time=\"1363926699000\" class=\"time\" target=\"_blank\" title=\"View message on Twitter\">" + item["created_time"] + "</a><span class=\"location\">&nbsp;</span></section></article><ul class=\"message-buttons quarter clearfix\"></ul></section></article></section></div>";
                        }
                        Response.Write(mess);

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

                        Tweet objTwitterMethod = new Tweet();
                        TwitterAccountRepository objTwtAccRepo = new TwitterAccountRepository();
                        try
                        {
                            string messid = Request.QueryString["messid"];
                            string replytext = Request.QueryString["replytext"];
                            string replyid = Request.QueryString["replyid"];
                            string userid = Request.QueryString["userid"];
                            string username = Request.QueryString["username"];
                            string rowid = Request.QueryString["rowid"];
                            TwitterAccount objTwtAcc = objTwtAccRepo.getUserInformation(user.Id, userid);

                            TwitterHelper twthelper = new TwitterHelper();

                            oAuthTwitter OAuthTwt = new oAuthTwitter();
                            OAuthTwt.AccessToken = objTwtAcc.OAuthToken;
                            OAuthTwt.AccessTokenSecret = objTwtAcc.OAuthSecret;
                            OAuthTwt.TwitterScreenName = objTwtAcc.TwitterScreenName;
                            twthelper.SetCofigDetailsForTwitter(OAuthTwt);
                            Tweet twt = new Tweet();
                            JArray post = twt.Post_Statuses_Update(OAuthTwt, replytext);
                        }
                        catch (Exception ex)
                        {
                            logger.Error(ex.Message);
                        }
                    }
                    else if (Request.QueryString["op"] == "gpProfile")
                    {
                        GooglePlusAccountRepository objgpAccRepo = new GooglePlusAccountRepository();
                        GooglePlusAccount objGpAcc = objgpAccRepo.getGooglePlusAccountDetailsById(Request.QueryString["gpid"].ToString(), user.Id);
                        PeopleController obj = new PeopleController();
                        oAuthToken objgpToken = new oAuthToken();
                        JArray objProfile = null;
                        try
                        {
                            string strAccess = objgpToken.GetAccessToken(objGpAcc.RefreshToken);
                            if (!strAccess.StartsWith("["))
                                strAccess = "[" + strAccess + "]";
                            JArray objArray = JArray.Parse(strAccess);
                            foreach (var itemgp in objArray)
                            {
                                objGpAcc.AccessToken = itemgp["access_token"].ToString();
                            }
                            objProfile = obj.GetPeopleProfile(Request.QueryString["gpid"].ToString(), objGpAcc.AccessToken);
                        }
                        catch (Exception Err)
                        {
                            logger.Error(Err.Message);
                            Console.Write(Err.Message.ToString());
                        }
                        string jas = string.Empty;
                        foreach (var item in objProfile)
                        {
                            jas += "<div class=\"modal-small draggable\">";
                            jas += "<div class=\"modal-content\">";
                            jas += "<button type=\"button\" class=\"modal-btn button b-close\">";
                            jas += "<span class=\"icon close-medium\"><span class=\"visuallyhidden\">X</span></span></button>";
                            jas += "<div class=\"modal-header\"><h3 class=\"modal-title\">Profile summary</h3></div>";
                            jas += "<div class=\"modal-body profile-modal\">";
                            jas += "<div class=\"module profile-card component profile-header\">";
                            jas += "<div style=\"background-image: url('https://pbs.twimg.com/profile_banners/215936249/1371721359');\" class=\"profile-header-inner flex-module clearfix\">";
                            jas += "<div class=\"profile-header-inner-overlay\"></div>";
                            jas += "<a href=\"#\" class=\"profile-picture media-thumbnail js-nav\">";
                            string[] imgurl = item["image"]["url"].ToString().Split('?');
                            jas += "<img src=\"" + imgurl[0] + " alt=\"" + item["name"]["givenName"] + "\" class=\"avatar size73\"></a>";
                            jas += "<div class=\"profile-card-inner\">";
                            jas += "<h1 class=\"fullname editable-group\">";
                            jas += "<a class=\"js-nav\" href=\"#\">" + item["name"]["givenName"] + "</a>";
                            jas += "<a href=\"#\" class=\"verified-link js-tooltip\">";
                            jas += "<span class=\"icon verified verified-large-border\">";
                            jas += "<span class=\"visuallyhidden\"></span></span></a></h1>";
                            jas += "<h2 class=\"username\">";
                            jas += "<a class=\"pretty-link js-nav\" href=\"#\">";
                            jas += "<span class=\"screen-name\"><s></s>" + item["displayName"] + "</span></a></h2>";
                            jas += "<div class=\"bio-container editable-group\"><p class=\"bio profile-field\"></p></div>";
                            jas += "<p class=\"location-and-url\">";
                            jas += "<span class=\"location-container editable-group\">";
                            jas += "<span class=\"location profile-field\"></span></span>";
                            jas += "<span class=\"divider hidden\"></span> ";
                            jas += "<span class=\"url editable-group\">  ";
                            jas += "<span class=\"profile-field\">";
                            jas += "<a target=\"_blank\" rel=\"me nofollow\" href=\"" + item["url"] + "\" title=\"#\">" + item["url"] + " </a></span></span></p>";
                            jas += "<div style=\"cursor: pointer; width: 16px; height: 16px; display: inline-block;\">&nbsp;</div><p></p></div></div>";
                            jas += "<div class=\"clearfix\"><div class=\"default-footer\">";
                            jas += "<div class=\"btn-group\"><div class=\"follow_button\"></div></div></div></div>";
                            jas += "<div class=\"profile-social-proof\">";
                            jas += "<div class=\"follow-bar\"></div></div></div>";
                            jas += "<ol class=\"recent-tweets\"><li class=\"\"><div><i class=\"dogear\"></i></div></li></ol>";
                            jas += "<div class=\"go_to_profile\">";
                            jas += "<small><a class=\"view_profile\" target=\"_blank\" href=\"" + item["url"] + "\">Go to full profile →</a></small></div></div>";
                            jas += "<div class=\"loading\"><span class=\"spinner-bigger\"></span></div></div></div>";
                        }
                        Response.Write(jas);
                    }
                    //else if (Request.QueryString["op"] == "updatedstatus")
                    //{
                    //    try
                    //    {
                    //        TwitterMessageRepository twtmsgRepo = new TwitterMessageRepository();
                    //        int i = twtmsgRepo.updateMessageStatus(user.Id);
                    //        FacebookFeedRepository fbfeedRepo = new FacebookFeedRepository();
                    //        int j = fbfeedRepo.updateMessageStatus(user.Id);

                    //        if (i > 0 || j > 0)
                    //        {
                    //            Session["CountMessages"] = 0;
                    //            Session["MessageDataTable"] = null;


                    //            DataSet ds = null;
                    //            if (Session["MessageDataTable"] == null)
                    //            {
                    //                clsFeedsAndMessages clsfeedsandmess = new clsFeedsAndMessages();
                    //                ds = clsfeedsandmess.bindMessagesIntoDataTable(user);
                    //                FacebookFeedRepository fbFeedRepo = new FacebookFeedRepository();
                    //                Session["MessageDataTable"] = ds;
                    //            }
                    //            else
                    //            {
                    //                ds = (DataSet)Session["MessageDataTable"];
                    //            }
                    //        }


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

                    //    }
                    //}

                    else if (Request.QueryString["op"] == "updatedstatus")
                    {
                        try
                        {
                            int i = 0;
                            int j=0;
                            List<TeamMemberProfile> alstprofiles = objTeamMemberProfileRepository.getAllTeamMemberProfilesOfTeam(team.Id);
                            foreach (TeamMemberProfile item in alstprofiles)
                            {
                                if (item.ProfileType == "twitter")
                                {
                                    TwitterMessageRepository twtmsgRepo = new TwitterMessageRepository();
                                     i = twtmsgRepo.updateMessageStatus(item.ProfileId);
                                }
                                else if (item.ProfileType == "facebook")
                                {
                                    FacebookFeedRepository fbfeedRepo = new FacebookFeedRepository();
                                     j = fbfeedRepo.updateMessageStatus(item.ProfileId);
 
                                }
                            }                         
                          

                            if (i > 0 || j > 0)
                            {
                                Session["CountMessages"] = 0;
                                Session["MessageDataTable"] = null;


                                DataSet ds = null;
                                if (Session["MessageDataTable"] == null)
                                {
                                    //clsFeedsAndMessages clsfeedsandmess = new clsFeedsAndMessages();
                                    ds = clsfeedsandmess.bindMessagesIntoDataTable(team.Id);
                                    FacebookFeedRepository fbFeedRepo = new FacebookFeedRepository();
                                    Session["MessageDataTable"] = ds;
                                }
                                else
                                {
                                    ds = (DataSet)Session["MessageDataTable"];
                                }
                            }


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

                        }
                    }



                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error : " + ex.StackTrace);
            }
        }
        //public void TwitterOAuthRedirect(object sender, EventArgs e)
        //{
        //    User user = (User)Session["LoggedUser"];

        //    oAuthTwitter OAuth = new oAuthTwitter();

        //    if (ddlGroup.SelectedIndex > 0)
        //    {
        //        HiddenFieldGroupNameInDDl.Value = ddlGroup.SelectedItem.Text;

        //        if (!string.IsNullOrEmpty(HiddenFieldGroupNameInDDl.Value))
        //        {
        //            GroupRepository grouprepo = new GroupRepository();
        //            Groups group = grouprepo.getGroupDetails(user.Id, HiddenFieldGroupNameInDDl.Value.ToString());
        //            Session["GroupName"] = group;
        //            TwitterHelper twthelper = new TwitterHelper();
        //            string twtredirecturl = twthelper.TwitterRedirect(ConfigurationManager.AppSettings["consumerKey"], ConfigurationManager.AppSettings["consumerSecret"], ConfigurationManager.AppSettings["callbackurl"]);
        //            Response.Redirect(twtredirecturl);

        //        }
        //    }
        //    else
        //    {
        //        try
        //        {
        //            string txtgroup = Page.Request.Form["txtGroupName"].ToString().Trim();



        //            if (!string.IsNullOrEmpty(txtgroup))
        //            {
        //                GroupRepository grouprepo = new GroupRepository();
        //                Groups group = new Groups();
        //                group.Id = Guid.NewGuid();
        //                group.GroupName = txtgroup;
        //                group.UserId = user.Id;
        //                group.EntryDate = DateTime.Now;
        //                if (!grouprepo.checkGroupExists(user.Id, txtgroup))
        //                {
        //                    grouprepo.AddGroup(group);
        //                    Groups grou = grouprepo.getGroupDetails(user.Id, txtgroup);
        //                    Session["GroupName"] = grou;
        //                }
        //                else
        //                {
        //                    Groups grou = grouprepo.getGroupDetails(user.Id, txtgroup);
        //                    Session["GroupName"] = grou;
        //                }
        //                if (Request["oauth_token"] == null)
        //                {
        //                    Session["UserAndGroupsForTwitter"] = "twitter";
        //                    TwitterHelper twthelper = new TwitterHelper();
        //                    string twtredirecturl = twthelper.TwitterRedirect(ConfigurationManager.AppSettings["consumerKey"], ConfigurationManager.AppSettings["consumerSecret"], ConfigurationManager.AppSettings["callbackurl"]);
        //                    Response.Redirect(twtredirecturl);

        //                }
        //            }
        //            else
        //            {
        //                Response.Write("<script>alert(\"Please fill Group Name\");</script>");
        //            }

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


        //}
        //public void FacebookRedirect(object sender, EventArgs e)
        //{
        //    User user = (User)Session["LoggedUser"];

        //if (ddlGroup.SelectedIndex > 0)
        //{
        //    HiddenFieldGroupNameInDDl.Value = ddlGroup.SelectedItem.Text;
        //    if (!string.IsNullOrEmpty(HiddenFieldGroupNameInDDl.Value))
        //    {
        //        GroupRepository grouprepo = new GroupRepository();
        //        Groups group = grouprepo.getGroupDetails(user.Id, HiddenFieldGroupNameInDDl.Value.ToString());
        //        Session["GroupName"] = group;
        //        Session["UserAndGroupsForFacebook"] = "facebook";
        //        facebook_connect.HRef = "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";
        //        FbOuthForProfile.HRef = facebook_connect.HRef;
        //        Response.Redirect(facebook_connect.HRef);
        //    }
        //}
        //else
        //{
        //    try
        //    {
        //        string txtgroup = Page.Request.Form["txtGroupName"].ToString();

        //        if (!string.IsNullOrEmpty(txtgroup))
        //        {
        //            GroupRepository grouprepo = new GroupRepository();
        //            Groups group = new Groups();
        //            group.Id = Guid.NewGuid();
        //            group.GroupName = txtgroup;
        //            group.UserId = user.Id;
        //            group.EntryDate = DateTime.Now;
        //            if (!grouprepo.checkGroupExists(user.Id, txtgroup))
        //            {
        //                grouprepo.AddGroup(group);
        //                Groups grou = grouprepo.getGroupDetails(user.Id, txtgroup);
        //                Session["GroupName"] = grou;
        //            }
        //            else
        //            {
        //                Groups grou = grouprepo.getGroupDetails(user.Id, txtgroup);
        //                Session["GroupName"] = grou;
        //            }
        //            Session["UserAndGroupsForFacebook"] = "facebook";
        //            facebook_connect.HRef = "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";
        //            FbOuthForProfile.HRef = facebook_connect.HRef;
        //            Response.Redirect(facebook_connect.HRef);

        //        }
        //        else
        //        {
        //            Response.Write("<script>alert(\"Please fill Group Name\");</script>");
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        Console.WriteLine(ex.StackTrace);
        //    }
        //}
        public void CreateGroups(object sender, EventArgs e)
        {
            try
            {
                User user = (User)Session["LoggedUser"];
                string txtgroup = Page.Request.Form["txtGroupName"].ToString().Trim();
                if (!string.IsNullOrEmpty(txtgroup))
                {
                    GroupRepository grouprepo = new GroupRepository();
                    Groups group = new Groups();
                    group.Id = Guid.NewGuid();
                    group.GroupName = txtgroup;
                    group.UserId = user.Id;
                    group.EntryDate = DateTime.Now;
                    if (!grouprepo.checkGroupExists(user.Id, txtgroup))
                    {
                        grouprepo.AddGroup(group);
                        Groups grou = grouprepo.getGroupDetails(user.Id, txtgroup);
                        //Session["GroupName"] = grou;
                    }

                    BusinessSettingRepository busnrepo = new BusinessSettingRepository();
                    //SocioBoard.Domain.Team team = (SocioBoard.Domain.Team)Session["GroupName"];
                    SocioBoard.Domain.BusinessSetting objbsnssetting = new SocioBoard.Domain.BusinessSetting();

                    if (!busnrepo.checkBusinessExists(user.Id, txtgroup))
                    {
                        objbsnssetting.Id = Guid.NewGuid();
                        objbsnssetting.BusinessName = txtgroup;
                        //objbsnssetting.GroupId = team.GroupId;
                        objbsnssetting.GroupId = group.Id;
                        objbsnssetting.AssigningTasks = false;
                        objbsnssetting.AssigningTasks = false;
                        objbsnssetting.TaskNotification = false;
                        objbsnssetting.TaskNotification = false;
                        objbsnssetting.FbPhotoUpload = 0;
                        objbsnssetting.UserId = user.Id;
                        objbsnssetting.EntryDate = DateTime.Now;
                        busnrepo.AddBusinessSetting(objbsnssetting);

                    }                  
                }

                else
                {
                    Response.Write("<script>alert(\"Please fill Group Name\");</script>");
                }

                Response.Redirect("UsersAndGroups.aspx");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
            }
        }
Esempio n. 8
0
        protected void btnRegister_Click(object sender, ImageClickEventArgs e)
        {
            try
            {
                User user = new User();
                UserRepository userrepo = new UserRepository();
                UserActivation objUserActivation = new UserActivation();
                Coupon objCoupon = new Coupon();
                CouponRepository objCouponRepository = new CouponRepository();
                Groups groups = new Groups();
                GroupRepository objGroupRepository = new GroupRepository();
                Team teams = new Team();
                TeamRepository objTeamRepository = new TeamRepository();
           

                SocioBoard.Helper.SessionFactory.configfilepath = Server.MapPath("~/hibernate.cfg.xml");
                try
                {


                    if (DropDownList1.SelectedValue == "Free" || DropDownList1.SelectedValue == "Standard" || DropDownList1.SelectedValue == "Deluxe" || DropDownList1.SelectedValue == "Premium" || DropDownList1.SelectedValue == "SocioBasic" || DropDownList1.SelectedValue == "SocioStandard" || DropDownList1.SelectedValue == "SocioPremium" || DropDownList1.SelectedValue == "SocioDeluxe")

                   
                    {



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




                        if (txtPassword.Text == txtConfirmPassword.Text)
                        {



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


                            user.CreateDate = DateTime.Now;
                            user.ExpiryDate = DateTime.Now.AddDays(30);
                            user.Id = Guid.NewGuid();
                            user.UserName = txtFirstName.Text + " " + txtLastName.Text;
                            user.Password = this.MD5Hash(txtPassword.Text);
                            user.EmailId = txtEmail.Text;
                            user.UserStatus = 1;
                            user.ActivationStatus = "0";
                                                     
                            if (TextBox1.Text.Trim() != "")
                            {
                                user.CouponCode = TextBox1.Text.Trim().ToString();
                            }


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

                               

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


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



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

                                    if (!busnrepo.checkBusinessExists(user.Id, groups.GroupName))
                                    {
                                        objbsnssetting.Id = Guid.NewGuid();
                                        objbsnssetting.BusinessName = groups.GroupName;
                                        objbsnssetting.GroupId = groups.Id;
                                        objbsnssetting.AssigningTasks = false;
                                        objbsnssetting.AssigningTasks = false;
                                        objbsnssetting.TaskNotification = false;
                                        objbsnssetting.TaskNotification = false;
                                        objbsnssetting.FbPhotoUpload = 0;
                                        objbsnssetting.UserId = user.Id;
                                        objbsnssetting.EntryDate = DateTime.Now;
                                        busnrepo.AddBusinessSetting(objbsnssetting);

                                    }
                                                                                                  
                                }
                                catch (Exception ex)
                                {
                                    Console.WriteLine(ex.Message);
                                    logger.Error("Error : " + ex.Message);
                                    logger.Error("Error : " + ex.StackTrace);
                                }


                                try
                                {
                                    logger.Error("1 Request.QueryString[refid]");
                                    if (Request.QueryString["refid"] != null)
                                    {
                                        logger.Error("3 Request.QueryString[refid]");
                                        User UserValid = null;
                                        if (IsUserValid(Request.QueryString["refid"].ToString(), ref UserValid))
                                        {
                                           
                                            logger.Error("Inside IsUserValid");
                                            user.RefereeStatus = "1";
                                            UpdateUserReference(UserValid);
                                            AddUserRefreeRelation(user, UserValid);
                                          
                                            logger.Error("IsUserValid");
                                        }
                                        else
                                        {
                                            user.RefereeStatus = "0";
                                        }
                                    }
                                    logger.Error("2 Request.QueryString[refid]");
                                }
                                catch (Exception ex)
                                {
                                    Console.WriteLine(ex.Message);
                                    logger.Error("btnRegister_Click" + ex.Message);
                                    logger.Error("btnRegister_Click" + ex.StackTrace);
                                }
                              


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

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

                                //add package start

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

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

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

                                //end package

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

                                                if (item.ProfileType == "facebook")
                                                {
                                                    try
                                                    {
                                                        FacebookAccount fbAccount = new FacebookAccount();
                                                        FacebookAccountRepository fbAccountRepo = new FacebookAccountRepository();
                                                        FacebookAccount userAccount = fbAccountRepo.getUserDetails(item.ProfileId);
                                                        fbAccount.AccessToken = userAccount.AccessToken;
                                                        fbAccount.EmailId = userAccount.EmailId;
                                                        fbAccount.FbUserId = item.ProfileId;
                                                        fbAccount.FbUserName = userAccount.FbUserName;
                                                        fbAccount.Friends = userAccount.Friends;
                                                        fbAccount.Id = Guid.NewGuid();
                                                        fbAccount.IsActive = 1;
                                                        fbAccount.ProfileUrl = userAccount.ProfileUrl;
                                                        fbAccount.Type = userAccount.Type;
                                                        fbAccount.UserId = user.Id;
                                                        fbAccountRepo.addFacebookUser(fbAccount);
                                                    }
                                                    catch (Exception ex)
                                                    {
                                                        Console.WriteLine(ex.Message);
                                                        logger.Error(ex.Message);
                                                    }
                                                }
                                                else if (item.ProfileType == "twitter")
                                                {
                                                    try
                                                    {
                                                        TwitterAccount twtAccount = new TwitterAccount();
                                                        TwitterAccountRepository twtAccRepo = new TwitterAccountRepository();
                                                        TwitterAccount twtAcc = twtAccRepo.getUserInfo(item.ProfileId);
                                                        twtAccount.FollowersCount = twtAcc.FollowersCount;
                                                        twtAccount.FollowingCount = twtAcc.FollowingCount;
                                                        twtAccount.Id = Guid.NewGuid();
                                                        twtAccount.IsActive = true;
                                                        twtAccount.OAuthSecret = twtAcc.OAuthSecret;
                                                        twtAccount.OAuthToken = twtAcc.OAuthToken;
                                                        twtAccount.ProfileImageUrl = twtAcc.ProfileImageUrl;
                                                        twtAccount.ProfileUrl = twtAcc.ProfileUrl;
                                                        twtAccount.TwitterName = twtAcc.TwitterName;
                                                        twtAccount.TwitterScreenName = twtAcc.TwitterScreenName;
                                                        twtAccount.TwitterUserId = twtAcc.TwitterUserId;
                                                        twtAccount.UserId = user.Id;
                                                        twtAccRepo.addTwitterkUser(twtAccount);
                                                    }
                                                    catch (Exception ex)
                                                    {
                                                        Console.WriteLine(ex.StackTrace);
                                                        logger.Error(ex.Message);
                                                    }
                                                }
                                                else if (item.ProfileType == "instagram")
                                                {
                                                    try
                                                    {

                                                        InstagramAccount insAccount = new InstagramAccount();
                                                        InstagramAccountRepository insAccRepo = new InstagramAccountRepository();
                                                        InstagramAccount InsAcc = insAccRepo.getInstagramAccountById(item.ProfileId);
                                                        insAccount.AccessToken = InsAcc.AccessToken;
                                                        insAccount.FollowedBy = InsAcc.FollowedBy;
                                                        insAccount.Followers = InsAcc.Followers;
                                                        insAccount.Id = Guid.NewGuid();
                                                        insAccount.InstagramId = item.ProfileId;
                                                        insAccount.InsUserName = InsAcc.InsUserName;
                                                        insAccount.IsActive = true;
                                                        insAccount.ProfileUrl = InsAcc.ProfileUrl;
                                                        insAccount.TotalImages = InsAcc.TotalImages;
                                                        insAccount.UserId = user.Id;
                                                        insAccRepo.addInstagramUser(insAccount);
                                                    }
                                                    catch (Exception ex)
                                                    {
                                                        Console.WriteLine(ex.StackTrace);
                                                        logger.Error(ex.Message);
                                                    }
                                                }
                                                else if (item.ProfileType == "linkedin")
                                                {
                                                    try
                                                    {
                                                        LinkedInAccount linkAccount = new LinkedInAccount();
                                                        LinkedInAccountRepository linkedAccountRepo = new LinkedInAccountRepository();
                                                        LinkedInAccount linkAcc = linkedAccountRepo.getLinkedinAccountDetailsById(item.ProfileId);
                                                        linkAccount.Id = Guid.NewGuid();
                                                        linkAccount.IsActive = true;
                                                        linkAccount.LinkedinUserId = item.ProfileId;
                                                        linkAccount.LinkedinUserName = linkAcc.LinkedinUserName;
                                                        linkAccount.OAuthSecret = linkAcc.OAuthSecret;
                                                        linkAccount.OAuthToken = linkAcc.OAuthToken;
                                                        linkAccount.OAuthVerifier = linkAcc.OAuthVerifier;
                                                        linkAccount.ProfileImageUrl = linkAcc.ProfileImageUrl;
                                                        linkAccount.ProfileUrl = linkAcc.ProfileUrl;
                                                        linkAccount.UserId = user.Id;
                                                        linkedAccountRepo.addLinkedinUser(linkAccount);
                                                    }
                                                    catch (Exception ex)
                                                    {
                                                        Console.WriteLine(ex.StackTrace);
                                                        logger.Error(ex.Message);
                                                    }
                                                }

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

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

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

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


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

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

                Console.WriteLine(ex.StackTrace);
                //Response.Redirect("Home.aspx");
            }
        }