Esempio n. 1
0
        /// <summary>
        /// Agrega un nuevo grupo
        /// </summary>
        /// <param name="pFileNode">Nodo que reprecenta el archivo ConfigurationManager.xml</param>
        /// <param name="pGroupName">Nombre de grupo</param>
        /// <param name="mnGroupOrProperty">Menu contextual espesifico para grupos o propiedades(keys)</param>
        internal static void AddGroup(TreeNode pFileNode,
                                      String pGroupName,
                                      ContextMenuStrip mnGroupOrProperty
                                      )
        {
            ListDictionary    dic = (ListDictionary)pFileNode.Tag;
            ConfigurationFile wConfigurationFile = (ConfigurationFile)dic["ConfigurationFile"];

            if (wConfigurationFile.Groups.Exists(g => g.Name.Equals(pGroupName, StringComparison.OrdinalIgnoreCase)))
            {
                FwkMessageView.Show("Already exist a group witch this name", "Duplicated group", MessageBoxButtons.OK, Fwk.Bases.FrontEnd.Controls.MessageBoxIcon.Warning);
                return;
            }


            TreeNode wtvGroupNode = new TreeNode(pGroupName);

            wtvGroupNode.ImageIndex         = pFileNode.TreeView.ImageList.Images.IndexOfKey("ShowAllCommentsHS.png");
            wtvGroupNode.SelectedImageIndex = pFileNode.TreeView.ImageList.Images.IndexOfKey("ShowAllCommentsHS.png");
            wtvGroupNode.ContextMenuStrip   = mnGroupOrProperty;
            Group wGroup = new Group();

            wGroup.Name      = pGroupName;
            wtvGroupNode.Tag = wGroup;
            ////Esto lo hace ConfigurationManager_CRUD
            //wConfigurationFile.Groups.Add(wGroup);
            pFileNode.Nodes.Add(wtvGroupNode);

            Fwk.Configuration.ConfigurationManager_CRUD.AddGroup(dic["provider"].ToString(), wGroup);
        }
Esempio n. 2
0
        private void btnLogOn_Click(object sender, EventArgs e)
        {
            // Prompt the user for name and password
            this.credentialsForm.Text = Properties.Resources.AuthenticateTitleMessage;
            DialogResult result = this.credentialsForm.ShowDialog();

            if (result == DialogResult.OK)
            {
                using (new WaitCursorHelper(this))
                {
                    _Authenticated = FwkMembership.ValidateUser(this.credentialsForm.Username, this.credentialsForm.Password, Membership.Provider.Name);

                    if (_Authenticated)
                    {
                        _Identity = new GenericIdentity(this.credentialsForm.Username, Membership.Provider.Name);

                        txtUserName.Text = _Identity.Name;



                        FwkMessageView.Show(string.Format(Properties.Resources.ValidCredentialsMessage, this.credentialsForm.Username),
                                            "ValidateUser",
                                            System.Windows.Forms.MessageBoxButtons.OK,
                                            Fwk.Bases.FrontEnd.Controls.MessageBoxIcon.Error);
                    }
                    else
                    {
                        FwkMessageView.Show(string.Format(Properties.Resources.InvalidCredentialsMessage, this.credentialsForm.Username), "ValidateUser",
                                            System.Windows.Forms.MessageBoxButtons.OK,
                                            Fwk.Bases.FrontEnd.Controls.MessageBoxIcon.Error);
                    }
                }
            }
        }
Esempio n. 3
0
        public static void CreateUser(string userName, string password)
        {
            try
            {
                //String app_name = Membership.Provider.ApplicationName;
                //MembershipUser wMembershipUser = Membership.GetUser(userName);

                Membership.CreateUser(userName, password);
            }
            catch (Exception ex)
            {
                FwkMessageView.Show(ex, "CreateUser", System.Windows.Forms.MessageBoxButtons.OK, Fwk.Bases.FrontEnd.Controls.MessageBoxIcon.Error);
            }
        }
