protected void btnPrint(object sender, EventArgs e) { //Initialize API Core FaceBook oFacebook = new FaceBook(); //Initialize KOKO SonetPie osonetpie = new SonetPie(); osonetpie.QSvarsString = GetQsVarsCollection(); osonetpie.AbsolutePath = AbsolutePagePath; string _sNotifierDID = new AppNotifier().GetNewDIDWithPrefix(); if (QSVars.Contains("NDID")) QSVars["NDID"] = _sNotifierDID; else QSVars.Add("NDID", _sNotifierDID); //Load app settings oDCAppUser = ofbBiz.GetAppUser(osonetpie, QSVars["ADID"].ToString(), QSVars["user_id"].ToString()); oAppProduct = ofbBiz.GetAppProductDetails(osonetpie, QSVars["PDID"].ToString()); Page.ClientScript.RegisterStartupScript(this.GetType(), "myCloseScript", "window.print();", true); ofbBiz.RaiseAppNotifier(oDCAppUser, "PRINT", Convert.ToString(QSVars["UDID"]), Convert.ToString(QSVars["PDID"]), Convert.ToString(QSVars["NDID"])); }
public bool EditAppNotifierDetails(AppNotifier _oAppNotifier) { try { return fbDALC.EditAppNotifierDetails(_oAppNotifier); } catch (Exception ex) { //Log4NetUtility.ErrorDebug(this.GetType().FullName, "Error in DCAppConfiguration GetAppConfiguration()", ex); throw ex; } }
public bool UpdateStatus(string token, string SecretKey) { try { var consumerKey = ConfigurationManager.AppSettings["TwitterConsumerKey"]; var consumerSecret = ConfigurationManager.AppSettings["TwitterConsumerSecret"]; string ADID = Request.QueryString["ADID"]; OAuthTokens accessToken = new OAuthTokens(); accessToken.AccessToken = token; accessToken.AccessTokenSecret = SecretKey; accessToken.ConsumerKey = consumerKey; accessToken.ConsumerSecret = consumerSecret; string postcontent = "Tweeted via " + ofbBiz.GetAppPath(Convert.ToString(Request.QueryString["app_id"])); // string postcontent = "Tweeted via " + ofbBiz.GetAppPath(Convert.ToString(Request.QueryString["app_id"])); TwitterResponse<TwitterStatus> tweetResponse = TwitterStatus.Update(accessToken, postcontent); if (tweetResponse.Result == RequestResult.Success) { //Tweeted Successfully SonetPie osonetpie = new SonetPie(); AppLeadData oAppLeadData = new AppLeadData(); AppProduct dAppproduct = new AppProduct(); dAppproduct = ofbBiz.GetAppProduct(ADID); string PDID = dAppproduct.DID; string _sNotifierDID = new AppNotifier().GetNewDIDWithPrefix(); string NDID = _sNotifierDID; //Load app settings oDCAppUser = ofbBiz.GetAppUser(osonetpie, ADID, SessionData.TwitterData.CachedUserId1); oAppProduct = ofbBiz.GetAppProductDetails(osonetpie, PDID); ofbBiz.RaiseAppNotifier(oDCAppUser, "TWEET", oDCAppUser.DID, PDID, NDID, oAppLeadData, string.Empty); } else { // Something bad happened } return true; } catch (Exception ex) { } return false; }
public bool AddAppNotifierDetails(SonetPie osonetpie, AppNotifier oDCAppNotifier) { try { DatabaseHandler oDBH = new DatabaseHandler(); int i = oDBH.ExecuteNonQuery_SP("AddAppNotifierDetails", oDCAppNotifier.DID, oDCAppNotifier.AppProductDID, oDCAppNotifier.AppUserDID, oDCAppNotifier.SoNetFriendID, oDCAppNotifier.SoNetFriendName, oDCAppNotifier.NotifierType, oDCAppNotifier.NoOfVisits.ToString(), oDCAppNotifier.SoNetEmailID, oDCAppNotifier.SoNetEmailContext, oDCAppNotifier.SoNetEmailContent); if (i < 0) return false; else return true; } catch (Exception ex) { //Log4NetUtility.ErrorDebug(this.GetType().FullName, "Error in GetConfigData(string _AppId)", ex); throw ex; } }
public string GetEmail(string sProductID, string sProductName, string sProductLogo, string sProductDescitpion, string AppID) { StringBuilder oSBShareButton = new StringBuilder(); string _sAppPathLink = fbBiz.GetAppPagePath(AppID); string _sNotifierDID = new AppNotifier().GetNewDIDWithPrefix(); if (!_sAppPathLink.EndsWith("?")) _sAppPathLink += "&"; //Build NotifierDID & pass it to link _sAppPathLink += "NDID=" + _sNotifierDID; oSBShareButton.Append("<a class=\"FB_Email\" href=\"#\" onclick=\"javascript:" + "METHOD" + sProductID + "Email(); return false;\"></a>" + Environment.NewLine); oSBShareButton.Append("<script type=\"text/javascript\">" + Environment.NewLine); oSBShareButton.Append("function " + "METHOD" + sProductID + "Email() {" + Environment.NewLine); oSBShareButton.Append("window.open('" + GetNavigationURL(NotifyURL + "EmailCoupon.aspx?PDID=" + sProductID) + "', 'mywindow', 'height=640,width=1145,menubar=0,toolbar=0,statusbar=0,scrollbars=0,resizable=0,fullscreen=no');" + Environment.NewLine); oSBShareButton.Append("} </script>" + Environment.NewLine); return oSBShareButton.ToString(); }
public string GetLikePlugin(string sProductID, string sProductName, string sProductLogo, string sProductDescitpion, string AppID) { StringBuilder oSBShareButton = new StringBuilder(); int NoOfVisits = ofbBiz.GetLikeCount(sProductID); bool CheckLikeNotify = ofbBiz.CheckLikeNotify(QSVars["UDID"].ToString()); string _sAppPathLink = ofbBiz.GetAppPagePath(AppID); string _sNotifierDID = new AppNotifier().GetNewDIDWithPrefix(); if (!_sAppPathLink.EndsWith("?")) _sAppPathLink += "&"; //Build NotifierDID & pass it to link _sAppPathLink += "NDID=" + _sNotifierDID; string sADID = QSVars["ADID"].ToString(); string suser_id = QSVars["user_id"].ToString(); string sUDiD = QSVars["UDID"].ToString(); //oSBShareButton.Append("<fb:like href=" + _sAppPathLink + " send=\"false\" width=\"450\" show_faces=\"false\"></fb:like>" + Environment.NewLine); oSBShareButton.Append("<button class=\"FB_Like\" id=\"Like\"></button> <div id=\"output\" class=\"SpanLike\">" + NoOfVisits + "</div><div class=\"divLike\">Likes</div>" + Environment.NewLine); // CHeck if user is coming first time else disable LIKE button oSBShareButton.Append("<script type=\"text/javascript\">" + Environment.NewLine); oSBShareButton.Append("$(document).ready(function () {" + Environment.NewLine); oSBShareButton.Append("window.onload = function () {" + Environment.NewLine); if (CheckLikeNotify == true) { oSBShareButton.Append("$(\"#Like\").attr(\"disabled\", \"disabled\");" + Environment.NewLine); oSBShareButton.Append("$(\"#Like\").css({ opacity: 0.5 });" + Environment.NewLine); oSBShareButton.Append("$(\"#Like\").addClass(\"FB_HideLike\");" + Environment.NewLine); } else { oSBShareButton.Append("$('.FB_Like').click(function () {" + Environment.NewLine); oSBShareButton.Append("$.ajax({" + Environment.NewLine); oSBShareButton.Append("url: \"FBNotify.aspx\"," + Environment.NewLine); oSBShareButton.Append("type: \"post\"," + Environment.NewLine); oSBShareButton.Append("data:'PDID=" + sProductID + "&NDID=" + _sNotifierDID + "&ADID=" + sADID + "&user_id=" + suser_id + "&UDID=" + sUDiD + "&NTYP=LIKE', " + Environment.NewLine); // callback handler that will be called on success oSBShareButton.Append("success: function (response, textStatus, jqXHR) {" + Environment.NewLine); // log a message to the console oSBShareButton.Append("AsycRequest('" + GetNavigationURL(NotifyURL + "FBNotify.aspx?NTYP=LIKE&PDID=" + sProductID + "&NDID=" + _sNotifierDID, true) + "');" + Environment.NewLine); //Notifier call to ASYNC function oSBShareButton.Append("}" + Environment.NewLine); oSBShareButton.Append("});" + Environment.NewLine); oSBShareButton.Append("var lb = '';" + Environment.NewLine); oSBShareButton.Append("var int = $('#output').html();" + Environment.NewLine); oSBShareButton.Append("if (lb == '') {" + Environment.NewLine); oSBShareButton.Append("lb = parseInt(int) + 1;" + Environment.NewLine); oSBShareButton.Append("$('#output').html(lb);" + Environment.NewLine); oSBShareButton.Append("$(this).fadeTo(\"fast\", .5);" + Environment.NewLine); oSBShareButton.Append("$(\"#Like\").addClass(\"FB_HideLike\");" + Environment.NewLine); oSBShareButton.Append("jQuery('#Like').attr('disabled', true)" + Environment.NewLine); oSBShareButton.Append("return false;" + Environment.NewLine); oSBShareButton.Append("}" + Environment.NewLine); oSBShareButton.Append("else {" + Environment.NewLine); oSBShareButton.Append("lb = parseInt(lb) + 1;" + Environment.NewLine); oSBShareButton.Append("$('#output').html(lb);" + Environment.NewLine); oSBShareButton.Append("$(this).fadeTo(\"fast\", .5);" + Environment.NewLine); oSBShareButton.Append("$(\"#Like\").addClass(\"FB_HideLike\");" + Environment.NewLine); oSBShareButton.Append("return false;" + Environment.NewLine); oSBShareButton.Append("jQuery('#Like').attr('disabled', true)" + Environment.NewLine); oSBShareButton.Append("}" + Environment.NewLine); oSBShareButton.Append("});" + Environment.NewLine); } oSBShareButton.Append("};" + Environment.NewLine); oSBShareButton.Append("});" + Environment.NewLine); oSBShareButton.Append("</script>" + Environment.NewLine); return oSBShareButton.ToString(); }
public bool EditAppNotifierDetails(AppNotifier oDCAppNotifier) { try { DatabaseHandler oDBH = new DatabaseHandler(); StringBuilder oSBQuery = new StringBuilder(); oDBH.FillData_SP("EditAppNotifierDetails", oDCAppNotifier.DID); return true; } catch (Exception ex) { //Log4NetUtility.ErrorDebug(this.GetType().FullName, "Error in GetConfigData(string _AppId)", ex); throw ex; } }
//For Print,Email public bool RaiseAppNotifier(AppUser oDCAppUser, string NTYP, string UDID, string PDID, string NDID) { //Check Event is sucess or not bool _bSetAppNotifierSuccess = false; try { //Validate NTYP before switching to respective notifier if (string.IsNullOrEmpty(NTYP)) return _bSetAppNotifierSuccess; //Build Post DCAppNotifier AppNotifier _oDCAppNotifier = new AppNotifier(); _oDCAppNotifier.AppUserDID = UDID; _oDCAppNotifier.AppProductDID = PDID; //Check if NDID already defined if so use it if (!string.IsNullOrEmpty(NDID)) _oDCAppNotifier.DID = NDID; else _oDCAppNotifier.DID = _oDCAppNotifier.GetNewDIDWithPrefix(); _oDCAppNotifier.NoOfVisits = 0; //Check which notifier to call based on NTYP switch (NTYP.ToUpper()) { case "PRINT": _oDCAppNotifier.NotifierType = "PRINT"; _bSetAppNotifierSuccess = fbDALC.AddAppNotifierDetails(GetSonetPie, _oDCAppNotifier); break; case "EMAIL": _oDCAppNotifier.NotifierType = "LIKE"; _bSetAppNotifierSuccess = fbDALC.AddAppNotifierDetails(GetSonetPie, _oDCAppNotifier); break; default: _bSetAppNotifierSuccess = false; break; } return _bSetAppNotifierSuccess; } catch (Exception ex) { //Log4NetUtility.ErrorDebug(this.GetType().FullName, "Error in DCAppConfiguration GetAppConfiguration()", ex); throw ex; } }
protected void BtnSubmit_Click(object sender, EventArgs e) { SonetPie osonetpie = new SonetPie(); osonetpie.QSvarsString = GetQsVarsCollection(); osonetpie.AbsolutePath = AbsolutePagePath; string _sNotifierDID = new AppNotifier().GetNewDIDWithPrefix(); if (QSVars.Contains("NDID")) QSVars["NDID"] = _sNotifierDID; else QSVars.Add("NDID", _sNotifierDID); //Load app settings oDCAppUser = ofbBiz.GetAppUser(osonetpie, QSVars["ADID"].ToString(), QSVars["user_id"].ToString()); oAppProduct = ofbBiz.GetAppProductDetails(osonetpie, QSVars["PDID"].ToString()); SendCouponEmail(); Page.ClientScript.RegisterStartupScript(this.GetType(), "myCloseScript", "window.close()", true); ofbBiz.RaiseAppNotifier(oDCAppUser, "EMAIL", Convert.ToString(QSVars["UDID"]), Convert.ToString(QSVars["PDID"]), Convert.ToString(QSVars["NDID"])); }
public string GetTwitterShareURL(string sProductID, string sProductName, string sProductLogo, string sProductDescitpion, string AppID) { string sADID = QSVars["ADID"].ToString(); string suser_id = QSVars["user_id"].ToString(); string sUDiD = QSVars["UDID"].ToString(); string sArticleTitle = "Check out this App!"; string _sAppPathLink = ofbBiz.GetAppPagePath(AppID); string sArticleSource = "http://www.testsonetreach.com";//sAppPathLink; string app_id = QSVars["app_id"].ToString(); string customLogoLocation = ofbBiz.GetCustomLogo(sProductID); string logoLocation = "https://www.testsonetreach.com/Images/sonet_watermark.png"; string _sNotifierDID = new AppNotifier().GetNewDIDWithPrefix(); if (!_sAppPathLink.EndsWith("?")) _sAppPathLink += "&"; //Build NotifierDID & pass it to link _sAppPathLink += "NDID=" + _sNotifierDID + "&NTYP=TWEET"; //Auth User to get Twitter Details Twitter otittwr = new Twitter(); string AuthTwitter = otittwr.GetTwitterAuthURL(sADID, app_id, sProductID); StringBuilder oSBTweetButton = new StringBuilder(); oSBTweetButton.Append("<a class=\"TW_Share\" href=\"#\" onclick=\"javascript:" + "METHOD" + sProductID + "Twitter(); return false;\" ></a>" + Environment.NewLine); oSBTweetButton.Append("<script type=\"text/javascript\">" + Environment.NewLine); oSBTweetButton.Append("function " + "METHOD" + sProductID + "Twitter() {" + Environment.NewLine); oSBTweetButton.Append("window.open('" + AuthTwitter + "', 'mywindow', 'height=470,width=660,menubar=0,toolbar=0,statusbar=0,scrollbars=0,resizable=0,fullscreen=no');" + Environment.NewLine); oSBTweetButton.Append("} </script>" + Environment.NewLine); return oSBTweetButton.ToString(); }
private string GetHeadBannerURL(string sProductID) { string NotifierDID = ofbBiz.GetNotifierDID(sProductID); if (string.IsNullOrEmpty(NotifierDID)) { _sNotifierDID = new AppNotifier().GetNewDIDWithPrefix(); } else { _sNotifierDID = NotifierDID; } StringBuilder sbBannerURL = new StringBuilder(); sbBannerURL.Append("<script type=\"text/javascript\">" + Environment.NewLine); sbBannerURL.Append("$(document).ready(function () {" + Environment.NewLine); sbBannerURL.Append("$(\"#aHeadBanner\").click(function () {" + Environment.NewLine); sbBannerURL.Append("AsycRequest('" + GetNavigationURL(NotifyURL + "FBNotify.aspx?NTYP=CLICK&PDID=" + sProductID + "&NDID=" + _sNotifierDID, true) + "');" + Environment.NewLine); sbBannerURL.Append("});" + Environment.NewLine); sbBannerURL.Append("});" + Environment.NewLine); sbBannerURL.Append("</script>" + Environment.NewLine); return sbBannerURL.ToString(); }
private string GetAppRequestButton(string sProductID, string sProductName, string sProductLogo, string sProductDescitpion, string AppID) { string _sAppPathLink = ofbBiz.GetAppPagePath(AppID); string customLogoLocation = ofbBiz.GetCustomLogo(sProductID); string logoLocation = "https://www.sonetreach.com/Images/sonet_watermark.png"; string _sNotifierDID = new AppNotifier().GetNewDIDWithPrefix(); if (!_sAppPathLink.EndsWith("?")) _sAppPathLink += "&"; //Build NotifierDID & pass it to link _sAppPathLink += "NDID=" + _sNotifierDID; StringBuilder oSBShareButton = new StringBuilder(); oSBShareButton.Append("<a class=\"FB_Recommend\" href=\"#\" onclick=\"javascript:" + sProductID + "AppReq(); return false;\"></a>" + Environment.NewLine); oSBShareButton.Append("<div id=\"fb-root\"></div>"); oSBShareButton.Append("<script src=\"http://connect.facebook.net/en_US/all.js\"></script>"); oSBShareButton.Append("<script type=\"text/javascript\">" + Environment.NewLine); oSBShareButton.Append("function " + sProductID + "AppReq() {" + Environment.NewLine); oSBShareButton.Append("FB.init({"); oSBShareButton.Append("appId : '" + AppID + "',"); oSBShareButton.Append("status : true,"); oSBShareButton.Append("cookie : true,"); oSBShareButton.Append("oauth: true"); oSBShareButton.Append("});"); oSBShareButton.Append("FB.ui({method: 'apprequests',"); oSBShareButton.Append("message: 'My Great Request' ,"); oSBShareButton.Append("link: '" + _sAppPathLink + "'"); oSBShareButton.Append("},"); oSBShareButton.Append("function requestCallback(response) {"); oSBShareButton.Append("var myStringArray = response.to;"); oSBShareButton.Append("for (var i = 0; i < myStringArray.length; i++) {"); //oSBShareButton.Append("alert(myStringArray[i]);");//Works perfect oSBShareButton.Append("document.getElementById('hiddenReqUSersLit').value=myStringArray[i];"); oSBShareButton.Append("document.cookie=document.getElementById('hiddenReqUSersLit').value;"); oSBShareButton.Append("AsycRequest('" + GetNavigationURL(NotifyURL + "FBNotify.aspx?NTYP=APPREQ&PDID=" + sProductID + "&NDID=" + _sNotifierDID, true) + "');" + Environment.NewLine); oSBShareButton.Append("}"); oSBShareButton.Append("});" + Environment.NewLine); oSBShareButton.Append("}" + Environment.NewLine); oSBShareButton.Append("</script>" + Environment.NewLine); return oSBShareButton.ToString(); }
public string GetShareButton(string sProductID, string sProductName, string sProductLogo, string sProductDescitpion, string AppID, string TabNAme) { StringBuilder oSBShareButton = new StringBuilder(); string _sAppPathLink = fbBiz.GetAppPagePath(AppID); string customLogoLocation = fbBiz.GetCustomLogo(sProductID); string logoLocation = "https://www.testsonetreach.com/Images/sonet_watermark.png"; string _sNotifierDID = new AppNotifier().GetNewDIDWithPrefix(); if (!_sAppPathLink.EndsWith("?")) _sAppPathLink += "&"; //Build NotifierDID & pass it to link _sAppPathLink += "NDID=" + _sNotifierDID; oSBShareButton.Append("<a class=\"FB_Share\" href=\"#\" onclick=\"javascript:" + sProductID + "SHARE(); return false;\"></a>" + Environment.NewLine); oSBShareButton.Append("<script type=\"text/javascript\">" + Environment.NewLine); oSBShareButton.Append("function " + sProductID + "SHARE() {" + Environment.NewLine); oSBShareButton.Append("FB.ui({" + Environment.NewLine); oSBShareButton.Append("method: 'feed'," + Environment.NewLine); oSBShareButton.Append("message: 'check out this event!'," + Environment.NewLine); oSBShareButton.Append("name: '" + TabNAme + "'," + Environment.NewLine); oSBShareButton.Append("caption: '" + TabNAme + "'," + Environment.NewLine); oSBShareButton.Append("description:'" + "SonetReach" + "'," + Environment.NewLine); oSBShareButton.Append("picture:'" + logoLocation + "'," + Environment.NewLine); oSBShareButton.Append("display:'touch'," + Environment.NewLine); oSBShareButton.Append("app_id: '" + AppID + "'," + Environment.NewLine); oSBShareButton.Append("link: 'https://www.sonetreach.com/MobileRedirect.aspx?app_id=" + AppID + "'," + Environment.NewLine); oSBShareButton.Append("redirect_uri: 'https://www.sonetreach.com/MobileRedirect.aspx?app_id=" + AppID + "&NTYP=MSHARE&PDID=" + sProductID + "&NDID=" + _sNotifierDID + "&user_id=" + userID + "'" + Environment.NewLine); oSBShareButton.Append("}," + Environment.NewLine); oSBShareButton.Append("function (response) {" + Environment.NewLine); oSBShareButton.Append("if (response && response.post_id) {" + Environment.NewLine); oSBShareButton.Append("AsycRequest('" + GetNavigationURL("https://www.sonetreach.com/FBNotify.aspx?NTYP=MSHARE&PDID=" + sProductID + "&NDID=" + _sNotifierDID, true) + "');" + Environment.NewLine); oSBShareButton.Append("}" + Environment.NewLine); oSBShareButton.Append("});" + Environment.NewLine); oSBShareButton.Append("}" + Environment.NewLine); oSBShareButton.Append("</script>" + Environment.NewLine); return oSBShareButton.ToString(); }
public string GetNewshare(string sProductID, string sProductName, string sProductLogo, string sProductDescitpion, string AppID, string TabNAme) { StringBuilder oSBShareButton = new StringBuilder(); string _sAppPathLink = ofbBiz.GetAppPagePath(AppID); string logoLocation = " "; string _sNotifierDID = new AppNotifier().GetNewDIDWithPrefix(); if (!_sAppPathLink.EndsWith("?")) _sAppPathLink += "&"; //Build NotifierDID & pass it to link _sAppPathLink += "NDID=" + _sNotifierDID; oSBShareButton.Append("<a class=\"defaultFacebookButtonGeorgiaAquarium\" href=\"#\" onclick=\"javascript:" + sProductID + "share(); return false;\">Share</a>" + Environment.NewLine); oSBShareButton.Append("<script type=\"text/javascript\">"); oSBShareButton.Append("function " + sProductID + "share() {" + Environment.NewLine); oSBShareButton.Append("var publish = {"); oSBShareButton.Append("method: 'feed',"); oSBShareButton.Append("message: 'getting educated about Facebook Connect',"); oSBShareButton.Append("name: 'Connect',"); oSBShareButton.Append("caption: 'The Facebook Connect JavaScript SDK',"); oSBShareButton.Append("description: ("); oSBShareButton.Append(" 'A small JavaScript library that allows you to harness ' "); oSBShareButton.Append("),"); oSBShareButton.Append("link: '" + _sAppPathLink + "',"); oSBShareButton.Append("picture: '',"); oSBShareButton.Append("actions: ["); oSBShareButton.Append(" { name: 'fbrell', link: '" + _sAppPathLink + "' }"); oSBShareButton.Append("],"); oSBShareButton.Append("user_message_prompt: 'Share your thoughts about RELL'"); oSBShareButton.Append(" };"); oSBShareButton.Append("}" + Environment.NewLine); oSBShareButton.Append("FB.ui(publish, Log.info.bind('feed callback'));"); oSBShareButton.Append("</script>"); return oSBShareButton.ToString(); }
private string GetNotifyLIKE(string sProductID) { string _sAppPathLink = ofbBiz.GetAppPagePath(QSVars["app_id"].ToString()); string _sNotifierDID = new AppNotifier().GetNewDIDWithPrefix(); if (!_sAppPathLink.EndsWith("?")) _sAppPathLink += "&"; //Build NotifierDID & pass it to link _sAppPathLink += "NDID=" + _sNotifierDID; AppProduct oAppProduct = new AppProduct(); StringBuilder sbNotifyLIKE = new StringBuilder(); sbNotifyLIKE.Append("<script>" + Environment.NewLine); sbNotifyLIKE.Append("$(\"document\").ready(function () {" + Environment.NewLine); //catch like event sbNotifyLIKE.Append("FB.Event.subscribe('edge.create', function (href, widget) {" + Environment.NewLine); sbNotifyLIKE.Append("AsycRequest('" + GetNavigationURL("https://www.testsonetreach.com/FBNotify.aspx?NTYP=LIKE&PDID=" + sProductID + "&NDID=" + _sNotifierDID, true) + "');" + Environment.NewLine); sbNotifyLIKE.Append("});" + Environment.NewLine); //catch unlike event sbNotifyLIKE.Append("FB.Event.subscribe('edge.remove', function (href, widget) {" + Environment.NewLine); //sbNotifyLIKE.Append("alert('You just unliked ' + href);" + Environment.NewLine); sbNotifyLIKE.Append("});" + Environment.NewLine); sbNotifyLIKE.Append("});" + Environment.NewLine); sbNotifyLIKE.Append("</script>" + Environment.NewLine); return sbNotifyLIKE.ToString(); }
public string GetShareButton(string sProductID, string sProductName, string sProductLogo, string sProductDescitpion, string AppID, string TabNAme) { StringBuilder oSBShareButton = new StringBuilder(); string _sAppPathLink = ofbBiz.GetAppPagePath(AppID); //string _sAppPathLink = ofbBiz.GetAppPath(AppID); string customLogoLocation = ofbBiz.GetCustomLogo(sProductID); string logoLocation = "https://www.testsonetreach.com/Images/sonet_watermark.png"; string _sNotifierDID = new AppNotifier().GetNewDIDWithPrefix(); if (!_sAppPathLink.EndsWith("?")) _sAppPathLink += "&"; //Build NotifierDID & pass it to link _sAppPathLink += "NDID=" + _sNotifierDID; oSBShareButton.Append("<a class=\"FB_Share\" href=\"#\" onclick=\"javascript:" + sProductID + "SHARE(); return false;\"></a>" + Environment.NewLine); oSBShareButton.Append("<script type=\"text/javascript\">" + Environment.NewLine); oSBShareButton.Append("function " + sProductID + "SHARE() {" + Environment.NewLine); oSBShareButton.Append("FB.ui({" + Environment.NewLine); oSBShareButton.Append("method: 'feed'," + Environment.NewLine); oSBShareButton.Append("display: 'popup'," + Environment.NewLine); oSBShareButton.Append("message: 'check out this event!'," + Environment.NewLine); oSBShareButton.Append("attachment: {" + Environment.NewLine); oSBShareButton.Append("name: '" + TabNAme + "'," + Environment.NewLine); oSBShareButton.Append("app_id: '" + AppID + "'," + Environment.NewLine); oSBShareButton.Append("caption: '" + TabNAme + "'," + Environment.NewLine); //oSBShareButton.Append("redirect_uri: '" + ofbBiz.GetAppPath(AppID) + "'," + Environment.NewLine); oSBShareButton.Append("redirect_uri: '" + ofbBiz.GetAppPagePath(AppID) + "'," + Environment.NewLine); oSBShareButton.Append("next: '" + "null" + "'," + Environment.NewLine); oSBShareButton.Append("description: '" + "" + "'," + Environment.NewLine); oSBShareButton.Append("link: '" + ofbBiz.GetAppPagePath(AppID) + "'," + Environment.NewLine); oSBShareButton.Append("media: [{" + Environment.NewLine); oSBShareButton.Append("type: 'image'," + Environment.NewLine); //oSBShareButton.Append("link: '" + ofbBiz.GetAppPagePath(AppID) + "'," + Environment.NewLine); //oSBShareButton.Append("link: '" + ofbBiz.GetAppPath(AppID) + "'," + Environment.NewLine); if (string.IsNullOrEmpty(customLogoLocation)) { oSBShareButton.Append("src: '" + logoLocation + "'" + Environment.NewLine); } else { oSBShareButton.Append("src: '" + customLogoLocation + "'" + Environment.NewLine); } oSBShareButton.Append("}]" + Environment.NewLine); oSBShareButton.Append("}" + Environment.NewLine); //TO post on Fanpage add actor_id = Page id if (QSVars.Contains("admin")) { if (QSVars["admin"].ToString().Equals("true")) { string pageid = ofbBiz.GetPageID(AppID); oSBShareButton.Append(",actor_id:'" + pageid + "'" + Environment.NewLine); } } oSBShareButton.Append("}," + Environment.NewLine); oSBShareButton.Append("function (response) {" + Environment.NewLine); oSBShareButton.Append("if (response && response.post_id) {" + Environment.NewLine); oSBShareButton.Append("AsycRequest('" + GetNavigationURL(NotifyURL + "FBNotify.aspx?NTYP=SHARE&PDID=" + sProductID + "&NDID=" + _sNotifierDID, true) + "');" + Environment.NewLine); oSBShareButton.Append("}" + Environment.NewLine); oSBShareButton.Append("});" + Environment.NewLine); oSBShareButton.Append("}" + Environment.NewLine); oSBShareButton.Append("</script>" + Environment.NewLine); return oSBShareButton.ToString(); }
//For Share, Like, Lead public bool RaiseAppNotifier(AppUser oDCAppUser, string NTYP, string UDID, string PDID, string NDID, AppLeadData oAppLeadData, string TO_id) { //Check Event is sucess or not bool _bSetAppNotifierSuccess = false; try { //Validate NTYP before switching to respective notifier if (string.IsNullOrEmpty(NTYP)) return _bSetAppNotifierSuccess; //Build Post DCAppNotifier AppNotifier _oDCAppNotifier = new AppNotifier(); _oDCAppNotifier.AppUserDID = UDID; _oDCAppNotifier.AppProductDID = PDID; //Check if NDID already defined if so use it if (!string.IsNullOrEmpty(NDID)) _oDCAppNotifier.DID = NDID; else _oDCAppNotifier.DID = _oDCAppNotifier.GetNewDIDWithPrefix(); _oDCAppNotifier.NoOfVisits = 0; //Check which notifier to call based on NTYP switch (NTYP.ToUpper()) { case "SHARE": _oDCAppNotifier.NotifierType = "SHARE"; _bSetAppNotifierSuccess = fbDALC.AddAppNotifierDetails(GetSonetPie, _oDCAppNotifier); break; case "LEAD": _oDCAppNotifier.NotifierType = "LEAD"; _oDCAppNotifier.SoNetEmailID = oAppLeadData.EmailID; _oDCAppNotifier.SoNetEmailContext = oAppLeadData.Subject; _oDCAppNotifier.SoNetEmailContent = oAppLeadData.Body; _bSetAppNotifierSuccess = fbDALC.AddAppNotifierDetails(GetSonetPie, _oDCAppNotifier); break; case "LIKE": _oDCAppNotifier.NotifierType = "LIKE"; _bSetAppNotifierSuccess = fbDALC.AddAppNotifierDetails(GetSonetPie, _oDCAppNotifier); break; case "MSHARE": _oDCAppNotifier.NotifierType = "MSHARE"; _bSetAppNotifierSuccess = fbDALC.AddAppNotifierDetails(GetSonetPie, _oDCAppNotifier); break; case "TWEET": _oDCAppNotifier.NotifierType = "TWEET"; _bSetAppNotifierSuccess = fbDALC.AddAppNotifierDetails(GetSonetPie, _oDCAppNotifier); break; case "MPOST": _oDCAppNotifier.NotifierType = "MPOST"; _oDCAppNotifier.SoNetFriendID = TO_id; if (!TO_id.Contains(",")) { _bSetAppNotifierSuccess = fbDALC.AddAppNotifierDetails(GetSonetPie, _oDCAppNotifier); } break; case "MLIKE": _oDCAppNotifier.NotifierType = "MLIKE"; _bSetAppNotifierSuccess = fbDALC.AddAppNotifierDetails(GetSonetPie, _oDCAppNotifier); break; case "CLICK": _oDCAppNotifier.NotifierType = "CLICK"; _bSetAppNotifierSuccess = fbDALC.AddAppNotifierDetails(GetSonetPie, _oDCAppNotifier); break; case "LISHARE": _oDCAppNotifier.NotifierType = "LISHARE"; _bSetAppNotifierSuccess = fbDALC.AddAppNotifierDetails(GetSonetPie, _oDCAppNotifier); break; default: _bSetAppNotifierSuccess = false; break; } return _bSetAppNotifierSuccess; } catch (Exception ex) { //Log4NetUtility.ErrorDebug(this.GetType().FullName, "Error in DCAppConfiguration GetAppConfiguration()", ex); throw ex; } }
protected override void OnPreLoad(EventArgs e) { try { base.OnPreLoad(e); FacebookBizProcess fbBiz = new FacebookBizProcess(); FaceBook oFBUtility = new FaceBook(); SonetPieBizProcess sonetpiebiz = new SonetPieBizProcess(); SonetPie sonetpie = new SonetPie(); NotifyURL = ConfigurationSettings.AppSettings["NotifyURL"]; pageRefreshed = false; if (QSVars.Contains("user_id")) { Session["facebook_user_id"] = QSVars["user_id"].ToString(); } if (QSVars.Contains("UDID")) { Session["sr_user_did"] = QSVars["UDID"].ToString(); } if (QSVars.Contains("PDID")) { Session["sr_product_did"] = QSVars["PDID"].ToString(); } if (Request.Url.Query.Contains("request") && !(Request.Url.Query.Contains("fb_source"))) //AppRequest callback, now save to notifiers { for (int i = 0; i < Request.QueryString.Count - 2; i++) { //every Request["to[i]"] has a userID for AppNotifier string fbUID = Request["to[" + i + "]"].ToString(); string _sNotifierDID = new AppNotifier().GetNewDIDWithPrefix(); string facebook_user_id = Convert.ToString(Session["facebook_user_id"]); string UDID = Convert.ToString(Session["sr_user_did"]); if (QSVars.Contains("NDID")) QSVars["NDID"] = _sNotifierDID; else QSVars.Add("NDID", _sNotifierDID); //Build DCAppWallPost for each user AppUser oDCAppUser = new AppUser(); string ConfigDID = fbBiz.GetConfigDEED(Convert.ToString(QSVars["app_id"])); if (!QSVars.Contains("ADID")) { QSVars.Add("ADID", ConfigDID); } if (!QSVars.Contains("PDID")) { QSVars.Add("PDID", Convert.ToString(Session["sr_product_did"])); } oDCAppUser = ofbBiz.GetAppUser(osonetpie, QSVars["ADID"].ToString(), facebook_user_id); _oDCAppWallPost.FromUserID = Convert.ToString(QSVars["user_id"]); _oDCAppWallPost.ToUserID = fbUID; _oDCAppWallPost.Name = ofbBiz.GetCustomTabName(QSVars["app_id"].ToString()); _oDCAppWallPost.Source = Convert.ToString(QSVars["user_id"]); AppLeadData oAppLead = new AppLeadData(); if (Request.Browser.IsMobileDevice == true || Request.UserAgent.ToLower().Contains("iphone") || Request.UserAgent.ToLower().Contains("android")) { if (fbBiz.RaiseAppNotifier(oDCAppUser, "MPOST", UDID, Convert.ToString(QSVars["PDID"]), "", fbUID)) { } } else { if (fbBiz.RaiseAppNotifier(oDCAppUser, "POST", UDID, Convert.ToString(QSVars["PDID"]), "", fbUID)) { } } } Page.ClientScript.RegisterStartupScript(this.GetType(), "myCloseScript", "window.close();", true); } if (Request["code"] == null) { if ((Request.QueryString.Count > 0) && !(Request["LIKED"] != null)) { //ParseRequest & set values to qsvars if (!(Request.QueryString).AllKeys[0].ToString().Contains("tabs_added")) { //REVISIT sonetpie.QSvarsString = GetQsVarsCollection(); sonetpie.FormvarsString = GetFormVarsCollection(); sonetpie.AbsolutePath = AbsolutePagePath; if (Request.Form.ToString() != string.Empty) { FormVars.Add("signed_request", Request.Form.Get(0).ToString()); } //Init Biz //SonetPieBizProcess sonetpiebiz = new SonetPieBizProcess(); if (QSVars.Contains("app_id")) { if (EnableAppServices) _oDCAppConfiguration = sonetpiebiz.GetAppConfiguration("", QSVars["app_id"].ToString()); SessionData.Config.DID = _oDCAppConfiguration.DID; //DigiMa.Common.FaceBook oFBUtility1 = new DigiMa.Common.FaceBook(); //check AppConfig got loaded if (AppConfig != null) { //Add CDID to Load customer if (QSVars.Contains("CDID")) QSVars["CDID"] = AppConfig.AppCustomerDID; else QSVars.Add("CDID", AppConfig.AppCustomerDID); //Add ADID to Load customer if (QSVars.Contains("ADID")) QSVars["ADID"] = AppConfig.DID; else QSVars.Add("ADID", AppConfig.DID); //Reset KOKO QSVars sonetpie.QSvarsString = GetQsVarsCollection(); _oDCAppCustomer = fbBiz.GetAppCustomer(Convert.ToString(QSVars["CDID"])); //ParseSigned Request if ((!QSVars.Contains("oauth_token"))) { oFBUtility.ParseSignedRequest(ref _qsVars, ref _frmVars, AppConfig); } if (QSVars.Contains("oauth_token")) { Session["oauth_token"] = Convert.ToString(QSVars["oauth_token"]); } if (QSVars.Contains("user_id")) { Session["user_id"] = Convert.ToString(QSVars["user_id"]); } //call graph to get page_Acc_tok if (QSVars.Contains("oauth_token") && (_oDCAppConfiguration.SAppCustomNameAdded == null || _oDCAppConfiguration.SAppCustomNameAdded == "")) { page_access_token = facebook.GetPageAccessToken(QSVars["oauth_token"].ToString()); System.Web.Script.Serialization.JavaScriptSerializer _oJavaScriptSerializer = new System.Web.Script.Serialization.JavaScriptSerializer(); JObject obj = JObject.Parse(page_access_token); IEnumerable<string> query = from res in (Newtonsoft.Json.Linq.JArray)obj["data"] let reso = res as JObject where ((string)reso["id"]).ToLower() == _oDCAppConfiguration.SPageID select (string)reso["access_token"]; //fetch the logo of this Campaign from AppProduct and pass to CallPages if (facebook.CallPages(_oDCAppConfiguration.SPageID, query.ToList()[0].ToString(), "app_" + QSVars["app_id"].ToString(), _oDCAppConfiguration.SCustomtTabName, fbBiz.FetchAppLogo(QSVars["app_id"].ToString()))) { //update custom_updated to Y fbBiz.UpdateCustomTabNAme(_oDCAppConfiguration.DID); ClientScript.RegisterStartupScript(this.GetType(), "scriptid", "window.parent.location.href='" + _oDCAppConfiguration.SAppPagePath + "'", true); } } //parse the JSON if (HasAuthorization) { if (!QSVars.Contains("oauth_token")) { //Set Authorization stamp on redirect url AppConfig.AppPath += "?soNETSrc="; if (QSVars.Contains("NDID")) AppConfig.AppPath += Convert.ToString(QSVars["NDID"]); else AppConfig.AppPath += "NULL"; //oFBUtility.GetAccessToken(QSVars["code"].ToString(), "user_location,email,friends_location,publish_stream",AppConfig.AppPath,AppConfig); // CHeck if Request is coming from Mobile device, then open Standalone if (Request.Browser.IsMobileDevice == true || Request.UserAgent.ToLower().Contains("iphone") || Request.UserAgent.ToLower().Contains("android")) { //oFBUtility.AuthorizeMob(this, "user_location,email,friends_location,user_birthday", AppConfig); } else { oFBUtility.Authorize(this, "user_location,email,friends_location,user_birthday", AppConfig); } } else { //Insert user into DB if (true) { //Call service to store into DB AppUser oDCAppUser = new AppUser(); oDCAppUser.AppConfigDID = AppConfig.DID; oDCAppUser.EmailID = "NULL"; oDCAppUser.SonetID = Convert.ToString(QSVars["user_id"]); oDCAppUser.SonetSRC = Convert.ToString(QSVars["soNETSrc"]); oDCAppUser.UserStatus = "Active"; oDCAppUser.SMType = "FB"; oDCAppUser = oFBUtility.GetUserDetail(Convert.ToString(QSVars["user_id"]), Convert.ToString(QSVars["oauth_token"]), oDCAppUser); //Save to DB if (!fbBiz.IsUserCreatedForFacebook(oDCAppUser.SonetID, oDCAppUser.AppConfigDID)) { if (fbBiz.SetAppUserAuthorize(oDCAppUser, Convert.ToString(QSVars["ADID"]))) _oDCAppUser = oDCAppUser; } } } } } //refrsh to get tab name //fbBiz.UpdateCustomTabNAme(_oDCAppConfiguration.DID); //ClientScript.RegisterStartupScript(this.GetType(), "scriptid", "window.parent.location.href='" + _oDCAppConfiguration.SAppPagePath + "'", true); //Load AppUser based on property if (_bEnableAppUser && _qsVars.Contains("user_id")) { sonetpie.QSvarsString = GetQsVarsCollection(); _oDCAppUser = fbBiz.GetAppUser(sonetpie, Convert.ToString(QSVars["ADID"]), Convert.ToString(QSVars["user_id"])); if (_oDCAppUser != null) { if (!_qsVars.Contains("UDID")) _qsVars.Add("UDID", _oDCAppUser.DID); else _qsVars["UDID"] = _oDCAppUser.DID; if (QSVars.Count < 8) { ClientScript.RegisterStartupScript(this.GetType(), "scriptid", "window.parent.location.href='" + _oDCAppConfiguration.SAppPagePath + "'", true);//To ensure all QSVARS are loaded from facebook } } } //Update Notifier count based on NDID or soNETSrc if (QSVars.Contains("soNETSrc") || QSVars.Contains("NDID")) { AppNotifier oAppNotifier = new AppNotifier(); if (QSVars.Contains("soNETSrc")) oAppNotifier.DID = Convert.ToString(QSVars["soNETSrc"]); if (QSVars.Contains("NDID")) oAppNotifier.DID = Convert.ToString(QSVars["NDID"]); if (!string.IsNullOrEmpty(oAppNotifier.DID)) fbBiz.EditAppNotifierDetails(oAppNotifier); } } } } else { // } } else { //Here redirect user to Page path if (QSVars.Contains("app_id") && QSVars.Contains("soNETSrc")) { //string pageToRedirect = fbBiz.GetAppPagePath(Convert.ToString(QSVars["app_id"])); //Response.Redirect(pageToRedirect,true); } } } catch (Exception ex) { CommonUtility commUtil = new CommonUtility(); commUtil.SendErrorMail(ex.Message, ex.StackTrace, System.Reflection.MethodBase.GetCurrentMethod().Name.ToString(), System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString(), SessionData.Customer.CustomerID); } }
protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); //Initialize API Core FaceBook oFacebook = new FaceBook(); //Initialize KOKO SonetPie osonetpie = new SonetPie(); QSVars.Add("NTYP", "LEAD"); osonetpie.QSvarsString = GetQsVarsCollection(); osonetpie.AbsolutePath = AbsolutePagePath; //Load app settings oDCAppUser = fbBizProc.GetAppUser(osonetpie, QSVars["ADID"].ToString(), QSVars["user_id"].ToString()); oAppProduct = fbBizProc.GetAppProductDetails(osonetpie, QSVars["PDID"].ToString()); //get Inquiry Email if exists //fetch Inmquiry EMAIL data string inquiryEmail; inquiryEmail = fbBizProc.GetInquiryEmail(Convert.ToString(QSVars["ADID"])); //Bind Post content at runtime if (oAppProduct.DID.Equals("AP006KV63YSPT0ZDHTMD")) { txtLeadContent.Text = "I am interested to know more on this event."; } else if (oAppProduct.DID.Equals("AP000CH69W22X9KDGZTT") || oAppProduct.DID.Equals("AP001CS762FRSC4BPCV3") || oAppProduct.DID.Equals("AP005S976CL8C85Y2HV5") || oAppProduct.DID.Equals("AP002PX605GMMMG9MQ59")) { txtLeadContent.Text = "I am interested to know more on this product."; } lblProductSummary.Text = GetProductSummary(); //Prefill product context if (oAppProduct != null) { if (oAppProduct.DID.Equals("AP006KV63YSPT0ZDHTMD")) { txtLeadContext.Text = oAppProduct.ProductName + " event inquiry"; } else if (oAppProduct.DID.Equals("AP000CH69W22X9KDGZTT") || oAppProduct.DID.Equals("AP001CS762FRSC4BPCV3") || oAppProduct.DID.Equals("AP005S976CL8C85Y2HV5") || oAppProduct.DID.Equals("AP002PX605GMMMG9MQ59")) { txtLeadContext.Text = oAppProduct.ProductName + " product inquiry"; } } else txtLeadContext.Text = "product inquiry"; //Prefill Email id if (!string.IsNullOrEmpty(inquiryEmail)) txtLeadEmailID.Text = oDCAppUser.EmailID; //Clear Error text lblValidationSummary.Text = string.Empty; //Perform Post to wall friends & Store notifierDID stat if (this.IsPostBack && oAppProduct != null && AppCustomer != null && AppConfig != null) { if (FormVars.Contains("BtnSubmit")) { if (Convert.ToString(FormVars["txtLeadEmailID"]).Trim().Length <= 0) Page.ClientScript.RegisterStartupScript(this.GetType(), "myCloseScript", "alert(\"Specify email id.\")", true); else if (Convert.ToString(FormVars["txtLeadContext"]).Trim().Length <= 0) lblValidationSummary.Text = "Specify email subject."; else if (Convert.ToString(FormVars["txtLeadContent"]).Trim().Length <= 0) lblValidationSummary.Text = "Specify email content."; else { AppLeadData oAppLeadData = new AppLeadData(); oAppLeadData.EmailID = Convert.ToString(FormVars["txtLeadEmailID"]); oAppLeadData.Subject = Convert.ToString(FormVars["txtLeadContext"]); oAppLeadData.Body = Convert.ToString(FormVars["txtLeadContent"]); string _sNotifierDID = new AppNotifier().GetNewDIDWithPrefix(); if (QSVars.Contains("NDID")) QSVars["NDID"] = _sNotifierDID; else QSVars.Add("NDID", _sNotifierDID); if (fbBizProc.RaiseAppNotifier(oDCAppUser, "LEAD", QSVars["UDID"].ToString(), QSVars["PDID"].ToString(), QSVars["NDID"].ToString(), oAppLeadData, string.Empty)) { //Now send email CommonUtility comUtil = new CommonUtility(); custTabName = fbBizProc.GetCustomTabName(Convert.ToString(QSVars["app_id"])); comUtil.SendEnquiryMail(inquiryEmail, oAppLeadData.Subject, oAppLeadData.Body, custTabName, oAppProduct,oDCAppUser.EmailID); Page.ClientScript.RegisterStartupScript(this.GetType(), "myCloseScript", "window.close()", true); } } } } //Set error message section if (!string.IsNullOrEmpty(lblValidationSummary.Text)) trErrorMsg.Visible = true; else trErrorMsg.Visible = false; }