Example #1
0
 private void ExtractUserNames(IEnumerable <string> userGamesFiles, string fileNamePattern)
 {
     foreach (var userGameFile in userGamesFiles.Select(Path.GetFileName))
     {
         UserNames.Add(userGameFile.Substring(0, userGameFile.Length - fileNamePattern.Length + 1));
     }
 }
Example #2
0
        /// <summary>
        /// Инициализация структуры хранения данных
        /// </summary>
        void InitDataStruct()
        {
            string pathUserNamesDictonary = Path.Combine(downloadedDataPath, userDataFolderName, userNamesDictonary);

            if (File.Exists(pathUserNamesDictonary))
            {
                userNames = DataManager.DeserializeData <UserNames>(pathUserNamesDictonary);
            }
            else
            {
                userNames = new UserNames();
            }
            //Инициализация директории
            void InitDirectory(string folderName)
            {
                string path = Path.Combine(downloadedDataPath, folderName);

                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
            }

            InitDirectory(newsFolderName);
            InitDirectory(userDataFolderName);
            InitDirectory(faqDirectory);

            RefreshNewsBlocks();
        }
Example #3
0
 /// <summary>
 ///     Clears all the global
 /// </summary>
 public static void ClearValues()
 {
     AccountingGroups.Clear();
     CostProfileGroups.Clear();
     CountriesOfOrigin.Clear();
     CustomerIdConversions.Clear();
     ExternalIdTypes.Clear();
     ItemCategories.Clear();
     ItemGroups.Clear();
     ItemIds.Clear();
     ItemIdSuffixes.Clear();
     ItemRecords.Clear();
     Languages.Clear();
     Licenses.Clear();
     LocalItemIds.Clear();
     MetaDescriptions.Clear();
     PricingGroups.Clear();
     ProductCategories.Clear();
     ProductFormats.Clear();
     ProductGoups.Clear();
     ProductLines.Clear();
     Properties.Clear();
     PsStatuses.Clear();
     RequestStatus.Clear();
     SpecialCharacters.Clear();
     TariffCodes.Clear();
     Territories.Clear();
     ToolTips.Clear();
     UpcProductFormatExceptions.Clear();
     Upcs.Clear();
     UserNames.Clear();
     UserRoles.Clear();
     WebCategoryList.Clear();
 }
Example #4
0
 private void Button_Click_1(object sender, RoutedEventArgs e)
 {
     if (!string.IsNullOrEmpty(SelectedUser))
     {
         UserNames.Remove(SelectedUser);
     }
 }
Example #5
0
        public static int PopulateTestData(AppDbContext context)
        {
            var toDos = context.ToDoItems.ToList();

            foreach (var item in toDos)
            {
                context.Remove(item);
            }
            context.SaveChanges();

            Random    rand          = new Random(Guid.NewGuid().GetHashCode());
            const int numberOfItems = 100;

            for (int n = 0; n < numberOfItems; n++)
            {
                string userName = UserNames.GetRandomName();

                var item = new ToDoItem
                {
                    Description = TextGenerator.GetText(10, 25),
                    DueDate     = DateTime.Now.AddSeconds(rand.Next(60 * 60 * 4, 60 * 60 * 24 * 7)),
                    Hours       = rand.Next(1, 8),
                    Owner       = userName,
                    Title       = TextGenerator.GetText(3, 10),
                    Avatar      = $"https://api.adorable.io/avatars/285/{userName}.png"
                };

                context.Add(item);
            }
            context.SaveChanges();

            return(numberOfItems);
        }
Example #6
0
 public void Save(string userName, string sdfName)
 {
     UserNames.Add(userName);
     UserNames = UserNames.Distinct().ToList();
     UserName  = userName;
     SdfName   = sdfName;
 }
Example #7
0
 public string GetUserName(string userId)
 {
     if (string.IsNullOrWhiteSpace(userId))
     {
         return("");
     }
     UserNames.TryGetValue(userId, out var userName);
     return(userName ?? "");
 }
Example #8
0
 public void AbortGame()
 {
     MainThread.Abort();
     UserNames.Clear();
     server.BroadCastToAll("GRDY|");
     Running   = false;
     IsRunning = false;
     Program.Log("已强制终止主线程");
 }
