Beispiel #1
0
        private void fillTree()
        {
            IUserInfo           ui = (IUserInfo)DataHost;
            List <Пользователь> list;

            UserLevel[] UserStyleArray = (UserLevel[])UserLevel.GetValues(typeof(UserLevel));
            tvList.BeginUpdate();
            try
            {
                tvList.Nodes.Clear();
                foreach (UserLevel category in UserStyleArray)
                {
                    TreeNode child;
                    TreeNode node = tvList.Nodes.Add(category.ToString());
                    node.Name = category.ToString();
                    node.Tag  = category;
                    node.SelectedImageIndex = 0;
                    node.ImageIndex         = 0;
                    list = ui.GetUserList(category);
                    foreach (Пользователь item in list)
                    {
                        child      = node.Nodes.Add(item.ПолноеИмя());
                        child.Name = item.ПолноеИмя();
                        child.Tag  = category;
                        child.SelectedImageIndex = 1;
                        child.ImageIndex         = 1;
                    }
                }
            }
            finally
            {
                tvList.EndUpdate();
            }
        }
Beispiel #2
0
        public static UserLevel GetCurrentLevel(string slevel)
        {
            UserLevel[] levels = (UserLevel[])UserLevel.GetValues(typeof(UserLevel));
            UserLevel   level  = UserLevel.Диспетчер;

            foreach (UserLevel item in levels)
            {
                if (item.ToString().Equals(slevel))
                {
                    level = item; break;
                }
            }
            return(level);
        }
Beispiel #3
0
        public static int UserLevelToInt(UserLevel level)
        {
            UserLevel[] levels = (UserLevel[])UserLevel.GetValues(typeof(UserLevel));
            int         n      = 0;

            foreach (UserLevel item in levels)
            {
                if (item == level)
                {
                    break;
                }
                n++;
            }
            return(n);
        }
Beispiel #4
0
        public static UserLevel IntToUserLevel(int index)
        {
            UserLevel[] levels = (UserLevel[])UserLevel.GetValues(typeof(UserLevel));
            UserLevel   level  = UserLevel.Диспетчер;
            int         n      = 0;

            foreach (UserLevel item in levels)
            {
                if (n == index)
                {
                    level = item; break;
                }
                n++;
            }
            return(level);
        }
Beispiel #5
0
 private void frmUserInfo_Load(object sender, EventArgs e)
 {
     cbCategory.Items.Clear();
     UserLevel[] UserStyleArray =
         (UserLevel[])UserLevel.GetValues(typeof(UserLevel));
     foreach (UserLevel cat in UserStyleArray)
     {
         cbCategory.Items.Add(cat.ToString());
     }
     cbCategory.SelectedIndex = (int)initstyle;
     if (!anew)
     {
         tbLastName.Text          = user.Фамилия;
         tbFirstName.Text         = user.Имя;
         tbMiddleName.Text        = user.Отчество;
         cbCategory.SelectedIndex = (int)user.Категория;
         tbPassword.Text          = user.Пароль;
         tbDoublePassword.Text    = user.Пароль;
     }
     Idler.Enabled = true;
     UpdateButtons();
 }
