CloudServerCollection.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace LYFZ.CloudServerData.DAL
  6. {
  7. public class CloudServerCollection : BaseDataOperate<LYFZ.CloudServerData.Model.CloudServerCollection>
  8. {
  9. public CloudServerCollection(LYFZ.CloudServerData.Model.DBConnection dbConn)
  10. {
  11. base.DBConn = dbConn;
  12. }
  13. /// <summary>
  14. /// 验证基本信息
  15. /// </summary>
  16. /// <param name="enterpriseModel"></param>
  17. /// <param name="msg"></param>
  18. /// <returns></returns>
  19. public bool VerifyBaseInfo(LYFZ.CloudServerData.Model.CloudServerCollection serverCollectionModel, ref string msg)
  20. {
  21. if (String.IsNullOrEmpty(serverCollectionModel.CloudServerName))
  22. {
  23. msg = "服务器名称不能为空";
  24. return false;
  25. }
  26. if (String.IsNullOrEmpty(serverCollectionModel.DataBaseServerIP))
  27. {
  28. msg = "服务器IP不能为空";
  29. return false;
  30. }
  31. if (serverCollectionModel.DataBasePort <= 0 || serverCollectionModel.DataBasePort > 65535)
  32. {
  33. msg = "服务器端口必须是“1—65535”之间的整数";
  34. return false;
  35. }
  36. if (String.IsNullOrEmpty(serverCollectionModel.DataBaseUser))
  37. {
  38. msg = "数据库登录用户不能为空";
  39. return false;
  40. }
  41. if (String.IsNullOrEmpty(serverCollectionModel.DataBasePass))
  42. {
  43. msg = "数据库登录用户密码不能为空";
  44. return false;
  45. }
  46. return true;
  47. }
  48. /// <summary>
  49. /// 验证服务器IP是否存在
  50. /// </summary>
  51. /// <param name="enterpriseID"></param>
  52. /// <param name="msg"></param>
  53. /// <returns></returns>
  54. public bool VerifyServerIPExists(string serverIP, ref string msg)
  55. {
  56. if (this.Exists("DataBaseServerIP", serverIP))
  57. {
  58. msg = "要添加的服务器IP“" + serverIP + "”已经存在,不能重复添加";
  59. return false;
  60. }
  61. return true;
  62. }
  63. }
  64. }