Skip to content
This repository was archived by the owner on Jul 1, 2025. It is now read-only.

Commit a2f7283

Browse files
committed
Merge branch 'release/3.0.9rc2'
2 parents 411af66 + 8dbbedb commit a2f7283

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+886
-834
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ lang_cmp.php
4646
packages/
4747
*.suo
4848
*.user
49-
49+
.vs/
5050
obj
5151
bin
5252

Doxyfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ PROJECT_NAME = "SuiteCRM Outlook Add-in"
3838
# could be handy for archiving the generated documentation or if some version
3939
# control system is used.
4040

41-
PROJECT_NUMBER = 3.0.7.0
41+
PROJECT_NUMBER = 3.0.9.0
4242

4343
# Using the PROJECT_BRIEF tag one can provide an optional one line description
4444
# for a project that appears at the top of each page and should give viewer a

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
### What's in this repository
44

5-
SuiteCRM Outlook Plug-In v3.0.8
5+
SuiteCRM Outlook Plug-In v 3.0.9.0
66

77
This repository has been created to allow community members to collaborate and contribute to the project.
88

SuiteCRMAddIn/BusinessLogic/AppointmentSyncState.cs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222
*/
2323
namespace SuiteCRMAddIn.BusinessLogic
2424
{
25-
using SuiteCRMAddIn.ProtoItems;
25+
using Extensions;
26+
using ProtoItems;
27+
using System.Text;
2628
using Outlook = Microsoft.Office.Interop.Outlook;
2729

2830
public class AppointmentSyncState: SyncState<Outlook.AppointmentItem>
@@ -34,6 +36,25 @@ public AppointmentSyncState(string crmType)
3436

3537
public override string CrmType { get; }
3638

39+
public override string Description
40+
{
41+
get
42+
{
43+
Outlook.UserProperty olPropertyEntryId = olItem.UserProperties[AppointmentSyncing.CrmIdPropertyName];
44+
string crmId = olPropertyEntryId == null ?
45+
"[not present]" :
46+
olPropertyEntryId.Value;
47+
StringBuilder bob = new StringBuilder();
48+
bob.Append($"\tOutlook Id : {olItem.EntryID}\n\tCRM Id : {crmId}\n\tSubject : '{olItem.Subject}'\n\tSensitivity : {olItem.Sensitivity}\n\tRecipients:\n");
49+
foreach (Outlook.Recipient recipient in olItem.Recipients)
50+
{
51+
bob.Append($"\t\t{recipient.Name}: {recipient.GetSmtpAddress()}\n");
52+
}
53+
54+
return bob.ToString();
55+
}
56+
}
57+
3758
public override string OutlookItemEntryId => OutlookItem.EntryID;
3859

3960
public override Outlook.OlSensitivity OutlookItemSensitivity => OutlookItem.Sensitivity;

SuiteCRMAddIn/BusinessLogic/AppointmentSyncing.cs

Lines changed: 243 additions & 83 deletions
Large diffs are not rendered by default.

SuiteCRMAddIn/BusinessLogic/CRMPermissionsCache.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,20 +163,20 @@ public bool HasAccess(string moduleName, string permission)
163163

164164
foreach (AvailableModule item in RestAPIWrapper.GetModules().items)
165165
{
166-
if (!string.IsNullOrWhiteSpace(item.module_label))
166+
if (!string.IsNullOrWhiteSpace(item.module_key))
167167
{
168168
CacheAccessPermission(
169-
item.module_label,
169+
item.module_key,
170170
ImportPermissionToken,
171171
item.module_acls1.FirstOrDefault(b => b.action == ImportPermissionToken)?.access ?? false);
172172
CacheAccessPermission(
173-
item.module_label,
173+
item.module_key,
174174
ExportPermissionToken,
175175
item.module_acls1.FirstOrDefault(b => b.action == ExportPermissionToken)?.access ?? false);
176176

177177
try
178178
{
179-
Log.Debug($"Cached {CRMPermissionsCache.cache[item.module_label]} permission for {item.module_label}");
179+
Log.Debug($"Cached {CRMPermissionsCache.cache[item.module_key]} permission for {item.module_key}");
180180
}
181181
catch (KeyNotFoundException)
182182
{

SuiteCRMAddIn/BusinessLogic/ContactSyncState.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
*/
2323
namespace SuiteCRMAddIn.BusinessLogic
2424
{
25+
using System;
2526
using SuiteCRMAddIn.ProtoItems;
2627
using Outlook = Microsoft.Office.Interop.Outlook;
2728

@@ -40,6 +41,18 @@ public class ContactSyncState: SyncState<Outlook.ContactItem>
4041

4142
public override Outlook.UserProperties OutlookUserProperties => OutlookItem.UserProperties;
4243

44+
public override string Description
45+
{
46+
get
47+
{
48+
Outlook.UserProperty olPropertyEntryId = olItem.UserProperties[Synchroniser<Outlook.ContactItem>.CrmIdPropertyName];
49+
string crmId = olPropertyEntryId == null ?
50+
"[not present]" :
51+
olPropertyEntryId.Value;
52+
return $"\tOutlook Id : {olItem.EntryID}\n\tCRM Id : {crmId}\n\tFull name : '{olItem.FullName}'\n\tSensitivity : {olItem.Sensitivity}";
53+
}
54+
}
55+
4356
/// <summary>
4457
/// Don't actually delete contact items from Outlook; instead, mark them private so they
4558
/// don't get copied back to CRM.

SuiteCRMAddIn/BusinessLogic/ContactSyncing.cs

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,14 @@ public override string DefaultCrmModule
7777

7878
protected override void SaveItem(Outlook.ContactItem olItem)
7979
{
80-
olItem.Save();
80+
try
81+
{
82+
olItem.Save();
83+
}
84+
catch (System.Exception any)
85+
{
86+
Log.Error($"Error while saving contact {olItem?.Email1Address}", any);
87+
}
8188
}
8289

8390
/// <summary>
@@ -87,7 +94,7 @@ protected override void SaveItem(Outlook.ContactItem olItem)
8794
/// <param name="crmModule">The module to snychronise with.</param>
8895
protected override void SyncFolder(Outlook.MAPIFolder folder, string crmModule)
8996
{
90-
Log.Info($"ContactSyncing.SyncFolder: '{folder}'");
97+
Log.Info($"ContactSyncing.SyncFolder: '{folder.FolderPath}'");
9198
try
9299
{
93100
if (this.permissionsCache.HasExportAccess())
@@ -219,29 +226,19 @@ private bool ShouldSyncFlagChanged(Outlook.ContactItem olItem, EntryValue crmIte
219226

220227
this.SetOutlookItemPropertiesFromCrmItem(crmItem, olItem);
221228

222-
var newState = new ContactSyncState
223-
{
224-
OutlookItem = olItem,
225-
OModifiedDate = DateTime.ParseExact(crmItem.GetValueAsString("date_modified"), "yyyy-MM-dd HH:mm:ss", null),
226-
CrmEntryId = crmItem.GetValueAsString("id"),
227-
};
228-
ItemsSyncState.Add(newState);
229-
230-
LogItemAction(newState.OutlookItem, "AppointmentSyncing.AddNewItemFromCrmToOutlook, saved item");
231-
232-
return newState;
229+
return this.AddOrGetSyncState(olItem);
233230
}
234231

235232
/// <summary>
236233
/// Log a message regarding this Outlook item, with detail of the item.
237234
/// </summary>
238235
/// <param name="olItem">The outlook item.</param>
239236
/// <param name="message">The message to be logged.</param>
240-
protected override void LogItemAction(Outlook.ContactItem olItem, string message)
237+
internal override void LogItemAction(Outlook.ContactItem olItem, string message)
241238
{
242239
try
243240
{
244-
Outlook.UserProperty olPropertyEntryId = olItem.UserProperties["SEntryID"];
241+
Outlook.UserProperty olPropertyEntryId = olItem.UserProperties[CrmIdPropertyName];
245242
string crmId = olPropertyEntryId == null ?
246243
"[not present]" :
247244
olPropertyEntryId.Value;
@@ -280,7 +277,7 @@ private bool ShouldSyncContact(EntryValue crmItem)
280277
/// <returns>True if either of these propertyies differ between the representations.</returns>
281278
private bool CrmItemChanged(EntryValue crmItem, Outlook.ContactItem olItem)
282279
{
283-
Outlook.UserProperty dateModifiedProp = olItem.UserProperties["SOModifiedDate"];
280+
Outlook.UserProperty dateModifiedProp = olItem.UserProperties[ModifiedDatePropertyName];
284281

285282
return (dateModifiedProp.Value != crmItem.GetValueAsString("date_modified") ||
286283
ShouldSyncFlagChanged(olItem, crmItem));
@@ -298,7 +295,7 @@ private bool CrmItemChanged(EntryValue crmItem, Outlook.ContactItem olItem)
298295
if (!itemSyncState.IsDeletedInOutlook)
299296
{
300297
Outlook.ContactItem olItem = itemSyncState.OutlookItem;
301-
Outlook.UserProperty dateModifiedProp = olItem.UserProperties["SOModifiedDate"];
298+
Outlook.UserProperty dateModifiedProp = olItem.UserProperties[ModifiedDatePropertyName];
302299
Outlook.UserProperty shouldSyncProp = olItem.UserProperties["SShouldSync"];
303300
this.LogItemAction(olItem, "ContactSyncing.UpdateExistingOutlookItemFromCrm");
304301

@@ -490,8 +487,8 @@ protected override string ConstructAndDespatchCrmItem(Outlook.ContactItem olItem
490487
return new ContactSyncState
491488
{
492489
OutlookItem = oItem,
493-
CrmEntryId = oItem.UserProperties["SEntryID"]?.Value.ToString(),
494-
OModifiedDate = ParseDateTimeFromUserProperty(oItem.UserProperties["SOModifiedDate"]?.Value.ToString()),
490+
CrmEntryId = oItem.UserProperties[CrmIdPropertyName]?.Value.ToString(),
491+
OModifiedDate = ParseDateTimeFromUserProperty(oItem.UserProperties[ModifiedDatePropertyName]?.Value.ToString()),
495492
};
496493
}
497494

@@ -530,6 +527,12 @@ internal override string GetOutlookEntryId(Outlook.ContactItem olItem)
530527
return olItem.EntryID;
531528
}
532529

530+
protected override string GetCrmEntryId(Outlook.ContactItem olItem)
531+
{
532+
return olItem?.UserProperties[CrmIdPropertyName]?.Value.ToString();
533+
}
534+
535+
533536
internal override Outlook.OlSensitivity GetSensitivity(Outlook.ContactItem item)
534537
{
535538
return item.Sensitivity;

SuiteCRMAddIn/BusinessLogic/EmailArchiving.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ public ArchiveResult ArchiveEmailWithEntityRelationships(Outlook.MailItem olItem
226226
private IList<System.Exception> CreateEmailRelationshipsWithEntities(string crmMailId, IEnumerable<CrmEntity> selectedCrmEntities)
227227
{
228228
var failures = new List<System.Exception>();
229-
foreach (var entity in selectedCrmEntities)
229+
foreach (CrmEntity entity in selectedCrmEntities)
230230
{
231231
try
232232
{

SuiteCRMAddIn/BusinessLogic/SyncState.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ public abstract class SyncState
6060

6161
public abstract Outlook.UserProperties OutlookUserProperties { get; }
6262

63+
/// <summary>
64+
/// A description of the item, suitable for use in debugging logs.
65+
/// </summary>
66+
public abstract string Description { get; }
67+
6368
public bool IsDeletedInOutlook
6469
{
6570
get

0 commit comments

Comments
 (0)