Ejemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            RegisterAjaxSessionKey();

            SignalManager sm = new SignalManager();
            ltTotals.Text = sm.GetCountAll().ToString();
            ltResolved.Text = sm.GetCountByStatus(Signal.SignalStatus.Resolved).ToString();
        }
Ejemplo n.º 2
0
        public Signal AddSignal(Signal s, string ajaxSessionKey)
        {
            CheckRequest(ajaxSessionKey);

            SignalManager sm = new SignalManager();
            s.CreationDate = DateTime.Now;
            s.UpdateDate = DateTime.Now;
            s.Status = Signal.SignalStatus.Approved; // FIX!!!!
            s.UpdateDate = DateTime.Now;
            s.ResolutionDescription = string.Empty;
            sm.CreateSignal(s);

            return s;
        }
Ejemplo n.º 3
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());

            for (int i = 0; i < ret.Count; i++)
            {
                JsonObject obj = new JsonObject();
                obj["signal"] = ret[i];
                obj["description"] = GetSignalDescription(ret[i]);
                ar.Push(obj);
            }

            return ar;
        }
Ejemplo n.º 4
0
        private void RenderPage()
        {
            if (QueryStringContains("id"))
            {
                SignalManager sm = new SignalManager();
                Signal s = sm.LoadSingnal(int.Parse(GetFromQueryString("id")));
                divTitle.InnerHtml = s.Subject;
                divDescription.InnerHtml = s.Description;

                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 func = JsUtils.CreateJsFunction("setMarker", false, "signalMarker" + GetFromQueryString("id"),
                    new JsUtils.JsFunction("new google.maps.LatLng(" + s.Latitude.ToString(new CultureInfo("en-US")) + "," + s.Longitude.ToString(new CultureInfo("en-US")) + ")"),
                    false, "map_canvas", true, true) + "getMap('map_canvas').obj.setZoom(" + s.Zoom.ToString() + ");";

                RegisterDocumentReadyFunction("setmarker", func);

                nearby.Attributes.Add("zip", s.Zip);

                if (!s.Attachment.Equals(string.Empty))
                {
                    divPhoto.Visible = true;
                    imgPhoto.ImageUrl = Path.Combine(ConfigurationManager.AppSettings["UploadPath"], s.Attachment);
                }

                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "currentSignalID", "currentSignalID=" + GetFromQueryString("id"), true);
            }
        }
Ejemplo n.º 5
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++)
            {
                JsonObject obj = new JsonObject();
                obj["signal"] = ret[i];
                obj["description"] = GetSignalDescription(ret[i]);
                ar.Push(obj);
            }

            container["signals"] = ar;

            return container;
        }
Ejemplo n.º 6
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");
        }