Example #9
0
        /// <summary>
        /// Process Records
        /// </summary>
        protected override void ProcessRecord()
        {
            var queries = new QuerystringBuilder();

            if (StartIndex != null)
            {
                queries.Add("startIndex", StartIndex.Value);
            }

            if (PageCount != null)
            {
                queries.Add("pageCount", PageCount.Value);
            }

            if (Domains != null && Domains.Any())
            {
                queries.Add("domains", string.Join(",", Domains));
            }

            if (EntityTypes != null && EntityTypes.Any())
            {
                queries.Add("entityTypes", string.Join(",", EntityTypes));
            }

            if (Actions != null && Actions.Any())
            {
                queries.Add("actions", string.Join(",", Actions));
            }

            if (!string.IsNullOrWhiteSpace(Search))
            {
                queries.Add("search", Search.Trim());
            }

            if (UserNames != null && UserNames.Any())
            {
                queries.Add("userNames", string.Join(",", UserNames));
            }

            if (StartTime.HasValue)
            {
                queries.Add("startTimeUsecs", StartTime.ToString());
            }

            if (EndTime.HasValue)
            {
                queries.Add("endTimeUsecs", EndTime.ToString());
            }

            var preparedUrl = $"/public/auditLogs/cluster{queries.Build()}";

            WriteDebug(preparedUrl);
            var result = Session.ApiClient.Get <Model.ClusterAuditLogsSearchResult>(preparedUrl);

            WriteObject(result.ClusterAuditLogs, true);
        }
Example #10
0
        private UserNames GetUserNamesFromArray(string[] nameArray)
        {
            // IDIR users have their names returned as lastName, firstName BCeID users have their
            // names returned as firstName, lastName
            UserNames result = new UserNames()
            {
                FirstName = _isIDIR ? nameArray[1] : nameArray[0],
                LastName  = _isIDIR ? nameArray[0] : nameArray[1]
            };

            return(result);
        }
Example #11
0
        private void GenerateDisplayName(string[] nameArray)
        {
            UserNames names = GetUserNamesFromArray(nameArray);

            if (names.LastName.Length >= 1)
            {
                names.LastName = names.LastName.Substring(0, 1);
            }
            _displayName = $"{names.FirstName} {names.LastName}";
            // clean up any rogue commas
            _displayName = _displayName.Replace(",", string.Empty).Trim();
        }
        private void LoadFullName(UserNames userNames, bool register = false)
        {
            if (userNames != null)
            {
                NameOne = userNames.FirstName != null?userNames.FirstName.ToString() : string.Empty;

                NameTwo = userNames.SecondName != null?userNames.SecondName.ToString() : string.Empty;

                LastNameOne = userNames.FirstSurname != null?userNames.FirstSurname.ToString() : string.Empty;

                LastNameTwo = userNames.SecondSurname != null?userNames.SecondSurname.ToString() : string.Empty;
            }
        }
Example #13
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            string s = newUser.Text.Trim();

            if (s.Length > 0)
            {
                if ((from a in UserNames where a.ToLower() == s.ToLower() select a).Count() == 0)
                {
                    UserNames.Add(s);
                    newUser.Text = "";
                }
            }
        }
Example #14
0
        public void Start()
        {
            var startTime = DateTime.Now;

            Console.WriteLine($"Start time: {startTime.ToString("G")}");
            Console.WriteLine("Program directory: " + Directory.GetCurrentDirectory());
            Console.WriteLine("Reading in Puzzle Games");
            if (ReadInPuzzleSource())
            {
                Console.WriteLine("\r" + PuzzleSourceUrls.Count + " Puzzles found");
                Console.WriteLine("Reading in User Games");
                ReadInUserGames();
                if (AllUserGames.Count == 0)
                {
                    Console.WriteLine("No user games found, please follow the instructions");
                    ShowInstructions();
                }
                else
                {
                    Console.Write(AllUserGames.Count + " games found from: ");
                    foreach (var userName in UserNames)
                    {
                        Console.Write(userName + (userName != UserNames.Last() ? ", " : string.Empty));
                    }
                    Console.WriteLine("\nSearch the riddles in games of you");
                    Search4UserGames();
                    Console.WriteLine("\r            ");
                    Console.WriteLine("Search successful ended");
                    switch (FoundGames.Count)
                    {
                    case 0:
                        Console.WriteLine("No games found");
                        break;

                    case 1:
                        Console.WriteLine("One game found");
                        break;

                    default:
                        Console.WriteLine(FoundGames.Count + " games found, scroll up to see");
                        break;
                    }
                    var endTime = DateTime.Now;
                    Console.WriteLine($"Start time: {endTime.ToString("G")}");
                    var timeDiff = endTime - startTime;
                    Console.WriteLine("Time needed: " + timeDiff);
                }
            }
            Console.ReadKey(false);
        }
