From 095ecf802262db8cbff4da7a19a3a6892330c6c0 Mon Sep 17 00:00:00 2001 From: Simon Brooke Date: Wed, 26 Apr 2017 10:11:53 +0100 Subject: [PATCH 1/2] #137: Fix --- .../EmailCategoriesCollection.cs | 58 +++++++++++++++++++ .../Daemon/FetchEmailCategoriesAction.cs | 11 +++- SuiteCRMAddIn/Dialogs/ArchiveDialog.cs | 8 ++- SuiteCRMAddIn/SuiteCRMAddIn.csproj | 1 + SuiteCRMAddIn/clsSettings.cs | 4 +- .../LicenceValidationHelperTests.cs | 9 +-- .../BusinessLogic/SyncDirectionTests.cs | 6 +- .../Daemon/FetchEmailCategoriesActionTests.cs | 5 +- .../LDAPAuthenticationHelperTests.cs | 9 +-- .../Properties/Settings.Designer.cs | 48 +++++++++++++++ .../Properties/Settings.settings | 12 ++++ SuiteCRMAddInTests/WithRestServiceTests.cs | 3 +- SuiteCRMAddInTests/app.config | 12 ++++ 13 files changed, 167 insertions(+), 19 deletions(-) create mode 100644 SuiteCRMAddIn/BusinessLogic/EmailCategoriesCollection.cs diff --git a/SuiteCRMAddIn/BusinessLogic/EmailCategoriesCollection.cs b/SuiteCRMAddIn/BusinessLogic/EmailCategoriesCollection.cs new file mode 100644 index 00000000..2febeb65 --- /dev/null +++ b/SuiteCRMAddIn/BusinessLogic/EmailCategoriesCollection.cs @@ -0,0 +1,58 @@ +/** + * Outlook integration for SuiteCRM. + * @package Outlook integration for SuiteCRM + * @copyright SalesAgility Ltd http://www.salesagility.com + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU LESSER GENERAL PUBLIC LICENCE as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENCE + * along with this program; if not, see http://www.gnu.org/licenses + * or write to the Free Software Foundation,Inc., 51 Franklin Street, + * Fifth Floor, Boston, MA 02110-1301 USA + * + * @author SalesAgility + */ +namespace SuiteCRMAddIn.BusinessLogic +{ + using System; + using System.Collections.Generic; + using System.Linq; + using System.Text; + using System.Threading.Tasks; + + /// + /// A list of the email categories known to the connected CRM instance, if that + /// CRM instance supports the email categories feature. If it does not, the + /// IsImplemented property will be false. + /// + public class EmailCategoriesCollection : List + { + /// + /// True if my connected CRM instance implementes email categories. + /// + private bool isImplemented = true; + + /// + /// True if my connected CRM instance implementes email categories. + /// + public bool IsImplemented + { + get + { + return this.isImplemented && this.Count > 0; + } + internal set + { + this.isImplemented = value; + } + } + } +} diff --git a/SuiteCRMAddIn/Daemon/FetchEmailCategoriesAction.cs b/SuiteCRMAddIn/Daemon/FetchEmailCategoriesAction.cs index 818f58eb..27cd4a1a 100644 --- a/SuiteCRMAddIn/Daemon/FetchEmailCategoriesAction.cs +++ b/SuiteCRMAddIn/Daemon/FetchEmailCategoriesAction.cs @@ -23,6 +23,7 @@ */ namespace SuiteCRMAddIn.Daemon { + using BusinessLogic; using SuiteCRMClient; using SuiteCRMClient.RESTObjects; using System.Collections.Generic; @@ -39,13 +40,13 @@ public class FetchEmailCategoriesAction : AbstractDaemonAction /// /// The list of items I shall modify. /// - private readonly List items; + private readonly EmailCategoriesCollection items; /// /// Construct a new instance of the FetchEmailCategoriesAction class. /// /// The list of items I shall modify - public FetchEmailCategoriesAction(List listToModify) : base(5) + public FetchEmailCategoriesAction(EmailCategoriesCollection listToModify) : base(5) { this.items = listToModify; } @@ -60,9 +61,15 @@ public override void Perform() if (field != null) { + items.IsImplemented = true; items.Clear(); items.AddRange(field.Options.Keys.OrderBy(x => x)); } + else + { + /* the CRM instance does not have the category_id field in its emails module */ + items.IsImplemented = false; + } } } } diff --git a/SuiteCRMAddIn/Dialogs/ArchiveDialog.cs b/SuiteCRMAddIn/Dialogs/ArchiveDialog.cs index 5cc8b8f6..b3e156a5 100644 --- a/SuiteCRMAddIn/Dialogs/ArchiveDialog.cs +++ b/SuiteCRMAddIn/Dialogs/ArchiveDialog.cs @@ -91,10 +91,16 @@ private void frmArchive_Load(object sender, EventArgs e) private void PopulateUIComponents() { this.txtSearch.Text = ConstructSearchText(Globals.ThisAddIn.SelectedEmails); - if (this.settings.EmailCategories != null) + if (this.settings.EmailCategories != null && this.settings.EmailCategories.IsImplemented) { this.categoryInput.DataSource = this.settings.EmailCategories; } + else + { + this.categoryInput.Enabled = false; + this.categoryInput.Visible = false; + this.categoryLabel.Visible = false; + } if (Globals.ThisAddIn.Settings.ShowCustomModules) { diff --git a/SuiteCRMAddIn/SuiteCRMAddIn.csproj b/SuiteCRMAddIn/SuiteCRMAddIn.csproj index c39e73ef..311be6c0 100644 --- a/SuiteCRMAddIn/SuiteCRMAddIn.csproj +++ b/SuiteCRMAddIn/SuiteCRMAddIn.csproj @@ -204,6 +204,7 @@ AddressBook.cs + diff --git a/SuiteCRMAddIn/clsSettings.cs b/SuiteCRMAddIn/clsSettings.cs index 7a92d613..8e2eac8d 100644 --- a/SuiteCRMAddIn/clsSettings.cs +++ b/SuiteCRMAddIn/clsSettings.cs @@ -373,11 +373,11 @@ public int RestTimeout /// Categories for emails. These are actually provided by CRM and not edited by the user, but are cached here. /// [UserScopedSetting, DebuggerNonUserCode] - public List EmailCategories + public EmailCategoriesCollection EmailCategories { get { - return (List)this["EmailCategories"]; + return (EmailCategoriesCollection)this["EmailCategories"]; } set { diff --git a/SuiteCRMAddInTests/BusinessLogic/LicenceValidationHelperTests.cs b/SuiteCRMAddInTests/BusinessLogic/LicenceValidationHelperTests.cs index 4ed901e7..b00088d5 100644 --- a/SuiteCRMAddInTests/BusinessLogic/LicenceValidationHelperTests.cs +++ b/SuiteCRMAddInTests/BusinessLogic/LicenceValidationHelperTests.cs @@ -3,21 +3,22 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using SuiteCRMAddIn.BusinessLogic; using SuiteCRMAddIn.Tests; + using SuiteCRMAddInTests.Properties; [TestClass()] public class LicenceValidationHelperTests : WithLoggerTests { [TestMethod()] - public void ValidateTest() + public void LicenceValidationHelperValidateTest() { Assert.IsTrue( new LicenceValidationHelper( this.Log, - "b8794235718652747b82fd713deac078", "e10a9aff077e983deca51e5d3688636c").Validate(), + Settings.Default.LicencePublicKey, Settings.Default.LicenceCustomerKey).Validate(), "Key pair valid, should validate"); Assert.IsFalse(new LicenceValidationHelper(this.Log, - "b8794235718652747b82fd713deac078", "froboz").Validate(), + Settings.Default.LicencePublicKey, "invalid").Validate(), "Customer licence key invalid, should not validate"); Assert.IsFalse(new LicenceValidationHelper(this.Log, - "froboz", "e10a9aff077e983deca51e5d3688636c").Validate(), + "invalid", Settings.Default.LicenceCustomerKey).Validate(), "Public key invalid, should not validate"); } } diff --git a/SuiteCRMAddInTests/BusinessLogic/SyncDirectionTests.cs b/SuiteCRMAddInTests/BusinessLogic/SyncDirectionTests.cs index 046a2b89..8ec1e3df 100644 --- a/SuiteCRMAddInTests/BusinessLogic/SyncDirectionTests.cs +++ b/SuiteCRMAddInTests/BusinessLogic/SyncDirectionTests.cs @@ -28,7 +28,7 @@ namespace SuiteCRMAddIn.BusinessLogic.Tests public class SyncDirectionTests { [TestMethod()] - public void ToStringTest() + public void SyncDirectionToStringTest() { Assert.AreEqual("None", SyncDirection.ToString(SyncDirection.Direction.Neither)); Assert.AreEqual("From CRM to Outlook", SyncDirection.ToString(SyncDirection.Direction.Export)); @@ -37,7 +37,7 @@ public void ToStringTest() } [TestMethod()] - public void AllowOutboundTest() + public void SyncDirectionAllowOutboundTest() { Assert.IsTrue(SyncDirection.AllowOutbound(SyncDirection.Direction.BiDirectional), "Bidirectional includes both"); Assert.IsTrue(SyncDirection.AllowOutbound(SyncDirection.Direction.Import), "Explicitly outbound"); @@ -46,7 +46,7 @@ public void AllowOutboundTest() } [TestMethod()] - public void AllowInboundTest() + public void SyncDirectionAllowInboundTest() { Assert.IsTrue(SyncDirection.AllowInbound(SyncDirection.Direction.BiDirectional), "Bidirectional includes both"); Assert.IsTrue(SyncDirection.AllowInbound(SyncDirection.Direction.Export), "Explicitly inbound"); diff --git a/SuiteCRMAddInTests/Daemon/FetchEmailCategoriesActionTests.cs b/SuiteCRMAddInTests/Daemon/FetchEmailCategoriesActionTests.cs index 4836c05d..56764dc7 100644 --- a/SuiteCRMAddInTests/Daemon/FetchEmailCategoriesActionTests.cs +++ b/SuiteCRMAddInTests/Daemon/FetchEmailCategoriesActionTests.cs @@ -22,6 +22,7 @@ */ namespace SuiteCRMAddIn.Daemon.Tests { + using BusinessLogic; using Microsoft.VisualStudio.TestTools.UnitTesting; using SuiteCRMAddIn.Daemon; using SuiteCRMAddIn.Tests; @@ -45,7 +46,7 @@ public class FetchEmailCategoriesActionTests : AbstractWithCrmConnectionTest /// /// The list of categories which performing my action should modify. /// - private readonly List categories = new List(); + private readonly EmailCategoriesCollection categories = new EmailCategoriesCollection(); /// /// Specialisation: I need an action. @@ -61,7 +62,7 @@ public override void Initialize() /// After performing my action, there should be some categories. /// [TestMethod()] - public void PerformTest() + public void FetchEmailCategoriesActionPerformTest() { Assert.AreEqual(0, categories.Count); this.action.Perform(); diff --git a/SuiteCRMAddInTests/LDAPAuthenticationHelperTests.cs b/SuiteCRMAddInTests/LDAPAuthenticationHelperTests.cs index e48b75c7..db125a91 100644 --- a/SuiteCRMAddInTests/LDAPAuthenticationHelperTests.cs +++ b/SuiteCRMAddInTests/LDAPAuthenticationHelperTests.cs @@ -2,15 +2,16 @@ { using Microsoft.VisualStudio.TestTools.UnitTesting; using SuiteCRMAddInTests; + using SuiteCRMAddInTests.Properties; using SuiteCRMClient; using System; [TestClass()] public class LDAPAuthenticationHelperTests : WithRestServiceTests { - string validUser = ""; - string validPass = ""; - string validKey = ""; + string validUser = Settings.Default.LDAPValidUser; + string validPass = Settings.Default.LDAPValidPass; + string validKey = Settings.Default.LDAPKey; [TestMethod()] public void LDAPAuthenticationHelperTest() @@ -28,7 +29,7 @@ public void LDAPAuthenticationHelperTest() } [TestMethod()] - public void AuthenticateTest() + public void LDAPAuthenticationHelperAuthenticateTest() { Assert.IsFalse( String.IsNullOrWhiteSpace( diff --git a/SuiteCRMAddInTests/Properties/Settings.Designer.cs b/SuiteCRMAddInTests/Properties/Settings.Designer.cs index 1c7537ef..9b1d1f2c 100644 --- a/SuiteCRMAddInTests/Properties/Settings.Designer.cs +++ b/SuiteCRMAddInTests/Properties/Settings.Designer.cs @@ -106,5 +106,53 @@ public string LogDirPath { this["LogLevel"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("TestUser")] + public string LDAPValidUser { + get { + return ((string)(this["LDAPValidUser"])); + } + set { + this["LDAPValidUser"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("test")] + public string LDAPValidPass { + get { + return ((string)(this["LDAPValidPass"])); + } + set { + this["LDAPValidPass"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("b8794235718652747b82fd713deac078")] + public string LicencePublicKey { + get { + return ((string)(this["LicencePublicKey"])); + } + set { + this["LicencePublicKey"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("e10a9aff077e983deca51e5d3688636c")] + public string LicenceCustomerKey { + get { + return ((string)(this["LicenceCustomerKey"])); + } + set { + this["LicenceCustomerKey"] = value; + } + } } } diff --git a/SuiteCRMAddInTests/Properties/Settings.settings b/SuiteCRMAddInTests/Properties/Settings.settings index b0e12a85..00d00747 100644 --- a/SuiteCRMAddInTests/Properties/Settings.settings +++ b/SuiteCRMAddInTests/Properties/Settings.settings @@ -23,5 +23,17 @@ Debug + + TestUser + + + test + + + b8794235718652747b82fd713deac078 + + + e10a9aff077e983deca51e5d3688636c + \ No newline at end of file diff --git a/SuiteCRMAddInTests/WithRestServiceTests.cs b/SuiteCRMAddInTests/WithRestServiceTests.cs index 5a0ccef5..ab2deed8 100644 --- a/SuiteCRMAddInTests/WithRestServiceTests.cs +++ b/SuiteCRMAddInTests/WithRestServiceTests.cs @@ -22,6 +22,7 @@ */ namespace SuiteCRMAddInTests { + using Properties; using SuiteCRMAddIn.Tests; using SuiteCRMClient; @@ -37,7 +38,7 @@ public abstract class WithRestServiceTests : WithLoggerTests public WithRestServiceTests() { - this.service = new RestService("http://demo.suitecrm.com/suitecrm77/", this.Log); + this.service = new RestService(Settings.Default.host, this.Log); } } } diff --git a/SuiteCRMAddInTests/app.config b/SuiteCRMAddInTests/app.config index 02ab757c..07bb390e 100644 --- a/SuiteCRMAddInTests/app.config +++ b/SuiteCRMAddInTests/app.config @@ -28,6 +28,18 @@ Debug + + TestUser + + + test + + + b8794235718652747b82fd713deac078 + + + e10a9aff077e983deca51e5d3688636c + \ No newline at end of file From 8e56081c138224e0e35ce6c9614287b8f0fb2933 Mon Sep 17 00:00:00 2001 From: Simon Brooke Date: Wed, 26 Apr 2017 11:19:39 +0100 Subject: [PATCH 2/2] Upversion to 3.0.3.0 (again) for rc5 --- SuiteCRMAddIn/Properties/AssemblyInfo.cs | 2 +- SuiteCRMAddInSetup/SuiteCRMAddInSetup.isl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/SuiteCRMAddIn/Properties/AssemblyInfo.cs b/SuiteCRMAddIn/Properties/AssemblyInfo.cs index 9692383d..eb4a4fa3 100644 --- a/SuiteCRMAddIn/Properties/AssemblyInfo.cs +++ b/SuiteCRMAddIn/Properties/AssemblyInfo.cs @@ -33,6 +33,6 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("3.0.2.16")] +[assembly: AssemblyVersion("3.0.3.0")] [assembly: AssemblyFileVersion("3.0.1")] diff --git a/SuiteCRMAddInSetup/SuiteCRMAddInSetup.isl b/SuiteCRMAddInSetup/SuiteCRMAddInSetup.isl index 3e663940..1aaeedba 100644 --- a/SuiteCRMAddInSetup/SuiteCRMAddInSetup.isl +++ b/SuiteCRMAddInSetup/SuiteCRMAddInSetup.isl @@ -4393,7 +4393,7 @@ UwBpAG4AZwBsAGUASQBtAGEAZwBlAAEARQB4AHAAcgBlAHMAcwA= PROGMSG_IIS_ROLLBACKWEBSERVICEEXTENSIONS##IDS_PROGMSG_IIS_ROLLBACKWEBSERVICEEXTENSIONS## ProductCode{7D2339B3-980B-4AF0-8428-56ABB4CD7EF0} ProductNameSuiteCRMAddIn - ProductVersion3.0.2.16 + ProductVersion3.0.3.0 ProgressType0install ProgressType1Installing ProgressType2installed