protected IEnumerable <PromotionRequest> GetPromotionRequests() { int campusID = -1; if (UsePersonCampusSetting && ArenaContext.Current.Person != null) { campusID = ArenaContext.Current.Person.Campus.CampusId; } PromotionRequestCollection prc = new PromotionRequestCollection(); prc.LoadCurrentWebRequests(TopicAreasSetting, AreaFilterSetting, campusID, int.Parse(MaxItemsSetting), EventsOnlySetting, -1); Random randGen = new Random(); var promotions = (from p in prc.OfType <PromotionRequest>() where p.Priority <= int.Parse(PriorityLevelSetting) + 1 select p).Select(p => new { Promotion = p, Index = (RandomizedSetting) ? randGen.NextDouble() * p.Priority : p.Priority }).OrderBy(p => p.Index) .Select(p => p.Promotion); // filter by campuses if UseConfigCampusSetting is not empty (feature for rev 13) if (!string.IsNullOrEmpty(UseConfigCampusSetting)) { var campuses = UseConfigCampusSetting.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList(); promotions = (from p in promotions where p.Campus == null || p.Campus.CampusId == -1 || campuses.Contains(p.Campus.CampusId.ToString()) select p); } return(promotions.ToList()); }
//private void RegisterScripts() //{ // BasePage.AddCssLink(Page, ResolveUrl(CssFileSetting)); //} void WriteSlider() { PromotionRequestCollection requestCollection = new PromotionRequestCollection(); requestCollection.LoadCurrentWebRequests(TopicAreaIDSetting, "both", intCampus, intMaxItems, boolEventsOnly, intImageType); this.phSlider.Controls.Add((Control) new LiteralControl(string.Format("<div id='{0}' class='slider-outer'>\n", sliderID))); foreach (PromotionRequest promoRequest in requestCollection) { string strTarget = promoRequest.WebExternalLink == promoRequest.DetailUrl("", DetailPageSetting, EventDetailPageSetting) ? "_blank" : "_parent"; try { boolIsFit = Convert.ToBoolean(IsStretchHeightSetting); } catch (FormatException) { Console.WriteLine("Unable to convert '{0}' to a Boolean.", IsStretchHeightSetting); } //this.phSlider.Controls.Add((Control)new LiteralControl("\t<div class='slider-slide' style='display: none;'>\n")); this.phSlider.Controls.Add((Control) new LiteralControl(string.Format("\t\t<a href='{0}' target='{1}' title='{2}' style='display: none;'>\n", promoRequest.DetailUrl("", DetailPageSetting, EventDetailPageSetting), strTarget, promoRequest.Title))); //this.phSlider.Controls.Add((Control)new LiteralControl(string.Format("\t\t<div class='promoText'>{0}</div>\n", promoRequest.WebText))); try { this.phSlider.Controls.Add((Control) new LiteralControl(string.Format("\t\t\t<img src='/CachedBlob.aspx?guid={0}' alt='{1}' style='width: 100%;{2}' />\n", promoRequest.Documents.GetFirstByType(intImageType).GUID, promoRequest.Title, boolIsFit ? " height: 100%;" : ""))); } catch (System.NullReferenceException err) { Console.WriteLine("Error writing image tag. Message = {0}", err.Message); } this.phSlider.Controls.Add((Control) new LiteralControl("\t\t</a>\n")); //this.phSlider.Controls.Add((Control)new LiteralControl("\t</div>\n")); } this.phSlider.Controls.Add((Control) new LiteralControl("</div><!-- /.slider-outer -->\n")); StringBuilder sliderScript = new StringBuilder(); sliderScript.Append("$(window).load(function(){\n"); sliderScript.Append(string.Format("\t$(\"#{0}\").cycle({{\n", sliderID, sliderID)); sliderScript.Append(string.Format("\t\tfx: \'{0}\',\n", SliderTransitionSetting)); sliderScript.Append(string.Format("\t\tspeed: {0},\n", SpeedSetting)); sliderScript.Append(string.Format("\t\ttimeout: {0},\n", TimeoutSetting)); sliderScript.Append(string.Format("\t\tpause: '{0}',\n", IsPauseSetting)); sliderScript.Append(string.Format("\t\tfit: '{0}',\n", IsStretchHeightSetting)); sliderScript.Append(string.Format("\t\twidth: '{0}',\n", SliderWidthSetting)); if (SliderHeightSetting.Length > 0) { sliderScript.Append(string.Format("\t\theight: '{0}',\n", SliderHeightSetting)); } sliderScript.Append("\t\tslideResize: '0',\n"); sliderScript.Append("\t\tcontainerResize: '0',\n"); sliderScript.Append(string.Format("\t\trandom: {0}\n", IsRandomSetting)); sliderScript.Append("\t});\n"); sliderScript.Append("});\n"); Page.ClientScript.RegisterStartupScript(this.GetType(), sliderID, sliderScript.ToString(), true); }
private int GetNextPromotionID() { PromotionRequestCollection prc = new PromotionRequestCollection(); int i, lastID = -1; // // Load all promotions for this display. // prc.LoadCurrentWebRequests(TopicAreaList, "both", CampusID, 1000, false, -1); // // Check for the previous ID number. // if (Request.Params["lastID"] != null) { lastID = Convert.ToInt32(Request.Params["lastID"]); } // // If there were no notes found, return -1. // if (prc.Count == 0) { return(-1); } // // If this was the first time called, return the first note. // if (lastID == -1) { return(prc[0].PromotionRequestID); } // // We have all the ID numbers for this system, snag the next one. // for (i = 0; i < prc.Count; i++) { if (prc[i].PromotionRequestID == lastID) { if (++i >= prc.Count) { return(prc[0].PromotionRequestID); } else { return(prc[i].PromotionRequestID); } } } return(prc[0].PromotionRequestID); }
/// <summary> /// Get a collection of the current web requests active for these topic areas. I forget why /// I had to do this as a custom method, I think something about the way the data is returned /// by the standard built-in methods. /// </summary> /// <returns>A collection of PromotionRequest objects.</returns> private PromotionRequestCollection GetCurrentWebRequests() { SqlConnection conn = new SqlDbConnection().GetDbConnection(); SqlCommand command = new SqlCommand("cust_sp_get_promotion_web_requests", conn); SqlDataReader reader = null; PromotionRequestCollection prc = new PromotionRequestCollection(); ArrayList paramList = new ArrayList(); // // Build up all the command parameters and options. // command.Parameters.Add(new SqlParameter("@TopicAreaIDs", (String.IsNullOrEmpty(TopicAreaList) ? "-1" : TopicAreaList))); command.Parameters.Add(new SqlParameter("@AreaFilter", "both")); command.Parameters.Add(new SqlParameter("@CampusID", -1)); command.Parameters.Add(new SqlParameter("@MaxItems", 1000)); command.Parameters.Add(new SqlParameter("@EventsOnly", false)); command.Parameters.Add(new SqlParameter("@DocumentTypeID", -1)); command.CommandText = "cust_sp_get_promotion_web_requests"; command.Connection = conn; command.CommandType = CommandType.StoredProcedure; try { // // Run the SP and load in all the promotions. // conn.Open(); reader = command.ExecuteReader(CommandBehavior.CloseConnection); while (reader.Read()) { prc.Add(new PromotionRequest((int)reader["promotion_request_id"])); } } catch (System.Exception e) { throw e; } finally { if (reader != null) { reader.Close(); } } return(prc); }
protected IEnumerable <PromotionRequest> GetPromotionRequests() { PromotionRequestCollection prc = new PromotionRequestCollection(); prc.LoadCurrentWebRequests(TopicAreasSetting, AreaFilterSetting, -1, int.Parse(MaxItemsSetting), false, -1); Random randGen = new Random(); var promotions = (from p in prc.OfType <PromotionRequest>() where p.Priority <= int.Parse(PriorityLevelSetting) + 1 select p).Select(p => new { Promotion = p, Index = (RandomizedSetting) ? randGen.NextDouble() * p.Priority : p.Priority }).OrderBy(p => p.Index) .Select(p => p.Promotion); return(promotions.ToList()); }
int FindPromotionRequest(int occurrenceAttendanceID) { PromotionRequestCollection prc = new PromotionRequestCollection(); prc.LoadCurrentWebRequests(TopicAreaID.ToString(), "primary", CampusID, 100, false, -1); foreach (PromotionRequest promotion in prc) { try { if (Convert.ToInt32(promotion.Title) == occurrenceAttendanceID) { return(promotion.PromotionRequestID); } } catch { } } return(-1); }
/// <summary> /// Figure out which is the next promotion/image the client wants and then send the data /// back to the client. /// </summary> private void GetNextPromotion() { PromotionRequestCollection prc = GetCurrentWebRequests(); int i, lastID = -1, nextID = -1, nextIndex = -1; // // Check for the previous ID number. // if (Request.Params["lastID"] != null) { String parm = Request.Params["lastID"]; if (!String.IsNullOrEmpty(parm)) { lastID = Convert.ToInt32(parm.Split(',')[0]); nextIndex = Convert.ToInt32(parm.Split(',')[1]) + 1; } } // // If there were no promotions found, return -1. // if (prc.Count == 0) { nextID = -1; } // // If this was the first time called, return the first image. // else if (lastID == -1) { nextID = prc[0].PromotionRequestID; nextIndex = 0; } // // We have all the ID numbers for this system, snag the next one. // else { for (i = 0; i < prc.Count; i++) { if (prc[i].PromotionRequestID == lastID) { // // Check if the image index is past the images available. // if (nextIndex < prc[i].Documents.Count) { nextID = lastID; break; } // // Otherwise determine if we have another promotion or if we start from beginning. // if (++i >= prc.Count) { nextID = prc[0].PromotionRequestID; } else { nextID = prc[i].PromotionRequestID; } nextIndex = 0; break; } } } SendDisplayXML(nextID, nextIndex); }
//private void RegisterScripts() //{ // BasePage.AddCssLink(Page, ResolveUrl(CssFileSetting)); //} void WriteSlider() { PromotionRequestCollection requestCollection = new PromotionRequestCollection(); requestCollection.LoadCurrentWebRequests(TopicAreaIDSetting, "both", intCampus, intMaxItems, boolEventsOnly, intImageType); this.phSlider.Controls.Add((Control)new LiteralControl(string.Format("<div id='{0}' class='slider-outer'>\n", sliderID))); foreach (PromotionRequest promoRequest in requestCollection) { string strTarget = promoRequest.WebExternalLink == promoRequest.DetailUrl("", DetailPageSetting, EventDetailPageSetting) ? "_blank" : "_parent"; try { boolIsFit = Convert.ToBoolean(IsStretchHeightSetting); } catch (FormatException) { Console.WriteLine("Unable to convert '{0}' to a Boolean.", IsStretchHeightSetting); } //this.phSlider.Controls.Add((Control)new LiteralControl("\t<div class='slider-slide' style='display: none;'>\n")); this.phSlider.Controls.Add((Control)new LiteralControl(string.Format("\t\t<a href='{0}' target='{1}' title='{2}' style='display: none;'>\n", promoRequest.DetailUrl("", DetailPageSetting, EventDetailPageSetting), strTarget, promoRequest.Title))); //this.phSlider.Controls.Add((Control)new LiteralControl(string.Format("\t\t<div class='promoText'>{0}</div>\n", promoRequest.WebText))); try { this.phSlider.Controls.Add((Control)new LiteralControl(string.Format("\t\t\t<img src='/CachedBlob.aspx?guid={0}' alt='{1}' style='width: 100%;{2}' />\n", promoRequest.Documents.GetFirstByType(intImageType).GUID, promoRequest.Title, boolIsFit ? " height: 100%;" : ""))); } catch (System.NullReferenceException err) { Console.WriteLine("Error writing image tag. Message = {0}", err.Message); } this.phSlider.Controls.Add((Control)new LiteralControl("\t\t</a>\n")); //this.phSlider.Controls.Add((Control)new LiteralControl("\t</div>\n")); } this.phSlider.Controls.Add((Control)new LiteralControl("</div><!-- /.slider-outer -->\n")); StringBuilder sliderScript = new StringBuilder(); sliderScript.Append("$(window).load(function(){\n"); sliderScript.Append(string.Format("\t$(\"#{0}\").cycle({{\n", sliderID, sliderID)); sliderScript.Append(string.Format("\t\tfx: \'{0}\',\n", SliderTransitionSetting)); sliderScript.Append(string.Format("\t\tspeed: {0},\n", SpeedSetting)); sliderScript.Append(string.Format("\t\ttimeout: {0},\n", TimeoutSetting)); sliderScript.Append(string.Format("\t\tpause: '{0}',\n", IsPauseSetting)); sliderScript.Append(string.Format("\t\tfit: '{0}',\n", IsStretchHeightSetting)); sliderScript.Append(string.Format("\t\twidth: '{0}',\n", SliderWidthSetting)); if (SliderHeightSetting.Length > 0) { sliderScript.Append(string.Format("\t\theight: '{0}',\n", SliderHeightSetting)); } sliderScript.Append("\t\tslideResize: '0',\n"); sliderScript.Append("\t\tcontainerResize: '0',\n"); sliderScript.Append(string.Format("\t\trandom: {0}\n", IsRandomSetting)); sliderScript.Append("\t});\n"); sliderScript.Append("});\n"); Page.ClientScript.RegisterStartupScript(this.GetType(), sliderID, sliderScript.ToString(), true); }
public void dgNote_ReBind(object sender, EventArgs e) { PromotionRequestCollection prc = new PromotionRequestCollection(); DataTable dt = new DataTable(); ArrayList data = new ArrayList(); dt.Columns.Add("promotion_id"); dt.Columns.Add("number_string"); dt.Columns.Add("created_date"); dt.Columns.Add("created_string"); dt.Columns.Add("created_by"); dt.Columns.Add("first_name"); dt.Columns.Add("full_name"); dt.Columns.Add("sort_name"); dt.Columns.Add("location_name"); dt.Columns.Add("show_name"); prc.LoadCurrentWebRequests(TopicAreaID.ToString(), "primary", CampusID, 1000, false, -1); foreach (PromotionRequest promotion in prc) { OccurrenceAttendance oa; DataRow row = dt.NewRow(); try { oa = new OccurrenceAttendance(Convert.ToInt32(promotion.Title)); row["first_name"] = oa.Person.FirstName; row["full_name"] = oa.Person.FullName; row["sort_name"] = oa.Person.LastName + ", " + oa.Person.FirstName; row["location_name"] = oa.Occurrence.Location; } catch { row["first_name"] = ""; row["full_name"] = ""; row["sort_name"] = ""; row["location_name"] = ""; } row["promotion_id"] = promotion.PromotionRequestID; row["created_date"] = promotion.DateCreated; row["created_string"] = promotion.DateCreated.ToShortDateTimeString(); row["created_by"] = promotion.CreatedBy; row["show_name"] = false; // // Pull out the number and status of the first name. // try { XmlDocument xdoc = new XmlDocument(); xdoc.LoadXml("<body>" + promotion.WebSummary + "</body>"); row["number_string"] = xdoc.ChildNodes[0].ChildNodes[0].ChildNodes[0].Value.ToString(); if (xdoc.ChildNodes[0].ChildNodes.Count == 2) { row["show_name"] = true; } } catch { } dt.Rows.Add(row); } dgNote.DataSource = dt; dgNote.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { int intCampus; if (!int.TryParse(CampusSetting, out intCampus)) { intCampus = -1; } int intMaxItems; if (!int.TryParse(MaxItemsSetting, out intMaxItems)) { intMaxItems = -1; } int intImageType; if (!int.TryParse(ImageTypeSetting, out intImageType)) { intImageType = -1; } bool boolEventsOnly; if (!Boolean.TryParse(EventsOnlySetting, out boolEventsOnly)) { boolEventsOnly = false; } string sliderID = this.ClientID + "_slider"; PromotionRequestCollection requestCollection = new PromotionRequestCollection(); requestCollection.LoadCurrentWebRequests(TopicAreaIDSetting, "both", intCampus, intMaxItems, boolEventsOnly, intImageType); // Paging and Navigation code is commented out: //this.phSlider.Controls.Add((Control)new LiteralControl(string.Format("<div id='nav_{0}' class='nav' style='display: none; position: absolute; z-index: 1000; margin: 0 padding: 3px; background-color: #ffffff; border: 1px solid #dddddd;' />"))); this.phSlider.Controls.Add((Control) new LiteralControl(string.Format("<div id='{0}' class='slider-outer'>\n", sliderID))); foreach (PromotionRequest promoRequest in requestCollection) { //string strTarget = "_parent"; // promoRequest.WebExternalLink == promoRequest.DetailUrl("", DetailPageSetting, EventDetailPageSetting) ? "_blank" : "_parent"; string strTarget = promoRequest.WebExternalLink == promoRequest.DetailUrl("", DetailPageSetting, EventDetailPageSetting) ? "_blank" : "_parent"; this.phSlider.Controls.Add((Control) new LiteralControl(string.Format("<div class='item'>\n"))); this.phSlider.Controls.Add((Control) new LiteralControl(string.Format("\t<a href='{0}' target='{1}'>\n", promoRequest.DetailUrl("", DetailPageSetting, EventDetailPageSetting), strTarget))); this.phSlider.Controls.Add((Control) new LiteralControl(string.Format("\t\t<img src='/CachedBlob.aspx?guid={0}' alt='{1}' style='width: 100%; {2}'>\n", promoRequest.Documents.GetFirstByType(intImageType).GUID, promoRequest.Title, Convert.ToBoolean(IsStretchHeightSetting) ? "height: 100%;" : ""))); this.phSlider.Controls.Add((Control) new LiteralControl("\t</a>\n")); this.phSlider.Controls.Add((Control) new LiteralControl("</div>\n")); } this.phSlider.Controls.Add((Control) new LiteralControl("</div><!-- /.slider-outer -->\n")); StringBuilder sliderScript = new StringBuilder(); sliderScript.Append("$(document).ready(function(){\n"); // Paging and Navigation code is commented out: //sliderScript.Append(string.Format("\t\t$(\'#{0}\').hover(\n", sliderID)); //sliderScript.Append(string.Format("\t\tfunction() {{ $(\'#nav_{0}\').fadeIn(); }},\n", sliderID)); //sliderScript.Append(string.Format("\t\tfunction() {{ $(\'#nav_{0}\').fadeOut(); }}\n", sliderID)); //sliderScript.Append(");\n\n"); sliderScript.Append(string.Format("$(\"#{0}\").cycle({{\n", sliderID, sliderID)); sliderScript.Append(string.Format("fx: \'{0}\',\n", SliderTransitionSetting)); sliderScript.Append(string.Format("speed: {0},\n", SpeedSetting)); sliderScript.Append(string.Format("timeout: {0},\n", TimeoutSetting)); sliderScript.Append(string.Format("pause: {0},\n", IsPauseSetting)); sliderScript.Append("fit: 1,\n"); sliderScript.Append(string.Format("width: {0},\n", SliderWidthSetting)); sliderScript.Append(string.Format("height: {0},\n", SliderHeightSetting)); sliderScript.Append(string.Format("random: {0}\n", IsRandomSetting)); // Paging and Navigation code is commented out: //sliderScript.Append(string.Format("\t\tpager: \'#nav_{0}\'\n", sliderID)); sliderScript.Append("\t});\n"); sliderScript.Append("});\n"); Page.ClientScript.RegisterStartupScript(this.GetType(), sliderID, sliderScript.ToString(), true); }