Beispiel #1
0
        public string ADDScheduledMessage(string typeandid, string ShareMessage, DateTime ClientTime, DateTime ScheduleTime, bool Status, string UserId, string PicUrl, DateTime CreateTime)
        {
            try
            {
                Guid          userid    = Guid.Parse(UserId);
                List <string> type      = new List <string>();
                List <string> profileid = new List <string>();
                string[]      TypeandId = typeandid.Split(',');
                for (int i = 0; i < TypeandId.Length; i = i + 2)
                {
                    type.Add(TypeandId[i]);
                    profileid.Add(TypeandId[i + 1]);
                }
                objScheduledMessage = new Domain.Socioboard.Domain.ScheduledMessage();

                try
                {
                    for (int i = 0; i < type.Count; i++)
                    {
                        objScheduledMessage.Id           = Guid.NewGuid();
                        objScheduledMessage.ShareMessage = ShareMessage;
                        objScheduledMessage.ClientTime   = ClientTime;
                        objScheduledMessage.ScheduleTime = ScheduleTime;
                        objScheduledMessage.CreateTime   = CreateTime;
                        objScheduledMessage.Status       = Status;
                        objScheduledMessage.UserId       = userid;
                        objScheduledMessage.ProfileType  = type[i];
                        objScheduledMessage.PicUrl       = PicUrl;
                        objScheduledMessage.ProfileId    = profileid[i];
                        objScheduledMessageRepository.addNewMessage(objScheduledMessage);
                    }
                }
                catch (Exception ex)
                {
                    logger.Error(ex.Message);
                    Console.WriteLine(ex.StackTrace);
                }
                ScheduledMessage objScheduledMessages = new ScheduledMessage();
                return(new JavaScriptSerializer().Serialize(typeandid));
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message);
                Console.WriteLine(ex.StackTrace);
                return(new JavaScriptSerializer().Serialize("Please try Again"));
            }
        }
        public IHttpActionResult LinkedInProfileUpdate(LinkedInManager LinkedInManager)
        {
            oAuthLinkedIn _oauth = new oAuthLinkedIn();
            string        json   = "";

            Domain.Socioboard.Domain.LinkedInAccount _LinkedinAccount = objLinkedInAccountRepository.getLinkedinAccountDetailsById(LinkedInManager.ProfileId);
            try
            {
                _oauth.ConsumerKey = ConfigurationManager.AppSettings["LinkedinApiKey"];
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                logger.Error(ex.Message);
            }

            try
            {
                _oauth.ConsumerSecret = ConfigurationManager.AppSettings["LinkedinSecretKey"];
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                logger.Error(ex.Message);
            }
            _oauth.Token = _LinkedinAccount.OAuthToken;
            string PostUrl = "https://api.linkedin.com/v1/people/~/shares?format=json";

            if (string.IsNullOrEmpty(LinkedInManager.ImageUrl))
            {
                json = _oauth.LinkedProfilePostWebRequest("POST", PostUrl, LinkedInManager.comment);
            }
            else
            {
                string imagepath = ConfigurationManager.AppSettings["DomainName"].ToString() + Regex.Split(LinkedInManager.ImageUrl, "wwwroot")[1].Replace("\\", "/");
                json = _oauth.LinkedProfilePostWebRequestWithImage("POST", PostUrl, LinkedInManager.comment, imagepath);
            }
            #region ScheduledMessage
            if (!string.IsNullOrEmpty(json))
            {
                objScheduledMessage.Id           = Guid.NewGuid();
                objScheduledMessage.PicUrl       = LinkedInManager.ImageUrl;
                objScheduledMessage.ProfileId    = LinkedInManager.ProfileId;
                objScheduledMessage.ProfileType  = "linkedin";
                objScheduledMessage.ScheduleTime = DateTime.Now;
                objScheduledMessage.ShareMessage = LinkedInManager.comment;
                objScheduledMessage.Status       = true;
                objScheduledMessage.UserId       = Guid.Parse(LinkedInManager.UserId);
                objScheduledMessage.CreateTime   = DateTime.Now;
                objScheduledMessage.ClientTime   = DateTime.Now;
                if (!objScheduledMessageRepository.checkMessageExistsAtTime(objScheduledMessage.UserId, objScheduledMessage.ScheduleTime))
                {
                    objScheduledMessageRepository.addNewMessage(objScheduledMessage);
                }
            }
            #endregion
            return(Ok());
        }
