예제 #1
0
        private void BuildPage()
        {
            tblList.Rows.Add(this.CreateListHeader(true, new string[] { "ID", "Oggetto", "Creata il", "Città", "Indirizzo", "Categoria", "Stato" }));

            SignalManager sm = new SignalManager();
            int totalRecords = 0;
            List<Signal> items = sm.Search(string.Empty, string.Empty, string.Empty, -1, -2, 0, out totalRecords);

            for (int i = 0; i < items.Count; i++)
            {
                TableRow tr = CreateTableRow();
                tr.Cells.Add(CreateTableCell(items[i].SignalID.ToString()));
                tr.Cells.Add(CreateTableCell(items[i].Subject));
                tr.Cells.Add(CreateTableCell(items[i].CreationDate.ToShortDateString()));
                tr.Cells.Add(CreateTableCell(items[i].City));
                tr.Cells.Add(CreateTableCell(items[i].Address));
                tr.Cells.Add(CreateTableCell(items[i].CategoryName));
                switch (items[i].Status)
                {
                    case Signal.SignalStatus.Approved:
                        tr.Cells.Add(CreateTableCell("Approvato"));
                        break;
                    case Signal.SignalStatus.NotApproved:
                        tr.Cells.Add(CreateTableCell("Non approvato"));
                        break;
                    case Signal.SignalStatus.Resolved:
                        tr.Cells.Add(CreateTableCell("Risolto"));
                        break;
                }

                List<Control> buttons = new List<Control>();
                buttons.Add(CreateImageLink("Edit.aspx?ID=" + items[i].SignalID, "Modifica", ImageButtons.Edit));
                buttons.Add(CreateImageButton(JsUtils.CreateJsFunction("performAction", true, new JsonObject(new string[]{"action","argument"}, new string[]{"delete", items[i].SignalID.ToString()})),
                    "Elimina", ImageButtons.Delete));
                buttons.Add(CreateImageButton(JsUtils.CreateJsFunction("performAction", true, new JsonObject(new string[]{"action","argument"}, new string[]{"approve", items[i].SignalID.ToString()})),
                    "Approva", ImageButtons.Approve));
                buttons.Add(CreateImageButton(JsUtils.CreateJsFunction("performAction", true, new JsonObject(new string[] { "action", "argument" }, new string[] { "reject", items[i].SignalID.ToString() })),
                    "Rifiuta", ImageButtons.Reject));
                tr.Controls.Add(CreateCommandsCell(buttons));

                tblList.Rows.Add(tr);
            }

            tblList.Rows.Add(CreatePaginationRow(totalRecords, 10, 7));
        }
예제 #2
0
        /// <summary>
        /// Processes the request.
        /// </summary>
        /// <param name="context">The context.</param>
        public override void ProcessRequest(HttpContext context)
        {
            base.ProcessRequest(context);

            try
            {
                SignalManager sm = new SignalManager();
                int tot;
                List<Signal> signals = sm.Search(context.Request.QueryString["city"], string.Empty, string.Empty, -1, -1, 0, out tot);

                context.Response.ContentType = "text/xml";

                if (context.Request.QueryString["type"] == null)
                {
                    RssGenerator rss = new RssGenerator();
                    rss.Channel = new Channel();
                    rss.Channel.Title = "Mettiaposto.it - Feed " + context.Request.QueryString["city"];
                    rss.Channel.Link = "http://" + context.Request.Url.Host;
                    rss.Channel.PubDate = DateTime.Now.ToString("s");
                    rss.Channel.Description = "Elenco delle segnalazioni inviate tramite Mettiaposto.it per la città di " + context.Request.QueryString["city"];
                    rss.Channel.Image = new Image();
                    rss.Channel.Image.Url = "http://" + context.Request.Url.Host + "/images/logo.png";
                    rss.Channel.Items = new List<Item>();

                    foreach (Signal s in signals)
                    {
                        Item item = new Item();
                        item.Title = s.Subject;
                        item.Description = s.Description;
                        item.PubDate = s.CreationDate.ToString("s");
                        item.Link = "http://" + context.Request.Url.Host + s.Link;
                        item.Guid = "http://" + context.Request.Url.Host + s.Link;
                        item.Commments = "http://" + context.Request.Url.Host + s.Link + "#comments";
                        if (s.HasImage)
                        {
                            item.Image = new Image();
                            item.Image.Url = "http://" + context.Request.Url.Host + WebUtils.GetImageUrl(UploadPaths.Comments, s.Attachment);
                        }

                        rss.Channel.Items.Add(item);
                    }

                    context.Response.Write(XmlUtils.Serialize(rss).OuterXml);
                }
                else
                {
                    GeoRSS rss = new GeoRSS();
                    rss.Author = new GeoRSSAuthor("Mettiaposto.it", "*****@*****.**");
                    rss.Link = new GeoRSSLink("http://www.mettiaposto.it");
                    rss.SubTitle = "Invia segnalazioni di problemi della tua città";
                    rss.Title = "Mettiaposto.it - GeoRSS " + context.Request.QueryString["city"];
                    rss.Entries = new List<GeoRSSEntry>();

                    foreach (Signal s in signals)
                    {
                        GeoRSSEntry e = new GeoRSSEntry();
                        e.ID = "http://" + context.Request.Url.Host + s.Link;
                        e.Summary = s.Description;
                        e.Title = s.Subject + " in " + s.Address + ", " + s.City;
                        e.Point = new GeoRSSPoint(s.Latitude, s.Longitude);
                        e.Link = new GeoRSSLink("http://" + context.Request.Url.Host + s.Link);
                        rss.Entries.Add(e);
                    }

                    XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
                    ns.Add(string.Empty, "http://www.w3.org/2005/Atom");
                    ns.Add("georss", "http://www.georss.org/georss");
                    context.Response.Write(XmlUtils.Serialize(rss, ns).OuterXml);
                }
            }
            catch (Exception ex)
            {
                LogUtils.Log("Error loading or creating RSS", ex);
                throw ex;
            }
        }
예제 #3
0
        public JsonObject SearchSignals(JsonObject searchParams)
        {
            JsonArray ar = new JsonArray();
            JsonObject container = new JsonObject();

            int totalRecords = 0;

            SignalManager sm = new SignalManager();
            List<Signal> ret = (List<Signal>)sm.Search(searchParams["city"].ToString(), searchParams["address"].ToString(), searchParams["zip"].ToString(),
                Convert.ToInt32(searchParams["categoryID"]), Convert.ToInt32(searchParams["status"]), Convert.ToInt32(searchParams["start"]), out totalRecords);

            SignalsList s = (SignalsList)new UserControl().LoadControl("/Includes/SignalsList.ascx");
            s.Populate(ret, totalRecords, 10);
            container["html"] = WebUtils.RenderControlToString(s);

            for (int i = 0; i < ret.Count; i++)
            {
                ret[i].Email = string.Empty;

                JsonObject obj = new JsonObject();
                obj["signal"] = ret[i];
                obj["description"] = GetSignalDescription(ret[i]);
                ar.Push(obj);
            }

            container["signals"] = ar;

            return container;
        }