Esempio n. 4
0
 private void btnCreateUser_Click(object sender, EventArgs e)
 {
     using (new WaitCursorHelper(this))
     {
         try
         {
             FwkMembership.CreateUser(_CurrentUser.LoginName, txtPassword.Text, String.Empty);
         }
         catch (Exception ex)
         {
             FwkMessageView.Show(ex, Properties.Resources.MessageBoxTitle, System.Windows.Forms.MessageBoxButtons.OK,
                                 Fwk.Bases.FrontEnd.Controls.MessageBoxIcon.Error);
         }
     }
     userByAppBindingSource.DataSource = FwkMembership.GetAllUsers(System.Web.Security.Membership.Provider.Name);
 }
Esempio n. 5
0
        /// <summary>
        /// Agrega una nueva Key
        /// </summary>
        /// <param name="pFileNode">Nodo que reprecenta el archivo ConfigurationManager.xml</param>
        /// <param name="pGroupName">Nombre de grupo</param>
        /// <param name="pKeyName">Nombre de la nueva Key</param>
        /// <param name="pKeyValue">Valor de la nueva Key</param>
        /// <param name="mnGroupOrProperty">Menu contextual espesifico para grupos o propiedades(keys)</param>
        public static void AddKey(TreeNode pFileNode,
                                  TreeNode pTreeNodeGroup,
                                  String pKeyName,
                                  String pKeyValue,
                                  Boolean pEncrypted,
                                  ContextMenuStrip mnGroupOrProperty
                                  )
        {
            #region Seleccion de Groups Node
            ListDictionary    dic = (ListDictionary)pFileNode.Tag;
            ConfigurationFile wConfigurationFile = (ConfigurationFile)dic["ConfigurationFile"];
            Group             wGroup             = (Group)pTreeNodeGroup.Tag;
            if (wGroup.Keys.Exists(k => k.Name.Equals(pKeyName, StringComparison.OrdinalIgnoreCase)))
            {
                FwkMessageView.Show("Already exist a propertie witch this name", " Duplicated propertie", MessageBoxButtons.OK, Fwk.Bases.FrontEnd.Controls.MessageBoxIcon.Warning);
                return;
            }


            #endregion

            #region Crea la Key a nivel del TreeView

            TreeNode wKeyTreeNode = new TreeNode(pKeyName);


            wKeyTreeNode.SelectedImageIndex = pFileNode.TreeView.ImageList.Images.IndexOfKey("PushpinHS.png");
            wKeyTreeNode.ImageIndex         = pFileNode.TreeView.ImageList.Images.IndexOfKey("UtilityText.ico");

            wKeyTreeNode.ContextMenuStrip = mnGroupOrProperty;

            Key wKey = new Key();
            wKey.Value.Text = pKeyValue;
            wKey.Name       = pKeyName;
            wKey.Encrypted  = pEncrypted;

            wKeyTreeNode.Tag = wKey;
            pTreeNodeGroup.Nodes.Add(wKeyTreeNode);

            //Esto lo hace ConfigurationManager_CRUD
            //wGroup.Keys.Add(wKey);

            Fwk.Configuration.ConfigurationManager_CRUD.AddProperty(dic["provider"].ToString(), wGroup.Name, wKey);

            #endregion
        }
Esempio n. 6
0
 public frmTest()
 {
     InitializeComponent();
     //System.Web.Security.SqlMembershipProvider wSqlMembershipProvider = new System.Web.Security.SqlMembershipProvider();
     //wSqlMembershipProvider.ApplicationName =
     using (new WaitCursorHelper(this))
     {
         try
         {
             userByAppBindingSource.DataSource = FwkMembership.GetAllUsers(System.Web.Security.Membership.Provider.Name);
             rolListBindingSource.DataSource   = FwkMembership.GetAllRoles(System.Web.Security.Membership.Provider.Name);
         }
         catch (Exception ex)
         {
             FwkMessageView.Show(ex, Properties.Resources.MessageBoxTitle, MessageBoxButtons.OK, Fwk.Bases.FrontEnd.Controls.MessageBoxIcon.Error);
         }
     }
 }
