Exemplo n.º 1
0
    private void InitMetricFilters()
    {
        //added checkboxes to treeview - BW, 4/15/2012.
        Literal list;
        string  listItem = "";

        List <ProfileMetric> metriclist = ProfileMetric.InitMetricList();
        var listOfUls = new List <string>();

        foreach (ProfileMetric pm in metriclist)
        {
            foreach (ProfileMetric.MetricThreshold mt in pm.thresholds)
            {
                /*CheckBox chk = new CheckBox();
                 * chk.ID = "chk" + pm.columnname + ((int)mt.ThresholdType).ToString();
                 * chk.Attributes.Add("threshold", mt.ToString());
                 * chk.Attributes.Add("onclick", "ReDraw('" + ddlMSA.ClientID + "')");
                 * //chk.Style.Add("margin", "5px");
                 *
                 * chk.Text = "";*/
                string chkbox = "<span threshold=\"" + mt.ToString() + "\"><input type='checkbox' onclick=\"ReDraw('" + ddlMSA.ClientID + "')\"  id=\"ContentPlaceHolder1_chk" + pm.columnname + ((int)mt.ThresholdType).ToString() + "\" name=\"ContentPlaceHolder1_chk" + pm.columnname + ((int)mt.ThresholdType).ToString() + "\"></span>";

                var lt     = new Literal();
                var thrstr = (mt.ThresholdType == ProfileMetric.MetricThreshold.ThresholdTypes.InControl) ? string.Empty :
                             "(" + mt.Threshold.ToString("0.00") + ")";
                var editlnk = (mt.ThresholdType == ProfileMetric.MetricThreshold.ThresholdTypes.InControl) ? string.Empty :
                              "<a href=\"ManageThresholdUsers.aspx?redirect=GoogleMap.aspx&edit_filter_id=" + pm.thresholdid + "\">Edit</a>";

                lt.Text = "<span style=\"font-size:12px;\">" + pm.displayname + " (" + mt.ThresholdType.ToString() + ") " + thrstr + " " +
                          editlnk + "</span>";

                //Change this line for Master Page

                listItem += "<li><span>" + chkbox + " " + lt.Text + "</span></li>";

                //Following was the original code
                //dvDropDowns.Controls.Add(chk);
                //dvDropDowns.Controls.Add(lt);
                //dvDropDowns.Controls.Add(new System.Web.UI.HtmlControls.HtmlGenericControl("br"));
            }

            listOfUls.Add("<li class='expandable'><span style=\"font-size:12px;\">" + pm.columnname + "</span><ul>" + listItem + "</ul></li>");
            listItem = "";
        }

        string liText = "";

        foreach (var listOfUl in listOfUls)
        {
            //liText += "<li class='collapsable'> " + listOfUl + " </li>";
            liText += listOfUl;
        }

        list = new Literal {
            Text = "<ul id='browser' class='treeview'>" + liText + "</ul><br/>"
        };
        dvDropDowns.Controls.Add(list);
    }
Exemplo n.º 2
0
    private void GenerateMap()
    {
        DataSet ds = GetTopProviders();

        if (ds != null && ds.Tables.Count > 0)
        {
            List <LatLong> lst = new List <LatLong>();

            foreach (DataRowView dr in ds.Tables[0].DefaultView)
            {
                StringBuilder sb = new StringBuilder();
                sb.Append((dr["Address1"] != null) ? Server.UrlEncode(dr["Address1"].ToString().ToUpper()) : string.Empty);
                //sb.Append((dr["Address2"] != null) ? Server.UrlEncode(dr["Address2"].ToString().ToUpper()) : string.Empty);
                sb.Append((dr["City"] != null && dr["City"].ToString() != string.Empty) ? ",+" + Server.UrlEncode(dr["City"].ToString().ToUpper()) : string.Empty);
                sb.Append((dr["State"] != null && dr["State"].ToString() != string.Empty) ? ",+" + Server.UrlEncode(dr["State"].ToString().ToUpper()) : string.Empty);

                string name         = (dr["Provider"] != null) ? dr["Provider"].ToString().ToUpper() : string.Empty;
                string phone        = (dr["Phone"] != null) ? dr["Phone"].ToString() : string.Empty;
                string tin          = (dr["TIN9"] != null) ? dr["TIN9"].ToString() : string.Empty;
                string suffix       = (dr["SUFFIX"] != null) ? dr["SUFFIX"].ToString() : string.Empty;
                string icon         = _iconGreen;
                string msa          = (dr["MSA"] != null) ? dr["MSA"].ToString() : string.Empty;
                string currentyear  = (dr["Current_Year"] != null) ? dr["Current_Year"].ToString() : string.Empty;
                string previousyear = (dr["Previous_Year"] != null) ? dr["Previous_Year"].ToString() : string.Empty;
                string lat          = (dr["lat"] != null) ? dr["lat"].ToString() : string.Empty;
                string lng          = (dr["long"] != null) ? dr["long"].ToString() : string.Empty;

                bool contracted = false;
                if (dr["Contracted"] != System.DBNull.Value)
                {
                    bool.TryParse(dr["Contracted"].ToString(), out contracted);
                }

                //Currently Thresholds are hardcoded into ProfileMetric.cs class under App_Code
                //If they are coming from class, it could be set here
                //If anything not in control, icon is red

                //Thresholds:
                List <ProfileMetric> metriclist = ProfileMetric.InitMetricList();
                ProfileMetric.UpdateMetricWithData(metriclist, ds.Tables[0], dr.Row);

                //Not needed as per the new business logic

                /*foreach (ProfileMetric pm in metriclist)
                 * {
                 *  //If any of the Metrics is not in control, icon is red
                 *  if (pm.incontrol.HasValue && pm.incontrol.Value == false)
                 *  {
                 *      icon = _iconRed;
                 *  }
                 * }*/

                LatLong latlng = new LatLong(tin, suffix, lat, lng, name, Server.UrlDecode(sb.ToString()), phone, msa, icon, contracted, currentyear, previousyear);

                if (latlng.Lat != string.Empty && latlng.Lng != string.Empty)
                {
                    latlng.MetricList = metriclist;
                    lst.Add(latlng);
                }
            }

            System.Web.Script.Serialization.JavaScriptSerializer oSerializer = new System.Web.Script.Serialization.JavaScriptSerializer();
            string sJSON = oSerializer.Serialize(lst);


            if (lst.Count > 0)
            {
                ltinitmap.Text  = "<script language=\"javascript\" type=\"text/javascript\">var latlngarr = " + sJSON + ";</script>" + Environment.NewLine;
                ltinitmap.Text += string.Format("<script language=\"javascript\" type=\"text/javascript\">var map = initialize(latlngarr);</script>");
            }
            else
            {
                //daily query limit can trigger this else condition
                ltinitmap.Text = "<script language=\"javascript\" type=\"text/javascript\">alert('No Providers Found');</script>";
            }
        }
    }