Example #15
0
        public static async Task <int> PopulateTestDataAsync(AppDbContext context, UserManager <User> userManager)
        {
            var toDos = context.ToDoItems.ToList();

            foreach (var item in toDos)
            {
                context.Remove(item);
            }
            context.SaveChanges();

            Random    rand          = new Random(Guid.NewGuid().GetHashCode());
            const int numberOfItems = 100;

            for (int n = 0; n < numberOfItems; n++)
            {
                var person = UserNames.GetRandomName();

                var user = await userManager.FindByEmailAsync(person.email);

                if (user == null)
                {
                    user = new User
                    {
                        Name     = person.name,
                        UserName = person.name.Replace(" ", ""),
                        Email    = person.email,
                    };

                    _ = await userManager.CreateAsync(user, "MySecretPassword1@");
                }

                var item = new ToDoItem
                {
                    Description = TextGenerator.GetText(10, 25),
                    DueDate     = DateTime.Now.AddSeconds(rand.Next(60 * 60 * 4, 60 * 60 * 24 * 7)),
                    Hours       = rand.Next(1, 8),
                    Owner       = user.Name,
                    OwnerId     = user.Id,
                    Title       = TextGenerator.GetText(3, 10),
                    Avatar      = $"https://api.adorable.io/avatars/285/{user.UserName}.png"
                };

                context.Add(item);
            }
            context.SaveChanges();

            return(numberOfItems);
        }
Example #16
0
 public async Task ImportLogs()
 {
     if (Core.ApplicationData.Instance.ActiveDatabase != null && (from a in logtypes.AvailableTypes where a.IsChecked select a).Count() > 0)
     {
         Import imp = new Import();
         await imp.ImportLogsOfUsers(
             Core.ApplicationData.Instance.ActiveDatabase,
             UserNames.ToList(),
             Core.Settings.Default.FindLogsOfUserBetweenDates,
             Core.Settings.Default.FindLogsOfUserMinDate,
             Core.Settings.Default.FindLogsOfUserMaxDate,
             (from a in logtypes.AvailableTypes where a.IsChecked select a.Item).ToList(),
             Core.Settings.Default.FindLogsOfUserImportMissing
             );
     }
 }
Example #17
0
 public static UserNames GetUserNamesData(long portalKey, long userKey)
 {
     if (portalKey != 0) // right now we only support caching on the main portal.  Could easily expand this.
     {
         throw new CacheException("Only Portal '0' supports caching in this version");
     }
     if (UserNameMap.ContainsKey(userKey))
     {
         return UserNameMap[userKey];
     }
     DotNetNuke.Entities.Users.UserInfo uinfo = DotNetNuke.Entities.Users.UserController.GetUser((int)portalKey, (int)userKey, false); // false does not hydrate user ROLES
     UserNames unames = new UserNames()
     {
         FirstName = uinfo.FirstName,
         LastName = uinfo.LastName,
         CombinedName = uinfo.FirstName + " " + uinfo.LastName.ToUpper()[0] + ".",
         Email = uinfo.Email,
         UserName = uinfo.Username
     };
     UserNameMap.Add(userKey, unames);
     return unames;
 }
