示例#1
0
        public bool SetAppUserAuthorize(AppUser oAppUser, string ADID)
        {
            try
            {
                //Check set is sucess or not
                bool _bSetAppUserSuccess = false;

                //Check AppUser Exist or not
                if (!TwDALC.IsAppUserActive(ADID, oAppUser))
                {
                    //Set New DID from DB
                    oAppUser.DID = oAppUser.GetNewDIDWithPrefix();
                    if (TwDALC.IsAppUserExist(ADID, ref oAppUser))
                        _bSetAppUserSuccess = TwDALC.EditAppUserDetails(GetSonetPie, oAppUser);
                    else
                        _bSetAppUserSuccess = TwDALC.AddAppUserDetails(GetSonetPie, oAppUser);

                    ////Insert AppEvent for authorize
                    //if (_bSetAppUserSuccess)
                    //{
                    //    //Raise Log Event for Authorize
                    //    _bSetAppUserSuccess = new BizAppUserEvent(GetsoNetKoKo).LogUserEventAuthorize(oDCAppUser);
                    //}
                }

                return _bSetAppUserSuccess;
            }
            catch (Exception ex)
            {
                //Log4NetUtility.ErrorDebug(this.GetType().FullName, "Error in DCAppConfiguration GetAppConfiguration()", ex);
                throw ex;
            }
        }
示例#2
0
        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"]));
        }
示例#3
0
        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;
        }
示例#4
0
        public bool IsAppUserExist(string ADID, ref AppUser oDCAppUser)
        {
            try
            {
                DatabaseHandler oDBH = new DatabaseHandler();

                //Check if user is already present if present then update his information & status
                object objRowCount = oDBH.ExecuteNonQuery_SP("IsAppUserExist", ADID, oDCAppUser.SonetID);
                if ((int)objRowCount > 0)
                {
                    return true;
                }
                return false;
            }
            catch (Exception ex)
            {
                //Log4NetUtility.ErrorDebug(this.GetType().FullName, "Error in GetConfigData(string _AppId)", ex);
                throw ex;
            }
        }
示例#5
0
 public bool EditAppUserDetails(SonetPie osonetpie, AppUser oDCAppUser)
 {
     try
     {
         DatabaseHandler oDBH = new DatabaseHandler();
         if (oDCAppUser.SBirthdate == "")
         {
             oDBH.FillData_SP("EditAppUserDetails", Convert.ToString(osonetpie.QSvars["ADID"]), oDCAppUser.SonetID, oDCAppUser.City, oDCAppUser.State, oDCAppUser.Country, oDCAppUser.EmailID, oDCAppUser.UserStatus, oDCAppUser.Gender, System.DBNull.Value, oDCAppUser.SFriend_count);
             return true;
         }
         else
         {
             oDBH.FillData_SP("EditAppUserDetails", Convert.ToString(osonetpie.QSvars["ADID"]), oDCAppUser.SonetID, oDCAppUser.City, oDCAppUser.State, oDCAppUser.Country, oDCAppUser.EmailID, oDCAppUser.UserStatus, oDCAppUser.Gender, oDCAppUser.SBirthdate, oDCAppUser.SFriend_count);
             return true;
         }
     }
     catch (Exception ex)
     {
         //Log4NetUtility.ErrorDebug(this.GetType().FullName, "Error in GetConfigData(string _AppId)", ex);
         throw ex;
     }
 }
示例#6
0
        public bool AddAppUserDetails(SonetPie osonetpie, AppUser oDCAppUser)
        {
            try
            {
                DatabaseHandler oDBH = new DatabaseHandler();
                if (oDCAppUser.SBirthdate == "")
                {

                    int i = oDBH.ExecuteNonQuery_SP("AddAppUserDetails", oDCAppUser.DID, oDCAppUser.AppConfigDID, oDCAppUser.UserName, oDCAppUser.SonetID, oDCAppUser.SonetSRC, oDCAppUser.ImageURL, oDCAppUser.City, oDCAppUser.State, oDCAppUser.Country, oDCAppUser.EmailID, oDCAppUser.UserStatus, oDCAppUser.Gender, oDCAppUser.EmailSubscription, System.DBNull.Value, oDCAppUser.SFriend_count, oDCAppUser.SMType, oDCAppUser.Token, oDCAppUser.TokenSecret);
                    if (i < 0) return false; else return true;
                }
                else
                {
                    int i = oDBH.ExecuteNonQuery_SP("AddAppUserDetails", oDCAppUser.DID, oDCAppUser.AppConfigDID, oDCAppUser.UserName, oDCAppUser.SonetID, oDCAppUser.SonetSRC, oDCAppUser.ImageURL, oDCAppUser.City, oDCAppUser.State, oDCAppUser.Country, oDCAppUser.EmailID, oDCAppUser.UserStatus, oDCAppUser.Gender, oDCAppUser.EmailSubscription, oDCAppUser.SBirthdate, oDCAppUser.SFriend_count, oDCAppUser.SMType, oDCAppUser.Token, oDCAppUser.TokenSecret);
                    if (i < 0) return false; else return true;
                }
            }
            catch (Exception ex)
            {
                //Log4NetUtility.ErrorDebug(this.GetType().FullName, "Error in GetConfigData(string _AppId)", ex);
                throw ex;
            }
        }
示例#7
0
        public AppUser GetAppUser(SonetPie sonetpie, string ADID, string user_id)
        {
            try
            {
                DatabaseHandler oDBH = new DatabaseHandler();

                DataTable oAppUserDataTable = oDBH.FillData_SP("GetAppUser", ADID, user_id).Tables[0];
                if (oAppUserDataTable != null)
                {
                    AppUser _oAppUser = new AppUser();
                    _oAppUser.DID = oAppUserDataTable.Rows[0]["DID"].ToString();
                    _oAppUser.AppConfigDID = oAppUserDataTable.Rows[0]["AppConfigDID"].ToString();
                    _oAppUser.UserName = oAppUserDataTable.Rows[0]["UserName"].ToString();
                    _oAppUser.SonetID = oAppUserDataTable.Rows[0]["soNetID"].ToString();
                    _oAppUser.SonetSRC = oAppUserDataTable.Rows[0]["soNetSRC"].ToString();
                    _oAppUser.ImageURL = oAppUserDataTable.Rows[0]["ImageURL"].ToString();
                    _oAppUser.City = oAppUserDataTable.Rows[0]["City"].ToString();
                    _oAppUser.State = oAppUserDataTable.Rows[0]["State"].ToString();
                    _oAppUser.Country = oAppUserDataTable.Rows[0]["Country"].ToString();
                    _oAppUser.EmailID = oAppUserDataTable.Rows[0]["EmailID"].ToString();
                    _oAppUser.UserStatus = oAppUserDataTable.Rows[0]["UserStatus"].ToString();
                    _oAppUser.Gender = oAppUserDataTable.Rows[0]["Gender"].ToString();
                    _oAppUser.EmailSubscription = oAppUserDataTable.Rows[0]["EmailSubscription"].ToString();
                    _oAppUser.SubscriptionEmailID = oAppUserDataTable.Rows[0]["SubscriptionEmailID"].ToString();
                    _oAppUser.SubscriptionReferral = oAppUserDataTable.Rows[0]["SubscriptionReferral"].ToString();
                    _oAppUser.SBirthdate = oAppUserDataTable.Rows[0]["Birthday"].ToString();
                    return _oAppUser;
                }
                else { return null; }
            }
            catch (Exception ex)
            {
                //Log4NetUtility.ErrorDebug(this.GetType().FullName, "Error in GetConfigData(string _AppId)", ex);
                throw ex;
            }
        }
示例#8
0
        //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;
            }
        }
示例#9
0
        //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;
            }
        }
