public string ScheduleLinkedinGroupMessage(string scheduledmsgguid, string Userid, string profileid) { string str = string.Empty; try { LinkedInAccount linkacc; string authLink = string.Empty; LinkedInAccountRepository linkedinAccRepo = new LinkedInAccountRepository(); objScheduledMessage = objScheduledMessageRepository.GetScheduledMessageDetails(Guid.Parse(scheduledmsgguid)); GroupScheduleMessageRepository grpschedulemessagerepo = new GroupScheduleMessageRepository(); Domain.Myfashion.Domain.GroupScheduleMessage _GroupScheduleMessage = grpschedulemessagerepo.GetScheduleMessageId(objScheduledMessage.Id); if (linkedinAccRepo.checkLinkedinUserExists(profileid, Guid.Parse(Userid))) { linkacc = linkedinAccRepo.getUserInformation(Guid.Parse(Userid), profileid); } else { linkacc = linkedinAccRepo.getUserInformation(profileid); } oAuthLinkedIn oauthlin = new oAuthLinkedIn(); oauthlin.ConsumerKey = ConfigurationManager.AppSettings["LiApiKey"]; oauthlin.ConsumerSecret = ConfigurationManager.AppSettings["LiSecretKey"]; oauthlin.FirstName = linkacc.LinkedinUserName; oauthlin.Id = linkacc.LinkedinUserId; oauthlin.Token = linkacc.OAuthToken; oauthlin.TokenSecret = linkacc.OAuthSecret; oauthlin.Verifier = linkacc.OAuthVerifier; string imgurl = objScheduledMessage.PicUrl; string text = objScheduledMessage.ShareMessage; string[] arrtext = null; try { arrtext = System.Text.RegularExpressions.Regex.Split(text, "$%^_^%$"); if (arrtext.Count() == 1) { arrtext = null; arrtext = text.Split(new string[] { "$%^_^%$" }, StringSplitOptions.None); } } catch (Exception ex) { return("somthing went wrong"); } string Title = arrtext[0]; string Message = arrtext[1]; string response = string.Empty; if (linkacc != null) { try { if (string.IsNullOrEmpty(objScheduledMessage.ShareMessage) && string.IsNullOrEmpty(objScheduledMessage.PicUrl)) { str = "There is no data in Share Message !"; } else { SocialStream sociostream = new SocialStream(); if (!string.IsNullOrEmpty(imgurl)) { imgurl = ConfigurationManager.AppSettings["DomainName"].ToString() + Regex.Split(imgurl, "wwwroot")[1].Replace("\\", "/"); response = sociostream.SetImagePostUpdate(oauthlin, _GroupScheduleMessage.GroupId, Message, Title, imgurl); } else { response = sociostream.SetPostUpdate(oauthlin, _GroupScheduleMessage.GroupId, Message, Title); } } } catch (Exception ex) { } str = "Message post on linkedingroup for Id :" + linkacc.LinkedinUserId + ", Title: " + Title + " and Message: " + Message; ScheduledMessage schmsg = new ScheduledMessage(); schmsg.UpdateScheduledMessageByMsgId(Guid.Parse(scheduledmsgguid)); } } catch (Exception ex) { Console.WriteLine(ex.Message); str = ex.Message; } return(str); }
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); } }