コード例 #1
0
        public FileContentResult ShowLegalEntityOwnersGraph(int?legalEntityFK, string color, int?dpi)
        {
            ILegalEntitiesRepository legalEntitiesRepository = new LegalEntitiesRepository(db);

            ILegalEntityOwnersRepository legalEntityOwnersRepository = new LegalEntityOwnersRepository(db);
            IPhysicalEntitiesRepository  physicalEntitiesRepository  = new PhysicalEntitiesRepository(db);

            List <LegalEntityOwner>       filteredCoList         = new List <LegalEntityOwner>();
            IQueryable <LegalEntityOwner> legalEntityOwnersTable = legalEntityOwnersRepository.GetValid();

            if (legalEntityFK != null)
            {
                List <LegalEntityOwner> coList = new List <LegalEntityOwner>();
                coList = legalEntityOwnersRepository.GetFirstLegalEntityOwnersForLegalEntity((int)legalEntityFK).ToList();

                foreach (var co in coList)
                {
                    LegalEntityOwnerView.Fill(filteredCoList, legalEntityOwnersTable.ToList(), co);
                }

                legalEntityOwnersTable = filteredCoList.AsQueryable();
            }

            IQueryable <LegalEntityOwnerView> legalEntityOwners = LegalEntityOwnerView.GetLegalEntityOwnerView(legalEntityOwnersTable,
                                                                                                               physicalEntitiesRepository.GetValid(),
                                                                                                               legalEntitiesRepository.GetValid());

            List <string> graphElements = new List <string>();

            foreach (LegalEntityOwnerView item in legalEntityOwners)
            {
                graphElements.Add(item.OwnerFK.ToString() + "[label=\"" + item.OwnerName + "\", shape=ci, fontsize=12, fontname=arial, labelloc=t, style=filled, fillcolor=\"white\", width=1.5]");

                if (legalEntityFK == item.LegalEntityFK)
                {
                    graphElements.Add(item.LegalEntityFK.ToString() + "[label=\"" + item.LegalEntityName + "\", shape=box, fontsize=12, fontname=arial, labelloc=t, style=filled, fontcolor=\"white\", color=\"black\", width=1.5]");
                }
                else
                {
                    graphElements.Add(item.LegalEntityFK.ToString() + "[label=\"" + item.LegalEntityName + "\", shape=box, fontsize=12, fontname=arial, labelloc=t, style=filled, fillcolor=\"white\", width=1.5]");
                }

                graphElements.Add(item.OwnerFK.ToString() + "->" + item.LegalEntityFK.ToString());
            }

            string graph = @"digraph Graphviz {";

            graph += "[bgcolor=\"" + color + "\", dpi=\"" + dpi + "\"],";
            graph += string.Join(", ", graphElements.ToArray());
            graph += "}";

            graph = graph.ConvertNonASCIICharacters();

            byte[] imageByte   = imageByte = Graphviz.RenderImage(graph, "dot", "png");;
            string contentType = "image/png";

            return(File(imageByte, contentType));
        }
コード例 #2
0
        /**
         * overriden, because we need the quantity on the arrows
         */
        public override string ToString()
        {
            string mystring = "";

            if (_originalEdges == null)
            {
                return(mystring);
            }

            foreach (var edge in _originalEdges)
            {
                // foreach (var edge in GetAllEdgesFromTailNode(fromNode))
                // {
                // <Type>, <Menge>, <ItemName> and on edges: <Menge>
                Quantity quantity = null;
                if (edge.GetLinkDemandAndProvider() != null)
                {
                    quantity = edge.GetLinkDemandAndProvider().GetQuantity();
                }

                string tailsGraphvizString =
                    Graphviz.GetGraphizString(edge.GetTailNode().GetEntity());
                string headsGraphvizString =
                    Graphviz.GetGraphizString(edge.GetHeadNode().GetEntity());
                mystring += $"\"{tailsGraphvizString}\" -> " + $"\"{headsGraphvizString}\"";
                // if (quantity.IsNull() == false)
                if (quantity != null && quantity.IsNull() == false)
                {
                    mystring += $" [ label=\" {quantity}\" ]";
                }

                mystring += ";" + Environment.NewLine;
                // }
            }

            return(mystring);
        }