示例#10
0
 public bool IsAppUserExistMobile(AppUser oDCAppUser)
 {
     try
     {
         return fbDALC.IsAppUserExistMobile(oDCAppUser);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
示例#11
0
        public AppUser GetUserDetail(string userid, AppUser oDCAppUser)
        {
            StringBuilder _sbUserInfoURL = new StringBuilder();
            _sbUserInfoURL.Append("https://api.twitter.com/1/users/lookup.json?user_id=" + userid);

            //Parse json to get MXDBAppUser
            string _sUserInfoJson = CallWebRequest("GET", _sbUserInfoURL.ToString(), string.Empty);
            object[] oUserLocationDataRow = new object[7];
            //Convert Json to JsonDictionary <of String, object>
            System.Web.Script.Serialization.JavaScriptSerializer _oJavaScriptSerializer = new System.Web.Script.Serialization.JavaScriptSerializer();
            object _oJSONObject = _oJavaScriptSerializer.DeserializeObject(_sUserInfoJson);
            int i = 0;
            for (i = 0; i <= ((object[])_oJSONObject).Length - 1; i++)
            {
                Dictionary<string, object> _ojsonUserDetails = (Dictionary<string, object>)((object[])_oJSONObject)[i];
                foreach (KeyValuePair<string, object> _oKeyjsonUserDetailsItem in _ojsonUserDetails)
                {
                    switch (_oKeyjsonUserDetailsItem.Key)
                    {
                        case "name": //set Name
                            oDCAppUser.UserName = Convert.ToString(_oKeyjsonUserDetailsItem.Value);
                            break;

                        case "profile_image_url": //set image
                            oDCAppUser.ImageURL = Convert.ToString(_oKeyjsonUserDetailsItem.Value);
                            break;

                        case "followers_count": //set followers count
                            oDCAppUser.SFriend_count = Convert.ToString(_oKeyjsonUserDetailsItem.Value);
                            break;

                        case "location": //set City
                            oDCAppUser.City = Convert.ToString(_oKeyjsonUserDetailsItem.Value);
                            break;

                        //case "current_location": // set current location
                        //    if (_oKeyjsonUserDetailsItem.Value != null && Convert.ToString(_oKeyjsonUserDetailsItem.Value).Length > 0)
                        //    {
                        //        //set location fields
                        //        Dictionary<string, object> jsonlocationDict = (Dictionary<string, object>)_oKeyjsonUserDetailsItem.Value;
                        //        foreach (KeyValuePair<string, object> _olocationItem in jsonlocationDict)
                        //        {
                        //            switch (_olocationItem.Key.ToLower())
                        //            {
                        //                case "city":
                        //                    if (Convert.ToString(_olocationItem.Value).Length > 0)
                        //                    {
                        //                        string[] _olocationvalue = Convert.ToString(_olocationItem.Value).Split(new string[] { "," }, StringSplitOptions.None);
                        //                        if (_olocationvalue.Length >= 1) oDCAppUser.City = _olocationvalue[0];
                        //                    }
                        //                    break;

                        //                case "state":
                        //                    if (Convert.ToString(_olocationItem.Value).Length > 0)
                        //                    {
                        //                        string[] _olocationvalue = Convert.ToString(_olocationItem.Value).Split(new string[] { "," }, StringSplitOptions.None);
                        //                        if (_olocationvalue.Length >= 1) oDCAppUser.State = _olocationvalue[0];
                        //                    }
                        //                    break;

                        //                case "country":
                        //                    if (Convert.ToString(_olocationItem.Value).Length > 0)
                        //                    {
                        //                        string[] _olocationvalue = Convert.ToString(_olocationItem.Value).Split(new string[] { "," }, StringSplitOptions.None);
                        //                        if (_olocationvalue.Length >= 1) oDCAppUser.Country = _olocationvalue[0];
                        //                    }
                        //                    break;

                        //                default:
                        //                    break; //Could not parse location json element
                        //            }
                        //        }
                        //    }
                        //    break;
                        //case "sex": oDCAppUser.Gender = Convert.ToString(_oKeyjsonUserDetailsItem.Value);
                        //    break;
                        //case "birthday_date": oDCAppUser.SBirthdate = Convert.ToString(_oKeyjsonUserDetailsItem.Value);
                        //    break;
                        //case "friend_count": oDCAppUser.SFriend_count = Convert.ToString(_oKeyjsonUserDetailsItem.Value);
                        //    break;
                    }
                }
            }

            return oDCAppUser;
        }
示例#12
0
        private void Page_PreRender(object sender, System.EventArgs e)
        {
            SonetPie osonetpie = new SonetPie();
            AppUser oDCAppUser = new AppUser();
            CanvasBizProcess ocanvBiz = new CanvasBizProcess();
            FacebookBizProcess fbBizProc = new FacebookBizProcess();
            try
            {

                if (Request.Browser.IsMobileDevice == true || Request.UserAgent.ToLower().Contains("iphone") || Request.UserAgent.ToLower().Contains("android") || Request.UserAgent.ToLower().Contains("ipad"))
                {
                    if (QSVars.Contains("oauth_token") && QSVars.Contains("oauth_token"))
                    {
                        Response.Redirect(NotifyURL + "MobileRedirect.aspx?app_id=" + QSVars["app_id"].ToString() + "&access_tok=" + QSVars["oauth_token"].ToString() + "&user_id=" + QSVars["user_id"], false);
                    }
                    else
                    {
                        Response.Redirect(NotifyURL + "MobileRedirect.aspx?app_id=" + QSVars["app_id"].ToString() + "&access_tok=" + Convert.ToString(Session["oauth_token"]) + "&user_id=" + Convert.ToString(Session["user_id"]), false);
                    }
                }

                MainJavaScriptContent.Text = GetInitializedJS();

                //NEW VERSION 13-April-2012
                //Use the response_type=code to generate the access token
                if (Request.QueryString.Count == 2)
                {

                    //close and redirect to SelectPage
                    StringBuilder oSBWindowScript = new StringBuilder();

                    string pageCaller = "{code:\"" + Convert.ToString(QSVars["code"]) + "\",app_id:\"" + Convert.ToString(QSVars["app_id"]) + "\"}";
                    oSBWindowScript.Append("window.opener.tabSelection(" + pageCaller + ");");
                    oSBWindowScript.Append("window.close();");

                    Page.ClientScript.RegisterStartupScript(this.GetType(), "myCloseScript", oSBWindowScript.ToString(), true);

                    Response.Redirect("SelectPage.aspx?app_id=" + Convert.ToString(QSVars["app_id"]) + "&code=" + Convert.ToString(QSVars["code"]), false);

                }

                if (Request.QueryString.Count == 1)
                {
                    osonetpie.QSvarsString = GetQsVarsCollection();
                    osonetpie.AbsolutePath = AbsolutePagePath;

                    if (QSVars.Count > 6)
                    {

                        oDCAppUser.AppConfigDID = QSVars["ADID"].ToString();
                        hdnAppConfigD.Value = oDCAppUser.AppConfigDID;
                        oDCAppUser.SonetID = QSVars["user_id"].ToString();
                        hdnUserID.Value = oDCAppUser.SonetID;
                        hdnAppID.Value = QSVars["app_id"].ToString();
                        Session["UserID"] = hdnUserID.Value;
                        Session["AppID"] = hdnAppID.Value;
                        Session["ADID"] = oDCAppUser.AppConfigDID;
                        oDCAppUser = ofbBiz.GetAppUser(osonetpie, QSVars["ADID"].ToString(), QSVars["user_id"].ToString());

                        if (QSVars.Contains("liked"))
                        {
                            if (QSVars["liked"].Equals("true") && !ofbBiz.IsLikeGatewayAdded(QSVars["ADID"].ToString())) // If Already liked show page else Force user to like, iff like gateway was selected
                            {
                                //check if configuration is still good- that means not EXPIRED
                                if (!ofbBiz.IsConfigurationExpired(QSVars["ADID"].ToString()))
                                {
                                    //populate the AppProduct encapsulation based on app that is loaded
                                    AppProduct oAppProduct = new AppProduct();
                                    FaceBook facebook = new FaceBook();

                                    oAppProduct = ofbBiz.GetActiveAppProduct(osonetpie, QSVars["ADID"].ToString());
                                    litHeadBannerCount.Text = GetHeadBannerURL(oAppProduct.DID);
                                    // Get the HTML to be shown

                                    //Get Custom Tab name
                                    string CustTabNAme = fbBizProc.GetCustomTabName(Session["AppID"].ToString());

                                    //Get Share Button for this Product
                                    string CommentBox = GetCommentPlugin(oAppProduct.DID, oAppProduct.ProductName, oAppProduct.ProductLogo, oAppProduct.ProductShortDesc, QSVars["app_id"].ToString(), fbBizProc.GetAppPagePath(Convert.ToString(QSVars["app_id"])));
                                    string ShareButton = GetShareButton(oAppProduct.DID, oAppProduct.ProductName, oAppProduct.ProductLogo, oAppProduct.ProductShortDesc, QSVars["app_id"].ToString(), CustTabNAme);
                                    string InviteButton = GetInviteButton(oAppProduct.DID, oAppProduct.ProductName, oAppProduct.ProductLogo, oAppProduct.ProductShortDesc, QSVars["app_id"].ToString());
                                    string RecommendButton = GetRecommendButton(oAppProduct.DID, oAppProduct.ProductName, oAppProduct.ProductLogo, oAppProduct.ProductShortDesc, QSVars["app_id"].ToString());
                                    string LikePlugin = GetLikePlugin(oAppProduct.DID, oAppProduct.ProductName, oAppProduct.ProductLogo, oAppProduct.ProductShortDesc, QSVars["app_id"].ToString());
                                    string EntryFormPlug = GetEntryForm(oAppProduct.DID, oAppProduct.ProductName, oAppProduct.ProductLogo, oAppProduct.ProductShortDesc, QSVars["ADID"].ToString(), QSVars["user_id"].ToString());
                                    string LeadPlugin = GetLeadButton(oAppProduct.DID, oAppProduct.ProductName, oAppProduct.ProductLogo, oAppProduct.ProductShortDesc, QSVars["app_id"].ToString());
                                    string PrintButton = GetPrint(oAppProduct.DID, oAppProduct.ProductName, oAppProduct.ProductLogo, oAppProduct.ProductShortDesc, QSVars["app_id"].ToString());
                                    string EmailButton = GetEmail(oAppProduct.DID, oAppProduct.ProductName, oAppProduct.ProductLogo, oAppProduct.ProductShortDesc, QSVars["app_id"].ToString());
                                    string TwitterButton = GetTwitterShareURL(oAppProduct.DID, oAppProduct.ProductName, oAppProduct.ProductLogo, oAppProduct.ProductShortDesc, QSVars["app_id"].ToString());
                                    string LinkedInButton = "<script src=\"//platform.linkedin.com/in.js\" type=\"text/javascript\"></script><script type=\"IN/Share\" data-counter=\"right\" data-url=\"" + ofbBiz.GetAppPath(Convert.ToString(Request.QueryString["app_id"])) + "\"  data-onSuccess=\"LIShare\"></script><script type=\"text/javascript\">            function LIShare() { AsycRequest('" + GetNavigationURL(NotifyURL + "FBNotify.aspx?NTYP=LISHARE&PDID=" + oAppProduct.DID + "&NDID=" + _sNotifierDID, true) + "');  }</script>";
                                    if (!oAppProduct.ProductCategory.Equals("WebHutColl."))
                                    {

                                        litHeadBannerCount.Text = GetHeadBannerURL(oAppProduct.DID);
                                        // Get the HTML to be shown

                                        string HTML = oAppProduct.ProductHTML;

                                        //Get Share Button for this Product

                                        if (oAppProduct.CommentsWidgetAdded.Equals(TRUE))
                                        {
                                            addCOMMENT = HTML.Replace("CommBox", CommentBox);
                                        }
                                        else
                                        {
                                            addCOMMENT = HTML.Replace("CommBox", "");
                                        }

                                        if (oAppProduct.ShareWidgetAdded.Equals(TRUE))
                                        {
                                            addSHARE = addCOMMENT.Replace("ShButton", ShareButton);
                                        }
                                        else
                                        {
                                            addSHARE = addCOMMENT.Replace("ShButton", "");
                                        }
                                        if (oAppProduct.TwitterWidgetAdded.Equals(TRUE))
                                        {
                                            addTwitter = addSHARE.Replace("TwButton", TwitterButton);
                                        }
                                        else
                                        {
                                            addTwitter = addSHARE.Replace("TwButton", string.Empty);
                                        }

                                        if (ocanvBiz.IsConfigForSweepstakes(oAppProduct.AppConfigDID))
                                        {
                                            if (oAppProduct.ReccWidgetAdded.Equals(TRUE))
                                            {
                                                addPOST = addTwitter.Replace("ReButton", InviteButton);
                                            }
                                            else
                                            {
                                                addPOST = addTwitter.Replace("ReButton", "");
                                            }
                                            //if HTML contains LIKE
                                            addEntry = addPOST.Replace("Entry", EntryFormPlug);

                                            if (string.IsNullOrEmpty(oAppProduct.AppCaption))
                                            {
                                                addCaption = addEntry.Replace("Caption", "");
                                            }
                                            else
                                            {
                                                addCaption = addEntry.Replace("Caption", oAppProduct.AppCaption);
                                            }

                                            if (oAppProduct.InquiryWidgetAdded.Equals(TRUE))
                                            {
                                                addLead = addCaption.Replace("Lead", LeadPlugin);
                                            }
                                            else
                                            {
                                                addLead = addCaption.Replace("Lead", "");
                                            }

                                            if (oAppProduct.LikeWidgetAdded.Equals(TRUE))
                                            {
                                                addLIKE = addLead.Replace("Like", LikePlugin);
                                            }
                                            else
                                            {
                                                addLIKE = addLead.Replace("Like", "");
                                            }

                                            litAppHTML.Text = addLIKE;
                                            hdnStatus.Value = "HIDE";
                                            apppathLink.Visible = false;
                                        }
                                        else
                                        {

                                            if (oAppProduct.ReccWidgetAdded.Equals(TRUE))
                                            {
                                                addPOST = addTwitter.Replace("ReButton", RecommendButton);
                                            }
                                            else
                                            {
                                                addPOST = addTwitter.Replace("ReButton", "");
                                            }

                                            if (oAppProduct.LikeWidgetAdded.Equals(TRUE))
                                            {
                                                addLIKE = addPOST.Replace("Like", LikePlugin);
                                            }
                                            else
                                            {
                                                addLIKE = addPOST.Replace("Like", "");
                                            }

                                            //if HTML contains LIKE
                                            addEntry = addLIKE.Replace("Entry", EntryFormPlug);

                                            if (oAppProduct.InquiryWidgetAdded.Equals(TRUE))
                                            {
                                                addLead = addEntry.Replace("Lead", LeadPlugin);
                                            }
                                            else
                                            {
                                                addLead = addEntry.Replace("Lead", "");
                                            }

                                            if (string.IsNullOrEmpty(oAppProduct.AppCaption))
                                            {
                                                addCaption = addLead.Replace("Caption", "");
                                            }
                                            else
                                            {
                                                addCaption = addLead.Replace("Caption", oAppProduct.AppCaption);
                                            }
                                            string addPrint = addCaption.Replace("Print", PrintButton);
                                            string addEmail = addPrint.Replace("Email", EmailButton);
                                            addTwitter = addEmail.Replace("TwButton", TwitterButton);
                                            litAppHTML.Text = addEmail;
                                            hdnStatus.Value = "HIDE";
                                            apppathLink.Visible = false;
                                        }
                                    }
                                    else
                                    {

                                        pageToLoad = "index.html";

                                        SiteID = fbBizProc.GetSiteIDForConfig(Convert.ToString(QSVars["ADID"]));
                                        SessionData.Config = new AppConfiguration();
                                        SessionData.Config.SSiteID = SiteID;
                                        TemplateID = fbBizProc.GetTemplateIDForConfig(Convert.ToString(QSVars["ADID"]));

                                        hdnPageToLoad.Value = pageToLoad;
                                        StreamReader streamReader = new StreamReader(Server.MapPath("Sites\\Final\\" + SiteID + "\\" + pageToLoad));
                                        string text = streamReader.ReadToEnd();
                                        streamReader.Close();

                                        //check for DirtyPage
                                        string Query = "select DirtyPage from Sites where SiteId=" + SiteID;

                                        DataSet oDataSet = new DataSet();
                                        SqlHelper.FillDataset(ConfigurationSettings.AppSettings["SoConn"].ToString(), CommandType.Text, Query, oDataSet, new string[] { "SiteDetails" });

                                        string isDirty = Convert.ToString(oDataSet.Tables["SiteDetails"].Rows[0]["DirtyPage"]);

                                        if (isDirty.Equals("Y"))
                                        {
                                            text = text.Replace("<img class=\"dynamic\" src=\"images/SNR_facebook.png\">", ShareButton);

                                            text = text.Replace("<img class=\"dynamic\" src=\"images/SNR_recommend.png\">", RecommendButton);

                                            text = text.Replace("<img class=\"dynamic\" src=\"images/fb-like-button.png\">", LikePlugin);

                                            text = text.Replace("<img class=\"dynamic\" src=\"images/SNR_twitter.png\">", TwitterButton);
                                            text = text.Replace("<img class=\"dynamic\" src=\"images/SNR_linkedIn.png\">", LinkedInButton);

                                            if (TemplateID == 11)
                                            {
                                                text = text.Replace("<img class=\"ActionImg\" src=\"images/email.png\">", EmailButton);
                                                text = text.Replace("<img class=\"ActionImg\" src=\"images/print.png\">", PrintButton);
                                            }
                                        }
                                        else
                                        {
                                            text = text.Replace("<img class=\"dynamic\" src=\"images/SNR_facebook.png\" />", ShareButton);

                                            text = text.Replace("<img class=\"dynamic\" src=\"images/SNR_recommend.png\" />", RecommendButton);

                                            text = text.Replace("<img class=\"dynamic\" src=\"images/fb-like-button.png\" />", LikePlugin);

                                            text = text.Replace("<img class=\"dynamic\" src=\"images/SNR_twitter.png\" />", TwitterButton);
                                            text = text.Replace("<img class=\"dynamic\" src=\"images/SNR_linkedIn.png\">", LinkedInButton);
                                            if (TemplateID == 11)
                                            {
                                                text = text.Replace("<img class=\"ActionImg\" src=\"Images/email.png\">", EmailButton);
                                                text = text.Replace("<img class=\"ActionImg\" src=\"Images/print.png\">", PrintButton);
                                            }
                                        }

                                        //fix all Image tags
                                        string imagesReplaced = text.Replace("images", "images1/" + SiteID);

                                        String style;

                                        if (TemplateID == 12)
                                        {
                                            style = "/CSS/RStore_style.css";
                                            SessionData.PrefData.TemplateID1 = TemplateID;
                                        }
                                        else if (TemplateID == 13)
                                        {
                                            style = "/CSS/FabrikStyle.css";
                                            popupContact.Visible = false;
                                            SessionData.PrefData.TemplateID1 = TemplateID;
                                        }
                                        else if (TemplateID == 11)
                                        {
                                            style = "/CSS/CouponsStyle.css";
                                            popupContact.Visible = false;
                                            SessionData.PrefData.TemplateID1 = TemplateID;
                                        }
                                        else if (TemplateID == 14)
                                        {
                                            style = "/CSS/realestate_styles.css";
                                            SessionData.PrefData.TemplateID1 = TemplateID;

                                        }
                                        else if (TemplateID == 16)
                                        {
                                            style = "/CSS/Restaurantstyle.css";
                                            SessionData.PrefData.TemplateID1 = TemplateID;

                                        }
                                        else if (TemplateID == 17)
                                        {
                                            style = "/CSS/Educationalstyle.css";
                                            SessionData.PrefData.TemplateID1 = TemplateID;

                                        }
                                        else
                                        {
                                            style = "/CSS/PFstyle.css";
                                            SessionData.PrefData.TemplateID1 = TemplateID;

                                        }

                                        //get all the Images, Styles in
                                        System.IO.StreamReader StreamReader1 =
            new System.IO.StreamReader(Server.MapPath("./Sites/Final/" + SiteID + style));
                                        string ReadStyle = StreamReader1.ReadToEnd();
                                        StreamReader1.Close();

                                        if (TemplateID == 14)
                                        {
                                            HtmlLink linking = Page.FindControl("facebookIDStyleSheet") as HtmlLink;
                                            linking.Href = "./Sites/Final/" + SiteID + style;
                                        }

                                        System.IO.StreamReader StreamReader2 =
            new System.IO.StreamReader(Server.MapPath("./ScriptsSonetReach/Facebookstyles.css"));
                                        string CleanStyle = StreamReader2.ReadToEnd();
                                        CleanStyle = string.Empty;
                                        StreamReader2.Close();

                                        System.IO.StreamWriter StreamWriter2 =
                        new System.IO.StreamWriter(Server.MapPath("./ScriptsSonetReach/Facebookstyles.css"));
                                        StreamWriter2.WriteLine(CleanStyle);
                                        StreamWriter2.Close();

                                        System.IO.StreamWriter StreamWriter1 =
                        new System.IO.StreamWriter(Server.MapPath("./ScriptsSonetReach/Facebookstyles.css"));
                                        StreamWriter1.WriteLine(ReadStyle);
                                        StreamWriter1.Close();

                                        ////saranya

                                        //System.IO.StreamReader sr = new System.IO.StreamReader(Server.MapPath("./ScriptsSonetReach/Facebookstyles.css"));
                                        //String fileContents = sr.ReadToEnd();
                                        //sr.Close();

                                        //System.IO.StreamWriter sw = new System.IO.StreamWriter(Server.MapPath("./ScriptsSonetReach/Facebookstyles.css"));
                                        //fileContents = fileContents.Replace("images", "images1/" + SiteID + "");
                                        //sw.WriteLine(fileContents);
                                        //sw.Close();

                                        ///NOW process all the images
                                        string imagePath = Server.MapPath("./Sites/Final/" + SiteID + "/Images/");
                                        string[] files = System.IO.Directory.GetFiles(imagePath);

                                        if (!Directory.Exists(Server.MapPath("./Images1/" + SiteID)))
                                        {
                                            Directory.CreateDirectory(Server.MapPath("./Images1/" + SiteID));
                                        }

                                        foreach (string file in files)
                                        {
                                            if (!System.IO.File.Exists(Server.MapPath("./Images1/" + SiteID + "/" + System.IO.Path.GetFileName(file))))
                                            {
                                                System.IO.File.Copy(file, System.IO.Path.Combine(Server.MapPath("./Images1/" + SiteID), System.IO.Path.GetFileName(file)));
                                            }
                                        }
                                        LoadComplete = true;

                                        litAppHTML.Text = imagesReplaced;

                                        if (TemplateID == 13)
                                        {
                                            litAppHTML.Text = litAppHTML.Text.Replace("<link href=\"CSS/FabrikStyle.css\" rel=\"stylesheet\" type=\"text/css\">", "");
                                        }
                                        else if (TemplateID == 11)
                                        {
                                            litAppHTML.Text = litAppHTML.Text.Replace("<link href=\"CSS/CouponsStyle.css\" rel=\"stylesheet\" type=\"text/css\" />", "");
                                        }
                                        backgroundPopup.Visible = false;
                                    }

                                }
                                else if (ofbBiz.IsSweepstakesAppModel(QSVars["ADID"].ToString()) == "SWEEPSTAKES") // Check if Sweepstake Appmodal
                                {
                                    if (ofbBiz.IsSweepstakesWinnerDay(QSVars["ADID"].ToString()))// Check if Sweepstake Date is today, redirect to Show Winners
                                    {
                                        Response.Redirect("SweepstakesWinners.aspx?ADID=" + Convert.ToString(QSVars["ADID"]), false);
                                    }
                                    else
                                    {
                                        string Enddate = ofbBiz.GetSweepstakesEndDate(QSVars["ADID"].ToString());
                                        if (!string.IsNullOrEmpty(Enddate))
                                        {
                                            DateTime sd = DateTime.Parse(Enddate);
                                            Enddate = sd.ToString("dd/M/yyyy");
                                        }
                                        //litAppHTML.Text = "Sweepstakes Contest is over. Results will be shown on ...";
                                        apppathLink.InnerText = "Sweepstakes Contest is over. Winners will be announced on " + Enddate;
                                        popupContact.Style.Add("margin-left", "250px");
                                    }

                                }
                                else
                                {
                                    AppExpired.Visible = true;
                                    litAppHTML.Text = "";
                                    popupContact.Visible = false;
                                }
                            }
                            else
                            {
                                if (ofbBiz.IsLikeGatewayAdded(QSVars["ADID"].ToString()))
                                {
                                    //means app page is liked and now user shud be shown app
                                    if (QSVars["liked"].Equals("true"))
                                    {
                                        if (!ofbBiz.IsConfigurationExpired(QSVars["ADID"].ToString()))
                                        {
                                            //populate the AppProduct encapsulation based on app that is loaded
                                            AppProduct oAppProduct = new AppProduct();
                                            FaceBook facebook = new FaceBook();

                                            oAppProduct = ofbBiz.GetActiveAppProduct(osonetpie, QSVars["ADID"].ToString());
                                            litHeadBannerCount.Text = GetHeadBannerURL(oAppProduct.DID);
                                            // Get the HTML to be shown

                                            string HTML = oAppProduct.ProductHTML;

                                            //Get Custom Tab name
                                            string CustTabNAme = fbBizProc.GetCustomTabName(Session["AppID"].ToString());

                                            //Get Share Button for this Product
                                            string CommentBox = GetCommentPlugin(oAppProduct.DID, oAppProduct.ProductName, oAppProduct.ProductLogo, oAppProduct.ProductShortDesc, QSVars["app_id"].ToString(), fbBizProc.GetAppPagePath(Convert.ToString(QSVars["app_id"])));
                                            string ShareButton = GetShareButton(oAppProduct.DID, oAppProduct.ProductName, oAppProduct.ProductLogo, oAppProduct.ProductShortDesc, QSVars["app_id"].ToString(), CustTabNAme);
                                            string InviteButton = GetInviteButton(oAppProduct.DID, oAppProduct.ProductName, oAppProduct.ProductLogo, oAppProduct.ProductShortDesc, QSVars["app_id"].ToString());
                                            string RecommendButton = GetRecommendButton(oAppProduct.DID, oAppProduct.ProductName, oAppProduct.ProductLogo, oAppProduct.ProductShortDesc, QSVars["app_id"].ToString());
                                            string LikePlugin = GetLikePlugin(oAppProduct.DID, oAppProduct.ProductName, oAppProduct.ProductLogo, oAppProduct.ProductShortDesc, QSVars["app_id"].ToString());
                                            string EntryFormPlug = GetEntryForm(oAppProduct.DID, oAppProduct.ProductName, oAppProduct.ProductLogo, oAppProduct.ProductShortDesc, QSVars["ADID"].ToString(), QSVars["user_id"].ToString());
                                            string LeadPlugin = GetLeadButton(oAppProduct.DID, oAppProduct.ProductName, oAppProduct.ProductLogo, oAppProduct.ProductShortDesc, QSVars["app_id"].ToString());
                                            string PrintButton = GetPrint(oAppProduct.DID, oAppProduct.ProductName, oAppProduct.ProductLogo, oAppProduct.ProductShortDesc, QSVars["app_id"].ToString());
                                            string EmailButton = GetEmail(oAppProduct.DID, oAppProduct.ProductName, oAppProduct.ProductLogo, oAppProduct.ProductShortDesc, QSVars["app_id"].ToString());
                                            string TwitterButton = GetTwitterShareURL(oAppProduct.DID, oAppProduct.ProductName, oAppProduct.ProductLogo, oAppProduct.ProductShortDesc, QSVars["app_id"].ToString());
                                            if (oAppProduct.CommentsWidgetAdded.Equals(TRUE))
                                            {
                                                addCOMMENT = HTML.Replace("CommBox", CommentBox);
                                            }
                                            else
                                            {
                                                addCOMMENT = HTML.Replace("CommBox", "");
                                            }

                                            if (oAppProduct.ShareWidgetAdded.Equals(TRUE))
                                            {
                                                addSHARE = addCOMMENT.Replace("ShButton", ShareButton);
                                            }
                                            else
                                            {
                                                addSHARE = addCOMMENT.Replace("ShButton", "");
                                            }

                                            if (oAppProduct.TwitterWidgetAdded.Equals(TRUE))
                                            {
                                                addTwitter = addSHARE.Replace("TwButton", TwitterButton);
                                            }
                                            else
                                            {
                                                addTwitter = addSHARE.Replace("TwButton", string.Empty);
                                            }

                                            if (ocanvBiz.IsConfigForSweepstakes(oAppProduct.AppConfigDID))
                                            {
                                                if (oAppProduct.ReccWidgetAdded.Equals(TRUE))
                                                {
                                                    addPOST = addTwitter.Replace("ReButton", InviteButton);
                                                }
                                                else
                                                {
                                                    addPOST = addTwitter.Replace("ReButton", "");
                                                }
                                                //if HTML contains LIKE
                                                addEntry = addPOST.Replace("Entry", EntryFormPlug);

                                                if (string.IsNullOrEmpty(oAppProduct.AppCaption))
                                                {
                                                    addCaption = addEntry.Replace("Caption", "");
                                                }
                                                else
                                                {
                                                    addCaption = addEntry.Replace("Caption", oAppProduct.AppCaption);
                                                }

                                                if (oAppProduct.InquiryWidgetAdded.Equals(TRUE))
                                                {
                                                    addLead = addCaption.Replace("Lead", LeadPlugin);
                                                }
                                                else
                                                {
                                                    addLead = addCaption.Replace("Lead", "");
                                                }

                                                if (oAppProduct.LikeWidgetAdded.Equals(TRUE))
                                                {
                                                    addLIKE = addLead.Replace("Like", LikePlugin);
                                                }
                                                else
                                                {
                                                    addLIKE = addLead.Replace("Like", "");
                                                }

                                                litAppHTML.Text = addLIKE;
                                                hdnStatus.Value = "HIDE";
                                                apppathLink.Visible = false;
                                            }
                                            else
                                            {

                                                if (oAppProduct.ReccWidgetAdded.Equals(TRUE))
                                                {
                                                    addPOST = addTwitter.Replace("ReButton", RecommendButton);
                                                }
                                                else
                                                {
                                                    addPOST = addTwitter.Replace("ReButton", "");
                                                }

                                                if (oAppProduct.LikeWidgetAdded.Equals(TRUE))
                                                {
                                                    addLIKE = addPOST.Replace("Like", LikePlugin);
                                                }
                                                else
                                                {
                                                    addLIKE = addPOST.Replace("Like", "");
                                                }

                                                if (oAppProduct.InquiryWidgetAdded.Equals(TRUE))
                                                {
                                                    addLead = addLIKE.Replace("Lead", LeadPlugin);
                                                }
                                                else
                                                {
                                                    addLead = addLIKE.Replace("Lead", "");
                                                }

                                                if (string.IsNullOrEmpty(oAppProduct.AppCaption))
                                                {
                                                    addCaption = addLead.Replace("Caption", "");
                                                }
                                                else
                                                {
                                                    addCaption = addLead.Replace("Caption", oAppProduct.AppCaption);
                                                }
                                                string addPrint = addCaption.Replace("Print", PrintButton);
                                                string addEmail = addPrint.Replace("Email", EmailButton);
                                                litAppHTML.Text = addEmail;
                                                hdnStatus.Value = "HIDE";
                                                apppathLink.Visible = false;
                                            }
                                        }
                                        else if (ofbBiz.IsSweepstakesAppModel(QSVars["ADID"].ToString()) == "SWEEPSTAKES") // Check if Sweepstake Appmodal
                                        {
                                            if (ofbBiz.IsSweepstakesWinnerDay(QSVars["ADID"].ToString()))// Check if Sweepstake Date is today, redirect to Show Winners
                                            {
                                                Response.Redirect("SweepstakesWinners.aspx?ADID=" + Convert.ToString(QSVars["ADID"]), false);
                                            }
                                            else
                                            {
                                                string Enddate = ofbBiz.GetSweepstakesEndDate(QSVars["ADID"].ToString());
                                                if (!string.IsNullOrEmpty(Enddate))
                                                {
                                                    DateTime sd = DateTime.Parse(Enddate);
                                                    Enddate = sd.ToString("dd/M/yyyy");
                                                }
                                                //litAppHTML.Text = "Sweepstakes Contest is over. Results will be shown on ...";
                                                apppathLink.InnerText = "Sweepstakes Contest is over. Winners will be announced on " + Enddate;
                                                popupContact.Style.Add("margin-left", "250px");
                                            }

                                        }
                                        else
                                        {
                                            AppExpired.Visible = true;
                                            litAppHTML.Text = "";
                                            popupContact.Visible = false;
                                        }
                                    }
                                    else
                                    {
                                        if (!QSVars["admin"].Equals("true"))
                                        {
                                            litAppHTML.Text = " <img id=\"imgLGateway\" src=\"Images/like_us_to_proceed.jpg\"/>";
                                            popupContact.Visible = false;
                                            backgroundPopup.Visible = false;
                                        }
                                        else
                                        {
                                            if (!ofbBiz.IsConfigurationExpired(QSVars["ADID"].ToString()))
                                            {
                                                //populate the AppProduct encapsulation based on app that is loaded
                                                AppProduct oAppProduct = new AppProduct();
                                                FaceBook facebook = new FaceBook();

                                                oAppProduct = ofbBiz.GetActiveAppProduct(osonetpie, QSVars["ADID"].ToString());
                                                litHeadBannerCount.Text = GetHeadBannerURL(oAppProduct.DID);
                                                // Get the HTML to be shown

                                                string HTML = oAppProduct.ProductHTML;

                                                //Get Custom Tab name
                                                string CustTabNAme = fbBizProc.GetCustomTabName(Session["AppID"].ToString());

                                                //Get Share Button for this Product
                                                string CommentBox = GetCommentPlugin(oAppProduct.DID, oAppProduct.ProductName, oAppProduct.ProductLogo, oAppProduct.ProductShortDesc, QSVars["app_id"].ToString(), fbBizProc.GetAppPagePath(Convert.ToString(QSVars["app_id"])));
                                                string ShareButton = GetShareButton(oAppProduct.DID, oAppProduct.ProductName, oAppProduct.ProductLogo, oAppProduct.ProductShortDesc, QSVars["app_id"].ToString(), CustTabNAme);
                                                string InviteButton = GetInviteButton(oAppProduct.DID, oAppProduct.ProductName, oAppProduct.ProductLogo, oAppProduct.ProductShortDesc, QSVars["app_id"].ToString());
                                                string RecommendButton = GetRecommendButton(oAppProduct.DID, oAppProduct.ProductName, oAppProduct.ProductLogo, oAppProduct.ProductShortDesc, QSVars["app_id"].ToString());
                                                string LikePlugin = GetLikePlugin(oAppProduct.DID, oAppProduct.ProductName, oAppProduct.ProductLogo, oAppProduct.ProductShortDesc, QSVars["app_id"].ToString());
                                                string EntryFormPlug = GetEntryForm(oAppProduct.DID, oAppProduct.ProductName, oAppProduct.ProductLogo, oAppProduct.ProductShortDesc, QSVars["ADID"].ToString(), QSVars["user_id"].ToString());
                                                string LeadPlugin = GetLeadButton(oAppProduct.DID, oAppProduct.ProductName, oAppProduct.ProductLogo, oAppProduct.ProductShortDesc, QSVars["app_id"].ToString());
                                                string PrintButton = GetPrint(oAppProduct.DID, oAppProduct.ProductName, oAppProduct.ProductLogo, oAppProduct.ProductShortDesc, QSVars["app_id"].ToString());
                                                string EmailButton = GetEmail(oAppProduct.DID, oAppProduct.ProductName, oAppProduct.ProductLogo, oAppProduct.ProductShortDesc, QSVars["app_id"].ToString());
                                                string TwitterButton = GetTwitterShareURL(oAppProduct.DID, oAppProduct.ProductName, oAppProduct.ProductLogo, oAppProduct.ProductShortDesc, QSVars["app_id"].ToString());
                                                if (oAppProduct.CommentsWidgetAdded.Equals(TRUE))
                                                {
                                                    addCOMMENT = HTML.Replace("CommBox", CommentBox);
                                                }
                                                else
                                                {
                                                    addCOMMENT = HTML.Replace("CommBox", "");
                                                }

                                                if (oAppProduct.ShareWidgetAdded.Equals(TRUE))
                                                {
                                                    addSHARE = addCOMMENT.Replace("ShButton", ShareButton);
                                                }
                                                else
                                                {
                                                    addSHARE = addCOMMENT.Replace("ShButton", "");
                                                }

                                                if (oAppProduct.TwitterWidgetAdded.Equals(TRUE))
                                                {
                                                    addTwitter = addSHARE.Replace("TwButton", TwitterButton);
                                                }
                                                else
                                                {
                                                    addTwitter = addSHARE.Replace("TwButton", string.Empty);
                                                }

                                                if (ocanvBiz.IsConfigForSweepstakes(oAppProduct.AppConfigDID))
                                                {
                                                    if (oAppProduct.ReccWidgetAdded.Equals(TRUE))
                                                    {
                                                        addPOST = addTwitter.Replace("ReButton", InviteButton);
                                                    }
                                                    else
                                                    {
                                                        addPOST = addTwitter.Replace("ReButton", "");
                                                    }
                                                    //if HTML contains LIKE
                                                    addEntry = addPOST.Replace("Entry", EntryFormPlug);

                                                    if (string.IsNullOrEmpty(oAppProduct.AppCaption))
                                                    {
                                                        addCaption = addEntry.Replace("Caption", "");
                                                    }
                                                    else
                                                    {
                                                        addCaption = addEntry.Replace("Caption", oAppProduct.AppCaption);
                                                    }

                                                    if (oAppProduct.InquiryWidgetAdded.Equals(TRUE))
                                                    {
                                                        addLead = addCaption.Replace("Lead", LeadPlugin);
                                                    }
                                                    else
                                                    {
                                                        addLead = addCaption.Replace("Lead", "");
                                                    }

                                                    if (oAppProduct.LikeWidgetAdded.Equals(TRUE))
                                                    {
                                                        addLIKE = addLead.Replace("Like", LikePlugin);
                                                    }
                                                    else
                                                    {
                                                        addLIKE = addLead.Replace("Like", "");
                                                    }

                                                    litAppHTML.Text = addLIKE;
                                                    hdnStatus.Value = "HIDE";
                                                    apppathLink.Visible = false;
                                                }
                                                else
                                                {

                                                    if (oAppProduct.ReccWidgetAdded.Equals(TRUE))
                                                    {
                                                        addPOST = addTwitter.Replace("ReButton", RecommendButton);
                                                    }
                                                    else
                                                    {
                                                        addPOST = addTwitter.Replace("ReButton", "");
                                                    }

                                                    if (oAppProduct.LikeWidgetAdded.Equals(TRUE))
                                                    {
                                                        addLIKE = addPOST.Replace("Like", LikePlugin);
                                                    }
                                                    else
                                                    {
                                                        addLIKE = addPOST.Replace("Like", "");
                                                    }

                                                    if (oAppProduct.InquiryWidgetAdded.Equals(TRUE))
                                                    {
                                                        addLead = addLIKE.Replace("Lead", LeadPlugin);
                                                    }
                                                    else
                                                    {
                                                        addLead = addLIKE.Replace("Lead", "");
                                                    }

                                                    if (string.IsNullOrEmpty(oAppProduct.AppCaption))
                                                    {
                                                        addCaption = addLead.Replace("Caption", "");
                                                    }
                                                    else
                                                    {
                                                        addCaption = addLead.Replace("Caption", oAppProduct.AppCaption);
                                                    }
                                                    string addPrint = addCaption.Replace("Print", PrintButton);
                                                    string addEmail = addPrint.Replace("Email", EmailButton);
                                                    litAppHTML.Text = addEmail;
                                                    hdnStatus.Value = "HIDE";
                                                    apppathLink.Visible = false;
                                                }
                                            }
                                            else if (ofbBiz.IsSweepstakesAppModel(QSVars["ADID"].ToString()) == "SWEEPSTAKES") // Check if Sweepstake Appmodal
                                            {
                                                if (ofbBiz.IsSweepstakesWinnerDay(QSVars["ADID"].ToString()))// Check if Sweepstake Date is today, redirect to Show Winners
                                                {
                                                    Response.Redirect("SweepstakesWinners.aspx?ADID=" + Convert.ToString(QSVars["ADID"]), false);
                                                }
                                                else
                                                {
                                                    string Enddate = ofbBiz.GetSweepstakesEndDate(QSVars["ADID"].ToString());
                                                    if (!string.IsNullOrEmpty(Enddate))
                                                    {
                                                        DateTime sd = DateTime.Parse(Enddate);
                                                        Enddate = sd.ToString("dd/M/yyyy");
                                                    }
                                                    //litAppHTML.Text = "Sweepstakes Contest is over. Results will be shown on ...";
                                                    apppathLink.InnerText = "Sweepstakes Contest is over. Winners will be announced on " + Enddate;
                                                    popupContact.Style.Add("margin-left", "250px");
                                                }

                                            }
                                            else
                                            {
                                                AppExpired.Visible = true;
                                                litAppHTML.Text = "";
                                                popupContact.Visible = false;
                                            }
                                        }
                                    }
                                }
                                else
                                {
                                    if (!ofbBiz.IsConfigurationExpired(QSVars["ADID"].ToString()))
                                    {
                                        //populate the AppProduct encapsulation based on app that is loaded
                                        AppProduct oAppProduct = new AppProduct();
                                        oAppProduct.DID = ofbBiz.GetProductDID(Convert.ToString(QSVars["ADID"]));
                                        FaceBook facebook = new FaceBook();
                                        //Get Custom Tab name
                                        string CustTabNAme = fbBizProc.GetCustomTabName(Session["AppID"].ToString());
                                        string CommentBox = GetCommentPlugin(oAppProduct.DID, oAppProduct.ProductName, oAppProduct.ProductLogo, oAppProduct.ProductShortDesc, QSVars["app_id"].ToString(), fbBizProc.GetAppPagePath(Convert.ToString(QSVars["app_id"])));
                                        string ShareButton = GetShareButton(oAppProduct.DID, oAppProduct.ProductName, oAppProduct.ProductLogo, oAppProduct.ProductShortDesc, QSVars["app_id"].ToString(), CustTabNAme);
                                        string InviteButton = GetInviteButton(oAppProduct.DID, oAppProduct.ProductName, oAppProduct.ProductLogo, oAppProduct.ProductShortDesc, QSVars["app_id"].ToString());
                                        string RecommendButton = GetRecommendButton(oAppProduct.DID, oAppProduct.ProductName, oAppProduct.ProductLogo, oAppProduct.ProductShortDesc, QSVars["app_id"].ToString());
                                        string LikePlugin = GetLikePlugin(oAppProduct.DID, oAppProduct.ProductName, oAppProduct.ProductLogo, oAppProduct.ProductShortDesc, QSVars["app_id"].ToString());
                                        string EntryFormPlug = GetEntryForm(oAppProduct.DID, oAppProduct.ProductName, oAppProduct.ProductLogo, oAppProduct.ProductShortDesc, QSVars["ADID"].ToString(), QSVars["user_id"].ToString());
                                        string LeadPlugin = GetLeadButton(oAppProduct.DID, oAppProduct.ProductName, oAppProduct.ProductLogo, oAppProduct.ProductShortDesc, QSVars["app_id"].ToString());
                                        string PrintButton = GetPrint(oAppProduct.DID, oAppProduct.ProductName, oAppProduct.ProductLogo, oAppProduct.ProductShortDesc, QSVars["app_id"].ToString());
                                        string EmailButton = GetEmail(oAppProduct.DID, oAppProduct.ProductName, oAppProduct.ProductLogo, oAppProduct.ProductShortDesc, QSVars["app_id"].ToString());
                                        string TwitterButton = GetTwitterShareURL(oAppProduct.DID, oAppProduct.ProductName, oAppProduct.ProductLogo, oAppProduct.ProductShortDesc, QSVars["app_id"].ToString());
                                        string LinkedInButton = "<script src=\"//platform.linkedin.com/in.js\" type=\"text/javascript\"></script><script type=\"IN/Share\" data-url=\"" + ofbBiz.GetAppPath(Convert.ToString(Request.QueryString["app_id"])) + "\"  data-onSuccess=\"LIShare\"></script><script type=\"text/javascript\">            function LIShare() { AsycRequest('" + GetNavigationURL(NotifyURL + "FBNotify.aspx?NTYP=LISHARE&PDID=" + oAppProduct.DID + "&NDID=" + _sNotifierDID, true) + "');  }</script>";
                                        oAppProduct = ofbBiz.GetActiveAppProduct(osonetpie, QSVars["ADID"].ToString());
                                        if (!oAppProduct.ProductCategory.Equals("WebHutColl."))
                                        {

                                            litHeadBannerCount.Text = GetHeadBannerURL(oAppProduct.DID);
                                            // Get the HTML to be shown

                                            string HTML = oAppProduct.ProductHTML;

                                            //Get Share Button for this Product

                                            if (oAppProduct.CommentsWidgetAdded.Equals(TRUE))
                                            {
                                                addCOMMENT = HTML.Replace("CommBox", CommentBox);
                                            }
                                            else
                                            {
                                                addCOMMENT = HTML.Replace("CommBox", "");
                                            }

                                            if (oAppProduct.ShareWidgetAdded.Equals(TRUE))
                                            {
                                                addSHARE = addCOMMENT.Replace("ShButton", ShareButton);
                                            }
                                            else
                                            {
                                                addSHARE = addCOMMENT.Replace("ShButton", "");
                                            }
                                            if (oAppProduct.TwitterWidgetAdded.Equals(TRUE))
                                            {
                                                addTwitter = addSHARE.Replace("TwButton", TwitterButton);
                                            }
                                            else
                                            {
                                                addTwitter = addSHARE.Replace("TwButton", string.Empty);
                                            }

                                            if (ocanvBiz.IsConfigForSweepstakes(oAppProduct.AppConfigDID))
                                            {
                                                if (oAppProduct.ReccWidgetAdded.Equals(TRUE))
                                                {
                                                    addPOST = addTwitter.Replace("ReButton", InviteButton);
                                                }
                                                else
                                                {
                                                    addPOST = addTwitter.Replace("ReButton", "");
                                                }
                                                //if HTML contains LIKE
                                                addEntry = addPOST.Replace("Entry", EntryFormPlug);

                                                if (string.IsNullOrEmpty(oAppProduct.AppCaption))
                                                {
                                                    addCaption = addEntry.Replace("Caption", "");
                                                }
                                                else
                                                {
                                                    addCaption = addEntry.Replace("Caption", oAppProduct.AppCaption);
                                                }

                                                if (oAppProduct.InquiryWidgetAdded.Equals(TRUE))
                                                {
                                                    addLead = addCaption.Replace("Lead", LeadPlugin);
                                                }
                                                else
                                                {
                                                    addLead = addCaption.Replace("Lead", "");
                                                }

                                                if (oAppProduct.LikeWidgetAdded.Equals(TRUE))
                                                {
                                                    addLIKE = addLead.Replace("Like", LikePlugin);
                                                }
                                                else
                                                {
                                                    addLIKE = addLead.Replace("Like", "");
                                                }

                                                litAppHTML.Text = addLIKE;
                                                hdnStatus.Value = "HIDE";
                                                apppathLink.Visible = false;
                                            }
                                            else
                                            {

                                                if (oAppProduct.ReccWidgetAdded.Equals(TRUE))
                                                {
                                                    addPOST = addTwitter.Replace("ReButton", RecommendButton);
                                                }
                                                else
                                                {
                                                    addPOST = addTwitter.Replace("ReButton", "");
                                                }

                                                if (oAppProduct.LikeWidgetAdded.Equals(TRUE))
                                                {
                                                    addLIKE = addPOST.Replace("Like", LikePlugin);
                                                }
                                                else
                                                {
                                                    addLIKE = addPOST.Replace("Like", "");
                                                }

                                                //if HTML contains LIKE
                                                addEntry = addLIKE.Replace("Entry", EntryFormPlug);

                                                if (oAppProduct.InquiryWidgetAdded.Equals(TRUE))
                                                {
                                                    addLead = addEntry.Replace("Lead", LeadPlugin);
                                                }
                                                else
                                                {
                                                    addLead = addEntry.Replace("Lead", "");
                                                }

                                                if (string.IsNullOrEmpty(oAppProduct.AppCaption))
                                                {
                                                    addCaption = addLead.Replace("Caption", "");
                                                }
                                                else
                                                {
                                                    addCaption = addLead.Replace("Caption", oAppProduct.AppCaption);
                                                }
                                                string addPrint = addCaption.Replace("Print", PrintButton);
                                                string addEmail = addPrint.Replace("Email", EmailButton);
                                                addTwitter = addEmail.Replace("TwButton", TwitterButton);
                                                litAppHTML.Text = addEmail;
                                                hdnStatus.Value = "HIDE";
                                                apppathLink.Visible = false;
                                            }
                                        }
                                        else
                                        {

                                            pageToLoad = "index.html";

                                            SiteID = fbBizProc.GetSiteIDForConfig(Convert.ToString(QSVars["ADID"]));
                                            SessionData.Config = new AppConfiguration();
                                            SessionData.Config.SSiteID = SiteID;
                                            TemplateID = fbBizProc.GetTemplateIDForConfig(Convert.ToString(QSVars["ADID"]));

                                            hdnPageToLoad.Value = pageToLoad;
                                            StreamReader streamReader = new StreamReader(Server.MapPath("Sites\\Final\\" + SiteID + "\\" + pageToLoad));
                                            string text = streamReader.ReadToEnd();
                                            streamReader.Close();

                                            //check for DirtyPage
                                            string Query = "select DirtyPage from Sites where SiteId=" + SiteID;

                                            DataSet oDataSet = new DataSet();
                                            SqlHelper.FillDataset(ConfigurationSettings.AppSettings["SoConn"].ToString(), CommandType.Text, Query, oDataSet, new string[] { "SiteDetails" });

                                            string isDirty = Convert.ToString(oDataSet.Tables["SiteDetails"].Rows[0]["DirtyPage"]);

                                            if (isDirty.Equals("Y"))
                                            {
                                                text = text.Replace("<img class=\"dynamic\" src=\"images/SNR_facebook.png\">", ShareButton);

                                                text = text.Replace("<img class=\"dynamic\" src=\"images/SNR_recommend.png\">", RecommendButton);

                                                text = text.Replace("<img class=\"dynamic\" src=\"images/fb-like-button.png\">", LikePlugin);

                                                text = text.Replace("<img class=\"dynamic\" src=\"images/SNR_twitter.png\">", TwitterButton);
                                                text = text.Replace("<img class=\"dynamic\" src=\"images/SNR_linkedIn.png\">", LinkedInButton);

                                                if (TemplateID == 11)
                                                {
                                                    text = text.Replace("<img class=\"ActionImg\" src=\"images/email.png\">", EmailButton);
                                                    text = text.Replace("<img class=\"ActionImg\" src=\"images/print.png\">", PrintButton);
                                                }
                                            }
                                            else
                                            {
                                                text = text.Replace("<img class=\"dynamic\" src=\"images/SNR_facebook.png\" />", ShareButton);

                                                text = text.Replace("<img class=\"dynamic\" src=\"images/SNR_recommend.png\" />", RecommendButton);

                                                text = text.Replace("<img class=\"dynamic\" src=\"images/fb-like-button.png\" />", LikePlugin);

                                                text = text.Replace("<img class=\"dynamic\" src=\"images/SNR_twitter.png\" />", TwitterButton);
                                                text = text.Replace("<img class=\"dynamic\" src=\"images/SNR_linkedIn.png\" />", LinkedInButton);
                                                if (TemplateID == 11)
                                                {
                                                    text = text.Replace("<img class=\"ActionImg\" src=\"Images/email.png\">", EmailButton);
                                                    text = text.Replace("<img class=\"ActionImg\" src=\"Images/print.png\">", PrintButton);
                                                }
                                            }

                                            //fix all Image tags
                                            string imagesReplaced = text.Replace("images", "images1/" + SiteID);

                                            String style;

                                            if (TemplateID == 12)
                                            {
                                                style = "/CSS/RStore_style.css";
                                                SessionData.PrefData.TemplateID1 = TemplateID;
                                            }
                                            else if (TemplateID == 13)
                                            {
                                                style = "/CSS/FabrikStyle.css";
                                                popupContact.Visible = false;
                                                SessionData.PrefData.TemplateID1 = TemplateID;
                                            }
                                            else if (TemplateID == 11)
                                            {
                                                style = "/CSS/CouponsStyle.css";
                                                popupContact.Visible = false;
                                                SessionData.PrefData.TemplateID1 = TemplateID;
                                            }
                                            else if (TemplateID == 14)
                                            {
                                                style = "/css/realestate_styles.css";
                                                SessionData.PrefData.TemplateID1 = TemplateID;

                                            }
                                            else if (TemplateID == 16)
                                            {
                                                style = "/CSS/Restaurantstyle.css";
                                                SessionData.PrefData.TemplateID1 = TemplateID;

                                            }
                                            else if (TemplateID == 17)
                                            {
                                                style = "/CSS/Educationalstyle.css";
                                                SessionData.PrefData.TemplateID1 = TemplateID;

                                            }

                                            else
                                            {
                                                style = "/css/PFstyle.css";
                                                SessionData.PrefData.TemplateID1 = TemplateID;

                                            }

                                            //get all the Images, Styles in
                                            System.IO.StreamReader StreamReader1 =
            new System.IO.StreamReader(Server.MapPath("./Sites/Final/" + SiteID + style));
                                            string ReadStyle = StreamReader1.ReadToEnd();
                                            StreamReader1.Close();

                                            if (TemplateID == 14)
                                            {
                                                HtmlLink linking = Page.FindControl("facebookIDStyleSheet") as HtmlLink;
                                                linking.Href = "./Sites/Final/" + SiteID + style;
                                            }

                                            System.IO.StreamReader StreamReader2 =
            new System.IO.StreamReader(Server.MapPath("./ScriptsSonetReach/Facebookstyles.css"));
                                            string CleanStyle = StreamReader2.ReadToEnd();
                                            CleanStyle = string.Empty;
                                            StreamReader2.Close();

                                            System.IO.StreamWriter StreamWriter2 =
                            new System.IO.StreamWriter(Server.MapPath("./ScriptsSonetReach/Facebookstyles.css"));
                                            StreamWriter2.WriteLine(CleanStyle);
                                            StreamWriter2.Close();

                                            System.IO.StreamWriter StreamWriter1 =
                            new System.IO.StreamWriter(Server.MapPath("./ScriptsSonetReach/Facebookstyles.css"));
                                            StreamWriter1.WriteLine(ReadStyle);
                                            StreamWriter1.Close();

                                            ////saranya

                                            //System.IO.StreamReader sr = new System.IO.StreamReader(Server.MapPath("./ScriptsSonetReach/Facebookstyles.css"));
                                            //String fileContents = sr.ReadToEnd();
                                            //sr.Close();

                                            //System.IO.StreamWriter sw = new System.IO.StreamWriter(Server.MapPath("./ScriptsSonetReach/Facebookstyles.css"));
                                            //fileContents = fileContents.Replace("images", "images1/" + SiteID + "");
                                            //sw.WriteLine(fileContents);
                                            //sw.Close();

                                            ///NOW process all the images
                                            string imagePath = Server.MapPath("./Sites/Final/" + SiteID + "/Images/");
                                            string[] files = System.IO.Directory.GetFiles(imagePath);

                                            if (!Directory.Exists(Server.MapPath("./Images1/" + SiteID)))
                                            {
                                                Directory.CreateDirectory(Server.MapPath("./Images1/" + SiteID));
                                            }

                                            foreach (string file in files)
                                            {
                                                if (!System.IO.File.Exists(Server.MapPath("./Images1/" + SiteID + "/" + System.IO.Path.GetFileName(file))))
                                                {
                                                    System.IO.File.Copy(file, System.IO.Path.Combine(Server.MapPath("./Images1/" + SiteID), System.IO.Path.GetFileName(file)));
                                                }
                                            }
                                            LoadComplete = true;

                                            litAppHTML.Text = imagesReplaced;

                                            if (TemplateID == 13)
                                            {
                                                litAppHTML.Text = litAppHTML.Text.Replace("<link href=\"CSS/FabrikStyle.css\" rel=\"stylesheet\" type=\"text/css\">", "");
                                            }
                                            else if (TemplateID == 11)
                                            {
                                                litAppHTML.Text = litAppHTML.Text.Replace("<link href=\"CSS/CouponsStyle.css\" rel=\"stylesheet\" type=\"text/css\" />", "");
                                            }
                                            backgroundPopup.Visible = false;
                                        }
                                    }
                                    else if (ofbBiz.IsSweepstakesAppModel(QSVars["ADID"].ToString()) == "SWEEPSTAKES") // Check if Sweepstake CampaignType
                                    {
                                        if (ofbBiz.IsSweepstakesWinnerDay(QSVars["ADID"].ToString()))// Check if Sweepstake Date is today, redirect to Show Winners
                                        {
                                            Response.Redirect("SweepstakesWinners.aspx?ADID=" + Convert.ToString(QSVars["ADID"]), false);
                                        }
                                        else
                                        {
                                            string Enddate = ofbBiz.GetSweepstakesEndDate(QSVars["ADID"].ToString());
                                            if (!string.IsNullOrEmpty(Enddate))
                                            {
                                                DateTime sd = DateTime.Parse(Enddate);
                                                Enddate = sd.ToString("dd/M/yyyy");
                                            }
                                            //litAppHTML.Text = "Sweepstakes Contest is over. Results will be shown on ...";
                                            apppathLink.InnerText = "Sweepstakes Contest is over. Winners will be announced on " + Enddate;
                                            popupContact.Style.Add("margin-left", "250px");
                                        }

                                    }
                                    else
                                    {
                                        AppExpired.Visible = true;
                                        litAppHTML.Text = "";
                                        popupContact.Visible = false;
                                    }
                                }
                            }
                        }
                        else
                        {
                            if (!ofbBiz.IsConfigurationExpired(QSVars["ADID"].ToString()))
                            {
                                //populate the AppProduct encapsulation based on app that is loaded
                                AppProduct oAppProduct = new AppProduct();
                                FaceBook facebook = new FaceBook();
                                //Get Custom Tab name
                                string CustTabNAme = fbBizProc.GetCustomTabName(Session["AppID"].ToString());
                                string CommentBox = GetCommentPlugin(oAppProduct.DID, oAppProduct.ProductName, oAppProduct.ProductLogo, oAppProduct.ProductShortDesc, QSVars["app_id"].ToString(), fbBizProc.GetAppPagePath(Convert.ToString(QSVars["app_id"])));
                                string ShareButton = GetShareButton(oAppProduct.DID, oAppProduct.ProductName, oAppProduct.ProductLogo, oAppProduct.ProductShortDesc, QSVars["app_id"].ToString(), CustTabNAme);
                                string InviteButton = GetInviteButton(oAppProduct.DID, oAppProduct.ProductName, oAppProduct.ProductLogo, oAppProduct.ProductShortDesc, QSVars["app_id"].ToString());
                                string RecommendButton = GetRecommendButton(oAppProduct.DID, oAppProduct.ProductName, oAppProduct.ProductLogo, oAppProduct.ProductShortDesc, QSVars["app_id"].ToString());
                                string LikePlugin = GetLikePlugin(oAppProduct.DID, oAppProduct.ProductName, oAppProduct.ProductLogo, oAppProduct.ProductShortDesc, QSVars["app_id"].ToString());
                                string EntryFormPlug = GetEntryForm(oAppProduct.DID, oAppProduct.ProductName, oAppProduct.ProductLogo, oAppProduct.ProductShortDesc, QSVars["ADID"].ToString(), QSVars["user_id"].ToString());
                                string LeadPlugin = GetLeadButton(oAppProduct.DID, oAppProduct.ProductName, oAppProduct.ProductLogo, oAppProduct.ProductShortDesc, QSVars["app_id"].ToString());
                                string PrintButton = GetPrint(oAppProduct.DID, oAppProduct.ProductName, oAppProduct.ProductLogo, oAppProduct.ProductShortDesc, QSVars["app_id"].ToString());
                                string EmailButton = GetEmail(oAppProduct.DID, oAppProduct.ProductName, oAppProduct.ProductLogo, oAppProduct.ProductShortDesc, QSVars["app_id"].ToString());
                                string TwitterButton = GetTwitterShareURL(oAppProduct.DID, oAppProduct.ProductName, oAppProduct.ProductLogo, oAppProduct.ProductShortDesc, QSVars["app_id"].ToString());
                                string LinkedInButton = "<script src=\"//platform.linkedin.com/in.js\" type=\"text/javascript\"></script><script type=\"IN/Share\" data-counter=\"right\" data-url=\"" + ofbBiz.GetAppPath(Convert.ToString(Request.QueryString["app_id"])) + "\"  data-onSuccess=\"LIShare\"></script><script type=\"text/javascript\">            function LIShare() { AsycRequest('" + GetNavigationURL(NotifyURL + "FBNotify.aspx?NTYP=LISHARE&PDID=" + oAppProduct.DID + "&NDID=" + _sNotifierDID, true) + "');  }</script>";
                                oAppProduct = ofbBiz.GetActiveAppProduct(osonetpie, QSVars["ADID"].ToString());
                                if (!oAppProduct.ProductCategory.Equals("WebHutColl."))
                                {

                                    litHeadBannerCount.Text = GetHeadBannerURL(oAppProduct.DID);
                                    // Get the HTML to be shown

                                    string HTML = oAppProduct.ProductHTML;

                                    //Get Share Button for this Product

                                    if (oAppProduct.CommentsWidgetAdded.Equals(TRUE))
                                    {
                                        addCOMMENT = HTML.Replace("CommBox", CommentBox);
                                    }
                                    else
                                    {
                                        addCOMMENT = HTML.Replace("CommBox", "");
                                    }

                                    if (oAppProduct.ShareWidgetAdded.Equals(TRUE))
                                    {
                                        addSHARE = addCOMMENT.Replace("ShButton", ShareButton);
                                    }
                                    else
                                    {
                                        addSHARE = addCOMMENT.Replace("ShButton", "");
                                    }
                                    if (oAppProduct.TwitterWidgetAdded.Equals(TRUE))
                                    {
                                        addTwitter = addSHARE.Replace("TwButton", TwitterButton);
                                    }
                                    else
                                    {
                                        addTwitter = addSHARE.Replace("TwButton", string.Empty);
                                    }

                                    if (ocanvBiz.IsConfigForSweepstakes(oAppProduct.AppConfigDID))
                                    {
                                        if (oAppProduct.ReccWidgetAdded.Equals(TRUE))
                                        {
                                            addPOST = addTwitter.Replace("ReButton", InviteButton);
                                        }
                                        else
                                        {
                                            addPOST = addTwitter.Replace("ReButton", "");
                                        }
                                        //if HTML contains LIKE
                                        addEntry = addPOST.Replace("Entry", EntryFormPlug);

                                        if (string.IsNullOrEmpty(oAppProduct.AppCaption))
                                        {
                                            addCaption = addEntry.Replace("Caption", "");
                                        }
                                        else
                                        {
                                            addCaption = addEntry.Replace("Caption", oAppProduct.AppCaption);
                                        }

                                        if (oAppProduct.InquiryWidgetAdded.Equals(TRUE))
                                        {
                                            addLead = addCaption.Replace("Lead", LeadPlugin);
                                        }
                                        else
                                        {
                                            addLead = addCaption.Replace("Lead", "");
                                        }

                                        if (oAppProduct.LikeWidgetAdded.Equals(TRUE))
                                        {
                                            addLIKE = addLead.Replace("Like", LikePlugin);
                                        }
                                        else
                                        {
                                            addLIKE = addLead.Replace("Like", "");
                                        }

                                        litAppHTML.Text = addLIKE;
                                        hdnStatus.Value = "HIDE";
                                        apppathLink.Visible = false;
                                    }
                                    else
                                    {

                                        if (oAppProduct.ReccWidgetAdded.Equals(TRUE))
                                        {
                                            addPOST = addTwitter.Replace("ReButton", RecommendButton);
                                        }
                                        else
                                        {
                                            addPOST = addTwitter.Replace("ReButton", "");
                                        }

                                        if (oAppProduct.LikeWidgetAdded.Equals(TRUE))
                                        {
                                            addLIKE = addPOST.Replace("Like", LikePlugin);
                                        }
                                        else
                                        {
                                            addLIKE = addPOST.Replace("Like", "");
                                        }

                                        //if HTML contains LIKE
                                        addEntry = addLIKE.Replace("Entry", EntryFormPlug);

                                        if (oAppProduct.InquiryWidgetAdded.Equals(TRUE))
                                        {
                                            addLead = addEntry.Replace("Lead", LeadPlugin);
                                        }
                                        else
                                        {
                                            addLead = addEntry.Replace("Lead", "");
                                        }

                                        if (string.IsNullOrEmpty(oAppProduct.AppCaption))
                                        {
                                            addCaption = addLead.Replace("Caption", "");
                                        }
                                        else
                                        {
                                            addCaption = addLead.Replace("Caption", oAppProduct.AppCaption);
                                        }
                                        string addPrint = addCaption.Replace("Print", PrintButton);
                                        string addEmail = addPrint.Replace("Email", EmailButton);
                                        addTwitter = addEmail.Replace("TwButton", TwitterButton);
                                        litAppHTML.Text = addEmail;
                                        hdnStatus.Value = "HIDE";
                                        apppathLink.Visible = false;
                                    }
                                }
                                else
                                {

                                    pageToLoad = "index.html";

                                    SiteID = fbBizProc.GetSiteIDForConfig(Convert.ToString(QSVars["ADID"]));
                                    SessionData.Config = new AppConfiguration();
                                    SessionData.Config.SSiteID = SiteID;
                                    TemplateID = fbBizProc.GetTemplateIDForConfig(Convert.ToString(QSVars["ADID"]));

                                    hdnPageToLoad.Value = pageToLoad;
                                    StreamReader streamReader = new StreamReader(Server.MapPath("Sites\\Final\\" + SiteID + "\\" + pageToLoad));
                                    string text = streamReader.ReadToEnd();
                                    streamReader.Close();

                                    //check for DirtyPage
                                    string Query = "select DirtyPage from Sites where SiteId=" + SiteID;
                                    DataSet oDataSet = new DataSet();
                                    SqlHelper.FillDataset(ConfigurationSettings.AppSettings["SoConn"].ToString(), CommandType.Text, Query, oDataSet, new string[] { "SiteDetails" });

                                    string isDirty = Convert.ToString(oDataSet.Tables["SiteDetails"].Rows[0]["DirtyPage"]);

                                    if (isDirty.Equals("Y"))
                                    {
                                        text = text.Replace("<img class=\"dynamic\" src=\"images/SNR_facebook.png\">", ShareButton);

                                        text = text.Replace("<img class=\"dynamic\" src=\"images/SNR_recommend.png\">", RecommendButton);

                                        text = text.Replace("<img class=\"dynamic\" src=\"images/fb-like-button.png\">", LikePlugin);

                                        text = text.Replace("<img class=\"dynamic\" src=\"images/SNR_twitter.png\">", TwitterButton);
                                        text = text.Replace("<img class=\"dynamic\" src=\"images/SNR_linkedIn.png\">", LinkedInButton);
                                        if (TemplateID == 11)
                                        {
                                            text = text.Replace("<img class=\"ActionImg\" src=\"images/email.png\">", EmailButton);
                                            text = text.Replace("<img class=\"ActionImg\" src=\"images/email.png\">", PrintButton);
                                        }
                                    }
                                    else
                                    {
                                        text = text.Replace("<img class=\"dynamic\" src=\"images/SNR_facebook.png\" />", ShareButton);

                                        text = text.Replace("<img class=\"dynamic\" src=\"images/SNR_recommend.png\" />", RecommendButton);

                                        text = text.Replace("<img class=\"dynamic\" src=\"images/fb-like-button.png\" />", LikePlugin);

                                        text = text.Replace("<img class=\"dynamic\" src=\"images/SNR_twitter.png\" />", TwitterButton);
                                        text = text.Replace("<img class=\"dynamic\" src=\"images/SNR_linkedIn.png\">", LinkedInButton);
                                        if (TemplateID == 11)
                                        {
                                            text = text.Replace("<img class=\"ActionImg\" src=\"images/email.png\">", EmailButton);
                                            text = text.Replace("<img class=\"ActionImg\" src=\"images/email.png\">", PrintButton);
                                        }
                                    }

                                    //fix all Image tags
                                    string imagesReplaced = text.Replace("images", "images1/" + SiteID);

                                    String style;

                                    if (TemplateID == 12)
                                    {
                                        style = "/CSS/RStore_style.css";

                                    }
                                    else if (TemplateID == 13)
                                    {
                                        style = "/CSS/FabrikStyle.css";
                                        popupContact.Visible = false;
                                    }
                                    else if (TemplateID == 11)
                                    {
                                        style = "/CSS/CouponsStyle.css";
                                        popupContact.Visible = false;
                                    }
                                    else if (TemplateID == 16)
                                    {
                                        style = "/CSS/Restaurantstyle.css";
                                        SessionData.PrefData.TemplateID1 = TemplateID;

                                    }

                                    else if (TemplateID == 17)
                                    {
                                        style = "/CSS/Educationalstyle.css";
                                        SessionData.PrefData.TemplateID1 = TemplateID;

                                    }
                                    else
                                    {
                                        style = "/CSS/realestate_styles.css";

                                    }

                                    //get all the Images, Styles in
                                    System.IO.StreamReader StreamReader1 =
            new System.IO.StreamReader(Server.MapPath("./Sites/Final/" + SiteID + style));
                                    string ReadStyle = StreamReader1.ReadToEnd();
                                    StreamReader1.Close();

                                    if (TemplateID == 14)
                                    {

                                        HtmlLink linking = Page.FindControl("facebookIDStyleSheet") as HtmlLink;
                                        linking.Href = "./Sites/Final/" + SiteID + style;

                                    }

                                    System.IO.StreamReader StreamReader2 =
            new System.IO.StreamReader(Server.MapPath("./ScriptsSonetReach/Facebookstyles.css"));
                                    string CleanStyle = StreamReader2.ReadToEnd();
                                    CleanStyle = string.Empty;
                                    StreamReader2.Close();

                                    System.IO.StreamWriter StreamWriter2 =
                    new System.IO.StreamWriter(Server.MapPath("./ScriptsSonetReach/Facebookstyles.css"));
                                    StreamWriter2.WriteLine(CleanStyle);
                                    StreamWriter2.Close();

                                    System.IO.StreamWriter StreamWriter1 =
                    new System.IO.StreamWriter(Server.MapPath("./ScriptsSonetReach/Facebookstyles.css"));
                                    StreamWriter1.WriteLine(ReadStyle);
                                    StreamWriter1.Close();

                                    //saranya

                                    System.IO.StreamReader sr = new System.IO.StreamReader(Server.MapPath("./ScriptsSonetReach/Facebookstyles.css"));
                                    String fileContents = sr.ReadToEnd();
                                    sr.Close();

                                    System.IO.StreamWriter sw = new System.IO.StreamWriter(Server.MapPath("./ScriptsSonetReach/Facebookstyles.css"));
                                    fileContents = fileContents.Replace("images", "images1/" + SiteID + "");
                                    sw.WriteLine(fileContents);
                                    sw.Close();

                                    ///NOW process all the images
                                    string imagePath = Server.MapPath("./Sites/Final/" + SiteID + "/Images/");
                                    string[] files = System.IO.Directory.GetFiles(imagePath);

                                    if (!Directory.Exists(Server.MapPath("./Images1/" + SiteID)))
                                    {
                                        Directory.CreateDirectory(Server.MapPath("./Images1/" + SiteID));
                                    }

                                    foreach (string file in files)
                                    {
                                        if (!System.IO.File.Exists(Server.MapPath("./Images1/" + SiteID + "/" + System.IO.Path.GetFileName(file))))
                                        {
                                            System.IO.File.Copy(file, System.IO.Path.Combine(Server.MapPath("./Images1/" + SiteID), System.IO.Path.GetFileName(file)));
                                        }
                                    }
                                    LoadComplete = true;

                                    litAppHTML.Text = imagesReplaced;

                                    litAppHTML.Text = litAppHTML.Text.Replace("<link href=\"CSS/FabrikStyle.css\" rel=\"stylesheet\" type=\"text/css\">", "");
                                    //litAppHTML.Text = litAppHTML.Text.Replace("<link href=\"css/realestate_styles.css\" rel=\"stylesheet\" type=\"text/css\">", "");

                                    backgroundPopup.Visible = false;
                                }
                            }
                            else if (ofbBiz.IsSweepstakesAppModel(QSVars["ADID"].ToString()) == "SWEEPSTAKES") // Check if Sweepstake CampaignType
                            {
                                if (ofbBiz.IsSweepstakesWinnerDay(QSVars["ADID"].ToString()))// Check if Sweepstake Date is today, redirect to Show Winners
                                {
                                    Response.Redirect("SweepstakesWinners.aspx?ADID=" + Convert.ToString(QSVars["ADID"]), false);
                                }
                                else
                                {
                                    string Enddate = ofbBiz.GetSweepstakesEndDate(QSVars["ADID"].ToString());
                                    if (!string.IsNullOrEmpty(Enddate))
                                    {
                                        DateTime sd = DateTime.Parse(Enddate);
                                        Enddate = sd.ToString("dd/M/yyyy");
                                    }
                                    //litAppHTML.Text = "Sweepstakes Contest is over. Results will be shown on ...";
                                    apppathLink.InnerText = "Sweepstakes Contest is over. Winners will be announced on " + Enddate;
                                    popupContact.Style.Add("margin-left", "250px");
                                }

                            }
                            else
                            {
                                AppExpired.Visible = true;
                                litAppHTML.Text = "";
                                popupContact.Visible = false;
                            }
                        }
                    }
                    else
                    {
                        oDCAppUser.AppConfigDID = Session["ADID"].ToString();
                        hdnAppConfigD.Value = oDCAppUser.AppConfigDID;
                        oDCAppUser.SonetID = Session["UserID"].ToString();
                        hdnUserID.Value = oDCAppUser.SonetID;
                        hdnAppID.Value = Session["AppID"].ToString();
                        Session["UserID"] = hdnUserID.Value;
                        Session["AppID"] = hdnAppID.Value;
                        oDCAppUser = ofbBiz.GetAppUser(osonetpie, Session["ADID"].ToString(), Session["UserID"].ToString());
                        //populate the AppProduct encapsulation based on app that is loaded
                        AppProduct oAppProduct = new AppProduct();
                        FaceBook facebook = new FaceBook();

                        oAppProduct = ofbBiz.GetActiveAppProduct(osonetpie, Session["ADID"].ToString());
                        litHeadBannerCount.Text = GetHeadBannerURL(oAppProduct.DID);
                        // Get the HTML to be shown

                        string HTML = oAppProduct.ProductHTML;
                        // Fill up Config and Custome
                        //Get Custom Tab name
                        string CustTabNAme = fbBizProc.GetCustomTabName(Session["AppID"].ToString());
                        //Get Share Button for this Product

                        string CommentBox = GetCommentPlugin(oAppProduct.DID, oAppProduct.ProductName, oAppProduct.ProductLogo, oAppProduct.ProductShortDesc, QSVars["app_id"].ToString(), fbBizProc.GetAppPagePath(Convert.ToString(QSVars["app_id"])));
                        string ShareButton = GetShareButton(oAppProduct.DID, oAppProduct.ProductName, oAppProduct.ProductLogo, oAppProduct.ProductShortDesc, Session["AppID"].ToString(), CustTabNAme);
                        string InviteButton = GetInviteButton(oAppProduct.DID, oAppProduct.ProductName, oAppProduct.ProductLogo, oAppProduct.ProductShortDesc, Session["AppID"].ToString());
                        string RecommendButton = GetRecommendButton(oAppProduct.DID, oAppProduct.ProductName, oAppProduct.ProductLogo, oAppProduct.ProductShortDesc, Session["AppID"].ToString());
                        string LikePlugin = GetLikePlugin(oAppProduct.DID, oAppProduct.ProductName, oAppProduct.ProductLogo, oAppProduct.ProductShortDesc, Session["AppID"].ToString());
                        string EntryFormPlug = GetEntryForm(oAppProduct.DID, oAppProduct.ProductName, oAppProduct.ProductLogo, oAppProduct.ProductShortDesc, Session["ADID"].ToString(), Session["UserID"].ToString().ToString());
                        string LeadPlugin = GetLeadButton(oAppProduct.DID, oAppProduct.ProductName, oAppProduct.ProductLogo, oAppProduct.ProductShortDesc, QSVars["app_id"].ToString());
                        string TwitterButton = GetTwitterShareURL(oAppProduct.DID, oAppProduct.ProductName, oAppProduct.ProductLogo, oAppProduct.ProductShortDesc, QSVars["app_id"].ToString());
                        //if HTML contains SHARE and Widgets are present

                        if (oAppProduct.CommentsWidgetAdded.Equals(TRUE))
                        {
                            addCOMMENT = HTML.Replace("CommBox", CommentBox);
                        }
                        else
                        {
                            addCOMMENT = HTML.Replace("CommBox", "");
                        }

                        if (oAppProduct.ShareWidgetAdded.Equals(TRUE))
                        {
                            addSHARE = addCOMMENT.Replace("ShButton", ShareButton);
                        }
                        else
                        {
                            addSHARE = addCOMMENT.Replace("ShButton", "");
                        }
                        if (oAppProduct.TwitterWidgetAdded.Equals(TRUE))
                        {
                            addTwitter = addSHARE.Replace("TwButton", TwitterButton);
                        }
                        else
                        {
                            addTwitter = addSHARE.Replace("TwButton", string.Empty);
                        }

                        if (ocanvBiz.IsConfigForSweepstakes(oAppProduct.AppConfigDID))
                        {
                            if (oAppProduct.ReccWidgetAdded.Equals(TRUE))
                            {
                                addPOST = addTwitter.Replace("ReButton", InviteButton);
                            }
                            else
                            {
                                addPOST = addTwitter.Replace("ReButton", "");
                            }
                            //if HTML contains LIKE
                            addEntry = addPOST.Replace("Like", EntryFormPlug);

                            litAppHTML.Text = addEntry;
                            hdnStatus.Value = "HIDE";
                            apppathLink.Visible = false;
                        }
                        else
                        {

                            if (oAppProduct.ReccWidgetAdded.Equals(TRUE))
                            {
                                addPOST = addTwitter.Replace("ReButton", InviteButton);
                            }
                            else
                            {
                                addPOST = addTwitter.Replace("ReButton", "");
                            }

                            if (oAppProduct.LikeWidgetAdded.Equals(TRUE))
                            {
                                addLIKE = addPOST.Replace("Like", LikePlugin);
                            }
                            else
                            {
                                addLIKE = addPOST.Replace("Like", "");
                            }

                            if (oAppProduct.InquiryWidgetAdded.Equals(TRUE))
                            {
                                addLead = addLIKE.Replace("Lead", LeadPlugin);
                            }
                            else
                            {
                                addLead = addLIKE.Replace("Lead", "");
                            }
                            litAppHTML.Text = addLead;
                            hdnStatus.Value = "HIDE";
                            apppathLink.Visible = false;
                        }
                    }
                }
                else if (Request.QueryString.AllKeys.Contains("request_ids"))
                {
                    apppathLink.HRef = fbBizProc.GetAppPagePath(Convert.ToString(QSVars["app_id"]));
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "myCloseScript", "window.parent.location.href='" + apppathLink.HRef.ToString() + "'", true);
                }
                else
                {
                    //Nothing to load , show error screen
                    if (QSVars["app_id"] == null)
                    {
                        Server.Transfer("Error.aspx");
                    }
                    else
                    {
                        apppathLink.HRef = fbBizProc.GetAppPagePath(Convert.ToString(QSVars["app_id"]));
                        if (QSVars.Contains("soNETSrc"))
                        {
                            if (!(Convert.ToString(QSVars["soNETSrc"].ToString()).Equals("NULL")))
                            {
                                Page.ClientScript.RegisterStartupScript(this.GetType(), "myCloseScript", "window.parent.close();", true);
                            }
                            else
                            {
                                Page.ClientScript.RegisterStartupScript(this.GetType(), "myCloseScript", "window.parent.location.href='" + apppathLink.HRef.ToString() + "'", true);
                            }
                        }
                    }

                    if (Request.Url.Query.Contains("fb_source"))
                    {
                        Page.ClientScript.RegisterStartupScript(this.GetType(), "myCloseScript", "window.parent.location.href='" + apppathLink.HRef.ToString() + "'", true);
                    }
                }

                //saranya
                if (Request.QueryString.AllKeys.Contains("request_ids"))
                {
                    apppathLink.HRef = fbBizProc.GetAppPagePath(Convert.ToString(QSVars["app_id"]));
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "myCloseScript", "window.parent.location.href='" + apppathLink.HRef.ToString() + "'", 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 void btnStep3Complete_Click(object sender, EventArgs e)
        {
            try
            {
                //Fetch Template Data
                dsTemplateData = canv.GetTempData(Convert.ToInt32(templateID)); //REVISIT
                hdnTrmplateID.Value = templateID;

                //Save Widgets info and Cust Tab name, then move to FB tab
                //Custom Tab Name
                if (!txtCustomTabNamePromoVid.Text.Trim().Equals(string.Empty))
                {

                    SessionData.Config.SCustomtTabName = txtCustomTabNamePromoVid.Text.Trim();
                }

                //Widgets
                if (chkShareButton.Checked)
                {
                    SessionData.Product.ShareWidgetAdded = "Y";

                }
                if (chkInquiry.Checked)
                {
                    SessionData.Product.InquiryWidgetAdded = "Y";
                }
                if (chkRecc.Checked)
                {
                    SessionData.Product.ReccWidgetAdded = "Y";
                }
                if (chkComment.Checked)
                {
                    SessionData.Product.CommentsWidgetAdded = "Y";
                }
                if (chkLike.Checked)
                {
                    SessionData.Product.LikeWidgetAdded = "Y";
                }
                if (chkTweeter.Checked)
                {
                    SessionData.Product.TwitterWidgetAdded = "Y";

                }

                //Like Gateway
                if (chkLikeGateway.Checked)
                {
                    SessionData.Product.LikeGatewayAdded = "Y";
                    //Save LikeGateway Image
                    if (filePromo2LikeGateWayImage.HasFile)
                    {
                        if (filePromo2LikeGateWayImage.PostedFile.ContentType == "image/jpeg" || filePromo2LikeGateWayImage.PostedFile.ContentType == "image/png" || filePromo2LikeGateWayImage.PostedFile.ContentType == "image/jpg" || filePromo2LikeGateWayImage.PostedFile.ContentType == "image/pjpeg")
                        {
                            if (filePromo2LikeGateWayImage.FileBytes.Length < ONE_MB)
                            {
                                string filenamePromo2Logo = Path.GetFileName(filePromo2LikeGateWayImage.FileName);

                                Bitmap sourceImage = new Bitmap(filePromo2LikeGateWayImage.PostedFile.InputStream);
                                SaveImageFile(sourceImage, Server.MapPath(pathToCreate + "/LikeGateway" + filenamePromo2Logo), 111, 74);
                                hdnFooterLogo.Value = filenamePromo2Logo;
                                SessionData.Product.ProductLogo = filenamePromo2Logo;

                                //NOW SAVE TO PRODUCT TABLE------> PRODUCTFOOTER
                            }
                            else
                            {
                                spnErrorfileLikeGateWayImage.InnerHtml = "File size should not be greater than 1 MB"; spnErrorfileLikeGateWayImage.Style.Add("color", "Red");
                                errCount++;
                            }
                        }
                        else
                        {
                            spnErrorfileLikeGateWayImage.InnerHtml = "Upload status: Only JPEG, PNG files are accepted!"; spnErrorfileLikeGateWayImage.Style.Add("color", "Red");
                            errCount++;
                        }
                    }
                }

                FacebookBizProcess fbBiz = new FacebookBizProcess();

                FaceBook ofacebook = new FaceBook();
                AppUser oAppUser = new AppUser();

                if ((Regex.IsMatch(txtVideoURL.Text.Trim(), @"(http|https)://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?")) && (txtVideoURL.Text.Trim().Contains("youtube")))
                {
                    iframecontent = ofacebook.GetEmbedURL(txtVideoURL.Text.Trim(), oAppUser);
                    string fixedURL = FixVideoURL(iframecontent);
                    //Now save the Video details
                    fbBiz.InsertVideoShareData(SessionData.Config.DID, txtVideoURL.Text.Trim(), fixedURL, txtDescription.Text.Trim());

                    if (!iframecontent.Equals(string.Empty))
                    {
                        string[] newEmbedURL = iframecontent.Split(' ');
                        string finalURL = newEmbedURL[3].Remove(0, 4);
                        if (!txtVideoURL.Text.Contains("autoplay"))
                        {
                            if (!txtVideoURL.Text.Contains("?"))
                            {
                                string tempData6 = dsTemplateData.Tables[0].Rows[0]["thtml"].ToString();

                                //Fill up Preview Data
                                string HeaderBannerURLReplaced = tempData6.Replace(" <a id=\"aHeadBanner\" href=\"\" target=\"_blank\">", "<a id=\"aHeadBanner\" href=" + txtBannerURL.Text + " target=\"_blank\" >"); // Replace Banner URL
                                string HeaderBannerReplaced = HeaderBannerURLReplaced.Replace("<img id=\"imgBanner\" alt=\"\" src=\"\" style=\"width: 500px; height: 100px;\" />", "<img id=\"imgBanner\" alt=\"\" src=\"Images/" + SessionData.Product.DID + "/" + "Banner" + hdnBanner.Value + "\" style=\"width: 500px; height: 100px;\"/>"); // Replace Banner Image

                                string ParamAdded = HeaderBannerReplaced.Replace("<paramss>", "<param name=\"movie\" value=\"" + finalURL + "?autoplay=0\">");
                                string ObjectAdded = ParamAdded.Replace("<iframe>", fixedURL);
                                string DescriptionAdded = ObjectAdded.Replace("</span>", txtDescription.Text.Trim().Replace("'", "''") + "</span>");
                                using (CanvasBizProcess canvasBiz = new CanvasBizProcess())
                                {
                                    canvasBiz.InsertPreviewHTML(DescriptionAdded, SessionData.Customer.CustomerID, SessionData.Product.DID);

                                }
                                varCount++;
                            }
                            else
                            {
                                string tempData6 = dsTemplateData.Tables[0].Rows[0]["thtml"].ToString();

                                //Fill up Preview Data
                                string HeaderBannerURLReplaced = tempData6.Replace(" <a id=\"aHeadBanner\" href=\"\" target=\"_blank\">", "<a id=\"aHeadBanner\" href=" + txtBannerURL.Text + " target=\"_blank\" >"); // Replace Banner URL
                                string HeaderBannerReplaced = HeaderBannerURLReplaced.Replace("<img id=\"imgBanner\" alt=\"\" src=\"\" style=\"width: 500px; height: 100px;\" />", "<img id=\"imgBanner\" alt=\"\" src=\"Images/" + SessionData.Product.DID + "/" + "Banner" + hdnBanner.Value + "\" style=\"width: 500px; height: 100px;\"/>"); // Replace Banner Image
                                string ParamAdded = HeaderBannerReplaced.Replace("<paramss>", "<param name=\"movie\" value=" + "\"" + finalURL + "&autoplay=0\">");
                                string ObjectAdded = ParamAdded.Replace("<iframe>", fixedURL);
                                string DescriptionAdded = ObjectAdded.Replace("NIOTPESRIC", txtDescription.Text.Trim().Replace("'", "''"));
                                using (CanvasBizProcess canvasBiz = new CanvasBizProcess())
                                {
                                    canvasBiz.InsertPreviewHTML(DescriptionAdded, SessionData.Customer.CustomerID, SessionData.Product.DID);
                                }
                                varCount++;
                            }
                        }
                        else
                        {
                            string tempData6 = dsTemplateData.Tables[0].Rows[0]["thtml"].ToString();

                            //Fill up Preview Data
                            string HeaderBannerURLReplaced = tempData6.Replace(" <a id=\"aHeadBanner\" href=\"\" target=\"_blank\">", "<a id=\"aHeadBanner\" href=" + txtBannerURL.Text + " target=\"_blank\" >"); // Replace Banner URL
                            string HeaderBannerReplaced = HeaderBannerURLReplaced.Replace("<img id=\"imgBanner\" alt=\"\" src=\"\" style=\"width: 500px; height: 100px;\" />", "<img id=\"imgBanner\" alt=\"\" src=\"Images/" + SessionData.Product.DID + "/" + "Banner" + hdnBanner.Value + "\" style=\"width: 500px; height: 100px;\"/>"); // Replace Banner Image
                            string ParamAdded = HeaderBannerReplaced.Replace("<paramss>", "<param name=\"movie\" value=\"" + finalURL + "\">");
                            string ObjectAdded = ParamAdded.Replace("<iframe>", iframecontent);
                            string DescriptionAdded = ObjectAdded.Replace("NIOTPESRIC", txtDescription.Text.Trim().Replace("'", "''"));

                            //make all videos play automatically
                            string autoPlayed = DescriptionAdded.Replace("autoplay=0", "autoplay=0");
                            using (CanvasBizProcess canvasBiz = new CanvasBizProcess())
                            {
                                canvasBiz.InsertPreviewHTML(autoPlayed, SessionData.Customer.CustomerID, SessionData.Product.DID);
                            }
                            varCount++;
                        }
                    }
                    else
                    {

                    }
                }
                else
                {

                }

                // Set Header Banner URL and Header Image in Product
                SessionData.Product.SHeaderBannerURL = txtBannerURL.Text;
                SessionData.Product.SHeaderBannerImg = hdnBanner.Value;
                SessionData.Product.ProductLogo = "https://www.sonetreach.com/Images/" + SessionData.Product.DID + "/Logo" + SessionData.Product.ProductLogo;
                SessionData.Product.SProductContentImage = "Body" + hdnContent.Value;

                if (!(SessionData.Config == null))
                {
                    //Apply Campaign Dates to Config
                    if (datepickerStart.Value != "")
                    {
                        SessionData.Config.SAppStartDT = SQLSafeDates(datepickerStart.Value, true);
                        SessionData.Config.AppExpiryDT = SQLSafeDates(datepickerEnd.Value, true);
                    }
                    //Now fill up the Config and get Product data.
                    SessionData.Config.SCampaignType = Video;
                    if (fbBiz.SetNewConfigDetails(SessionData.Config, SessionData.Config.SCustomtTabName,Video))
                    {
                        ////********If user comes here we know we should set up a Product Info, So, create a row in AppProduct and assign these values to SessionData********

                        SessionData.Product.AppConfigDID = SessionData.Config.DID;
                        SessionData.Product.ProductName = SessionData.Config.AppName;
                        SessionData.Product.ProductHTML = canv.FetchFinalHTML(SessionData.Product.DID, CDID);
                        fbBiz.SetNewProductDetails(SessionData.Product);

                        SessionData.Product = fbBiz.GetAppProductDetails();

                        // Now Enable the Facebook Tab

                    }
                }
                else
                {
                    //No configs allowed
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "myCloseScript", "alert(\"Config Not Available. Please Contact HELPDESK.\")", true);
                }

                HtmlGenericControl fbookShow = new HtmlGenericControl();
                fbookShow = (HtmlGenericControl)MainList.FindControl("FacebookDet");
                fbookShow.Style.Add("display", "block");
                hdnTabStatus.Value = STEP_THREE_COMPLETE;
            }
            catch (Exception ex)
            {
                commonUtil.SendErrorMail(ex.Message, ex.StackTrace, System.Reflection.MethodBase.GetCurrentMethod().Name.ToString(), System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString(), SessionData.Customer.CustomerID);
            }
        }
        protected void btnStep3Complete_Click(object sender, EventArgs e)
        {
            try
            {
                //Fetch Template Data
                FacebookBizProcess fbBiz = new FacebookBizProcess();
                string createdHTML = fbBiz.GetProductHTML(SessionData.Product.DID); //REVISIT
                hdnTrmplateID.Value = templateID;

                //Save Widgets info and Cust Tab name, then move to FB tab
                //Custom Tab Name
                if (!txtCustomTabNamePromo2.Text.Trim().Equals(string.Empty))
                {

                    SessionData.Config.SCustomtTabName = txtCustomTabNamePromo2.Text.Trim();
                }
                //Widgets
                if (chkShareButton.Checked)
                {
                    SessionData.Product.ShareWidgetAdded = "Y";

                }
                else
                {
                    SessionData.Product.ShareWidgetAdded = "N";
                }
                if (chkInquiry.Checked)
                {
                    SessionData.Product.InquiryWidgetAdded = "Y";
                }
                else
                {
                    SessionData.Product.InquiryWidgetAdded = "N";
                }
                if (chkRecc.Checked)
                {
                    SessionData.Product.ReccWidgetAdded = "Y";
                }
                else
                {
                    SessionData.Product.ReccWidgetAdded = "N";
                }
                if (chkComment.Checked)
                {
                    SessionData.Product.CommentsWidgetAdded = "Y";
                }
                else
                {
                    SessionData.Product.CommentsWidgetAdded = "N";
                }
                if (chkLike.Checked)
                {
                    SessionData.Product.LikeWidgetAdded = "Y";
                }
                else
                {
                    SessionData.Product.LikeWidgetAdded = "N";
                }

                if (chkTweeter.Checked)
                {
                    SessionData.Product.TwitterWidgetAdded = "Y";

                }
                else
                {
                    SessionData.Product.TwitterWidgetAdded = "N";
                }
                oVidShareData = fbBiz.GetVideoShareData(SessionData.Config.DID);

                //Like Gateway
                if (chkLikeGateway.Checked)
                {
                    SessionData.Product.LikeGatewayAdded = "Y";
                    //Save LikeGateway Image
                    if (filePromo2LikeGateWayImage.HasFile)
                    {
                        if (filePromo2LikeGateWayImage.PostedFile.ContentType == "image/jpeg" || filePromo2LikeGateWayImage.PostedFile.ContentType == "image/png" || filePromo2LikeGateWayImage.PostedFile.ContentType == "image/jpg" || filePromo2LikeGateWayImage.PostedFile.ContentType == "image/pjpeg")
                        {
                            if (filePromo2LikeGateWayImage.FileBytes.Length < 1048576)
                            {
                                string filenamePromo2Logo = Path.GetFileName(filePromo2LikeGateWayImage.FileName);

                                Bitmap sourceImage = new Bitmap(filePromo2LikeGateWayImage.PostedFile.InputStream);
                                SaveImageFile(sourceImage, Server.MapPath(pathToCreate + "/LikeGateway" + filenamePromo2Logo), 111, 74);
                                hdnFooterLogo.Value = filenamePromo2Logo;
                                SessionData.Product.ProductLogo = filenamePromo2Logo;

                            }
                            else
                            {
                                spnErrorfileLikeGateWayImage.InnerHtml = "File size should not be greater than 1 MB"; spnErrorfileLikeGateWayImage.Style.Add("color", "Red");
                                errCount++;
                            }
                        }
                        else
                        {
                            spnErrorfileLikeGateWayImage.InnerHtml = "Upload status: Only JPEG, PNG files are accepted!"; spnErrorfileLikeGateWayImage.Style.Add("color", "Red");
                            errCount++;
                        }
                    }
                }
                if (fbBiz.IsAppCreationAllowed(SessionData.Customer.CustomerID))
                {
                    FaceBook ofacebook = new FaceBook();
                    AppUser oAppUser = new AppUser();

                    if ((Regex.IsMatch(txtVideoURL.Text.Trim(), @"(http|https)://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?")) && (txtVideoURL.Text.Trim().Contains("youtube")))
                    {
                        iframecontent = ofacebook.GetEmbedURL(txtVideoURL.Text.Trim(), oAppUser);
                        iframecontentOld = ofacebook.GetEmbedURL(oVidShareData.SVideoShareURL, oAppUser);

                        string fixedURL = FixVideoURL(iframecontent);
                        string fixedUrlOld = FixVideoURL(iframecontentOld);
                        //Now update VideoShareData
                        fbBiz.UpdateVideoShareData(SessionData.Config.DID, txtVideoURL.Text.Trim(), fixedURL, txtDescription.Text.Trim());

                        if (!iframecontent.Equals(string.Empty))
                        {
                            string[] newEmbedURL = iframecontent.Split(' ');
                            string finalURL = newEmbedURL[3].Remove(0, 4);

                            string[] oldEmbedURL = iframecontentOld.Split(' ');
                            string oldfinalURL = oldEmbedURL[3].Remove(0, 4);
                            if (!txtVideoURL.Text.Contains("autoplay"))
                            {
                                if (!txtVideoURL.Text.Contains("?"))
                                {
                                    if (!(string.IsNullOrEmpty(txtBannerURL.Text.Trim()))) //New image was chosen, then do normal replace, else, bring new image
                                    //SessionData.Product.SHeaderBannerURL != txtBannerURL.Text
                                    {
                                        HeaderBannerURLReplaced = createdHTML.Replace(SessionData.Product.SHeaderBannerURL, txtBannerURL.Text);
                                    }
                                    else
                                    {
                                        HeaderBannerURLReplaced = createdHTML.Replace(" <a id=\"aHeadBanner\" href=\"\" target=\"_blank\">", "<a id=\"aHeadBanner\" href=" + SessionData.Product.SHeaderBannerURL + " target=\"_blank\" >"); // Replace Banner URL
                                    }

                                    if (hdnFileBannerHasFile.Value.Equals(HASFILE)) //New image was chosen, then do normal replace, else, bring new image
                                    {
                                        HeaderBannerReplaced = HeaderBannerURLReplaced.Replace(SessionData.Product.SHeaderBannerImg, hdnBanner.Value);
                                    }
                                    else
                                    {

                                        HeaderBannerReplaced = HeaderBannerURLReplaced.Replace("<img id=\"imgBanner\" alt=\"\" src=\"Images/" + SessionData.Product.DID + "/" + SessionData.Product.SHeaderBannerImg + "\" style=\"width: 500px; height: 100px;\" />", "<img id=\"imgBanner\" alt=\"\" src=\"Images/" + SessionData.Product.DID + "/" + "Banner" + hdnBanner.Value + "\"  style=\"width: 500px; height: 100px;\" />");

                                        //check if canvas settings have changed, if so, need to resize existing image
                                    }
                                    string ParamAdded = HeaderBannerReplaced.Replace(oldfinalURL, finalURL);
                                    string ObjectAdded = ParamAdded.Replace(fixedUrlOld, fixedURL);
                                    string DescriptionAdded = ObjectAdded.Replace(oVidShareData.SVideoShareDesc, txtDescription.Text.Trim().Replace("'", "''"));
                                    using (CanvasBizProcess canvasBiz = new CanvasBizProcess())
                                    {
                                        canvasBiz.UpdatePreviewHTML(DescriptionAdded, SessionData.Customer.CustomerID, SessionData.Product.DID);

                                    }
                                    varCount++;
                                }
                                else
                                {
                                    if (!(string.IsNullOrEmpty(txtBannerURL.Text.Trim()))) //New image was chosen, then do normal replace, else, bring new image
                                    //SessionData.Product.SHeaderBannerURL != txtBannerURL.Text
                                    {
                                        HeaderBannerURLReplaced = createdHTML.Replace(SessionData.Product.SHeaderBannerURL, txtBannerURL.Text);
                                    }
                                    else
                                    {
                                        HeaderBannerURLReplaced = createdHTML.Replace(" <a id=\"aHeadBanner\" href=\"\" target=\"_blank\">", "<a id=\"aHeadBanner\" href=" + SessionData.Product.SHeaderBannerURL + " target=\"_blank\" >"); // Replace Banner URL
                                    }

                                    if (hdnFileBannerHasFile.Value.Equals(HASFILE)) //New image was chosen, then do normal replace, else, bring new image
                                    {
                                        HeaderBannerReplaced = HeaderBannerURLReplaced.Replace(SessionData.Product.SHeaderBannerImg, hdnBanner.Value);
                                    }
                                    else
                                    {

                                        HeaderBannerReplaced = HeaderBannerURLReplaced.Replace("<img id=\"imgBanner\" alt=\"\" src=\"Images/" + SessionData.Product.DID + "/" + SessionData.Product.SHeaderBannerImg + "\" style=\"width: 500px; height: 100px;\" />", "<img id=\"imgBanner\" alt=\"\" src=\"Images/" + SessionData.Product.DID + "/" + "Banner" + hdnBanner.Value + "\"  style=\"width: 500px; height: 100px;\" />");

                                        //check if canvas settings have changed, if so, need to resize existing image
                                    }
                                    string ParamAdded = HeaderBannerReplaced.Replace(oldfinalURL, finalURL);
                                    string ObjectAdded = ParamAdded.Replace(fixedUrlOld, fixedURL);
                                    string DescriptionAdded = ObjectAdded.Replace(oVidShareData.SVideoShareDesc, txtDescription.Text.Trim().Replace("'", "''"));
                                    using (CanvasBizProcess canvasBiz = new CanvasBizProcess())
                                    {
                                        canvasBiz.UpdatePreviewHTML(DescriptionAdded, SessionData.Customer.CustomerID, SessionData.Product.DID);
                                    }
                                    varCount++;
                                }
                            }
                            else
                            {
                                if (!(string.IsNullOrEmpty(txtBannerURL.Text.Trim()))) //New image was chosen, then do normal replace, else, bring new image
                                {
                                    HeaderBannerURLReplaced = createdHTML.Replace(SessionData.Product.SHeaderBannerURL, txtBannerURL.Text);
                                }
                                else
                                {
                                    HeaderBannerURLReplaced = createdHTML.Replace(" <a id=\"aHeadBanner\" href=\"\" target=\"_blank\">", "<a id=\"aHeadBanner\" href=" + SessionData.Product.SHeaderBannerURL + " target=\"_blank\" >"); // Replace Banner URL
                                }

                                if (hdnFileBannerHasFile.Value.Equals(HASFILE)) //New image was chosen, then do normal replace, else, bring new image
                                {
                                    HeaderBannerReplaced = HeaderBannerURLReplaced.Replace(SessionData.Product.SHeaderBannerImg, hdnBanner.Value);
                                }
                                else
                                {

                                    HeaderBannerReplaced = HeaderBannerURLReplaced.Replace("<img id=\"imgBanner\" alt=\"\" src=\"Images/" + SessionData.Product.DID + "/" + SessionData.Product.SHeaderBannerImg + "\" style=\"width: 500px; height: 100px;\" />", "<img id=\"imgBanner\" alt=\"\" src=\"Images/" + SessionData.Product.DID + "/" + "Banner" + hdnBanner.Value + "\"  style=\"width: 500px; height: 100px;\" />");

                                    //check if canvas settings have changed, if so, need to resize existing image
                                }
                                string ParamAdded = HeaderBannerReplaced.Replace(oldfinalURL, finalURL);
                                string ObjectAdded = ParamAdded.Replace(fixedUrlOld, fixedURL);
                                string DescriptionAdded = ObjectAdded.Replace(oVidShareData.SVideoShareDesc, txtDescription.Text.Trim().Replace("'", "''"));

                                //make all videos play automatically
                                string autoPlayed = DescriptionAdded.Replace("autoplay=0", "autoplay=0");
                                using (CanvasBizProcess canvasBiz = new CanvasBizProcess())
                                {
                                    canvasBiz.UpdatePreviewHTML(autoPlayed, SessionData.Customer.CustomerID, SessionData.Product.DID);
                                }
                                varCount++;
                            }
                        }
                        else
                        {

                        }
                    }
                    else
                    {

                    }

                    if (hdnFileBannerHasFile.Value.Equals(HASFILE))
                    {
                        SessionData.Product.SHeaderBannerImg = hdnBanner.Value;
                    }

                    // Add Banner URL
                    if (!(string.IsNullOrEmpty(txtBannerURL.Text.Trim())))
                    {
                        SessionData.Product.SHeaderBannerURL = txtBannerURL.Text.Trim();
                    }

                    if (!(SessionData.Config == null))
                    {
                        if (datepickerStart.Value != "")
                        {
                            SessionData.Config.SAppStartDT = SQLSafeDates(datepickerStart.Value, true);
                            SessionData.Config.AppExpiryDT = SQLSafeDates(datepickerEnd.Value, true);
                        }

                        //Now fill up the Config and get Product data.
                        if (fbBiz.UpdateConfigDetails(SessionData.Config, PROMOTIONS, SessionData.Config.SCustomtTabName))
                        {
                            ////********If user comes here we know we should set up a Product Info, So, create a row in AppProduct and assign these values to SessionData********

                            SessionData.Product.AppConfigDID = SessionData.Config.DID;
                            SessionData.Product.ProductName = SessionData.Config.AppName;
                            SessionData.Product.ProductHTML = canv.FetchFinalHTML(SessionData.Product.DID, SessionData.Customer.CustomerID);
                            fbBiz.UpdateProductDetails(SessionData.Product);
                        }
                    }
                    else
                    {
                        //No configs allowed
                        Page.ClientScript.RegisterStartupScript(this.GetType(), "myCloseScript", "alert(\"Config Not Available. Please Contact HELPDESK.\")", true);
                    }
                }
                else
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "myCloseScript", "alert(\"You can only create 3 Campaigns with a TRIAL account !\")", true);
                }

                HtmlGenericControl fbookShow = new HtmlGenericControl();
                fbookShow = (HtmlGenericControl)MainList.FindControl("FacebookDet");
                fbookShow.Style.Add("display", "block");
                hdnTabStatus.Value = STEP_THREE_COMPLETE;
            }
            catch (Exception ex)
            {
                commonUtil.SendErrorMail(ex.Message, ex.StackTrace, System.Reflection.MethodBase.GetCurrentMethod().Name.ToString(), System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString(), SessionData.Customer.CustomerID);
            }
        }
示例#15
0
        public AppUser GetTwitterTokens(string ADID, string SMType, string soNetId)
        {
            DataSet dsTweeterTokens = new DataSet();
            DatabaseHandler oDBH = new DatabaseHandler();
            AppUser oAppUser = new AppUser();
            dsTweeterTokens = oDBH.FillData_SP("GetTwitterTokens", ADID, SMType, soNetId);

            try
            {
                if (dsTweeterTokens.Tables.Count > 0)
                {
                    if (dsTweeterTokens.Tables[0].Rows.Count > 0)
                    {
                        oAppUser.Token = Convert.ToString(dsTweeterTokens.Tables[0].Rows[0]["Token"].ToString());
                        oAppUser.TokenSecret = Convert.ToString(dsTweeterTokens.Tables[0].Rows[0]["TokenSecret"].ToString());
                        return oAppUser;
                    }
                }
                else
                {

                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return null;
        }
示例#16
0
        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"]));
        }
示例#17
0
        protected void Page_Load(object sender, EventArgs e)
        {
            CanvasBizProcess ocanbiz = new CanvasBizProcess();
            TwitterBizProcess Twbiz = new TwitterBizProcess();
            Twitter otittwr = new Twitter();

            string oauthverifier = Request.QueryString["oauth_verifier"].ToString();
            string oauthtoken = (Request.QueryString["oauth_token"].ToString());
            string userid = otittwr.CreateCachedAccessToken(oauthtoken, oauthverifier);

            //string ADID = SessionData.Product.AppConfigDID;
            //string app_id = SessionData.Config.AppID;
            string ADID = Request.QueryString["ADID"];
            string app_id = Request.QueryString["app_id"];
            String SMType = "TW";

            //First Check whether User Exsist

            oDCAppUser = ocanbiz.GetTwitterTokens(ADID, SMType, userid);
            if (oDCAppUser != null)
            {
                string token = oDCAppUser.Token;
                string tokensecret = oDCAppUser.TokenSecret;
                if (otittwr.CheckAppAuthorized(token, tokensecret) == true)
                {

                    UpdateStatus(token, tokensecret);
                    ClientScript.RegisterStartupScript(typeof(Page), "RedirectArticle", "alert('Tweeted Successfully ! ! ! ');", true);
                    ClientScript.RegisterStartupScript(typeof(Page), "closePage", "window.close('Test.aspx');", true);

                    //Tweet();
                    //ScriptManager.RegisterStartupScript(this, typeof(string), "OPEN_WINDOW", "var Mleft = (screen.width/2)-(760/2);var Mtop = (screen.height/2)-(700/2);window.open( '" + URL + "', null, 'height=700,width=760,status=yes,toolbar=no,scrollbars=yes,menubar=no,location=no,top=\'+Mtop+\', left=\'+Mleft+\'' );", true);

                    //this.ClientScript.RegisterStartupScript(this.GetType(), "navigate", "window.location = $('#aTwitterBtn').attr('href');", true);

                    //this.ClientScript.RegisterStartupScript(this.GetType(),"navigate","window.onload = function() {window.location.hash='#message';}",
                    //                    true);

                }
            }
            else
            {

                AppUser oAppuser = new AppUser();
                oAppuser.AppConfigDID = ADID;
                oAppuser.EmailID = "NULL";
                oAppuser.SonetID = userid;
                oAppuser.SonetSRC = "FBSRC";
                oAppuser.UserStatus = "Active";
                oAppuser.SMType = "TW";
                oAppuser.Token = SessionData.TwitterData.TokenKey;
                oAppuser.TokenSecret = SessionData.TwitterData.TokenSecretKey;
                oAppuser = otittwr.GetUserDetail(userid, oAppuser);

                //Insert in AppUser when Brand Tweets the Campaign
                if (!Twbiz.IsUserCreatedForTwitter(oAppuser.SonetID, oAppuser.AppConfigDID))
                {
                    if (Twbiz.SetAppUserAuthorize(oAppuser, ADID)) oDCAppUser = oAppuser;
                }

                UpdateStatus(SessionData.TwitterData.TokenKey, SessionData.TwitterData.TokenSecretKey);

                //Close this page since all info is available.
                ClientScript.RegisterStartupScript(typeof(Page), "RedirectArticle", "alert('Tweeted Successfully ! ! ! ');", true);
                ClientScript.RegisterStartupScript(typeof(Page), "closePage", "window.close('Test.aspx');", true);
            }
        }
示例#18
0
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);
            //Initialize API Core
            FaceBook oFacebook = new FaceBook();

            //Initialize KOKO
            SonetPie osonetpie = new SonetPie();
            osonetpie.QSvarsString = GetQsVarsCollection();
            osonetpie.AbsolutePath = AbsolutePagePath;

            //Load app settings

            oDCAppUser = ofbBiz.GetAppUser(osonetpie, QSVars["ADID"].ToString(), QSVars["user_id"].ToString());

            //Prefill Email id
            if (oDCAppUser != null) txtLeadEmailID.Text = oDCAppUser.EmailID;
            GetSiteDetails();
            string strUrl = Server.MapPath(oSiteDetails.FolderPathTool) + "\\index.html";

            HtmlDocument doc = new HtmlDocument();
            doc.Load(strUrl, Encoding.UTF8); //load the HTML located at strURL

            //now take out HTML where class="row-2" as this is the html we want User to print/email
            //var divToEmail = from myHTML in doc.DocumentNode.SelectNodes("//div[@class='row-2']") select myHTML;

            HtmlNode node = doc.DocumentNode.SelectSingleNode("//div[starts-with(@class, 'row-2')]");
            var images = node.SelectNodes("//img/@src").ToList();

            string final = images[6].OuterHtml;
            string[] splitFinal = final.Split('"');

            imgSRC = splitFinal[3].ToString();
            Session["imgSRC"] = oSiteDetails.FolderPathTool+ imgSRC;
            string[] filenameSplit = imgSRC.Split('/');
            string filename = filenameSplit[1].ToString();

            litEmailbody.Text = node.InnerHtml.Replace(imgSRC,"images1/"+oSiteDetails.SiteID+"/"+filename);
            litEmailbody.Text = litEmailbody.Text.Replace("~/Template/Amalgam v1.0/", "");
        }
