/// <summary>
        /// Sends the specified c.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <param name="signalID">The signal ID.</param>
        public void Send(Comment c, int signalID)
        {
            try
            {
                SignalManager sm = new SignalManager();
                Signal s = sm.LoadSingnal(signalID);

                this.BccReceivers.Add(new MailAddress(s.Email));

                List<SignalSubscription> subscriptions = sm.GetSubscriptions(signalID);

                foreach (SignalSubscription sc in subscriptions)
                {
                    MailAddress ma = new MailAddress(sc.Email);
                    if (!this.BccReceivers.Contains(ma))
                        this.BccReceivers.Add(ma);
                }

                this.CreateXML(s, c);
                base.Transform();
                base.Send();
            }
            catch (Exception ex)
            {
                LogUtils.Log("Error sending alert communication", ex);
            }
        }
Beispiel #2
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));
        }
Beispiel #3
0
        /// <summary>
        /// Processes the request.
        /// </summary>
        /// <param name="context">The context.</param>
        public override void ProcessRequest(HttpContext context)
        {
            base.ProcessRequest(context);

            CheckRequest(context.Request.QueryString["token"]);

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

            if (context.Request.Files["fuFile"] != null)
            {
                JsonObject ret = new JsonObject();

                try
                {
                    HttpPostedFile file = context.Request.Files["fuFile"];

                    if (file != null)
                    {
                        if (permittedExts.Contains(Path.GetExtension(file.FileName).ToLower()))
                        {
                            SignalManager sm = new SignalManager();
                            ret["fileName"] = sm.UploadAttachment(file);
                        }
                        else
                        {
                            ret["error"] = "WRONG_EXT";
                        }
                    }
                    else
                        ret["error"] = "NO_FILE";
                }
                catch (Exception ex)
                {
                    ret["error"] = "ERROR";
                    ret["errorMessage"] = ex.Message;
                    ret["stackTrace"] = ex.StackTrace;
                }

                context.Response.Write(ret.ToString());
            }
        }
Beispiel #4
0
        protected void lnkAction_Click(object sender, EventArgs e)
        {
            JsonObject action = GetAction();

            SignalManager sm = new SignalManager();
            switch (action["action"].ToString())
            {
                case "delete":
                    sm.Delete(int.Parse(action["argument"].ToString()));
                    Alert("Segnalazione cancellata");
                    break;
                case "approve":
                    //sm.ResolveSignal(int.Parse(action["argument"].ToString()), string.Empty);
                    Alert("Segnalazione approvata");
                    break;
                case "reject":
                    //sm.RejectSignal(int.Parse(action["argument"].ToString()), string.Empty);
                    Alert("Segnalazione rifiutata");
                    break;
            }

            BuildPage();
        }
Beispiel #5
0
 private void BuildPage()
 {
     SignalManager sm = new SignalManager();
     Signal s = sm.LoadSingnal(int.Parse(GetFromQueryString("ID")));
 }