Beispiel #6
0
 private void backgroundFetch_RunWorkerCompleted(object sender, System.ComponentModel.RunWorkerCompletedEventArgs e)
 {
     IDictionary<string, string> Reals = (IDictionary<string, string>)e.Result;
     if (!mustReload) mustReload = (Reals.ContainsKey("Version") &&
                                    Reals.ContainsKey("BaseVersion")) ?
         DateTime.Parse(Reals["Version"]) > DateTime.Parse(Reals["BaseVersion"]) : false;
     lbPV.Text = (Reals.ContainsKey("PVText")) ? Reals["PVText"] : "------";
     lbRaw.Text = (Reals.ContainsKey("Raw")) ? Reals["Raw"] : "------";
     lbPVCalc.Text = (Reals.ContainsKey("PV")) ? Reals["PV"] : "------";
     string alarms = (Reals.ContainsKey("Alarms")) ? Reals["Alarms"] : String.Empty;
     lbPVEUHI.BackColor = (alarms.IndexOf("HE=") < 0) ? this.BackColor : Color.Magenta;
     lbPVEULO.BackColor = (alarms.IndexOf("LE=") < 0) ? this.BackColor : Color.Magenta;
     lbPVHHTP.BackColor = (alarms.IndexOf("HH=") < 0) ? this.BackColor : Color.Red;
     lbPVHITP.BackColor = (alarms.IndexOf("HI=") < 0) ? this.BackColor : Color.Yellow;
     lbPVHITP.ForeColor = (alarms.IndexOf("HI=") < 0) ? Color.White : Color.Black;
     lbPVLOTP.BackColor = (alarms.IndexOf("LO=") < 0) ? this.BackColor : Color.Yellow;
     lbPVLOTP.ForeColor = (alarms.IndexOf("LO=") < 0) ? Color.White : Color.Black;
     lbPVLLTP.BackColor = (alarms.IndexOf("LL=") < 0) ? this.BackColor : Color.Red;
     lastcent = percent;
     percent = 0;
     if (Decimal.TryParse((Reals.ContainsKey("PVPercent")) ?
         (string)Reals["PVPercent"] : "0", out percent)) percent = percent / 100m;
     lbPVPercent.Text = percent.ToString("0.000 %");
     lbPV.BackColor = (Reals.ContainsKey("BackColor")) ?
         Color.FromArgb(int.Parse(Reals["BackColor"])) : Color.Black;
     lbPV.ForeColor = (Reals.ContainsKey("ForeColor")) ?
         Color.FromArgb(int.Parse(Reals["ForeColor"])) : Color.White;
     bool quit = (Reals.ContainsKey("QuitAlarms")) ?
         bool.Parse(Reals["QuitAlarms"]) : true;
     bool alarm = (Reals.ContainsKey("HasAlarms")) ?
         bool.Parse(Reals["HasAlarms"]) : false;
     bool lostalarm = (Reals.ContainsKey("HasLostAlarms")) ?
         bool.Parse(Reals["HasLostAlarms"]) : false;
     if (!quit && blink)
     {
         lbPV.BackColor = Color.Transparent;
         lbPV.ForeColor = Color.White;
         if (alarms.IndexOf("HE=True") < 0)
             lbPVEUHI.BackColor = Color.Transparent;
         if (alarms.IndexOf("HH=True") < 0)
             lbPVHHTP.BackColor = Color.Transparent;
         if (alarms.IndexOf("HI=True") < 0)
         {
             lbPVHITP.BackColor = Color.Transparent;
             lbPVHITP.ForeColor = Color.White;
         }
         if (alarms.IndexOf("LO=True") < 0)
         {
             lbPVLOTP.BackColor = Color.Transparent;
             lbPVLOTP.ForeColor = Color.White;
         }
         if (alarms.IndexOf("LL=True") < 0)
             lbPVLLTP.BackColor = Color.Transparent;
         if (alarms.IndexOf("LE=True") < 0)
             lbPVEULO.BackColor = Color.Transparent;
     }
     if (Reals.ContainsKey("UserLevel"))
     {
         string slevel = Reals["UserLevel"];
         UserLevel[] levels = (UserLevel[])UserLevel.GetValues(typeof(UserLevel));
         UserLevel level = UserLevel.Диспетчер;
         foreach (UserLevel item in levels)
             if (item.ToString().Equals(slevel)) { level = item; break; }
         if (level >= UserLevel.Оператор)
             btnQuit.Enabled = !quit;
         else
             btnQuit.Enabled = false;
     }
     else 
         btnQuit.Enabled = false;
     pbBar.Invalidate();
     blink = !blink;
 }
