예제 #1
0
        private TreeData.TreeDataTableDataTable GetTreeData(DataTable rxnsPaths)
        {
            TreeData.TreeDataTableDataTable dt = null;
            if (rxnsPaths != null && Paths != null)
            {
                dt = new TreeData.TreeDataTableDataTable();
                //dt.AddTreeDataTableRow("1", "", "Localhost", "This is your Local Server");
                //dt.AddTreeDataTableRow("2", "1", "Child 1", "This is the first child.");
                //dt.AddTreeDataTableRow("3", "1", "Child 2", "This is the second child.");
                //dt.AddTreeDataTableRow("4", "1", "Child 3", "This is the third child.");
                //dt.AddTreeDataTableRow("5", "2", "GrandChild 1", "This is the only Grandchild.");
                //for (int i = 6; i < 150; i++)
                //{
                //    Random rand = new Random();
                //    dt.AddTreeDataTableRow(i.ToString(), rand.Next(1, i).ToString(), "GrandChild " + i.ToString(), "This is the only Grandchild.");
                //}

                string rxnNo       = "";
                string paths       = "";
                string parentRxnNo = "";
                string steps       = "";

                for (int i = 0; i < rxnsPaths.Rows.Count; i++)
                {
                    rxnNo       = "Rxn" + rxnsPaths.Rows[i]["RxnNo"].ToString();
                    parentRxnNo = !string.IsNullOrEmpty(rxnsPaths.Rows[i]["ParentRxnNo"].ToString()) ? "Rxn" + rxnsPaths.Rows[i]["ParentRxnNo"].ToString() : "";
                    paths       = rxnsPaths.Rows[i]["Paths"].ToString();
                    steps       = rxnsPaths.Rows[i]["Steps"].ToString();

                    dt.AddTreeDataTableRow(rxnNo, parentRxnNo, rxnNo, paths);
                }
            }
            return(dt);
        }
예제 #2
0
        private TreeData.TreeDataTableDataTable CreateDate()
        {
            var treeData = new TreeData.TreeDataTableDataTable();

            foreach (var value in _values)
            {
                if (value.CurrentState == MethodValue.State.FinalPath)
                {
                    continue;
                }

                var note = value.CurrentState switch
                {
                    MethodValue.State.Changed => $"-({value.Selected?.row}, {value.Selected?.column})",
                    MethodValue.State.Trimmed => $"\u0304(\u0304{value.Selected?.row}\u0304,\u0304 \u0304{value.Selected?.column}\u0304)",
                    _ => $"({value.Selected?.row}, {value.Selected?.column})"
                };
                var patentId = value.ParentValueId == -1? "" : value.ParentValueId.ToString();

                treeData.AddTreeDataTableRow(value.ValueId.ToString(), value.ParentValueId.ToString(), value.Value.HasValue? value.Value?.ToString() : "", note);
            }

            return(treeData);
        }
    }
        /// <summary>
        /// Esta funcion se encarga de generar un arbol de las celulas disponibles para dicho usuario, incluidas a las cuales es lider, lider del lider y la misma que el usuario mismo asiste
        /// </summary>
        /// <param name="usuarioId"></param>
        /// <param name="mostrarCheckboxes"></param>
        /// <returns></returns>
        public Ext.Net.TreeNode GenerarArbolDeCelulas(int usuarioId, ThreeStateBool mostrarCheckboxes, bool expandido)
        {
            ManejadorDeCelulas manejadorCelulas = new ManejadorDeCelulas();

            List <Celula> celulasPermitidas = manejadorCelulas.ObtenerCelulasPermitidasPorMiembroComoCelulas(usuarioId);

            TreeData.TreeDataTableDataTable dt = new TreeData.TreeDataTableDataTable();

            //Agregamos la celula a la que el miembro asiste, aun y cuando sera de solo lectura; solamente si no existia ya en la lista de celulas permitidas (es decir, asiste y es lider a la vez)
            Miembro miembro = (from o in SesionActual.Instance.getContexto <IglesiaEntities>().Miembro where o.MiembroId == usuarioId select o).SingleOrDefault();

            if (!(celulasPermitidas.Any(o => o.CelulaId == miembro.CelulaId)))
            {
                dt.AddTreeDataTableRow(miembro.CelulaId.ToString(), string.Empty, miembro.Celula.Descripcion, atributoDeSoloLectura);
            }

            string celulaId;
            string miembroCelulaId;
            string atributoExtra;

            foreach (Celula c in celulasPermitidas)
            {
                celulaId = c.CelulaId.ToString();
                if (c.CelulaLider.Count > 0)
                {
                    CelulaLider celulaLider = c.CelulaLider.FirstOrDefault(o => o.Borrado == false && o.Miembro.Borrado == false);
                    if (celulaLider != null)
                    {
                        miembroCelulaId = celulaLider.Miembro.CelulaId.ToString();
                        miembroCelulaId = (celulaId.Equals(miembroCelulaId)) ? string.Empty : miembroCelulaId; //Evitamos un loop infinito al momento en que el miembro sea lider de la celula a la que asiste
                        atributoExtra   = (string.IsNullOrEmpty(miembroCelulaId)) ? atributoDeSoloLectura : string.Empty;
                        dt.AddTreeDataTableRow(celulaId, miembroCelulaId, c.Descripcion, atributoExtra);
                    }
                }
            }

            //Obtenemos las celulas sin "lideres"
            List <Celula> celulasSinLider = manejadorCelulas.ObtenerCelulasSinLideresComoCelulas();

            if (celulasSinLider.Count > 0)
            {
                int idNodoCelulasSinLideres = 9999999;
                dt.AddTreeDataTableRow(idNodoCelulasSinLideres.ToString(), miembro.CelulaId.ToString(), "Celulas sin Asignacion de Lider", atributoDeSoloLectura);
                foreach (Celula c in celulasSinLider)
                {
                    dt.AddTreeDataTableRow(c.CelulaId.ToString(), idNodoCelulasSinLideres.ToString(), c.Descripcion, string.Empty);
                }
            }

            Ext.Net.TreeNode navegacion = new Ext.Net.TreeNode("Celulas");
            navegacion.Expanded = expandido;
            if ((celulasPermitidas != null) && (celulasPermitidas.Count > 0))
            {
                generarNodos(navegacion, TreeBuilder.GenerateTree(miembro.CelulaId.ToString(), dt), mostrarCheckboxes, expandido); //La celula inicial es la celula a la que el usuario asiste
            }

            return(navegacion);
        }
