Esempio n. 1
0
        public void Concurrency_AddRemoveSearshByName_OkAndNoExceptions()
        {
            UserCollection <int, int, int> c = new UserCollection <int, int, int>();

            Parallel.For(0, 1000, (i) =>
            {
                try
                {
                    Tuple <int, int> k1 = new Tuple <int, int>(-1, i);
                    Tuple <int, int> k2 = new Tuple <int, int>(-2, i);
                    c.Add(k1, i);
                    c.Add(k2, i);
                    var d = c.SearchByName(i);
                    Assert.AreEqual(2, d.Count);
                    Assert.IsTrue(c.Remove(k1));
                    Assert.IsTrue(c.Remove(k2));
                    Assert.IsFalse(c.ContainsKey(k1));
                    Assert.IsFalse(c.ContainsKey(k2));
                }
                catch (Exception e)
                {
                    Assert.Fail(e.Message);
                }
            });
            Assert.AreEqual(0, c.Count);
        }
Esempio n. 2
0
        public void Add_AddingByNullKeyParts_ThrowsException()
        {
            UserCollection <UserType, string, string> c = new UserCollection <UserType, string, string>();
            bool hasException1 = false, hasException2 = false;

            try
            {
                c.Add(new Key(new UserType(1, null), "Mike"), "Superman");
            }
            catch (Exception e)
            {
                hasException1 = true;
            }
            try
            {
                c.Add(new Key(new UserType(1, "xyz"), null), "Superman");
            }
            catch (Exception e)
            {
                hasException2 = true;
            }

            Assert.IsTrue(hasException1);
            Assert.IsTrue(hasException2);
        }
Esempio n. 3
0
        public void Remove_Adding3Remove1_Expected2AndNoElement()
        {
            UserCollection <UserType, string, string> c = new UserCollection <UserType, string, string>();
            Key k = new Key(new UserType(3, "a"), "Mike");

            c.Add(new Key(new UserType(1, "a"), "Mike"), "Employee");
            c.Add(new Key(new UserType(2, "a"), "Mike"), "Employee");
            c.Add(k, "Employee");
            c.Remove(k);

            Assert.AreEqual(2, c.Count);
            Assert.IsFalse(c.ContainsKey(k));
        }
Esempio n. 4
0
        public UserCollection GetUnSignedUsers(BPMConnection cn, BPMObjectNameCollection accounts)
        {
            BPMObjectNameCollection accountsUnSigned = new BPMObjectNameCollection();

            accountsUnSigned.AddRange(accounts);

            foreach (Footmark footmark in this)
            {
                if (accountsUnSigned.Contains(footmark.Account))
                {
                    accountsUnSigned.Remove(footmark.Account);
                }
            }

            UserCollection users = new UserCollection();

            foreach (string account in accountsUnSigned)
            {
                if (users.Contains(account))
                {
                    continue;
                }

                User user = User.TryGetUser(cn, account);
                if (user != null)
                {
                    users.Add(user);
                }
            }

            return(users);
        }
Esempio n. 5
0
 void _userOperationVM_OnSaved(object sender, User e)
 {
     UserCollection.Remove(e);
     UserCollection.Add(e);
     _hardwareOperationVM_OnClosed(sender, new EventArgs {
     });
 }