Example #18
0
        public static UserNames GetUserNamesData(long portalKey, long userKey)
        {
            if (portalKey != 0) // right now we only support caching on the main portal.  Could easily expand this.
            {
                throw new CacheException("Only Portal '0' supports caching in this version");
            }
            if (UserNameMap.ContainsKey(userKey))
            {
                return(UserNameMap[userKey]);
            }
            DotNetNuke.Entities.Users.UserInfo uinfo = DotNetNuke.Entities.Users.UserController.GetUser((int)portalKey, (int)userKey, false); // false does not hydrate user ROLES
            UserNames unames = new UserNames()
            {
                FirstName    = uinfo.FirstName,
                LastName     = uinfo.LastName,
                CombinedName = uinfo.FirstName + " " + uinfo.LastName.ToUpper()[0] + ".",
                Email        = uinfo.Email,
                UserName     = uinfo.Username
            };

            UserNameMap.Add(userKey, unames);
            return(unames);
        }
Example #19
0
        public async Task <IActionResult> OnPostAsync()
        {
            for (int i = 0; i < userManager.Users.ToList().Count; i++)
            {
                var user = userManager.Users.ToList()[i];

                Console.WriteLine(user.Name);
                if (UserNames.Contains(user.Id))
                {
                    if (!await IsInRole(user))
                    {
                        await userManager.AddToRoleAsync(user, RoleName);
                    }
                }
                else
                {
                    if (await IsInRole(user))
                    {
                        await userManager.RemoveFromRoleAsync(user, RoleName);
                    }
                }
            }
            return(RedirectToPage("/AdminPages/ListRoles"));
        }
Example #20
0
        public MeetingViewModel(IRHDispatcher dispatcher, IServiceProvider serviceProvider, NavigationState navigationState, INavigation navigation)
        {
            _dispatcher      = dispatcher;
            _serviceProvider = serviceProvider;
            _navigationState = navigationState;
            _navigation      = navigation;
            token            = ConnectEvent.Instance.Subscribe((c) =>
            {
                lock (lockobj) //Synchronous
                {
                    if (c.Parms.ContainsKey("HostCode") && c.Parms["HostCode"] != null && ((string)c.Parms["HostCode"]).ToUpper() == HostCode)
                    {
                        switch (c.Method)
                        {
                        case "ReceiveUpdate":
                            _dispatcher.Invoke(Dispatcher, () => {
                                var newUserNames = (List <string>)c.Parms["UserNames"];
                                foreach (var newUser in newUserNames)
                                {
                                    if (!UserNames.Contains(newUser))
                                    {
                                        UserNames.Add(newUser);
                                    }
                                }
                                var removeUsers = new List <string>();
                                foreach (var existUser in UserNames)
                                {
                                    if (!newUserNames.Contains(existUser))
                                    {
                                        removeUsers.Add(existUser);
                                    }
                                }
                                foreach (var user in removeUsers)
                                {
                                    UserNames.Remove(user);
                                }
                            });
                            break;

                        case "ReceiveUpdateRaiseHands":
                            if (c.Parms.ContainsKey("HostCode"))
                            {
                                _dispatcher.Invoke(Dispatcher, () => {
                                    var RaisedHands = (List <string>)c.Parms["RaisedHands"];
                                    RaisedNames.Clear();
                                    foreach (var name in RaisedHands)
                                    {
                                        RaisedNames.Add(name);
                                    }
                                    PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("RaisedNames"));
                                });
                            }
                            break;

                        case "ReceiveCloseHost":
                            if (!IsHost)
                            {
                                var leaveparms = new Dictionary <string, object>();
                                leaveparms.Add("HostCode", HostCode);
                                leaveparms.Add("Name", Name);
                                leaveparms.Add("IsHost", IsHost);
                                ConnectEvent.Instance.Publish(new Connect()
                                {
                                    Method = "Set", Parms = leaveparms
                                });
                                _navigation.GoBack();
                            }
                            break;
                        }
                    }
                }
            });
            LoadedCommand    = new DelegateCommand(OnLoaded);
            LeaveCommand     = new DelegateCommand(OnLeave);
            RaiseHandCommand = new DelegateCommand <string>(OnRaiseHand);
        }
