CNAS取数仪器端升级
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

SyncParamsOperation.cs 3.1KB

4 kuukautta sitten
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. using CnasSynchrousModel;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. namespace CnasSynchronusClient
  7. {
  8. public class SyncParamsOperation
  9. {
  10. private List<string> lstTargetKeepField = new List<string>() {
  11. "ID"
  12. };
  13. private List<string> lstSourceKeepField = new List<string>() {
  14. };
  15. /// <summary>
  16. /// 表名重复性验证【不允许存在多表结构】
  17. /// </summary>
  18. /// <param name="lst"></param>
  19. /// <param name="strSourceTable"></param>
  20. /// <param name="strTargetTable"></param>
  21. /// <returns></returns>
  22. public bool CheckTableIfRepeat(List<SyncParamasInfo> lst, string strSourceTable, string strTargetTable)
  23. {
  24. bool IfRepeat = false;
  25. if (lst.Count>0&&lst.Where(s => s.SourceTable == strSourceTable && s.TargetTable == strTargetTable).Count() <= 0)
  26. IfRepeat = true;
  27. return IfRepeat;
  28. }
  29. /// <summary>
  30. /// 来源字段重复性验证【同一字段不允许配置多次】
  31. /// </summary>
  32. /// <param name="lst"></param>
  33. /// <param name="strSourceTable"></param>
  34. /// <param name="strSourceField"></param>
  35. /// <returns></returns>
  36. public bool CheckSourceFieldRepeat(List<SyncParamasInfo> lst, string strSourceTable, string strSourceField)
  37. {
  38. bool IfRepeat = false;
  39. if (lst.Where(s => s.SourceTable == strSourceTable && s.SourceField == strSourceField).Count() > 0)
  40. IfRepeat = true;
  41. return IfRepeat;
  42. }
  43. /// <summary>
  44. /// 目标字段重复性验证【同一字段不允许配置多次】
  45. /// </summary>
  46. /// <param name="lst"></param>
  47. /// <param name="strTargetTable"></param>
  48. /// <param name="strTargetField"></param>
  49. /// <returns></returns>
  50. public bool CheckTargetFieldRepeat(List<SyncParamasInfo> lst, string strTargetTable, string strTargetField)
  51. {
  52. bool IfRepeat = false;
  53. if (lst.Where(s => s.TargetTable == strTargetTable && s.TargetField == strTargetField).Count() > 0)
  54. IfRepeat = true;
  55. return IfRepeat;
  56. }
  57. /// <summary>
  58. /// 是否目标数据库的保留字段【比如自增字段,不允许同步】
  59. /// </summary>
  60. /// <param name="strTargetField"></param>
  61. /// <returns></returns>
  62. public bool CheckTargetKeepField(string strTargetField)
  63. {
  64. if (lstTargetKeepField.Contains(strTargetField))
  65. return true;
  66. else
  67. return false;
  68. }
  69. /// <summary>
  70. /// 是否来源数据库的保留字段
  71. /// </summary>
  72. /// <param name="strSourceField"></param>
  73. /// <returns></returns>
  74. public bool CheckSourceKeepField(string strSourceField)
  75. {
  76. if (lstSourceKeepField.Contains(strSourceField))
  77. return true;
  78. else
  79. return false;
  80. }
  81. }
  82. }