private LookMessage SaveLook() { string db = ConfigurationManager.ConnectionStrings["DatabaseConnectionString"].ConnectionString; string query = "EXEC [stp_SS_SaveLook] @product='" + productMap + "', @uid=" + this.userId + ",@tag='" + tagMap + "', @title=N'" + this.title + "',@color ='" + this.colormap + "'"; if (originalLookId != 0) { query += (", @originalLook=" + this.originalLookId); } SqlConnection myConnection = new SqlConnection(db); LookMessage msg = new LookMessage(); try { myConnection.Open(); using (SqlDataAdapter adp = new SqlDataAdapter(query, myConnection)) { SqlCommand cmd = adp.SelectCommand; cmd.CommandTimeout = 300000; System.Data.SqlClient.SqlDataReader dr = cmd.ExecuteReader(); Look look = new Look(); look = Look.GetLookFromSqlReader(dr); msg.Look = look; msg.LookDescription = look.title; foreach (Tag tag in msg.Look.tags) { if (!tag.name.StartsWith("#")) { msg.LookDescription += ("#" + tag.name); } else { msg.LookDescription += tag.name; } msg.LookDescription += " "; } for (int i = 0; i < msg.Look.products.Count; i++) { msg.LookDescription += "#" + (msg.Look.products[i].brandName); if (i < msg.Look.products.Count - 1) { msg.LookDescription += " "; } } } } finally { myConnection.Close(); } return(msg); }
protected virtual void HandleLookMessage(LookMessage Message) { Message.ObjectInfo.ObjectBase.ResolveResources(resourceManager, false); Message.ObjectInfo.ObjectBase.DecompressResources(); }
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); }