示例#19
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //litOGTags.Text = GetOGMetaTags();
            NotifyURL = ConfigurationSettings.AppSettings["NotifyURL"];

            if (Request["acc_tok"] != null)
            {
                access_tok = Request["acc_tok"].ToString();
            }

            if (Request["uID"] != null)
            {
                userID = Request["uID"].ToString();
            }
            if (Request["app_id"] != null)
            {
                app_id = Request["app_id"].ToString();
            }
            litEnableFBJS.Text = GetInitializedJS();
            //string id = hdnUserID.Value;
            FaceBook facebook = new FaceBook();

            if (!string.IsNullOrEmpty(access_tok))
            {
                oDCAppUser = facebook.GetUserDetail(userID, access_tok, oDCAppUser);
            }

            oDCAppUser.AppConfigDID = fbBiz.GetConfigDEED(app_id);
            ADID = oDCAppUser.AppConfigDID;
            //Now INSERT User details to AppUser table
            if (Request.UserAgent.ToLower().Contains("iphone") || Request.UserAgent.ToLower().Contains("android"))
            {
                oDCAppUser.SonetSRC = MOBILE_USER;
            }
            else
            {
                oDCAppUser.SonetSRC = TAB_USER;
                if (Request.UserAgent.ToLower().Contains("ipad"))
                {
                    //modify css to suit width

                }
            }

            if (string.IsNullOrEmpty(oDCAppUser.SonetID))
            {
                oDCAppUser.SonetID = userID;
            }

            if (!fbBiz.IsAppUserExistMobile(oDCAppUser))
            {
                if (fbBiz.SetAppUserAuthorize(oDCAppUser, ADID)) //
                {
                }
            }

            bool ISPageLiked;
            if (!string.IsNullOrEmpty(access_tok))
            {
                ISPageLiked = facebook.IsPageLiked("314911595222628", access_tok);
            }
            else
            {
                ISPageLiked = false;
            }

            //show HTML, LIKE gatewat
            if (!fbBiz.IsLikeGatewayAdded(app_id)) // If Already liked show page else Force user to like, iff like gateway was selected
            {

                SessionData.Config = new AppConfiguration();
                SessionData.Config.DID = fbBiz.GetConfigDEED(app_id);
                //check if configuration is still good- that means not EXPIRED
                if (!fbBiz.IsConfigurationExpired(SessionData.Config.DID))
                {
                    //populate the AppProduct encapsulation based on app that is loaded
                    AppProduct oAppProduct = new AppProduct();

                    oAppProduct = fbBiz.GetActiveAppProduct(osonetpie, SessionData.Config.DID);
                    string HTML = oAppProduct.ProductHTML;

                    //Get Custom Tab name
                    string CustTabNAme = fbBiz.GetCustomTabName(app_id);

                    //Get Share Button for this Product
                    string CommentBox = GetCommentPlugin(oAppProduct.DID, oAppProduct.ProductName, oAppProduct.ProductLogo, oAppProduct.ProductShortDesc, app_id, fbBiz.GetAppPagePath(app_id));
                    string ShareButton = GetShareButton(oAppProduct.DID, oAppProduct.ProductName, oAppProduct.ProductLogo, oAppProduct.ProductShortDesc, app_id, CustTabNAme);
                    string InviteButton = GetInviteButton(oAppProduct.DID, oAppProduct.ProductName, oAppProduct.ProductLogo, oAppProduct.ProductShortDesc, app_id);
                    string RecommendButton = GetRecommendButtonForMobile(oAppProduct.DID, oAppProduct.ProductName, oAppProduct.ProductLogo, oAppProduct.ProductShortDesc, app_id);
                    string LikePlugin = GetLikePlugin(oAppProduct.DID, oAppProduct.ProductName, oAppProduct.ProductLogo, oAppProduct.ProductShortDesc, app_id);
                    string PrintButton = GetPrint(oAppProduct.DID, oAppProduct.ProductName, oAppProduct.ProductLogo, oAppProduct.ProductShortDesc, app_id);
                    string EmailButton = GetEmail(oAppProduct.DID, oAppProduct.ProductName, oAppProduct.ProductLogo, oAppProduct.ProductShortDesc, app_id);
                    //string TwitterButton = GetTwitterShareURL(oAppProduct.DID, oAppProduct.ProductName, oAppProduct.ProductLogo, oAppProduct.ProductShortDesc, app_id);
                    // Get the HTML to be shown
                    if (!oAppProduct.ProductCategory.Equals("WebHutColl."))
                    {

                        if (oAppProduct.CommentsWidgetAdded.Equals(TRUE))
                        {
                            addCOMMENT = HTML.Replace("CommBox", CommentBox);
                        }
                        else
                        {
                            addCOMMENT = HTML.Replace("CommBox", "");
                        }

                        if (oAppProduct.ShareWidgetAdded.Equals(TRUE))
                        {
                            addSHARE = addCOMMENT.Replace("ShButton", ShareButton);
                        }
                        else
                        {
                            addSHARE = addCOMMENT.Replace("ShButton", "");
                        }
                        if (oAppProduct.ReccWidgetAdded.Equals(TRUE))
                        {
                            if (canv.IsConfigForSweepstakes(oAppProduct.AppConfigDID))
                            {
                                addCaption = addSHARE.Replace("ReButton", InviteButton);
                            }
                            else
                            {
                                addCaption = addSHARE.Replace("ReButton", RecommendButton);
                            }
                        }
                        else
                        {
                            addCaption = addSHARE.Replace("ReButton", "");
                        }

                        addLead = addCaption.Replace("Lead", "");
                        addLIKE = addLead.Replace("Like", LikePlugin);
                        addPOST = addLIKE.Replace("Caption", oAppProduct.AppCaption);
                        addTwitter = addPOST.Replace("TwButton", "");

                        litHTML.Text = addTwitter;
                    }
                    else
                    {
                        headRow.Style.Remove("background-color");
                        mainRow.Style.Remove("background-color");
                        //render Webhut template

                        SiteID = fbBiz.GetSiteIDForConfig(Convert.ToString(ADID));
                        SessionData.Config = new AppConfiguration();
                        SessionData.Config.SSiteID = SiteID;
                        int TemplateID = fbBiz.GetTemplateIDForConfig(Convert.ToString(ADID));

                        pageToLoad = "index.html";
                        StreamReader streamReader = new StreamReader(Server.MapPath("Sites\\Final\\" + SiteID + "\\" + pageToLoad));
                        string text = streamReader.ReadToEnd();
                        streamReader.Close();

                        //check for DirtyPage
                        string Query = "select DirtyPage from Sites where SiteId=" + SiteID;

                        DataSet oDataSet = new DataSet();
                        SqlHelper.FillDataset(ConfigurationSettings.AppSettings["SoConn"].ToString(), CommandType.Text, Query, oDataSet, new string[] { "SiteDetails" });

                        string isDirty = Convert.ToString(oDataSet.Tables["SiteDetails"].Rows[0]["DirtyPage"]);

                        if (isDirty.Equals("Y"))
                        {
                            text = text.Replace("<img class=\"dynamic\" src=\"images/SNR_facebook.png\">", ShareButton);

                            text = text.Replace("<img class=\"dynamic\" src=\"images/SNR_recommend.png\">", RecommendButton);

                            text = text.Replace("<img class=\"dynamic\" src=\"images/fb-like-button.png\">", LikePlugin);

                            text = text.Replace("<img class=\"dynamic\" src=\"images/SNR_twitter.png\">", "");

                            if (TemplateID == 11)
                            {
                                text = text.Replace("<img class=\"ActionImg\" src=\"Images/email.png\" />", EmailButton);
                                text = text.Replace("<img class=\"ActionImg\" src=\"Images/print.png\" />", PrintButton);
                            }
                        }
                        else
                        {
                            text = text.Replace("<img class=\"dynamic\" src=\"images/SNR_facebook.png\" />", ShareButton);

                            text = text.Replace("<img class=\"dynamic\" src=\"images/SNR_recommend.png\" />", RecommendButton);

                            text = text.Replace("<img class=\"dynamic\" src=\"images/fb-like-button.png\" />", LikePlugin);

                            text = text.Replace("<img class=\"dynamic\" src=\"images/SNR_twitter.png\" />", "");
                            if (TemplateID == 11)
                            {
                                text = text.Replace("<img class=\"ActionImg\" src=\"Images/email.png\" />", EmailButton);
                                text = text.Replace("<img class=\"ActionImg\" src=\"Images/print.png\" />", PrintButton);
                            }
                        }

                        //fix all Image tags
                        string imagesReplaced = text.Replace("images", "images1/" + SiteID);

                        String style;

                        if (TemplateID == 12)
                        {
                            style = "/CSS/RStore_style.css";
                            SessionData.PrefData.TemplateID1 = TemplateID;
                        }
                        else if (TemplateID == 13)
                        {
                            style = "/CSS/FabrikStyle.css";

                            SessionData.PrefData.TemplateID1 = TemplateID;
                        }
                        else if (TemplateID == 11)
                        {
                            style = "/CSS/CouponsStyle.css";

                            SessionData.PrefData.TemplateID1 = TemplateID;
                        }
                        else if (TemplateID == 14)
                        {
                            style = "/css/realestate_styles.css";
                            SessionData.PrefData.TemplateID1 = TemplateID;

                        }
                        else
                        {
                            style = "/css/PFstyle.css";
                            SessionData.PrefData.TemplateID1 = TemplateID;
                        }

                        //get all the Images, Styles in
                        System.IO.StreamReader StreamReader1 =
            new System.IO.StreamReader(Server.MapPath("./Sites/Final/" + SiteID + style));
                        string ReadStyle = StreamReader1.ReadToEnd();
                        StreamReader1.Close();

                        if (TemplateID == 14)
                        {
                            HtmlLink linking = Page.FindControl("facebookIDStyleSheets") as HtmlLink;
                            linking.Href = "./Sites/Final/" + SiteID + style;
                        }

                        System.IO.StreamReader StreamReader2 =
            new System.IO.StreamReader(Server.MapPath("./ScriptsSonetReach/Facebookstyles.css"));
                        string CleanStyle = StreamReader2.ReadToEnd();
                        CleanStyle = string.Empty;
                        StreamReader2.Close();

                        System.IO.StreamWriter StreamWriter2 =
            new System.IO.StreamWriter(Server.MapPath("./ScriptsSonetReach/Facebookstyles.css"));
                        StreamWriter2.WriteLine(CleanStyle);
                        StreamWriter2.Close();

                        System.IO.StreamWriter StreamWriter1 =
            new System.IO.StreamWriter(Server.MapPath("./ScriptsSonetReach/Facebookstyles.css"));
                        StreamWriter1.WriteLine(ReadStyle);
                        StreamWriter1.Close();

                        ////saranya

                        //System.IO.StreamReader sr = new System.IO.StreamReader(Server.MapPath("./ScriptsSonetReach/Facebookstyles.css"));
                        //String fileContents = sr.ReadToEnd();
                        //sr.Close();

                        //System.IO.StreamWriter sw = new System.IO.StreamWriter(Server.MapPath("./ScriptsSonetReach/Facebookstyles.css"));
                        //fileContents = fileContents.Replace("images", "images1/" + SiteID + "");
                        //sw.WriteLine(fileContents);
                        //sw.Close();

                        ///NOW process all the images
                        string imagePath = Server.MapPath("./Sites/Final/" + SiteID + "/Images/");
                        string[] files = System.IO.Directory.GetFiles(imagePath);

                        if (!Directory.Exists(Server.MapPath("./Images1/" + SiteID)))
                        {
                            Directory.CreateDirectory(Server.MapPath("./Images1/" + SiteID));
                        }

                        foreach (string file in files)
                        {
                            if (!System.IO.File.Exists(Server.MapPath("./Images1/" + SiteID + "/" + System.IO.Path.GetFileName(file))))
                            {
                                System.IO.File.Copy(file, System.IO.Path.Combine(Server.MapPath("./Images1/" + SiteID), System.IO.Path.GetFileName(file)));
                            }
                        }
                        LoadComplete = true;

                        litHTML.Text = imagesReplaced;

                        if (TemplateID == 13)
                        {
                            litHTML.Text = litHTML.Text.Replace("<link href=\"CSS/FabrikStyle.css\" rel=\"stylesheet\" type=\"text/css\">", "");
                        }
                        else if (TemplateID == 11)
                        {
                            litHTML.Text = litHTML.Text.Replace("<link href=\"CSS/CouponsStyle.css\" rel=\"stylesheet\" type=\"text/css\" />", "");
                        }
                    }
                }
            }
            else
            {
                if (ISPageLiked)
                {
                    SessionData.Config = new AppConfiguration();
                    SessionData.Config.DID = fbBiz.GetConfigDEED(app_id);
                    //check if configuration is still good- that means not EXPIRED
                    if (!fbBiz.IsConfigurationExpired(SessionData.Config.DID))
                    {
                        //populate the AppProduct encapsulation based on app that is loaded
                        AppProduct oAppProduct = new AppProduct();

                        oAppProduct = fbBiz.GetActiveAppProduct(osonetpie, SessionData.Config.DID);
                        // Get the HTML to be shown

                        string HTML = oAppProduct.ProductHTML;

                        //Get Custom Tab name
                        string CustTabNAme = fbBiz.GetCustomTabName(app_id);

                        //Get Share Button for this Product
                        string CommentBox = GetCommentPlugin(oAppProduct.DID, oAppProduct.ProductName, oAppProduct.ProductLogo, oAppProduct.ProductShortDesc, app_id, fbBiz.GetAppPagePath(app_id));
                        string ShareButton = GetShareButton(oAppProduct.DID, oAppProduct.ProductName, oAppProduct.ProductLogo, oAppProduct.ProductShortDesc, app_id, CustTabNAme);
                        string InviteButton = GetInviteButton(oAppProduct.DID, oAppProduct.ProductName, oAppProduct.ProductLogo, oAppProduct.ProductShortDesc, app_id);
                        string RecommendButton = GetRecommendButtonForMobile(oAppProduct.DID, oAppProduct.ProductName, oAppProduct.ProductLogo, oAppProduct.ProductShortDesc, app_id);
                        string LikePlugin = GetLikePlugin(oAppProduct.DID, oAppProduct.ProductName, oAppProduct.ProductLogo, oAppProduct.ProductShortDesc, app_id);
                        //string EntryFormPlug = GetEntryForm(oAppProduct.DID, oAppProduct.ProductName, oAppProduct.ProductLogo, oAppProduct.ProductShortDesc, QSVars["ADID"].ToString(), QSVars["user_id"].ToString());
                        //string LeadPlugin = GetLeadButton(oAppProduct.DID, oAppProduct.ProductName, oAppProduct.ProductLogo, oAppProduct.ProductShortDesc, QSVars["AppID"].ToString());
                        //string PrintButton = GetPrint(oAppProduct.DID, oAppProduct.ProductName, oAppProduct.ProductLogo, oAppProduct.ProductShortDesc, QSVars["AppID"].ToString());
                        //string EmailButton = GetEmail(oAppProduct.DID, oAppProduct.ProductName, oAppProduct.ProductLogo, oAppProduct.ProductShortDesc, QSVars["AppID"].ToString());
                        if (oAppProduct.CommentsWidgetAdded.Equals(TRUE))
                        {
                            addCOMMENT = HTML.Replace("CommBox", CommentBox);
                        }
                        else
                        {
                            addCOMMENT = HTML.Replace("CommBox", "");
                        }

                        if (oAppProduct.ShareWidgetAdded.Equals(TRUE))
                        {
                            addSHARE = addCOMMENT.Replace("ShButton", ShareButton);
                        }
                        else
                        {
                            addSHARE = addCOMMENT.Replace("ShButton", "");
                        }
                        if (oAppProduct.ReccWidgetAdded.Equals(TRUE))
                        {
                            if (canv.IsConfigForSweepstakes(oAppProduct.AppConfigDID))
                            {
                                addCaption = addSHARE.Replace("ReButton", InviteButton);
                            }
                            else
                            {
                                addCaption = addSHARE.Replace("ReButton", RecommendButton);
                            }
                        }
                        else
                        {
                            addCaption = addSHARE.Replace("ReButton", "");
                        }

                        addLead = addCaption.Replace("Lead", "");
                        addLIKE = addLead.Replace("Like", LikePlugin);
                        addPOST = addLIKE.Replace("Caption", oAppProduct.AppCaption);
                        addTwitter = addPOST.Replace("TwButton", "");
                        litHTML.Text = addTwitter;
                    }
                    else
                    {
                        litHTML.Text = "Oops! Looks like your aplication expired. Please buy credits to continue.";
                    }
                }
                else
                {
                    if ((Request.QueryString.Count == 1 && Request.QueryString["app_id"] != null) || (!string.IsNullOrEmpty(access_tok)))
                    {
                        //string pagePath = fbBiz.GetAppPath(Request["app_id"].ToString());
                        //Page.ClientScript.RegisterStartupScript(this.GetType(), "myCloseScript", "window.parent.location.href='" + pagePath + "'", true);
                    }
                    else
                    {
                        litHTML.Text = " <div class=\"fb-like\" data-href=\"https://www.testsonetreach.com/MobileRedirect.aspx?app_id=295889527140091\" data-send=\"false\" data-width=\"400\" data-show-faces=\"true\"></div>";
                    }
                }
            }
        }