コード例 #3
0
ファイル: Arbol.cs プロジェクト: JeffMenca/Proyecto-1-LFP
        //Generar arbol
        public void generarArbol()
        {
            //Crear carpeta
            string path       = @"..\Arboles Sintacticos";
            string contenido2 = "";

            if (!Directory.Exists(path))
            {
                DirectoryInfo di = Directory.CreateDirectory(path);
            }
            filtrarArbol();
            for (int i = 0; i < nodosOrdenados.Count; i++)
            {
                Nodos nodo = (Nodos)nodosOrdenados[i];
                contenido2 += "\"" + nodo.getPadre().getNombre() + " " + nodo.getPadre().getNivel() + "\"" + "->" + "\""
                              + nodo.getNombre() + " " + nodo.getNivel() + "\"" + ";\n";
            }
            String inicio     = "digraph G {";
            string contenido1 = "{" +
                                "node [margin=0 fontsize=12 shape=circle]\n";
            String final = " }";

            string graphVizString = inicio + contenido1 + contenido2 + final + final;

            Console.WriteLine(contenido2);
            Bitmap bm     = new Bitmap(Graphviz.RenderImage(graphVizString, "jpg"));
            var    imagen = new Bitmap(bm);

            bm.Dispose();
            Image image = (Image)imagen;

            imagen.Save(path + @"\prueba.jpg", ImageFormat.Jpeg);
            imagen.Dispose();
            IDE.ImagenArbol foto = new IDE.ImagenArbol();
            foto.Show();
        }
コード例 #4
0
 /// <summary>
 /// Show graph on a screen.
 /// </summary>
 /// <param name="title"></param>
 public void ShowGraph(string title)
 {
     Graphviz.ShowGraph(graph, title);
 }
コード例 #5
0
 public void Show(string title = "Infer.NET Schedule")
 {
     Graphviz.ShowGraph(graph, title);
 }
コード例 #6
0
 public void Show(string title = "Infer.NET Dependency Graph")
 {
     Graphviz.ShowGraph(graph, title);
 }