Esempio n. 7
0
        private void btnCreateNewRol_Click(object sender, EventArgs e)
        {
            using (new WaitCursorHelper(this))
            {
                try
                {
                    FwkMembership.CreateRole(txtRolName.Text, txtDescription.Text, frmAdmin.Provider.Name);

                    base.MessageViewInfo.Show(string.Format(Properties.Resources.RolCreatedMessage, txtRolName.Text));
                    Initialize();
                    NewSecurityInfoCreatedHandler();
                }
                catch (Exception ex)
                {
                    FwkMessageView.Show(ex, "Rol creation  ", System.Windows.Forms.MessageBoxButtons.OK, Fwk.Bases.FrontEnd.Controls.MessageBoxIcon.Error);
                }
            }
        }
Esempio n. 8
0
        public static List <UserByApp> GetAllUsers()
        {
            UserByApp        wUserByApp;
            List <UserByApp> wUsersList = new List <UserByApp>();

            try
            {
                foreach (MembershipUser wMembershipUser in Membership.GetAllUsers())
                {
                    wUserByApp = new UserByApp(wMembershipUser);
                    wUsersList.Add(wUserByApp);
                }
            }
            catch (Exception ex)
            {
                FwkMessageView.Show(ex, "MembershipUserCollection", System.Windows.Forms.MessageBoxButtons.OK, Fwk.Bases.FrontEnd.Controls.MessageBoxIcon.Error);
            }

            return(wUsersList);
        }
Esempio n. 9
0
        internal static void QuitFile(TreeNode node)
        {
            ListDictionary wDictionary = (ListDictionary)node.Tag;

            try
            {
                System.Configuration.Configuration configuration;
                ExeConfigurationFileMap            map = new ExeConfigurationFileMap();
                map.ExeConfigFilename = System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name + ".config";
                configuration         = ConfigurationManager.OpenMappedExeConfiguration(map, ConfigurationUserLevel.None);
                ConfigProviderElement prov = Fwk.Configuration.ConfigurationManager.ConfigProvider.GetProvider(wDictionary["provider"].ToString());

                Fwk.Configuration.ConfigurationManager.ConfigProvider.Providers.Remove(prov);

                configuration.Save(ConfigurationSaveMode.Minimal, true);
            }
            catch (Exception ex)
            {
                FwkMessageView.Show(ex, "Config manager", MessageBoxButtons.OK, Fwk.Bases.FrontEnd.Controls.MessageBoxIcon.Error);
            }
        }
Esempio n. 10
0
        public void m1()
        {
            try
            {
                //ICacheManager cc = CacheFactory.GetCacheManager("XCache2");

                //Authenticate the user and initialize the security cache
                //ISecurityCacheProvider secCache = SecurityCacheFactory.GetSecurityCacheProvider("ProveedorAlmacenCaching");
                // Cache the identity. The SecurityCache will generate and return a token.
                //IToken token = secCache.SaveIdentity(new GenericIdentity(Environment.UserName));
                //IToken token = secCache.SaveIdentity(new GenericIdentity("xxxx"));


                //// Retrieves the identity previoussecCachely saved by using the corresponding token.
                //IIdentity savedIdentity = secCache.GetIdentity(token);
            }
            catch (Exception ex)
            {
                FwkMessageView.Show(ex, "m1()", System.Windows.Forms.MessageBoxButtons.OK, Fwk.Bases.FrontEnd.Controls.MessageBoxIcon.Error);
            }
        }
Esempio n. 11
0
 private void button4_Click(object sender, EventArgs e)
 {
     FwkMessageView.Show("asdfasdf", "titulito", MessageBoxButtons.OK, MessageBoxIcon.Question);
 }