예제 #4
0
        /// <summary>
        /// show the agency tree
        /// </summary>
        public void ShowTree()
        {
            HideAll();
            panelTree.Show();
            panelTree.Location = new Point(0, 0);

            Agent[] agents = Connection.Instance.GetAgentDatas();


            TreeData.TreeDataTableDataTable dtTree = new TreeData.TreeDataTableDataTable();


            for (int i = 0; i < agents.Length; i++)
            {
                string status = "";

                string pOrVp = "";

                if (agents[i].ID == Connection.Instance.GetPrincipalOrViceDataFromBranchID(agents[i].BranchID, PrincipalOrVice.Principal)[1].ToString())
                {
                    pOrVp = "P";
                }
                else if (agents[i].ID == Connection.Instance.GetPrincipalOrViceDataFromBranchID(agents[i].BranchID, PrincipalOrVice.VicePrincipal)[1].ToString())
                {
                    pOrVp = "VP";
                }

                if (agents[i].Status == 0)
                {
                    status = "(disabled)";
                }
                else
                {
                    status = "(active)";
                }
                dtTree.AddTreeDataTableRow(agents[i].ID, agents[i].UplineID, agents[i].Name + "\n Branch : " + agents[i].BranchID + "\n\n" + status + " \n\n" + pOrVp, "");
            }

            TreeBuilder myTree = new TreeBuilder(dtTree);


            myTree.BoxHeight = 100;
            myTree.BoxWidth  = 200;

            Image temp = Image.FromStream(
                myTree.GenerateTree("Elton",
                                    System.Drawing.Imaging.ImageFormat.Bmp));

            pictureBoxTree.Size  = temp.Size;
            pictureBoxTree.Image = temp;
        }