示例#20
0
        public string GetEmbedURL(string url, AppUser oDCAppUser)
        {
            try
            {
                string RetHTML = "";
                StringBuilder _sbFriendInfoURL = new StringBuilder();
                _sbFriendInfoURL.Append("http://api.embed.ly/1/oembed?url=");
                _sbFriendInfoURL.Append(HttpUtility.UrlEncode(url));
                _sbFriendInfoURL.Append("&maxwidth=450");
                _sbFriendInfoURL.Append("&format=JSON");

                //Parse json to get MXDBAppUser
                string _sFriendsInfoJson = CallWebRequest("GET", _sbFriendInfoURL.ToString(), string.Empty);

                //Create DataTable
                DataTable oFriendsTable = new DataTable("FriendsTable");
                DataColumn osoNETID = new DataColumn("HTML");
                oFriendsTable.Columns.Add(osoNETID);
                //DataColumn oImage = new DataColumn("Image");
                //oFriendsTable.Columns.Add(oImage);
                //DataColumn oName = new DataColumn("Name");
                //oFriendsTable.Columns.Add(oName);
                //DataColumn oLocation = new DataColumn("Location");
                //oFriendsTable.Columns.Add(oLocation);
                //DataColumn oGender = new DataColumn("Gender");
                //oFriendsTable.Columns.Add(oGender);

                //Convert Json to JsonDictionary <of String, object>
                System.Web.Script.Serialization.JavaScriptSerializer _oJavaScriptSerializer = new System.Web.Script.Serialization.JavaScriptSerializer();

                Dictionary<string, object> values = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, object>>(_sFriendsInfoJson);
                if (values.Keys.Count > 0)
                {
                    if (values.Keys.Contains("html"))
                    {
                        RetHTML = values["html"].ToString();
                    }
                    else
                    {
                        RetHTML = string.Empty;
                    }
                }
                return RetHTML;
            }
            catch (Exception ex)
            {
                //Something went wrong while parsing friend current_location
                throw ex;
            }
        }