Example #21
0
        public LoginViewModel()
        {
            UserService      = new UserService();
            User_MenuService = new User_MenuService();
            userNames        = new List <string>();

            loginCommand = new DelegateCommand();
            loginCommand.ExcuteAction = new Action <object>(Login);

            //moveCommand.ExcuteAction = new Action<object>((o) =>
            //{
            //    var win = o as Window;
            //    win.DragMove();
            //});

            closeCommand.ExcuteAction = new Action <object>(o =>
            {
                Application.Current.Shutdown();
            });

            loadNameAndPwdCommand = new DelegateCommand();
            //加载用户名列表和加载上次登录用户的密码
            loadNameAndPwdCommand.ExcuteAction = new Action <object>(o =>
            {
                Thread.Sleep(2000);
                var config = JsonHelper.ReadJsonFileToStr <Configs>(AppDomain.CurrentDomain.BaseDirectory + @"config/configs.json");
                if (config != null)
                {
                    if (config.UserConfig.Count > 0)
                    {
                        UserName = config.UserConfig[0].UserName;
                        config.UserConfig.ForEach(u =>
                        {
                            //添加到用户名列表
                            UserNames.Add(u.UserName);
                        });
                        if (!string.IsNullOrEmpty(config.UserConfig[0].Token))
                        {
                            //根据用户名和token获取密码
                            Pwd = UserService.GetPwdByTokenAndName(UserName, config.UserConfig[0].Token);
                        }
                    }
                }
            });

            //选择项改变
            selectChangeCommand = new DelegateCommand();
            selectChangeCommand.ExcuteAction = new Action <object>(o =>
            {
                var combox = o as ComboBox;

                var config = JsonHelper.ReadJsonFileToStr <Configs>(AppDomain.CurrentDomain.BaseDirectory + @"config/configs.json");
                foreach (var item in config.UserConfig)
                {
                    if (item.UserName == combox.SelectedItem as string)
                    {
                        if (!string.IsNullOrEmpty(item.Token))
                        {
                            //根据用户名和token获取密码
                            Pwd = UserService.GetPwdByTokenAndName(item.UserName, item.Token);
                            return;
                        }
                    }
                }
                Pwd = "";
            });
        }