Esempio n. 6
0
 public void UpdateU()
 {
     try
     {
         UserCollection.Clear();
         string     sql     = "SELECT Username, Password, Email FROM tblUser WHERE Username != @admin";
         SqlCommand command = new SqlCommand(sql, sqlCon);
         command.Parameters.AddWithValue("@admin", "admin");
         sqlCon.Open();
         SqlDataReader reader = command.ExecuteReader();
         while (reader.Read())
         {
             User user = new User();
             user.Username = reader.GetString(0);
             user.Password = reader.GetString(1);
             user.Email    = reader.GetString(2);
             UserCollection.Add(user);
         }
         reader.Close();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
     finally
     {
         if (sqlCon != null)
         {
             sqlCon.Close();
         }
     }
 }
Esempio n. 7
0
        public void SendChannelMessage(string msg, ClientSocket sender)
        {
            MinecraftHandler mc        = Tunnel.MinecraftHandler;
            char             colorCode = mc.Config.ServerBroadcastColorChar;
            List <Channel>   channels  = Channels.FindAll(x => x.User.IsInlist(sender.Name));
            UserCollection   users     = new UserCollection();

            foreach (Channel c in channels)
            {
                foreach (User u in c.User)
                {
                    if (mc.IsStringInList(u.Name, mc.Player))
                    {
                        if (!users.IsInlist(u))
                        {
                            users.Add(u);
                        }
                    }
                }
            }

            foreach (User player in users)
            {
                ClientSocket client = (ClientSocket)FindPlayer(player.Name);
                if (client != null)
                {
                    String message = string.Concat(new object[] { "§" + colorCode, msg });
                    foreach (var item in CreateList(message, 119))
                    {
                        client.SendPacket(3, ByteArythmetic.StoA(item));
                    }
                }
            }
        }
Esempio n. 8
0
        public void OnUserSubmitButtonClicked(object sender, RoutedEventArgs e)
        {
            UserCollection.Add(new User(view.usernameTextBox.Text, view.emailTextBox.Text));

            view.usernameTextBox.Text = "";
            view.emailTextBox.Text    = "";
        }
Esempio n. 9
0
        public UserCollection GetAllUsersDynamicCollection(string where, string orderBy)
        {
            IDBManager     dbm = new DBManager();
            UserCollection col = new UserCollection();

            try
            {
                dbm.CreateParameters(2);
                dbm.AddParameters(0, "@WhereCondition", where);
                dbm.AddParameters(1, "@OrderByExpression", orderBy);
                IDataReader reader = dbm.ExecuteReader(CommandType.StoredProcedure, "SelectUsersDynamic");
                while (reader.Read())
                {
                    User user = new User();
                    user.ID         = Int32.Parse(reader["ID"].ToString());
                    user.EmployeeID = Int32.Parse(reader["EmployeeID"].ToString());
                    user.UserName   = reader["UserName"].ToString();
                    user.Password   = reader["Password"].ToString();
                    col.Add(user);
                }
            }
            catch (Exception ex)
            {
                log.Write(ex.Message, "GetAllUsersDynamicCollection");
            }
            finally
            {
                dbm.Dispose();
            }
            return(col);
        }
Esempio n. 10
0
        public UserCollection SearchUser(string partialUsername)
        {
            if (skype.Friends.Count <= 0)
            {
                return(null);
            }

            UserCollection friends = new UserCollection();

            try
            {
                foreach (User friend in skype.Friends)
                {
                    if (friend.Handle.Contains(partialUsername))
                    {
                        friends.Add(friend);
                    }
                }
            }
            catch
            {
                return(null);
            }

            return(friends);
        }
Esempio n. 11
0
        public virtual UserCollection GetGroupUsers(HttpContext context)
        {
            YZRequest request = new YZRequest(context);
            int       groupid = request.GetInt32("groupid");

            Group.MemberCollection members;
            using (IYZDbProvider provider = YZDbProviderManager.DefaultProvider)
            {
                using (IDbConnection cn = provider.OpenConnection())
                {
                    members = GroupManager.GetGroupMembers(provider, cn, groupid);
                }
            }

            UserCollection users = new UserCollection();

            using (BPMConnection cn = new BPMConnection())
            {
                cn.WebOpen();

                foreach (Group.Member member in members)
                {
                    User user = User.TryGetUser(cn, member.UID);
                    if (user != null)
                    {
                        users.Add(user);
                    }
                }
            }

            return(users);
        }
Esempio n. 12
0
        public virtual JObject Public(HttpContext context)
        {
            YZRequest request = new YZRequest(context);

            this.ApproveCheck(context);

            int     taskid   = request.GetInt32("TaskID");
            JObject jPost    = request.GetPostData <JObject>();
            string  comments = (string)jPost["comments"];
            BPMObjectNameCollection accounts = jPost["uids"].ToObject <BPMObjectNameCollection>();

            UserCollection users = new UserCollection();

            using (BPMConnection cn = new BPMConnection())
            {
                cn.WebOpen();

                foreach (string account in accounts)
                {
                    User user = BPMTask.Public(cn, taskid, account);
                    users.Add(user);
                }

                JObject rv = new JObject();
                rv[YZJsonProperty.success] = true;
                rv["UserNameList"]         = YZStringHelper.GetUserNameListString(users);

                return(rv);
            }
        }
Esempio n. 13
0
        public override CommandResult Execute(String chan, String pw, String arg3, String arg4)
        {
            if (!String.IsNullOrEmpty(chan))
            {
                Channel channel = EasyGuess.GetMatchedChannel(((ServerSocket)Server).Channels, chan);
                if (channel != null)
                {
                    String         str         = "";
                    UserCollection usersOnline = new UserCollection();

                    foreach (User u in channel.User)
                    {
                        if (MinecraftHandler.IsStringInList(u.Name, MinecraftHandler.Player))
                        {
                            usersOnline.Add(u);
                        }
                    }

                    Server.SendExecuteResponse(TriggerPlayer, String.Format("Users in channel {0} ({1}): ", chan, usersOnline.Count));


                    foreach (User u in usersOnline)
                    {
                        str += u.Name + ", ";
                    }
                    if (!String.IsNullOrEmpty(str))
                    {
                        Server.SendExecuteResponse(TriggerPlayer, String.Format("{0}", str));
                    }
                    return(new CommandResult(true, String.Format("{0} executed cinfo", TriggerPlayer)));
                }
                return(new CommandResult(true, String.Format("Channel not found"), true));
            }
            else
            {
                List <Channel> channels = ((ServerSocket)Server).Channels.FindAll(x => x.User.IsInlist(TriggerPlayer));


                Server.SendExecuteResponse(TriggerPlayer, String.Format("You're in the following channels: "));
                String str = "";
                foreach (Channel c in channels)
                {
                    UserCollection usersOnline = new UserCollection();
                    foreach (User u in c.User)
                    {
                        if (MinecraftHandler.IsStringInList(u.Name, MinecraftHandler.Player))
                        {
                            usersOnline.Add(u);
                        }
                    }

                    str += String.Format("{0} ({1}), ", c.Name, usersOnline.Count);
                }
                if (!String.IsNullOrEmpty(str))
                {
                    Server.SendExecuteResponse(TriggerPlayer, String.Format("{0}", str));
                }
                return(new CommandResult(true, String.Format("{0} executed cinfo", TriggerPlayer)));
            }
        }
Esempio n. 14
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="roleName"></param>
        /// <returns></returns>
        public UserCollection GetUsersInRole(int roleID)
        {
            UserCollection collection = new UserCollection();

            collection.Clear();
            try
            {
                // Create SQL parameters
                SqlParameter prmRoleID = new SqlParameter("@RoleID", SqlDbType.Int, 4);
                prmRoleID.Direction = ParameterDirection.Input;
                prmRoleID.Value     = roleID;

                // Execute procedure to update role
                using (IDataReader dr = Database.ExecuteReader("UspGetUsersInRole", CommandType.StoredProcedure, prmRoleID))
                {
                    while (dr.Read())
                    {
                        User user = Populate(dr);

                        collection.Add(user);
                    }
                }

                return(collection);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 15
0
        public static bool Save(User user)
        {
            if (user.Id < 0)
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    // Insert new user
                    bool userInserted = repo.Insert(user);

                    // Insert settings for the user
                    bool settingsInserted = settingsRepo.Insert(user);

                    // Complete transaction
                    if (userInserted && settingsInserted)
                    {
                        ts.Complete();

                        users.Add(user);
                        return(true);
                    }
                    else
                    {
                        // Do nothing
                        // Transaction will be rolled back.
                    }
                }
            }
            else
            {
                return(repo.Update(user));
            }

            return(false);
        }
Esempio n. 16
0
        public UserCollection GetAllUsersCollection()
        {
            IDBManager     dbm = new DBManager();
            UserCollection col = new UserCollection();

            try
            {
                IDataReader reader = dbm.ExecuteReader(CommandType.StoredProcedure, "SelectUsersAll");
                while (reader.Read())
                {
                    User user = new User();
                    user.ID         = Int32.Parse(reader["ID"].ToString());
                    user.EmployeeID = Int32.Parse(reader["EmployeeID"].ToString());
                    user.UserName   = reader["UserName"].ToString();
                    user.Password   = reader["Password"].ToString();
                    col.Add(user);
                }
            }
            catch (Exception ex)
            {
                log.Write(ex.Message, "GetAllUsersCollection");
                throw (ex);
            }
            finally
            {
                dbm.Dispose();
            }
            return(col);
        }
Esempio n. 17
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public UserCollection FindUsersByUserName(string userName)
        {
            try
            {
                UserCollection collection = new UserCollection();

                collection.Clear();
                // create sql parameters
                SqlParameter prmUserName = new SqlParameter("@UserName", SqlDbType.VarChar, 128);
                prmUserName.Direction = ParameterDirection.Input;
                prmUserName.Value     = userName;

                // Execute procedure
                using (IDataReader dr = Database.ExecuteReader("UspFindUserByUserName", CommandType.StoredProcedure, prmUserName))
                {
                    while (dr.Read())
                    {
                        User user = Populate(dr);
                        collection.Add(user);
                    }
                }

                return(collection);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 18
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public UserCollection GetAllUsers()
        {
            try
            {
                UserCollection collection = new UserCollection();

                collection.Clear();

                // Execute procedure
                using (IDataReader dr = Database.ExecuteReader("UspGetAllUsers", CommandType.StoredProcedure))
                {
                    while (dr.Read())
                    {
                        User user = Populate(dr);

                        collection.Add(user);
                    }
                }

                return(collection);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 19
0
        public void Add_AddingEquelKeysElements_ThrowsException()
        {
            UserCollection <UserType, string, string> c = new UserCollection <UserType, string, string>();
            bool hasException = false;

            c.Add(new Key(new UserType(1, "xyz"), "Mike"), "Employee");
            try
            {
                c.Add(new Key(new UserType(1, "xyz"), "Mike"), "Superman");
            }
            catch (ArgumentOutOfRangeException e)
            {
                hasException = true;
            }

            Assert.IsTrue(hasException);
        }
Esempio n. 20
0
 private void LoadCollectionFromCache()
 {
     foreach (BoardGameDataItem game in BoardGameStorage.CollectionGames)
     {
         UserCollection.Add(game);
     }
     UpdateCollectionForHub();
 }
Esempio n. 21
0
        public void AddUser_AddsToCollection()
        {
            var users = new UserCollection();

            users.Add(new User());

            Assert.AreEqual(1, users.Count);
        }
Esempio n. 22
0
        public override CommandResult Execute(String chan,String pw, String arg3, String arg4)
        {
            if (!String.IsNullOrEmpty(chan))
            {
                Channel channel = EasyGuess.GetMatchedChannel(((ServerSocket)Server).Channels, chan);
                if (channel != null)
                {
                    String str = "";
                    UserCollection usersOnline = new UserCollection();

                    foreach (User u in channel.User)
                    {
                        if (MinecraftHandler.IsStringInList(u.Name, MinecraftHandler.Player))
                        {
                            usersOnline.Add(u);
                        }
                    }

                    Server.SendExecuteResponse(TriggerPlayer, String.Format("Users in channel {0} ({1}): ", chan, usersOnline.Count));

                    foreach (User u in usersOnline)
                    {
                        str += u.Name + ", ";
                    }
                    if (!String.IsNullOrEmpty(str))
                    {
                        Server.SendExecuteResponse(TriggerPlayer, String.Format("{0}", str));
                    }
                    return new CommandResult(true, String.Format("{0} executed cinfo",TriggerPlayer));
                }
                return new CommandResult(true, String.Format("Channel not found"), true);
            }
            else
            {
                List<Channel> channels = ((ServerSocket)Server).Channels.FindAll(x => x.User.IsInlist(TriggerPlayer));

                Server.SendExecuteResponse(TriggerPlayer, String.Format("You're in the following channels: "));
                String str = "";
                foreach (Channel c in channels)
                {
                    UserCollection usersOnline = new UserCollection();
                    foreach (User u in c.User)
                    {
                        if (MinecraftHandler.IsStringInList(u.Name, MinecraftHandler.Player))
                        {
                            usersOnline.Add(u);
                        }
                    }

                    str += String.Format("{0} ({1}), ", c.Name, usersOnline.Count);
                }
                if (!String.IsNullOrEmpty(str))
                {
                    Server.SendExecuteResponse(TriggerPlayer, String.Format("{0}", str));
                }
                return new CommandResult(true, String.Format("{0} executed cinfo", TriggerPlayer));
            }
        }
        /// <summary>
        /// Imports the new SiteUsers to the target SharePoint.
        /// </summary>
        /// <exception cref="ElementsMigrationException">If the migration fails</exception>
        private void ImportNewUsers()
        {
            Console.WriteLine("import new Users...");
            Logger.AddMessage("import new Users...");
            UserCollection sourceUserCollection = this.GetAllUser(SourceClientContext);
            UserCollection targetUserCollection = this.GetAllUser(TargetClientContext);

            HashSet <string> targetUserNames = targetUserCollection.GetAllLoginNames();

            foreach (var sourceUser in sourceUserCollection)
            {
                if (!targetUserNames.Contains(sourceUser.LoginName))
                {
                    Console.WriteLine("Import user '{0}'", sourceUser.LoginName);
                    Logger.AddMessage("import User '" + sourceUser.LoginName + "'");

                    UserCreationInformation creationObject = new UserCreationInformation();
                    creationObject.Email     = sourceUser.Email;
                    creationObject.LoginName = sourceUser.LoginName;
                    creationObject.Title     = sourceUser.Title;

                    User targetUser = targetUserCollection.Add(creationObject);

                    try
                    {
                        targetUser.IsSiteAdmin = sourceUser.IsSiteAdmin;
                    }
                    catch (PropertyOrFieldNotInitializedException)
                    {
                    }

                    try
                    {
                        targetUser.Tag = sourceUser.Tag;
                    }
                    catch (PropertyOrFieldNotInitializedException)
                    {
                    }
                }
                else
                {
                    Console.WriteLine("user '{0}' is already on target server. nothing to import.", sourceUser.LoginName);
                    Logger.AddMessage("don't have to import user '" + sourceUser.LoginName + "'");
                }
            }

            try
            {
                TargetClientContext.ExecuteQuery();
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception during importing the SiteUsers.", e);
                Logger.AddMessage("Exception during importing the Users. Error = " + e.Message);
                throw new ElementsMigrationException("Exception during importing the SiteUsers.", e);
            }
        }
Esempio n. 24
0
        public void ClearAndContainssKey_Adding2Remove1_ExpectedNothing()
        {
            UserCollection <UserType, string, string> c = new UserCollection <UserType, string, string>();
            Key k1 = new Key(new UserType(1, "a"), "Mike");
            Key k2 = new Key(new UserType(2, "b"), "Mike");
            Key k3 = new Key(new UserType(2, "b"), "Jane");

            c.Add(k1, "Employee");
            c.Add(k2, "Manager");
            c.Add(k3, "Looser");

            c.Clear();

            Assert.AreEqual(0, c.Count);
            Assert.IsFalse(c.ContainsKey(k1));
            Assert.IsFalse(c.ContainsKey(k2));
            Assert.IsFalse(c.ContainsKey(k3));
        }
Esempio n. 25
0
 public void Login(string connectionId)
 {
     if (!users.Where(user => user.ClientId == connectionId).Any())
     {
         User thisUser = new User();
         thisUser.ClientId = connectionId;
         users.Add(thisUser);
     }
 }
Esempio n. 26
0
        /// <summary>
        /// 根据动态参数查询用户
        /// </summary>
        /// <param name="strFields"></param>
        /// <param name="strValues"></param>
        /// <returns></returns>
        public static UserCollection GetUser(List <QueryElement> list)
        {
            StringBuilder  sb   = new StringBuilder();
            UserCollection coll = new UserCollection();

            sb.AppendFormat("{0} ", "select * from user where 1=1");
            if (list.Count > 0)
            {
                MySqlParameter[] pars = new MySqlParameter[list.Count];
                for (int i = 0; i < list.Count; i++)
                {
                    QueryElement query = list[i];

                    sb.AppendFormat("{0} {1} {2} @{3} ", query.QueryLogic, query.Queryname, query.QueryOperation, query.Queryname);
                    pars[i] = new MySqlParameter("@" + query.Queryname, query.QueryElementType);
                    if (query.QueryOperation.Equals("like"))
                    {
                        pars[i].Value = "%" + query.Queryvalue + "%";
                    }
                    else
                    {
                        pars[i].Value = query.Queryvalue;
                    }
                }
                using (MySqlDataReader reader = MySqlDBHelper.GetReader(sb.ToString(), pars))
                {
                    while (reader.Read())
                    {
                        coll.Add(new UserInfo(reader));
                    }
                }
            }
            else
            {
                using (MySqlDataReader reader = MySqlDBHelper.GetReader(sb.ToString()))
                {
                    while (reader.Read())
                    {
                        coll.Add(new UserInfo(reader));
                    }
                }
            }
            return(coll);
        }
Esempio n. 27
0
        public static UserCollection GetUsers(List <int> userIDs)
        {
            UserCollection users = new UserCollection();

            foreach (int id in userIDs)
            {
                users.Add(GetUser(id));
            }
            return(users);
        }
Esempio n. 28
0
        public void ValuesByName_Adding3AndSearch_Ok()
        {
            UserCollection <UserType, string, string> c = new UserCollection <UserType, string, string>();
            Key k1 = new Key(new UserType(1, "a"), "Mike");
            Key k2 = new Key(new UserType(2, "b"), "Mike");
            Key k3 = new Key(new UserType(2, "b"), "Jane");

            c.Add(k1, "Employee");
            c.Add(k2, "Manager");
            c.Add(k3, "Looser");

            var d1 = c.SearchByName("Jane");
            var d2 = c.SearchByName("Mike");

            Assert.AreEqual(1, d1.Count);
            Assert.AreEqual(2, d2.Count);
            Assert.AreEqual("Employee", d2[new UserType(1, "a")]);
            Assert.AreEqual("Manager", d2[new UserType(2, "b")]);
            Assert.AreEqual("Looser", d1[new UserType(2, "b")]);
        }
Esempio n. 29
0
        private async void LoadUsers()
        {
            var users = await _userDataService.GetUsersAsync();

            UserCollection.Clear();
            foreach (var item in users)
            {
                UserCollection.Add(item);
            }
            RaisePropertyChanged(() => UserCollection);
        }
        public void DoNotDuplicateUserWhenCallingGetUser()
        {
            var collection = new UserCollection();
            var user       = new User("Test");

            collection.Add(user);
            var user2 = collection.GetUser("Test");

            Assert.Single(collection);
            Assert.Same(user, user2);
        }
Esempio n. 31
0
 public void Should_send_message_to_group()
 {
     var oSkype = new Skype();
     if (oSkype.Client.IsRunning == false)
     {
         oSkype.Client.Start(false, true);
     }
     UserCollection users = oSkype.Friends;
     foreach (User f in users)
     {
         Console.WriteLine(f.DisplayName + "|" + f.FullName + "|" + f.Handle);
     }
     //var msg = oSkype.SendMessage("testgogroups", "some text...");
     var om = new UserCollection();
     om.Add(oSkype.get_User("testgogroups"));
     om.Add(oSkype.get_User("jonny.plankton"));
     var oc = oSkype.CreateChatMultiple(om);
     oc.OpenWindow();
     //oc.Topic = "Build is broken";
     oc.SendMessage("Build is broken");
     oc.Leave();
 }
Esempio n. 32
0
File: User.cs Progetto: mudasar/scco
        internal static UserCollection CollectAll()
        {
            var dataTable  = DatabaseController.ExecuteSelectQuery("SELECT * FROM " + TABLE_NAME);
            var collection = new UserCollection();

            foreach (DataRow dataRow in dataTable.Rows)
            {
                var item = new User();
                item.SetPropertiesFromDataRow(dataRow);
                collection.Add(item);
            }
            return(collection);
        }
Esempio n. 33
0
 public static UserCollection GetUsers(List<int> userIDs)
 {
     UserCollection users = new UserCollection();
     foreach (int id in userIDs) {
         users.Add(GetUser(id));
     }
     return users;
 }
Esempio n. 34
0
        public UserCollection SearchUser(string partialUsername)
        {
            
            if( skype.Friends.Count <= 0)
                return null;

            UserCollection friends = new UserCollection();

            try
            {
                foreach (User friend in skype.Friends)
                {
                    if (friend.Handle.Contains(partialUsername))
                        friends.Add(friend);
                }
            }
            catch
            {
                return null;
            }
            
            return friends;

        }
Esempio n. 35
0
        public override UserCollection GetUserShows(int userID, int pageNumber, int pageSize, out Dictionary<int, int> points, out Dictionary<int, string> contents)
        {
            using (SqlQuery query = new SqlQuery())
            {
                query.Pager.TableName = "bx_PointShowUsers";
                query.Pager.SortField = "[Price]";
                query.Pager.IsDesc = true;
                query.Pager.PageNumber = pageNumber;
                query.Pager.PageSize = pageSize;
                query.Pager.SelectCount = true;
                query.Pager.PrimaryKey = "[UserID]";

                using (XSqlDataReader reader = query.ExecuteReader())
                {
                    UserCollection users = new UserCollection();
                    points = new Dictionary<int, int>();
                    contents = new Dictionary<int, string>();
                    while (reader.Read())
                    {
                        User user = new User(reader);
                        users.Add(user);
                        points.Add(user.UserID, reader.Get<int>("Price"));
                        contents.Add(user.UserID, reader.Get<string>("Content"));
                    }

                    if (reader.NextResult())
                    {
                        while (reader.Read())
                        {
                            users.TotalRecords = reader.Get<int>(0);
                        }
                    }
                    return users;
                }

            }
        }
Esempio n. 36
0
        ///// <summary>
        ///// 查询一条用户记录.
        ///// </summary>
        ///// <param name="userName">用户名</param>
        ///// <returns>User 模型</returns>
        //public User GetSingleUser(string userName)
        //{
        //    string sql = "SELECT * FROM [T_Users] WHERE UserName=@UserName";
        //    OleDbParameter[] parms = {new OleDbParameter("@UserName",OleDbType.VarChar,50)};
        //    parms[0].Value = userName;
        //    DataTable table = DbHelper.ExecuteDataTable(sql, parms);
        //    User tUser = null;
        //    if (table.Rows.Count > 0)
        //    {
        //        tUser = new User();
        //        tUser.UID = Convert.ToInt32(table.Rows[0]["UID"]);
        //        tUser.UserName = table.Rows[0]["UserName"].ToString();
        //        tUser.Pwd = table.Rows[0]["Pwd"].ToString();
        //        tUser.JoinDate = Convert.ToDateTime(table.Rows[0]["JoinDate"]);
        //        tUser.Login_IP = table.Rows[0]["Login_IP"].ToString();
        //        tUser.Login_Date = Convert.ToDateTime(table.Rows[0]["Login_Date"]);
        //    }
        //    return tUser;
        //}
        /// <summary>
        /// 查询用户 所有用户
        /// </summary>
        /// <returns>UserCollection 包含所有记录.</returns>
        public static UserCollection GetList()
        {
            UserCollection list = new UserCollection();
            string sql = "select * from T_Users";
            MySqlDataReader reader = DbHelper.ExecuteDataReader(sql);
            if (reader.HasRows)
            {
                list = new UserCollection();
                while (reader.Read())
                {
                    list.Add(FillDataRecord(reader));
                }
            }
            reader.Close();

            return list;
        }
Esempio n. 37
0
        /// <summary>
        /// Returns the user's friends who have most recently updated, each with current status inline.
        /// </summary>
        public UserCollection GetFriends(int userId)
        {
            try
            {
                UserCollection users = new UserCollection();
                int friendsCount;

                if (currentLoggedInUser != null && currentLoggedInUser.Id == userId)
                {
                    friendsCount = CurrentlyLoggedInUser.FollowingCount;
                }
                else
                {
                    // need to make an extra call to twitter
                    User user = GetUser(userId);
                    friendsCount = user.FollowingCount;
                }

                var ceiling = Math.Ceiling(friendsCount / 100m);
                var results = new List<TwitterUser>();
                for (var i = 1; i <= ceiling; i++)
                {
                    var friends = FluentTwitter.CreateRequest(new Dimebrain.TweetSharp.TwitterClientInfo() { ClientName = "Witty" })
                        .AuthenticateAs(username, ToInsecureString(password))
                        .Users().GetFriends().For(userId)
                        .Skip(i).AsJson()
                        .Request().AsUsers();

                    results.AddRange(friends);
                }

                foreach (TwitterUser user in results)
                    users.Add(CreateUser(user));

                return users;
            }
            catch
            {
                return null;
            }
        }
Esempio n. 38
0
        public void SendChannelMessage(string msg, ClientSocket sender)
        {
            MinecraftHandler mc = Tunnel.MinecraftHandler;
            char colorCode = mc.Config.ServerBroadcastColorChar;
            List<Channel> channels = Channels.FindAll(x => x.User.IsInlist(sender.Name));
            UserCollection users = new UserCollection();

            foreach (Channel c in channels)
            {
                foreach (User u in c.User)
                {
                    if (mc.IsStringInList(u.Name, mc.Player))
                    {
                        if (!users.IsInlist(u))
                        {
                            users.Add(u);
                        }
                    }
                }
            }

            foreach (User player in users)
            {
                ClientSocket client = (ClientSocket)FindPlayer(player.Name);
                if (client != null)
                {
                    String message = string.Concat(new object[] { "§" + colorCode, msg });
                    foreach (var item in CreateList(message, 119))
                    {
                        client.SendPacket(3, ByteArythmetic.StoA(item));
                    }
                }
            }
        }
Esempio n. 39
0
 public UserCollection QueryAll()
 {
     UserCollection collection = new UserCollection();
     using (SqlConnection connection = new SqlConnection(connectionString))
     {
         SqlCommand command = new SqlCommand();
         command.Connection = connection;
         command.CommandText = "SP_SEL_Table";
         SqlParameter _param = command.Parameters.Add("@value1", System.Data.SqlDbType.VarChar);
         _param.Value = "Users";
         SqlParameter _param2 = command.Parameters.Add("@value2", System.Data.SqlDbType.VarChar);
         _param2.Value = "";
         SqlParameter _param3 = command.Parameters.Add("@value3", System.Data.SqlDbType.VarChar);
         _param3.Value = "";
         SqlParameter _param4 = command.Parameters.Add("@order_by1", System.Data.SqlDbType.VarChar);
         _param4.Value = "2";
         SqlParameter _param5 = command.Parameters.Add("@order_by2", System.Data.SqlDbType.TinyInt);
         _param5.Value = 0;
         command.CommandType = System.Data.CommandType.StoredProcedure;
         connection.Open();
         SqlDataReader reader = command.ExecuteReader();
         if (reader.HasRows)
         {
             while (reader.Read())
             {
                 User user = new User();
                 user.UserID = Convert.ToInt32(reader["ID"]);
                 user.UserName = reader["UserAccount"].ToString();
                 user.Enable = Convert.ToInt32(reader["Enable"]);
                 collection.Add(user);
             }
         }
         reader.Close();
         return collection;
     }
 }