Beispiel #6
0
        private void RenderPage()
        {
            if (QueryStringContains("id"))
            {
                SignalManager sm = new SignalManager();
                Signal s = sm.LoadSingnal(int.Parse(GetFromQueryString("id")));
                divTitle.InnerHtml = s.Subject;
                plhDescription.Controls.Add(new LiteralControl(s.Description));

                this.Title = String.Format(this.Title, s.Subject, s.Address, s.City);
                metaOgDescription.Attributes["content"] = s.Excerpt;
                ogTitle.Attributes["content"] = String.Format(ogTitle.Attributes["content"], s.Subject, s.Address, s.City);

                if (!s.ShowName)
                    ltAuthor.Text = "Anonimo";
                else
                    ltAuthor.Text = s.Name;

                lblAddress.Text = s.Address;

                ltTimeFrame.Text = SignalUtils.GetTimeframe(s.CreationDate);

                CategoryManager cm = new CategoryManager();
                ltCategory.Text = cm.Load(s.CategoryID).Name;

                string markerImage = "MARKERIMAGE_ALERT";
                if (s.Status == Signal.SignalStatus.Resolved)
                    markerImage = "MARKERIMAGE_OK";

                JsonObject currentMarker = new JsonObject();
                currentMarker["id"] = s.SignalID.ToString();
                currentMarker["lat"] = s.Latitude;//.ToString(new CultureInfo("en-US"));
                currentMarker["lng"] = s.Longitude;//.ToString(new CultureInfo("en-US"));
                currentMarker["zoom"] = s.Zoom;//.ToString();
                currentMarker["image"] = new OpenSignals.Framework.Core.Utility.JsUtils.JsConstant(markerImage);
                currentMarker["zip"] = s.Zip;
                currentMarker["status"] = s.Status;

                ClientScript.RegisterClientScriptBlock(this.GetType(), "currentMarker", "currentMarker=" + currentMarker.ToString() + ";", true);

                if (!s.Attachment.Equals(string.Empty))
                {
                    divPhoto.Visible = true;
                    lnkPhoto.HRef = WebUtils.GetImageUrl(UploadPaths.Big, s.Attachment);
                    imgPhoto.ImageUrl = WebUtils.GetImageUrl(UploadPaths.Small, s.Attachment);
                    ogImage.Attributes["content"] = WebUtils.GetImageUrl(UploadPaths.Small, s.Attachment);
                }

                switch (s.Status)
                {
                    case Signal.SignalStatus.ReOpened:
                        divStatusReopened.Visible = true;
                        divStatusReopened.InnerHtml = String.Format(divStatusReopened.InnerHtml, s.ReopenDate.ToShortDateString(), s.ReopenDescription);
                        break;
                    case Signal.SignalStatus.Approved:
                        divStatusNotResolved.Visible = true;
                        break;
                    case Signal.SignalStatus.Resolved:
                        divStatusResolved.Visible = true;
                        divStatusResolved.InnerHtml = String.Format(divStatusResolved.InnerHtml, s.ResolutionDate, s.ResolutionDescription);
                        break;
                    case Signal.SignalStatus.Expired:
                        divStatusExpired.Visible = true;
                        break;
                }

                switch (s.CriticalLevel)
                {
                    case Signal.CriticalLevels.Normal:
                        lblCriticalLevel.Text = "Bassa";
                        lblCriticalLevel.CssClass = "criticalNormal";
                        break;
                    case Signal.CriticalLevels.Medium:
                        lblCriticalLevel.Text = "Media";
                        lblCriticalLevel.CssClass = "criticalMedium";
                        break;
                    case Signal.CriticalLevels.High:
                        lblCriticalLevel.Text = "Alta";
                        lblCriticalLevel.CssClass = "criticalHigh";
                        break;
                }

                if (sm.SearchNearZip(s.Zip, s.SignalID).Count == 0)
                {
                    liMapNearby.Visible = false;
                    mapNearby.Visible = false;
                }
            }
        }
Beispiel #7
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;
            }
        }
Beispiel #8
0
        public Signal AddSignal(Signal s, string ajaxSessionKey)
        {
            CheckRequest(ajaxSessionKey);

            SignalManager sm = new SignalManager();
            s.CategoryName = null;
            s.Description = WebUtils.FormatHtml(s.Description);
            s.CreationDate = DateTime.Now;
            s.UpdateDate = DateTime.Now;
            s.ReopenDescription = string.Empty;

            if (ConfigurationOptions.Current.GetBool("signal_approve_on_submission"))
                s.Status = Signal.SignalStatus.Approved;
            else
                s.Status = Signal.SignalStatus.NotApproved;

            s.UpdateDate = DateTime.Now;
            s.ResolutionDescription = string.Empty;
            sm.CreateSignal(s);

            SignalSubmissionEmail sse = new SignalSubmissionEmail();
            sse.Send(s);

            return s;
        }
Beispiel #9
0
        public void SubscribeSignal(JsonObject param)
        {
            CheckRequest(param["ajaxSessionKey"].ToString());

            SignalManager sm = new SignalManager();
            SignalSubscription ss = new SignalSubscription();
            ss.Email = param["email"].ToString();
            ss.SignalID = Convert.ToInt32(param["signalID"]);

            if (!sm.CheckIfSubscribed(ss))
                sm.SubscribeSignal(ss);
            else
                throw new Exception("Sei già iscritto a questa segnalazione");
        }
Beispiel #10
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;
        }
Beispiel #11
0
        public JsonArray GetSignalsNearby(JsonObject param)
        {
            CheckRequest(param["ajaxSessionKey"].ToString());

            JsonArray ar = new JsonArray();

            SignalManager sm = new SignalManager();
            List<Signal> ret = sm.SearchNearZip(param["zip"].ToString(), Convert.ToInt32(param["signalID"]));

            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);
            }

            return ar;
        }
Beispiel #12
0
        public void ChangeSignalStatus(int signalID, int newStatus, string description, string sessionKey)
        {
            CheckRequest(sessionKey);

            SignalManager sm = new SignalManager();
            Signal s = sm.LoadSingnal(signalID);
            s.Status = newStatus;

            switch (newStatus)
            {
                case Signal.SignalStatus.ReOpened:
                    s.ReopenDate = DateTime.Now;
                    s.ReopenDescription = WebUtils.FormatHtml(description);
                    break;
                case Signal.SignalStatus.Resolved:
                    s.ResolutionDate = DateTime.Now;
                    s.ResolutionDescription = WebUtils.FormatHtml(description);
                    break;
            }

            sm.ChangeSignalStatus(s);

            SignalAlertEmail email = new SignalAlertEmail();
            email.Send(signalID);
        }