Пример #1
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"]);
        }
    }
Пример #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (this.Session["contest"] == null)
        {
            this.contestId          = int.Parse(ConfigurationManager.AppSettings["ContestId1"]);
            this.Session["contest"] = this.contestId;
        }
        else
        {
            this.contestId = (int)this.Session["contest"];
        }

        bool setupVariables = SetupVariables();

        if (!setupVariables)
        {
            LookMessage message = new LookMessage()
            {
                ErrorMessage = "Sorry, we\'ve encountered an unknown error.<br />Please try again."
            };
            Response.Write(SerializationHelper.ToJSONString(typeof(LookMessage), message));
        }

        //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)
            {
                LookMessage message = new LookMessage()
                {
                    ErrorMessage = "Sorry, we\'ve encountered an unknown error.<br />Please try again."
                };
                Response.Write(SerializationHelper.ToJSONString(typeof(LookMessage), message));
            }
        }
        else
        {
            LookMessage message = new LookMessage()
            {
                ErrorMessage = "Sorry, we\'ve encountered an unknown error.<br />Please try again."
            };
            Response.Write(SerializationHelper.ToJSONString(typeof(LookMessage), message));
        }

        //Save Look
        LookMessage msg = SaveLook();

        //set up the image for the ocmbined look
        try
        {
            string imageFilePath = Path.Combine(Server.MapPath("images/looks"), msg.Look.id + ".jpg");

            if (msg.Look.products.Count >= 3)
            {
                if (!File.Exists(imageFilePath))
                {
                    WebHelper.CreateLookPanel(msg.Look, imageFilePath);
                }
            }
            else
            {
                if (!File.Exists(imageFilePath))
                {
                    WebHelper.MergeTwoImages(msg.Look.products[0].GetImageUrl(), msg.Look.products[1].GetImageUrl(), imageFilePath);
                }
            }
        }
        catch
        {
            //signal to the pinterest pinner that image unavailable?
        }

        string callbackName = Request.QueryString["callback"];

        Response.Write(callbackName + "(" + SerializationHelper.ToJSONString(typeof(LookMessage), msg) + ");");

        //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(msg.Look, appAccessToken, null, null);
    }
Пример #3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string db = ConfigurationManager.ConnectionStrings["DatabaseConnectionString"].ConnectionString;

        if (string.IsNullOrEmpty(this.Request.QueryString["uid"]))
        {
            VoteStatusMessage message = new VoteStatusMessage()
            {
                ErrorMessage = "Please <a href=\"/register.aspx\">Register</a> or <a href=\"/login.aspx\">login</a> to confirm your vote!<br/>"
            };
            Response.Write(SerializationHelper.ToJSONString(typeof(VoteStatusMessage), message));
            return;
        }

        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)
            {
                VoteStatusMessage message = new VoteStatusMessage()
                {
                    ErrorMessage = "Sorry, we\'ve encountered an unknown error.<br />Please try again."
                };
                string callbackName = Request.QueryString["callback"];
                Response.Write(callbackName + "(" + SerializationHelper.ToJSONString(typeof(VoteStatusMessage), message) + ");");
                return;
            }
            else
            {
                //update the user's points
                user.points         += this.pointIncrement;
                this.Session["user"] = user;
            }
        }
        else
        {
            //get redirect url and get the user to log in via facebook
            string            redirectUrl = FacebookHelper.GetCode(this.lookId.ToString());
            VoteStatusMessage message     = new VoteStatusMessage()
            {
                RedirectUrl = redirectUrl
            };
            string callbackName = Request.QueryString["callback"];
            Response.Write(callbackName + "(" + SerializationHelper.ToJSONString(typeof(VoteStatusMessage), message) + ");");
            return;
        }

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

        if (this.Session["contest"] == null)
        {
            this.contestId          = int.Parse(ConfigurationManager.AppSettings["ContestId1"]);
            this.Session["contest"] = this.contestId;
        }
        else
        {
            this.contestId = (int)this.Session["contest"];
        }
        this.retailerId = long.Parse(ConfigurationManager.AppSettings["Retailer"]);

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

        //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(this.lookId, this.userId, appAccessToken, this.vote, null, null);
    }