예제 #1
0
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            PgM.PgTableBaseM table = (PgM.PgTableBaseM)value;
            if (table == null)
            {
                return(Visibility.Collapsed);
            }
            AbsM.ETableType tabletype = table.Type;
            String          par       = parameter.ToString();

            switch (par)
            {
            case "Структура":
            case "Свойства":
            {
                return(Visibility.Visible);
            }

            case "Группы":
            case "Подписи":
            case "Стили":
            {
                if (tabletype == AbsM.ETableType.MapLayer || tabletype == AbsM.ETableType.View)
                {
                    return(Visibility.Visible);
                }
                else
                {
                    return(Visibility.Collapsed);
                }
            }

            case "Права":
            {
                PgM.PgUserM user = (table.Source as PgVM.PgDataRepositoryVM).CurrentUser;
                if (user == null || user.Type == PgM.UserType.User)
                {
                    return(Visibility.Collapsed);
                }
                else
                {
                    return(Visibility.Visible);
                }
            }

            case "Индекс":
            {
                return(Visibility.Visible);
            }

            default:
            {
                return(Visibility.Collapsed);
            }
            }
        }
예제 #2
0
 public void CopyFrom(PgUserM user)
 {
     this.Source     = user.Source;
     this.ID         = user.ID;
     this.Pass       = user.Pass;
     this.PassSync   = user.PassSync;
     this.NameFull   = user.NameFull;
     this.Login      = user.Login;
     this.Otdel      = user.Otdel;
     this.WindowName = user.WindowName;
     this.Type       = user.Type;
     this.Extent     = user.Extent;
 }
예제 #3
0
 /// <summary>
 /// Сохранение атрибутов пользователя в базе
 /// </summary>
 public void Save(object parameter = null)
 {
     try
     {
         BindingProxy bindProxy = parameter as BindingProxy;
         PgUserM      pgUser    = bindProxy.Data as PgUserM;
         int          id        = Source.InsertUpdateUser(pgUser);
         if (pgUser.IsNewUser)
         {
             pgUser         = Source.Users.First(u => u.ID == id);
             bindProxy.Data = pgUser;
         }
     }
     catch (Exception ex)
     {
         Classes.workLogFile.writeLogFile(ex, true, true);
     }
 }
예제 #4
0
 public PgActionRightM(PgUserM user, PgDataRepositoryVM source)
 {
     User    = user;
     _source = source;
 }
예제 #5
0
 public PgUserM(PgUserM user, PgVM.PgDataRepositoryVM source)
 {
     CopyFrom(user);
     _source = source;
 }
예제 #6
0
        /// <summary>
        /// Можно ли сохранить пользователя
        /// </summary>
        public bool CanSave(object parameter = null)
        {
            BindingProxy bindProxy = parameter as BindingProxy;

            if (bindProxy.Data is PgUserM)
            {
                EvaluateError = null;
                PgUserM pgUser  = bindProxy.Data as PgUserM;
                bool    canSave = true;
                canSave &= !String.IsNullOrEmpty(pgUser.Login);
                canSave &= !String.IsNullOrEmpty(pgUser.NameFull);
                canSave &= !String.IsNullOrEmpty(pgUser.Otdel);
                canSave &= !String.IsNullOrEmpty(pgUser.WindowName);
                canSave &= (pgUser.Type != 0);
                if (!canSave)
                {
                    EvaluateError = "Введите обязательные поля";
                }

                bool ok = true;
                if (pgUser != null && pgUser.Login != null && pgUser.Login.Length > 0)
                {
                    if ((pgUser.Login[0] >= 'a' && pgUser.Login[0] <= 'z') || (pgUser.Login[0] == '_'))
                    {
                        for (int i = 1; i < pgUser.Login.Length; i++)
                        {
                            if (!((pgUser.Login[i] >= 'a' && pgUser.Login[i] <= 'z') ||
                                  (pgUser.Login[i] >= '0' && pgUser.Login[i] <= '9') ||
                                  pgUser.Login[i] == '_'))
                            {
                                ok = false;
                            }
                        }
                    }
                    else
                    {
                        ok = false;
                    }
                    if (!ok)
                    {
                        if (String.IsNullOrEmpty(EvaluateError))
                        {
                            EvaluateError = Rekod.Properties.Resources.LocUserLoginWarning;
                        }
                    }
                }
                else
                {
                    ok = false;
                }
                canSave &= ok;

                if (pgUser.IsNewUser && String.IsNullOrEmpty(pgUser.Pass))
                {
                    canSave &= false;
                    if (String.IsNullOrEmpty(EvaluateError))
                    {
                        EvaluateError = "Пароль не должен быть пустым";;
                    }
                }
                if (canSave)
                {
                    EvaluateError = null;
                }
                return(canSave);
            }
            else
            {
                EvaluateError = null;
                return(false);
            }
        }