コード例 #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            HttpCookie cookie = Request.Cookies["Logged"];

            Response.Write("<img id='loadingImage' width='100' height='100' style='position:absolute;margin-top:-100px;margin-left:-100px;top:50% !important;left:50% !important;' src='../Pictures/loading.gif'/>");
            Response.Write("<div id='content' class='container' style='display:none'>");

            if (cookie["select"] == null)
            {
                Response.Write("<div class='alert alert-warning'><strong>Warning!</strong>You haven't selected any smartphone.</div>");
            }
            else
            {
                string connectionString = ConfigurationManager.ConnectionStrings["SilentConnection"].ConnectionString;


                String         graphVizString = Graphviz.GenerateInput(connectionString, cookie["username"]);
                Bitmap         bm             = new Bitmap(Graphviz.RenderImage(graphVizString, "jpg"));
                ImageConverter converter      = new ImageConverter();
                Response.Write("<img style='display:block;margin:0 auto;' src='data:image/png;base64, " + Convert.ToBase64String((byte[])converter.ConvertTo(bm, typeof(byte[]))) + "'/></span>");

                DataTable table;
                DataTable tableNr = SqlHelper.GetSpecificInformation(connectionString, cookie["username"], "GetRegisteredPhones");
                Response.Write("<div class='row'>");
                Response.Write("<div class='col-md-12'>");
                Response.Write("<div class='jumbotron'>");
                if (tableNr != null && tableNr.Rows.Count != 0)
                {
                    Response.Write("<h2>Contact agenda between registered smartphones</h2>");
                    Response.Write("<br>");
                    foreach (DataRow row in tableNr.Rows)
                    {
                        Response.Write("<h4>" + row["Manufacturer"].ToString() + " " + row["Model"].ToString() + " " + row["IMEI"].ToString() + "</h4>");
                        table = SqlHelper.GetSpecificInformation(connectionString, row["IMEI"].ToString(), "CompareContacts");
                        Response.Write("<table class='table table-hover table-responsive'>");
                        Response.Write("<thead><tr><th>Manufacturer</th><th>Model</th><th>IMEI</th><th>Check</th></tr></thead>");
                        Response.Write("<tbody>");
                        foreach (DataRow roww in table.Rows)
                        {
                            Response.Write("<tr class='success'>");
                            Response.Write("<td>" + roww["Manufacturer"].ToString() + "</td>");
                            Response.Write("<td>" + roww["Model"].ToString() + "</td>");
                            Response.Write("<td>" + roww["IMEI"].ToString() + "</td>");
                            if (roww["Checkk"].ToString() == "1")
                            {
                                Response.Write("<td><img width='30' height='30' src='../Pictures/check.png'/></td>");
                            }
                            else
                            {
                                Response.Write("<td><img width='30' height='30' src='../Pictures/X.png'/></td>");
                            }
                            Response.Write("</tr>");
                        }
                        Response.Write("</tbody>");
                        Response.Write("</table>");
                    }
                }
                else
                {
                    Response.Write("<div class='alert alert-warning'><strong>Info!</strong>You don't have any phones registered.</div>");
                }
                Response.Write("</div>");
                Response.Write("</div>");
                Response.Write("</div>");


                table = SqlHelper.GetSpecificInformation(connectionString, cookie["select"], "GetMostCalled");

                Response.Write("<div class='row'>");
                Response.Write("<div class='col-md-6'>");
                Response.Write("<div class='jumbotron'>");

                if (table != null && table.Rows.Count != 0)
                {
                    Response.Write("<h2>Five most called contacts</h2>");
                    Response.Write("<table class='table table-hover table-responsive'>");
                    Response.Write("<thead><tr><th>Name</th><th>Number</th></tr></thead>");
                    Response.Write("<tbody>");
                    int counter = 0;
                    foreach (DataRow row in table.Rows)
                    {
                        Response.Write("<tr>");
                        Response.Write("<td>" + row["Name"].ToString() + "</td>");
                        Response.Write("<td>" + row["Number"].ToString() + "</td>");
                        Response.Write("</tr>");
                        counter++;
                        if (counter == 5)
                        {
                            break;
                        }
                    }
                    Response.Write("</tbody>");
                    Response.Write("</table>");
                }
                else
                {
                    Response.Write("<div class='alert alert-warning'><strong>Info!</strong>You don't have a call history.</div>");
                }
                Response.Write("</div>");
                Response.Write("</div>");

                table = SqlHelper.GetSpecificInformation(connectionString, cookie["select"], "GetMostMessaged");
                Response.Write("<div class='col-md-6'>");
                Response.Write("<div class='jumbotron'>");
                if (table != null && table.Rows.Count != 0)
                {
                    Response.Write("<h2>Five most messaged contacts</h2>");
                    Response.Write("<table class='table table-hover table-responsive'>");
                    Response.Write("<thead><tr><th>Name</th><th>Number</th></tr></thead>");
                    Response.Write("<tbody>");
                    int counter = 0;
                    foreach (DataRow row in table.Rows)
                    {
                        Response.Write("<tr>");
                        Response.Write("<td>" + row["Name"].ToString() + "</td>");
                        Response.Write("<td>" + row["Number"].ToString() + "</td>");
                        Response.Write("</tr>");
                        counter++;
                        if (counter == 5)
                        {
                            break;
                        }
                    }
                    Response.Write("</tbody>");
                    Response.Write("</table>");
                }
                else
                {
                    Response.Write("<div class='alert alert-warning'><strong>Info!</strong>You don't have any messages.</div>");
                }
                Response.Write("</div>");
                Response.Write("</div>");
                Response.Write("</div>");

                table = SqlHelper.GetSpecificInformation(connectionString, cookie["select"], "GetLastCall");
                Response.Write("<div class='row'>");
                Response.Write("<div class='col-md-6'>");
                Response.Write("<div class='jumbotron'>");

                if (table != null && table.Rows.Count != 0)
                {
                    Response.Write("<h2>Last call</h2>");
                    Response.Write("<table class='table table-hover table-responsive'>");
                    Response.Write("<thead><tr><th>Name</th><th>Number</th><th>Date</th></tr></thead>");
                    Response.Write("<tbody>");
                    Response.Write("<tr>");
                    Response.Write("<td>" + table.Rows[0]["Name"].ToString() + "</td>");
                    Response.Write("<td>" + table.Rows[0]["Number"].ToString() + "</td>");
                    Response.Write("<td>" + table.Rows[0]["Date"].ToString() + "</td>");
                    Response.Write("</tr>");
                    Response.Write("</tbody>");
                    Response.Write("</table>");
                }
                else
                {
                    Response.Write("<div class='alert alert-warning'><strong>Info!</strong>You don't have a call history.</div>");
                }
                Response.Write("</div>");
                Response.Write("</div>");

                table = SqlHelper.GetSpecificInformation(connectionString, cookie["select"], "GetLastMessage");
                Response.Write("<div class='col-md-6'>");
                Response.Write("<div class='jumbotron'>");
                if (table != null && table.Rows.Count != 0)
                {
                    Response.Write("<h2>Last message</h2>");
                    Response.Write("<table class='table table-hover'>");
                    Response.Write("<tr><td>Contact name: </td><td>" + table.Rows[0]["Name"].ToString() + "</td></tr>");
                    Response.Write("<tr><td>Date: </td><td>" + table.Rows[0]["Date"].ToString() + "</td></tr>");
                    Response.Write("</table>");
                    Response.Write("<p>" + table.Rows[0]["Body"].ToString() + "</p>");
                }
                else
                {
                    Response.Write("<div class='alert alert-warning'><strong>Info!</strong>You don't have any messages.</div>");
                }
                Response.Write("</div>");
                Response.Write("</div>");
                Response.Write("</div>");
            }
            Response.Write("</div>");
        }