예제 #5
0
파일: Form1.cs 프로젝트: BrentKnowles/flow2
        //dt.AddTreeDataTableRow(title_id, supervisor, values[0].ToUpper(), "zzap","","","","");

        /// <summary>
        /// Trying to have a better structure here for building the tree data
        /// </summary>
        /// <returns></returns>
        private TreeData.TreeDataTableDataTable GetBetterTreeData()
        {
            TreeData.TreeDataTableDataTable dt = LoadFromDatabase();

            /*
             * TreeData.TreeDataTableDataTable dt = new TreeData.TreeDataTableDataTable();
             *
             *
             * NodeDetails nodeDetails = new NodeDetails(1);
             *
             *
             * dt.AddTreeDataTableRow(nodeDetails.nodeID, nodeDetails.parentNodeID, nodeDetails.nodeDescription,
             *  nodeDetails.nodeNote, nodeDetails.nodeCategory,nodeDetails.nodeSOD, nodeDetails.scripting, nodeDetails.nodetype);
             * nodeDetails.nodeID = "2";
             * nodeDetails.parentNodeID = "1";
             * nodeDetails.nodeDescription = "snakes";
             * nodeDetails.scripting = "line(3);";
             *
             * dt.AddTreeDataTableRow(nodeDetails.nodeID, nodeDetails.parentNodeID, nodeDetails.nodeDescription,
             * nodeDetails.nodeNote, nodeDetails.nodeCategory, nodeDetails.nodeSOD, nodeDetails.scripting, nodeDetails.nodetype);
             *
             * nodeDetails.nodeID = "3";
             * nodeDetails.parentNodeID = "1";
             * nodeDetails.nodeDescription = "fish sticks";
             * nodeDetails.nodetype = "action";
             * nodeDetails.scripting = "";
             *
             * dt.AddTreeDataTableRow(nodeDetails.nodeID, nodeDetails.parentNodeID, nodeDetails.nodeDescription,
             * nodeDetails.nodeNote, nodeDetails.nodeCategory, nodeDetails.nodeSOD, nodeDetails.scripting, nodeDetails.nodetype);
             *
             *
             * nodeDetails.nodeID = "4";
             * nodeDetails.parentNodeID = "3";
             * nodeDetails.nodeDescription = "baby fish";
             * nodeDetails.nodetype = "orphan";
             *
             * dt.AddTreeDataTableRow(nodeDetails.nodeID, nodeDetails.parentNodeID, nodeDetails.nodeDescription,
             * nodeDetails.nodeNote, nodeDetails.nodeCategory, nodeDetails.nodeSOD, nodeDetails.scripting, nodeDetails.nodetype);
             *
             */

            return(dt);
        }
예제 #6
0
        private void BuildTree()
        {
            TreeData.TreeDataTableDataTable dtTree =
                new TreeData.TreeDataTableDataTable();
            var tree = ClassificationUtil.ExtractTree(GridData, Mode, (int)groupCountControl.Value);

            foreach (var treeEntry in tree)
            {
                TreeNode node  = treeEntry.Item2;
                var      label = node is LeafNode ? ((LeafNode)node).ImageName.Split(Path.DirectorySeparatorChar).Last() : "";
                dtTree.AddTreeDataTableRow(node.Id, treeEntry.Item1, label, node.GroupRoot);
            }
            //instantiate the object
            var myTree = new TreeBuilder(dtTree);
            var rootId = tree.Find(t => t.Item1 == "").Item2.Id;

            treeBox.Image = Image.FromStream(
                myTree.GenerateTree(rootId,
                                    System.Drawing.Imaging.ImageFormat.Bmp));
        }
        private void 管理员录入界面_Load(object sender, EventArgs e)
        {
            TreeGenerator.TreeData.TreeDataTableDataTable dtTree = new TreeData.TreeDataTableDataTable();
            string id, fatherid;
            string name;

            using (
                SqlConnection con = new SqlConnection("server=localhost;database=FamliyTree;uid=sa;pwd=123456"))
            {
                if (con.State != ConnectionState.Open)
                {
                    con.Close();
                    con.Open();
                }
                SqlCommand cmd = con.CreateCommand();
                cmd.CommandText = @" Select  PERSON_NAME,PERSON_ID,FATHER_ID from PERSON_TABLE";//查询根节点
                SqlDataReader sdr = cmd.ExecuteReader();

                while (sdr.Read())
                {
                    id       = sdr["PERSON_ID"].ToString();
                    fatherid = sdr["FATHER_ID"].ToString();
                    name     = sdr["PERSON_NAME"].ToString();
                    if (fatherid == "0")
                    {
                        dtTree.AddTreeDataTableRow(id, "", name, "");
                    }
                    else
                    {
                        dtTree.AddTreeDataTableRow(id, fatherid, name, "");
                    }
                }

                //instantiate the object
                //myOrgChart = new OrgChartGenerator.OrgChart(myOrgData);
                myTree = new TreeBuilder(dtTree);
                ShowTree();
            }
        }
        public static void displayChart(DDTDiagram dfd)
        {
            DirectedPathNode root = getDirectedPath(dfd);

            ACNode acRoot = getArchitectureChart(root);

            TreeData.TreeDataTableDataTable dtTree = new TreeData.TreeDataTableDataTable();
            acRoot.getTree(dtTree);
            /*dtTree.AddTreeDataTableRow("12", "", "System", "");
            dtTree.AddTreeDataTableRow("1", "12", "Input", "");
            dtTree.AddTreeDataTableRow("2", "12", "Process", "");
            dtTree.AddTreeDataTableRow("3", "12", "Output", "");
            dtTree.AddTreeDataTableRow("4", "1", "3000", "");
            dtTree.AddTreeDataTableRow("5", "1", "3001", "");
            dtTree.AddTreeDataTableRow("6", "2", "3000", "");
            dtTree.AddTreeDataTableRow("7", "4", "4000", "");
            dtTree.AddTreeDataTableRow("8", "4", "4001", "");
            */

            TreeBuilder t = new TreeBuilder(dtTree);
            //Now - Generate the tree itself
            Image i = Image.FromStream(
                t.GenerateTree(acRoot.id,
                System.Drawing.Imaging.ImageFormat.Bmp));
            i.Save("C://test.bmp");

            //ExecuteCommand("C://test.bmp", 100);
            PictureBox pb = new PictureBox();
            pb.SizeMode = PictureBoxSizeMode.AutoSize;
            pb.Image = i;

            Form newForm = new Form();
            newForm.Controls.Add(pb);
            newForm.AutoSize = true;
            newForm.BackColor = Color.White;
            newForm.Show();
        }
