protected void rptr_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            pnlList.Visible = false;


            var o = new Event();

            o.Fetch(int.Parse(e.CommandArgument.ToString()));

            lblTitle.Text = o.EventTitle;
            lblWhen.Text  = FormatHelper.ToNormalDate(o.EventDate) + " " + o.EventTime;
            var c = new Codes();

            if (o.BranchID != 0)
            {
                lblWhere.Text = (c.FetchObject(o.BranchID)).Code;
            }

            lblHtml.Text = o.HTML;

            var cf = CustomEventFields.FetchObject();

            if (cf.Use1)
            {
                Panel1.Visible = true;
                CF1Label.Text  = cf.Label1;
                CF1Value.Text  = o.Custom1;
            }
            if (cf.Use2)
            {
                Panel2.Visible = true;
                CF2Label.Text  = cf.Label2;
                CF2Value.Text  = o.Custom2;
            }
            if (cf.Use3)
            {
                Panel3.Visible = true;
                CF3Label.Text  = cf.Label3;
                CF3Value.Text  = o.Custom3;
            }
            pnlDetail.Visible = true;
        }
示例#2
0
        public void ProcessRequest(HttpContext context)
        {
            var jsonResponse = new JsonEvent();

            if (context.Request.QueryString["EventId"] == null)
            {
                jsonResponse.Success      = false;
                jsonResponse.ErrorMessage = "No event id provided.";
                this.Log().Error(string.Format("Event requested from {0}?{1} with no id.",
                                               context.Request.Url,
                                               context.Request.QueryString));
            }
            else
            {
                int eventId = 0;
                if (!int.TryParse(context.Request["EventId"].ToString(), out eventId))
                {
                    jsonResponse.Success      = false;
                    jsonResponse.ErrorMessage = "Invalid event id provided.";
                    this.Log().Error(string.Format("Requested event {0} from {1}?{2} - invalid id",
                                                   context.Request["EventId"].ToString(),
                                                   context.Request.Url,
                                                   context.Request.QueryString));
                }
                else
                {
                    DAL.Event e = new DAL.Event().FetchObject(eventId);
                    if (e == null)
                    {
                        jsonResponse.Success      = false;
                        jsonResponse.ErrorMessage = "Event not found.";
                        this.Log().Error(string.Format("Requested event {0} from {1}?{2} - not found",
                                                       eventId,
                                                       context.Request.Url,
                                                       context.Request.QueryString));
                    }
                    else
                    {
                        var cf = CustomEventFields.FetchObject();
                        jsonResponse.Success          = true;
                        jsonResponse.Title            = e.EventTitle;
                        jsonResponse.ShortDescription = e.ShortDescription;
                        jsonResponse.Description      = e.HTML;
                        jsonResponse.When             = Event.DisplayEventDateTime(e);

                        if (e.BranchID > 0)
                        {
                            var codeObject = DAL.Codes.FetchObject(e.BranchID);
                            if (codeObject != null)
                            {
                                jsonResponse.Where = codeObject.Description;
                            }
                        }
                        if (!string.IsNullOrWhiteSpace(e.Custom1) &&
                            !string.IsNullOrWhiteSpace(cf.Label1))
                        {
                            jsonResponse.CustomLabel1 = cf.Label1;
                            jsonResponse.CustomValue1 = e.Custom1;
                        }
                        if (!string.IsNullOrWhiteSpace(e.Custom2) &&
                            !string.IsNullOrWhiteSpace(cf.Label2))
                        {
                            jsonResponse.CustomLabel2 = cf.Label2;
                            jsonResponse.CustomValue2 = e.Custom2;
                        }
                        if (!string.IsNullOrWhiteSpace(e.Custom3) &&
                            !string.IsNullOrWhiteSpace(cf.Label3))
                        {
                            jsonResponse.CustomLabel3 = cf.Label3;
                            jsonResponse.CustomValue3 = e.Custom3;
                        }
                    }
                }
            }


            context.Response.ContentType = "application/json";
            var settings = new JsonSerializerSettings();

            settings.StringEscapeHandling = StringEscapeHandling.EscapeHtml;
            context.Response.Write(JsonConvert.SerializeObject(jsonResponse, settings));
        }
