From 5280a0b306a370cd464dfc391d7ff57f201d6643 Mon Sep 17 00:00:00 2001 From: Roy Date: Tue, 21 Jun 2022 21:49:58 +0300 Subject: Email Bulk Modifier. --- Software/Visual_Studio/Tango.sln | 35 +++++++-- .../Tango.BulkEmailModifier.CLI/App.config | 16 ++++ .../Tango.BulkEmailModifier.CLI/Emails.csv | 12 +++ .../Utilities/Tango.BulkEmailModifier.CLI/Model.cs | 14 ++++ .../Tango.BulkEmailModifier.CLI/Program.cs | 88 ++++++++++++++++++++++ .../Properties/AssemblyInfo.cs | 36 +++++++++ .../Tango.BulkEmailModifier.CLI.csproj | 79 +++++++++++++++++++ .../Tango.BulkEmailModifier.CLI/packages.config | 4 + 8 files changed, 278 insertions(+), 6 deletions(-) create mode 100644 Software/Visual_Studio/Utilities/Tango.BulkEmailModifier.CLI/App.config create mode 100644 Software/Visual_Studio/Utilities/Tango.BulkEmailModifier.CLI/Emails.csv create mode 100644 Software/Visual_Studio/Utilities/Tango.BulkEmailModifier.CLI/Model.cs create mode 100644 Software/Visual_Studio/Utilities/Tango.BulkEmailModifier.CLI/Program.cs create mode 100644 Software/Visual_Studio/Utilities/Tango.BulkEmailModifier.CLI/Properties/AssemblyInfo.cs create mode 100644 Software/Visual_Studio/Utilities/Tango.BulkEmailModifier.CLI/Tango.BulkEmailModifier.CLI.csproj create mode 100644 Software/Visual_Studio/Utilities/Tango.BulkEmailModifier.CLI/packages.config (limited to 'Software/Visual_Studio') diff --git a/Software/Visual_Studio/Tango.sln b/Software/Visual_Studio/Tango.sln index b305193f8..2278bb67b 100644 --- a/Software/Visual_Studio/Tango.sln +++ b/Software/Visual_Studio/Tango.sln @@ -479,6 +479,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Tango.ColorLib_v5", "ColorL EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.PDF", "Tango.PDF\Tango.PDF.csproj", "{84FB2B51-213E-4602-A5DB-FA97D8AE907A}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.BulkEmailModifier.CLI", "Utilities\Tango.BulkEmailModifier.CLI\Tango.BulkEmailModifier.CLI.csproj", "{DA4FCA0B-E0EA-431F-B0CC-AA9B0A4C73C2}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -4570,6 +4572,26 @@ Global {84FB2B51-213E-4602-A5DB-FA97D8AE907A}.Release|x64.Build.0 = Release|Any CPU {84FB2B51-213E-4602-A5DB-FA97D8AE907A}.Release|x86.ActiveCfg = Release|Any CPU {84FB2B51-213E-4602-A5DB-FA97D8AE907A}.Release|x86.Build.0 = Release|Any CPU + {DA4FCA0B-E0EA-431F-B0CC-AA9B0A4C73C2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DA4FCA0B-E0EA-431F-B0CC-AA9B0A4C73C2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DA4FCA0B-E0EA-431F-B0CC-AA9B0A4C73C2}.Debug|ARM.ActiveCfg = Debug|Any CPU + {DA4FCA0B-E0EA-431F-B0CC-AA9B0A4C73C2}.Debug|ARM.Build.0 = Debug|Any CPU + {DA4FCA0B-E0EA-431F-B0CC-AA9B0A4C73C2}.Debug|ARM64.ActiveCfg = Debug|Any CPU + {DA4FCA0B-E0EA-431F-B0CC-AA9B0A4C73C2}.Debug|ARM64.Build.0 = Debug|Any CPU + {DA4FCA0B-E0EA-431F-B0CC-AA9B0A4C73C2}.Debug|x64.ActiveCfg = Debug|Any CPU + {DA4FCA0B-E0EA-431F-B0CC-AA9B0A4C73C2}.Debug|x64.Build.0 = Debug|Any CPU + {DA4FCA0B-E0EA-431F-B0CC-AA9B0A4C73C2}.Debug|x86.ActiveCfg = Debug|Any CPU + {DA4FCA0B-E0EA-431F-B0CC-AA9B0A4C73C2}.Debug|x86.Build.0 = Debug|Any CPU + {DA4FCA0B-E0EA-431F-B0CC-AA9B0A4C73C2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DA4FCA0B-E0EA-431F-B0CC-AA9B0A4C73C2}.Release|Any CPU.Build.0 = Release|Any CPU + {DA4FCA0B-E0EA-431F-B0CC-AA9B0A4C73C2}.Release|ARM.ActiveCfg = Release|Any CPU + {DA4FCA0B-E0EA-431F-B0CC-AA9B0A4C73C2}.Release|ARM.Build.0 = Release|Any CPU + {DA4FCA0B-E0EA-431F-B0CC-AA9B0A4C73C2}.Release|ARM64.ActiveCfg = Release|Any CPU + {DA4FCA0B-E0EA-431F-B0CC-AA9B0A4C73C2}.Release|ARM64.Build.0 = Release|Any CPU + {DA4FCA0B-E0EA-431F-B0CC-AA9B0A4C73C2}.Release|x64.ActiveCfg = Release|Any CPU + {DA4FCA0B-E0EA-431F-B0CC-AA9B0A4C73C2}.Release|x64.Build.0 = Release|Any CPU + {DA4FCA0B-E0EA-431F-B0CC-AA9B0A4C73C2}.Release|x86.ActiveCfg = Release|Any CPU + {DA4FCA0B-E0EA-431F-B0CC-AA9B0A4C73C2}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -4740,14 +4762,15 @@ Global {859A766B-78AD-484E-9BF2-2CE0FE288894} = {B2AF4F3F-2828-47C3-8F3E-A0EA0BD66FF8} {DBBD90F4-4135-475D-A8F8-6795D3A8F697} = {0048447D-1D94-4E60-9DAD-7349C777CB4E} {0F87D32E-B65F-4AE8-862C-29F4CCC38240} = {7181F9DE-0760-46B7-AD8F-BDBCAEDEF1B7} + {DA4FCA0B-E0EA-431F-B0CC-AA9B0A4C73C2} = {5F6BBAA8-EAD0-4B18-97E5-55B4F56DD760} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution - BuildVersion_UseGlobalSettings = False - BuildVersion_AssemblyInfoFilename = Properties\AssemblyInfo.cs - BuildVersion_StartDate = 2000/1/1 - BuildVersion_UpdateFileVersion = False - BuildVersion_UpdateAssemblyVersion = True - BuildVersion_BuildVersioningStyle = None.None.Increment.DeltaBaseYearDayOfYear SolutionGuid = {7986F7F4-A86A-4994-B1B6-0988D7F057B6} + BuildVersion_BuildVersioningStyle = None.None.Increment.DeltaBaseYearDayOfYear + BuildVersion_UpdateAssemblyVersion = True + BuildVersion_UpdateFileVersion = False + BuildVersion_StartDate = 2000/1/1 + BuildVersion_AssemblyInfoFilename = Properties\AssemblyInfo.cs + BuildVersion_UseGlobalSettings = False EndGlobalSection EndGlobal diff --git a/Software/Visual_Studio/Utilities/Tango.BulkEmailModifier.CLI/App.config b/Software/Visual_Studio/Utilities/Tango.BulkEmailModifier.CLI/App.config new file mode 100644 index 000000000..f05da3520 --- /dev/null +++ b/Software/Visual_Studio/Utilities/Tango.BulkEmailModifier.CLI/App.config @@ -0,0 +1,16 @@ + + + + +
+ + + + + + + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/Utilities/Tango.BulkEmailModifier.CLI/Emails.csv b/Software/Visual_Studio/Utilities/Tango.BulkEmailModifier.CLI/Emails.csv new file mode 100644 index 000000000..802ed4a2e --- /dev/null +++ b/Software/Visual_Studio/Utilities/Tango.BulkEmailModifier.CLI/Emails.csv @@ -0,0 +1,12 @@ +Old,New +chaim@twine-s.com,Chaim.Dikman@twine-s.com +Dana@twine-s.com,Dana.Hochberg@twine-s.com +Daria@twine-s.com,Daria.Fonshtein@twine-s.com +David@twine-s.com,David.Orenstein@twine-s.com +dekel@twine-s.com,Dekel.tsuberi@twine-s.com +Eran@twine-s.com,Eran.Hirschberg@twine-s.com +ErezK@twine-s.com,Erez.Koppel@twine-s.com +Gal.l@twine-s.com,Gal.Lahav@twine-s.com +Gil@twine-s.com,Gil.Garama@twine-s.com +gilad@twine-s.com,Gilad.Gotesman@twine-s.com +gili@twine-s.com,Gili.Mitshel@twine-s.com diff --git a/Software/Visual_Studio/Utilities/Tango.BulkEmailModifier.CLI/Model.cs b/Software/Visual_Studio/Utilities/Tango.BulkEmailModifier.CLI/Model.cs new file mode 100644 index 000000000..df207add8 --- /dev/null +++ b/Software/Visual_Studio/Utilities/Tango.BulkEmailModifier.CLI/Model.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.BulkEmailModifier.CLI +{ + public class Model + { + public String Old { get; set; } + public String New { get; set; } + } +} diff --git a/Software/Visual_Studio/Utilities/Tango.BulkEmailModifier.CLI/Program.cs b/Software/Visual_Studio/Utilities/Tango.BulkEmailModifier.CLI/Program.cs new file mode 100644 index 000000000..a5370b12c --- /dev/null +++ b/Software/Visual_Studio/Utilities/Tango.BulkEmailModifier.CLI/Program.cs @@ -0,0 +1,88 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL; +using Tango.Core; +using Tango.CSV; +using System.Data.Entity; +using Tango.BL.Entities; + +namespace Tango.BulkEmailModifier.CLI +{ + class Program + { + static void Main(string[] args) + { + Console.WriteLine("Modifying email addresses..."); + + var emails = CsvFile.Read(new CsvSource("Emails.csv")).ToList(); + + DataSource dataSource = new DataSource(); + dataSource.Address = "twine.database.windows.net"; + dataSource.IntegratedSecurity = false; + dataSource.UserName = "Roy"; + dataSource.Password = "Aa123456"; + + List catalogs = new List() + { + "Tango_DEV", + "Tango_TEST", + "Tango_PROCESS", + "Tango_ALPHA", + "Tango_BETA", + "Tango_STAGE", + "Tango", + "Tango_BB", + }; + + foreach (var catalog in catalogs) + { + Console.WriteLine(); + Console.WriteLine($"Switching to database {catalog}..."); + Console.WriteLine(); + + dataSource.Catalog = catalog; + + using (ObservablesContext db = ObservablesContext.CreateDefault(dataSource)) + { + foreach (var email in emails) + { + var user = db.Users.Include(x => x.Contact).SingleOrDefault(x => x.Email.ToLower() == email.Old.ToLower()); + + if (user == null) + { + Console.ForegroundColor = ConsoleColor.DarkGray; + Console.WriteLine($"'{email.Old}' not found."); + Console.ForegroundColor = ConsoleColor.Gray; + continue; + } + + var existingNewUser = db.Users.SingleOrDefault(x => x.Email.ToLower() == email.New.ToLower()); + if (existingNewUser != null) + { + Console.WriteLine($"Deleting existing new user for {existingNewUser.Email}..."); + db.Users.Remove(existingNewUser); + db.SaveChanges(); + } + + user.Email = email.New; + + if (user.Contact.Email.ToLower() == email.Old.ToLower()) + { + user.Contact.Email = email.New; + } + + Console.WriteLine($"Modifying {catalog} {email.Old} => {email.New}"); + db.SaveChanges(); + } + } + } + + Console.ForegroundColor = ConsoleColor.Green; + Console.WriteLine(); + Console.WriteLine("DONE"); + } + } +} diff --git a/Software/Visual_Studio/Utilities/Tango.BulkEmailModifier.CLI/Properties/AssemblyInfo.cs b/Software/Visual_Studio/Utilities/Tango.BulkEmailModifier.CLI/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..71ba01d8a --- /dev/null +++ b/Software/Visual_Studio/Utilities/Tango.BulkEmailModifier.CLI/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Tango.BulkEmailModifier.CLI")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Tango.BulkEmailModifier.CLI")] +[assembly: AssemblyCopyright("Copyright © 2022")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("da4fca0b-e0ea-431f-b0cc-aa9b0a4c73c2")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// 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("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Software/Visual_Studio/Utilities/Tango.BulkEmailModifier.CLI/Tango.BulkEmailModifier.CLI.csproj b/Software/Visual_Studio/Utilities/Tango.BulkEmailModifier.CLI/Tango.BulkEmailModifier.CLI.csproj new file mode 100644 index 000000000..6343e017a --- /dev/null +++ b/Software/Visual_Studio/Utilities/Tango.BulkEmailModifier.CLI/Tango.BulkEmailModifier.CLI.csproj @@ -0,0 +1,79 @@ + + + + + Debug + AnyCPU + {DA4FCA0B-E0EA-431F-B0CC-AA9B0A4C73C2} + Exe + Tango.BulkEmailModifier.CLI + Tango.BulkEmailModifier.CLI + v4.6.1 + 512 + true + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll + + + ..\..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll + + + + + + + + + + + + + + + + + + + + PreserveNewest + + + + + + {f441feee-322a-4943-b566-110e12fd3b72} + Tango.BL + + + {A34EE0F0-649D-41C8-8489-B6F1CC6924EE} + Tango.Core + + + {58e8825f-0c96-449c-b320-1e82b0aa876b} + Tango.CSV + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/Utilities/Tango.BulkEmailModifier.CLI/packages.config b/Software/Visual_Studio/Utilities/Tango.BulkEmailModifier.CLI/packages.config new file mode 100644 index 000000000..b3daf0d6c --- /dev/null +++ b/Software/Visual_Studio/Utilities/Tango.BulkEmailModifier.CLI/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file -- cgit v1.3.1