示例#21
0
        public AppUser GetUserDetail(string sUserID, string soauth_token, AppUser oDCAppUser)
        {
            if (string.IsNullOrEmpty(soauth_token)) throw new Exception("Specify valid access token.");
            if (string.IsNullOrEmpty(sUserID)) throw new Exception("Specify valid userid.");

            StringBuilder _sbUserInfoURL = new StringBuilder();
            _sbUserInfoURL.Append("https://api.facebook.com/method/fql.query?query=");
            _sbUserInfoURL.Append("SELECT name,pic,current_location,email,sex,birthday_date,friend_count FROM user WHERE uid =");
            _sbUserInfoURL.Append("'" + sUserID + "'");
            _sbUserInfoURL.Append("&access_token=" + soauth_token);
            _sbUserInfoURL.Append("&format=JSON");

            //Parse json to get MXDBAppUser
            string _sUserInfoJson = CallWebRequest("GET", _sbUserInfoURL.ToString(), string.Empty);
            object[] oUserLocationDataRow = new object[7];
            //Convert Json to JsonDictionary <of String, object>
            System.Web.Script.Serialization.JavaScriptSerializer _oJavaScriptSerializer = new System.Web.Script.Serialization.JavaScriptSerializer();
            object _oJSONObject = _oJavaScriptSerializer.DeserializeObject(_sUserInfoJson);
            int i = 0;
            for (i = 0; i <= ((object[])_oJSONObject).Length - 1; i++)
            {
                Dictionary<string, object> _ojsonUserDetails = (Dictionary<string, object>)((object[])_oJSONObject)[i];
                foreach (KeyValuePair<string, object> _oKeyjsonUserDetailsItem in _ojsonUserDetails)
                {
                    switch (_oKeyjsonUserDetailsItem.Key)
                    {
                        case "name": //set Email
                            oDCAppUser.UserName = Convert.ToString(_oKeyjsonUserDetailsItem.Value);
                            break;

                        case "pic": //set User name
                            oDCAppUser.ImageURL = Convert.ToString(_oKeyjsonUserDetailsItem.Value);
                            break;

                        case "email": //set contact email
                            oDCAppUser.EmailID = Convert.ToString(_oKeyjsonUserDetailsItem.Value);
                            break;

                        case "current_location": // set current location
                            if (_oKeyjsonUserDetailsItem.Value != null && Convert.ToString(_oKeyjsonUserDetailsItem.Value).Length > 0)
                            {
                                //set location fields
                                Dictionary<string, object> jsonlocationDict = (Dictionary<string, object>)_oKeyjsonUserDetailsItem.Value;
                                foreach (KeyValuePair<string, object> _olocationItem in jsonlocationDict)
                                {
                                    switch (_olocationItem.Key.ToLower())
                                    {
                                        case "city":
                                            if (Convert.ToString(_olocationItem.Value).Length > 0)
                                            {
                                                string[] _olocationvalue = Convert.ToString(_olocationItem.Value).Split(new string[] { "," }, StringSplitOptions.None);
                                                if (_olocationvalue.Length >= 1) oDCAppUser.City = _olocationvalue[0];
                                            }
                                            break;

                                        case "state":
                                            if (Convert.ToString(_olocationItem.Value).Length > 0)
                                            {
                                                string[] _olocationvalue = Convert.ToString(_olocationItem.Value).Split(new string[] { "," }, StringSplitOptions.None);
                                                if (_olocationvalue.Length >= 1) oDCAppUser.State = _olocationvalue[0];
                                            }
                                            break;

                                        case "country":
                                            if (Convert.ToString(_olocationItem.Value).Length > 0)
                                            {
                                                string[] _olocationvalue = Convert.ToString(_olocationItem.Value).Split(new string[] { "," }, StringSplitOptions.None);
                                                if (_olocationvalue.Length >= 1) oDCAppUser.Country = _olocationvalue[0];
                                            }
                                            break;

                                        default:
                                            break; //Could not parse location json element
                                    }
                                }
                            }
                            break;
                        case "sex": oDCAppUser.Gender = Convert.ToString(_oKeyjsonUserDetailsItem.Value);
                            break;
                        case "birthday_date": oDCAppUser.SBirthdate = Convert.ToString(_oKeyjsonUserDetailsItem.Value);
                            break;
                        case "friend_count": oDCAppUser.SFriend_count = Convert.ToString(_oKeyjsonUserDetailsItem.Value);
                            break;
                    }
                }
            }

            return oDCAppUser;
        }
