Ejemplo n.º 1
0
        internal SqlBrowserTreeView(ConnectionCollection connCol)
            : this()
        {
            this.BeginUpdate();
            try
            {
                RainstormStudios.Collections.StringCollection colDatasource = new StringCollection();
                for (int i = 0; i < connCol.Count; i++)
                {
                    colDatasource.AddUnique(rsData.GetDataSource(connCol[i].ConnectionString), i.ToString());
                }

                for (int i = 0; i < colDatasource.Count; i++)
                {
                    Connection cn = connCol[int.Parse(colDatasource.GetKey(i))];
                    if (rsDb.IsSQL(cn.ConnectionString, cn.DatabaseProvider))
                    {
                        TreeNode ndDb = new TreeNode(colDatasource[i]);
                        ndDb.Tag = new rsDbSql(cn.ConnectionString);
                        //ndDb.Name = cn.Name + "-" + cn.DatabaseProvider.ToString();
                        ndDb.Name = colDatasource[i];
                        ndDb.Nodes.Add("<EMPTY>");
                        ndDb.ImageIndex         = 1;
                        ndDb.SelectedImageIndex = 1;
                        ndDb.ContextMenuStrip   = this.mnuNdGroup;
                        this.Nodes.Add(ndDb);
                    }
                }
            }
            catch (Exception ex)
            {
                this.Nodes.Clear();
                this.Nodes.Add("An Error Occured:");
                this.Nodes.Add(ex.Message);
            }
            finally
            {
                this.EndUpdate();
            }
        }
        public override MembershipUserCollection FindUsersByName(string usernameToMatch, int pageIndex, int pageSize, out int totalRecords)
        {
            MembershipUserCollection users = new MembershipUserCollection();
            try
            {
                using (DataSet ds = this.OpenXml())
                {
                    DataRow[] dr = this.SearchByFieldValue(ds, "Users", "Username", usernameToMatch, pageIndex, pageSize);
                    StringCollection usrNms = new StringCollection();
                    for (int i = 0; i < dr.Length; i++)
                        usrNms.Add(dr[i]["LoweredUserName"].ToString(), i.ToString());
                    usrNms.Sort(Collections.SortDirection.Ascending);
                    for (int i = 0; i < usrNms.Count; i++)
                    {
                        DataRow drUsr = dr[int.Parse(usrNms.GetKey(i))];
                        users.Add(this.PopulateMembershipUser(drUsr, this.GetMembershipEntry(drUsr["UserId"], ds)));
                    }
                    //for (int i = 0; i < dr.Length; i++)
                    //    users.Add(this.PopulateMembershipUser(dr[i], this.GetMembershipEntry(dr[i]["UserId"], ds)));
                    totalRecords = ds.Tables["Users"].Rows.Count;
                }
            }
            catch
            { throw; }

            return users;
        }
 public override MembershipUserCollection GetAllUsers(int pageIndex, int pageSize, out int totalRecords)
 {
     try
     {
         MembershipUserCollection users = new MembershipUserCollection();
         using (DataSet ds = this.OpenXml())
         {
             StringCollection usrNms = new StringCollection();
             for (int i = 0; i < ds.Tables["Users"].Rows.Count; i++)
                 usrNms.Add(ds.Tables["Users"].Rows[i]["LoweredUserName"].ToString(), i.ToString());
             usrNms.Sort(Collections.SortDirection.Ascending);
             for (int i = 0; i < usrNms.Count; i++)
             {
                 DataRow drUsr = ds.Tables["Users"].Rows[int.Parse(usrNms.GetKey(i))];
                 users.Add(this.PopulateMembershipUser(drUsr, this.GetMembershipEntry(drUsr["UserId"], ds)));
             }
             //for (int i = 0; i < ds.Tables["Users"].Rows.Count; i++)
             //    users.Add(this.PopulateMembershipUser(ds.Tables["Users"].Rows[i], this.GetMembershipEntry(ds.Tables["Users"].Rows[i]["UserId"], ds)));
             totalRecords = ds.Tables["Users"].Rows.Count;
         }
         return users;
     }
     catch
     { throw; }
 }