Exemple #1
0
        public SignalInfo fillSubRoot(SignalInfo root, SignalGroup group)
        {
            string kks = group.KKSDev + "-" + group.level;

            if (root.Children == null)
            {
                root.Children = new List <SignalInfo>();
            }
            foreach (SignalInfo ch in root.Children)
            {
                if (ch.KKS == kks)
                {
                    return(ch);
                }
            }
            SignalInfo si = new SignalInfo();

            si.KKS         = kks;
            si.ShortName   = group.name;
            si.FullName    = group.name;
            si.FullNameUp  = si.FullName.ToUpper();
            si.ShortNameUp = si.ShortName.ToUpper();
            root.Children.Add(si);
            return(si);
        }
Exemple #2
0
        public void readkksDev()
        {
            SubSystems = new Dictionary <int, string>();
            SqlConnection con = DBSettings.getConnection();

            con.Open();
            SqlCommand com = con.CreateCommand();

            Status.Text     = "Чтение групп сигналов";
            com.CommandText = "Select * from ASU_signal_group";
            SqlDataReader reader = com.ExecuteReader();

            Signals = new Dictionary <string, List <SignalGroup> >();
            while (reader.Read())
            {
                SignalGroup gr = new SignalGroup();
                gr.KKSDev = reader.GetString(0);
                gr.name   = reader.GetString(3);
                try {
                    gr.level = reader.GetInt32(1);
                }
                catch {
                    gr.level = -1;
                }
                try {
                    gr.parent = reader.GetInt32(2);
                }
                catch {
                    gr.parent = -1;
                }
                if (!Signals.ContainsKey(gr.KKSDev))
                {
                    Signals.Add(gr.KKSDev, new List <SignalGroup>());
                }
                Signals[gr.KKSDev].Add(gr);
            }
            reader.Close();
            con.Close();
        }
Exemple #3
0
 public void readkksDev()
 {
     SubSystems = new Dictionary<int, string>();
     SqlConnection con = DBSettings.getConnection();
     con.Open();
     SqlCommand com = con.CreateCommand();
     Status.Text = "Чтение групп сигналов";
     com.CommandText = "Select * from ASU_signal_group";
     SqlDataReader reader = com.ExecuteReader();
     Signals = new Dictionary<string, List<SignalGroup>>();
     while (reader.Read()) {
         SignalGroup gr = new SignalGroup();
         gr.KKSDev = reader.GetString(0);
         gr.name = reader.GetString(3);
         try {
             gr.level = reader.GetInt32(1);
         }
         catch {
             gr.level = -1;
         }
         try {
             gr.parent = reader.GetInt32(2);
         }
         catch {
             gr.parent = -1;
         }
         if (!Signals.ContainsKey(gr.KKSDev)) {
             Signals.Add(gr.KKSDev, new List<SignalGroup>());
         }
         Signals[gr.KKSDev].Add(gr);
     }
     reader.Close();
     con.Close();
 }
Exemple #4
0
 public SignalInfo fillSubRoot(SignalInfo root, SignalGroup group)
 {
     string kks = group.KKSDev + "-" + group.level;
     if (root.Children == null)
         root.Children = new List<SignalInfo>();
     foreach (SignalInfo ch in root.Children) {
         if (ch.KKS == kks)
             return ch;
     }
     SignalInfo si = new SignalInfo();
     si.KKS = kks;
     si.ShortName = group.name;
     si.FullName = group.name;
     si.FullNameUp = si.FullName.ToUpper();
     si.ShortNameUp = si.ShortName.ToUpper();
     root.Children.Add(si);
     return si;
 }
Exemple #5
0
        public void fillSubTree(SignalInfo root)
        {
            if (!root.isLastTreeNode)
            {
                foreach (SignalInfo ch in root.Children)
                {
                    fillSubTree(ch);
                }
            }
            else if (root.Children != null)
            {
                SignalInfo subRoot = new SignalInfo();
                subRoot.Children = new List <SignalInfo>();
                List <SignalInfo> forDel = new List <SignalInfo>();
                foreach (SignalInfo si in root.Children)
                {
                    if (!Signals.ContainsKey(si.kksDev))
                    {
                        continue;
                    }
                    List <SignalGroup> groups  = Signals[si.kksDev];
                    List <SignalGroup> subTree = new List <SignalGroup>();
                    try {
                        int level = si.idLevel;
                        int index = 0;
                        while (index < groups.Count)
                        {
                            SignalGroup gr = groups[index];
                            if (gr.level == level)
                            {
                                subTree.Add(gr);
                                level = gr.parent;
                                index = -1;
                            }
                            index++;
                        }
                    }
                    catch { }

                    try {
                        if (subTree.Count > 0)
                        {
                            SignalInfo siTemp = subRoot;
                            for (int i = subTree.Count - 1; i >= 0; i--)
                            {
                                SignalGroup gr = subTree[i];
                                siTemp = fillSubRoot(siTemp, gr);
                            }
                            if (siTemp.Children == null)
                            {
                                siTemp.Children = new List <SignalInfo>();
                            }
                            siTemp.Children.Add(si);
                            forDel.Add(si);
                        }
                    }
                    catch { }
                }
                foreach (SignalInfo del in forDel)
                {
                    root.Children.Remove(del);
                }
                foreach (SignalInfo add in subRoot.Children)
                {
                    bool found = false;
                    foreach (SignalInfo s in root.Children)
                    {
                        if (s.KKS == add.KKS)
                        {
                            found = true;
                            break;
                        }
                    }
                    if (!found)
                    {
                        root.Children.Add(add);
                    }
                }
            }
        }