示例#22
0
        protected override void OnPreLoad(EventArgs e)
        {
            string PDID = string.Empty;
            string NDID = string.Empty;
            string ADID = string.Empty;
            string UDID = string.Empty;
            string NTYP = string.Empty;
            string user_id = string.Empty;
            string TO_id = string.Empty;
            try
            {
                base.OnPreLoad(e);
                //Initialize KOKO
                SonetPie osonetpie = new SonetPie();
                osonetpie.QSvarsString = GetQsVarsCollection();
                osonetpie.AbsolutePath = AbsolutePagePath;

                //Call Service to load app settings
                AppUser oAppUser = new AppUser();
                AppLeadData oAppLead = new AppLeadData();
                FacebookBizProcess ofbBiz = new FacebookBizProcess();
                SonetPieBizProcess sonetpiebiz = new SonetPieBizProcess();

                //CHeck if User has Liked. Using Jquery AJAX we will get Params in Request.Form
                if (Request.HttpMethod == "POST")
                {
                    PDID = Request.Form["PDID"];
                    NDID = Request.Form["NDID"];
                    ADID = Request.Form["ADID"];
                    UDID = Request.Form["UDID"];
                    NTYP = Request.Form["NTYP"];
                    user_id = Request.Form["user_id"];

                    oAppUser = ofbBiz.GetAppUser(osonetpie, ADID, user_id);

                    if (NTYP != null && UDID != null && PDID != null)
                    {
                        if (ofbBiz.RaiseAppNotifier(oAppUser, NTYP, UDID, PDID, NDID, oAppLead, string.Empty))
                            litRunTimeHTMLContent.Text = "Successfully raised notifier.";
                        else
                            litRunTimeHTMLContent.Text = "Unable to raise notifier.";
                    }
                    else litRunTimeHTMLContent.Text = "In-Complete information.";
                }
                else
                {
                    if (QSVars["NTYP"].ToString().Equals("MPOST"))
                    {
                        if (!QSVars.Contains("UDID"))
                        {
                            UDID = ofbBiz.GetUserDID(QSVars["ADID"].ToString(), Request["userID"].ToString());
                            if (Request.Cookies.AllKeys[0] != null)
                            {
                                TO_id = Request.Cookies.AllKeys[0];
                                if (TO_id.Contains(","))
                                {
                                    string[] allFriends = TO_id.Split(',');
                                    for (int i = 0; i < allFriends.Length; i++)
                                    {
                                        if (ofbBiz.RaiseAppNotifier(oAppUser, Convert.ToString(QSVars["NTYP"]), UDID, Convert.ToString(QSVars["PDID"]), "", oAppLead, allFriends[i]))
                                            litRunTimeHTMLContent.Text = "Successfully raised notifier.";
                                        else
                                            litRunTimeHTMLContent.Text = "Unable to raise notifier.";
                                    }
                                }
                                else
                                {
                                    if (ofbBiz.RaiseAppNotifier(oAppUser, Convert.ToString(QSVars["NTYP"]), UDID, Convert.ToString(QSVars["PDID"]), "", oAppLead, TO_id))
                                        litRunTimeHTMLContent.Text = "Successfully raised notifier.";
                                    else
                                        litRunTimeHTMLContent.Text = "Unable to raise notifier.";
                                }
                            }
                        }

                        if (ofbBiz.RaiseAppNotifier(oAppUser, Convert.ToString(QSVars["NTYP"]), UDID, Convert.ToString(QSVars["PDID"]), "", oAppLead, TO_id))
                            litRunTimeHTMLContent.Text = "Successfully raised notifier.";
                        else
                            litRunTimeHTMLContent.Text = "Unable to raise notifier.";

                    }
                    else
                    {
                        bool CheckLikeNotify = ofbBiz.CheckLikeNotify(QSVars["UDID"].ToString());
                        if (CheckLikeNotify != true)
                        {
                            oAppUser = ofbBiz.GetAppUser(osonetpie, QSVars["ADID"].ToString(), QSVars["user_id"].ToString());

                            //Load AppUser from DB Based on user_id
                            if (QSVars.Contains("NTYP") && QSVars.Contains("UDID") && QSVars.Contains("PDID"))
                            {
                                if (ofbBiz.RaiseAppNotifier(oAppUser, Convert.ToString(QSVars["NTYP"]), Convert.ToString(QSVars["UDID"]), Convert.ToString(QSVars["PDID"]), Convert.ToString(QSVars["NDID"]), oAppLead, string.Empty))
                                    litRunTimeHTMLContent.Text = "Successfully raised notifier.";
                                else
                                    litRunTimeHTMLContent.Text = "Unable to raise notifier.";
                            }
                            else litRunTimeHTMLContent.Text = "In-Complete information.";
                        }
                    }
                }

            }
            catch (Exception ex)
            {
                DigiMa.Common.CommonUtility objCommon = new CommonUtility();
                objCommon.SendErrorMail(ex.Message, ex.StackTrace, System.Reflection.MethodBase.GetCurrentMethod().Name.ToString(), System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString(), "");
            }
        }
