Exemplo n.º 1
0
 public void Edit(SummaryChart objectToEdit)
 {
     _summaryChartPresenter.Edit(objectToEdit);
     UpdateCaption();
     updateChartVisibility();
     _view.Display();
 }
Exemplo n.º 2
0
        public static string GetSummary(string listid, string type)
        {
            SummaryChart sc = new SummaryChart();

            List <SummaryItem> rawitems = new List <SummaryItem>();
            List <SummaryItem> rtnitems = new List <SummaryItem>();

            Framework.Utilities.DataIO dataio = new Framework.Utilities.DataIO();
            try
            {
                string        connstr      = dataio.GetConnectionString();
                SqlConnection dbconnection = new SqlConnection(connstr);

                dbconnection.Open();

                SqlCommand dbcommand = new SqlCommand();
                dbcommand.CommandType    = CommandType.Text;
                dbcommand.CommandText    = string.Format("exec [Profile.Data].[List.GetSummary]  @UserID = {0}", listid);
                dbcommand.CommandTimeout = dataio.GetCommandTimeout();

                dbcommand.Connection = dbconnection;
                using (SqlDataReader dbreader = dbcommand.ExecuteReader(CommandBehavior.CloseConnection))
                {
                    while (dbreader.Read())
                    {
                        rawitems.Add(new SummaryItem {
                            Variable = dbreader["Variable"].ToString(), Value = dbreader["Value"].ToString().Replace("'", "\\'"), n = Convert.ToInt32(dbreader["n"]), color = ""
                        });
                    }

                    if (!dbreader.IsClosed)
                    {
                        dbreader.Close();
                    }
                }
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }

            rtnitems = rawitems.FindAll(o => o.Variable.ToLower() == type.ToLower()).ToList();

            sc.cols = "{\"cols\": [{\"id\":\"\",\"label\": \"" + type + "\",\"pattern\":\"\",\"type\":\"string\"},{\"id\":\"\",\"label\":\"Count\",\"pattern\":\"\",\"type\":\"number\"}],";
            sc.rows = "\"rows\":[";
            foreach (SummaryItem si in rtnitems)
            {
                sc.rows += "{ \"c\":[{\"v\":\"" + si.Value + "\"},{\"v\":" + si.n.ToString() + "}]},";
            }
            sc.rows   = sc.rows.Substring(0, sc.rows.Length - 1);
            sc.colors = "],\"colors\":\"[#4E79A7,#F28E2B,#E15759,#76B7B2,#59A14F,#EDC948,#B07AA1,#FF9DA7,#9C755F,#BAB0AC]\"}";

            return(sc.cols + sc.rows + sc.colors);
        }
Exemplo n.º 3
0
        public static List <SummaryItem> GetSummaryRaw(string listid, string type)
        {
            SummaryChart sc = new SummaryChart();

            List <SummaryItem> rawitems = new List <SummaryItem>();
            List <SummaryItem> rtnitems = new List <SummaryItem>();

            Framework.Utilities.DataIO dataio = new Framework.Utilities.DataIO();
            try
            {
                string        connstr      = dataio.GetConnectionString();
                SqlConnection dbconnection = new SqlConnection(connstr);

                dbconnection.Open();

                SqlCommand dbcommand = new SqlCommand();
                dbcommand.CommandType    = CommandType.Text;
                dbcommand.CommandText    = string.Format("exec [Profile.Data].[List.GetSummary]  @UserID = {0}", listid);
                dbcommand.CommandTimeout = dataio.GetCommandTimeout();

                dbcommand.Connection = dbconnection;
                using (SqlDataReader dbreader = dbcommand.ExecuteReader(CommandBehavior.CloseConnection))
                {
                    while (dbreader.Read())
                    {
                        rawitems.Add(new SummaryItem {
                            Variable = dbreader["Variable"].ToString(), Value = dbreader["Value"].ToString().Replace("'", "\\'"), n = Convert.ToInt32(dbreader["n"]), color = ""
                        });
                    }

                    if (!dbreader.IsClosed)
                    {
                        dbreader.Close();
                    }
                }
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }

            rtnitems = rawitems.FindAll(o => o.Variable.ToLower() == type.ToLower()).ToList();



            return(rtnitems);
        }