示例#3
0
        public void ProcessRequest(HttpContext context)
        {
            var jsonResponse = new JsonEvent();

            if (context.Request.QueryString["EventId"] == null)
            {
                jsonResponse.Success      = false;
                jsonResponse.ErrorMessage = "No event id provided.";
                this.Log().Error(string.Format("Event requested from {0}?{1} with no id.",
                                               context.Request.Url,
                                               context.Request.QueryString));
            }
            else
            {
                int eventId = 0;
                if (!int.TryParse(context.Request["EventId"].ToString(), out eventId))
                {
                    jsonResponse.Success      = false;
                    jsonResponse.ErrorMessage = "Invalid event id provided.";
                    this.Log().Error(string.Format("Requested event {0} from {1}?{2} - invalid id",
                                                   context.Request["EventId"].ToString(),
                                                   context.Request.Url,
                                                   context.Request.QueryString));
                }
                else
                {
                    DAL.Event e = new DAL.Event().FetchObject(eventId);
                    if (e == null || e.HiddenFromPublic == true)
                    {
                        jsonResponse.Success      = false;
                        jsonResponse.ErrorMessage = "Event not found.";
                        this.Log().Error(string.Format("Requested event {0} from {1}?{2} - not found",
                                                       eventId,
                                                       context.Request.Url,
                                                       context.Request.QueryString));
                    }
                    else
                    {
                        var cf = CustomEventFields.FetchObject();
                        jsonResponse.Success      = true;
                        jsonResponse.Title        = e.EventTitle;
                        jsonResponse.ExternalLink = e.ExternalLinkToEvent;
                        jsonResponse.Description  = context.Server.HtmlDecode(e.HTML);
                        jsonResponse.When         = Event.DisplayEventDateTime(e);

                        if (e.BranchID > 0)
                        {
                            string branchName = string.Empty;
                            var    codeObject = DAL.Codes.FetchObject(e.BranchID);
                            if (codeObject != null)
                            {
                                jsonResponse.Where = codeObject.Description;
                            }
                            var crosswalk = DAL.LibraryCrosswalk.FetchObjectByLibraryID(e.BranchID);
                            if (crosswalk != null)
                            {
                                if (!string.IsNullOrEmpty(jsonResponse.Where) &&
                                    !string.IsNullOrEmpty(crosswalk.BranchLink))
                                {
                                    jsonResponse.Where = string.Format(WebTools.BranchLinkStub,
                                                                       crosswalk.BranchLink,
                                                                       jsonResponse.Where);
                                }

                                if (!string.IsNullOrEmpty(jsonResponse.Where) &&
                                    !string.IsNullOrEmpty(crosswalk.BranchAddress))
                                {
                                    jsonResponse.Where += string.Format(WebTools.BranchMapStub,
                                                                        HttpUtility.UrlEncode(crosswalk.BranchAddress));
                                }
                            }
                        }
                        if (!string.IsNullOrWhiteSpace(e.Custom1) &&
                            !string.IsNullOrWhiteSpace(cf.Label1))
                        {
                            jsonResponse.CustomLabel1 = cf.Label1;
                            jsonResponse.CustomValue1 = e.Custom1;
                        }
                        if (!string.IsNullOrWhiteSpace(e.Custom2) &&
                            !string.IsNullOrWhiteSpace(cf.Label2))
                        {
                            jsonResponse.CustomLabel2 = cf.Label2;
                            jsonResponse.CustomValue2 = e.Custom2;
                        }
                        if (!string.IsNullOrWhiteSpace(e.Custom3) &&
                            !string.IsNullOrWhiteSpace(cf.Label3))
                        {
                            jsonResponse.CustomLabel3 = cf.Label3;
                            jsonResponse.CustomValue3 = e.Custom3;
                        }
                    }
                }
            }


            context.Response.ContentType = "application/json";
            var settings = new JsonSerializerSettings();

            settings.StringEscapeHandling = StringEscapeHandling.EscapeHtml;
            context.Response.Write(JsonConvert.SerializeObject(jsonResponse, settings));
        }