示例#23
0
        protected void btnPublish_Click(object sender, EventArgs e)
        {
            try
            {
                //SessionData.Config = new AppConfiguration();
                if (SessionData.PrefData.TaskTwo1.Equals(MICROSITE))
                {
                    CopyToMicrosites(SessionData.UserAction.SiteID1, txtSubDomainName.Text.Trim());
                }

                if (SessionData.PrefData.TaskTwo1.Equals(YOUTUBE))
                {
                    //ask for uploading video and save in Userfiles
                    if (fileYoutubeVideo.HasFile)
                    {
                        string filename = fileYoutubeVideo.FileName;
                        string path = Server.MapPath("./Youtube/" + SessionData.UserAction.SiteID1);

                        if (!Directory.Exists(path))
                        {
                            Directory.CreateDirectory(path);
                        }
                        string strFinalFileName = Path.GetFileName(fileYoutubeVideo.FileName);
                        long FileLength = fileYoutubeVideo.PostedFile.ContentLength;

                        fileYoutubeVideo.PostedFile.SaveAs(path + "/" + filename);

                        if (UploadToYoutube(filename))
                        {
                            //Page.ClientScript.RegisterStartupScript(this.GetType(), "myCloseScript", "alert(\"Youtube video uploaded !\")", true);
                            SessionData.UserAction.TaskComplete = YOUTUBE;
                        }
                    }
                }

                SessionData.Product = new AppProduct();
                SessionData.Product.DID = GetNewDIDWithPrefix();

                //Prepare file system directory to store Images
                string pathToCreate = "~/Images/" + SessionData.Product.DID;
                if (!Directory.Exists(Server.MapPath(pathToCreate)))
                {
                    Directory.CreateDirectory(Server.MapPath(pathToCreate));
                }

                //Fetch Template Data
                dsTemplateData = canv.GetTempData(Convert.ToInt32(templateID)); //REVISIT
                hdnTrmplateID.Value = templateID;

                hdnPDID.Value = SessionData.Product.DID;
                hdnfield.Value = CDID;
                if (!Directory.Exists(Server.MapPath(pathToCreate)))
                {
                    Directory.CreateDirectory(Server.MapPath(pathToCreate));
                }

                //Caption
                //if (!string.IsNullOrEmpty(txtHeaderText.Text))
                //{
                //    SessionData.Product.AppCaption = txtHeaderText.Text;
                //}

                SessionData.Product.ProductCategory = WH_CREATED;
                //Start Date, Expiry Date
                FacebookBizProcess fbBiz = new FacebookBizProcess();
                if (fbBiz.IsAppCreationAllowed(SessionData.Customer.CustomerID)) //check if user is allowed to create Promos etc under his current plan *****************************************************************
                {
                    SessionData.Config = new AppConfiguration();
                    AppConfiguration oAppAvaila = new AppConfiguration();
                    oAppAvaila = fbBiz.GetAvailableConfig(CDID);
                    SessionData.Config = oAppAvaila;
                    SessionData.Config.DID = GetNewDID("AN");

                    //Custom Tab Name
                    if (!txtCustomTabNamePromoVid.Text.Trim().Equals(string.Empty))
                    {
                        SessionData.Config.SCustomtTabName = txtCustomTabNamePromoVid.Text.Trim();
                        SessionData.UserAction.CustomTabName1 = txtCustomTabNamePromoVid.Text.Trim();
                    }
                    SessionData.Config.STemplatePage = TEMPLATE_PAGE;
                }
                else
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "myCloseScript", "alert(\"You can only create 3 Campaigns with a TRIAL account !\")", true);
                }

                FaceBook ofacebook = new FaceBook();
                AppUser oAppUser = new AppUser();

                SessionData.Config.SSiteID = SiteID;
                SessionData.Config.STemplateID = SessionData.PrefData.TemplateID1;

                SessionData.Product.ProductLogo = "https://www.sonetreach.com/Images/" + SessionData.Product.DID + "/Logo" + SessionData.Product.ProductLogo;
                SessionData.Product.SProductContentImage = "Body" + hdnContent.Value;

                if (!(SessionData.Config == null))
                {

                    //Now fill up the Config and get Product data.
                    SessionData.Config.SCampaignType = Video;
                    if (fbBiz.SetNewConfigDetails(SessionData.Config, SessionData.Config.SCustomtTabName, Video))
                    {
                        //Update expiry date
                        fbBiz.UpdateConfigExpiryForWH(SessionData.Config.DID);

                        ////********If user comes here we know we should set up a Product Info, So, create a row in AppProduct and assign these values to SessionData********

                        SessionData.Product.AppConfigDID = SessionData.Config.DID;
                        SessionData.Product.ProductName = SessionData.Config.AppName;
                        SessionData.Product.ProductHTML = "";

                        fbBiz.SetNewProductDetails(SessionData.Product);

                        SessionData.Product = fbBiz.GetAppProductDetails();
                    }
                }
                else
                {
                    //No configs allowed
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "myCloseScript", "alert(\"Config Not Available. Please Contact HELPDESK.\");", true);
                }

                if (SessionData.Config.SAppPageTabSelected == null)
                {

                    StringBuilder oSBPageSElector = new StringBuilder();
                    oSBPageSElector.Append("window.open('http://www.facebook.com/dialog/permissions.request?app_id=");
                    oSBPageSElector.Append(SessionData.Config.AppID + "&redirect_uri=" + ActiveURL + SessionData.Config.AppID + "&response_type=code&perms=user_birthday,user_location,email,manage_pages\','name','height=140,width=790,menubar=0,toolbar=0,statusbar=0,scrollbars=0,resizable=0');");
                    litLogin.Text = oSBPageSElector.ToString();
                }
            }
            catch (Exception ex)
            {
                //commonUtil.SendErrorMail(ex.Message, ex.StackTrace, System.Reflection.MethodBase.GetCurrentMethod().Name.ToString(), System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString(), SessionData.Customer.CustomerID);
                throw ex;
            }
        }
示例#24
0
        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);
            }
        }
示例#25
0
        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;
        }