예제 #9
0
 private TreeData.TreeDataTableDataTable GetTreeData()
 {
     TreeData.TreeDataTableDataTable dt = new TreeData.TreeDataTableDataTable();
     dt.AddTreeDataTableRow("1", "", "Localhost", "This is your Local Server");
     dt.AddTreeDataTableRow("2", "1", "Child 1", "This is the first child.");
     dt.AddTreeDataTableRow("3", "1", "Child 2", "This is the second child.");
     dt.AddTreeDataTableRow("4", "1", "Child 3", "This is the third child.");
     dt.AddTreeDataTableRow("5", "2", "GrandChild 1", "This is the only Grandchild.");
     for (int i = 6; i < 150; i++)
     {
         Random rand = new Random();
         dt.AddTreeDataTableRow(i.ToString(), rand.Next(1, i).ToString(), "GrandChild " + i.ToString(), "This is the only Grandchild.");
     }
     return dt;
 }
예제 #10
0
 /// <summary>
 /// ctor
 /// </summary>
 /// <param name="TreeData"></param>
 public TreeBuilder(TreeData.TreeDataTableDataTable TreeData)
 {
     dtTree = TreeData;
 }
예제 #11
0
        public void Dispose()
        {
            dtTree = null;

            if (gr != null)
            {
                gr.Dispose();
                gr = null;
            }
        }
