Advertisement
Guest User

Untitled

a guest
Nov 9th, 2018
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Drawing;
  4. using System.IO;
  5. using System.Linq;
  6. using System.Reflection;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using WS.Models;
  10.  
  11. namespace WS.DAO
  12. {
  13. public class UserDao
  14. {
  15. public static List<User> GetUsers()
  16. {
  17. var userList = new List<User>();
  18. //string path = "resources\\users.csv";
  19. //string pathFile = Path.Combine(
  20. //Path.GetDirectoryName(
  21. //Assembly.GetExecutingAssembly().Location), @path);
  22. //string pathFile = File.ReadLines()
  23. string text = File.ReadAllText("users.txt", Encoding.GetEncoding(1251));
  24. foreach (string row in text.Split('\n'))
  25. {
  26. if (!string.IsNullOrEmpty(row))
  27. {
  28. var cells = row.Split(',');
  29. User user = new User();
  30. user.lastName = cells[0];
  31. user.FirstNameAndPatronomic = cells[1];
  32. user.login = cells[2];
  33. user.password = cells[3];
  34. user.role = cells[4];
  35. user.photo = "Images\\" + user.login + ".jpg";
  36. userList.Add(user);
  37.  
  38. }
  39. }
  40. return userList;
  41. }
  42. public static Image GetImageFromFile(string inputPath)
  43. {
  44. string path = Path.Combine(Path.GetDirectoryName(
  45. Assembly.GetExecutingAssembly().Location),
  46. @inputPath);
  47. Image image = new Bitmap(path);
  48. return image;
  49. }
  50.  
  51. }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement