Exemple #1
0
    private void Subscribe()
    {
        string        db           = ConfigurationManager.ConnectionStrings["DatabaseConnectionString"].ConnectionString;
        string        query        = "EXEC [stp_SS_Subscribe] @uid=" + this.userId + ", @sid=" + this.subscriberId + ",@subscribe=" + this.isSubscribe;
        SqlConnection myConnection = new SqlConnection(db);

        Product p = new Product();

        try
        {
            myConnection.Open();
            using (SqlDataAdapter adp = new SqlDataAdapter(query, myConnection))
            {
                SqlCommand cmd = adp.SelectCommand;
                cmd.CommandTimeout = 300000;
                cmd.ExecuteNonQuery();
            }

            SubscribeStatusMessage msg = new SubscribeStatusMessage();

            string callbackName = Request.QueryString["callback"];
            Response.Write(callbackName + "(" + SerializationHelper.ToJSONString(typeof(SubscribeStatusMessage), msg) + ");");
        }
        finally
        {
            myConnection.Close();
        }
    }
Exemple #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        bool setupVariables = SetupVariables();

        //Check if the userid is same as the session user else return
        if (this.Session["user"] != null)
        {
            UserProfile user = this.Session["user"] as UserProfile;
            if (user.userId != this.userId)
            {
                SubscribeStatusMessage message = new SubscribeStatusMessage()
                {
                    ErrorMessage = "Sorry, we\'ve encountered an unknown error.<br />Please try again."
                };
                string callbackName = Request.QueryString["callback"];
                Response.Write(callbackName + "(" + SerializationHelper.ToJSONString(typeof(SubscribeStatusMessage), message) + ");");
            }
        }
        else
        {
            //get redirect url and get the user to log in via facebook
            //check if there's a look id
            string lookid = string.Empty;
            if (Request.QueryString["lid"] != null)
            {
                lookid = Request.QueryString["lid"];
            }

            string redirectUrl             = FacebookHelper.GetCode(lookid);
            SubscribeStatusMessage message = new SubscribeStatusMessage()
            {
                RedirectUrl = redirectUrl
            };
            string callbackName = Request.QueryString["callback"];
            Response.Write(callbackName + "(" + SerializationHelper.ToJSONString(typeof(SubscribeStatusMessage), message) + ");");
            return;
        }

        if (!setupVariables)
        {
            SubscribeStatusMessage message = new SubscribeStatusMessage()
            {
                ErrorMessage = "Sorry, we\'ve encountered an unknown error.<br />Please try again."
            };
            string callbackName = Request.QueryString["callback"];
            Response.Write(callbackName + "(" + SerializationHelper.ToJSONString(typeof(SubscribeStatusMessage), message) + ");");
        }

        //Save Vote and get the new look
        Subscribe();

        //Send notifications asynchronously
        notifications = new NotificationDelegete(this.SendNotifications);

        string appAccessToken = null;

        //check if app access token exists
        if (this.Session["app_access_token"] != null)
        {
            appAccessToken = this.Session["app_access_token"].ToString();
        }

        notifications.BeginInvoke(appAccessToken, null, null);

        if (Request.QueryString["redirect"] != null)
        {
            Response.Redirect(Request.QueryString["redirect"]);
        }
    }