예제 #12
0
파일: Form1.cs 프로젝트: PKanokwan/AL3_61
        private TreeData.TreeDataTableDataTable GetTreeData()
        {
            int    ct = 1, cn = 0, lv = 0;
            String root;

            String[] roots;
            root  = Convert.ToString(tree.Root.Branches[0]);
            roots = root.Split(' ');
            cn    = tree.Root.Branches.Count;
            TreeData.TreeDataTableDataTable dt = new TreeData.TreeDataTableDataTable();
            dt.AddTreeDataTableRow(Convert.ToString(ct), "", "Root", roots[0]);
            lv = 1;
            for (int i = 0; i < cn; i++)
            {
                ct = ct + 1;
                if (roots[0] == "Outlook")
                {
                    lv = 1;
                    if (tree.Root.Branches[i].IsLeaf == false)
                    {
                        String   node  = Convert.ToString(tree.Root.Branches[i].Branches[0]);
                        String[] nodes = node.Split(' ');
                        dt.AddTreeDataTableRow(Convert.ToString(ct), Convert.ToString(lv), bn1[i], nodes[0]);
                        lv = ct;
                        int cn2 = tree.Root.Branches[i].Branches.Count;
                        for (int j = 0; j < cn2; j++)
                        {
                            ct = ct + 1;
                            if (nodes[0] == "Outlook")
                            {
                                if (tree.Root.Branches[i].Branches[j].IsLeaf == true)
                                {
                                    int oo1 = tree.Root.Branches[i].Branches[j].Output.Value;
                                    dt.AddTreeDataTableRow(Convert.ToString(ct), Convert.ToString(lv), bn1[j], bn5[oo1]);
                                }
                            }
                            else if (nodes[0] == "Temp")
                            {
                                if (tree.Root.Branches[i].Branches[j].IsLeaf == true)
                                {
                                    int oo1 = tree.Root.Branches[i].Branches[j].Output.Value;
                                    dt.AddTreeDataTableRow(Convert.ToString(ct), Convert.ToString(lv), bn2[j], bn5[oo1]);
                                }
                            }
                            else if (nodes[0] == "Humid")
                            {
                                if (tree.Root.Branches[i].Branches[j].IsLeaf == true)
                                {
                                    int oo1 = tree.Root.Branches[i].Branches[j].Output.Value;
                                    dt.AddTreeDataTableRow(Convert.ToString(ct), Convert.ToString(lv), bn3[j], bn5[oo1]);
                                }
                            }
                            else if (nodes[0] == "Wind")
                            {
                                if (tree.Root.Branches[i].Branches[j].IsLeaf == true)
                                {
                                    int oo1 = tree.Root.Branches[i].Branches[j].Output.Value;
                                    dt.AddTreeDataTableRow(Convert.ToString(ct), Convert.ToString(lv), bn4[j], bn5[oo1]);
                                }
                            }
                        }
                    }
                    else
                    {
                        int oo = tree.Root.Branches[i].Output.Value;
                        dt.AddTreeDataTableRow(Convert.ToString(ct), Convert.ToString(lv), bn1[i], bn5[oo]);
                    }
                }
                else if (roots[0] == "Temp")
                {
                    lv = 1;
                    if (tree.Root.Branches[i].IsLeaf == false)
                    {
                        String   node  = Convert.ToString(tree.Root.Branches[i].Branches[0]);
                        String[] nodes = node.Split(' ');
                        dt.AddTreeDataTableRow(Convert.ToString(ct), Convert.ToString(lv), bn2[i], nodes[0]);
                        lv = ct;
                        int cn2 = tree.Root.Branches[i].Branches.Count;
                        for (int j = 0; j < cn2; j++)
                        {
                            ct = ct + 1;
                            if (nodes[0] == "Outlook")
                            {
                                if (tree.Root.Branches[i].Branches[j].IsLeaf == true)
                                {
                                    int oo1 = tree.Root.Branches[i].Branches[j].Output.Value;
                                    dt.AddTreeDataTableRow(Convert.ToString(ct), Convert.ToString(lv), bn1[j], bn5[oo1]);
                                }
                            }
                            else if (nodes[0] == "Temp")
                            {
                                if (tree.Root.Branches[i].Branches[j].IsLeaf == true)
                                {
                                    int oo1 = tree.Root.Branches[i].Branches[j].Output.Value;
                                    dt.AddTreeDataTableRow(Convert.ToString(ct), Convert.ToString(lv), bn2[j], bn5[oo1]);
                                }
                            }
                            else if (nodes[0] == "Humid")
                            {
                                if (tree.Root.Branches[i].Branches[j].IsLeaf == true)
                                {
                                    int oo1 = tree.Root.Branches[i].Branches[j].Output.Value;
                                    dt.AddTreeDataTableRow(Convert.ToString(ct), Convert.ToString(lv), bn3[j], bn5[oo1]);
                                }
                            }
                            else if (nodes[0] == "Wind")
                            {
                                if (tree.Root.Branches[i].Branches[j].IsLeaf == true)
                                {
                                    int oo1 = tree.Root.Branches[i].Branches[j].Output.Value;
                                    dt.AddTreeDataTableRow(Convert.ToString(ct), Convert.ToString(lv), bn4[j], bn5[oo1]);
                                }
                            }
                        }
                    }
                    else
                    {
                        int oo = tree.Root.Branches[i].Output.Value;
                        dt.AddTreeDataTableRow(Convert.ToString(ct), Convert.ToString(lv), bn2[i], bn5[oo]);
                    }
                }
                else if (roots[0] == "Humid")
                {
                    lv = 1;
                    if (tree.Root.Branches[i].IsLeaf == false)
                    {
                        String   node  = Convert.ToString(tree.Root.Branches[i].Branches[0]);
                        String[] nodes = node.Split(' ');
                        dt.AddTreeDataTableRow(Convert.ToString(ct), Convert.ToString(lv), bn3[i], nodes[0]);
                        lv = ct;
                        int cn2 = tree.Root.Branches[i].Branches.Count;
                        for (int j = 0; j < cn2; j++)
                        {
                            ct = ct + 1;
                            if (nodes[0] == "Outlook")
                            {
                                if (tree.Root.Branches[i].Branches[j].IsLeaf == true)
                                {
                                    int oo1 = tree.Root.Branches[i].Branches[j].Output.Value;
                                    dt.AddTreeDataTableRow(Convert.ToString(ct), Convert.ToString(lv), bn1[j], bn5[oo1]);
                                }
                            }
                            else if (nodes[0] == "Temp")
                            {
                                if (tree.Root.Branches[i].Branches[j].IsLeaf == true)
                                {
                                    int oo1 = tree.Root.Branches[i].Branches[j].Output.Value;
                                    dt.AddTreeDataTableRow(Convert.ToString(ct), Convert.ToString(lv), bn2[j], bn5[oo1]);
                                }
                            }
                            else if (nodes[0] == "Humid")
                            {
                                if (tree.Root.Branches[i].Branches[j].IsLeaf == true)
                                {
                                    int oo1 = tree.Root.Branches[i].Branches[j].Output.Value;
                                    dt.AddTreeDataTableRow(Convert.ToString(ct), Convert.ToString(lv), bn3[j], bn5[oo1]);
                                }
                            }
                            else if (nodes[0] == "Wind")
                            {
                                if (tree.Root.Branches[i].Branches[j].IsLeaf == true)
                                {
                                    int oo1 = tree.Root.Branches[i].Branches[j].Output.Value;
                                    dt.AddTreeDataTableRow(Convert.ToString(ct), Convert.ToString(lv), bn4[j], bn5[oo1]);
                                }
                            }
                        }
                    }
                    else
                    {
                        int oo = tree.Root.Branches[i].Output.Value;
                        dt.AddTreeDataTableRow(Convert.ToString(ct), Convert.ToString(lv), bn3[i], bn5[oo]);
                    }
                }
                else if (roots[0] == "Wind")
                {
                    lv = 1;
                    if (tree.Root.Branches[i].IsLeaf == false)
                    {
                        String   node  = Convert.ToString(tree.Root.Branches[i].Branches[0]);
                        String[] nodes = node.Split(' ');
                        dt.AddTreeDataTableRow(Convert.ToString(ct), Convert.ToString(lv), bn4[i], nodes[0]);
                        lv = ct;
                        int cn2 = tree.Root.Branches[i].Branches.Count;
                        for (int j = 0; j < cn2; j++)
                        {
                            ct = ct + 1;
                            if (nodes[0] == "Outlook")
                            {
                                if (tree.Root.Branches[i].Branches[j].IsLeaf == true)
                                {
                                    int oo1 = tree.Root.Branches[i].Branches[j].Output.Value;
                                    dt.AddTreeDataTableRow(Convert.ToString(ct), Convert.ToString(lv), bn1[j], bn5[oo1]);
                                }
                            }
                            else if (nodes[0] == "Temp")
                            {
                                if (tree.Root.Branches[i].Branches[j].IsLeaf == true)
                                {
                                    int oo1 = tree.Root.Branches[i].Branches[j].Output.Value;
                                    dt.AddTreeDataTableRow(Convert.ToString(ct), Convert.ToString(lv), bn2[j], bn5[oo1]);
                                }
                            }
                            else if (nodes[0] == "Humid")
                            {
                                if (tree.Root.Branches[i].Branches[j].IsLeaf == true)
                                {
                                    int oo1 = tree.Root.Branches[i].Branches[j].Output.Value;
                                    dt.AddTreeDataTableRow(Convert.ToString(ct), Convert.ToString(lv), bn3[j], bn5[oo1]);
                                }
                            }
                            else if (nodes[0] == "Wind")
                            {
                                if (tree.Root.Branches[i].Branches[j].IsLeaf == true)
                                {
                                    int oo1 = tree.Root.Branches[i].Branches[j].Output.Value;
                                    dt.AddTreeDataTableRow(Convert.ToString(ct), Convert.ToString(lv), bn4[j], bn5[oo1]);
                                }
                            }
                        }
                    }
                    else
                    {
                        int oo = tree.Root.Branches[i].Output.Value;
                        dt.AddTreeDataTableRow(Convert.ToString(ct), Convert.ToString(lv), bn4[i], bn5[oo]);
                    }
                }
            }



            return(dt);
        }
