Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

180 lines
5.3KB

  1. using MailKit;
  2. using System.Text.Json.Serialization;
  3. using System.Xml;
  4. namespace Services
  5. {
  6. public class EmailMessage
  7. {
  8. [JsonIgnore]
  9. public MailKit.UniqueId? Uid { get; set; } // Pour charger le corps plus tard
  10. [JsonPropertyName("UidString")]
  11. public string? UidString
  12. {
  13. get => Uid != null ? Uid?.ToString() : null;
  14. set
  15. {
  16. if (!string.IsNullOrWhiteSpace(value))
  17. {
  18. if (MailKit.UniqueId.TryParse(value, out var parsed))
  19. Uid = parsed;
  20. else
  21. Uid = null; // ou log une erreur
  22. }
  23. else
  24. {
  25. Uid = null;
  26. }
  27. }
  28. }
  29. /*
  30. public string UidString
  31. {
  32. get => Uid.ToString();
  33. set => Uid = UniqueId.Parse(value);
  34. }
  35. */
  36. public string Id { get; set; } = "";
  37. public string To { get; set; } = "";
  38. public string Cc { get; set; } = "";
  39. public bool IsDestinatairePrincipal { get; set; }=false;
  40. public string From { get; set; } = "";
  41. public string FromName { get; set; } = "";
  42. public string Subject { get; set; } = "";
  43. public string InReplyTo { get; set; } = "";
  44. public DateTime Date { get; set; }
  45. public string DateSTR { get => Date.ToString("dd/MM/yyyy HH:mm"); }
  46. public string Analyse { get; set; } = "";
  47. public string Preview { get; set; } = "";
  48. public string TextBody { get; set; } = "";
  49. public string TextBodyHTML { get; set; } = "";
  50. [JsonIgnore]
  51. public string TextBody_PJ
  52. {
  53. get
  54. {
  55. if (ContentPJ == null || ContentPJ.Count == 0)
  56. return TextBody;
  57. var joined = string.Join("\n---\n", ContentPJ);
  58. return $"{TextBody}\n\n--- Contenu des pièces jointes ---\n{joined}";
  59. }
  60. }
  61. [JsonIgnore]
  62. public string ContentPJ_STR
  63. {
  64. get
  65. {
  66. if (ContentPJ == null || ContentPJ.Count == 0)
  67. return "";
  68. var joined = string.Join("\n---\n", ContentPJ);
  69. return $"--- Contenu des pièces jointes ---\n{joined}";
  70. }
  71. }
  72. public string Resume { get; set; } = "";
  73. public string Categorie { get; set; } = "";
  74. public string Strategie { get; set; } = "";
  75. public string Reponse { get; set; } = "";
  76. public bool IsImportant { get; set; } = false;
  77. public bool IsUrgent { get; set; } = false;
  78. public int ImportanceScore { get; set; } = 0; // de 0 à 5
  79. public int UrgenceScore { get; set; } = 0; // de 0 à 5
  80. public List<string>? ContentPJ { get; set; } = new();
  81. public int PJ_NBR
  82. {
  83. get
  84. {
  85. if (ContentPJ == null || ContentPJ.Count == 0)
  86. return 0;
  87. return ContentPJ.Count;
  88. }
  89. }
  90. [JsonIgnore]
  91. public string PJ_NBR_STR
  92. {
  93. get
  94. {
  95. if (PJ_NBR > 0)
  96. return "📎";
  97. return "";
  98. }
  99. }
  100. public bool IsPJ { get => ContentPJ != null && ContentPJ.Count > 0; }
  101. public string Priorite { get => $"Important : {(IsImportant ? "✔️" : "❌")} - Urgent : {(IsUrgent ? "⚠️" : "❌")}"; }
  102. public string ImportanceSTR => $"{ImportanceScore}/5";
  103. public string UrgenceSTR => $"{UrgenceScore}/5";
  104. public string ModeleIA { get; set; } = "";
  105. [JsonIgnore]
  106. public bool ToRemove { get; set; } = false;
  107. public bool PresenceSuspecte { get; set; } = false;
  108. [JsonIgnore]
  109. public string PresenceSuspecte_STR
  110. {
  111. get
  112. {
  113. if (PresenceSuspecte)
  114. return "⚠️";
  115. return "";
  116. }
  117. }
  118. [JsonIgnore]
  119. public string IsDestinatairePrincipal_STR
  120. {
  121. get
  122. {
  123. if (IsDestinatairePrincipal)
  124. return "📩";
  125. else
  126. return "👥";
  127. }
  128. }
  129. [JsonIgnore]
  130. public string IsDestinatairePrincipal_STR_TXT
  131. {
  132. get
  133. {
  134. if (IsDestinatairePrincipal)
  135. return "Vous êtes destinataire principal de ce mail";
  136. else
  137. return "Vous êtes en copie de ce mail";
  138. }
  139. }
  140. }
  141. #region Classe MessageToSend
  142. public class MessageToSend
  143. {
  144. public string Object { get; set; } = "";
  145. public string DestinataireA { get; set; } = "";
  146. public string DestinataireCC { get; set; } = "";
  147. public string Type { get; set; } = "Professionnel";
  148. public string Ton { get; set; } = "";
  149. public string Posture { get; set; } = "";
  150. public string Couleur { get; set; } = "";
  151. public string NiveauDetail{ get; set; } = "";
  152. public bool VOUS_TU { get; set; } = true;// "true : 'Vous'" ou "false : 'Tu'"
  153. public string Query { get; set; } = "";
  154. public string Body { get; set; } = "...";
  155. }
  156. #endregion
  157. }