Esempio n. 12
0
        private static void LoadFile(TreeNode pConfigManagerTreeNode,
                                     ContextMenuStrip mnContextCnfgManFile, ContextMenuStrip mnContextCnfgManFile_Fail,
                                     ContextMenuStrip mnGroupOrProperty, ConfigProviderElement provider, bool isRefresh)
        {
            ConfigurationFile wConfigurationFile;
            ListDictionary    wDictionary = new ListDictionary();

            try
            {
                if (isRefresh)
                {
                    wConfigurationFile = Fwk.Configuration.ConfigurationManager.RefreshConfigurationFile(provider.Name);
                }
                else
                {
                    wConfigurationFile = Fwk.Configuration.ConfigurationManager.GetConfigurationFile(provider.Name);
                }
                //wConfigurationFile.FileName = System.IO.Path.GetFileName(wConfigurationFile.BaseConfigFile);


                #region [Set to FileNode]
                TreeNode wFileNode = new TreeNode(wConfigurationFile.FileName);

                wFileNode.ToolTipText = string.Concat("Proveedor tipo: ", provider.ConfigProviderType.ToString());;
                wDictionary.Add("FullFileName", wConfigurationFile.ProviderName);
                wDictionary.Add("ConfigurationFile", wConfigurationFile);
                wDictionary.Add("provider", provider.Name);

                wFileNode.Tag = wDictionary;
                wFileNode.ContextMenuStrip   = mnContextCnfgManFile;
                wFileNode.ImageIndex         = pConfigManagerTreeNode.TreeView.ImageList.Images.IndexOfKey("inifile.ico");
                wFileNode.SelectedImageIndex = pConfigManagerTreeNode.TreeView.ImageList.Images.IndexOfKey("inifile.ico");

                #region Agrego todos los grupos

                LoadGroupFromFile(pConfigManagerTreeNode, wFileNode, wConfigurationFile.Groups, mnGroupOrProperty);

                #endregion

                #endregion

                //Si todo funciono buien agrego el nodo
                pConfigManagerTreeNode.Nodes.Add(wFileNode);
            }
            catch (InvalidOperationException er)
            {
                TechnicalException te = new Fwk.Exceptions.TechnicalException("It's not valid configuration manager file", er);
                FwkMessageView.Show(te, "Config manager", MessageBoxButtons.OK, Fwk.Bases.FrontEnd.Controls.MessageBoxIcon.Error);
            }
            catch (TechnicalException er1)
            {
                if (er1.ErrorId.Equals("8011") || er1.ErrorId.Equals("8200") || er1.ErrorId.Equals("8012"))
                {
                    TreeNode wFileNode = new TreeNode(provider.BaseConfigFile);

                    wFileNode.ContextMenuStrip = mnContextCnfgManFile_Fail;
                    wFileNode.ToolTipText      = Fwk.Exceptions.ExceptionHelper.GetAllMessageException(er1);
                    wDictionary.Add("FullFileName", provider.BaseConfigFile);
                    wDictionary.Add("ConfigurationFile", null);
                    wDictionary.Add("provider", provider.Name);

                    wFileNode.Tag = wDictionary;
                    //wFileNode.ContextMenuStrip = mnContextCnfgManFile;
                    wFileNode.ImageIndex         = pConfigManagerTreeNode.TreeView.ImageList.Images.IndexOfKey("alert.png");
                    wFileNode.SelectedImageIndex = pConfigManagerTreeNode.TreeView.ImageList.Images.IndexOfKey("alert.png");
                    pConfigManagerTreeNode.Nodes.Add(wFileNode);
                }
                else
                {
                    FwkMessageView.Show(er1, "Config manager", MessageBoxButtons.OK, Fwk.Bases.FrontEnd.Controls.MessageBoxIcon.Error);
                }
            }
        }