예제 #13
0
파일: Form1.cs 프로젝트: BrentKnowles/flow2
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        private TreeData.TreeDataTableDataTable GetTreeData(TreeBuilder.mode mode)
        {
            List <string> strings = new List <string>();

            if (dataGridView1.DataSource != null)
            {
                PreloadFromDatabase();
            }


            //
            // Lowercase all strings
            //
            if (textBox1.Text == "")
            {
                textBox1.Text = "ceo;";
            }
            if (textBoxPeople.Text == "")
            {
                textBoxPeople.Text = "ceo;Joe";
            }
            if (textBoxDuties.Text == "")
            {
                textBoxDuties.Text = "a;b";
            }


            // escape apostophes -- doing this in the google sheet instead
            textBoxDuties.Text = textBoxDuties.Text.Replace("'", "#");


            textBox1.Text      = textBox1.Text.ToLower();
            textBoxPeople.Text = textBoxPeople.Text.ToLower();
            textBoxDuties.Text = textBoxDuties.Text.ToLower();


            // -1 - Create People -> Rolemapping
            Hashtable peopleHash = new Hashtable();

            string[] textPeople = null;

            if (mode == TreeBuilder.mode.ORG)
            {
                textPeople = textBoxPeople.Text.Split(new string[1] {
                    "\r\n"
                }, StringSplitOptions.None);
            }
            else
            if (mode == TreeBuilder.mode.DUTY)
            {
                textPeople = textBoxDuties.Text.Split(new string[1] {
                    "\r\n"
                }, StringSplitOptions.None);
            }



            string category = String.Empty;
            string SOD      = string.Empty;

            foreach (string s in textPeople)
            {
                if (s == "")
                {
                    break;
                }

                string[] values = s.Split(new char[1] {
                    ';'
                }, StringSplitOptions.None);
                if (values == null || values.Length < 2)
                {
                    throw new Exception("Bad Data");
                }
                string people_ref     = values[0].ToLower();
                string supervisor_ref = values[1].ToLower();

                if (values.Length >= 4)
                {
                    category       = values[2];
                    SOD            = values[3];
                    supervisor_ref = string.Format("{0};{1};{2}", supervisor_ref, category, SOD);
                }



                if (peopleHash[people_ref] == null)
                {
                    // create a list for this hash
                    // we store a List of PEOPLE assigned to a role (i.e., multiple technical designers might exist
                    peopleHash[people_ref] = new List <string>();
                    (peopleHash[people_ref] as List <string>).Add(supervisor_ref);
                }
                else
                {
                    // add to the list
                    (peopleHash[people_ref] as List <string>).Add(supervisor_ref);
                }
            }

            // 0 - Process text box
            string[] text = textBox1.Text.Split(new string[1] {
                "\r\n"
            }, StringSplitOptions.None);
            foreach (string s in text)
            {
                strings.Add(s);
            }
            System.Collections.Hashtable hash = new System.Collections.Hashtable();

            // 1 - Set the data up for parsing
            for (int i = 0; i < strings.Count; i++)
            {
                string[] values = strings[i].Split(new char[1] {
                    ';'
                }, StringSplitOptions.None);



                if (values == null || values.Length < 2)
                {
                    MessageBox.Show("Bad Data");
                    return(null);
                }
                else
                {
                    string supervisor_ref = values[1].ToLower();

                    if (mode == TreeBuilder.mode.DUTY)
                    {
                        if (supervisor_ref != "")
                        {
                            // when listing duties we use a flat org structure
                            supervisor_ref = "1";
                        }
                    }
                    string title = values[0];
                    // store the row index to later build the ORG tree
                    // if (supervisor == "") supervisor = ""; // CEO needs the number assignment

                    hash[title] = supervisor_ref;
                }
            }


            // 2 - now that processing is done we build the tree
            TreeData.TreeDataTableDataTable dt = new TreeData.TreeDataTableDataTable();

            for (int i = 0; i < strings.Count; i++)
            {
                string[] values = strings[i].Split(new char[1] {
                    ';'
                }, StringSplitOptions.None);

                if (values == null || values.Length < 2)
                {
                    throw new Exception("Bad Data");
                }
                string title_id = values[0];

                // If our supervisor is CEO we need to use "1" instead of label
                string supervisor = hash[title_id].ToString();


                if (supervisor == CEO)
                {
                    supervisor = "1";
                }

                //RULE first row is CEO
                if (i == 0)
                {
                    title_id = "1";
                }

                bool   addedBoss = false;
                string person    = "";// NO_PERSON;



                if (peopleHash.Count <= 0)
                {
                    person = "";
                }
                if (peopleHash[title_id] != null)
                {
                    if (peopleHash[title_id] is List <string> )
                    {
                        person = "";
                        if (mode == TreeBuilder.mode.DUTY)
                        {
                            person = "";
                        }
                        //   string[] values_Detail = supervisor.Split(new char[1] { ';' }, StringSplitOptions.None);



                        List <string> tempList = (peopleHash[title_id] as List <string>);
                        if (tempList.Count > 1)
                        {
                            /* Intentionally breaking the Person system 9/28/2017 to allow wordwrap
                             *
                             */

                            dt.AddTreeDataTableRow(title_id, supervisor, values[0].ToUpper(), "zzap", "", "", "", "");



                            addedBoss = true;
                            string _id = title_id;
                            foreach (string s in tempList)
                            {
                                string[] values2 = s.Split(new char[1] {
                                    ';'
                                }, StringSplitOptions.None);
                                if (values2.Length >= 3)
                                {
                                    category = "boom"; // values2[1];
                                    SOD      = "carl"; // values2[2];
                                }

                                dt.AddTreeDataTableRow(s, _id, values2[0], "justperson", category, SOD, "", "");
                                _id = s;

                                if (mode == TreeBuilder.mode.DUTY)
                                {
                                    // Add Category if DUTY-VIEW
                                    //categ
                                    // Add person actualy doing this
                                }


                                //person = person + "\n" + s;
                            }
                        }
                        else
                        {
                            person = tempList[0];
                        }
                    }
                }

                if (addedBoss == false)
                {
                    // * Break string mode

                    string titletext = values[0];
                    string line2text = "";

                    /*  int idx = titletext.IndexOf("*");
                     * if (idx > -1)
                     * {
                     *    line2text = titletext.Substring(idx);
                     *    titletext = titletext.Substring(0, idx);
                     * }
                     * don't actually need since word wrap ALREADY HAPPENS?S?
                     */

                    dt.AddTreeDataTableRow(title_id, supervisor, titletext.ToUpper(), line2text, "", "", "", "");
                }
                addedBoss = false;
            }

            /*
             * dt.AddTreeDataTableRow("Project Director", "1", "PD", "This is the first child.");
             * dt.AddTreeDataTableRow("3", "1", "Child 2", "This is the second child.");
             * dt.AddTreeDataTableRow("4", "1", "Child 3", "This is the third child.");
             * dt.AddTreeDataTableRow("5", "Project Director", "GrandChild 1", "This is the only Grandchild.");
             */
            return(dt);
        }
