1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
use crate::com::{FromDispatchNew, SafeDispatch, SafeVariant};
use crate::errors::SageResult;
use windows::Win32::System::Com::IDispatch;
/// Wrapper pour l'objet ServiceContact de Sage 100c (IBOServiceContact3)
///
/// Représente un service de contact dans Sage 100c.
/// Permet de catégoriser les contacts par service.
#[derive(Debug)]
pub struct ServiceContact {
pub dispatch: IDispatch,
}
impl ServiceContact {
/// Crée un SafeDispatch temporaire pour les appels
fn dispatch(&self) -> SafeDispatch<'_> {
SafeDispatch::new(&self.dispatch)
}
// ==================== PROPRIÉTÉS PRINCIPALES ====================
/// Récupère l'intitulé du service de contact
pub fn sc_intitule(&self) -> SageResult<String> {
self.dispatch()
.call_method_by_name("SC_Intitule", &[])?
.to_string()
}
/// Définit l'intitulé du service de contact
pub fn set_sc_intitule(&self, intitule: &str) -> SageResult<()> {
let param = SafeVariant::from_string(intitule);
self.dispatch()
.call_method_by_name("SetSC_Intitule", &[param])?;
Ok(())
}
/// Récupère le classement du service
pub fn sc_classement(&self) -> SageResult<String> {
self.dispatch()
.call_method_by_name("SC_Classement", &[])?
.to_string()
}
/// Définit le classement du service
pub fn set_sc_classement(&self, classement: &str) -> SageResult<()> {
let param = SafeVariant::from_string(classement);
self.dispatch()
.call_method_by_name("SetSC_Classement", &[param])?;
Ok(())
}
// ==================== MÉTHODES IBIPersistObject ====================
/// Sauvegarde les modifications du service de contact
pub fn write(&self) -> SageResult<()> {
self.dispatch().call_method_by_name("Write", &[])?;
Ok(())
}
/// Supprime le service de contact
pub fn remove(&self) -> SageResult<()> {
self.dispatch().call_method_by_name("Remove", &[])?;
Ok(())
}
// ==================== MÉTHODES DE DESCRIPTION ====================
/// Retourne une description formatée du service de contact
pub fn description(&self) -> SageResult<String> {
let intitule = self.sc_intitule()?;
Ok(format!("ServiceContact: {}", intitule))
}
}
impl FromDispatchNew for ServiceContact {
fn from_dispatch_new(dispatch: IDispatch) -> SageResult<Self> {
Ok(Self { dispatch })
}
}
#[cfg(test)]
mod tests {
#[test]
fn test_service_contact_properties() {
// Test de documentation des propriétés disponibles
// Propriétés principales: sc_intitule, sc_classement
// Méthodes: write(), remove(), description()
}
}