Exemple #1
0
        private void Profiles_DatumInserted(IDataRow row)
        {
            if (InvokeRequired)
            {
                BeginInvoke(new Action <IDataRow>(Profiles_DatumInserted), row);
            }
            else
            {
                var profile = row as UserProfile;
                var strs    = new string[]
                {
                    profile.ID.ToString(),
                    profile.Name,
                    ProfilePrivileges.GetPrivilegeName(profile.Privilege),
                    m_profileStatusNames[(int)GetProfileStatus(profile)],
                    ProfileManagementMode.GetManagementModeName(
                        AppContext.ClientsManager.GetProfileManagementMode(profile.ID))
                };

                var lvi = new ListViewItem(strs)
                {
                    Tag = profile
                };

                m_lvData.Items.Add(lvi);
            }
        }
Exemple #2
0
        bool AddDatum(string name, ProfilePrivilege_t privilege)
        {
            var seq = from UserProfile p in m_ndxProfiles.Source.Enumerate()
                      where string.Compare(p.Name, name, true) == 0
                      select p;

            if (seq.Count() > 0)
            {
                var logger = new TextLogger(LogSeverity.Warning);
                logger.PutLine("Duplication de données détectée.");
                logger.PutLine(seq.Single().ToString());
                logger.Flush();

                MessageBox.Show("La validation de  données a échouée. " +
                                "Consultez le journal des événements pour plus d’informations.",
                                null,
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Warning);

                return(false);
            }

            var profile = new UserProfile(AppContext.TableManager.Profiles.CreateUniqID(), name, privilege);

            //ajouter gestion des profils
            var mgmntMode = new ProfileManagementMode(profile.ID);

            using (IDatumProvider dp = AppContext.TableManager.ProfileManagementMode.DataProvider)
            {
                dp.Connect();
                dp.Insert(mgmntMode);
            }

            //ajouer le profil
            m_ndxProfiles.Source.Insert(profile);


            return(true);
        }
Exemple #3
0
        private void ManagementMode_DatumReplaced(IDataRow row)
        {
            if (InvokeRequired)
            {
                Invoke(new Action <IDataRow>(ManagementMode_DatumReplaced), row);
            }
            else
            {
                var lvi = (from item in m_lvData.Items.AsEnumerable <ListViewItem>()
                           where (item.Tag as UserProfile).ID == row.ID
                           select item).Single();

                ManagementMode_t mode = (m_ndxerMgmntMode.Get(row.ID) as ProfileManagementMode).ManagementMode;

                if (lvi.Selected)
                {
                    m_tsbAutoManagement.Checked = mode == ManagementMode_t.Auto;
                }

                lvi.SubItems[m_colMgmntMode.Index].Text = ProfileManagementMode.GetManagementModeName(mode);
            }
        }
Exemple #4
0
        private void Profiles_DatumReplaced(IDataRow row)
        {
            if (InvokeRequired)
            {
                BeginInvoke(new Action <IDataRow>(Profiles_DatumReplaced), row);
            }
            else
            {
                var profile = row as UserProfile;

                //pas besoin de remplacer le mode gestion car la form du profil
                //ne le prend pas en charge

                for (int i = 0; i < m_lvData.Items.Count; ++i)
                {
                    if ((m_lvData.Items[i].Tag as UserProfile).ID == profile.ID)
                    {
                        var strs = new string[]
                        {
                            profile.ID.ToString(),
                            profile.Name,
                            ProfilePrivileges.GetPrivilegeName(profile.Privilege),
                            m_profileStatusNames[(int)GetProfileStatus(profile)],
                            ProfileManagementMode.GetManagementModeName(
                                AppContext.ClientsManager.GetProfileManagementMode(profile.ID))
                        };

                        var newItem = new ListViewItem(strs)
                        {
                            Tag = profile
                        };

                        m_lvData.Items[i] = newItem;
                        break;
                    }
                }
            }
        }
Exemple #5
0
        void LoadData()
        {
            Dbg.Assert(!InvokeRequired);

            m_lvData.Items.Clear();

            var seq = from UserProfile p in m_dpProfiles.Enumerate()
                      let strs = new[]
            {
                p.ID.ToString(),
                p.Name,
                ProfilePrivileges.GetPrivilegeName(p.Privilege),
                m_profileStatusNames[(int)GetProfileStatus(p)],
                ProfileManagementMode.GetManagementModeName(
                    AppContext.ClientsManager.GetProfileManagementMode(p.ID))
            }
            select new ListViewItem(strs)
            {
                Tag = p
            };

            m_lvData.Items.AddRange(seq.ToArray());
        }