Example #22
0
        public void Work()
        {
            Program.Log("已开局");
            Running = true;
            server.BroadCastToAll("SGRD|");
            CreateCards();
            AnnounceNewGame();
            cards[0].Sort();
            cards[1].Sort();
            cards[2].Sort();
            SendCardList(0);
            SendCardList(1);
            SendCardList(2);
            server.BroadCastToAll("SMSG|即将开局...");
            Thread.Sleep(5000);
            int  now = rand.Next(3);
            bool LandlordSelected = false;

            for (int i = 1; i <= 3; i++)
            {
                AnnounceRound(now);
                if (AskLandlord(now))
                {
                    LandlordSelected = true;
                    break;
                }
                else
                {
                    now++;
                    now %= 3;
                }
            }
            if (LandlordSelected)
            {
                int Landlord = now;
                Program.Log(String.Format("{0}号玩家是地主", now));
                server.BroadCastToAll("PLDL|" + now);
                server.BroadCastToAll("SLOG|" + now + "是地主");
                cards[now].AddRange(baseCard);
                cards[now].Sort();
                SendBaseCard();
                Selection Last  = new Selection();
                int       Owner = now;
                int       time  = 1;
                while (true)
                {
                    AnnounceRound(now);
                    SendCardList(now);
                    Selection selection = GetSelection(now);
                    while (!SelectionOK(now, Last, Owner, selection))
                    {
                        TellSelectionFail(now);
                        selection = GetSelection(now);
                    }
                    if (selection.type != Selection.Type.None)
                    {
                        Last  = selection;
                        Owner = now;
                    }
                    if (selection.type == Selection.Type.Bomb)
                    {
                        time *= 2;
                    }
                    AnnounceSelection(now, selection);
                    foreach (Card i in selection)
                    {
                        cards[now].Remove(i);
                    }
                    if (cards[now].Count == 2 && selection.type != Selection.Type.None)
                    {
                        server.BroadCastToAll("SMSG|" + UserNames[now] + "报双了");
                        server.BroadCastToAll("SLOG|" + UserNames[now] + "报双了");
                    }
                    if (cards[now].Count == 1 && selection.type != Selection.Type.None)
                    {
                        server.BroadCastToAll("SMSG|" + UserNames[now] + "报单了");
                        server.BroadCastToAll("SLOG|" + UserNames[now] + "报单了");
                    }
                    if (cards[now].Count == 0)
                    {
                        AnnounceWinner(now, Landlord, time);
                        break;
                        //server.StopService();
                        //return;
                    }
                    else
                    {
                        SendCardList(now);
                        now++;
                        now %= 3;
                    }
                }
            }
            else
            {
                UserNames.Clear();
            }
            Program.Log("本局结束");
            Running = false;
            UserNames.Clear();
            server.BroadCastToAll("GRDY|");
            //server.StopService();
        }
        //Pre: The map name, the user name, and the elapsed time of the user
        //Post: A boolean for whether the highscore was updated
        //Desc: A method for updating the highscores of a map
        public bool UpdateHighscoresMap(string mapName, string user, float elapsedTime)
        {
            //Temporarily used lists for the names and times
            List <string> tempNames = new List <string>();
            List <float>  tempTimes = new List <float>();

            //If the list of usernames is not null
            if (UserNames != null)
            {
                //Clears the usernames and times for each user
                UserNames.Clear();
                UserTimes.Clear();
            }

            //Checks if the file exists
            if (onlineHelper.CheckFileExists(mapName + FILE_NAME_SUFFIX))
            {
                //Downloads the file
                onlineHelper.DownloadFile(mapName + FILE_PATH_SUFFIX, mapName + FILE_NAME_SUFFIX);

                //Creates a stream reader for the file
                reader = new StreamReader(mapName + FILE_PATH_SUFFIX);

                //Gets the score count using the reader from the file
                int scoreCount = Convert.ToInt32(reader.ReadLine());

                //Loop for every score saved in the file
                for (int i = 0; i < scoreCount; i++)
                {
                    //Adds the neames and times to the lists from the file
                    tempNames.Add(reader.ReadLine());
                    tempTimes.Add((float)Convert.ToDouble(reader.ReadLine()));
                }

                //Closes the stream reader
                reader.Close();

                //Adds the new user and their time
                tempNames.Add(user);
                tempTimes.Add(elapsedTime);

                //Sorts the new times
                SortTimes(tempNames, tempTimes);

                //If the amount of scores saved is greater then the max amount of scores
                if (UserNames.Count > MAX_SCORES)
                {
                    //Removes the last score
                    UserNames.RemoveAt(UserNames.Count - 1);
                    UserTimes.RemoveAt(UserTimes.Count - 1);
                }

                //Creates the stream writer with the file path
                writer = new StreamWriter(mapName + FILE_PATH_SUFFIX);

                //Writes the amount of scores to the file
                writer.WriteLine(UserNames.Count);

                //Loop for every score
                for (int i = 0; i < UserNames.Count; i++)
                {
                    //Writers the user name and it's time to the file
                    writer.WriteLine(UserNames[i]);
                    writer.WriteLine(UserTimes[i]);
                }

                //Closes the file
                writer.Close();

                //If the file was updates
                if (onlineHelper.UpdateFile(mapName + FILE_NAME_SUFFIX, mapName + FILE_PATH_SUFFIX, FILE_TYPE, FILE_DESCRIPTION))
                {
                    //Returns that the file was updateed
                    return(true);
                }
            }
            //If the file does not exist
            else
            {
                //Resets the names and the times for each name
                UserNames = new List <string>();
                UserTimes = new List <float>();

                //Adds the new user and their time
                UserNames.Add(user);
                UserTimes.Add(elapsedTime);

                //A stream writer is created with the path of the current map
                writer = new StreamWriter(mapName + FILE_PATH_SUFFIX);

                //Writes the amount of scores in the file
                writer.WriteLine(UserNames.Count);

                //Writes the new user name and time to the file
                writer.WriteLine(UserNames[0]);
                writer.WriteLine(UserTimes[0]);

                //Closes the stream writer
                writer.Close();

                //If the file was uploaded
                if (onlineHelper.UpdateFile(mapName + FILE_NAME_SUFFIX, mapName + FILE_PATH_SUFFIX, FILE_TYPE, FILE_DESCRIPTION))
                {
                    //Returns that the file was uploaded
                    return(true);
                }
            }

            //Returns that the file was not uploaded
            return(false);
        }
Example #24
0
 public User GetUserbyName(UserNames userName)
 {
     return(users.FirstOrDefault(u => u.Name == userName.ToString()));
 }