aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Utilities/Tango.CctOptimizer.CLI
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Visual_Studio/Utilities/Tango.CctOptimizer.CLI')
-rw-r--r--Software/Visual_Studio/Utilities/Tango.CctOptimizer.CLI/App.config28
-rw-r--r--Software/Visual_Studio/Utilities/Tango.CctOptimizer.CLI/Program.cs187
-rw-r--r--Software/Visual_Studio/Utilities/Tango.CctOptimizer.CLI/Properties/AssemblyInfo.cs36
-rw-r--r--Software/Visual_Studio/Utilities/Tango.CctOptimizer.CLI/Tango.CctOptimizer.CLI.csproj71
-rw-r--r--Software/Visual_Studio/Utilities/Tango.CctOptimizer.CLI/packages.config4
5 files changed, 0 insertions, 326 deletions
diff --git a/Software/Visual_Studio/Utilities/Tango.CctOptimizer.CLI/App.config b/Software/Visual_Studio/Utilities/Tango.CctOptimizer.CLI/App.config
deleted file mode 100644
index a46da65da..000000000
--- a/Software/Visual_Studio/Utilities/Tango.CctOptimizer.CLI/App.config
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<configuration>
- <configSections>
- <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
- <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
- </configSections>
- <startup>
- <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
- </startup>
- <entityFramework>
- <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
- <providers>
- <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
- </providers>
- </entityFramework>
- <runtime>
- <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
- <dependentAssembly>
- <assemblyIdentity name="Microsoft.IdentityModel.Clients.ActiveDirectory" publicKeyToken="31bf3856ad364e35" culture="neutral" />
- <bindingRedirect oldVersion="0.0.0.0-5.0.5.0" newVersion="5.0.5.0" />
- </dependentAssembly>
- <dependentAssembly>
- <assemblyIdentity name="Z.EntityFramework.Extensions" publicKeyToken="59b66d028979105b" culture="neutral" />
- <bindingRedirect oldVersion="0.0.0.0-4.0.50.0" newVersion="4.0.50.0" />
- </dependentAssembly>
- </assemblyBinding>
- </runtime>
-</configuration> \ No newline at end of file
diff --git a/Software/Visual_Studio/Utilities/Tango.CctOptimizer.CLI/Program.cs b/Software/Visual_Studio/Utilities/Tango.CctOptimizer.CLI/Program.cs
deleted file mode 100644
index 2306163d1..000000000
--- a/Software/Visual_Studio/Utilities/Tango.CctOptimizer.CLI/Program.cs
+++ /dev/null
@@ -1,187 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using Tango.BL;
-using Tango.BL.Entities;
-using Tango.Core;
-using Tango.Core.Helpers;
-
-namespace Tango.CctOptimizer.CLI
-{
- class Program
- {
- static void Main(string[] args)
- {
- DataSource dataSource = new DataSource();
- dataSource.Catalog = "Tango_TEST";
- dataSource.Address = "twine.database.windows.net";
- dataSource.IntegratedSecurity = false;
- dataSource.UserName = "Roy";
- dataSource.Password = "Aa123456";
-
- RESTART:
-
- Console.Write("Checking CCT Optimizations...");
-
- long totalBytes = 0;
-
- List<Cct> toRemove = new List<Cct>();
- List<Cct> allCCT = new List<Cct>();
- List<Rml> allRmls = new List<Rml>();
-
- try
- {
- using (ObservablesContext db = ObservablesContext.CreateDefault(dataSource))
- {
- allRmls = db.Rmls.Where(x => x.CctGuid != null).ToList();
-
- var cctsGuids = db.Ccts.Select(x => x.Guid).ToList();
- int cctCount = cctsGuids.Count;
- int cctCounter = 0;
-
- foreach (var guid in cctsGuids)
- {
- var cct = db.Ccts.SingleOrDefault(x => x.Guid == guid);
- allCCT.Add(cct);
- cctCounter++;
- ClearCurrentConsoleLine();
- Console.Write($"Checking CCT Optimizations... {(int)((double)cctCounter / (double)cctCount * 100d)}%");
- }
-
- Console.WriteLine();
- Console.WriteLine();
-
- //NOT USED
- var notUsedCCT = allCCT.Where(x => !allRmls.Exists(y => y.CctGuid == x.Guid)).ToList();
-
- Console.WriteLine($"Not used CCT ({notUsedCCT.Count}):");
- Console.WriteLine("---------------------------------------");
- foreach (var cct in notUsedCCT)
- {
- long length = cct.Data != null ? cct.Data.Length : 0;
- totalBytes += length;
- toRemove.Add(cct);
- Console.WriteLine($"{(cct.FileName != null ? cct.FileName : "N/A")} - {FileHelper.GetFriendlyFileSize(length)}");
- }
-
- //DUPLICATES
- List<Cct> toExamine = allCCT.Where(x => x.FileName != null).Where(x => !notUsedCCT.Contains(x)).ToList();
- List<Cct> uniqueCCTs = toExamine.DistinctBy(x => x.FileName).ToList();
- List<Cct> duplicates = new List<Cct>();
-
- foreach (var cct in toExamine)
- {
- if (uniqueCCTs.Exists(x => x != cct && x.FileName == cct.FileName))
- {
- duplicates.Add(cct);
- }
- }
-
- Console.WriteLine();
- Console.WriteLine();
- Console.WriteLine($"Duplicates CCT ({duplicates.Count}):");
- Console.WriteLine("---------------------------------------");
- foreach (var duplicateGroup in duplicates.GroupBy(x => x.FileName))
- {
- long length = duplicateGroup.First().Data != null ? duplicateGroup.First().Data.Length * duplicateGroup.Count() : 0;
- totalBytes += length;
-
- foreach (var cct in duplicateGroup)
- {
- toRemove.Add(cct);
- }
-
- Console.WriteLine($"{(duplicateGroup.First().FileName != null ? duplicateGroup.First().FileName : "N/A")} - {FileHelper.GetFriendlyFileSize(length)} {(duplicateGroup.Count() > 1 ? $"X{duplicateGroup.Count()}" : String.Empty)}");
- }
-
- Console.WriteLine();
- Console.WriteLine();
- Console.WriteLine($"Total CCT's found: {allCCT.Count}");
- Console.WriteLine($"Optimization will delete {toRemove.Count} CCT records ({FileHelper.GetFriendlyFileSize(totalBytes)})");
- Console.WriteLine();
-
- if (toRemove.Count > 0)
- {
- Console.Write("Press 'Y' to start optimization procedure.");
- var key = Console.ReadKey();
-
- if (key.Key != ConsoleKey.Y)
- {
- Environment.Exit(0);
- return;
- }
- }
- else
- {
- Console.WriteLine("Press enter to exit to optimizer...");
- Console.ReadLine();
- Environment.Exit(0);
- return;
- }
-
-
- //Reassign RMLs from duplicates...
- Console.WriteLine();
- Console.WriteLine();
- Console.WriteLine("Reassigning RMLs CCTS...");
- Console.WriteLine("---------------------------------------");
- Console.WriteLine();
-
- foreach (var rml in allRmls)
- {
- var duplicateCCT = duplicates.SingleOrDefault(x => x.Guid == rml.CctGuid);
-
- if (duplicateCCT != null)
- {
- var uniqueCCT = uniqueCCTs.SingleOrDefault(x => x.FileName == duplicateCCT.FileName);
- Console.WriteLine($"Reassigning RML '{rml.Name}' to '{uniqueCCT.FileName} (ID: {uniqueCCT.ID})'...");
- rml.CctGuid = uniqueCCT.Guid;
- db.SaveChanges();
- }
- }
-
- //Remove unused and duplicate CCTs...
- Console.WriteLine();
- Console.WriteLine();
- Console.WriteLine("Removing CCT's...");
- Console.WriteLine("---------------------------------------");
- Console.WriteLine();
-
- foreach (var cct in toRemove)
- {
- Console.WriteLine($"Removing '{cct.FileName}' ID: {cct.ID}...");
- cct.DeleteCascadeAsync(db).Wait();
- }
-
- Console.WriteLine();
- Console.WriteLine();
- Console.WriteLine("Optimization Completed.");
- Console.WriteLine();
- Console.WriteLine();
- goto RESTART;
- }
- }
- catch (Exception ex)
- {
- Console.WriteLine();
- Console.WriteLine();
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine("Error occurred while trying to perform the optimization.");
- Console.WriteLine(ex.ToString());
- Console.WriteLine();
- Console.WriteLine();
- Console.ReadLine();
- }
- }
-
- public static void ClearCurrentConsoleLine()
- {
- int currentLineCursor = Console.CursorTop;
- Console.SetCursorPosition(0, Console.CursorTop);
- Console.Write(new string(' ', Console.WindowWidth));
- Console.SetCursorPosition(0, currentLineCursor);
- }
- }
-}
diff --git a/Software/Visual_Studio/Utilities/Tango.CctOptimizer.CLI/Properties/AssemblyInfo.cs b/Software/Visual_Studio/Utilities/Tango.CctOptimizer.CLI/Properties/AssemblyInfo.cs
deleted file mode 100644
index 38926dca0..000000000
--- a/Software/Visual_Studio/Utilities/Tango.CctOptimizer.CLI/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-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.CctOptimizer.CLI")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("Tango.CctOptimizer.CLI")]
-[assembly: AssemblyCopyright("Copyright © 2020")]
-[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("69168924-9aa8-447d-ad64-f07dbf4f0909")]
-
-// 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.CctOptimizer.CLI/Tango.CctOptimizer.CLI.csproj b/Software/Visual_Studio/Utilities/Tango.CctOptimizer.CLI/Tango.CctOptimizer.CLI.csproj
deleted file mode 100644
index 14dd0b54b..000000000
--- a/Software/Visual_Studio/Utilities/Tango.CctOptimizer.CLI/Tango.CctOptimizer.CLI.csproj
+++ /dev/null
@@ -1,71 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProjectGuid>{69168924-9AA8-447D-AD64-F07DBF4F0909}</ProjectGuid>
- <OutputType>Exe</OutputType>
- <RootNamespace>Tango.CctOptimizer.CLI</RootNamespace>
- <AssemblyName>Tango.CctOptimizer.CLI</AssemblyName>
- <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
- <FileAlignment>512</FileAlignment>
- <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
- <Deterministic>true</Deterministic>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- <PlatformTarget>AnyCPU</PlatformTarget>
- <DebugSymbols>true</DebugSymbols>
- <DebugType>full</DebugType>
- <Optimize>false</Optimize>
- <OutputPath>bin\Debug\</OutputPath>
- <DefineConstants>DEBUG;TRACE</DefineConstants>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- <PlatformTarget>AnyCPU</PlatformTarget>
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- <OutputPath>bin\Release\</OutputPath>
- <DefineConstants>TRACE</DefineConstants>
- <ErrorReport>prompt</ErrorReport>
- <WarningLevel>4</WarningLevel>
- </PropertyGroup>
- <ItemGroup>
- <Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
- <HintPath>..\..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll</HintPath>
- </Reference>
- <Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
- <HintPath>..\..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll</HintPath>
- </Reference>
- <Reference Include="System" />
- <Reference Include="System.ComponentModel.DataAnnotations" />
- <Reference Include="System.Core" />
- <Reference Include="System.Xml.Linq" />
- <Reference Include="System.Data.DataSetExtensions" />
- <Reference Include="Microsoft.CSharp" />
- <Reference Include="System.Data" />
- <Reference Include="System.Net.Http" />
- <Reference Include="System.Xml" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="Program.cs" />
- <Compile Include="Properties\AssemblyInfo.cs" />
- </ItemGroup>
- <ItemGroup>
- <None Include="App.config" />
- <None Include="packages.config" />
- </ItemGroup>
- <ItemGroup>
- <ProjectReference Include="..\..\Tango.BL\Tango.BL.csproj">
- <Project>{f441feee-322a-4943-b566-110e12fd3b72}</Project>
- <Name>Tango.BL</Name>
- </ProjectReference>
- <ProjectReference Include="..\..\Tango.Core\Tango.Core.csproj">
- <Project>{a34ee0f0-649d-41c8-8489-b6f1cc6924ee}</Project>
- <Name>Tango.Core</Name>
- </ProjectReference>
- </ItemGroup>
- <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
-</Project> \ No newline at end of file
diff --git a/Software/Visual_Studio/Utilities/Tango.CctOptimizer.CLI/packages.config b/Software/Visual_Studio/Utilities/Tango.CctOptimizer.CLI/packages.config
deleted file mode 100644
index b3daf0d6c..000000000
--- a/Software/Visual_Studio/Utilities/Tango.CctOptimizer.CLI/packages.config
+++ /dev/null
@@ -1,4 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<packages>
- <package id="EntityFramework" version="6.2.0" targetFramework="net461" />
-</packages> \ No newline at end of file