예제 #14
0
파일: Form1.cs 프로젝트: BrentKnowles/flow2
        /// <summary>
        ///
        /// </summary>
        private TreeData.TreeDataTableDataTable LoadFromDatabase()
        {
            DataTable table       = ds.Tables[0];
            const int key         = 0;
            const int parentkey   = 1;
            const int description = 2;
            const int note        = 3;
            const int scripting   = 4;
            const int ntype       = 5;

            TreeData.TreeDataTableDataTable dt = new TreeData.TreeDataTableDataTable();
            foreach (DataRow dr in table.Rows)
            {
                if (dr[key].ToString() != "")
                {
                    NodeDetails nodeDetails = new NodeDetails(1);
                    nodeDetails.nodeID       = dr[key].ToString();
                    nodeDetails.parentNodeID = dr[parentkey].ToString();


                    if (dr[description] != null)
                    {
                        nodeDetails.nodeDescription = dr[description].ToString();
                    }
                    if (dr[note] != null)
                    {
                        nodeDetails.nodeNote = dr[note].ToString();
                    }
                    if (dr[scripting] != null)
                    {
                        nodeDetails.scripting = dr[scripting].ToString();
                    }
                    if (dr[ntype] != null)
                    {
                        nodeDetails.nodetype = dr[ntype].ToString();
                    }

                    try
                    {
                        dt.AddTreeDataTableRow(nodeDetails.nodeID, nodeDetails.parentNodeID, nodeDetails.nodeDescription,
                                               nodeDetails.nodeNote, nodeDetails.nodeCategory, nodeDetails.nodeSOD, nodeDetails.scripting, nodeDetails.nodetype);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Data may be lost, error with unique key.");
                    }
                    //
                    // -1 is a control row
                    // scripting column contains a stylesheet to load
                    //
                    if (dr[key].ToString() == "-1" && dr[scripting] != null)
                    {
                        string filename = dr[scripting].ToString();
                        if (File.Exists(filename))
                        {
                            LoadStyle(filename);
                        }
                    }
                }
            }
            return(dt);
        }
        public static void displayChart(DDTDiagram dfd, int processingStartID, int outputStartID)
        {
            // first lets get the directed graph from the DFD
            DirectedPathNode root = TransactionDFDConverter.getDirectedPath(dfd);
            string processingStart = DDTHelper.manager.project.getDDTObject(processingStartID).ToString();
            string outputStart = DDTHelper.manager.project.getDDTObject(outputStartID).ToString();

            ACNode nullRoot = new ACNode("null root");
            ACNode acRoot = new ACNode("SYSTEM", nullRoot);
            ACNode input = new ACNode("INPUT", acRoot);
            ACNode processing = new ACNode("PROCESSING", acRoot);
            ACNode output = new ACNode("OUTPUT", acRoot);

            acRoot.addChild(input);
            acRoot.addChild(processing);
            acRoot.addChild(output);

            DirectedPathNode current = root;
            // build the input tree.
            while (current.name != processingStart)
            {
                ACNode newNode = new ACNode(current.name, input);
                input.addChild(newNode);
                current = current.next[0];
            }
            // build the processing tree.
            while (current.name != outputStart)
            {
                ACNode newNode = new ACNode(current.name, processing);
                processing.addChild(newNode);
                current = current.next[0];
            }
            // build output tree.
            while (current != null)
            {
                ACNode newNode = new ACNode(current.name, output);
                output.addChild(newNode);
                current = current.next[0];
            }

            // actually create the architecture chart.
            TreeData.TreeDataTableDataTable dtTree = new TreeData.TreeDataTableDataTable();
            acRoot.getTree(dtTree);

            TreeBuilder t = new TreeBuilder(dtTree);
            //Now - Generate the tree itself
            Image i = Image.FromStream(
                t.GenerateTree(acRoot.id,
                System.Drawing.Imaging.ImageFormat.Bmp));
            i.Save("C://test.bmp");

            //ExecuteCommand("C://test.bmp", 100);
            PictureBox pb = new PictureBox();
            pb.SizeMode = PictureBoxSizeMode.AutoSize;
            pb.Image = i;

            Form newForm = new Form();
            newForm.Controls.Add(pb);
            newForm.AutoSize = true;
            newForm.BackColor = Color.White;
            newForm.Show();
        }