Beispiel #3
0
        public string AddComposeMessage(string UserId, string ProfileId, string ProfileType, string Message)
        {
            ScheduledMessageRepository objScheduledMessageRepository = new ScheduledMessageRepository();

            Domain.Socioboard.Domain.ScheduledMessage objScheduledMessage = new Domain.Socioboard.Domain.ScheduledMessage();
            objScheduledMessage.ShareMessage = Message;
            objScheduledMessage.ClientTime   = DateTime.Now;
            objScheduledMessage.ScheduleTime = DateTime.Now;
            objScheduledMessage.CreateTime   = DateTime.Now;
            objScheduledMessage.Status       = true;
            objScheduledMessage.UserId       = Guid.Parse(UserId);
            objScheduledMessage.ProfileType  = ProfileType;
            objScheduledMessage.ProfileId    = ProfileId;
            objScheduledMessageRepository.addNewMessage(objScheduledMessage);
            return("");
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                System.IO.StreamReader       sr;
                Newtonsoft.Json.Linq.JObject jo;

                try
                {
                    if (Request.QueryString["op"].ToString() == "postFBGroupFeeds")
                    {
                        sr = new System.IO.StreamReader(Request.InputStream);
                        string data = "";
                        data = sr.ReadToEnd();
                        jo   = Newtonsoft.Json.Linq.JObject.Parse(data);
                        gid  = Server.UrlDecode((string)jo["gid"]);
                        ack  = Server.UrlDecode((string)jo["ack"]);
                        string msg = Server.UrlDecode((string)jo["msg"]);

                        string res = PostFBGroupFeeds(ack, gid, msg);

                        Response.Write(res);
                        return;
                    }

                    else if (Request.QueryString["op"].ToString() == "postonselectedgroup")
                    {
                        try
                        {
                            logger.Error("cod is here");
                            SocioBoard.Domain.User         user = (SocioBoard.Domain.User)Session["LoggedUser"];
                            ScheduledMessageRepository     objScheduledMessageRepository     = new ScheduledMessageRepository();
                            GroupScheduleMessageRepository objGroupScheduleMEssageRepository = new GroupScheduleMessageRepository();
                            ScheduledMessage     schmessage    = new ScheduledMessage();
                            GroupScheduleMessage grpschmessage = new GroupScheduleMessage();
                            string msg        = string.Empty;
                            string title      = string.Empty;
                            string intrval    = string.Empty;
                            string fbuserid   = string.Empty;
                            string linuserid  = string.Empty;
                            string clienttime = string.Empty;

                            var SelectedGroupId = Request.Form["gid"].ToString().Split(',');
                            title      = Request.Form["title"].ToString();
                            msg        = Request.Form["msg"].ToString();
                            intrval    = Request.Form["intervaltime"].ToString();
                            fbuserid   = Request.Form["fbuserid"].ToString();
                            linuserid  = Request.Form["linuserid"].ToString();
                            clienttime = Request.Form["clienttime"].ToString();
                            string time         = Request.Form["timeforsch"];
                            string date         = Request.Form["dateforsch"];
                            var    files        = Request.Files.Count;
                            var    fi           = Request.Files["files"];
                            string file         = string.Empty;
                            int    intervaltime = 0;
                            intervaltime = Convert.ToInt32(intrval);

                            Session["scheduletime"] = null;



                            string filepath = string.Empty;

                            if (Request.Files.Count > 0)
                            {
                                if (fi != null)
                                {
                                    var path = Server.MapPath("~/Contents/img/upload");


                                    filepath = path + "/" + fi.FileName;
                                    if (!Directory.Exists(path))
                                    {
                                        Directory.CreateDirectory(path);
                                    }
                                    fi.SaveAs(filepath);
                                }
                            }

                            foreach (var item in SelectedGroupId)
                            {
                                string[] networkingwithid = item.Split('_');

                                if (networkingwithid[1] == "lin")
                                {
                                    try
                                    {
                                        string[] arrliusrid = linuserid.Split('_');
                                        string   linkuserid = arrliusrid[1];
                                        string   groupid    = networkingwithid[2];
                                        string   profileid  = networkingwithid[0];

                                        if (intervaltime != 0)
                                        {
                                            if (Session["scheduletime"] == null)
                                            {
                                                string servertime = this.CompareDateWithclient(clienttime, date + " " + time);
                                                schmessage.ScheduleTime = Convert.ToDateTime(servertime);
                                                DateTime d1 = schmessage.ScheduleTime;
                                                DateTime d2 = d1.AddMinutes(intervaltime);
                                                Session["scheduletime"] = d2;
                                            }
                                            else
                                            {
                                                DateTime d1 = (DateTime)Session["scheduletime"];
                                                schmessage.ScheduleTime = d1;
                                                DateTime d2 = d1.AddMinutes(intervaltime);
                                                Session["scheduletime"] = d2;
                                            }
                                        }

                                        SocialStream sociostream = new SocialStream();
                                        string       message     = title + "$%^_^%$" + msg;
                                        schmessage.CreateTime  = DateTime.Now;
                                        schmessage.ProfileType = "linkedingroup";
                                        schmessage.ProfileId   = profileid;
                                        schmessage.Id          = Guid.NewGuid();
                                        if (Request.Files.Count > 0)
                                        {
                                            // schmessage.PicUrl = ConfigurationManager.AppSettings["MailSenderDomain"] + "Contents/img/upload/" + fi.FileName;
                                            var path = System.Configuration.ConfigurationManager.AppSettings["MailSenderDomain"] + "Contents/img/upload";
                                            file = path + "/" + fi.FileName;
                                            schmessage.PicUrl = file;
                                        }
                                        else
                                        {
                                            schmessage.PicUrl = "Null";
                                        }

                                        schmessage.ClientTime   = Convert.ToDateTime(clienttime);
                                        schmessage.ShareMessage = message;;
                                        schmessage.UserId       = user.Id;
                                        schmessage.Status       = false;


                                        logger.Error("cod is befor insert in schedule message");
                                        objScheduledMessageRepository.addNewMessage(schmessage);

                                        grpschmessage.Id = Guid.NewGuid();
                                        grpschmessage.ScheduleMessageId = schmessage.Id;
                                        grpschmessage.GroupId           = groupid;
                                        objGroupScheduleMEssageRepository.addNewGroupMessage(grpschmessage);
                                    }
                                    catch (Exception ex)
                                    {
                                        logger.Error("cod is in exception");
                                        logger.Error(ex.StackTrace);
                                        Console.WriteLine(ex.StackTrace);
                                    }
                                }
                                else if (networkingwithid[1] == "fb")
                                {
                                    try
                                    {
                                        string   facebookgrouppost = string.Empty;
                                        string[] arrfbusrid        = fbuserid.Split('_');
                                        string   acccesstkn        = arrfbusrid[1];
                                        string   groupid           = networkingwithid[2];
                                        string   profileid         = networkingwithid[0];

                                        if (intervaltime != 0)
                                        {
                                            if (Session["scheduletime"] == null)
                                            {
                                                string servertime = this.CompareDateWithclient(clienttime, date + " " + time);
                                                schmessage.ScheduleTime = Convert.ToDateTime(servertime);
                                                DateTime d1 = schmessage.ScheduleTime;
                                                DateTime d2 = d1.AddMinutes(intervaltime);
                                                Session["scheduletime"] = d2;
                                            }
                                            else
                                            {
                                                DateTime d1 = (DateTime)Session["scheduletime"];
                                                schmessage.ScheduleTime = d1;
                                                DateTime d2 = d1.AddMinutes(intervaltime);
                                                Session["scheduletime"] = d2;
                                            }
                                        }
                                        schmessage.CreateTime  = DateTime.Now;
                                        schmessage.ProfileType = "facebookgroup";
                                        schmessage.ProfileId   = profileid;
                                        schmessage.Id          = Guid.NewGuid();
                                        if (Request.Files.Count > 0)
                                        {
                                            // schmessage.PicUrl = ConfigurationManager.AppSettings["MailSenderDomain"] + "Contents/img/upload/" + fi.FileName;
                                            var path = System.Configuration.ConfigurationManager.AppSettings["MailSenderDomain"] + "Contents/img/upload";
                                            file = path + "/" + fi.FileName;
                                            schmessage.PicUrl = file;
                                        }
                                        else
                                        {
                                            schmessage.PicUrl = "Null";
                                        }

                                        schmessage.ClientTime   = Convert.ToDateTime(clienttime);
                                        schmessage.ShareMessage = msg;
                                        schmessage.UserId       = user.Id;
                                        schmessage.Status       = false;
                                        objScheduledMessageRepository.addNewMessage(schmessage);
                                        grpschmessage.Id = Guid.NewGuid();
                                        grpschmessage.ScheduleMessageId = schmessage.Id;
                                        grpschmessage.GroupId           = groupid;
                                        objGroupScheduleMEssageRepository.addNewGroupMessage(grpschmessage);
                                    }
                                    catch (Exception ex)
                                    {
                                        Console.WriteLine(ex.StackTrace);
                                    }
                                }
                            }//End For Each
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }
                        Response.Write("success");
                    }

                    else if (Request.QueryString["op"].ToString() == "getlinkedInGroupDetails")
                    {
                        string GroupData = string.Empty;
                        string picurl    = string.Empty;
                        string summary   = string.Empty;

                        string groupid        = Request.QueryString["groupid"].ToString();
                        string LinkedinUserId = Request.QueryString["linkuserid"].ToString();


                        LinkedInAccount arrLinkedinAccoount = linAccRepo.getLinkedinAccountDetailsById(LinkedinUserId);
                        oAuthLinkedIn   objoAuthLinkedIn    = new oAuthLinkedIn();
                        objoAuthLinkedIn.Token       = arrLinkedinAccoount.OAuthToken;
                        objoAuthLinkedIn.Verifier    = arrLinkedinAccoount.OAuthVerifier;
                        objoAuthLinkedIn.TokenSecret = arrLinkedinAccoount.OAuthSecret;
                        List <GlobusLinkedinLib.App.Core.LinkedInGroup.Group_Updates> lstlinkedinGroup = GetGroupPostDetail(objoAuthLinkedIn, 50, groupid);

                        try
                        {
                            foreach (var item in lstlinkedinGroup)
                            {
                                picurl = "";
                                if (string.IsNullOrEmpty(item.pictureurl))
                                {
                                    picurl = "../../Contents/img/blank_img.png";
                                }
                                else
                                {
                                    picurl = item.pictureurl;
                                }

                                if (string.IsNullOrEmpty(item.summary))
                                {
                                    summary = ".";
                                }
                                else
                                {
                                    summary = item.summary;
                                }

                                GroupData += "<div id=\"abhay\" class=\"storyContent\"><a class=\"actorPhoto\"><img src=\"" + picurl + "\"  alt=\"\" style=\"width:56px;height:56px\"></a>" +
                                             "<div class=\"storyInnerContent\"><div class=\"actordescription\"><a class=\"passiveName\">" + item.firstname + " " + item.lastname + "  -    " + item.headline + "</a></div>" +
                                             "<div class=\"messagebody\"><div style=\"color: black;font-size: large;margin-bottom: 15\">" + Server.HtmlEncode(item.title) + "</div>" + summary + "</div>" +
                                             "</div>" +
                                             "<p style=\"margin-left:60px\">comments(" + item.comments_total + ") likes- " + item.likes_total + "</p><p><span class=\"comment\" onclick=\"FollowPosts('" + groupid + "','" + item.GpPostid + "','" + LinkedinUserId + "','" + item.isFollowing + "')\">" + getfollow(item.isFollowing) + "</span></p>" +
                                             "<p><span class=\"comment\" onclick=\"LikePosts('" + groupid + "','" + item.GpPostid + "','" + LinkedinUserId + "','" + item.isLiked + "')\">" + getlike(item.isLiked) + "</span></p>" +
                                             "<p><span id=\"commentlin_" + item.GpPostid + "\" class=\"comment\" onclick=\"CommentOnPosts('" + item.GpPostid + "')\">Comment</span></p>" +


                                             "<p class=\"commeent_box\"><input id=\"textlin_" + item.GpPostid + "\" type=\"text\" class=\"put_comments\"></p>" +
                                             "<p><span onclick=\"commentLin('" + groupid + "','" + item.GpPostid + "','" + LinkedinUserId + "')\" id=\"oklin_" + item.GpPostid + "\" class=\"ok\">ok</span><span id=\"cancellin_" + item.GpPostid + "\" onclick=\"cancelLin('" + item.GpPostid + "');\" class=\"cancel\"> cancel</span></p>" +



                                             "</div>";
                            }
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }

                        Response.Write(GroupData);
                        return;
                    }



                    else if (Request.QueryString["op"].ToString() == "linkedCommentOnPost")
                    {
                        try
                        {
                            string message        = Request.QueryString["message"].ToString();
                            string groupid        = Request.QueryString["groupid"].ToString();
                            string LinkedinUserId = (Request.QueryString["LinkedinUserId"]);
                            string GpPostid       = (Request.QueryString["GpPostid"]);


                            LinkedInAccount arrLinkedinAccoount = linAccRepo.getLinkedinAccountDetailsById(LinkedinUserId);
                            oAuthLinkedIn   objoAuthLinkedIn    = new oAuthLinkedIn();
                            objoAuthLinkedIn.Token       = arrLinkedinAccoount.OAuthToken;
                            objoAuthLinkedIn.Verifier    = arrLinkedinAccoount.OAuthVerifier;
                            objoAuthLinkedIn.TokenSecret = arrLinkedinAccoount.OAuthSecret;
                            SocialStream sociostream = new SocialStream();
                            string       res         = sociostream.SetCommentOnPost(objoAuthLinkedIn, GpPostid, message);
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }
                    }



                    else if (Request.QueryString["op"].ToString() == "FollowPost")
                    {
                        try
                        {
                            string msg            = string.Empty;
                            string postid         = Request.QueryString["groupid"].ToString();
                            string LinkedinUserId = (Request.QueryString["LinkedinUserId"]);
                            int    isFollowing    = Convert.ToInt16(Request.QueryString["isFollowing"]);

                            if (isFollowing == 1)
                            {
                                msg = "false";
                            }
                            else
                            {
                                msg = "true";
                            }


                            LinkedInAccount arrLinkedinAccoount = linAccRepo.getLinkedinAccountDetailsById(LinkedinUserId);
                            oAuthLinkedIn   objoAuthLinkedIn    = new oAuthLinkedIn();
                            objoAuthLinkedIn.Token       = arrLinkedinAccoount.OAuthToken;
                            objoAuthLinkedIn.Verifier    = arrLinkedinAccoount.OAuthVerifier;
                            objoAuthLinkedIn.TokenSecret = arrLinkedinAccoount.OAuthSecret;


                            SocialStream sociostream = new SocialStream();
                            string       res         = sociostream.SetFollowCountUpdate(objoAuthLinkedIn, postid, msg);
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }
                    }

                    else if (Request.QueryString["op"].ToString() == "postLinkedInGroupFeeds")
                    {
                        string result = "success";
                        try
                        {
                            string          groupid             = Request.QueryString["groupid"].ToString();
                            string          title               = Request.QueryString["title"].ToString();
                            string          LinkedinUserId      = Request.QueryString["LinkedinUserId"].ToString();
                            string          msg                 = Request.QueryString["msg"].ToString();
                            LinkedInAccount arrLinkedinAccoount = linAccRepo.getLinkedinAccountDetailsById(LinkedinUserId);
                            oAuthLinkedIn   objoAuthLinkedIn    = new oAuthLinkedIn();
                            objoAuthLinkedIn.Token       = arrLinkedinAccoount.OAuthToken;
                            objoAuthLinkedIn.Verifier    = arrLinkedinAccoount.OAuthVerifier;
                            objoAuthLinkedIn.TokenSecret = arrLinkedinAccoount.OAuthSecret;

                            SocialStream sociostream = new SocialStream();
                            string       res         = sociostream.SetPostUpdate(objoAuthLinkedIn, groupid, msg, title);
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }

                        Response.Write(result);
                    }

                    else if (Request.QueryString["op"].ToString() == "LikePost")
                    {
                        try
                        {
                            string msg            = string.Empty;
                            string postid         = Request.QueryString["groupid"].ToString();
                            string LinkedinUserId = (Request.QueryString["LinkedinUserId"]);
                            int    isLike         = Convert.ToInt16(Request.QueryString["isLike"]);

                            if (isLike == 1)
                            {
                                msg = "false";
                            }
                            else
                            {
                                msg = "true";
                            }


                            LinkedInAccount arrLinkedinAccoount = linAccRepo.getLinkedinAccountDetailsById(LinkedinUserId);
                            oAuthLinkedIn   objoAuthLinkedIn    = new oAuthLinkedIn();
                            objoAuthLinkedIn.Token       = arrLinkedinAccoount.OAuthToken;
                            objoAuthLinkedIn.Verifier    = arrLinkedinAccoount.OAuthVerifier;
                            objoAuthLinkedIn.TokenSecret = arrLinkedinAccoount.OAuthSecret;


                            SocialStream sociostream = new SocialStream();
                            string       res         = sociostream.SetLikeUpdate(objoAuthLinkedIn, postid, msg);
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.StackTrace);
                        }
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Error : " + ex.StackTrace);
                }

                sr = new System.IO.StreamReader(Request.InputStream);
                string line = "";
                line       = sr.ReadToEnd();
                jo         = Newtonsoft.Json.Linq.JObject.Parse(line);
                gid        = Server.UrlDecode((string)jo["gid"]);
                ack        = Server.UrlDecode((string)jo["ack"]);
                returndata = fgroupfeeds(ack, gid);
                Response.Write(returndata);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error : " + ex.StackTrace);
            }
        }