using framework_business; using framework_library; using System; using System.Collections; using System.Collections.Generic; using System.Configuration; using System.IO; using System.Linq; using System.Reflection; using System.Text; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class _Default : System.Web.UI.Page { private const string imagePath = "upload/gallery/image/"; private const string taskImagePath = "~/upload/tasks/"; #region events /// /// Page Load Event /// /// /// protected void Page_Load(object sender, EventArgs e) { try { if (!Page.IsPostBack) { bool userLoggedIn = false; if (utils.verifySession("user")) userLoggedIn = true; upAddTask.Visible = false; //btnAddTask.CssClass = "btn btn-warning top-right"; //btnAddTask.Visible = false; /* CVH 2016-04-07 Replace web address and image links */ string content = ""; string topContent = ""; oSetup _setup = handler.ReturnSetup(true); if (!_setup.isWebsite && !userLoggedIn) { if (_setup.securePath != String.Empty) Response.Redirect(_setup.securePath + "/admin", false); else Response.Redirect("/admin", false); } lblBanners.Text = handler.ReturnBannerCarousel(pNums.BannerType.Slider.GetHashCode(), "Slider", true, true, true); foreach (oContent pg in xData.GetTypedByCriteriaSpecific("recId", typeof(oContent), "isActive", "1", "sequence")) { ///* CVH 2016-08-15 If Home content name contains login, redirect to login page. This is for instances with no "website" section, only billing, login required before access to site */ //if (!userLoggedIn && pg.title.ToLower().Contains("home") && pg.title.ToLower().Contains("login")) //{ // Response.Redirect("/admin?redirect=home", false); //} //else //{ if (pg.title.ToLower().Contains("home") && !pg.title.ToLower().Contains("top")) content += pg.contentHTML; if (pg.title.ToLower().Contains("top")) { topContent += pg.contentHTML; /* CVH 2016-08-19 Remove for now, Jas to redo using FindControl */ //divTop.Visible = true; } //} } content = content.Replace("{WebAddress}", ConfigurationManager.AppSettings["WebAddy"]); topContent = topContent.Replace("{WebAddress}", ConfigurationManager.AppSettings["WebAddy"]); ArrayList list = xData.GetTypedByCriteriaSpecific("recId", typeof(oGallery), "isActive", "1"); string prepostcare = ""; string shoulderconditions = ""; string ask = ""; string publications = ""; foreach (oGallery gal in list) { string type = ""; foreach (pNums.PictureType typ in Enum.GetValues(typeof(pNums.PictureType))) { if ((int)typ == gal.pictureTypeId) type = typ.ToString(); } //upload/gallery/image/General/raxcvyhwu.jpg if (gal.title == "Home Pre Post Operative Care") prepostcare = imagePath + type + "/" + gal.fileName; else if (gal.title == "Home Shoulder Conditions") shoulderconditions = imagePath + type + "/" + gal.fileName; else if (gal.title == "Home Ask Dr Christelle") ask = imagePath + type + "/" + gal.fileName; else if (gal.title == "Home Publications Testimonials") publications = imagePath + type + "/" + gal.fileName; } content = content.Replace("{Image Pre Post Operative Care}", prepostcare); content = content.Replace("{Image Shoulder Conditions}", shoulderconditions); content = content.Replace("{Image Ask Dr Christelle}", ask); content = content.Replace("{Image Publications Testimonials}", publications); topContent = topContent.Replace("{Image Pre Post Operative Care}", prepostcare); topContent = topContent.Replace("{Image Shoulder Conditions}", shoulderconditions); topContent = topContent.Replace("{Image Ask Dr Christelle}", ask); topContent = topContent.Replace("{Image Publications Testimonials}", publications); /* CVH 2016-08-19 Remove for now, Jas to redo using FindControl */ //lblHomeTop.Text = topContent; lblHomeContent.Text = content; SetHomePromotions(); } if (utils.verifySession("user")) { oUser usr = (oUser)Session["user"]; if (usr.userType == pNums.UserType.AdminUser.GetHashCode() || usr.userType == pNums.UserType.SuperUser.GetHashCode()) { ArrayList list = xData.GetTypedByCriteriaBegins("recId", typeof(oModule), "module", "Tasks"); if (list != null && list.Count > 0) { oModule mod = (oModule)list[0]; if (mod.isActive) upAddTask.Visible = true; } } } } catch (Exception ex) { exception.HandleException("Default:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]); Response.Redirect("/error", false); } } private void SetHomePromotions() { PlaceHolder plc = (PlaceHolder)Page.FindControl("plcPromotion"); Panel pnlPromo = (Panel)Page.FindControl("pnlPromotion"); if (plc != null && pnlPromo != null) { //get all active promotion for the day foreach (oPromotion promotion in xData.GetTypedByCriteriaSpecific("recId", typeof(oPromotion), "isActive,showOnHome,startDate,endDate", "1,1,~<=" + DateTime.Now.ToShortDateString() + ",~>=" + DateTime.Now.ToShortDateString(), "endDate")) { StringBuilder promotionBuilder = new StringBuilder(); promotionBuilder.AppendLine("
"); promotionBuilder.AppendLine("

" + promotion.caption + "

"); promotionBuilder.AppendLine("
"); if (promotion.layoutTypeId == pNums.LayoutType.Stack.GetHashCode()) { foreach (oPromotionFile promotionFile in xData.GetTypedByCriteriaSpecific("recId", typeof(oPromotionFile), "promotionId,isActive", promotion.recId.ToString() + ",1", "fileName")) { promotionBuilder.AppendLine("
"); promotionBuilder.AppendLine("
"); promotionBuilder.AppendLine(""); promotionBuilder.AppendLine("
"); promotionBuilder.AppendLine("
"); } } if (promotion.layoutTypeId == pNums.LayoutType.Tile.GetHashCode()) { int rowNum = 1; foreach (oPromotionFile promotionFile in xData.GetTypedByCriteriaSpecific("recId", typeof(oPromotionFile), "promotionId,isActive", promotion.recId.ToString() + ",1", "fileName")) { if (rowNum % 2 != 0) { promotionBuilder.AppendLine("
"); } promotionBuilder.AppendLine("
"); promotionBuilder.AppendLine(""); promotionBuilder.AppendLine("
"); if (rowNum % 2 == 0) { promotionBuilder.AppendLine("
"); } rowNum++; } } plc.Controls.Add(new LiteralControl(promotionBuilder.ToString())); } if (plc.Controls.Count > 0) { pnlPromo.Visible = true; } } } protected void btnAddTask_Click(object sender, EventArgs e) { try { //if a snapshot for current canvas exists, don't take new snapshot, first load existing int canvasId = -1; string snapshotName = "canvas" + canvasId + "_tmp" + System.DateTime.Now.ToString("yyyyMMddhhmmssff"); Session["overlaySnapshotName"] = snapshotName; Session["overlayCanvasId"] = canvasId; //invoke javascript to take snapshot ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "myHomeSnap", "CaptureSnapshot('" + snapshotName + "');", true); } catch (Exception ex) { exception.HandleException("Home:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]); Response.Redirect("/error", false); } } #endregion }