Beispiel #1
0
        /// <summary>
        /// Prompts the user to choose a profile user id.
        /// </summary>
        /// <param name="owner"> Parent Form </param>
        /// <returns> </returns>
        public static string GetUserProfileId(Form owner)
        {
            List <ListItem> userIds = GetFolderNames("/dev_hdd0/home/");

            List <ListItem> userNames = new();

            foreach (ListItem userId in userIds)
            {
                userNames.Add(new ListItem
                {
                    Value = userId.Name,
                    Name  = $"{userId.Name} ({GetUserNameFromUserId(userId.Name)})"
                });
            }

            switch (userIds.Count)
            {
            case > 0:
            {
                ListItem userId = DialogExtensions.ShowListViewDialog(owner, "User Profile IDs", userNames);

                if (userId != null)
                {
                    return(userId.Name.Split()[0]);
                }

                break;
            }
            }

            XtraMessageBox.Show(owner,
                                "Could not find any users. Make sure there is at least one user profile on the console.",
                                "No Users Found", MessageBoxButtons.OK, MessageBoxIcon.Error);
            return(null);
        }
Beispiel #2
0
        /// <summary>
        ///     Prompts the user to choose their user id
        /// </summary>
        /// <param name="owner">Console IP Address</param>
        /// <returns></returns>
        public static string GetUserId(Form owner)
        {
            var userIds = GetFolderNames("/dev_hdd0/home/");

            if (userIds.Count >= 1)
            {
                return(DialogExtensions.ShowListInputDialog(owner, "User Profile IDs", userIds));
            }
            _ = DarkMessageBox.Show(owner,
                                    "Could not find any users on your console. Make sure you have at least one user profile and then try again.",
                                    "No Users Found", MessageBoxIcon.Error);
            return(null);
        }
Beispiel #3
0
        /// <summary>
        /// Prompts the user to choose their profile user id.
        /// </summary>
        /// <param name="owner"> Console IP Address </param>
        /// <returns> </returns>
        public static string GetUserProfileId(Form owner)
        {
            List <string> userIds = GetFolderNames("/dev_hdd0/home/", false);

            List <string> userNames = (from userId in userIds
                                       select $"{userId} ({GetUserNameFromUserId(userId)})").ToList();

            if (userIds.Count > 0)
            {
                string userId = DialogExtensions.ShowListInputDialog(owner, "User Profile IDs", userNames).Split()[0];

                if (userId != null)
                {
                    return(userId);
                }
            }

            XtraMessageBox.Show("Could not find any users. Make sure you have created at least one user profile.", "No Users Found", MessageBoxButtons.OK, MessageBoxIcon.Error);
            return(null);
        }
Beispiel #4
0
        public static void EditProfileComment(Form owner)
        {
            MainWindow.Window.SetStatus("Editing profile comment file...");

            //FtpClient ftpClient = MainWindow.FtpClient;
            //FtpConnection ftpConnection = MainWindow.FtpConnection;

            //string userId = GetUserProfileId(owner);
            string userId          = "00000001";
            string commentFilePath = $"/dev_hdd0/home/{userId}/friendim/mecomment.dat";
            string filePath        = $"{UserFolders.Tmp}mecomment.dat";

            //string currentProfileComment = new string[] { string.Empty };
            string[] currentProfileComment = { string.Empty };

            if (File.Exists(filePath))
            {
                currentProfileComment = File.ReadAllLines(filePath);
            }

            //if (ftpConnection.FileExists(commentFilePath))
            //if (ftpClient.FileExists(commentFilePath))
            //{
            //    MessageBox.Show("File exists.");
            //    //ftpConnection.GetFile(commentFilePath, filePath, false);
            //    //DownloadFile(filePath, commentFilePath);
            //    ftpClient.DownloadFile(filePath, commentFilePath);
            //    MessageBox.Show("File downloaded to : " + filePath);
            //    currentProfileComment = File.ReadAllLines(filePath);
            //    MessageBox.Show(string.Join(",", currentProfileComment));
            //}
            //else
            //{
            //    MessageBox.Show("File doesn't exist.");
            //    return;
            //    //File.WriteAllText(filePath, string.Empty);
            //}

            //if (ftpClient.FileExists(commentFilePath))
            //{
            //    ftpClient.DownloadFile(filePath, commentFilePath);
            //}
            //else
            //{
            //    File.WriteAllText(filePath, string.Empty);
            //}

            string[] newProfileComment = DialogExtensions.ShowMultiTextInputDialog(owner, "Set Profile Comment", "Profile Comment:", currentProfileComment);
            //string newProfileComment = DialogExtensions.ShowTextInputDialog(owner, "Set Profile Comment", "Profile Comment:", currentProfileComment, 0);

            switch (newProfileComment)
            {
            case null:
                MessageBox.Show("Comment can't be empty.");
                return;
            }

            File.WriteAllLines(filePath, newProfileComment);

            if (new FileInfo(filePath).Length > 64)
            {
                XtraMessageBox.Show(MainWindow.Window, "Profile comment file must be equal or less than 64 bytes.", "Maximum Bytes", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                MainWindow.Window.SetStatus("Profile comment file must be equal or less than 64 bytes.");
                return;
            }

            UploadFile(filePath, commentFilePath);
            MainWindow.Window.SetStatus("Successfully edited profile comment.");
        }