Beispiel #7
0
        private void backgroundFetch_RunWorkerCompleted(object sender, System.ComponentModel.RunWorkerCompletedEventArgs e)
        {
            IDictionary <string, string> Reals = (IDictionary <string, string>)e.Result;

            if (!mustReload)
            {
                mustReload = (Reals.ContainsKey("Version") &&
                              Reals.ContainsKey("BaseVersion")) ?
                             DateTime.Parse(Reals["Version"]) > DateTime.Parse(Reals["BaseVersion"]) : false;
            }
            lbPV.Text  = (Reals.ContainsKey("PVText")) ? Reals["PVText"] : "------";
            lbRaw.Text = (Reals.ContainsKey("Raw")) ? Reals["Raw"] : "------";
            if (Reals.ContainsKey("PV"))
            {
                bool pv = bool.Parse(Reals["PV"]);
                if (pv)
                {
                    lbPVCalc.Text        = "Лог. \"1\"";
                    lbOn.ForeColor       = Color.White;
                    lbOff.ForeColor      = Color.Silver;
                    lbOnColor.BackColor  = ent.BaseColor((int)ent.Values["ColorUp"]);
                    lbOffColor.BackColor = Color.Black;
                }
                else
                {
                    lbPVCalc.Text        = "Лог. \"0\"";
                    lbOn.ForeColor       = Color.Silver;
                    lbOff.ForeColor      = Color.White;
                    lbOnColor.BackColor  = Color.Black;
                    lbOffColor.BackColor = ent.BaseColor((int)ent.Values["ColorDown"]);
                }
            }
            else
            {
                lbPVCalc.Text = "------";
            }
            string alarms = (Reals.ContainsKey("Alarms")) ? Reals["Alarms"] : String.Empty;

            lbAlarmUp.BackColor   = (alarms.IndexOf("HA=") < 0) ? this.BackColor : Color.Red;
            lbAlarmDown.BackColor = (alarms.IndexOf("LA=") < 0) ? this.BackColor : Color.Red;
            lbPV.BackColor        = (Reals.ContainsKey("BackColor")) ?
                                    Color.FromArgb(int.Parse(Reals["BackColor"])) : Color.Black;
            lbPV.ForeColor = (Reals.ContainsKey("ForeColor")) ?
                             Color.FromArgb(int.Parse(Reals["ForeColor"])) : Color.White;
            bool quit = (Reals.ContainsKey("QuitAlarms")) ?
                        bool.Parse(Reals["QuitAlarms"]) : true;
            bool alarm = (Reals.ContainsKey("HasAlarms")) ?
                         bool.Parse(Reals["HasAlarms"]) : false;
            bool lostalarm = (Reals.ContainsKey("HasLostAlarms")) ?
                             bool.Parse(Reals["HasLostAlarms"]) : false;

            if (!quit && blink)
            {
                lbPV.BackColor = Color.Transparent;
                lbPV.ForeColor = Color.White;
                if (alarms.IndexOf("HA=True") < 0)
                {
                    lbAlarmUp.BackColor = Color.Transparent;
                }
                if (alarms.IndexOf("LA=True") < 0)
                {
                    lbAlarmDown.BackColor = Color.Transparent;
                }
            }
            if (Reals.ContainsKey("UserLevel"))
            {
                string      slevel = Reals["UserLevel"];
                UserLevel[] levels = (UserLevel[])UserLevel.GetValues(typeof(UserLevel));
                UserLevel   level  = UserLevel.Диспетчер;
                foreach (UserLevel item in levels)
                {
                    if (item.ToString().Equals(slevel))
                    {
                        level = item; break;
                    }
                }
                if (level >= UserLevel.Оператор)
                {
                    btnQuit.Enabled = !quit;
                }
                else
                {
                    btnQuit.Enabled = false;
                }
            }
            else
            {
                btnQuit.Enabled = false;
            }
            blink = !blink;
        }