DESKTOP-LJ825E1\Admin před 1 rokem
revize
ad88d2ca3f
100 změnil soubory, kde provedl 18756 přidání a 0 odebrání
  1. 362 0
      .gitignore
  2. binární
      REPORT_VAS_Final.xlsx
  3. 25 0
      SuperCms.sln
  4. 18 0
      SuperCms/.config/dotnet-tools.json
  5. 1242 0
      SuperCms/Controllers/BaseController.cs
  6. 1122 0
      SuperCms/Controllers/ConfigController.cs
  7. 261 0
      SuperCms/Controllers/HomeController.cs
  8. 515 0
      SuperCms/Controllers/OracleController.cs
  9. 28 0
      SuperCms/Controllers/PartialController.cs
  10. 348 0
      SuperCms/Controllers/RegistryController.cs
  11. 807 0
      SuperCms/Controllers/ReportController.cs
  12. 134 0
      SuperCms/Controllers/StockController.cs
  13. 329 0
      SuperCms/Controllers/SupportController.cs
  14. 3097 0
      SuperCms/Controllers/UtilsController.cs
  15. 23 0
      SuperCms/Database/ConnCkData.cs
  16. 20 0
      SuperCms/Database/ConnCkNganh.cs
  17. 137 0
      SuperCms/Database/ModelContext.cs
  18. 33 0
      SuperCms/Extensions/SessionExtensions.cs
  19. binární
      SuperCms/Files/Invoices/13_06_2022/1_TELEMOR_invoice_GTS.docx
  20. binární
      SuperCms/Files/Invoices/23_07_2021/10_invoice_INTERLAND.xlsx
  21. binární
      SuperCms/Files/Invoices/23_07_2021/1_invoice_GTS.docx
  22. binární
      SuperCms/Files/Invoices/23_07_2021/2_invoice_GTS.docx
  23. binární
      SuperCms/Files/Invoices/23_07_2021/3_invoice_GTS.docx
  24. binární
      SuperCms/Files/Invoices/23_07_2021/4_invoice_GTS.docx
  25. binární
      SuperCms/Files/Invoices/23_07_2021/5_invoice_VIETTECH.docx
  26. binární
      SuperCms/Files/Invoices/23_07_2021/6_invoice_VIETTECH.docx
  27. binární
      SuperCms/Files/Invoices/23_07_2021/7_invoice_VIETTECH.docx
  28. binární
      SuperCms/Files/Invoices/23_07_2021/8_invoice_INTERLAND.xlsx
  29. binární
      SuperCms/Files/Invoices/23_07_2021/9_invoice_INTERLAND.xlsx
  30. binární
      SuperCms/Files/Payments/13_06_2022/1_3_payment_GTS.docx
  31. binární
      SuperCms/Files/Payments/13_06_2022/1_TELEMOR_payment_GTS.docx
  32. binární
      SuperCms/Files/Payments/22_07_2021/10_payment_INTERLAND.docx
  33. binární
      SuperCms/Files/Payments/22_07_2021/1_payment_GTS.docx
  34. binární
      SuperCms/Files/Payments/22_07_2021/2_payment_GTS.docx
  35. binární
      SuperCms/Files/Payments/22_07_2021/3_payment_GTS.docx
  36. binární
      SuperCms/Files/Payments/22_07_2021/4_payment_GTS.docx
  37. binární
      SuperCms/Files/Payments/22_07_2021/5_payment_VIETTECH.docx
  38. binární
      SuperCms/Files/Payments/22_07_2021/6_payment_VIETTECH.docx
  39. binární
      SuperCms/Files/Payments/22_07_2021/7_payment_VIETTECH.docx
  40. binární
      SuperCms/Files/Payments/22_07_2021/8_payment_INTERLAND.docx
  41. binární
      SuperCms/Files/Payments/22_07_2021/9_payment_INTERLAND.docx
  42. binární
      SuperCms/Files/Payments/23_07_2021/10_payment_INTERLAND.docx
  43. binární
      SuperCms/Files/Payments/23_07_2021/1_payment_GTS.docx
  44. binární
      SuperCms/Files/Payments/23_07_2021/2_payment_GTS.docx
  45. binární
      SuperCms/Files/Payments/23_07_2021/3_payment_GTS.docx
  46. binární
      SuperCms/Files/Payments/23_07_2021/4_payment_GTS.docx
  47. binární
      SuperCms/Files/Payments/23_07_2021/5_payment_VIETTECH.docx
  48. binární
      SuperCms/Files/Payments/23_07_2021/6_payment_VIETTECH.docx
  49. binární
      SuperCms/Files/Payments/23_07_2021/7_payment_VIETTECH.docx
  50. binární
      SuperCms/Files/Payments/23_07_2021/8_payment_INTERLAND.docx
  51. binární
      SuperCms/Files/Payments/23_07_2021/9_payment_INTERLAND.docx
  52. binární
      SuperCms/Files/Template/template.xlsx
  53. binární
      SuperCms/Files/Template/template2.xlsx
  54. 84 0
      SuperCms/Models/BotStructure.cs
  55. 70 0
      SuperCms/Models/Config.cs
  56. 38 0
      SuperCms/Models/ConfigViewModel.cs
  57. 75 0
      SuperCms/Models/ConnCompany.cs
  58. 96 0
      SuperCms/Models/ConnConfig.cs
  59. 80 0
      SuperCms/Models/ConnData.cs
  60. 71 0
      SuperCms/Models/ConnTelco.cs
  61. 28 0
      SuperCms/Models/Contract.cs
  62. 11 0
      SuperCms/Models/ErrorViewModel.cs
  63. 84 0
      SuperCms/Models/GroupStructure.cs
  64. 46 0
      SuperCms/Models/HomeViewModel.cs
  65. 16 0
      SuperCms/Models/PartialViewModel.cs
  66. 9 0
      SuperCms/Models/RegistryViewModel.cs
  67. 88 0
      SuperCms/Models/ReportViewModel.cs
  68. 63 0
      SuperCms/Models/ResponseStructure.cs
  69. 90 0
      SuperCms/Models/ScheduleStructure.cs
  70. 80 0
      SuperCms/Models/SendMail.cs
  71. 16 0
      SuperCms/Models/StockViewModel.cs
  72. 15 0
      SuperCms/Models/SupportViewModel.cs
  73. 78 0
      SuperCms/Oracle/OracleDynamicParameters.cs
  74. 41 0
      SuperCms/Program.cs
  75. 27 0
      SuperCms/Properties/launchSettings.json
  76. 45 0
      SuperCms/Repositories/ISuperCmsRepo.cs
  77. 959 0
      SuperCms/Repositories/SuperCmsRepo.cs
  78. binární
      SuperCms/Resources/ITL.jpg
  79. binární
      SuperCms/Resources/Mountain-200.jpg
  80. binární
      SuperCms/Resources/Mountain-300.jpg
  81. binární
      SuperCms/Resources/PAYMENT REQUEST ALL.docx
  82. binární
      SuperCms/Resources/Sample.docx
  83. binární
      SuperCms/Resources/gts.jpg
  84. binární
      SuperCms/Resources/payment - Copy.docx
  85. binární
      SuperCms/Resources/payment.docx
  86. 12 0
      SuperCms/Resources/payment.html
  87. 12 0
      SuperCms/Resources/payment_EQUIZZ_07_07_2021.html
  88. 12 0
      SuperCms/Resources/payment_FORTUNE_07_07_2021.html
  89. 12 0
      SuperCms/Resources/payment_GAME PORTAL_07_07_2021.html
  90. 12 0
      SuperCms/Resources/payment_HAPPY CALL_07_07_2021.html
  91. 12 0
      SuperCms/Resources/payment_HOROSCOPE_07_07_2021.html
  92. 12 0
      SuperCms/Resources/payment_KARA_07_07_2021.html
  93. 12 0
      SuperCms/Resources/payment_LUCKY CARD_07_07_2021.html
  94. 12 0
      SuperCms/Resources/payment_LUCKY DRAW_07_07_2021.html
  95. 12 0
      SuperCms/Resources/payment_MYCUPID_07_07_2021.html
  96. 12 0
      SuperCms/Resources/payment_T-EVENT _07_07_2021.html
  97. 12 0
      SuperCms/Resources/payment_code.html
  98. 7803 0
      SuperCms/Resources/payment_code_all.html
  99. 12 0
      SuperCms/Resources/payment_code_generate.html
  100. 86 0
      SuperCms/Startup.cs

+ 362 - 0
.gitignore

@@ -0,0 +1,362 @@
+## Ignore Visual Studio temporary files, build results, and
+## files generated by popular Visual Studio add-ons.
+##
+## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
+
+# User-specific files
+*.rsuser
+*.suo
+*.user
+*.userosscache
+*.sln.docstates
+
+# User-specific files (MonoDevelop/Xamarin Studio)
+*.userprefs
+
+# Mono auto generated files
+mono_crash.*
+
+# Build results
+[Dd]ebug/
+[Dd]ebugPublic/
+[Rr]elease/
+[Rr]eleases/
+x64/
+x86/
+[Ww][Ii][Nn]32/
+[Aa][Rr][Mm]/
+[Aa][Rr][Mm]64/
+bld/
+[Bb]in/
+[Oo]bj/
+[Ll]og/
+[Ll]ogs/
+NEducation/Content/assets/imgs/picture/
+NEducation/Content/assets/imgs/picture1/
+# Visual Studio 2015/2017 cache/options directory
+.vs/
+*.vs/
+# Uncomment if you have tasks that create the project's static files in wwwroot
+#wwwroot/
+
+# Visual Studio 2017 auto generated files
+Generated\ Files/
+
+# MSTest test Results
+[Tt]est[Rr]esult*/
+[Bb]uild[Ll]og.*
+
+# NUnit
+*.VisualState.xml
+TestResult.xml
+nunit-*.xml
+
+# Build Results of an ATL Project
+[Dd]ebugPS/
+[Rr]eleasePS/
+dlldata.c
+
+# Benchmark Results
+BenchmarkDotNet.Artifacts/
+
+# .NET Core
+project.lock.json
+project.fragment.lock.json
+artifacts/
+
+# ASP.NET Scaffolding
+ScaffoldingReadMe.txt
+
+# StyleCop
+StyleCopReport.xml
+
+# Files built by Visual Studio
+*_i.c
+*_p.c
+*_h.h
+*.ilk
+*.meta
+*.obj
+*.iobj
+*.pch
+*.pdb
+*.ipdb
+*.pgc
+*.pgd
+*.rsp
+*.sbr
+*.tlb
+*.tli
+*.tlh
+*.tmp
+*.tmp_proj
+*_wpftmp.csproj
+*.log
+*.vspscc
+*.vssscc
+.builds
+*.pidb
+*.svclog
+*.scc
+
+# Chutzpah Test files
+_Chutzpah*
+
+# Visual C++ cache files
+ipch/
+*.aps
+*.ncb
+*.opendb
+*.opensdf
+*.sdf
+*.cachefile
+*.VC.db
+*.VC.VC.opendb
+
+# Visual Studio profiler
+*.psess
+*.vsp
+*.vspx
+*.sap
+
+# Visual Studio Trace Files
+*.e2e
+
+# TFS 2012 Local Workspace
+$tf/
+
+# Guidance Automation Toolkit
+*.gpState
+
+# ReSharper is a .NET coding add-in
+_ReSharper*/
+*.[Rr]e[Ss]harper
+*.DotSettings.user
+
+# TeamCity is a build add-in
+_TeamCity*
+
+# DotCover is a Code Coverage Tool
+*.dotCover
+
+# AxoCover is a Code Coverage Tool
+.axoCover/*
+!.axoCover/settings.json
+
+# Coverlet is a free, cross platform Code Coverage Tool
+coverage*[.json, .xml, .info]
+
+# Visual Studio code coverage results
+*.coverage
+*.coveragexml
+
+# NCrunch
+_NCrunch_*
+.*crunch*.local.xml
+nCrunchTemp_*
+
+# MightyMoose
+*.mm.*
+AutoTest.Net/
+
+# Web workbench (sass)
+.sass-cache/
+
+# Installshield output folder
+[Ee]xpress/
+
+# DocProject is a documentation generator add-in
+DocProject/buildhelp/
+DocProject/Help/*.HxT
+DocProject/Help/*.HxC
+DocProject/Help/*.hhc
+DocProject/Help/*.hhk
+DocProject/Help/*.hhp
+DocProject/Help/Html2
+DocProject/Help/html
+
+# Click-Once directory
+publish/
+References/
+# Publish Web Output
+*.[Pp]ublish.xml
+*.azurePubxml
+# Note: Comment the next line if you want to checkin your web deploy settings,
+# but database connection strings (with potential passwords) will be unencrypted
+*.pubxml
+*.publishproj
+
+# Microsoft Azure Web App publish settings. Comment the next line if you want to
+# checkin your Azure Web App publish settings, but sensitive information contained
+# in these scripts will be unencrypted
+PublishScripts/
+
+# NuGet Packages
+*.nupkg
+# NuGet Symbol Packages
+*.snupkg
+# The packages folder can be ignored because of Package Restore
+**/[Pp]ackages/*
+# except build/, which is used as an MSBuild target.
+!**/[Pp]ackages/build/
+# Uncomment if necessary however generally it will be regenerated when needed
+#!**/[Pp]ackages/repositories.config
+# NuGet v3's project.json files produces more ignorable files
+*.nuget.props
+*.nuget.targets
+
+# Microsoft Azure Build Output
+csx/
+*.build.csdef
+
+# Microsoft Azure Emulator
+ecf/
+rcf/
+
+# Windows Store app package directories and files
+AppPackages/
+BundleArtifacts/
+Package.StoreAssociation.xml
+_pkginfo.txt
+*.appx
+*.appxbundle
+*.appxupload
+
+# Visual Studio cache files
+# files ending in .cache can be ignored
+*.[Cc]ache
+# but keep track of directories ending in .cache
+!?*.[Cc]ache/
+
+# Others
+ClientBin/
+~$*
+*~
+*.dbmdl
+*.dbproj.schemaview
+*.jfm
+*.pfx
+*.publishsettings
+orleans.codegen.cs
+
+# Including strong name files can present a security risk
+# (https://github.com/github/gitignore/pull/2483#issue-259490424)
+#*.snk
+
+# Since there are multiple workflows, uncomment next line to ignore bower_components
+# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
+#bower_components/
+
+# RIA/Silverlight projects
+Generated_Code/
+
+# Backup & report files from converting an old project file
+# to a newer Visual Studio version. Backup files are not needed,
+# because we have git ;-)
+_UpgradeReport_Files/
+Backup*/
+UpgradeLog*.XML
+UpgradeLog*.htm
+ServiceFabricBackup/
+*.rptproj.bak
+
+# SQL Server files
+*.mdf
+*.ldf
+*.ndf
+
+# Business Intelligence projects
+*.rdl.data
+*.bim.layout
+*.bim_*.settings
+*.rptproj.rsuser
+*- [Bb]ackup.rdl
+*- [Bb]ackup ([0-9]).rdl
+*- [Bb]ackup ([0-9][0-9]).rdl
+
+# Microsoft Fakes
+FakesAssemblies/
+
+# GhostDoc plugin setting file
+*.GhostDoc.xml
+
+# Node.js Tools for Visual Studio
+.ntvs_analysis.dat
+node_modules/
+
+# Visual Studio 6 build log
+*.plg
+
+# Visual Studio 6 workspace options file
+*.opt
+
+# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
+*.vbw
+
+# Visual Studio LightSwitch build output
+**/*.HTMLClient/GeneratedArtifacts
+**/*.DesktopClient/GeneratedArtifacts
+**/*.DesktopClient/ModelManifest.xml
+**/*.Server/GeneratedArtifacts
+**/*.Server/ModelManifest.xml
+_Pvt_Extensions
+
+# Paket dependency manager
+.paket/paket.exe
+paket-files/
+
+# FAKE - F# Make
+.fake/
+
+# CodeRush personal settings
+.cr/personal
+
+# Python Tools for Visual Studio (PTVS)
+__pycache__/
+*.pyc
+
+# Cake - Uncomment if you are using it
+# tools/**
+# !tools/packages.config
+
+# Tabs Studio
+*.tss
+
+# Telerik's JustMock configuration file
+*.jmconfig
+
+# BizTalk build output
+*.btp.cs
+*.btm.cs
+*.odx.cs
+*.xsd.cs
+
+# OpenCover UI analysis results
+OpenCover/
+
+# Azure Stream Analytics local run output
+ASALocalRun/
+
+# MSBuild Binary and Structured Log
+*.binlog
+
+# NVidia Nsight GPU debugger configuration file
+*.nvuser
+
+# MFractors (Xamarin productivity tool) working folder
+.mfractor/
+
+# Local History for Visual Studio
+.localhistory/
+
+# BeatPulse healthcheck temp database
+healthchecksdb
+
+# Backup folder for Package Reference Convert tool in Visual Studio 2017
+MigrationBackup/
+
+# Ionide (cross platform F# VS Code tools) working folder
+.ionide/
+
+# Fody - auto-generated XML schema
+FodyWeavers.xsd

binární
REPORT_VAS_Final.xlsx


+ 25 - 0
SuperCms.sln

@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.30611.23
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SuperCms", "SuperCms\SuperCms.csproj", "{C57F3256-4370-45EC-A01C-C18FFED0591D}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Any CPU = Debug|Any CPU
+		Release|Any CPU = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{C57F3256-4370-45EC-A01C-C18FFED0591D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{C57F3256-4370-45EC-A01C-C18FFED0591D}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{C57F3256-4370-45EC-A01C-C18FFED0591D}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{C57F3256-4370-45EC-A01C-C18FFED0591D}.Release|Any CPU.Build.0 = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+	GlobalSection(ExtensibilityGlobals) = postSolution
+		SolutionGuid = {B0B7971D-F0D0-431C-A176-BD9B798CAF27}
+	EndGlobalSection
+EndGlobal

+ 18 - 0
SuperCms/.config/dotnet-tools.json

@@ -0,0 +1,18 @@
+{
+  "version": 1,
+  "isRoot": true,
+  "tools": {
+    "dotnet-ef": {
+      "version": "5.0.1",
+      "commands": [
+        "dotnet-ef"
+      ]
+    },
+    "csharpier": {
+      "version": "0.26.7",
+      "commands": [
+        "dotnet-csharpier"
+      ]
+    }
+  }
+}

+ 1242 - 0
SuperCms/Controllers/BaseController.cs

@@ -0,0 +1,1242 @@
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.IO;
+using System.IO.Compression;
+using System.Linq;
+using System.Net;
+using System.Net.Http;
+using System.Security.Cryptography;
+using System.Threading.Tasks;
+using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Mvc;
+using SuperCms.Database;
+using SuperCms.Models;
+using Syncfusion.Drawing;
+using Syncfusion.XlsIO;
+
+namespace SuperCms.Controllers
+{
+    public class BaseController : Controller
+    {
+        private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof(Program));
+
+        protected string convertToDateTimeServer(String date)
+        {
+            // date: 
+            DateTime oDateFrom = DateTime.Parse(date);
+            string hour = oDateFrom.Hour < 10 ? "0" + oDateFrom.Hour : oDateFrom.Hour.ToString();
+            string minute = oDateFrom.Minute < 10 ? "0" + oDateFrom.Minute : oDateFrom.Minute.ToString();
+            string second = oDateFrom.Second < 10 ? "0" + oDateFrom.Second : oDateFrom.Second.ToString();
+            string month = oDateFrom.Month < 10 ? "0" + oDateFrom.Month : oDateFrom.Month.ToString();
+            string day = oDateFrom.Day < 10 ? "0" + oDateFrom.Day : oDateFrom.Day.ToString();
+            string fromCheck = month + "/" + day + "/" + oDateFrom.Year + " " + hour + ":" + minute + ":" + second;
+            return fromCheck; //yyyy-MM-dd HH24:mm:ss
+        }
+
+        protected string getStartByMonthToString(int monthLeft)
+        {
+            DateTime now = DateTime.Now;
+            DateTime time = new DateTime(now.Year, now.Month, 1, 0, 0, 0);
+            DateTime timeB = time.AddMonths(monthLeft);
+            return timeB.ToString("MM/dd/yyyy HH:mm:ss");
+        }
+
+        protected DateTime getStartByMonthToDate(int monthLeft)
+        {
+            DateTime now = DateTime.Now;
+            DateTime time = new DateTime(now.Year, now.Month, 1, 0, 0, 0);
+            DateTime timeB = time.AddMonths(monthLeft);
+            return timeB;
+        }
+
+        protected DateTime getEndByMonthToDate(int monthLeft)
+        {
+            DateTime now = DateTime.Now;
+            DateTime time = new DateTime(now.Year, now.Month, 1, 23, 59, 59);
+            DateTime timeB = time.AddMonths(monthLeft + 1).AddDays(-1);
+            return timeB;
+        }
+
+        protected DateTime getStartByMonthToDate(DateTime now, int monthLeft)
+        {
+            DateTime time = new DateTime(now.Year, now.Month, 1, 0, 0, 0);
+            DateTime timeB = time.AddMonths(monthLeft);
+            return timeB;
+        }
+
+        protected DateTime getEndByMonthToDate(DateTime now, int monthLeft)
+        {
+            DateTime time = new DateTime(now.Year, now.Month, 1, 23, 59, 59);
+            DateTime timeB = time.AddMonths(monthLeft + 1).AddDays(-1);
+            return timeB;
+        }
+
+        protected string getStartByDayToString()
+        {
+            DateTime now = DateTime.Now;
+            DateTime date = new DateTime(now.Year, now.Month, now.Day, 0, 0, 0);
+            //int dayOfWeek = (int)now.DayOfWeek;
+            return date.AddDays(-(7)).ToString("MM/dd/yyyy HH:mm:ss");
+        }
+
+        protected String getEndByDayToString()
+        {
+            // mm/dd/yyyy hh:MM:ss PT
+            //DateTime now = DateTime.Now;
+
+            // convert to dd/mm/yyyy
+            //return DateTime.Now.ToString("dd/MM/yyyy");
+
+            DateTime now = DateTime.Now;
+            DateTime date = new DateTime(now.Year, now.Month, now.Day, 23, 59, 59);
+            return date.AddDays(0).ToString("MM/dd/yyyy HH:mm:ss");
+        }
+
+        protected DateTime getStartByDayToDate()
+        {
+            DateTime now = DateTime.Now;
+            DateTime date = new DateTime(now.Year, now.Month, now.Day, 0, 0, 0);
+            //int dayOfWeek = (int)now.DayOfWeek;
+            return date.AddDays(-(7));
+        }
+
+        protected DateTime getEndByDayToDate()
+        {
+            // mm/dd/yyyy hh:MM:ss PT
+            //DateTime now = DateTime.Now;
+
+            // convert to dd/mm/yyyy
+            //return DateTime.Now.ToString("dd/MM/yyyy");
+
+            DateTime now = DateTime.Now;
+            DateTime date = new DateTime(now.Year, now.Month, now.Day, 23, 59, 59);
+            return date.AddDays(0);
+        }
+
+        protected List<DateTime> getRangeTime(DateTime start, DateTime end)
+        {
+            TimeSpan difference = end - start;
+
+            List<DateTime> days = new List<DateTime>();
+            //days.Add(DateTime.Now);
+
+            for (int i = difference.Days; i >= 0; i--)
+            {
+                DateTime dateG = start.AddDays(i);
+                DateTime date = new DateTime(dateG.Year, dateG.Month, dateG.Day, 0, 0, 0);
+                days.Add(date);
+            }
+            return days;
+        }
+
+        protected List<DateTime> getRangeTimeForExport(DateTime start, DateTime end)
+        {
+            TimeSpan difference = end - start;
+
+            List<DateTime> days = new List<DateTime>();
+            days.Add(end);
+
+            for (int i = difference.Days; i >= 0; i--)
+            {
+                DateTime dateG = start.AddDays(i);
+                DateTime date = new DateTime(dateG.Year, dateG.Month, dateG.Day, 0, 0, 0);
+                days.Add(date);
+            }
+            return days;
+        }
+
+        protected List<DateTime> getRangeMonth(DateTime start, DateTime end)
+        {
+            DateTime startD = new DateTime(start.Year, start.Month, 1);
+            DateTime endD = new DateTime(end.Year, end.Month, 1);
+            int diffMonths = (endD.Month + endD.Year * 12) - (startD.Month + startD.Year * 12);
+
+            List<DateTime> days = new List<DateTime>();
+            days.Add(end);
+            for (int i = diffMonths; i >= 0; i--)
+            {
+                DateTime dateG = start.AddMonths(i);
+                DateTime date;
+                if (i == 0)
+                {
+                    date = new DateTime(dateG.Year, dateG.Month, dateG.Day, 0, 0, 0);
+                }
+                else
+                {
+                    date = new DateTime(dateG.Year, dateG.Month, 1, 0, 0, 0);
+                }
+                days.Add(date);
+            }
+            return days;
+        }
+
+        protected List<DistributedByTelcoAndCompany> distributedByTelcoAndCompany(ConnTelcos telcos, ConnCompanies companies, ConnConfigs services, int count, List<DistributedByTelcoAndCompany> result)
+        {
+            if (count >= services.data.Count)
+            {
+                return result;
+            }
+            else
+            {
+                ConnConfig service = services.data[count];
+                if (service.companyID == null || service.telcoID == null)
+                {
+                    return distributedByTelcoAndCompany(telcos, companies, services, count + 1, result);
+                }
+                else
+                {
+                    log.Info(service.telcoID + " " + service.serviceName);
+                    List<DistributedByTelcoAndCompany> resultt = result;
+                    DistributedByTelcoAndCompany dis = result.Find(x => x.telco.id == service.telcoID);
+                    if (dis == null)
+                    {
+                        // add telco to result
+                        DistributedByTelcoAndCompany newEle = new DistributedByTelcoAndCompany();
+                        newEle.telco = telcos.data.Find(x => x.id == service.telcoID);
+                        // add company
+                        ConnCompany company = companies.data.Find(x => x.id == service.companyID);
+                        newEle.companies = new ConnCompanies();
+                        newEle.companies.data = new List<ConnCompany>();
+                        newEle.companies.data.Add(company);
+
+                        // add service
+                        newEle.services = new ConnConfigs();
+                        newEle.services.data = new List<ConnConfig>();
+                        newEle.services.data.Add(service);
+
+                        result.Add(newEle);
+                        return distributedByTelcoAndCompany(telcos, companies, services, count + 1, result);
+                    }
+                    else
+                    {
+                        // telco existed, get telco
+                        DistributedByTelcoAndCompany disres = result.Find(x => x.telco.id == service.telcoID);
+                        ConnTelco telco = disres.telco;
+
+                        // check company existed ???
+                        ConnCompany com = disres.companies.data.Find(x => x.id == service.companyID);
+                        if (com == null)
+                        {
+                            // add company
+                            ConnCompany company = companies.data.Find(x => x.id == service.companyID);
+                            result.Where(S => S.telco.id == service.telcoID).Select(S => { S.companies.data.Add(company); return S; }).ToList();
+                        }
+
+                        // check service existed ???
+                        ConnConfig ser = disres.services.data.Find(x => x.id == service.id);
+                        if (ser == null)
+                        {
+                            // add company
+                            result.Where(S => S.telco.id == service.telcoID).Select(S => { S.services.data.Add(service); return S; }).ToList();
+                        }
+                        return distributedByTelcoAndCompany(telcos, companies, services, count + 1, result);
+                    }
+                }
+            }
+        }
+
+        protected IActionResult ToExcelStock(List<DateTime> listdate, Dictionary<ConnCkNganh, Dictionary<DateTime, ConnCkData>> distributionData)
+        {
+            try
+            {
+                using (ExcelEngine excelEngine = new ExcelEngine())
+                {
+                    IApplication application = excelEngine.Excel;
+                    application.DefaultVersion = ExcelVersion.Excel2013;
+                    IWorkbook workbook = application.Workbooks.Create(1);
+
+                    IWorksheet worksheet = workbook.Worksheets[0];
+                    List<RowAttributed> rowAttributedList = new List<RowAttributed>();
+
+                    int rowCount = 1;
+
+                    // for header
+                    worksheet.Range["A1"].Text = "NO";
+                    worksheet.Range["B1"].Text = "NGÀNH";
+                    worksheet.Range["C1"].Text = "CHỈ SỐ";
+
+                    for (int d = 0; d < listdate.Count; d++)
+                    {
+
+                        worksheet.Range[UtilsController.GetExcelColumnName(4 + d * 2) + rowCount.ToString()].Text = listdate[d].ToString("dd/MM");
+                        worksheet.Range[UtilsController.GetExcelColumnName(5 + d * 2) + rowCount.ToString()].Text = "%";
+                    }
+
+                    rowCount++;
+
+
+                    List<double> listTongGiaTri = new List<double>();
+                    List<double> listTongKhoiLuong = new List<double>();
+                    List<double> listTongThayDoi = new List<double>();
+                    List<double> listTongMua = new List<double>();
+                    List<double> listTongBan = new List<double>();
+
+                    for (int d = 0; d < listdate.Count; d++)
+                    {
+                        // tong sum
+                        double tongGiaTri = 0.0;
+                        double tongThayDoi = 0.0;
+                        double tongKhoiLuong = 0.0;
+                        double tongMua = 0.0;
+                        double tongBan = 0.0;
+
+                        for (int k = 0; k < distributionData.Count; k++)
+                        {
+                            Dictionary<DateTime, ConnCkData> dataDateList = distributionData.ElementAt(k).Value;
+                            ConnCkData ckData = dataDateList.ElementAt(d).Value;
+                            if (ckData != null)
+                            {
+                                tongBan += Decimal.ToDouble(ckData.TnnBan ?? 0);
+                                tongMua += Decimal.ToDouble(ckData.TnnMua ?? 0);
+                                tongKhoiLuong += Decimal.ToDouble(ckData.KhoiLuong ?? 0);
+                                //tongThayDoi += Double.Parse(ckData.ThayDoi);
+                                tongGiaTri += Decimal.ToDouble(ckData.GiaTri ?? 0);
+                            }
+                        }
+                        listTongGiaTri.Add(tongGiaTri);
+                        listTongKhoiLuong.Add(tongKhoiLuong);
+                        listTongMua.Add(tongMua);
+                        listTongBan.Add(tongBan);
+                        //listTongThayDoi.Add(tongThayDoi);
+                    }
+
+                    for (int i = 0; i < distributionData.Count; i++)
+                    {
+                        ConnCkNganh nganh = distributionData.ElementAt(i).Key;
+
+                        worksheet.Range[UtilsController.GetExcelColumnName(1) + rowCount.ToString()].Text = (i + 1).ToString();
+                        rowAttributedList = rowHandler(rowAttributedList, new RowAttributed(UtilsController.GetExcelColumnName(1), rowCount.ToString(), true, null, Color.FromArgb(247, 220, 111), 1, 1, 1, 1, null));
+
+                        worksheet.Range[UtilsController.GetExcelColumnName(2) + rowCount.ToString()].Text = nganh.Name.ToString();
+                        rowAttributedList = rowHandler(rowAttributedList, new RowAttributed(UtilsController.GetExcelColumnName(2), rowCount.ToString(), true, null, Color.FromArgb(247, 220, 111), 1, 1, 1, 1, null));
+
+
+                        Dictionary<DateTime, ConnCkData> dataCkList = distributionData.ElementAt(i).Value;
+
+                        // chi so tang giam
+                        worksheet.Range[UtilsController.GetExcelColumnName(3) + rowCount.ToString()].Text = "Tăng / Giảm";
+                        rowAttributedList = rowHandler(rowAttributedList, new RowAttributed(UtilsController.GetExcelColumnName(3), rowCount.ToString(), true, null, Color.FromArgb(247, 220, 111), 1, 1, 1, 1, null));
+
+
+                        for (int j = 0; j < dataCkList.Count; j++)
+                        {
+                            ConnCkData dataCk = dataCkList.ElementAt(j).Value;
+                            rowAttributedList = rowHandler(rowAttributedList, new RowAttributed(UtilsController.GetExcelColumnName(j * 2 + 4), rowCount.ToString(), true, null, Color.FromArgb(247, 220, 111), 1, 1, 1, 1, null));
+                            rowAttributedList = rowHandler(rowAttributedList, new RowAttributed(UtilsController.GetExcelColumnName(j * 2 + 5), rowCount.ToString(), true, null, Color.FromArgb(247, 220, 111), 1, 1, 1, 1, null));
+
+                            if (dataCk != null)
+                            {
+                                worksheet.Range[UtilsController.GetExcelColumnName(j * 2 + 4) + rowCount.ToString()].Text = dataCk.TangGiam.ToString();
+                            }
+                        }
+                        rowCount++;
+
+                        // chi so tang giam
+                        worksheet.Range[UtilsController.GetExcelColumnName(3) + rowCount.ToString()].Text = "Thay đổi";
+
+                        for (int j = 0; j < dataCkList.Count; j++)
+                        {
+                            ConnCkData dataCk = dataCkList.ElementAt(j).Value;
+                            if (dataCk != null)
+                            {
+                                worksheet.Range[UtilsController.GetExcelColumnName(j * 2 + 4) + rowCount.ToString()].Text = dataCk.ThayDoi.ToString();
+                            }
+                        }
+                        rowCount++;
+
+                        // chi so tang giam
+                        worksheet.Range[UtilsController.GetExcelColumnName(3) + rowCount.ToString()].Text = "Khối lượng";
+                        for (int j = 0; j < dataCkList.Count; j++)
+                        {
+                            ConnCkData dataCk = dataCkList.ElementAt(j).Value;
+                            if (dataCk != null)
+                            {
+                                double percent = Math.Round(Decimal.ToDouble(dataCk.KhoiLuong ?? 0) * 100 / listTongKhoiLuong[j], 2);
+                                worksheet.Range[UtilsController.GetExcelColumnName(j * 2 + 4) + rowCount.ToString()].Text = dataCk.KhoiLuong.ToString();
+                                worksheet.Range[UtilsController.GetExcelColumnName(j * 2 + 5) + rowCount.ToString()].Text = percent.ToString() + "%";
+                            }
+                        }
+                        rowCount++;
+
+                        // chi so tang giam
+                        worksheet.Range[UtilsController.GetExcelColumnName(3) + rowCount.ToString()].Text = "Giá trị";
+                        for (int j = 0; j < dataCkList.Count; j++)
+                        {
+                            ConnCkData dataCk = dataCkList.ElementAt(j).Value;
+                            if (dataCk != null)
+                            {
+                                worksheet.Range[UtilsController.GetExcelColumnName(j * 2 + 4) + rowCount.ToString()].Text = dataCk.GiaTri.ToString();
+                                double percent = Math.Round(Decimal.ToDouble(dataCk.GiaTri ?? 0) * 100 / listTongGiaTri[j], 2);
+                                worksheet.Range[UtilsController.GetExcelColumnName(j * 2 + 4) + rowCount.ToString()].Text = dataCk.GiaTri.ToString();
+                                worksheet.Range[UtilsController.GetExcelColumnName(j * 2 + 5) + rowCount.ToString()].Text = percent.ToString() + "%";
+                            }
+                        }
+                        rowCount++;
+
+                        // chi so tang giam
+                        worksheet.Range[UtilsController.GetExcelColumnName(3) + rowCount.ToString()].Text = "Mua";
+                        for (int j = 0; j < dataCkList.Count; j++)
+                        {
+                            ConnCkData dataCk = dataCkList.ElementAt(j).Value;
+                            if (dataCk != null)
+                            {
+                                double percent = Math.Round(Decimal.ToDouble(dataCk.TnnMua ?? 0) * 100 / listTongMua[j], 2);
+                                worksheet.Range[UtilsController.GetExcelColumnName(j * 2 + 4) + rowCount.ToString()].Text = dataCk.TnnMua.ToString();
+                                worksheet.Range[UtilsController.GetExcelColumnName(j * 2 + 5) + rowCount.ToString()].Text = percent.ToString() + "%";
+                            }
+                        }
+                        rowCount++;
+
+                        // chi so tang giam
+                        worksheet.Range[UtilsController.GetExcelColumnName(3) + rowCount.ToString()].Text = "Bán";
+                        for (int j = 0; j < dataCkList.Count; j++)
+                        {
+                            ConnCkData dataCk = dataCkList.ElementAt(j).Value;
+                            if (dataCk != null)
+                            {
+                                double percent = Math.Round(Decimal.ToDouble(dataCk.TnnBan ?? 0) * 100 / listTongBan[j], 2);
+                                worksheet.Range[UtilsController.GetExcelColumnName(j * 2 + 4) + rowCount.ToString()].Text = dataCk.TnnBan.ToString();
+                                worksheet.Range[UtilsController.GetExcelColumnName(j * 2 + 5) + rowCount.ToString()].Text = percent.ToString() + "%";
+                            }
+                        }
+                        rowCount++;
+                    }
+
+
+                    // TONG
+                    worksheet.Range[UtilsController.GetExcelColumnName(1) + rowCount.ToString()].Text = (distributionData.Count).ToString();
+                    rowAttributedList = rowHandler(rowAttributedList, new RowAttributed(UtilsController.GetExcelColumnName(1), rowCount.ToString(), true, null, Color.FromArgb(247, 220, 111), 1, 1, 1, 1, null));
+
+                    worksheet.Range[UtilsController.GetExcelColumnName(2) + rowCount.ToString()].Text = "TỔNG".ToString();
+                    rowAttributedList = rowHandler(rowAttributedList, new RowAttributed(UtilsController.GetExcelColumnName(2), rowCount.ToString(), true, null, Color.FromArgb(247, 220, 111), 1, 1, 1, 1, null));
+
+                    // chi so tang giam
+                    worksheet.Range[UtilsController.GetExcelColumnName(3) + rowCount.ToString()].Text = "Khối lượng";
+                    rowAttributedList = rowHandler(rowAttributedList, new RowAttributed(UtilsController.GetExcelColumnName(3), rowCount.ToString(), true, null, Color.FromArgb(247, 220, 111), 1, 1, 1, 1, null));
+
+                    for (int j = 0; j < listTongKhoiLuong.Count; j++)
+                    {
+                        worksheet.Range[UtilsController.GetExcelColumnName(j * 2 + 4) + rowCount.ToString()].Text = listTongKhoiLuong[j].ToString();
+                        rowAttributedList = rowHandler(rowAttributedList, new RowAttributed(UtilsController.GetExcelColumnName(j * 2 + 4), rowCount.ToString(), true, null, Color.FromArgb(247, 220, 111), 1, 1, 1, 1, null));
+                        rowAttributedList = rowHandler(rowAttributedList, new RowAttributed(UtilsController.GetExcelColumnName(j * 2 + 5), rowCount.ToString(), true, null, Color.FromArgb(247, 220, 111), 1, 1, 1, 1, null));
+
+                    }
+                    rowCount++;
+
+                    // chi so tang giam
+                    worksheet.Range[UtilsController.GetExcelColumnName(3) + rowCount.ToString()].Text = "Giá trị";
+                    for (int j = 0; j < listTongGiaTri.Count; j++)
+                    {
+                        worksheet.Range[UtilsController.GetExcelColumnName(j * 2 + 4) + rowCount.ToString()].Text = listTongGiaTri[j].ToString();
+                    }
+                    rowCount++;
+
+                    // chi so tang giam
+                    worksheet.Range[UtilsController.GetExcelColumnName(3) + rowCount.ToString()].Text = "Mua";
+                    for (int j = 0; j < listTongMua.Count; j++)
+                    {
+                        worksheet.Range[UtilsController.GetExcelColumnName(j * 2 + 4) + rowCount.ToString()].Text = listTongMua[j].ToString();
+                    }
+                    rowCount++;
+
+                    // chi so tang giam
+                    worksheet.Range[UtilsController.GetExcelColumnName(3) + rowCount.ToString()].Text = "Bán";
+                    for (int j = 0; j < listTongBan.Count; j++)
+                    {
+                        worksheet.Range[UtilsController.GetExcelColumnName(j * 2 + 4) + rowCount.ToString()].Text = listTongBan[j].ToString();
+                    }
+                    rowCount++;
+
+                    //Formatting
+                    //Global styles should be used when the same style needs to be applied to more than one cell. This usage of a global style reduces memory usage.
+                    //Add custom colors to the palette
+                    workbook.SetPaletteColor(8, Color.FromArgb(255, 174, 33));
+
+                    //Defining header style
+                    IStyle headerStyle = workbook.Styles.Add("HeaderStyle" + 0.ToString());
+                    headerStyle.BeginUpdate();
+                    headerStyle.Color = Color.FromArgb(82, 190, 128);
+                    headerStyle.Font.Bold = true;
+                    headerStyle.Borders[ExcelBordersIndex.EdgeLeft].LineStyle = ExcelLineStyle.Thin;
+                    headerStyle.Borders[ExcelBordersIndex.EdgeRight].LineStyle = ExcelLineStyle.Thin;
+                    headerStyle.Borders[ExcelBordersIndex.EdgeTop].LineStyle = ExcelLineStyle.Thin;
+                    headerStyle.Borders[ExcelBordersIndex.EdgeBottom].LineStyle = ExcelLineStyle.Thin;
+                    headerStyle.EndUpdate();
+
+                    //Apply Header style
+                    worksheet.Rows[0].CellStyle = headerStyle;
+
+                    for (int g = 0; g < rowAttributedList.Count; g++)
+                    {
+                        worksheet.Range[rowAttributedList[g].character + rowAttributedList[g].number].CellStyle = setStyleRowExcel(workbook, 0, rowAttributedList[g]);
+                    }
+
+                    //Auto-fit the columns
+                    worksheet.UsedRange.AutofitColumns();
+
+
+                    //Saving the workbook as stream
+                    //FileStream stream = new FileStream("GlobalStyles.xlsx", FileMode.Create, FileAccess.ReadWrite);
+                    //workbook.SaveAs(stream);
+                    //stream.Dispose();
+                    using (var stream = new MemoryStream())
+                    {
+                        workbook.SaveAs(stream);
+                        var content = stream.ToArray();
+                        return File(
+                            content,
+                            "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
+                            "stock_" + DateTime.Now.ToString("dd_MM") + ".xlsx");
+                    }
+                }
+
+            }
+            catch (Exception ex)
+            {
+                log.Error("Exception: ", ex);
+                return Redirect("/Home");
+            }
+        }
+
+        protected IActionResult Excel(DateTime endDateTime, List<DistributedDataForExcelByOneMonth> dataList, List<DistributedByTime> dataAll)
+        {
+            try
+            {
+                using (ExcelEngine excelEngine = new ExcelEngine())
+                {
+                    IApplication application = excelEngine.Excel;
+                    application.DefaultVersion = ExcelVersion.Excel2013;
+                    IWorkbook workbook = application.Workbooks.Create(dataList.Count);
+
+
+                    for (int i = 0; i < dataList.Count; i++)
+                    {
+                        int rowCount = 1;
+                        List<DistributedByTelcoAndCompany> distributedByTelcoAndCompanyT = new List<DistributedByTelcoAndCompany>();
+                        List<DistributedByTelcoAndCompany> disByTelcoAndCompany = distributedByTelcoAndCompany(dataList[i].telcos, dataList[i].companies, dataList[i].services, 0, distributedByTelcoAndCompanyT);
+                        IWorksheet worksheet = workbook.Worksheets[i];
+
+                        List<RowAttributed> rowAttributedList = new List<RowAttributed>();
+
+                        // for header
+                        worksheet.Range["A1"].Text = "NO";
+                        worksheet.Range["B1"].Text = "VAS CODE";
+                        worksheet.Range["C1"].Text = "Acc now";
+                        worksheet.Range["D1"].Text = "Acc last month";
+                        worksheet.Range["E1"].Text = "+/-";
+                        worksheet.Range["F1"].Text = "%";
+                        rowCount++;
+
+                        disByTelcoAndCompany.Sort(delegate (DistributedByTelcoAndCompany x, DistributedByTelcoAndCompany y)
+                        {
+                            if (x.telco.sequence == null && y.telco.sequence == null) return 0;
+                            else if (x.telco.sequence == null) return -1;
+                            else if (y.telco.sequence == null) return 1;
+                            else return int.Parse(x.telco.sequence).CompareTo(int.Parse(y.telco.sequence));
+                        });
+
+                        // FOR MONEY TABLES
+                        for (int k = 0; k < disByTelcoAndCompany.Count; k++)
+                        {
+                            if (k != 0)
+                            {
+                                rowCount++;
+                            }
+                            // show telco name
+                            worksheet.Range[UtilsController.GetExcelColumnName(1) + rowCount.ToString()].Text = disByTelcoAndCompany[k].telco.telcoName;
+                            worksheet.Range[UtilsController.GetExcelColumnName(1) + rowCount.ToString() + ":" + UtilsController.GetExcelColumnName(6) + rowCount.ToString()].Merge();
+                            rowAttributedList = rowHandler(rowAttributedList, new RowAttributed(UtilsController.GetExcelColumnName(1), rowCount.ToString(), true, null, Color.FromArgb(247, 220, 111), 1, 1, 1, 1, 1));
+                            rowCount++;
+
+
+                            disByTelcoAndCompany[k].companies.data.Sort(delegate (ConnCompany x, ConnCompany y)
+                            {
+                                if (x.sequence == null && y.sequence == null) return 0;
+                                else if (x.sequence == null) return -1;
+                                else if (y.sequence == null) return 1;
+                                else return int.Parse(x.sequence).CompareTo(int.Parse(y.sequence));
+                            });
+
+
+                            for (int c = 0; c < disByTelcoAndCompany[k].companies.data.Count; c++)
+                            {
+                                // show company name
+                                ConnCompany company = disByTelcoAndCompany[k].companies.data[c];
+                                worksheet.Range[UtilsController.GetExcelColumnName(1) + rowCount.ToString()].Text = company.name;
+                                worksheet.Range[UtilsController.GetExcelColumnName(1) + rowCount.ToString() + ":" + UtilsController.GetExcelColumnName(6) + rowCount.ToString()].Merge();
+                                rowAttributedList = rowHandler(rowAttributedList, new RowAttributed(UtilsController.GetExcelColumnName(1), rowCount.ToString(), true, null, Color.FromArgb(236, 112, 99), 1, 1, 1, 1, 1));
+                                rowCount++;
+
+                                // show all services which is belong this this company
+                                List<ConnConfig> serviceBelong = disByTelcoAndCompany[k].services.data.FindAll(x => x.companyID == company.id);
+
+                                serviceBelong.Sort(delegate (ConnConfig x, ConnConfig y)
+                                {
+                                    if (x.sequence == null && y.sequence == null) return 0;
+                                    else if (x.sequence == null) return -1;
+                                    else if (y.sequence == null) return 1;
+                                    else return int.Parse(x.sequence).CompareTo(int.Parse(y.sequence));
+                                });
+
+                                for (int s = 0; s < serviceBelong.Count; s++)
+                                {
+                                    ConnConfig service = serviceBelong[s];
+                                    //worksheet.Range[GetExcelColumnName(1) + rowCount.ToString()].Text = service.serviceName;
+                                    //serviceRowList.Add(rowCount);
+                                    //rowCount++;
+
+
+                                    // get the data of this service
+                                    List<DistributedByTime> dataService = dataList[i].distributedByTimes.FindAll(x => x.service.id == service.id);
+                                    DateTime now = DateTime.Now.AddDays(-1);
+
+                                    // get date now
+                                    DistributedByTime dataNow = dataService.Find(x => x.time.ToString("dd/MM/yyyy") == endDateTime.ToString("dd/MM/yyyy"));
+                                    if (dataService.Count > 0)
+                                    {
+                                        // check
+                                        if (dataService[0].time.Month == now.Month)
+                                        {
+                                            for (int d = 1; d < dataList[i].time.Count; d++)
+                                            {
+                                                worksheet.Range[UtilsController.GetExcelColumnName(d + 6) + "1"].Text = dataList[i].time[d].ToString("dd/MM");
+                                            }
+                                        }
+                                        else
+                                        {
+                                            for (int d = 2; d < dataList[i].time.Count; d++)
+                                            {
+                                                worksheet.Range[UtilsController.GetExcelColumnName(d + 5) + "1"].Text = dataList[i].time[d].ToString("dd/MM");
+                                            }
+                                        }
+                                    }
+                                    // get all data in the last month
+                                    // get month now
+
+                                    DateTime startLastMonth = getStartByMonthToDate(dataList[i].time[dataList[i].time.Count - 1], -1);
+                                    DateTime stopLastMonth = getEndByMonthToDate(dataList[i].time[dataList[i].time.Count - 1], -1);
+
+                                    worksheet.Name = getStartByMonthToDate(dataList[i].time[dataList[i].time.Count - 1], 0).ToString("MM yyyy");
+
+                                    List<DistributedByTime> dataLastMonth = dataAll.FindAll(x =>
+                                        DateTime.Compare(startLastMonth, x.time) <= 0 && DateTime.Compare(x.time, stopLastMonth) <= 0 && x.service.id == service.id);
+
+                                    //DateTime startNow = getStartByMonthToDate(0);
+                                    //DateTime stopNow = getEndByDayToDate();
+                                    //List<DistributedByTime> dataThisMonth = dataService.FindAll(x =>
+                                    //    DateTime.Compare(startNow, x.time) <= 0 && DateTime.Compare(x.time, stopNow) <= 0);
+
+                                    // remove the first element
+
+                                    List<DistributedByTime> dataThisMonth = new List<DistributedByTime>();
+                                    for (int h = dataNow != null && dataNow.connDatas != null ? 1 : 0; h < dataService.Count; h++)
+                                    {
+                                        dataThisMonth.Add(dataService[h]);
+                                    }
+
+                                    double newSub = 0, newSubBefore = 0;
+                                    double deactive = 0, deactiveBefore = 0;
+                                    double revenue = 0, revenueBefore = 0;
+                                    double expense = 0, expenseBefore = 0;
+                                    double totalSub = 0, totalSubBefore = 0;
+                                    double benefit = 0, benefitBefore = 0;
+                                    double benefitP = 0, revenueP = 0, expenseP = 0;
+                                    double benefitD = 0, revenueD = 0, expenseD = 0;
+
+                                    int dayMonthNow = dataThisMonth.Count;
+
+                                    //for (int y = 0; y < dataLastMonth.Count; y++)
+                                    //{
+                                    //    if (dataLastMonth[y].connDatas.data.Count > 0)
+                                    //    {
+                                    //        for (int q = 0; q < dayMonthNow; q++)
+                                    //        {
+                                    //            newSubBefore += int.Parse(dataLastMonth[q].connDatas.data[0].registerNew);
+                                    //            deactiveBefore += int.Parse(dataLastMonth[q].connDatas.data[0].deactive);
+                                    //            revenueBefore += int.Parse(dataLastMonth[q].connDatas.data[0].revenue);
+                                    //            expenseBefore += int.Parse(dataLastMonth[q].connDatas.data[0].expense);
+                                    //            totalSubBefore += int.Parse(dataLastMonth[q].connDatas.data[0].totalSub);
+                                    //        }
+                                    //    }
+                                    //}
+
+                                    if (dataLastMonth.Count > 0 && dayMonthNow <= dataLastMonth.Count - 1)
+                                    {
+                                        for (int q = 0; q < dayMonthNow; q++)
+                                        {
+                                            if (dataLastMonth[dataLastMonth.Count - 1 - q].connDatas.data.Count > 0)
+                                            {
+                                                if (dataLastMonth[dataLastMonth.Count - 1 - q].connDatas.data[0].registerNew != null)
+                                                {
+                                                    newSubBefore += double.Parse(dataLastMonth[dataLastMonth.Count - 1 - q].connDatas.data[0].registerNew);
+                                                }
+                                                if (dataLastMonth[dataLastMonth.Count - 1 - q].connDatas.data[0].deactive != null)
+                                                {
+                                                    deactiveBefore += double.Parse(dataLastMonth[dataLastMonth.Count - 1 - q].connDatas.data[0].deactive);
+                                                }
+                                                if (dataLastMonth[dataLastMonth.Count - 1 - q].connDatas.data[0].revenue != null)
+                                                {
+                                                    revenueBefore += double.Parse(dataLastMonth[dataLastMonth.Count - 1 - q].connDatas.data[0].revenue);
+                                                }
+                                                if (dataLastMonth[dataLastMonth.Count - 1 - q].connDatas.data[0].expense != null)
+                                                {
+                                                    expenseBefore += double.Parse(dataLastMonth[dataLastMonth.Count - 1 - q].connDatas.data[0].expense);
+                                                }
+                                                if (dataLastMonth[dataLastMonth.Count - 1 - q].connDatas.data[0].totalSub != null)
+                                                {
+                                                    totalSubBefore += double.Parse(dataLastMonth[dataLastMonth.Count - 1 - q].connDatas.data[0].totalSub);
+                                                }
+                                            }
+                                        }
+                                    }
+
+                                    benefitBefore = revenueBefore - Math.Abs(expenseBefore);
+
+                                    for (int y = 0; y < dataThisMonth.Count; y++)
+                                    {
+                                        if (dataThisMonth[y].connDatas.data.Count > 0)
+                                        {
+                                            if (dataThisMonth[y].connDatas.data[0].registerNew != null)
+                                            {
+                                                newSub += double.Parse(dataThisMonth[y].connDatas.data[0].registerNew);
+                                            }
+                                            if (dataThisMonth[y].connDatas.data[0].deactive != null)
+                                            {
+                                                deactive += double.Parse(dataThisMonth[y].connDatas.data[0].deactive);
+                                            }
+                                            if (dataThisMonth[y].connDatas.data[0].revenue != null)
+                                            {
+                                                revenue += double.Parse(dataThisMonth[y].connDatas.data[0].revenue);
+                                            }
+                                            if (dataThisMonth[y].connDatas.data[0].expense != null)
+                                            {
+                                                expense += double.Parse(dataThisMonth[y].connDatas.data[0].expense);
+                                            }
+                                            if (dataThisMonth[y].connDatas.data[0].totalSub != null)
+                                            {
+                                                totalSub += double.Parse(dataThisMonth[y].connDatas.data[0].totalSub);
+                                            }
+                                        }
+                                    }
+                                    benefit = revenue - Math.Abs(expense);
+
+                                    revenueD = revenue - revenueBefore;
+                                    expenseD = Math.Abs(expense) - Math.Abs(expenseBefore);
+                                    benefitD = benefit - benefitBefore;
+
+                                    revenueP = revenueBefore != 0 ? Math.Round(revenueD * 100 / revenueBefore, 2) : 100;
+                                    expenseP = expenseBefore != 0 ? Math.Round(expenseD * 100 / expenseBefore, 2) : 100;
+                                    benefitP = benefitBefore != 0 ? Math.Round(benefitD * 100 / benefitBefore, 2) : 100;
+
+                                    // show
+                                    worksheet.Range[UtilsController.GetExcelColumnName(2) + rowCount.ToString()].Text = service.serviceName + " NET";
+                                    RowAttributed r3 = new RowAttributed(UtilsController.GetExcelColumnName(2), rowCount.ToString(), true, Color.FromArgb(255, 0, 0), Color.FromArgb(215, 189, 226), 1, 1, 1, 1, null);
+                                    rowAttributedList = rowHandler(rowAttributedList, r3);
+
+                                    worksheet.Range[UtilsController.GetExcelColumnName(3) + rowCount.ToString()].Text = string.Format("{0:#,0}", benefit).ToString();
+                                    rowAttributedList = rowHandler(rowAttributedList, new RowAttributed(UtilsController.GetExcelColumnName(3), rowCount.ToString(), true, Color.FromArgb(255, 0, 0), null, 1, 1, 1, 1, null));
+
+                                    worksheet.Range[UtilsController.GetExcelColumnName(4) + rowCount.ToString()].Text = string.Format("{0:#,0}", benefitBefore).ToString();
+                                    rowAttributedList = rowHandler(rowAttributedList, new RowAttributed(UtilsController.GetExcelColumnName(4), rowCount.ToString(), true, Color.FromArgb(255, 0, 0), null, 1, 1, 1, 1, null));
+
+                                    if (benefitD < 0)
+                                    {
+                                        worksheet.Range[UtilsController.GetExcelColumnName(5) + rowCount.ToString()].Text = "(" + string.Format("{0:#,0}", Math.Abs(benefitD)).ToString() + ")";
+                                        rowAttributedList = rowHandler(rowAttributedList, new RowAttributed(UtilsController.GetExcelColumnName(5), rowCount.ToString(), true, null, null, 1, 1, 1, 1, null));
+
+                                        worksheet.Range[UtilsController.GetExcelColumnName(6) + rowCount.ToString()].Text = string.Format("{0:#,0}", benefitP).ToString() + "%";
+                                        rowAttributedList = rowHandler(rowAttributedList, new RowAttributed(UtilsController.GetExcelColumnName(6), rowCount.ToString(), true, null, null, 1, 1, 1, 1, null));
+                                    }
+                                    else
+                                    {
+                                        worksheet.Range[UtilsController.GetExcelColumnName(5) + rowCount.ToString()].Text = string.Format("{0:#,0}", benefitD).ToString();
+                                        rowAttributedList = rowHandler(rowAttributedList, new RowAttributed(UtilsController.GetExcelColumnName(5), rowCount.ToString(), true, null, null, 1, 1, 1, 1, null));
+
+                                        worksheet.Range[UtilsController.GetExcelColumnName(6) + rowCount.ToString()].Text = string.Format("{0:#,0}", benefitP).ToString() + "%";
+                                        rowAttributedList = rowHandler(rowAttributedList, new RowAttributed(UtilsController.GetExcelColumnName(6), rowCount.ToString(), true, null, null, 1, 1, 1, 1, null));
+
+                                    }
+
+                                    if (dataNow != null && dataNow.connDatas != null && dataNow.connDatas.data.Count > 0)
+                                    {
+                                        double benefitN = 0;
+                                        if (dataNow.connDatas.data[0].revenue != null && dataNow.connDatas.data[0].expense != null)
+                                        {
+                                            benefitN = double.Parse(dataNow.connDatas.data[0].revenue) - Math.Abs(double.Parse(dataNow.connDatas.data[0].expense));
+
+                                        }
+                                        worksheet.Range[UtilsController.GetExcelColumnName(7) + rowCount.ToString()].Text = string.Format("{0:#,0}", benefitN).ToString();
+                                        rowAttributedList = rowHandler(rowAttributedList, new RowAttributed(UtilsController.GetExcelColumnName(7), rowCount.ToString(), true, Color.FromArgb(255, 0, 0), null, 1, 1, 1, 1, null));
+
+                                    }
+                                    for (int l = 0; l < dataThisMonth.Count; l++)
+                                    {
+                                        if (dataThisMonth[l].connDatas.data.Count > 0)
+                                        {
+                                            double benefitT = 0;
+                                            if (dataThisMonth[l].connDatas.data[0].revenue != null && dataThisMonth[l].connDatas.data[0].expense != null)
+                                            {
+                                                benefitT = double.Parse(dataThisMonth[l].connDatas.data[0].revenue) - Math.Abs(double.Parse(dataThisMonth[l].connDatas.data[0].expense));
+                                            }
+                                            worksheet.Range[UtilsController.GetExcelColumnName(dataNow != null ? 7 + l + 1 : 7 + l) + rowCount.ToString()].Text = string.Format("{0:#,0}", benefitT).ToString();
+                                            rowAttributedList = rowHandler(rowAttributedList, new RowAttributed(UtilsController.GetExcelColumnName(dataNow != null ? 7 + l + 1 : 7 + l), rowCount.ToString(), true, Color.FromArgb(255, 0, 0), null, 1, 1, 1, 1, null));
+
+                                        }
+                                    }
+                                    rowCount++;
+
+                                    if (service.state == UtilsController.Constant.ALL_REVEUNUE)
+                                    {
+                                        worksheet.Range[UtilsController.GetExcelColumnName(2) + rowCount.ToString()].Text = service.serviceName;
+                                        rowAttributedList = rowHandler(rowAttributedList, new RowAttributed(UtilsController.GetExcelColumnName(2), rowCount.ToString(), true, null, Color.FromArgb(215, 189, 226), 1, 1, 1, 1, null));
+
+                                        worksheet.Range[UtilsController.GetExcelColumnName(3) + rowCount.ToString()].Text = string.Format("{0:#,0}", revenue).ToString();
+                                        rowAttributedList = rowHandler(rowAttributedList, new RowAttributed(UtilsController.GetExcelColumnName(3), rowCount.ToString(), true, null, null, 1, 1, 1, 1, null));
+
+                                        worksheet.Range[UtilsController.GetExcelColumnName(4) + rowCount.ToString()].Text = string.Format("{0:#,0}", revenueBefore).ToString();
+                                        rowAttributedList = rowHandler(rowAttributedList, new RowAttributed(UtilsController.GetExcelColumnName(4), rowCount.ToString(), true, null, null, 1, 1, 1, 1, null));
+
+
+                                        if (revenueD < 0)
+                                        {
+                                            worksheet.Range[UtilsController.GetExcelColumnName(5) + rowCount.ToString()].Text = "(" + string.Format("{0:#,0}", Math.Abs(revenueD)).ToString() + ")";
+                                            rowAttributedList = rowHandler(rowAttributedList, new RowAttributed(UtilsController.GetExcelColumnName(5), rowCount.ToString(), true, null, null, 1, 1, 1, 1, null));
+
+                                            worksheet.Range[UtilsController.GetExcelColumnName(6) + rowCount.ToString()].Text = string.Format("{0:#,0}", revenueP).ToString() + "%";
+                                            rowAttributedList = rowHandler(rowAttributedList, new RowAttributed(UtilsController.GetExcelColumnName(6), rowCount.ToString(), true, null, null, 1, 1, 1, 1, null));
+                                        }
+                                        else
+                                        {
+                                            worksheet.Range[UtilsController.GetExcelColumnName(5) + rowCount.ToString()].Text = string.Format("{0:#,0}", revenueD).ToString();
+                                            rowAttributedList = rowHandler(rowAttributedList, new RowAttributed(UtilsController.GetExcelColumnName(5), rowCount.ToString(), true, null, null, 1, 1, 1, 1, null));
+
+                                            worksheet.Range[UtilsController.GetExcelColumnName(6) + rowCount.ToString()].Text = string.Format("{0:#,0}", revenueP).ToString() + "%";
+                                            rowAttributedList = rowHandler(rowAttributedList, new RowAttributed(UtilsController.GetExcelColumnName(6), rowCount.ToString(), true, null, null, 1, 1, 1, 1, null));
+                                        }
+
+                                        if (dataNow != null && dataNow.connDatas != null && dataNow.connDatas.data.Count > 0)
+                                        {
+                                            worksheet.Range[UtilsController.GetExcelColumnName(7) + rowCount.ToString()].Text = string.Format("{0:#,0}", double.Parse(dataNow.connDatas.data[0].revenue)).ToString();
+                                            rowAttributedList = rowHandler(rowAttributedList, new RowAttributed(UtilsController.GetExcelColumnName(7), rowCount.ToString(), true, null, null, 1, 1, 1, 1, null));
+
+                                        }
+
+                                        for (int l = 0; l < dataThisMonth.Count; l++)
+                                        {
+                                            if (dataThisMonth[l].connDatas.data.Count > 0)
+                                            {
+                                                worksheet.Range[UtilsController.GetExcelColumnName(dataNow != null ? 7 + l + 1 : 7 + l) + rowCount.ToString()].Text = string.Format("{0:#,0}", double.Parse(dataThisMonth[l].connDatas.data[0].revenue)).ToString();
+                                                rowAttributedList = rowHandler(rowAttributedList, new RowAttributed(UtilsController.GetExcelColumnName(dataNow != null ? 7 + l + 1 : 7 + l), rowCount.ToString(), true, null, null, 1, 1, 1, 1, null));
+
+                                            }
+                                        }
+                                        rowCount++;
+
+                                        worksheet.Range[UtilsController.GetExcelColumnName(2) + rowCount.ToString()].Text = service.serviceName + " COST";
+                                        rowAttributedList = rowHandler(rowAttributedList, new RowAttributed(UtilsController.GetExcelColumnName(2), rowCount.ToString(), true, null, Color.FromArgb(215, 189, 226), 1, 1, 1, 1, null));
+
+                                        worksheet.Range[UtilsController.GetExcelColumnName(3) + rowCount.ToString()].Text = string.Format("{0:#,0}", Math.Abs(expense)).ToString();
+                                        rowAttributedList = rowHandler(rowAttributedList, new RowAttributed(UtilsController.GetExcelColumnName(3), rowCount.ToString(), true, null, null, 1, 1, 1, 1, null));
+
+                                        worksheet.Range[UtilsController.GetExcelColumnName(4) + rowCount.ToString()].Text = string.Format("{0:#,0}", Math.Abs(expenseBefore)).ToString();
+                                        rowAttributedList = rowHandler(rowAttributedList, new RowAttributed(UtilsController.GetExcelColumnName(4), rowCount.ToString(), true, null, null, 1, 1, 1, 1, null));
+
+                                        if (expenseD < 0)
+                                        {
+                                            worksheet.Range[UtilsController.GetExcelColumnName(5) + rowCount.ToString()].Text = "(" + string.Format("{0:#,0}", Math.Abs(expenseD)).ToString() + ")";
+                                            rowAttributedList = rowHandler(rowAttributedList, new RowAttributed(UtilsController.GetExcelColumnName(5), rowCount.ToString(), true, null, null, 1, 1, 1, 1, null));
+
+                                            worksheet.Range[UtilsController.GetExcelColumnName(6) + rowCount.ToString()].Text = string.Format("{0:#,0}", expenseP).ToString() + "%";
+                                            rowAttributedList = rowHandler(rowAttributedList, new RowAttributed(UtilsController.GetExcelColumnName(6), rowCount.ToString(), true, null, null, 1, 1, 1, 1, null));
+
+                                        }
+                                        else
+                                        {
+                                            worksheet.Range[UtilsController.GetExcelColumnName(5) + rowCount.ToString()].Text = string.Format("{0:#,0}", Math.Abs(expenseD)).ToString();
+                                            rowAttributedList = rowHandler(rowAttributedList, new RowAttributed(UtilsController.GetExcelColumnName(5), rowCount.ToString(), true, null, null, 1, 1, 1, 1, null));
+
+                                            worksheet.Range[UtilsController.GetExcelColumnName(6) + rowCount.ToString()].Text = string.Format("{0:#,0}", expenseP).ToString() + "%";
+                                            rowAttributedList = rowHandler(rowAttributedList, new RowAttributed(UtilsController.GetExcelColumnName(6), rowCount.ToString(), true, null, null, 1, 1, 1, 1, null));
+
+                                        }
+
+                                        if (dataNow != null && dataNow.connDatas != null && dataNow.connDatas.data.Count > 0)
+                                        {
+                                            String expenseCheck1 = dataNow.connDatas.data[0].expense != null ? dataNow.connDatas.data[0].expense : "0";
+                                            worksheet.Range[UtilsController.GetExcelColumnName(7) + rowCount.ToString()].Text = string.Format("{0:#,0}", Math.Abs(double.Parse(expenseCheck1))).ToString();
+                                            rowAttributedList = rowHandler(rowAttributedList, new RowAttributed(UtilsController.GetExcelColumnName(7), rowCount.ToString(), true, null, null, 1, 1, 1, 1, null));
+
+                                        }
+                                        for (int l = 0; l < dataThisMonth.Count; l++)
+                                        {
+                                            if (dataThisMonth[l].connDatas.data.Count > 0)
+                                            {
+                                                String expenseCheck = dataThisMonth[l].connDatas.data[0].expense != null ? dataThisMonth[l].connDatas.data[0].expense : "0";
+                                                worksheet.Range[UtilsController.GetExcelColumnName(dataNow != null ? 7 + l + 1 : 7 + l) + rowCount.ToString()].Text = string.Format("{0:#,0}", Math.Abs(double.Parse(expenseCheck))).ToString();
+                                                rowAttributedList = rowHandler(rowAttributedList, new RowAttributed(UtilsController.GetExcelColumnName(dataNow != null ? 7 + l + 1 : 7 + l), rowCount.ToString(), true, null, null, 1, 1, 1, 1, null));
+
+                                            }
+                                        }
+                                        rowCount++;
+                                    }
+                                }
+                                worksheet.Range[UtilsController.GetExcelColumnName(2) + rowCount.ToString()].Text = "TOTAL";
+                                rowCount++;
+                            }
+                        }
+
+
+                        // FOR SUBSCRIBERS TABLES
+                        rowCount += 10;
+                        worksheet.Range[UtilsController.GetExcelColumnName(1) + rowCount.ToString()].Text = "TOTAL SUBSCRIBERS COMPARE LAST MONTH";
+                        worksheet.Range[UtilsController.GetExcelColumnName(1) + rowCount.ToString() + ":" + UtilsController.GetExcelColumnName(6) + rowCount.ToString()].Merge();
+                        rowAttributedList = rowHandler(rowAttributedList, new RowAttributed(UtilsController.GetExcelColumnName(1), rowCount.ToString(), true, Color.FromArgb(0, 0, 0), Color.FromArgb(255, 174, 33), 1, 1, 1, 1, 1));
+                        rowCount++;
+
+                        // for header
+                        worksheet.Range[UtilsController.GetExcelColumnName(1) + rowCount.ToString()].Text = "NO";
+                        worksheet.Range[UtilsController.GetExcelColumnName(2) + rowCount.ToString()].Text = "VAS CODE";
+                        worksheet.Range[UtilsController.GetExcelColumnName(3) + rowCount.ToString()].Text = "Acc now";
+                        worksheet.Range[UtilsController.GetExcelColumnName(4) + rowCount.ToString()].Text = "Acc last month";
+                        worksheet.Range[UtilsController.GetExcelColumnName(5) + rowCount.ToString()].Text = "+/-";
+                        worksheet.Range[UtilsController.GetExcelColumnName(6) + rowCount.ToString()].Text = "%";
+
+                        //for (int d = 1; d < dataList[i].time.Count; d++)
+                        //{
+                        //    worksheet.Range[GetExcelColumnName(d + 6) + "1"].Text = dataList[i].time[d].ToString("dd/MM");
+                        //}
+
+                        //rowCount++;
+
+
+                        for (int k = 0; k < disByTelcoAndCompany.Count; k++)
+                        {
+                            if (k != 0)
+                            {
+                                rowCount++;
+                            }
+                            // show telco name
+                            worksheet.Range[UtilsController.GetExcelColumnName(1) + rowCount.ToString()].Text = disByTelcoAndCompany[k].telco.telcoName;
+                            worksheet.Range[UtilsController.GetExcelColumnName(1) + rowCount.ToString() + ":" + UtilsController.GetExcelColumnName(6) + rowCount.ToString()].Merge();
+                            rowAttributedList = rowHandler(rowAttributedList, new RowAttributed(UtilsController.GetExcelColumnName(1), rowCount.ToString(), true, null, Color.FromArgb(247, 220, 111), 1, 1, 1, 1, 1));
+                            rowCount++;
+
+
+                            disByTelcoAndCompany[k].companies.data.Sort(delegate (ConnCompany x, ConnCompany y)
+                            {
+                                if (x.sequence == null && y.sequence == null) return 0;
+                                else if (x.sequence == null) return -1;
+                                else if (y.sequence == null) return 1;
+                                else return int.Parse(x.sequence).CompareTo(int.Parse(y.sequence));
+                            });
+
+                            for (int c = 0; c < disByTelcoAndCompany[k].companies.data.Count; c++)
+                            {
+                                // show company name
+                                ConnCompany company = disByTelcoAndCompany[k].companies.data[c];
+                                worksheet.Range[UtilsController.GetExcelColumnName(1) + rowCount.ToString()].Text = company.name;
+                                worksheet.Range[UtilsController.GetExcelColumnName(1) + rowCount.ToString() + ":" + UtilsController.GetExcelColumnName(6) + rowCount.ToString()].Merge();
+                                rowAttributedList = rowHandler(rowAttributedList, new RowAttributed(UtilsController.GetExcelColumnName(1), rowCount.ToString(), true, null, Color.FromArgb(236, 112, 99), 1, 1, 1, 1, 1));
+                                rowCount++;
+
+                                // show all services which is belong this this company
+                                List<ConnConfig> serviceBelong = disByTelcoAndCompany[k].services.data.FindAll(x => x.companyID == company.id);
+
+                                serviceBelong.Sort(delegate (ConnConfig x, ConnConfig y)
+                                {
+                                    if (x.sequence == null && y.sequence == null) return 0;
+                                    else if (x.sequence == null) return -1;
+                                    else if (y.sequence == null) return 1;
+                                    else return int.Parse(x.sequence).CompareTo(int.Parse(y.sequence));
+                                });
+
+                                for (int s = 0; s < serviceBelong.Count; s++)
+                                {
+                                    ConnConfig service = serviceBelong[s];
+                                    //worksheet.Range[GetExcelColumnName(1) + rowCount.ToString()].Text = service.serviceName;
+                                    //serviceRowList.Add(rowCount);
+                                    //rowCount++;
+
+
+                                    // get the data of this service
+                                    List<DistributedByTime> dataService = dataList[i].distributedByTimes.FindAll(x => x.service.id == service.id);
+                                    DateTime now = DateTime.Now.AddDays(-1);
+
+                                    // get date now
+                                    DistributedByTime dataNow = dataService.Find(x => x.time.ToString("dd/MM/yyyy") == now.ToString("dd/MM/yyyy"));
+                                    // get all data in the last month
+                                    // get month now
+
+                                    DateTime startLastMonth = getStartByMonthToDate(dataList[i].time[dataList[i].time.Count - 1], -1);
+                                    DateTime stopLastMonth = getEndByMonthToDate(dataList[i].time[dataList[i].time.Count - 1], -1);
+
+                                    worksheet.Name = getStartByMonthToDate(dataList[i].time[dataList[i].time.Count - 1], 0).ToString("MM yyyy");
+
+                                    List<DistributedByTime> dataLastMonth = dataAll.FindAll(x =>
+                                        DateTime.Compare(startLastMonth, x.time) <= 0 && DateTime.Compare(x.time, stopLastMonth) <= 0 && x.service.id == service.id);
+
+                                    //DateTime startNow = getStartByMonthToDate(0);
+                                    //DateTime stopNow = getEndByDayToDate();
+                                    //List<DistributedByTime> dataThisMonth = dataService.FindAll(x =>
+                                    //    DateTime.Compare(startNow, x.time) <= 0 && DateTime.Compare(x.time, stopNow) <= 0);
+
+                                    //List<DistributedByTime> dataThisMonth = dataService;
+                                    List<DistributedByTime> dataThisMonth = new List<DistributedByTime>();
+                                    for (int h = dataNow != null && dataNow.connDatas != null ? 1 : 0; h < dataService.Count; h++)
+                                    {
+                                        dataThisMonth.Add(dataService[h]);
+                                    }
+
+                                    double totalSub = 0, totalSubBefore = 0;
+                                    double totalSubD = 0, totalSubP = 0, totalSubN = 0;
+
+
+                                    if (dataLastMonth.Count > 0 && dataLastMonth[0].connDatas.data.Count > 0)
+                                    {
+                                        totalSubBefore = int.Parse(dataLastMonth[0].connDatas.data[0].totalSub);
+                                    }
+
+                                    if (dataThisMonth.Count > 0 && dataThisMonth[0].connDatas.data.Count > 0)
+                                    {
+                                        totalSub = int.Parse(dataThisMonth[0].connDatas.data[0].totalSub);
+                                    }
+
+                                    totalSubD = totalSub - totalSubBefore;
+                                    totalSubP = totalSubBefore != 0 ? Math.Round(totalSubD * 100 / totalSubBefore, 2) : 100;
+
+                                    // show
+                                    worksheet.Range[UtilsController.GetExcelColumnName(2) + rowCount.ToString()].Text = service.serviceName;
+                                    RowAttributed r3 = new RowAttributed(UtilsController.GetExcelColumnName(2), rowCount.ToString(), true, Color.FromArgb(255, 0, 0), Color.FromArgb(215, 189, 226), 1, 1, 1, 1, null);
+                                    rowAttributedList = rowHandler(rowAttributedList, r3);
+
+                                    worksheet.Range[UtilsController.GetExcelColumnName(3) + rowCount.ToString()].Text = string.Format("{0:#,0}", totalSub).ToString();
+                                    rowAttributedList = rowHandler(rowAttributedList, new RowAttributed(UtilsController.GetExcelColumnName(3), rowCount.ToString(), true, Color.FromArgb(255, 0, 0), null, 1, 1, 1, 1, null));
+
+                                    worksheet.Range[UtilsController.GetExcelColumnName(4) + rowCount.ToString()].Text = string.Format("{0:#,0}", totalSubBefore).ToString();
+                                    rowAttributedList = rowHandler(rowAttributedList, new RowAttributed(UtilsController.GetExcelColumnName(4), rowCount.ToString(), true, Color.FromArgb(255, 0, 0), null, 1, 1, 1, 1, null));
+
+                                    if (totalSubD < 0)
+                                    {
+                                        worksheet.Range[UtilsController.GetExcelColumnName(5) + rowCount.ToString()].Text = "(" + string.Format("{0:#,0}", Math.Abs(totalSubD)).ToString() + ")";
+                                        rowAttributedList = rowHandler(rowAttributedList, new RowAttributed(UtilsController.GetExcelColumnName(5), rowCount.ToString(), true, null, null, 1, 1, 1, 1, null));
+
+                                        worksheet.Range[UtilsController.GetExcelColumnName(6) + rowCount.ToString()].Text = string.Format("{0:#,0}", totalSubP).ToString() + "%";
+                                        rowAttributedList = rowHandler(rowAttributedList, new RowAttributed(UtilsController.GetExcelColumnName(6), rowCount.ToString(), true, null, null, 1, 1, 1, 1, null));
+                                    }
+                                    else
+                                    {
+                                        worksheet.Range[UtilsController.GetExcelColumnName(5) + rowCount.ToString()].Text = string.Format("{0:#,0}", totalSubD).ToString();
+                                        rowAttributedList = rowHandler(rowAttributedList, new RowAttributed(UtilsController.GetExcelColumnName(5), rowCount.ToString(), true, null, null, 1, 1, 1, 1, null));
+
+                                        worksheet.Range[UtilsController.GetExcelColumnName(6) + rowCount.ToString()].Text = string.Format("{0:#,0}", totalSubP).ToString() + "%";
+                                        rowAttributedList = rowHandler(rowAttributedList, new RowAttributed(UtilsController.GetExcelColumnName(6), rowCount.ToString(), true, null, null, 1, 1, 1, 1, null));
+
+                                    }
+
+                                    if (dataNow != null && dataNow.connDatas.data.Count > 0)
+                                    {
+                                        worksheet.Range[UtilsController.GetExcelColumnName(7) + rowCount.ToString()].Text = string.Format("{0:#,0}", double.Parse(dataNow.connDatas.data[0].totalSub)).ToString();
+                                        rowAttributedList = rowHandler(rowAttributedList, new RowAttributed(UtilsController.GetExcelColumnName(7), rowCount.ToString(), true, null, null, 1, 1, 1, 1, null));
+
+                                    }
+                                    for (int l = 0; l < dataThisMonth.Count; l++)
+                                    {
+                                        if (dataThisMonth[l].connDatas.data.Count > 0)
+                                        {
+                                            worksheet.Range[UtilsController.GetExcelColumnName(dataNow != null ? 7 + l + 1 : 7 + l) + rowCount.ToString()].Text = string.Format("{0:#,0}", double.Parse(dataThisMonth[l].connDatas.data[0].totalSub)).ToString();
+                                            rowAttributedList = rowHandler(rowAttributedList, new RowAttributed(UtilsController.GetExcelColumnName(dataNow != null ? 7 + l + 1 : 7 + l), rowCount.ToString(), true, Color.FromArgb(255, 0, 0), null, 1, 1, 1, 1, null));
+                                        }
+                                    }
+                                    rowCount++;
+                                }
+                                worksheet.Range[UtilsController.GetExcelColumnName(2) + rowCount.ToString()].Text = "TOTAL";
+                                rowCount++;
+                            }
+                        }
+
+
+                        //Formatting
+                        //Global styles should be used when the same style needs to be applied to more than one cell. This usage of a global style reduces memory usage.
+                        //Add custom colors to the palette
+                        workbook.SetPaletteColor(8, Color.FromArgb(255, 174, 33));
+
+                        //Defining header style
+                        IStyle headerStyle = workbook.Styles.Add("HeaderStyle" + i.ToString());
+                        headerStyle.BeginUpdate();
+                        headerStyle.Color = Color.FromArgb(82, 190, 128);
+                        headerStyle.Font.Bold = true;
+                        headerStyle.Borders[ExcelBordersIndex.EdgeLeft].LineStyle = ExcelLineStyle.Thin;
+                        headerStyle.Borders[ExcelBordersIndex.EdgeRight].LineStyle = ExcelLineStyle.Thin;
+                        headerStyle.Borders[ExcelBordersIndex.EdgeTop].LineStyle = ExcelLineStyle.Thin;
+                        headerStyle.Borders[ExcelBordersIndex.EdgeBottom].LineStyle = ExcelLineStyle.Thin;
+                        headerStyle.EndUpdate();
+
+                        //Apply Header style
+                        worksheet.Rows[0].CellStyle = headerStyle;
+
+                        for (int g = 0; g < rowAttributedList.Count; g++)
+                        {
+                            worksheet.Range[rowAttributedList[g].character + rowAttributedList[g].number].CellStyle = setStyleRowExcel(workbook, i, rowAttributedList[g]);
+                        }
+
+                        //Auto-fit the columns
+                        worksheet.UsedRange.AutofitColumns();
+                    }
+
+                    //Saving the workbook as stream
+                    //FileStream stream = new FileStream("GlobalStyles.xlsx", FileMode.Create, FileAccess.ReadWrite);
+                    //workbook.SaveAs(stream);
+                    //stream.Dispose();
+                    using (var stream = new MemoryStream())
+                    {
+                        workbook.SaveAs(stream);
+                        var content = stream.ToArray();
+                        return File(
+                            content,
+                            "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
+                            "report_" + DateTime.Now.ToString("dd_MM") + ".xlsx");
+                    }
+                }
+            }
+            catch (Exception ex)
+            {
+                log.Error("Exception: ", ex);
+                return Redirect("/Home");
+            }
+        }
+
+
+
+        private IStyle setStyleRowExcel(IWorkbook workbook, int worksheet, RowAttributed row)
+        {
+            IStyle bodyStyle = workbook.Styles.Add(row.character + row.number + "Style" + worksheet.ToString());
+            bodyStyle.BeginUpdate();
+            if (row.color != null)
+            {
+                bodyStyle.Font.RGBColor = (Color)row.color;
+            }
+            if (row.bold != null)
+            {
+                bodyStyle.Font.Bold = row.bold;
+            }
+            if (row.background != null)
+            {
+                bodyStyle.Color = (Color)row.background;
+            }
+            if (row.thinLeft != null)
+            {
+                bodyStyle.Borders[ExcelBordersIndex.EdgeLeft].LineStyle = ExcelLineStyle.Thin;
+            }
+            if (row.thinRight != null)
+            {
+                bodyStyle.Borders[ExcelBordersIndex.EdgeRight].LineStyle = ExcelLineStyle.Thin;
+            }
+            if (row.thinTop != null)
+            {
+                bodyStyle.Borders[ExcelBordersIndex.EdgeTop].LineStyle = ExcelLineStyle.Thin;
+            }
+            if (row.thinBottom != null)
+            {
+                bodyStyle.Borders[ExcelBordersIndex.EdgeBottom].LineStyle = ExcelLineStyle.Thin;
+            }
+            if (row.center != null)
+            {
+                bodyStyle.HorizontalAlignment = ExcelHAlign.HAlignCenter;
+            }
+            else
+            {
+                bodyStyle.HorizontalAlignment = ExcelHAlign.HAlignLeft;
+            }
+            bodyStyle.EndUpdate();
+            return bodyStyle;
+        }
+
+        private List<RowAttributed> rowHandler(List<RowAttributed> rowList, RowAttributed row)
+        {
+
+            RowAttributed getRow = rowList.Find(x => x.character == row.character && x.number == row.number);
+            if (getRow != null)
+            {
+                rowList.Where(S => S.character == row.character && S.number == row.number).Select(S =>
+                {
+                    S.color = row.color != null ? row.color : S.color;
+                    S.bold = row.bold != null ? row.bold : S.bold;
+                    S.background = row.background != null ? row.background : S.background;
+                    S.thinLeft = row.thinLeft != null ? row.thinLeft : S.thinLeft;
+                    S.thinRight = row.thinRight != null ? row.thinRight : S.thinRight;
+                    S.thinTop = row.thinTop != null ? row.thinTop : S.thinTop;
+                    S.thinBottom = row.thinBottom != null ? row.thinBottom : S.thinBottom;
+                    return S;
+                }).ToList();
+            }
+            else
+            {
+                rowList.Add(row);
+            }
+            return rowList;
+        }
+
+        protected void CreateAuthToken()
+        {
+            // create session authen
+            // Create the random value we will use to secure the session.
+            string authId = GenerateAuthId();
+
+            // Store the value in both our Session and a Cookie.
+            HttpContext.Session.SetString("AuthorizationCookieId", authId);
+            string sessionValue = HttpContext.Session.GetString("AuthorizationCookieId");
+            //CookieOptions option = new CookieOptions
+            //{
+            //    Expires = DateTime.Now.AddMinutes(1)
+            //};
+            //Response.Cookies.Append("Key Name", "Value", option);
+            CookieOptions options = new CookieOptions()
+            {
+                //Path = "/",
+                //HttpOnly = true,
+                //Secure = false,
+                //SameSite = SameSiteMode.None
+                Expires = DateTime.Now.AddMinutes(60)
+            };
+            HttpContext.Response.Cookies.Append("AuthorizationCookie", authId, options);
+            string cookieValue = HttpContext.Request.Cookies["AuthorizationCookie"];
+        }
+        protected bool CheckAuthToken()
+        {
+            string cookieValue = HttpContext.Request.Cookies["AuthorizationCookie"];
+            string sessionValue = HttpContext.Session.GetString("AuthorizationCookieId");
+
+            if (cookieValue == null || sessionValue == null || cookieValue != sessionValue)
+            {
+                // Invalidate the session and log out the current user.
+                return false;
+            }
+            else
+            {
+                return true;
+            }
+        }
+
+        protected bool ClearCache()
+        {
+            HttpContext.Session.Clear();
+            foreach (var cookieKey in HttpContext.Request.Cookies.Keys)
+            {
+                HttpContext.Response.Cookies.Delete(cookieKey);
+            }
+            return true;
+        }
+
+        private string GenerateAuthId()
+        {
+            using (RandomNumberGenerator rng = new RNGCryptoServiceProvider())
+            {
+                byte[] tokenData = new byte[32];
+                rng.GetBytes(tokenData);
+                return Convert.ToBase64String(tokenData);
+            }
+        }
+
+    }
+}

+ 1122 - 0
SuperCms/Controllers/ConfigController.cs

@@ -0,0 +1,1122 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.Logging;
+using SuperCms.Extensions;
+using SuperCms.Models;
+using SuperCms.Repositories;
+
+namespace SuperCms.Controllers
+{
+    public class ConfigController : BaseController
+    {
+        private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof(Program));
+
+        private OracleController oracle;
+
+        ISuperCmsRepo iSuperCmsRepo;
+        public ConfigController(ISuperCmsRepo ISuperCmsRepo)
+        {
+            iSuperCmsRepo = ISuperCmsRepo;
+        }
+
+        public IActionResult Index(String tableType, String page)
+        {
+            try
+            {
+                if (!CheckAuthToken())
+                {
+                    return Redirect("/Home/Login");
+                }
+                oracle = new OracleController(iSuperCmsRepo);
+                String pageNow = page != null ? page : "1";
+                HttpContext.Session.SetComplexData("page", pageNow);
+                String type = tableType != null ? tableType : UtilsController.Constant.BOTS;
+                ConfigViewModel model = new ConfigViewModel();
+
+                ConnTelcos telcos = HttpContext.Session.GetComplexData<ConnTelcos>("telcos");
+                if (telcos == null)
+                {
+                    telcos = oracle.getConnTelcos();
+                    HttpContext.Session.SetComplexData("telcos", telcos);
+                }
+                model.telcos = telcos;
+
+                ConnCompanies companies = HttpContext.Session.GetComplexData<ConnCompanies>("companies");
+                if (companies == null)
+                {
+                    companies = oracle.getConnCompanies();
+                    HttpContext.Session.SetComplexData("companies", companies);
+                }
+                model.companies = companies;
+
+                ConnConfigs services = oracle.getConnConfigs();
+                HttpContext.Session.SetComplexData("services", services);
+                model.services = services;
+
+                // get all bots 
+                BotStructures bots = oracle.getBotstructures();
+                GroupStructures groups = oracle.getGroupstructures();
+                Configs configs = oracle.getConfigs();
+
+                // get all send mail
+                SendMails sendMails = oracle.getSendMails();
+
+                //save to session
+                HttpContext.Session.SetComplexData("configs", configs);
+                HttpContext.Session.SetComplexData("bots", bots);
+                HttpContext.Session.SetComplexData("groups", groups);
+                HttpContext.Session.SetComplexData("sendMails", sendMails);
+                HttpContext.Session.SetComplexData("services", services);
+
+
+                ScheduleStructures schedules = oracle.getSchedulestructures(pageNow, UtilsController.Constant.NUMBER_ROW_ON_PAGE);
+                HttpContext.Session.SetComplexData("schedules", schedules);
+
+                model.totalPage = type == UtilsController.Constant.SERVICE_CONFIG ? "1" : oracle.getTotalRow(type, UtilsController.Constant.NUMBER_ROW_ON_PAGE);
+                model.configs = configs;
+                model.bots = bots;
+                model.groups = groups;
+                model.sendMails = sendMails;
+                model.schedules = schedules;
+                model.services = services;
+                model.companies = companies;
+                model.telcos = telcos;
+
+                model.tableType = type;
+                model.page = pageNow;
+
+                return View("Index", model);
+            }
+            catch (Exception ex)
+            {
+                log.Error("Exception: ", ex);
+                return Redirect("/Home");
+            }
+        }
+
+        public IActionResult ExportSendMail(String tableType, SendMail data)
+        {
+            try
+            {
+                if (!CheckAuthToken())
+                {
+                    return Redirect("/Home/Login");
+                }
+                ConfigViewModel model = new ConfigViewModel();
+                model.tableType = tableType != null ? tableType : UtilsController.Constant.SENDMAIL;
+                ConnTelcos telcos = HttpContext.Session.GetComplexData<ConnTelcos>("telcos");
+                ConnCompanies companies = HttpContext.Session.GetComplexData<ConnCompanies>("companies");
+                ConnConfigs services = HttpContext.Session.GetComplexData<ConnConfigs>("services");
+
+
+                model.telcos = telcos;
+                model.companies = companies;
+                model.services = new ConnConfigs();
+
+                List<DistributedByTelcoAndCompany> disByTelcoAndCompany = HttpContext.Session.GetComplexData<List<DistributedByTelcoAndCompany>>("distributedByTelcoAndCompany");
+                DistributedByTelcoAndCompany dis = disByTelcoAndCompany.Find(x => x.telco.id == data.telcoId);
+
+                if (dis == null)
+                {
+                    model.telco = disByTelcoAndCompany[0].telco;
+                    model.company = disByTelcoAndCompany[0].companies.data[0];
+                    model.services.data = services.data.FindAll(x => x.telcoID == data.telcoId && x.companyID == disByTelcoAndCompany[0].companies.data[0].id);
+                }
+                else
+                {
+                    model.telco = dis.telco;
+                    model.companies = dis.companies;
+                    model.company = data.companyId != null && data.companyId != "null" ? dis.companies.data.Find(x => x.id == data.companyId) : dis.companies.data[0];
+                    model.services.data = services.data.FindAll(x => x.telcoID == data.telcoId && x.companyID == (data.companyId != null && data.companyId != "null" ? data.companyId : dis.companies.data[0].id));
+                }
+                model.sendMail = data;
+                return PartialView("Adding", model);
+            }
+            catch (Exception ex)
+            {
+                return Redirect("/Home");
+            }
+        }
+
+        public IActionResult ExportService(String tableType, ConnConfig data)
+        {
+            try
+            {
+                if (!CheckAuthToken())
+                {
+                    return Redirect("/Home/Login");
+                }
+                ConfigViewModel model = new ConfigViewModel();
+                model.tableType = tableType != null ? tableType : UtilsController.Constant.SERVICE_CONFIG;
+                ConnTelcos telcos = HttpContext.Session.GetComplexData<ConnTelcos>("telcos");
+                ConnCompanies companies = HttpContext.Session.GetComplexData<ConnCompanies>("companies");
+                ConnConfigs services = HttpContext.Session.GetComplexData<ConnConfigs>("services");
+
+
+                model.telcos = telcos;
+                model.companies = companies;
+                model.services = new ConnConfigs();
+
+                List<DistributedByTelcoAndCompany> disByTelcoAndCompany = HttpContext.Session.GetComplexData<List<DistributedByTelcoAndCompany>>("distributedByTelcoAndCompany");
+                DistributedByTelcoAndCompany dis = disByTelcoAndCompany.Find(x => x.telco.id == data.telcoID);
+
+                if (dis == null)
+                {
+                    model.telco = disByTelcoAndCompany[0].telco;
+                    model.company = disByTelcoAndCompany[0].companies.data[0];
+                    model.services.data = services.data.FindAll(x => x.telcoID == data.telcoID && x.companyID == disByTelcoAndCompany[0].companies.data[0].id);
+                }
+                else
+                {
+                    model.telco = dis.telco;
+                    model.companies = dis.companies;
+                    model.company = data.companyID != null && data.companyID != "null" ? dis.companies.data.Find(x => x.id == data.companyID) : dis.companies.data[0];
+                    model.services.data = services.data.FindAll(x => x.telcoID == data.telcoID && x.companyID == (data.companyID != null && data.companyID != "null" ? data.companyID : dis.companies.data[0].id));
+                }
+                model.service = data;
+                return PartialView("Adding", model);
+            }
+            catch (Exception ex)
+            {
+                return Redirect("/Home");
+            }
+        }
+
+        public IActionResult Adding(String tableType)
+        {
+            try
+            {
+                if (!CheckAuthToken())
+                {
+                    return Redirect("/Home/Login");
+                }
+                ConfigViewModel model = new ConfigViewModel();
+                model.bots = new BotStructures();
+                model.groups = new GroupStructures();
+                model.tableType = tableType;
+
+                BotStructures bots = HttpContext.Session.GetComplexData<BotStructures>("bots");
+                GroupStructures groups = HttpContext.Session.GetComplexData<GroupStructures>("groups");
+                Configs configs = HttpContext.Session.GetComplexData<Configs>("configs");
+                SendMails sendMails = HttpContext.Session.GetComplexData<SendMails>("sendMails");
+
+                model.bots.data = bots.data.FindAll(x => x.status != UtilsController.Constant.DISABLE);
+                model.groups.data = groups.data.FindAll(x => x.status != UtilsController.Constant.DISABLE);
+
+                ConnTelcos telcos = HttpContext.Session.GetComplexData<ConnTelcos>("telcos");
+                ConnCompanies companies = HttpContext.Session.GetComplexData<ConnCompanies>("companies");
+
+                model.telcos = telcos;
+                model.companies = companies;
+                List<DistributedByTelcoAndCompany> disByTelcoAndCompany = HttpContext.Session.GetComplexData<List<DistributedByTelcoAndCompany>>("distributedByTelcoAndCompany");
+
+                model.telco = disByTelcoAndCompany[0].telco;
+                model.company = disByTelcoAndCompany[0].companies.data[0];
+                model.services = disByTelcoAndCompany[0].services;
+
+                return PartialView("Adding", model);
+            }
+            catch (Exception ex)
+            {
+                log.Error("Exception: ", ex);
+                return Redirect("/Home");
+            }
+        }
+
+        [ValidateAntiForgeryToken]
+        public JsonResult AddingBotAction(BotStructure data)
+        {
+            try
+            {
+                if (!CheckAuthToken())
+                {
+                    return Json(new
+                    {
+                        code = UtilsController.Constant.ERROR,
+                        href = "/Home/Login"
+                    });
+                }
+                String page = HttpContext.Session.GetComplexData<String>("page");
+                data.startDate = convertToDateTimeServer(data.startDate);
+                data.endDate = convertToDateTimeServer(data.endDate);
+                oracle = new OracleController(iSuperCmsRepo);
+                BotStructures bots = oracle.addingBotStructure(data);
+                if (bots.data.Count > 0)
+                {
+                    return Json(new
+                    {
+                        code = UtilsController.Constant.SUCCESS,
+                        href = "/Config?tableType=" + UtilsController.Constant.BOTS + "&page=" + page,
+                    });
+                }
+                else
+                {
+                    return Json(new
+                    {
+                        code = UtilsController.Constant.ERROR,
+                        href = "/Config?tableType=" + UtilsController.Constant.BOTS + "&page=" + page,
+                    });
+                }
+            }
+            catch (Exception ex)
+            {
+                log.Error("Exception " + ex);
+                return Json(new
+                {
+                    code = UtilsController.Constant.ERROR,
+                    href = "/Home"
+                });
+            }
+        }
+
+        [ValidateAntiForgeryToken]
+        public JsonResult AddingGroupAction(GroupStructure data)
+        {
+            try
+            {
+                if (!CheckAuthToken())
+                {
+                    return Json(new
+                    {
+                        code = UtilsController.Constant.ERROR,
+                        href = "/Home/Login"
+                    });
+                }
+                String page = HttpContext.Session.GetComplexData<String>("page");
+                data.startDate = convertToDateTimeServer(data.startDate);
+                data.endDate = convertToDateTimeServer(data.endDate);
+                oracle = new OracleController(iSuperCmsRepo);
+                GroupStructures groups = oracle.addingGroupStructure(data);
+                if (groups.data.Count > 0)
+                {
+                    return Json(new
+                    {
+                        code = UtilsController.Constant.SUCCESS,
+                        href = "/Config?tableType=" + UtilsController.Constant.GROUPS + "&page=" + page,
+                    });
+                }
+                else
+                {
+                    return Json(new
+                    {
+                        code = UtilsController.Constant.ERROR,
+                        href = "/Config?tableType=" + UtilsController.Constant.GROUPS + "&page=" + page,
+                    });
+                }
+            }
+            catch (Exception ex)
+            {
+                log.Error("Exception " + ex);
+                return Json(new
+                {
+                    code = UtilsController.Constant.ERROR,
+                    href = "/Home"
+                });
+            }
+        }
+
+        [ValidateAntiForgeryToken]
+        public JsonResult AddingScheduleAction(ScheduleStructure data)
+        {
+            try
+            {
+                if (!CheckAuthToken())
+                {
+                    return Json(new
+                    {
+                        code = UtilsController.Constant.ERROR,
+                        href = "/Home/Login"
+                    });
+                }
+                String page = HttpContext.Session.GetComplexData<String>("page");
+                data.timeRun = convertToDateTimeServer(data.timeRun);
+                oracle = new OracleController(iSuperCmsRepo);
+                ScheduleStructures schedules = oracle.addingScheduleStructure(data);
+                if (schedules.data.Count > 0)
+                {
+                    return Json(new
+                    {
+                        code = UtilsController.Constant.SUCCESS,
+                        href = "/Config?tableType=" + UtilsController.Constant.SCHEDULES + "&page=" + page,
+                    });
+                }
+                else
+                {
+                    return Json(new
+                    {
+                        code = UtilsController.Constant.ERROR,
+                        href = "/Config?tableType=" + UtilsController.Constant.SCHEDULES + "&page=" + page,
+                    });
+                }
+            }
+            catch (Exception ex)
+            {
+                log.Error("Exception " + ex);
+                return Json(new
+                {
+                    code = UtilsController.Constant.ERROR,
+                    href = "/Home"
+                });
+            }
+        }
+
+        [ValidateAntiForgeryToken]
+        public JsonResult AddingConfigAction(Config data)
+        {
+            try
+            {
+                if (!CheckAuthToken())
+                {
+                    return Json(new
+                    {
+                        code = UtilsController.Constant.ERROR,
+                        href = "/Home/Login"
+                    });
+                }
+                String page = HttpContext.Session.GetComplexData<String>("page");
+                oracle = new OracleController(iSuperCmsRepo);
+                Configs configs = oracle.addingConfig(data);
+                if (configs.data.Count > 0)
+                {
+                    return Json(new
+                    {
+                        code = UtilsController.Constant.SUCCESS,
+                        href = "/Config?tableType=" + UtilsController.Constant.CONFIGS + "&page=" + page,
+                    });
+                }
+                else
+                {
+                    return Json(new
+                    {
+                        code = UtilsController.Constant.ERROR,
+                        href = "/Config?tableType=" + UtilsController.Constant.CONFIGS + "&page=" + page,
+                    });
+                }
+            }
+            catch (Exception ex)
+            {
+                log.Error("Exception " + ex);
+                return Json(new
+                {
+                    code = UtilsController.Constant.ERROR,
+                    href = "/Home"
+                });
+            }
+        }
+
+        [ValidateAntiForgeryToken]
+        public JsonResult AddingSendMailAction(SendMail data)
+        {
+            try
+            {
+                if (!CheckAuthToken())
+                {
+                    return Json(new
+                    {
+                        code = UtilsController.Constant.ERROR,
+                        href = "/Home/Login"
+                    });
+                }
+                String page = HttpContext.Session.GetComplexData<String>("page");
+                data.timeSend = convertToDateTimeServer(data.timeSend);
+                oracle = new OracleController(iSuperCmsRepo);
+                SendMails sendMails = oracle.addingSendMail(data);
+                if (sendMails.data.Count > 0)
+                {
+                    return Json(new
+                    {
+                        code = UtilsController.Constant.SUCCESS,
+                        href = "/Config?tableType=" + UtilsController.Constant.SENDMAIL + "&page=" + page,
+                    });
+                }
+                else
+                {
+                    return Json(new
+                    {
+                        code = UtilsController.Constant.ERROR,
+                        href = "/Config?tableType=" + UtilsController.Constant.SENDMAIL + "&page=" + page,
+                    });
+                }
+            }
+            catch (Exception ex)
+            {
+                log.Error("Exception " + ex);
+                return Json(new
+                {
+                    code = UtilsController.Constant.ERROR,
+                    href = "/Home"
+                });
+            }
+        }
+
+        [ValidateAntiForgeryToken]
+        public JsonResult AddingServiceAction(ConnConfig data)
+        {
+            try
+            {
+                if (!CheckAuthToken())
+                {
+                    return Json(new
+                    {
+                        code = UtilsController.Constant.ERROR,
+                        href = "/Home/Login"
+                    });
+                }
+                String page = HttpContext.Session.GetComplexData<String>("page");
+                //data.timeSend = convertToDateTimeServer(data.timeSend);
+                ConnTelcos telcos = HttpContext.Session.GetComplexData<ConnTelcos>("telcos");
+                ConnCompanies companies = HttpContext.Session.GetComplexData<ConnCompanies>("companies");
+
+                ConnCompany company = companies.data.Find(x => x.id == data.companyID);
+                ConnTelco telco = telcos.data.Find(x => x.id == data.telcoID);
+                data.telco = telco.telcoName;
+
+                String timeNow = DateTime.Now.ToString("dd/MM/yyyy");
+                data.totalRun = "0";
+                data.dateRun = timeNow;
+                data.dateGet = timeNow;
+                data.hourRun = data.hourRun + ":00";
+
+                oracle = new OracleController(iSuperCmsRepo);
+                ConnConfigs connConfigs = oracle.addConnConfigs(data);
+                if (connConfigs.data.Count > 0)
+                {
+                    return Json(new
+                    {
+                        code = UtilsController.Constant.SUCCESS,
+                        href = "/Config?tableType=" + UtilsController.Constant.SERVICE_CONFIG + "&page=" + page,
+                    });
+                }
+                else
+                {
+                    return Json(new
+                    {
+                        code = UtilsController.Constant.ERROR,
+                        href = "/Config?tableType=" + UtilsController.Constant.SERVICE_CONFIG + "&page=" + page,
+                    });
+                }
+            }
+            catch (Exception ex)
+            {
+                log.Error("Exception " + ex);
+                return Json(new
+                {
+                    code = UtilsController.Constant.ERROR,
+                    href = "/Home"
+                });
+            }
+        }
+
+        public IActionResult Editing(String tableType, String id)
+        {
+            try
+            {
+                if (!CheckAuthToken())
+                {
+                    return Redirect("/Home/Login");
+                }
+                ConfigViewModel model = new ConfigViewModel();
+                model.tableType = tableType;
+                model.bots = new BotStructures();
+                model.groups = new GroupStructures();
+
+                BotStructures bots = HttpContext.Session.GetComplexData<BotStructures>("bots");
+                GroupStructures groups = HttpContext.Session.GetComplexData<GroupStructures>("groups");
+                ScheduleStructures schedules = HttpContext.Session.GetComplexData<ScheduleStructures>("schedules");
+                Configs configs = HttpContext.Session.GetComplexData<Configs>("configs");
+                SendMails sendMails = HttpContext.Session.GetComplexData<SendMails>("sendMails");
+                ConnConfigs connConfigs = HttpContext.Session.GetComplexData<ConnConfigs>("services");
+
+
+                if (tableType == UtilsController.Constant.BOTS)
+                {
+                    BotStructure bot = bots.data.Find(x => x.id == id);
+                    if (bot == null)
+                    {
+                        log.Error("No existed bot: " + id);
+                        return Redirect("/Home");
+                    }
+                    model.bot = bot;
+                    HttpContext.Session.SetComplexData("bot", bot);
+                }
+                else if (tableType == UtilsController.Constant.GROUPS)
+                {
+                    GroupStructure group = groups.data.Find(x => x.id == id);
+                    if (group == null)
+                    {
+                        log.Error("No existed group: " + id);
+                        return Redirect("/Home");
+                    }
+                    model.group = group;
+                    HttpContext.Session.SetComplexData("group", group);
+                }
+                else if (tableType == UtilsController.Constant.SCHEDULES)
+                {
+                    ScheduleStructure schedule = schedules.data.Find(x => x.id == id);
+                    if (schedule == null)
+                    {
+                        log.Error("No existed schedule: " + id);
+                        return Redirect("/Home");
+                    }
+                    model.schedule = schedule;
+                    HttpContext.Session.SetComplexData("schedule", schedule);
+                }
+                else if (tableType == UtilsController.Constant.CONFIGS)
+                {
+                    Config config = configs.data.Find(x => x.id == id);
+                    if (config == null)
+                    {
+                        log.Error("No existed config: " + id);
+                        return Redirect("/Home");
+                    }
+                    model.config = config;
+                    HttpContext.Session.SetComplexData("config", config);
+                }
+                else if (tableType == UtilsController.Constant.SENDMAIL)
+                {
+                    SendMail sendMail = sendMails.data.Find(x => x.id == id);
+                    if (sendMail == null)
+                    {
+                        log.Error("No existed config: " + id);
+                        return Redirect("/Home");
+                    }
+
+                    ConnTelcos telcos = HttpContext.Session.GetComplexData<ConnTelcos>("telcos");
+                    ConnCompanies companies = HttpContext.Session.GetComplexData<ConnCompanies>("companies");
+                    ConnConfigs services = HttpContext.Session.GetComplexData<ConnConfigs>("services");
+                    List<DistributedByTelcoAndCompany> disByTelcoAndCompany = HttpContext.Session.GetComplexData<List<DistributedByTelcoAndCompany>>("distributedByTelcoAndCompany");
+                    DistributedByTelcoAndCompany dis = disByTelcoAndCompany.Find(x => x.telco.id == sendMail.telcoId);
+
+                    model.telcos = telcos;
+                    model.companies = companies;
+                    model.services = new ConnConfigs();
+
+                    if (dis == null)
+                    {
+                        model.telco = disByTelcoAndCompany[0].telco;
+                        model.company = disByTelcoAndCompany[0].companies.data[0];
+                        model.services.data = services.data.FindAll(x => x.telcoID == sendMail.telcoId && x.companyID == disByTelcoAndCompany[0].companies.data[0].id);
+                    }
+                    else
+                    {
+                        model.telco = dis.telco;
+                        model.companies = dis.companies;
+                        model.company = dis.companies.data.Find(x => x.id == sendMail.companyId);
+                        model.services.data = services.data.FindAll(x => x.telcoID == sendMail.telcoId && x.companyID == sendMail.companyId);
+                    }
+                    model.service = services.data.Find(x => x.id == sendMail.serviceId);
+
+                    model.sendMail = sendMail;
+                    HttpContext.Session.SetComplexData("sendMail", sendMail);
+                }
+                else if (tableType == UtilsController.Constant.SERVICE_CONFIG)
+                {
+                    ConnConfig connConfig = connConfigs.data.Find(x => x.id == id);
+                    if (connConfig == null)
+                    {
+                        log.Error("No existed config: " + id);
+                        return Redirect("/Home");
+                    }
+                    ConnTelcos telcos = HttpContext.Session.GetComplexData<ConnTelcos>("telcos");
+                    ConnCompanies companies = HttpContext.Session.GetComplexData<ConnCompanies>("companies");
+                    ConnConfigs services = HttpContext.Session.GetComplexData<ConnConfigs>("services");
+                    List<DistributedByTelcoAndCompany> disByTelcoAndCompany = HttpContext.Session.GetComplexData<List<DistributedByTelcoAndCompany>>("distributedByTelcoAndCompany");
+                    DistributedByTelcoAndCompany dis = disByTelcoAndCompany.Find(x => x.telco.id == connConfig.telcoID);
+
+                    model.telcos = telcos;
+                    model.companies = companies;
+                    model.services = new ConnConfigs();
+                    model.service = connConfig;
+                    if (dis == null)
+                    {
+                        model.telco = disByTelcoAndCompany[0].telco;
+                        model.company = disByTelcoAndCompany[0].companies.data[0];
+                        model.services.data = services.data.FindAll(x => x.telcoID == connConfig.telcoID && x.companyID == disByTelcoAndCompany[0].companies.data[0].id);
+                    }
+                    else
+                    {
+                        model.telco = dis.telco;
+                        model.companies = dis.companies;
+                        model.company = dis.companies.data.Find(x => x.id == connConfig.companyID);
+                        model.services.data = services.data.FindAll(x => x.telcoID == connConfig.telcoID && x.companyID == connConfig.companyID);
+                    }
+                    HttpContext.Session.SetComplexData("service", connConfig);
+                }
+                else
+                {
+                    log.Error("No existed table type: " + tableType);
+                    return Redirect("/Home");
+                }
+
+                model.bots.data = bots.data.FindAll(x => x.status != UtilsController.Constant.DISABLE);
+                model.groups.data = groups.data.FindAll(x => x.status != UtilsController.Constant.DISABLE);
+
+                return PartialView("Editing", model);
+            }
+            catch (Exception ex)
+            {
+                log.Error("Exception: ", ex);
+                return Redirect("/Home");
+            }
+        }
+
+        [ValidateAntiForgeryToken]
+        public JsonResult EditingBotAction(BotStructure data)
+        {
+            try
+            {
+                if (!CheckAuthToken())
+                {
+                    return Json(new
+                    {
+                        code = UtilsController.Constant.ERROR,
+                        href = "/Home/Login"
+                    });
+                }
+                String page = HttpContext.Session.GetComplexData<String>("page");
+                BotStructure bot = HttpContext.Session.GetComplexData<BotStructure>("bot");
+                data.id = bot.id;
+                data.startDate = convertToDateTimeServer(data.startDate);
+                data.endDate = convertToDateTimeServer(data.endDate);
+
+                oracle = new OracleController(iSuperCmsRepo);
+                BotStructures bots = oracle.editingBotStructure(data);
+                if (bots.data.Count > 0)
+                {
+                    return Json(new
+                    {
+                        code = UtilsController.Constant.SUCCESS,
+                        href = "/Config?tableType=" + UtilsController.Constant.BOTS + "&page=" + page,
+                    });
+                }
+                else
+                {
+                    return Json(new
+                    {
+                        code = UtilsController.Constant.ERROR,
+                        href = "/Config?tableType=" + UtilsController.Constant.BOTS + "&page=" + page,
+                    });
+                }
+            }
+            catch (Exception ex)
+            {
+                log.Error("Exception " + ex);
+                return Json(new
+                {
+                    code = UtilsController.Constant.ERROR,
+                    href = "/Home"
+                });
+            }
+        }
+
+        [ValidateAntiForgeryToken]
+        public JsonResult EditingGroupAction(GroupStructure data)
+        {
+            try
+            {
+                if (!CheckAuthToken())
+                {
+                    return Json(new
+                    {
+                        code = UtilsController.Constant.ERROR,
+                        href = "/Home/Login"
+                    });
+                }
+                String page = HttpContext.Session.GetComplexData<String>("page");
+                GroupStructure group = HttpContext.Session.GetComplexData<GroupStructure>("group");
+                data.id = group.id;
+                data.startDate = convertToDateTimeServer(data.startDate);
+                data.endDate = convertToDateTimeServer(data.endDate);
+                oracle = new OracleController(iSuperCmsRepo);
+                GroupStructures groups = oracle.editingGroupStructure(data);
+                if (groups.data.Count > 0)
+                {
+                    return Json(new
+                    {
+                        code = UtilsController.Constant.SUCCESS,
+                        href = "/Config?tableType=" + UtilsController.Constant.GROUPS + "&page=" + page,
+                    });
+                }
+                else
+                {
+                    return Json(new
+                    {
+                        code = UtilsController.Constant.ERROR,
+                        href = "/Config?tableType=" + UtilsController.Constant.GROUPS + "&page=" + page,
+                    });
+                }
+            }
+            catch (Exception ex)
+            {
+                log.Error("Exception " + ex);
+                return Json(new
+                {
+                    code = UtilsController.Constant.ERROR,
+                    href = "/Home"
+                });
+            }
+        }
+        [ValidateAntiForgeryToken]
+        public JsonResult EditingScheduleAction(ScheduleStructure data)
+        {
+            try
+            {
+                if (!CheckAuthToken())
+                {
+                    return Json(new
+                    {
+                        code = UtilsController.Constant.ERROR,
+                        href = "/Home/Login"
+                    });
+                }
+                String page = HttpContext.Session.GetComplexData<String>("page");
+                ScheduleStructure schedule = HttpContext.Session.GetComplexData<ScheduleStructure>("schedule");
+                data.id = schedule.id;
+                data.timeRun = convertToDateTimeServer(data.timeRun);
+                oracle = new OracleController(iSuperCmsRepo);
+                ScheduleStructures schedules = oracle.editingScheduleStructure(data);
+                if (schedules.data.Count > 0)
+                {
+                    return Json(new
+                    {
+                        code = UtilsController.Constant.SUCCESS,
+                        href = "/Config?tableType=" + UtilsController.Constant.SCHEDULES + "&page=" + page,
+                    });
+                }
+                else
+                {
+                    return Json(new
+                    {
+                        code = UtilsController.Constant.ERROR,
+                        href = "/Config?tableType=" + UtilsController.Constant.SCHEDULES + "&page=" + page,
+                    });
+                }
+            }
+            catch (Exception ex)
+            {
+                log.Error("Exception " + ex);
+                return Json(new
+                {
+                    code = UtilsController.Constant.ERROR,
+                    href = "/Home"
+                });
+            }
+        }
+
+        [ValidateAntiForgeryToken]
+        public JsonResult EditingSendMailAction(SendMail data)
+        {
+            try
+            {
+                if (!CheckAuthToken())
+                {
+                    return Json(new
+                    {
+                        code = UtilsController.Constant.ERROR,
+                        href = "/Home/Login"
+                    });
+                }
+                String page = HttpContext.Session.GetComplexData<String>("page");
+                SendMail sendMail = HttpContext.Session.GetComplexData<SendMail>("sendMail");
+                data.id = sendMail.id;
+                data.timeSend = convertToDateTimeServer(data.timeSend);
+                oracle = new OracleController(iSuperCmsRepo);
+                SendMails sendMails = oracle.editingSendMail(data);
+                if (sendMails.data.Count > 0)
+                {
+                    return Json(new
+                    {
+                        code = UtilsController.Constant.SUCCESS,
+                        href = "/Config?tableType=" + UtilsController.Constant.SENDMAIL + "&page=" + page,
+                    });
+                }
+                else
+                {
+                    return Json(new
+                    {
+                        code = UtilsController.Constant.ERROR,
+                        href = "/Config?tableType=" + UtilsController.Constant.SENDMAIL + "&page=" + page,
+                    });
+                }
+            }
+            catch (Exception ex)
+            {
+                log.Error("Exception " + ex);
+                return Json(new
+                {
+                    code = UtilsController.Constant.ERROR,
+                    href = "/Home"
+                });
+            }
+        }
+
+        [ValidateAntiForgeryToken]
+        public JsonResult EditingConfigAction(Config data)
+        {
+            try
+            {
+                if (!CheckAuthToken())
+                {
+                    return Json(new
+                    {
+                        code = UtilsController.Constant.ERROR,
+                        href = "/Home/Login"
+                    });
+                }
+                String page = HttpContext.Session.GetComplexData<String>("page");
+                Config config = HttpContext.Session.GetComplexData<Config>("config");
+                data.id = config.id;
+
+                oracle = new OracleController(iSuperCmsRepo);
+                Configs configs = oracle.editingConfig(data);
+                if (configs.data.Count > 0)
+                {
+                    return Json(new
+                    {
+                        code = UtilsController.Constant.SUCCESS,
+                        href = "/Config?tableType=" + UtilsController.Constant.CONFIGS + "&page=" + page,
+                    });
+                }
+                else
+                {
+                    return Json(new
+                    {
+                        code = UtilsController.Constant.ERROR,
+                        href = "/Config?tableType=" + UtilsController.Constant.CONFIGS + "&page=" + page,
+                    });
+                }
+            }
+            catch (Exception ex)
+            {
+                log.Error("Exception " + ex);
+                return Json(new
+                {
+                    code = UtilsController.Constant.ERROR,
+                    href = "/Home"
+                });
+            }
+        }
+
+        [ValidateAntiForgeryToken]
+        public JsonResult EditingServiceAction(ConnConfig data)
+        {
+            try
+            {
+                if (!CheckAuthToken())
+                {
+                    return Json(new
+                    {
+                        code = UtilsController.Constant.ERROR,
+                        href = "/Home/Login"
+                    });
+                }
+                String page = HttpContext.Session.GetComplexData<String>("page");
+                ConnConfig connConfig = HttpContext.Session.GetComplexData<ConnConfig>("service");
+                data.id = connConfig.id;
+                ConnTelcos telcos = HttpContext.Session.GetComplexData<ConnTelcos>("telcos");
+                ConnCompanies companies = HttpContext.Session.GetComplexData<ConnCompanies>("companies");
+
+                ConnCompany company = companies.data.Find(x => x.id == data.companyID);
+                ConnTelco telco = telcos.data.Find(x => x.id == data.telcoID);
+                data.telco = telco.telcoName;
+
+                String timeNow = DateTime.Now.ToString("dd/MM/yyyy");
+                data.totalRun = "0";
+                data.dateRun = timeNow;
+                data.dateGet = timeNow;
+                if (data.hourRun.Length > 5)
+                {
+                    data.hourRun = data.hourRun;
+                }
+                else
+                {
+                    data.hourRun = data.hourRun + ":00";
+                }
+
+                oracle = new OracleController(iSuperCmsRepo);
+                ConnConfigs connConfigs = oracle.editConnConfigs(data);
+                if (connConfigs.data.Count > 0)
+                {
+                    return Json(new
+                    {
+                        code = UtilsController.Constant.SUCCESS,
+                        href = "/Config?tableType=" + UtilsController.Constant.SERVICE_CONFIG + "&page=" + page,
+                    });
+                }
+                else
+                {
+                    return Json(new
+                    {
+                        code = UtilsController.Constant.ERROR,
+                        href = "/Config?tableType=" + UtilsController.Constant.SERVICE_CONFIG + "&page=" + page,
+                    });
+                }
+            }
+            catch (Exception ex)
+            {
+                log.Error("Exception " + ex);
+                return Json(new
+                {
+                    code = UtilsController.Constant.ERROR,
+                    href = "/Home"
+                });
+            }
+        }
+
+        [ValidateAntiForgeryToken]
+        public JsonResult DeletingAction(String tableType, String id)
+        {
+            try
+            {
+                if (!CheckAuthToken())
+                {
+                    return Json(new
+                    {
+                        code = UtilsController.Constant.ERROR,
+                        href = "/Home/Login"
+                    });
+                }
+                oracle = new OracleController(iSuperCmsRepo);
+
+                ConfigViewModel model = new ConfigViewModel();
+                model.tableType = tableType;
+                String page = HttpContext.Session.GetComplexData<String>("page");
+                BotStructures bots = HttpContext.Session.GetComplexData<BotStructures>("bots");
+                GroupStructures groups = HttpContext.Session.GetComplexData<GroupStructures>("groups");
+                ScheduleStructures schedules = HttpContext.Session.GetComplexData<ScheduleStructures>("schedules");
+                SendMails sendMails = HttpContext.Session.GetComplexData<SendMails>("sendMails");
+                ConnConfigs connConfigs = HttpContext.Session.GetComplexData<ConnConfigs>("services");
+
+
+                if (tableType == null || id == null)
+                {
+                    log.Error("Null ");
+                    return Json(new
+                    {
+                        code = UtilsController.Constant.ERROR,
+                        href = "/Home"
+                    });
+                }
+
+                Boolean response;
+
+                if (tableType == UtilsController.Constant.BOTS)
+                {
+                    BotStructure bot = bots.data.Find(x => x.id == id);
+                    if (bot == null)
+                    {
+                        log.Error("No existed bot: " + id);
+                        return Json(new
+                        {
+                            code = UtilsController.Constant.ERROR,
+                            message = "An error was happened",
+                            href = "/Config?tableType=" + tableType + "&page=" + page,
+                        });
+                    }
+
+                }
+                else if (tableType == UtilsController.Constant.GROUPS)
+                {
+                    GroupStructure group = groups.data.Find(x => x.id == id);
+                    if (group == null)
+                    {
+                        log.Error("No existed group: " + id);
+                        return Json(new
+                        {
+                            code = UtilsController.Constant.ERROR,
+                            message = "An error was happened",
+                            href = "/Config?tableType=" + tableType + "&page=" + page,
+                        });
+                    }
+                    model.group = group;
+                }
+                else if (tableType == UtilsController.Constant.SCHEDULES)
+                {
+                    ScheduleStructure schedule = schedules.data.Find(x => x.id == id);
+                    if (schedule == null)
+                    {
+                        log.Error("No existed schedule: " + id);
+                        return Json(new
+                        {
+                            code = UtilsController.Constant.ERROR,
+                            message = "An error was happened",
+                            href = "/Config?tableType=" + tableType + "&page=" + page,
+                        });
+                    }
+                    model.schedule = schedule;
+                }
+                else if (tableType == UtilsController.Constant.SENDMAIL)
+                {
+                    SendMail sendMail = sendMails.data.Find(x => x.id == id);
+                    if (sendMail == null)
+                    {
+                        log.Error("No existed schedule: " + id);
+                        return Json(new
+                        {
+                            code = UtilsController.Constant.ERROR,
+                            message = "An error was happened",
+                            href = "/Config?tableType=" + tableType + "&page=" + page,
+                        });
+                    }
+                    model.sendMail = sendMail;
+                }
+                else if (tableType == UtilsController.Constant.SERVICE_CONFIG)
+                {
+                    ConnConfig connConfig = connConfigs.data.Find(x => x.id == id);
+                    if (connConfig == null)
+                    {
+                        log.Error("No existed connConfig: " + id);
+                        return Json(new
+                        {
+                            code = UtilsController.Constant.ERROR,
+                            message = "An error was happened",
+                            href = "/Config?tableType=" + tableType + "&page=" + page,
+                        });
+                    }
+                    model.service = connConfig;
+                }
+                else
+                {
+                    log.Error("No existed table type: " + tableType);
+                    return Json(new
+                    {
+                        code = UtilsController.Constant.ERROR,
+                        message = "An error was happened",
+                        href = "/Home",
+                    });
+                }
+                response = oracle.deleteStructure(tableType, id);
+                if (!response)
+                {
+                    return Json(new
+                    {
+                        code = UtilsController.Constant.ERROR,
+                        message = "Delete failure",
+                        href = "/Config?tableType=" + tableType + "&page=" + page,
+                    });
+                }
+                else
+                {
+                    return Json(new
+                    {
+                        code = UtilsController.Constant.SUCCESS,
+                        message = "Delete successful",
+                        href = "/Config?tableType=" + tableType + "&page=" + page,
+                    });
+                }
+            }
+            catch (Exception ex)
+            {
+                log.Error("Exception " + ex);
+                return Json(new
+                {
+                    code = UtilsController.Constant.ERROR,
+                    href = "/Home"
+                });
+            }
+        }
+    }
+}

+ 261 - 0
SuperCms/Controllers/HomeController.cs

@@ -0,0 +1,261 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Globalization;
+using System.Linq;
+using System.Threading.Tasks;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.Logging;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+using SuperCms.Extensions;
+using SuperCms.Models;
+using SuperCms.Repositories;
+
+namespace SuperCms.Controllers
+{
+    public class HomeController : BaseController
+    {
+        private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof(Program));
+
+        ISuperCmsRepo iSuperCmsRepo;
+        private OracleController oracle;
+
+        public HomeController(ISuperCmsRepo ISuperCmsRepo)
+        {
+            iSuperCmsRepo = ISuperCmsRepo;
+        }
+
+
+        public IActionResult Index(String startDate, String endDate, String page)
+        {
+            // get all services
+            try
+            {
+                if (!CheckAuthToken())
+                {
+                    //return Redirect("/Support/Index");
+                    return Redirect("/Home/Login");
+                }
+                oracle = new OracleController(iSuperCmsRepo);
+
+                HomeViewModel model = new HomeViewModel
+                {
+                    page = page != null ? page : "1",
+                    totalPage = "0",
+                    services = new ConnConfigs()
+                };
+                model.services.data = new List<ConnConfig>();
+                model.connDatas = new ConnDatas();
+                model.connDatas.data = new List<ConnData>();
+                model.connDatasNow = new ConnDatas();
+                model.connDatasNow.data = new List<ConnData>();
+                model.connDatasBefore = new ConnDatas();
+                model.connDatasBefore.data = new List<ConnData>();
+                model.distributedDatas = new List<DistributedData>();
+                model.telcos = new ConnTelcos();
+                model.telcos.data = new List<ConnTelco>();
+                model.companies = new ConnCompanies();
+                model.companies.data = new List<ConnCompany>();
+                ConnDatas tempData = new ConnDatas();
+                tempData.data = new List<ConnData>();
+
+                String start = startDate == null ? getStartByDayToString() : DateTime.ParseExact(startDate, "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture).ToString("MM/dd/yyyy HH:mm:ss");
+                String end = endDate == null ? getEndByDayToString() : DateTime.ParseExact(endDate, "yyyy-MM-ddTHH:mm", CultureInfo.InvariantCulture).ToString("MM/dd/yyyy HH:mm:ss");
+                DateTime startDateTime = startDate == null ? getStartByDayToDate() : DateTime.ParseExact(startDate, "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture);
+                DateTime endDateTime = endDate == null ? getEndByDayToDate() : DateTime.ParseExact(endDate, "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture);
+
+
+                ConnTelcos telcos = HttpContext.Session.GetComplexData<ConnTelcos>("telcos");
+                if (telcos == null)
+                {
+                    telcos = oracle.getConnTelcos();
+                    HttpContext.Session.SetComplexData("telcos", telcos);
+                }
+                model.telcos = telcos;
+
+                ConnCompanies companies = HttpContext.Session.GetComplexData<ConnCompanies>("companies");
+                if (companies == null)
+                {
+                    companies = oracle.getConnCompanies();
+                    HttpContext.Session.SetComplexData("companies", companies);
+                }
+                model.companies = companies;
+
+                ConnConfigs services = HttpContext.Session.GetComplexData<ConnConfigs>("services");
+                if (services == null)
+                {
+                    services = oracle.getConnConfigs();
+                    HttpContext.Session.SetComplexData("services", services);
+                }
+                model.services = services;
+                model.totalServices = services;
+                // phan loai cac dich vu vao tung cong ty va tung thi truong
+                List<DistributedByTelcoAndCompany> dis = HttpContext.Session.GetComplexData<List<DistributedByTelcoAndCompany>>("distributedByTelcoAndCompany");
+                if (dis == null)
+                {
+                    List<DistributedByTelcoAndCompany> distributedByTelcoAndCompanyT = new List<DistributedByTelcoAndCompany>();
+                    dis = distributedByTelcoAndCompany(model.telcos, model.companies, model.services, 0, distributedByTelcoAndCompanyT);
+                    HttpContext.Session.SetComplexData("distributedByTelcoAndCompany", dis);
+                }
+
+                int total = services.data.Count / int.Parse(UtilsController.Constant.NUMBER_ROW_ON_PAGE);
+                if (total % int.Parse(UtilsController.Constant.NUMBER_ROW_ON_PAGE) != 0)
+                {
+                    total++;
+                }
+                model.totalPage = total.ToString();
+                model.services = services;
+
+                // get data
+                var resultD = iSuperCmsRepo.GetConnData(log, start, end);
+                var propertyD = typeof(ICollection).GetProperty("Count");
+                int countD = (int)propertyD.GetValue(resultD, null);
+                if (resultD != null && countD > 0)
+                {
+                    ConnDatas data = new ConnDatas();
+                    data.data = new List<ConnData>();
+                    foreach (IDictionary<string, object> row in (IEnumerable<object>)resultD)
+                    {
+                        var json = JsonConvert.SerializeObject(row);
+                        ConnData dataGet = new ConnData(json.ToString());
+                        data.data.Add(dataGet);
+                    }
+                    model.connDatas = data;
+                }
+
+
+                // get only ROW services 
+                int startRow = (int.Parse(model.page) - 1) * int.Parse(UtilsController.Constant.NUMBER_ROW_ON_PAGE);
+                int endRow = (int.Parse(model.page)) * int.Parse(UtilsController.Constant.NUMBER_ROW_ON_PAGE);
+
+                ConnConfigs configs = new ConnConfigs();
+                configs.data = new List<ConnConfig>();
+                for (int c = startRow; c < (endRow > model.services.data.Count ? model.services.data.Count : endRow); c++)
+                {
+                    configs.data.Add(model.services.data[c]);
+                }
+                model.services = configs;
+
+                if (model.connDatas.data.Count > 0 && model.services.data.Count > 0)
+                {
+                    for (int i = 0; i < model.services.data.Count; i++)
+                    {
+                        ConnConfig service = model.services.data[i];
+                        List<ConnData> data = model.connDatas.data.FindAll(x => x.configID == service.id);
+                        data.Sort(delegate (ConnData x, ConnData y)
+                        {
+                            if (x.dateGet == null && y.dateGet == null) return 0;
+                            else if (x.dateGet == null) return -1;
+                            else if (y.dateGet == null) return 1;
+                            else return y.dateGet.CompareTo(x.dateGet);
+                        });
+                        //if (data.Count > 0)
+                        //{
+                        //    model.connDatasNow.data.Add(data[0]);
+                        //}
+                        //if (data.Count > 1)
+                        //{
+                        //    model.connDatasBefore.data.Add(data[1]);
+                        //}
+                        DistributedData distributedData = new DistributedData();
+                        distributedData.connDatas = new ConnDatas();
+                        distributedData.connDatas.data = new List<ConnData>();
+                        distributedData.service = service;
+                        distributedData.connDatas.data = data.Count > 0 ? data : new List<ConnData>();
+                        model.distributedDatas.Add(distributedData);
+                    }
+                }
+
+                model.listDate = getRangeTime(startDateTime, endDateTime);
+
+                // distributed by time
+                model.distributedByTimes = new List<DistributedByTime>();
+                for (int i = 0; i < model.listDate.Count - 1; i++)
+                {
+                    DistributedByTime time = new DistributedByTime();
+                    time.time = model.listDate[i];
+                    time.connDatas = new ConnDatas();
+                    time.connDatas.data = model.connDatas.data.FindAll(x =>
+                    DateTime.Compare(model.listDate[i + 1], DateTime.ParseExact(x.dateGet + " 23:59:59", "dd/MM/yyyy HH:mm:ss", CultureInfo.InvariantCulture)) < 0 &&
+                        DateTime.Compare(DateTime.ParseExact(x.dateGet + " 23:59:59", "dd/MM/yyyy HH:mm:ss", CultureInfo.InvariantCulture), model.listDate[i]) < 0);
+                    model.distributedByTimes.Add(time);
+                }
+                model.connDatasNow = model.distributedByTimes[0].connDatas;
+
+                return View("Index", model);
+            }
+            catch (Exception ex)
+            {
+                log.Error("Exception: ", ex);
+                return Redirect("/Shared/Error");
+            }
+        }
+
+        public IActionResult Login()
+        {
+            return View();
+        }
+        public IActionResult LoginAction(String account, String password)
+        {
+            if (account == null || password == null)
+            {
+                return Redirect("/Home/Login");
+            }
+            // get all columns in table
+            var result = iSuperCmsRepo.Login(log, account, password);
+
+            var property = typeof(ICollection).GetProperty("Count");
+            int count = (int)property.GetValue(result, null);
+            if (result != null && count > 0)
+            {
+                String number = "0";
+                foreach (IDictionary<string, object> row in (IEnumerable<object>)result)
+                {
+                    var json = JObject.Parse(JsonConvert.SerializeObject(row));
+                    number = (string)json["COUNT(*)"].ToString();
+                }
+                if (number == "1")
+                {
+                    CreateAuthToken();
+                    return Redirect("/Home");
+                }
+                else
+                {
+                    return Redirect("/Home/Login");
+                }
+
+            }
+            else
+            {
+                return Redirect("/Home/Login");
+            }
+        }
+
+        public IActionResult Logout()
+        {
+            try
+            {
+                ClearCache();
+                return Redirect("/Home/Login");
+            }
+            catch (Exception ex)
+            {
+                log.Error("Exception " + ex);
+                return Redirect("/Shared/Error");
+            }
+
+        }
+        public IActionResult Privacy()
+        {
+            return View();
+        }
+
+        [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
+        public IActionResult Error()
+        {
+            return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
+        }
+    }
+}

+ 515 - 0
SuperCms/Controllers/OracleController.cs

@@ -0,0 +1,515 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.Logging;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+using SuperCms.Models;
+using SuperCms.Repositories;
+using static SuperCms.Controllers.UtilsController;
+
+namespace SuperCms.Controllers
+{
+    public class OracleController
+    {
+        private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof(Program));
+
+        private readonly ILogger<ReportController> _logger;
+
+        ISuperCmsRepo iSuperCmsRepo;
+        public OracleController(ISuperCmsRepo ISuperCmsRepo)
+        {
+            iSuperCmsRepo = ISuperCmsRepo;
+        }
+
+        // get all schedules within today
+        public BotStructures getBotstructures()
+        {
+            BotStructures bots = new BotStructures();
+            bots.data = new List<BotStructure>();
+
+            var resultC = iSuperCmsRepo.GetAllBots(log);
+
+            var propertyC = typeof(ICollection).GetProperty("Count");
+            int countC = (int)propertyC.GetValue(resultC, null);
+            if (resultC != null && countC > 0)
+            {
+                foreach (IDictionary<string, object> row in (IEnumerable<object>)resultC)
+                {
+                    var json = JsonConvert.SerializeObject(row);
+                    BotStructure dataGet = new BotStructure(json.ToString());
+                    bots.data.Add(dataGet);
+                }
+            }
+            return bots;
+        }
+
+        public ScheduleStructures getSchedulestructures(String seqPage, String rowsOnPage)
+        {
+            ScheduleStructures schedules = new ScheduleStructures();
+            schedules.data = new List<ScheduleStructure>();
+
+            var resultC = iSuperCmsRepo.GetScheduleByRow(log, seqPage, rowsOnPage);
+
+            var propertyC = typeof(ICollection).GetProperty("Count");
+            int countC = (int)propertyC.GetValue(resultC, null);
+            if (resultC != null && countC > 0)
+            {
+                foreach (IDictionary<string, object> row in (IEnumerable<object>)resultC)
+                {
+                    var json = JsonConvert.SerializeObject(row);
+                    ScheduleStructure dataGet = new ScheduleStructure(json.ToString());
+                    schedules.data.Add(dataGet);
+                }
+            }
+            return schedules;
+        }
+
+        public GroupStructures getGroupstructures()
+        {
+            GroupStructures groups = new GroupStructures();
+            groups.data = new List<GroupStructure>();
+
+            var resultC = iSuperCmsRepo.GetAllGroups(log);
+
+            var propertyC = typeof(ICollection).GetProperty("Count");
+            int countC = (int)propertyC.GetValue(resultC, null);
+            if (resultC != null && countC > 0)
+            {
+                foreach (IDictionary<string, object> row in (IEnumerable<object>)resultC)
+                {
+                    var json = JsonConvert.SerializeObject(row);
+                    GroupStructure dataGet = new GroupStructure(json.ToString());
+                    groups.data.Add(dataGet);
+                }
+            }
+            return groups;
+        }
+
+        public Configs getConfigs()
+        {
+            Configs configs = new Configs();
+            configs.data = new List<Config>();
+
+            var resultC = iSuperCmsRepo.GetAllConfigs(log);
+
+            var propertyC = typeof(ICollection).GetProperty("Count");
+            int countC = (int)propertyC.GetValue(resultC, null);
+            if (resultC != null && countC > 0)
+            {
+                foreach (IDictionary<string, object> row in (IEnumerable<object>)resultC)
+                {
+                    var json = JsonConvert.SerializeObject(row);
+                    Config dataGet = new Config(json.ToString());
+                    configs.data.Add(dataGet);
+                }
+            }
+            return configs;
+        }
+
+        public String getTotalRow(String type, String rowsOnPage)
+        {
+            ScheduleStructures schedules = new ScheduleStructures();
+            schedules.data = new List<ScheduleStructure>();
+
+            var resultC = iSuperCmsRepo.GetTotalRow(log, type);
+            String number = "1";
+
+            var propertyC = typeof(ICollection).GetProperty("Count");
+            int countC = (int)propertyC.GetValue(resultC, null);
+            if (resultC != null && countC > 0)
+            {
+                foreach (IDictionary<string, object> row in (IEnumerable<object>)resultC)
+                {
+                    var json = JObject.Parse(JsonConvert.SerializeObject(row));
+                    number = (string)json["COUNT(*)"].ToString();
+                }
+                int totalPage = int.Parse(number) / int.Parse(rowsOnPage);
+                if (int.Parse(number) % int.Parse(rowsOnPage) != 0)
+                {
+                    totalPage++;
+                }
+                number = totalPage.ToString();
+            }
+            return number;
+        }
+
+        public BotStructures addingBotStructure(BotStructure bot)
+        {
+            BotStructures bots = new BotStructures();
+            bots.data = new List<BotStructure>();
+
+            var resultC = iSuperCmsRepo.AddingBotStructure(log, bot);
+
+            var propertyC = typeof(ICollection).GetProperty("Count");
+            int countC = (int)propertyC.GetValue(resultC, null);
+            if (resultC != null && countC > 0)
+            {
+                foreach (IDictionary<string, object> row in (IEnumerable<object>)resultC)
+                {
+                    var json = JsonConvert.SerializeObject(row);
+                    BotStructure dataGet = new BotStructure(json.ToString());
+                    bots.data.Add(dataGet);
+                }
+            }
+            return bots;
+        }
+
+        public GroupStructures addingGroupStructure(GroupStructure group)
+        {
+            GroupStructures groups = new GroupStructures();
+            groups.data = new List<GroupStructure>();
+
+            var resultC = iSuperCmsRepo.AddingGroupStructure(log, group);
+
+            var propertyC = typeof(ICollection).GetProperty("Count");
+            int countC = (int)propertyC.GetValue(resultC, null);
+            if (resultC != null && countC > 0)
+            {
+                foreach (IDictionary<string, object> row in (IEnumerable<object>)resultC)
+                {
+                    var json = JsonConvert.SerializeObject(row);
+                    GroupStructure dataGet = new GroupStructure(json.ToString());
+                    groups.data.Add(dataGet);
+                }
+            }
+            return groups;
+        }
+
+        public ScheduleStructures addingScheduleStructure(ScheduleStructure schedule)
+        {
+            ScheduleStructures schedules = new ScheduleStructures();
+            schedules.data = new List<ScheduleStructure>();
+
+            var resultC = iSuperCmsRepo.AddingScheduleStructure(log, schedule);
+
+            var propertyC = typeof(ICollection).GetProperty("Count");
+            int countC = (int)propertyC.GetValue(resultC, null);
+            if (resultC != null && countC > 0)
+            {
+                foreach (IDictionary<string, object> row in (IEnumerable<object>)resultC)
+                {
+                    var json = JsonConvert.SerializeObject(row);
+                    ScheduleStructure dataGet = new ScheduleStructure(json.ToString());
+                    schedules.data.Add(dataGet);
+                }
+            }
+            return schedules;
+        }
+
+        public Configs addingConfig(Config config)
+        {
+            Configs configs = new Configs();
+            configs.data = new List<Config>();
+
+            var resultC = iSuperCmsRepo.AddingConfig(log, config);
+
+            var propertyC = typeof(ICollection).GetProperty("Count");
+            int countC = (int)propertyC.GetValue(resultC, null);
+            if (resultC != null && countC > 0)
+            {
+                foreach (IDictionary<string, object> row in (IEnumerable<object>)resultC)
+                {
+                    var json = JsonConvert.SerializeObject(row);
+                    Config dataGet = new Config(json.ToString());
+                    configs.data.Add(dataGet);
+                }
+            }
+            return configs;
+        }
+
+        public BotStructures editingBotStructure(BotStructure bot)
+        {
+            BotStructures bots = new BotStructures();
+            bots.data = new List<BotStructure>();
+
+            var resultC = iSuperCmsRepo.EditingBotStructure(log, bot);
+
+            var propertyC = typeof(ICollection).GetProperty("Count");
+            int countC = (int)propertyC.GetValue(resultC, null);
+            if (resultC != null && countC > 0)
+            {
+                foreach (IDictionary<string, object> row in (IEnumerable<object>)resultC)
+                {
+                    var json = JsonConvert.SerializeObject(row);
+                    BotStructure dataGet = new BotStructure(json.ToString());
+                    bots.data.Add(dataGet);
+                }
+            }
+            return bots;
+        }
+
+        public GroupStructures editingGroupStructure(GroupStructure group)
+        {
+            GroupStructures groups = new GroupStructures();
+            groups.data = new List<GroupStructure>();
+
+            var resultC = iSuperCmsRepo.EditingGroupStructure(log, group);
+
+            var propertyC = typeof(ICollection).GetProperty("Count");
+            int countC = (int)propertyC.GetValue(resultC, null);
+            if (resultC != null && countC > 0)
+            {
+                foreach (IDictionary<string, object> row in (IEnumerable<object>)resultC)
+                {
+                    var json = JsonConvert.SerializeObject(row);
+                    GroupStructure dataGet = new GroupStructure(json.ToString());
+                    groups.data.Add(dataGet);
+                }
+            }
+            return groups;
+        }
+
+        public ScheduleStructures editingScheduleStructure(ScheduleStructure schedule)
+        {
+            ScheduleStructures schedules = new ScheduleStructures();
+            schedules.data = new List<ScheduleStructure>();
+
+            var resultC = iSuperCmsRepo.EditingScheduleStructure(log, schedule);
+
+            var propertyC = typeof(ICollection).GetProperty("Count");
+            int countC = (int)propertyC.GetValue(resultC, null);
+            if (resultC != null && countC > 0)
+            {
+                foreach (IDictionary<string, object> row in (IEnumerable<object>)resultC)
+                {
+                    var json = JsonConvert.SerializeObject(row);
+                    ScheduleStructure dataGet = new ScheduleStructure(json.ToString());
+                    schedules.data.Add(dataGet);
+                }
+            }
+            return schedules;
+        }
+
+        public Configs editingConfig(Config config)
+        {
+            Configs configs = new Configs();
+            configs.data = new List<Config>();
+
+            var resultC = iSuperCmsRepo.EditingConfig(log, config);
+
+            var propertyC = typeof(ICollection).GetProperty("Count");
+            int countC = (int)propertyC.GetValue(resultC, null);
+            if (resultC != null && countC > 0)
+            {
+                foreach (IDictionary<string, object> row in (IEnumerable<object>)resultC)
+                {
+                    var json = JsonConvert.SerializeObject(row);
+                    Config dataGet = new Config(json.ToString());
+                    configs.data.Add(dataGet);
+                }
+            }
+            return configs;
+        }
+
+        public Boolean deleteStructure(String tableType, String id)
+        {
+            ResponseStructures response = new ResponseStructures();
+            response.data = new List<ResponseStructure>();
+
+            var resultC = iSuperCmsRepo.DeleteStructure(log, tableType, id);
+
+            var propertyC = typeof(ICollection).GetProperty("Count");
+            int countC = (int)propertyC.GetValue(resultC, null);
+            if (resultC != null && countC > 0)
+            {
+                foreach (IDictionary<string, object> row in (IEnumerable<object>)resultC)
+                {
+                    var json = JsonConvert.SerializeObject(row);
+                    ResponseStructure dataGet = new ResponseStructure(json.ToString());
+                    response.data.Add(dataGet);
+                }
+            }
+            if (response.data[0].code == Constant.SUCCESS)
+            {
+                return true;
+            }
+            else
+            {
+                return false;
+            }
+        }
+
+        public SendMails getSendMails()
+        {
+            SendMails sendMails = new SendMails();
+            sendMails.data = new List<SendMail>();
+
+            var resultC = iSuperCmsRepo.GetAllSendMails(log);
+
+            var propertyC = typeof(ICollection).GetProperty("Count");
+            int countC = (int)propertyC.GetValue(resultC, null);
+            if (resultC != null && countC > 0)
+            {
+                foreach (IDictionary<string, object> row in (IEnumerable<object>)resultC)
+                {
+                    var json = JsonConvert.SerializeObject(row);
+                    SendMail dataGet = new SendMail(json.ToString());
+                    sendMails.data.Add(dataGet);
+                }
+            }
+            return sendMails;
+        }
+
+        public SendMails addingSendMail(SendMail sendMail)
+        {
+            SendMails sendMails = new SendMails();
+            sendMails.data = new List<SendMail>();
+
+            var resultC = iSuperCmsRepo.AddingSendMail(log, sendMail);
+
+            var propertyC = typeof(ICollection).GetProperty("Count");
+            int countC = (int)propertyC.GetValue(resultC, null);
+            if (resultC != null && countC > 0)
+            {
+                foreach (IDictionary<string, object> row in (IEnumerable<object>)resultC)
+                {
+                    var json = JsonConvert.SerializeObject(row);
+                    SendMail dataGet = new SendMail(json.ToString());
+                    sendMails.data.Add(dataGet);
+                }
+            }
+            return sendMails;
+        }
+
+        public SendMails editingSendMail(SendMail sendMail)
+        {
+            SendMails sendMails = new SendMails();
+            sendMails.data = new List<SendMail>();
+
+            var resultC = iSuperCmsRepo.EditingSendMail(log, sendMail);
+
+            var propertyC = typeof(ICollection).GetProperty("Count");
+            int countC = (int)propertyC.GetValue(resultC, null);
+            if (resultC != null && countC > 0)
+            {
+                foreach (IDictionary<string, object> row in (IEnumerable<object>)resultC)
+                {
+                    var json = JsonConvert.SerializeObject(row);
+                    SendMail dataGet = new SendMail(json.ToString());
+                    sendMails.data.Add(dataGet);
+                }
+            }
+            return sendMails;
+        }
+
+        public ConnConfigs getConnConfigs()
+        {
+            ConnConfigs data = new ConnConfigs();
+            data.data = new List<ConnConfig>();
+            var resultC = iSuperCmsRepo.GetConnConfig(log);
+
+            var propertyC = typeof(ICollection).GetProperty("Count");
+            int countC = (int)propertyC.GetValue(resultC, null);
+            if (resultC != null && countC > 0)
+            {
+
+                foreach (IDictionary<string, object> row in (IEnumerable<object>)resultC)
+                {
+                    var json = JsonConvert.SerializeObject(row);
+                    ConnConfig dataGet = new ConnConfig(json.ToString());
+                    data.data.Add(dataGet);
+                }
+            }
+            return data;
+        }
+
+        public ConnTelcos getConnTelcos()
+        {
+            ConnTelcos data = new ConnTelcos();
+            data.data = new List<ConnTelco>();
+
+            var resultT = iSuperCmsRepo.GetConnTelco(log);
+
+            var propertyT = typeof(ICollection).GetProperty("Count");
+            int countT = (int)propertyT.GetValue(resultT, null);
+            if (resultT != null && countT > 0)
+            {
+
+                foreach (IDictionary<string, object> row in (IEnumerable<object>)resultT)
+                {
+                    var json = JsonConvert.SerializeObject(row);
+                    ConnTelco dataGet = new ConnTelco(json.ToString());
+                    data.data.Add(dataGet);
+                }
+                //sort 
+                data.data.Sort(delegate (ConnTelco x, ConnTelco y)
+                {
+                    return int.Parse(x.id).CompareTo(int.Parse(y.id));
+                });
+            }
+            return data;
+        }
+
+        public ConnCompanies getConnCompanies()
+        {
+            ConnCompanies data = new ConnCompanies();
+            data.data = new List<ConnCompany>();
+
+            var resultT = iSuperCmsRepo.GetConnCompany(log);
+
+            var propertyT = typeof(ICollection).GetProperty("Count");
+            int countT = (int)propertyT.GetValue(resultT, null);
+            if (resultT != null && countT > 0)
+            {
+
+                foreach (IDictionary<string, object> row in (IEnumerable<object>)resultT)
+                {
+                    var json = JsonConvert.SerializeObject(row);
+                    ConnCompany dataGet = new ConnCompany(json.ToString());
+                    data.data.Add(dataGet);
+                }
+                data.data.Sort(delegate (ConnCompany x, ConnCompany y)
+                {
+                    return int.Parse(x.id).CompareTo(int.Parse(y.id));
+                });
+            }
+            return data;
+        }
+
+        public ConnConfigs addConnConfigs(ConnConfig connConfig)
+        {
+            ConnConfigs data = new ConnConfigs();
+            data.data = new List<ConnConfig>();
+            var resultC = iSuperCmsRepo.AddConnConfig(log, connConfig);
+
+            var propertyC = typeof(ICollection).GetProperty("Count");
+            int countC = (int)propertyC.GetValue(resultC, null);
+            if (resultC != null && countC > 0)
+            {
+
+                foreach (IDictionary<string, object> row in (IEnumerable<object>)resultC)
+                {
+                    var json = JsonConvert.SerializeObject(row);
+                    ConnConfig dataGet = new ConnConfig(json.ToString());
+                    data.data.Add(dataGet);
+                }
+            }
+            return data;
+        }
+
+        public ConnConfigs editConnConfigs(ConnConfig connConfig)
+        {
+            ConnConfigs data = new ConnConfigs();
+            data.data = new List<ConnConfig>();
+            var resultC = iSuperCmsRepo.EditConnConfig(log, connConfig);
+
+            var propertyC = typeof(ICollection).GetProperty("Count");
+            int countC = (int)propertyC.GetValue(resultC, null);
+            if (resultC != null && countC > 0)
+            {
+
+                foreach (IDictionary<string, object> row in (IEnumerable<object>)resultC)
+                {
+                    var json = JsonConvert.SerializeObject(row);
+                    ConnConfig dataGet = new ConnConfig(json.ToString());
+                    data.data.Add(dataGet);
+                }
+            }
+            return data;
+        }
+    }
+}

+ 28 - 0
SuperCms/Controllers/PartialController.cs

@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using LiveInfo.Models;
+using Microsoft.AspNetCore.Mvc;
+
+namespace SuperCms.Controllers
+{
+    public class PartialController : Controller
+    {
+        public IActionResult Response(String message)
+        {
+            PartialViewModel model = new PartialViewModel();
+            model.message = message;
+            return PartialView("Response", model);
+        }
+        public IActionResult Confirm(String message, String url, String id, String tableType)
+        {
+            PartialViewModel model = new PartialViewModel();
+            model.url = url;
+            model.id = id;
+            model.tableType = tableType;
+            model.message = message;
+            return PartialView("Confirm", model);
+        }
+    }
+}

+ 348 - 0
SuperCms/Controllers/RegistryController.cs

@@ -0,0 +1,348 @@
+using Microsoft.AspNetCore.Mvc;
+using SuperCms.Models;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Net;
+using System.Net.Http;
+using System.Text.RegularExpressions;
+using System.Threading.Tasks;
+using SuperCms.Controllers;
+using Syncfusion.XlsIO;
+using System.Text;
+
+namespace SuperCms.Controllers
+{
+    public class RegistryController : BaseController
+    {
+        public async Task<IActionResult> IndexAsync(string txtThoigian, string txtLoaiPT, string cboTinh)
+        {
+            try
+            {
+                RegistryViewModel model = new RegistryViewModel();
+
+                if (txtThoigian == null || txtLoaiPT == null || cboTinh == null)
+                {
+                    return View(model);
+                }
+                string endPoint = "http://app.vr.org.vn/ptpublic/quahankd.aspx";
+                var client = new HttpClient();
+
+                // get valid key
+                WebRequest request = HttpWebRequest.Create(endPoint);
+                WebResponse response1 = request.GetResponse();
+                StreamReader reader = new StreamReader(response1.GetResponseStream());
+                string responseText = reader.ReadToEnd();
+
+                bool loop = true;
+                int i = 0;
+                var tableHTML = "";
+                var table = "";
+                string old = "";
+                List<KeyValuePair<string, string>> data = new List<KeyValuePair<string, string>>();
+                List<KeyValuePair<string, string>> dataOld = new List<KeyValuePair<string, string>>();
+
+                while (loop)
+                {
+                    //if (i == 0)
+                    //{
+                    //    data.Add(new KeyValuePair<string, string>("__EVENTTARGET", ""));
+                    //    data.Add(new KeyValuePair<string, string>("__EVENTARGUMENT", ""));
+                    //    data.Add(new KeyValuePair<string, string>("cmdTraCuu", "Tra cứu"));
+                    //}
+                    //else
+                    //{
+                    //    data.Add(new KeyValuePair<string, string>("__EVENTTARGET", "DGTimPT$ctl54$ctl" + (i < 10 ? "0" + i.ToString() : i.ToString())));
+                    //    data.Add(new KeyValuePair<string, string>("__EVENTARGUMENT", ""));
+                    //}
+
+                    using (var httpClient = new HttpClient())
+                    {
+                        if (i == 0)
+                        {
+                            List<KeyValuePair<string, string>> dataGet = UtilsController.ParseDataRequest(responseText);
+                            dataGet.Add(new KeyValuePair<string, string>("cboTinh", cboTinh));
+                            dataGet.Add(new KeyValuePair<string, string>("txtLoaiPT", txtLoaiPT));
+                            dataGet.Add(new KeyValuePair<string, string>("txtThoigian", txtThoigian));
+                            dataGet.Add(new KeyValuePair<string, string>("__EVENTTARGET", ""));
+                            dataGet.Add(new KeyValuePair<string, string>("__EVENTARGUMENT", ""));
+                            dataGet.Add(new KeyValuePair<string, string>("cmdTraCuu", "Tra cứu"));
+                            data = dataGet;
+                        }
+                        else
+                        {
+                            dataOld.Add(new KeyValuePair<string, string>("__EVENTTARGET", "DGTimPT$ctl54$ctl" + (i < 10 ? "0" + i.ToString() : i.ToString())));
+                            dataOld.Add(new KeyValuePair<string, string>("__EVENTARGUMENT", ""));
+                            dataOld.Add(new KeyValuePair<string, string>("cboTinh", cboTinh));
+                            dataOld.Add(new KeyValuePair<string, string>("txtLoaiPT", txtLoaiPT));
+                            dataOld.Add(new KeyValuePair<string, string>("txtThoigian", txtThoigian));
+                            data = dataOld;
+
+                        }
+                        using (var content = new FormUrlEncodedContent(data))
+                        {
+                            content.Headers.Clear();
+                            content.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
+
+                            HttpResponseMessage response = await httpClient.PostAsync(endPoint, content);
+
+                            var result = response.Content.ReadAsStringAsync().Result;
+                            dataOld = UtilsController.ParseDataRequest(result);
+                            if (old != null)
+                            {
+                                if (old.Length == result.Length)
+                                {
+                                    loop = false;
+                                    continue;
+                                }
+                            }
+                            old = result;
+
+                            Regex regex1 = new Regex("<table cell[^>]*>[\\s\\S]*?<\\/table>", RegexOptions.IgnoreCase);
+                            Match match1;
+                            for (match1 = regex1.Match(result); match1.Success; match1 = match1.NextMatch())
+                            {
+                                var result2 = match1.Groups[0].Value;
+
+                                Regex regex2 = new Regex("<tr[^>]*>[\\s\\S]*?<\\/tr>", RegexOptions.IgnoreCase);
+                                Match match2;
+                                int count = 0;
+                                for (match2 = regex2.Match(result2); match2.Success; match2 = match2.NextMatch())
+                                {
+                                    if (count > 0)
+                                    {
+                                        if (!match2.Groups[0].Value.Contains("DGTimPT$ctl"))
+                                        {
+                                            var d = match2.Groups[0].Value;
+                                            table = table + d;
+                                        }
+                                    }
+                                    count++;
+                                }
+                            }
+                        }
+                    }
+                    i++;
+                }
+
+                //tableHTML = "<html>" + "<body>" +
+                //    "<table cellspacing=\"0\" width=\"500\" style=\"table-layout:fixed; border-collapse:collapse; width: 500pt\">" +
+                //    @"<tr><td> Số TT </td>
+                //    <td> Biển đăng ký</td>
+                //    <td> Ngày đăng ký</td>
+                //    <td> Nhãn hiệu </td>
+                //    <td> Chủ phương tiên</td>
+                //    <td> Địa chỉ </td>
+                //    <td> Ngày kiểm định</td>
+                //    <td> Đơn vị KĐ</td>
+                //    <td> Số GCN KĐ</td>
+                //    <td> Thời hạn GCN</td>
+                //    </tr>" +
+                //    table +
+                //    @"</table>" +
+                //    "</body></html>";
+
+                //String tableHTMLNew = tableHTML.Replace("&", "&amp;");
+                //MemoryStream ms = new MemoryStream();
+                //using (ExcelEngine excelEngine = new ExcelEngine())
+                //{
+
+                //    // Step 2 : Instantiate the Excel application object.
+                //    IApplication application = excelEngine.Excel;
+                //    application.DefaultVersion = ExcelVersion.Excel2016;
+
+                //    // A workbook is created.
+                //    IWorkbook workbook = application.Workbooks.Create(1);
+
+                //    // The first worksheet object in the worksheets collection is accessed.
+                //    IWorksheet worksheet = workbook.Worksheets[0];
+
+                //    byte[] byteArray = Encoding.UTF8.GetBytes(tableHTMLNew);
+
+                //    MemoryStream file = new MemoryStream(byteArray);
+
+                //    // Imports HTML table into the worksheet from first row and first column.
+                //    worksheet.ImportHtmlTable(file, 1, 1);
+
+                //    worksheet.UsedRange.AutofitColumns();
+                //    worksheet.UsedRange.AutofitRows();
+
+                //    workbook.SaveAs(ms);
+                //    ms.Position = 0;
+                //}
+                //return File(ms, "Application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "Export-HTML-Table.xlsx");
+
+                model.table = table;
+
+                return View(model);
+            }
+            catch (Exception ex)
+            {
+                return Redirect("/Home");
+            }
+        }
+
+
+        public async Task<IActionResult> GetDataAsync(string txtThoigian, string txtLoaiPT, string cboTinh)
+        {
+            try
+            {
+                string endPoint = "http://app.vr.org.vn/ptpublic/quahankd.aspx";
+                var client = new HttpClient();
+
+                // get valid key
+                WebRequest request = HttpWebRequest.Create(endPoint);
+                WebResponse response1 = request.GetResponse();
+                StreamReader reader = new StreamReader(response1.GetResponseStream());
+                string responseText = reader.ReadToEnd();
+
+                bool loop = true;
+                int i = 0;
+                var tableHTML = "";
+                var table = "";
+                string old = "";
+                List<KeyValuePair<string, string>> data = new List<KeyValuePair<string, string>>();
+                List<KeyValuePair<string, string>> dataOld = new List<KeyValuePair<string, string>>();
+
+                while (loop)
+                {
+                    //if (i == 0)
+                    //{
+                    //    data.Add(new KeyValuePair<string, string>("__EVENTTARGET", ""));
+                    //    data.Add(new KeyValuePair<string, string>("__EVENTARGUMENT", ""));
+                    //    data.Add(new KeyValuePair<string, string>("cmdTraCuu", "Tra cứu"));
+                    //}
+                    //else
+                    //{
+                    //    data.Add(new KeyValuePair<string, string>("__EVENTTARGET", "DGTimPT$ctl54$ctl" + (i < 10 ? "0" + i.ToString() : i.ToString())));
+                    //    data.Add(new KeyValuePair<string, string>("__EVENTARGUMENT", ""));
+                    //}
+
+                    using (var httpClient = new HttpClient())
+                    {
+                        if (i == 0)
+                        {
+                            List<KeyValuePair<string, string>> dataGet = UtilsController.ParseDataRequest(responseText);
+                            dataGet.Add(new KeyValuePair<string, string>("cboTinh", cboTinh));
+                            dataGet.Add(new KeyValuePair<string, string>("txtLoaiPT", txtLoaiPT));
+                            dataGet.Add(new KeyValuePair<string, string>("txtThoigian", txtThoigian));
+                            dataGet.Add(new KeyValuePair<string, string>("__EVENTTARGET", ""));
+                            dataGet.Add(new KeyValuePair<string, string>("__EVENTARGUMENT", ""));
+                            dataGet.Add(new KeyValuePair<string, string>("cmdTraCuu", "Tra cứu"));
+                            data = dataGet;
+                        }
+                        else
+                        {
+                            dataOld.Add(new KeyValuePair<string, string>("__EVENTTARGET", "DGTimPT$ctl54$ctl" + (i < 10 ? "0" + i.ToString() : i.ToString())));
+                            dataOld.Add(new KeyValuePair<string, string>("__EVENTARGUMENT", ""));
+                            dataOld.Add(new KeyValuePair<string, string>("cboTinh", cboTinh));
+                            dataOld.Add(new KeyValuePair<string, string>("txtLoaiPT", txtLoaiPT));
+                            dataOld.Add(new KeyValuePair<string, string>("txtThoigian", txtThoigian));
+                            data = dataOld;
+
+                        }
+                        using (var content = new FormUrlEncodedContent(data))
+                        {
+                            content.Headers.Clear();
+                            content.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
+
+                            HttpResponseMessage response = await httpClient.PostAsync(endPoint, content);
+
+                            var result = response.Content.ReadAsStringAsync().Result;
+                            dataOld = UtilsController.ParseDataRequest(result);
+                            if (old != null)
+                            {
+                                if (old.Length == result.Length)
+                                {
+                                    loop = false;
+                                    continue;
+                                }
+                            }
+                            old = result;
+
+                            Regex regex1 = new Regex("<table cell[^>]*>[\\s\\S]*?<\\/table>", RegexOptions.IgnoreCase);
+                            Match match1;
+                            for (match1 = regex1.Match(result); match1.Success; match1 = match1.NextMatch())
+                            {
+                                var result2 = match1.Groups[0].Value;
+
+                                Regex regex2 = new Regex("<tr[^>]*>[\\s\\S]*?<\\/tr>", RegexOptions.IgnoreCase);
+                                Match match2;
+                                int count = 0;
+                                for (match2 = regex2.Match(result2); match2.Success; match2 = match2.NextMatch())
+                                {
+                                    if (count > 0)
+                                    {
+                                        if (!match2.Groups[0].Value.Contains("DGTimPT$ctl"))
+                                        {
+                                            var d = match2.Groups[0].Value;
+                                            table = table + d;
+                                        }
+                                    }
+                                    count++;
+                                }
+                            }
+                        }
+                    }
+                    i++;
+                }
+
+                //tableHTML = "<html>" + "<body>" +
+                //    "<table cellspacing=\"0\" width=\"500\" style=\"table-layout:fixed; border-collapse:collapse; width: 500pt\">" +
+                //    @"<tr><td> Số TT </td>
+                //    <td> Biển đăng ký</td>
+                //    <td> Ngày đăng ký</td>
+                //    <td> Nhãn hiệu </td>
+                //    <td> Chủ phương tiên</td>
+                //    <td> Địa chỉ </td>
+                //    <td> Ngày kiểm định</td>
+                //    <td> Đơn vị KĐ</td>
+                //    <td> Số GCN KĐ</td>
+                //    <td> Thời hạn GCN</td>
+                //    </tr>" +
+                //    table +
+                //    @"</table>" +
+                //    "</body></html>";
+
+                //String tableHTMLNew = tableHTML.Replace("&", "&amp;");
+                //MemoryStream ms = new MemoryStream();
+                //using (ExcelEngine excelEngine = new ExcelEngine())
+                //{
+
+                //    // Step 2 : Instantiate the Excel application object.
+                //    IApplication application = excelEngine.Excel;
+                //    application.DefaultVersion = ExcelVersion.Excel2016;
+
+                //    // A workbook is created.
+                //    IWorkbook workbook = application.Workbooks.Create(1);
+
+                //    // The first worksheet object in the worksheets collection is accessed.
+                //    IWorksheet worksheet = workbook.Worksheets[0];
+
+                //    byte[] byteArray = Encoding.UTF8.GetBytes(tableHTMLNew);
+
+                //    MemoryStream file = new MemoryStream(byteArray);
+
+                //    // Imports HTML table into the worksheet from first row and first column.
+                //    worksheet.ImportHtmlTable(file, 1, 1);
+
+                //    worksheet.UsedRange.AutofitColumns();
+                //    worksheet.UsedRange.AutofitRows();
+
+                //    workbook.SaveAs(ms);
+                //    ms.Position = 0;
+                //}
+                //return File(ms, "Application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "Export-HTML-Table.xlsx");
+                RegistryViewModel model = new RegistryViewModel();
+                model.table = tableHTML;
+
+                return RedirectToAction("/Index", model);
+            }
+            catch (Exception ex)
+            {
+                return Redirect("/Home");
+            }
+        }
+
+    }
+}

+ 807 - 0
SuperCms/Controllers/ReportController.cs

@@ -0,0 +1,807 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+//using System.Drawing;
+using System.Globalization;
+using System.IO;
+//using DocumentFormat.OpenXml.Spreadsheet;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.Logging;
+using Newtonsoft.Json;
+using SuperCms.Extensions;
+using SuperCms.Models;
+using SuperCms.Repositories;
+using Syncfusion.Drawing;
+using Syncfusion.XlsIO;
+
+namespace SuperCms.Controllers
+{
+    public class ReportController : BaseController
+    {
+        private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof(Program));
+
+        ISuperCmsRepo iSuperCmsRepo;
+
+        public ReportController(ISuperCmsRepo ISuperCmsRepo)
+        {
+            iSuperCmsRepo = ISuperCmsRepo;
+        }
+
+        public IActionResult Index(
+            String typeGet,
+            String telcoID,
+            String companyID,
+            String startDate,
+            String endDate,
+            String page,
+            String dateGet
+        )
+        {
+            try
+            {
+                if (!CheckAuthToken())
+                {
+                    return Redirect("/Home/Login");
+                }
+
+                ReportViewModel model = new ReportViewModel();
+
+                model.date = dateGet != null ? dateGet : (DateTime.Now.Day).ToString();
+
+                model.page = page != null ? page : "1";
+                model.typeGet = typeGet != null ? typeGet : UtilsController.Constant.MONEY_GET;
+                model.services = new ConnConfigs();
+                model.services.data = new List<ConnConfig>();
+
+                model.telcos = new ConnTelcos();
+                model.telcos.data = new List<ConnTelco>();
+
+                model.companies = new ConnCompanies();
+                model.companies.data = new List<ConnCompany>();
+
+                model.distributedDataByServices = new List<DistributedDataByService>();
+
+                ConnCompanies companies = HttpContext.Session.GetComplexData<ConnCompanies>(
+                    "companies"
+                );
+                if (companies == null)
+                {
+                    var resultT = iSuperCmsRepo.GetConnCompany(log);
+
+                    var propertyT = typeof(ICollection).GetProperty("Count");
+                    int countT = (int)propertyT.GetValue(resultT, null);
+                    if (resultT != null && countT > 0)
+                    {
+                        ConnCompanies data = new ConnCompanies();
+                        data.data = new List<ConnCompany>();
+                        foreach (IDictionary<string, object> row in (IEnumerable<object>)resultT)
+                        {
+                            var json = JsonConvert.SerializeObject(row);
+                            ConnCompany dataGet = new ConnCompany(json.ToString());
+                            data.data.Add(dataGet);
+                        }
+                        HttpContext.Session.SetComplexData("companies", data);
+                    }
+                }
+                model.companies = companies;
+                model.companyID = companyID != null ? companyID : companies.data[0].id;
+
+                ConnTelcos telcos = HttpContext.Session.GetComplexData<ConnTelcos>("telcos");
+                if (telcos == null)
+                {
+                    var resultT = iSuperCmsRepo.GetConnTelco(log);
+
+                    var propertyT = typeof(ICollection).GetProperty("Count");
+                    int countT = (int)propertyT.GetValue(resultT, null);
+                    if (resultT != null && countT > 0)
+                    {
+                        ConnTelcos data = new ConnTelcos();
+                        data.data = new List<ConnTelco>();
+                        foreach (IDictionary<string, object> row in (IEnumerable<object>)resultT)
+                        {
+                            var json = JsonConvert.SerializeObject(row);
+                            ConnTelco dataGet = new ConnTelco(json.ToString());
+                            data.data.Add(dataGet);
+                        }
+                        telcos = new ConnTelcos();
+                        telcos.data = new List<ConnTelco>();
+                        telcos = data;
+                        HttpContext.Session.SetComplexData("telcos", data);
+                    }
+                }
+                model.telcos = telcos;
+                model.telcoID = telcoID != null ? telcoID : model.telcos.data[0].id;
+
+                ConnConfigs services = HttpContext.Session.GetComplexData<ConnConfigs>("services");
+                if (services == null)
+                {
+                    var resultC = iSuperCmsRepo.GetConnConfig(log);
+
+                    var propertyC = typeof(ICollection).GetProperty("Count");
+                    int countC = (int)propertyC.GetValue(resultC, null);
+                    if (resultC != null && countC > 0)
+                    {
+                        ConnConfigs data = new ConnConfigs();
+                        data.data = new List<ConnConfig>();
+                        foreach (IDictionary<string, object> row in (IEnumerable<object>)resultC)
+                        {
+                            var json = JsonConvert.SerializeObject(row);
+                            ConnConfig dataGet = new ConnConfig(json.ToString());
+                            data.data.Add(dataGet);
+                        }
+                        services = new ConnConfigs();
+                        services.data = new List<ConnConfig>();
+                        services = data;
+                        HttpContext.Session.SetComplexData("services", data);
+                    }
+                }
+                model.services = services;
+
+                List<DistributedByTelcoAndCompany> dis = HttpContext.Session.GetComplexData<
+                    List<DistributedByTelcoAndCompany>
+                >("distributedByTelcoAndCompany");
+                if (dis == null)
+                {
+                    List<DistributedByTelcoAndCompany> distributedByTelcoAndCompanyT =
+                        new List<DistributedByTelcoAndCompany>();
+                    dis = distributedByTelcoAndCompany(
+                        model.telcos,
+                        model.companies,
+                        model.services,
+                        0,
+                        distributedByTelcoAndCompanyT
+                    );
+                    HttpContext.Session.SetComplexData("distributedByTelcoAndCompany", dis);
+                }
+
+                model.telco = model.telcos.data.Find(x => x.id == model.telcoID);
+                model.company = model.companies.data.Find(x => x.id == model.companyID);
+                DistributedByTelcoAndCompany resGet = dis.Find(x => x.telco.id == model.telcoID);
+                ConnCompanies c = new ConnCompanies();
+                c.data = new List<ConnCompany>();
+                ConnConfigs s = new ConnConfigs();
+                s.data = new List<ConnConfig>();
+                model.services = resGet != null ? resGet.services : s;
+                model.companies = resGet != null ? resGet.companies : c;
+
+                // sort
+                model.services.data.Sort(
+                    delegate(ConnConfig x, ConnConfig y)
+                    {
+                        if (x.sequence == null && y.sequence == null)
+                            return 0;
+                        else if (x.sequence == null)
+                            return -1;
+                        else if (y.sequence == null)
+                            return 1;
+                        else
+                            return int.Parse(x.sequence).CompareTo(int.Parse(y.sequence));
+                    }
+                );
+
+                // get data in 2 months
+                String start =
+                    startDate == null
+                        ? getStartByMonthToString(-1)
+                        : DateTime
+                            .ParseExact(
+                                startDate,
+                                "yyyy-MM-ddTHH:mm:ss",
+                                CultureInfo.InvariantCulture
+                            )
+                            .ToString("MM/dd/yyyy HH:mm:ss");
+                String end =
+                    endDate == null
+                        ? getEndByDayToString()
+                        : DateTime
+                            .ParseExact(endDate, "yyyy-MM-ddTHH:mm", CultureInfo.InvariantCulture)
+                            .ToString("MM/dd/yyyy HH:mm:ss");
+
+                DateTime startDateTime =
+                    startDate == null
+                        ? getStartByMonthToDate(-1)
+                        : DateTime.ParseExact(
+                            startDate,
+                            "yyyy-MM-ddTHH:mm:ss",
+                            CultureInfo.InvariantCulture
+                        );
+                DateTime endDateTime =
+                    endDate == null
+                        ? getEndByDayToDate()
+                        : DateTime.ParseExact(
+                            endDate,
+                            "yyyy-MM-ddTHH:mm:ss",
+                            CultureInfo.InvariantCulture
+                        );
+
+                model.listDate = getRangeTime(startDateTime, endDateTime);
+                model.timeNow = model.listDate[1].ToString("dd/MM");
+                for (int i = 0; i < model.services.data.Count; i++)
+                {
+                    DistributedDataByService distributedDataByService =
+                        new DistributedDataByService();
+                    distributedDataByService.dataNow = new ConnDatas();
+                    distributedDataByService.dataLastMonth = new ConnDatas();
+
+                    distributedDataByService.service = model.services.data[i];
+                    distributedDataByService.dataLastMonth.data = new List<ConnData>();
+                    distributedDataByService.dataNow.data = new List<ConnData>();
+
+                    // distributed by time
+                    distributedDataByService.distributedByTimes = new List<DistributedByTime>();
+
+                    var resultD = iSuperCmsRepo.GetConnDataByService(
+                        log,
+                        model.services.data[i].id,
+                        start,
+                        end
+                    );
+                    var propertyD = typeof(ICollection).GetProperty("Count");
+                    int countD = (int)propertyD.GetValue(resultD, null);
+                    if (resultD != null && countD > 0)
+                    {
+                        ConnDatas data = new ConnDatas();
+                        data.data = new List<ConnData>();
+                        foreach (IDictionary<string, object> row in (IEnumerable<object>)resultD)
+                        {
+                            var json = JsonConvert.SerializeObject(row);
+                            ConnData dataGet = new ConnData(json.ToString());
+                            data.data.Add(dataGet);
+                        }
+                        DateTime startLastMonth = startDateTime;
+                        DateTime stopLastMonth = getEndByMonthToDate(-1);
+                        List<ConnData> dataLastMonth = data.data.FindAll(
+                            x =>
+                                DateTime.Compare(
+                                    startLastMonth,
+                                    DateTime.ParseExact(
+                                        x.dateGet + " 01:00:00",
+                                        "dd/MM/yyyy HH:mm:ss",
+                                        CultureInfo.InvariantCulture
+                                    )
+                                ) <= 0
+                                && DateTime.Compare(
+                                    DateTime.ParseExact(
+                                        x.dateGet + " 01:00:00",
+                                        "dd/MM/yyyy HH:mm:ss",
+                                        CultureInfo.InvariantCulture
+                                    ),
+                                    stopLastMonth
+                                ) <= 0
+                        );
+
+                        DateTime startNow = getStartByMonthToDate(0);
+                        DateTime stopNow = getEndByDayToDate();
+
+                        List<ConnData> dataNow = data.data.FindAll(
+                            x =>
+                                DateTime.Compare(
+                                    startNow,
+                                    DateTime.ParseExact(
+                                        x.dateGet + " 01:00:00",
+                                        "dd/MM/yyyy HH:mm:ss",
+                                        CultureInfo.InvariantCulture
+                                    )
+                                ) < 0
+                                && DateTime.Compare(
+                                    DateTime.ParseExact(
+                                        x.dateGet + " 01:00:00",
+                                        "dd/MM/yyyy HH:mm:ss",
+                                        CultureInfo.InvariantCulture
+                                    ),
+                                    stopNow
+                                ) < 0
+                        );
+
+                        //if (dataNow.Count == 0)
+                        //{
+                        //    dataNow.Add(dataLastMonth[dataLastMonth.Count - 1]);
+                        //}
+
+                        distributedDataByService.dataLastMonth.data =
+                            dataLastMonth != null ? dataLastMonth : new List<ConnData>();
+                        distributedDataByService.dataNow.data =
+                            dataNow != null ? dataNow : new List<ConnData>();
+
+                        for (int t = 0; t < model.listDate.Count - 1; t++)
+                        {
+                            DistributedByTime time = new DistributedByTime();
+                            time.time = model.listDate[t + 1];
+                            time.connDatas = new ConnDatas();
+                            time.connDatas.data = data.data.FindAll(
+                                x =>
+                                    DateTime.Compare(
+                                        model.listDate[t + 1],
+                                        DateTime.ParseExact(
+                                            x.dateGet + " 01:00:00",
+                                            "dd/MM/yyyy HH:mm:ss",
+                                            CultureInfo.InvariantCulture
+                                        )
+                                    ) <= 0
+                                    && DateTime.Compare(
+                                        DateTime.ParseExact(
+                                            x.dateGet + " 01:00:00",
+                                            "dd/MM/yyyy HH:mm:ss",
+                                            CultureInfo.InvariantCulture
+                                        ),
+                                        model.listDate[t]
+                                    ) <= 0
+                            );
+                            distributedDataByService.distributedByTimes.Add(time);
+                        }
+                    }
+                    model.distributedDataByServices.Add(distributedDataByService);
+                }
+                return View("Index", model);
+            }
+            catch (Exception ex)
+            {
+                log.Error("Exception: ", ex);
+                return Redirect("/Home");
+            }
+        }
+
+        public IActionResult Export(String telcoID, String companyID)
+        {
+            try
+            {
+                if (!CheckAuthToken())
+                {
+                    return Redirect("/Home/Login");
+                }
+                ReportViewModel model = new ReportViewModel();
+                ConnTelcos telcos = HttpContext.Session.GetComplexData<ConnTelcos>("telcos");
+                ConnCompanies companies = HttpContext.Session.GetComplexData<ConnCompanies>(
+                    "companies"
+                );
+
+                model.telcos = telcos;
+                model.companies = companies;
+                List<DistributedByTelcoAndCompany> disByTelcoAndCompany =
+                    HttpContext.Session.GetComplexData<List<DistributedByTelcoAndCompany>>(
+                        "distributedByTelcoAndCompany"
+                    );
+                DistributedByTelcoAndCompany dis = disByTelcoAndCompany.Find(
+                    x => x.telco.id == telcoID
+                );
+
+                if (dis == null)
+                {
+                    model.telco = disByTelcoAndCompany[0].telco;
+                    model.company = disByTelcoAndCompany[0].companies.data[0];
+                    model.services = disByTelcoAndCompany[0].services;
+                }
+                else
+                {
+                    model.telco = dis.telco;
+                    model.companies = dis.companies;
+                    model.company =
+                        companyID != null
+                            ? dis.companies.data.Find(x => x.id == companyID)
+                            : dis.companies.data[0];
+                    model.services = dis.services;
+                }
+                model.telcoID = model.telco.id;
+                model.companyID = model.company.id;
+
+                model.startDate = getStartByMonthToString(-1);
+                model.endDate = getEndByDayToString();
+
+                return PartialView("Export", model);
+            }
+            catch (Exception ex)
+            {
+                return Redirect("/Home");
+            }
+        }
+
+        public IActionResult ExportAction(
+            String telcoID,
+            String companyID,
+            String serviceID,
+            String startMonth,
+            String endMonth
+        )
+        {
+            try
+            {
+                if (!CheckAuthToken())
+                {
+                    return Redirect("/Home/Login");
+                }
+                //Adding values to a worksheet range
+                // get all data
+                ConnTelcos telcos = HttpContext.Session.GetComplexData<ConnTelcos>("telcos");
+                ConnCompanies companies = HttpContext.Session.GetComplexData<ConnCompanies>(
+                    "companies"
+                );
+                ConnConfigs services = HttpContext.Session.GetComplexData<ConnConfigs>("services");
+
+                //sort
+                telcos.data.Sort(
+                    delegate(ConnTelco x, ConnTelco y)
+                    {
+                        return int.Parse(x.id).CompareTo(int.Parse(y.id));
+                    }
+                );
+
+                companies.data.Sort(
+                    delegate(ConnCompany x, ConnCompany y)
+                    {
+                        return int.Parse(x.id).CompareTo(int.Parse(y.id));
+                    }
+                );
+
+                DateTime startDateTime =
+                    startMonth == null
+                        ? getStartByMonthToDate(-1)
+                        : DateTime.ParseExact(
+                            convertToDateTimeServer(startMonth),
+                            "MM/dd/yyyy HH:mm:ss",
+                            CultureInfo.InvariantCulture
+                        );
+                DateTime endDateTime =
+                    endMonth == null
+                        ? getEndByDayToDate()
+                        : DateTime.ParseExact(
+                            convertToDateTimeServer(endMonth),
+                            "MM/dd/yyyy HH:mm:ss",
+                            CultureInfo.InvariantCulture
+                        );
+
+                List<DateTime> listMonths = getRangeMonth(startDateTime, endDateTime);
+                List<DistributedByTelcoAndCompany> disByTelcoAndCompany =
+                    HttpContext.Session.GetComplexData<List<DistributedByTelcoAndCompany>>(
+                        "distributedByTelcoAndCompany"
+                    );
+                // if telcoID == null => get all telcos and all companies
+                List<DistributedDataForExcelByOneMonth> disAllMonth =
+                    new List<DistributedDataForExcelByOneMonth>();
+                List<DistributedByTime> dataAll = new List<DistributedByTime>();
+
+                if (telcoID == UtilsController.Constant.GET_ALL)
+                {
+                    for (int i = 0; i < listMonths.Count - 1; i++)
+                    {
+                        DateTime start = listMonths[i + 1];
+                        DateTime end = listMonths[i];
+                        DistributedDataForExcelByOneMonth disOneMonth =
+                            new DistributedDataForExcelByOneMonth();
+                        List<DateTime> listDate = getRangeTimeForExport(start, end);
+                        disOneMonth.time = listDate;
+                        disOneMonth.telcos = telcos;
+                        disOneMonth.companies = companies;
+                        disOneMonth.services = services;
+                        disOneMonth.distributedByTimes = new List<DistributedByTime>();
+
+                        String startTime = start.ToString("MM/dd/yyyy HH:mm:ss");
+                        String endTime = end.ToString("MM/dd/yyyy HH:mm:ss");
+
+                        // get data
+                        for (int s = 0; s < services.data.Count; s++)
+                        {
+                            var resultD = iSuperCmsRepo.GetConnDataByService(
+                                log,
+                                services.data[s].id,
+                                startTime,
+                                endTime
+                            );
+                            var propertyD = typeof(ICollection).GetProperty("Count");
+                            int countD = (int)propertyD.GetValue(resultD, null);
+                            if (resultD != null && countD > 0)
+                            {
+                                ConnDatas data = new ConnDatas();
+                                data.data = new List<ConnData>();
+                                foreach (
+                                    IDictionary<string, object> row in (IEnumerable<object>)resultD
+                                )
+                                {
+                                    var json = JsonConvert.SerializeObject(row);
+                                    ConnData dataGet = new ConnData(json.ToString());
+                                    data.data.Add(dataGet);
+                                }
+
+                                for (int t = 0; t < listDate.Count - 1; t++)
+                                {
+                                    DistributedByTime time = new DistributedByTime();
+                                    time.time = listDate[t + 1];
+                                    time.service = services.data[s];
+
+                                    time.connDatas = new ConnDatas();
+                                    time.connDatas.data = data.data.FindAll(
+                                        x =>
+                                            DateTime.Compare(
+                                                listDate[t + 1],
+                                                DateTime.ParseExact(
+                                                    x.dateGet + " 01:00:00",
+                                                    "dd/MM/yyyy HH:mm:ss",
+                                                    CultureInfo.InvariantCulture
+                                                )
+                                            ) <= 0
+                                            && DateTime.Compare(
+                                                DateTime.ParseExact(
+                                                    x.dateGet + " 01:00:00",
+                                                    "dd/MM/yyyy HH:mm:ss",
+                                                    CultureInfo.InvariantCulture
+                                                ),
+                                                listDate[t]
+                                            ) <= 0
+                                    );
+                                    disOneMonth.distributedByTimes.Add(time);
+                                    dataAll.Add(time);
+                                }
+                            }
+                        }
+                        disAllMonth.Add(disOneMonth);
+                    }
+                }
+                else if (
+                    telcoID != UtilsController.Constant.GET_ALL
+                    && companyID == UtilsController.Constant.GET_ALL
+                )
+                {
+                    for (int i = 0; i < listMonths.Count - 1; i++)
+                    {
+                        DateTime start = listMonths[i + 1];
+                        DateTime end = listMonths[i];
+
+                        DistributedDataForExcelByOneMonth disOneMonth =
+                            new DistributedDataForExcelByOneMonth();
+                        List<DateTime> listDate = getRangeTimeForExport(start, end);
+                        disOneMonth.time = listDate;
+
+                        disOneMonth.telcos = new ConnTelcos();
+                        disOneMonth.telcos.data = new List<ConnTelco>();
+                        disOneMonth.telcos.data.Add(telcos.data.Find(x => x.id == telcoID));
+                        disOneMonth.services = services;
+                        disOneMonth.companies = companies;
+                        disOneMonth.distributedByTimes = new List<DistributedByTime>();
+
+                        String startTime = start.ToString("MM/dd/yyyy HH:mm:ss");
+                        String endTime = end.ToString("MM/dd/yyyy HH:mm:ss");
+
+                        // get all service which have telcoID and companyID equal to telcoID and all
+                        List<ConnConfig> servicesFilter = services.data.FindAll(
+                            x => x.telcoID == telcoID
+                        );
+                        disOneMonth.services = new ConnConfigs();
+                        disOneMonth.services.data = servicesFilter;
+
+                        // get data
+                        for (int s = 0; s < servicesFilter.Count; s++)
+                        {
+                            var resultD = iSuperCmsRepo.GetConnDataByService(
+                                log,
+                                servicesFilter[s].id,
+                                startTime,
+                                endTime
+                            );
+                            var propertyD = typeof(ICollection).GetProperty("Count");
+                            int countD = (int)propertyD.GetValue(resultD, null);
+                            if (resultD != null && countD > 0)
+                            {
+                                ConnDatas data = new ConnDatas();
+                                data.data = new List<ConnData>();
+                                foreach (
+                                    IDictionary<string, object> row in (IEnumerable<object>)resultD
+                                )
+                                {
+                                    var json = JsonConvert.SerializeObject(row);
+                                    ConnData dataGet = new ConnData(json.ToString());
+                                    data.data.Add(dataGet);
+                                }
+                                for (int t = 0; t < listDate.Count - 1; t++)
+                                {
+                                    DistributedByTime time = new DistributedByTime();
+                                    time.time = listDate[t + 1];
+                                    time.service = servicesFilter[s];
+                                    time.connDatas = new ConnDatas();
+                                    time.connDatas.data = data.data.FindAll(
+                                        x =>
+                                            DateTime.Compare(
+                                                listDate[t + 1],
+                                                DateTime.ParseExact(
+                                                    x.dateGet + " 01:00:00",
+                                                    "dd/MM/yyyy HH:mm:ss",
+                                                    CultureInfo.InvariantCulture
+                                                )
+                                            ) <= 0
+                                            && DateTime.Compare(
+                                                DateTime.ParseExact(
+                                                    x.dateGet + " 01:00:00",
+                                                    "dd/MM/yyyy HH:mm:ss",
+                                                    CultureInfo.InvariantCulture
+                                                ),
+                                                listDate[t]
+                                            ) <= 0
+                                    );
+                                    disOneMonth.distributedByTimes.Add(time);
+                                    dataAll.Add(time);
+                                }
+                            }
+                        }
+                        disAllMonth.Add(disOneMonth);
+                    }
+                }
+                else if (
+                    telcoID != UtilsController.Constant.GET_ALL
+                    && companyID != UtilsController.Constant.GET_ALL
+                    && serviceID == UtilsController.Constant.GET_ALL
+                )
+                {
+                    for (int i = 0; i < listMonths.Count - 1; i++)
+                    {
+                        DateTime start = listMonths[i + 1];
+                        DateTime end = listMonths[i];
+
+                        DistributedDataForExcelByOneMonth disOneMonth =
+                            new DistributedDataForExcelByOneMonth();
+                        List<DateTime> listDate = getRangeTimeForExport(start, end);
+                        disOneMonth.time = listDate;
+
+                        disOneMonth.telcos = new ConnTelcos();
+                        disOneMonth.telcos.data = new List<ConnTelco>();
+                        disOneMonth.telcos.data.Add(telcos.data.Find(x => x.id == telcoID));
+
+                        disOneMonth.companies = new ConnCompanies();
+                        disOneMonth.companies.data = new List<ConnCompany>();
+                        disOneMonth.companies.data.Add(companies.data.Find(x => x.id == companyID));
+                        disOneMonth.distributedByTimes = new List<DistributedByTime>();
+                        //disOneMonth.services = services;
+                        String startTime = start.ToString("MM/dd/yyyy HH:mm:ss");
+                        String endTime = end.ToString("MM/dd/yyyy HH:mm:ss");
+
+                        // get all service which have telcoID and companyID equal to telcoID and all
+                        List<ConnConfig> servicesFilter = services.data.FindAll(
+                            x => x.telcoID == telcoID && x.companyID == companyID
+                        );
+                        disOneMonth.services = new ConnConfigs();
+                        disOneMonth.services.data = servicesFilter;
+                        // get data
+                        for (int s = 0; s < servicesFilter.Count; s++)
+                        {
+                            var resultD = iSuperCmsRepo.GetConnDataByService(
+                                log,
+                                servicesFilter[s].id,
+                                startTime,
+                                endTime
+                            );
+                            var propertyD = typeof(ICollection).GetProperty("Count");
+                            int countD = (int)propertyD.GetValue(resultD, null);
+                            if (resultD != null && countD > 0)
+                            {
+                                ConnDatas data = new ConnDatas();
+                                data.data = new List<ConnData>();
+                                foreach (
+                                    IDictionary<string, object> row in (IEnumerable<object>)resultD
+                                )
+                                {
+                                    var json = JsonConvert.SerializeObject(row);
+                                    ConnData dataGet = new ConnData(json.ToString());
+                                    data.data.Add(dataGet);
+                                }
+                                for (int t = 0; t < listDate.Count - 1; t++)
+                                {
+                                    DistributedByTime time = new DistributedByTime();
+                                    time.time = listDate[t + 1];
+                                    time.service = servicesFilter[s];
+                                    time.connDatas = new ConnDatas();
+                                    time.connDatas.data = data.data.FindAll(
+                                        x =>
+                                            DateTime.Compare(
+                                                listDate[t + 1],
+                                                DateTime.ParseExact(
+                                                    x.dateGet + " 01:00:00",
+                                                    "dd/MM/yyyy HH:mm:ss",
+                                                    CultureInfo.InvariantCulture
+                                                )
+                                            ) <= 0
+                                            && DateTime.Compare(
+                                                DateTime.ParseExact(
+                                                    x.dateGet + " 01:00:00",
+                                                    "dd/MM/yyyy HH:mm:ss",
+                                                    CultureInfo.InvariantCulture
+                                                ),
+                                                listDate[t]
+                                            ) <= 0
+                                    );
+                                    disOneMonth.distributedByTimes.Add(time);
+                                    dataAll.Add(time);
+                                }
+                            }
+                        }
+                        disAllMonth.Add(disOneMonth);
+                    }
+                }
+                else
+                {
+                    for (int i = 0; i < listMonths.Count - 1; i++)
+                    {
+                        DateTime start = listMonths[i + 1];
+                        DateTime end = listMonths[i];
+
+                        DistributedDataForExcelByOneMonth disOneMonth =
+                            new DistributedDataForExcelByOneMonth();
+                        List<DateTime> listDate = getRangeTimeForExport(start, end);
+                        disOneMonth.time = listDate;
+
+                        disOneMonth.telcos = new ConnTelcos();
+                        disOneMonth.telcos.data = new List<ConnTelco>();
+                        disOneMonth.telcos.data.Add(telcos.data.Find(x => x.id == telcoID));
+
+                        disOneMonth.companies = new ConnCompanies();
+                        disOneMonth.companies.data = new List<ConnCompany>();
+                        disOneMonth.companies.data.Add(companies.data.Find(x => x.id == companyID));
+                        disOneMonth.distributedByTimes = new List<DistributedByTime>();
+
+                        String startTime = start.ToString("MM/dd/yyyy HH:mm:ss");
+                        String endTime = end.ToString("MM/dd/yyyy HH:mm:ss");
+
+                        // get all service which have telcoID and companyID equal to telcoID and all
+                        ConnConfig serviceFilter = services.data.Find(x => x.id == serviceID);
+                        disOneMonth.services = new ConnConfigs();
+                        disOneMonth.services.data = new List<ConnConfig>();
+                        disOneMonth.services.data.Add(serviceFilter);
+                        // get data
+                        var resultD = iSuperCmsRepo.GetConnDataByService(
+                            log,
+                            serviceFilter.id,
+                            startTime,
+                            endTime
+                        );
+                        var propertyD = typeof(ICollection).GetProperty("Count");
+                        int countD = (int)propertyD.GetValue(resultD, null);
+                        if (resultD != null && countD > 0)
+                        {
+                            ConnDatas data = new ConnDatas();
+                            data.data = new List<ConnData>();
+                            foreach (
+                                IDictionary<string, object> row in (IEnumerable<object>)resultD
+                            )
+                            {
+                                var json = JsonConvert.SerializeObject(row);
+                                ConnData dataGet = new ConnData(json.ToString());
+                                data.data.Add(dataGet);
+                            }
+                            for (int t = 0; t < listDate.Count - 1; t++)
+                            {
+                                DistributedByTime time = new DistributedByTime();
+                                time.time = listDate[t + 1];
+                                time.service = serviceFilter;
+                                time.connDatas = new ConnDatas();
+                                time.connDatas.data = data.data.FindAll(
+                                    x =>
+                                        DateTime.Compare(
+                                            listDate[t + 1],
+                                            DateTime.ParseExact(
+                                                x.dateGet + " 01:00:00",
+                                                "dd/MM/yyyy HH:mm:ss",
+                                                CultureInfo.InvariantCulture
+                                            )
+                                        ) <= 0
+                                        && DateTime.Compare(
+                                            DateTime.ParseExact(
+                                                x.dateGet + " 01:00:00",
+                                                "dd/MM/yyyy HH:mm:ss",
+                                                CultureInfo.InvariantCulture
+                                            ),
+                                            listDate[t]
+                                        ) <= 0
+                                );
+                                disOneMonth.distributedByTimes.Add(time);
+                                dataAll.Add(time);
+                            }
+                        }
+                        disAllMonth.Add(disOneMonth);
+                    }
+                }
+                return Excel(endDateTime, disAllMonth, dataAll);
+            }
+            catch (Exception ex)
+            {
+                log.Error("Exception: ", ex);
+                return Redirect("/Home");
+            }
+        }
+    }
+}

+ 134 - 0
SuperCms/Controllers/StockController.cs

@@ -0,0 +1,134 @@
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Threading.Tasks;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.AspNetCore.Mvc.Rendering;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.Extensions.Configuration;
+using SuperCms.Database;
+using SuperCms.Models;
+
+namespace SuperCms.Controllers
+{
+    public class StockController : BaseController
+    {
+        private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof(Program));
+        private readonly ModelContext _context;
+        IConfiguration configuration;
+
+        public StockController(ModelContext context)
+        {
+            _context = context;
+        }
+
+        // GET: ConnCkDatas
+        public async Task<IActionResult> Index(String fromDate, String toDate)
+        {
+            if (!CheckAuthToken())
+            {
+                return Redirect("/Home/Login");
+            }
+            StockViewModel model = new StockViewModel();
+
+            try
+            {
+                var nganh = await _context.ConnCkNganh.ToListAsync();
+                //var data = await _context.ConnCkData.ToListAsync();
+
+                model.stockNganh = nganh;
+
+                DateTime fromDateR = fromDate == null ? DateTime.Now.AddDays(-10) :
+                    DateTime.ParseExact(fromDate, UtilsController.validformats, CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal);
+                DateTime toDateR = toDate == null ? DateTime.Now.AddDays(-1) :
+                    DateTime.ParseExact(toDate, UtilsController.validformats, CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal);
+
+                model.fromDate = fromDateR.ToString("dd/MM/yyyy");
+                model.toDate = toDateR.ToString("dd/MM/yyyy");
+
+                var dataGet = _context.ConnCkData.ToList().Where(a =>
+                    DateTime.ParseExact(a.Ngay, "dd/MM/yyyy", CultureInfo.InvariantCulture) >= fromDateR &&
+                    DateTime.ParseExact(a.Ngay, "dd/MM/yyyy", CultureInfo.InvariantCulture) <= toDateR
+                ).ToList();
+                model.stockData = dataGet;
+                model.listDate = getRangeTime(fromDateR, toDateR);
+
+                Dictionary<ConnCkNganh, Dictionary<DateTime, ConnCkData>> dictionaryData =
+                    new Dictionary<ConnCkNganh, Dictionary<DateTime, ConnCkData>>();
+
+                // distribution to nhom nganh 
+                for (int i = 0; i < nganh.Count; i++)
+                {
+                    // phan bo ve cac ngay
+                    //List<Dictionary<DateTime, List<ConnCkData>>> keyValuePairsList = new List<Dictionary<DateTime, List<ConnCkData>>>();
+                    Dictionary<DateTime, ConnCkData> keyValuePairs = new Dictionary<DateTime, ConnCkData>();
+
+                    for (int j = 0; j < model.listDate.Count; j++)
+                    {
+                        ConnCkData dataNganh = dataGet.Find(a => a.NganhId == nganh[i].Id &&
+                                DateTime.ParseExact(a.Ngay, "dd/MM/yyyy", CultureInfo.InvariantCulture) == model.listDate[j]
+                        );
+                        keyValuePairs.Add(model.listDate[j], dataNganh);
+                        //keyValuePairsList.Add(keyValuePairs);
+                    }
+                    dictionaryData.Add(nganh[i], keyValuePairs);
+                }
+                model.distributeData = dictionaryData;
+            }
+            catch (Exception ex)
+            {
+                log.Error("Exception: ", ex);
+                return Redirect("/Home");
+            }
+            return View(model);
+        }
+
+        [ValidateAntiForgeryToken]
+        public async Task<IActionResult> ExportAsync(String fromDate, String toDate)
+        {
+            try
+            {
+                var nganh = await _context.ConnCkNganh.ToListAsync();
+
+                DateTime fromDateR = fromDate == null ? DateTime.Now.AddDays(-10) :
+                    DateTime.ParseExact(fromDate, UtilsController.validformats, CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal);
+                DateTime toDateR = toDate == null ? DateTime.Now.AddDays(-1) :
+                    DateTime.ParseExact(toDate, UtilsController.validformats, CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal);
+
+                var dataGet = _context.ConnCkData.ToList().Where(a =>
+                    DateTime.ParseExact(a.Ngay, "dd/MM/yyyy", CultureInfo.InvariantCulture) >= fromDateR &&
+                    DateTime.ParseExact(a.Ngay, "dd/MM/yyyy", CultureInfo.InvariantCulture) <= toDateR
+                ).ToList();
+                List<DateTime> listDate = getRangeTime(fromDateR, toDateR);
+
+                Dictionary<ConnCkNganh, Dictionary<DateTime, ConnCkData>> dictionaryData =
+                    new Dictionary<ConnCkNganh, Dictionary<DateTime, ConnCkData>>();
+
+                // distribution to nhom nganh 
+                for (int i = 0; i < nganh.Count; i++)
+                {
+                    // phan bo ve cac ngay
+                    //List<Dictionary<DateTime, List<ConnCkData>>> keyValuePairsList = new List<Dictionary<DateTime, List<ConnCkData>>>();
+                    Dictionary<DateTime, ConnCkData> keyValuePairs = new Dictionary<DateTime, ConnCkData>();
+
+                    for (int j = 0; j < listDate.Count; j++)
+                    {
+                        ConnCkData dataNganh = dataGet.Find(a => a.NganhId == nganh[i].Id &&
+                                DateTime.ParseExact(a.Ngay, "dd/MM/yyyy", CultureInfo.InvariantCulture) == listDate[j]
+                        );
+                        keyValuePairs.Add(listDate[j], dataNganh);
+                        //keyValuePairsList.Add(keyValuePairs);
+                    }
+                    dictionaryData.Add(nganh[i], keyValuePairs);
+                }
+                return ToExcelStock(listDate, dictionaryData);
+            }
+            catch (Exception ex)
+            {
+                log.Error("Exception: ", ex);
+                return Redirect("/Home");
+            }
+        }
+    }
+}

+ 329 - 0
SuperCms/Controllers/SupportController.cs

@@ -0,0 +1,329 @@
+using DocumentFormat.OpenXml.Packaging;
+using Microsoft.AspNetCore.Hosting;
+using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.AspNetCore.StaticFiles;
+using NPOI.HSSF.UserModel;
+using NPOI.SS.UserModel;
+using NPOI.XSSF.UserModel;
+using SuperCms.Extensions;
+using SuperCms.Models;
+using Syncfusion.DocIO;
+using Syncfusion.DocIO.DLS;
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.IO;
+using System.IO.Compression;
+using System.Linq;
+using System.Net;
+using System.Net.Http;
+using System.Net.Http.Headers;
+using System.Text;
+using System.Threading.Tasks;
+using System.Xml.Linq;
+using BorderStyle = Syncfusion.DocIO.DLS.BorderStyle;
+using HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment;
+
+namespace SuperCms.Controllers
+{
+    public class SupportController : BaseController
+    {
+        private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof(Program));
+        private IHostingEnvironment _hostingEnvironment;
+        OracleController oracle;
+
+        public SupportController(IHostingEnvironment hostingEnvironment)
+        {
+            _hostingEnvironment = hostingEnvironment;
+        }
+
+        public IActionResult Index(String tableType, String actionFile)
+        {
+            try
+            {
+                if (!CheckAuthToken())
+                {
+                    return Redirect("/Home/Login");
+                }
+                //UtilsController.PaymentConverter(null);
+
+                SupportViewModel model = new SupportViewModel();
+                model.typeTable = tableType != null ? tableType : UtilsController.Constant.PAYMENT_FILE;
+                model.actionFile = actionFile != null ? actionFile : UtilsController.Constant.SHOW_FILE;
+
+                // get file to show
+
+
+                return View("Index", model);
+            }
+            catch (Exception ex)
+            {
+                log.Error("Exception: ", ex);
+                return Redirect("/Home");
+            }
+        }
+
+        public ActionResult Download(String tableType)
+        {
+            try
+            {
+                String zipPath = "";
+                if (tableType == UtilsController.Constant.PAYMENT_FILE)
+                {
+                    string startPath = "./Files/Payments/" + DateTime.Now.ToString("dd_MM_yyyy");
+                    zipPath = "./Files/Payments/" + "Payments_" + DateTime.Now.ToString("dd_MM_yyyy") + ".zip";
+                    if (UtilsController.CheckFile(zipPath))
+                    {
+                        // delete file
+                        UtilsController.DeleteFile(zipPath);
+                    }
+                    ZipFile.CreateFromDirectory(startPath, zipPath);
+                }
+                else
+                {
+                    string startPath = "./Files/Invoices/" + DateTime.Now.ToString("dd_MM_yyyy");
+                    zipPath = "./Files/Invoices/" + "Invoices_" + DateTime.Now.ToString("dd_MM_yyyy") + ".zip";
+                    if (UtilsController.CheckFile(zipPath))
+                    {
+                        // delete file
+                        UtilsController.DeleteFile(zipPath);
+                    }
+                    ZipFile.CreateFromDirectory(startPath, zipPath);
+                }
+
+                var provider = new FileExtensionContentTypeProvider();
+                if (!provider.TryGetContentType(zipPath, out var contentType))
+                {
+                    contentType = "application/octet-stream";
+                }
+
+                var bytes = UtilsController.GetFileByte(zipPath);
+                return File(bytes, contentType, Path.GetFileName(zipPath));
+
+            }
+            catch (Exception ex)
+            {
+                log.Error("Exception: ", ex);
+                return null;
+            }
+        }
+
+        [ValidateAntiForgeryToken]
+        public ActionResult UploadAction(String typeTable)
+        {
+            try
+            {
+                if (!CheckAuthToken())
+                {
+                    return Redirect("/Home/Login");
+                }
+                IFormFile file = Request.Form.Files[0];
+                string folderName = "UploadExcel";
+                string webRootPath = _hostingEnvironment.WebRootPath;
+                string newPath = Path.Combine(webRootPath, folderName);
+                StringBuilder sb = new StringBuilder();
+                if (!Directory.Exists(newPath))
+                {
+                    Directory.CreateDirectory(newPath);
+                }
+                if (file.Length > 0)
+                {
+                    string sFileExtension = Path.GetExtension(file.FileName).ToLower();
+                    ISheet sheet;
+                    string fullPath = Path.Combine(newPath, file.FileName);
+                    using (var stream = new FileStream(fullPath, FileMode.Create))
+                    {
+                        file.CopyTo(stream);
+                        stream.Position = 0;
+                        if (sFileExtension == ".xls")
+                        {
+                            HSSFWorkbook hssfwb = new HSSFWorkbook(stream); //This will read the Excel 97-2000 formats  
+                            sheet = hssfwb.GetSheetAt(0); //get first sheet from workbook  
+                        }
+                        else
+                        {
+                            XSSFWorkbook hssfwb = new XSSFWorkbook(stream); //This will read 2007 Excel format  
+                            sheet = hssfwb.GetSheetAt(0); //get first sheet from workbook   
+                        }
+                        IRow headerRow = sheet.GetRow(0); //Get Header Row
+                        int cellCount = headerRow.LastCellNum;
+                        sb.Append("<table class='table table-bordered'><tr>");
+                        for (int j = 0; j < cellCount; j++)
+                        {
+                            NPOI.SS.UserModel.ICell cell = headerRow.GetCell(j);
+                            if (cell == null || string.IsNullOrWhiteSpace(cell.ToString())) continue;
+                            sb.Append("<th>" + cell.ToString() + "</th>");
+                        }
+                        sb.Append("</tr>");
+                        sb.AppendLine("<tr>");
+
+                        List<Contract> contracts = new List<Contract>();
+
+                        for (int i = (sheet.FirstRowNum + 1); i <= sheet.LastRowNum; i++) //Read Excel File
+                        {
+                            IRow row = sheet.GetRow(i);
+                            if (row == null)
+                            {
+                                continue;
+                            }
+                            if (row.Cells.All(d => d.CellType == CellType.Blank))
+                            {
+                                continue;
+                            };
+                            for (int j = row.FirstCellNum; j < cellCount; j++)
+                            {
+                                if (row.GetCell(j) != null)
+                                {
+                                    sb.Append("<td>" + row.GetCell(j).ToString() + "</td>");
+                                }
+                                else
+                                {
+                                    sb.Append("<td> </td>");
+                                }
+                            }
+                            sb.AppendLine("</tr>");
+
+                            Contract contract = new Contract();
+                            contract.id = row.GetCell(0) != null ? row.GetCell(0).ToString() : "";
+                            contract.telco = row.GetCell(13) != null ? row.GetCell(13).ToString() : "";
+                            contract.syntaxTelco = row.GetCell(2) != null ? row.GetCell(2).ToString() : "";
+                            contract.company = row.GetCell(1) != null ? row.GetCell(1).ToString() : "";
+                            contract.service = row.GetCell(3) != null ? row.GetCell(3).ToString() : "";
+                            contract.contractCode = row.GetCell(4) != null ? row.GetCell(4).ToString() : "";
+                            contract.address = row.GetCell(8) != null ? row.GetCell(8).ToString() : "";
+                            contract.account = row.GetCell(9) != null ? row.GetCell(9).ToString() : "";
+                            contract.swiftCode = row.GetCell(11) != null ? row.GetCell(11).ToString() : "";
+                            contract.time = row.GetCell(5) != null ? row.GetCell(5).ToString() : "";
+                            contract.money = row.GetCell(6) != null ? row.GetCell(6).ToString() : "";
+                            contract.beneficiary = row.GetCell(7) != null ? row.GetCell(7).ToString() : "";
+                            contract.syntaxConpany = row.GetCell(12) != null ? row.GetCell(12).ToString() : "";
+                            contract.bank = row.GetCell(10) != null ? row.GetCell(10).ToString() : "";
+                            contract.addressTelco = row.GetCell(14) != null ? row.GetCell(14).ToString() : "";
+                            contract.taxCode = row.GetCell(15) != null ? row.GetCell(15).ToString() : "";
+
+                            contracts.Add(contract);
+
+                        }
+                        HttpContext.Session.SetComplexData("contractsImport", contracts);
+
+                        sb.Append("</table>");
+                    }
+                }
+                return this.Content(sb.ToString());
+            }
+            catch (Exception ex)
+            {
+                log.Error("Exception: ", ex);
+                return Redirect("/Home");
+            }
+        }
+
+        [ValidateAntiForgeryToken]
+        public JsonResult ImportAction(String typeTable, String timeNow)
+        {
+            if (!CheckAuthToken())
+            {
+                return Json(new
+                {
+                    code = UtilsController.Constant.ERROR,
+                    href = "/Home/Login"
+                });
+            }
+            try
+            {
+                bool check = false;
+                List<Contract> contracts = HttpContext.Session.GetComplexData<List<Contract>>("contractsImport");
+                List<Contract> listITL = new List<Contract>();
+                for (int i = 0; i < contracts.Count; i++)
+                {
+
+                    if (typeTable == UtilsController.Constant.PAYMENT_FILE)
+                    {
+                        // following by telco
+                        if (contracts[i].syntaxTelco == "NATCOM")
+                        {
+                            check = UtilsController.PaymentNatcomAllDumpt(contracts[i]);
+                        }
+                        else
+                        {
+                            check = UtilsController.PaymentDumpt(contracts[i]);
+                        }
+                    }
+                    else
+                    {
+                        if (contracts[i].syntaxTelco == "NATCOM")
+                        {
+                            check = UtilsController.InvoiceNatcomInterlandDumpt(contracts[i]);
+                        }
+                        else
+                        {
+                            if (contracts[i].syntaxConpany == "GTS")
+                            {
+                                check = UtilsController.InvoiceGTSDumpt(contracts[i]);
+                            }
+                            else if (contracts[i].syntaxConpany == "VTECH" || contracts[i].syntaxConpany == "VIETTECH")
+                            {
+                                check = UtilsController.InvoiceVTECHDumpt(contracts[i]);
+                            }
+                            else if (contracts[i].syntaxConpany == "ITL" || contracts[i].syntaxConpany == "INTERLAND")
+                            {
+                                check = UtilsController.InvoiceITLDumpt(contracts[i]);
+                            }
+                            else
+                            {
+                                log.Error("No match syntax company " + contracts[i].syntaxConpany);
+                            }
+                        }
+                    }
+                }
+
+                DateTime startTimeNowDateTime = DateTime.Parse(timeNow, CultureInfo.InvariantCulture);
+                DateTime startdate = new DateTime(startTimeNowDateTime.Year, startTimeNowDateTime.Month, startTimeNowDateTime.Day, 0, 0, 0);
+                DateTime enddate = new DateTime(startTimeNowDateTime.Year, startTimeNowDateTime.Month, startTimeNowDateTime.Day, 23, 59, 59);
+
+                ////convert a doc file to html
+                //UtilsController.ReadDocFileToHtml();
+
+
+                HttpContext.Session.RemoveComplexData("contractsImport");
+
+                return check ? Json(new
+                {
+                    code = UtilsController.Constant.SUCCESS,
+                    message = "Import Successful",
+                    href = "/Import"
+                }) : Json(new
+                {
+                    code = UtilsController.Constant.ERROR,
+                    message = "Import Fails",
+                    href = "/Import"
+                });
+            }
+            catch (Exception ex)
+            {
+                log.Error("Exp: " + ex);
+            }
+            return Json(new
+            {
+                code = UtilsController.Constant.ERROR,
+                message = "Import Fails",
+                href = "/Import"
+            });
+        }
+
+        [ValidateAntiForgeryToken]
+        public IActionResult DownloadTemplate()
+        {
+            String file = "./Files/Template/template.xlsx";
+            var provider = new FileExtensionContentTypeProvider();
+            if (!provider.TryGetContentType(file, out var contentType))
+            {
+                contentType = "application/octet-stream";
+            }
+
+            var bytes = UtilsController.GetFileByte(file);
+            return File(bytes, contentType, Path.GetFileName(file));
+        }
+    }
+}

+ 3097 - 0
SuperCms/Controllers/UtilsController.cs

@@ -0,0 +1,3097 @@
+using System;
+using System.Collections.Generic;
+//using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Xml.Linq;
+using Aspose.Words;
+using Aspose.Words.Saving;
+using DocumentFormat.OpenXml.Packaging;
+using Microsoft.AspNetCore.Mvc;
+using Spire.Doc;
+using SuperCms.Models;
+using Syncfusion.DocIO;
+using Syncfusion.DocIO.DLS;
+using Syncfusion.Drawing;
+using OutlineLevel = Syncfusion.DocIO.OutlineLevel;
+using System.IO;
+using System.Globalization;
+using Syncfusion.XlsIO;
+using System.Net.Http;
+using System.Net;
+using System.Text.RegularExpressions;
+
+namespace SuperCms.Controllers
+{
+    public class UtilsController
+    {
+        private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof(Program));
+
+        public static string[] validformats = new[] {
+            "MM/dd/yyyy",
+            "yyyy/MM/dd",
+            "dd/MM/yyyy HH:mm:ss",
+            "MM/dd/yyyy HH:mm:ss",
+            "MM/dd/yyyy hh:mm tt",
+            "yyyy-MM-dd HH:mm:ss, fff",
+            "yyyy-MM-ddTHH:mm:ss",
+            "yyyy-MM-ddTHH:mm",
+            "yyyy-MM-ddTHH:mm:ss.fff",
+            "yyyy-MM-dd",
+            "HH:mm:ss","HH:mm"};
+        public static String convertLargeNumberToString(int remain, String resString)
+        {
+            int result, phanDu;
+            if (remain > 1000)
+            {
+                result = remain / 1000;
+                phanDu = remain - result * 1000;
+                if (resString == "")
+                {
+                    return convertLargeNumberToString(phanDu, resString + "." + phanDu);
+
+                }
+                return convertLargeNumberToString(phanDu, resString + ".");
+            }
+            else
+            {
+                return resString + "." + remain.ToString();
+            }
+        }
+
+        public static string RandomString(int size, bool lowerCase)
+        {
+            StringBuilder builder = new StringBuilder();
+            Random random = new Random();
+            char ch;
+            for (int i = 0; i < size; i++)
+            {
+                ch = Convert.ToChar(Convert.ToInt32(Math.Floor(26 * random.NextDouble() + 65)));
+                builder.Append(ch);
+            }
+            if (lowerCase)
+                return builder.ToString().ToLower();
+            return builder.ToString();
+        }
+
+        public class Constant
+        {
+            public const String SERVICE_ID = "3";
+            public const String PARENT_ID = "-1";
+
+            public const String NUMBER_ROW_ON_PAGE = "10";
+            public const String GET_ALL = "-1";
+
+            //
+            public const String SUCCESS = "0";
+            public const String ERROR = "-1";
+
+            public const String BOTS = "1";
+            public const String GROUPS = "2";
+            public const String SCHEDULES = "3";
+            public const String CONFIGS = "4";
+            public const String SENDMAIL = "5";
+            public const String SERVICE_CONFIG = "6";
+
+
+            public const int MAX_SCHEDULE_STATUS = 5;
+            public const int MAX_GROUP_STATUS = 2;
+            public const int MAX_BOT_STATUS = 1;
+            public const int MAX_WARNING_STATUS = 2;
+
+            public const String DISABLE = "0";
+            public const String ENABLE = "1";
+
+            public const String MONEY_GET = "0";
+            public const String SUBS_GET = "1";
+            public const int MAX_GET = 2;
+            public const int MAX_TABLE = 5;
+
+
+            public const String ONLY_REVEUNUE = "0";
+            public const String ALL_REVEUNUE = "1";
+            public const int MAX_FILE = 2;
+            public const String PAYMENT_FILE = "0";
+            public const String INVOICE_FILE = "1";
+
+            public const String SHOW_FILE = "1";
+            public const String SAVE_FILE = "2";
+
+            public const String DISABLE_GET_DATA = "0";
+            public const String ENABLE_GET_DATA_AND_WARNING = "1";
+            public const String ENABLE_GET_DATA_AND_NOT_WARNING = "2";
+        }
+
+        public static String convertNameTable(String tableType)
+        {
+            switch (tableType)
+            {
+                case "1": return "Cấu hình người gửi";
+                case "2": return "Cấu hình người nhận";
+                case "3": return "Cấu hình lập lịch gửi";
+                case "4": return "Cấu hình configuration";
+                case "5": return "Cấu hình gửi email";
+                case "6": return "Cấu hình thêm mới dịch vụ";
+                default: return "NULL";
+            }
+        }
+        public static String convertNameTypeGet(String typeGet)
+        {
+            switch (typeGet)
+            {
+                case "0": return "Money Report";
+                case "1": return "Subscribers Report";
+                default: return "NULL";
+            }
+        }
+
+        public static String convertScheduleStatus(int status)
+        {
+            switch (status)
+            {
+                case 0: return "Disable";
+                case 1: return "Reminder one time";
+                case 2: return "Reminder hour by hour";
+                case 3: return "Reminder day by day";
+                case 4: return "Reminder week by week";
+                case 5: return "Reminder month by month";
+                default: return "NULL";
+            }
+        }
+
+        public static String convertBotStatus(int status)
+        {
+            switch (status)
+            {
+                case 0: return "Disable";
+                case 1: return "Get and warning";
+                case 2: return "Get and not warning";
+                default: return "NULL";
+            }
+        }
+
+        public static String convertServiceState(int state)
+        {
+            switch (state)
+            {
+                case 0: return "Không";
+                case 1: return "Có";
+                default: return "NULL";
+            }
+        }
+
+        public static String convertGroupStatus(int status)
+        {
+            switch (status)
+            {
+                case 0: return "Disable";
+                case 1: return "Communication";
+                case 2: return "Alarm";
+                default: return "NULL";
+            }
+        }
+
+        public static String convertSendMailStatus(int status)
+        {
+            switch (status)
+            {
+                case 0: return "Disable";
+                case 1: return "Enable";
+                default: return "NULL";
+            }
+        }
+
+        public static string ConvertListType(String type)
+        {
+            switch (type)
+            {
+                case "0": return "Payment file";
+                case "1": return "Invoice file";
+                default: return type + " Unknown";
+            }
+        }
+
+        public static String ReadDocFileToHtml()
+        {
+            String html = System.IO.File.ReadAllText("./resources/payment_code_all.html");
+            return html;
+        }
+
+
+        public static bool InvoiceNatcomInterlandDumpt(Contract contract)
+        {
+            try
+            {
+                string[] validformats = new[] { "MM/dd/yyyy", "yyyy/MM/dd", "MM/dd/yyyy HH:mm:ss", "dd-MMM-yyyy",
+                                        "MM/dd/yyyy hh:mm tt", "yyyy-MM-dd HH:mm:ss, fff", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mm", "yyyy-MM-ddTHH:mm:ss.fff", "yyyy-MM-dd"};
+
+                DateTime convertTime = DateTime.ParseExact(contract.time, validformats,
+            CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal);
+
+                // Creating a new document.
+                WordDocument document = new WordDocument();
+
+                // Setting document page margins.
+                MarginsF pagemargins = new MarginsF();
+                pagemargins.Bottom = 20;
+                pagemargins.Top = 20;
+                pagemargins.Left = 75;
+                pagemargins.Right = 75;
+                // Assigning document page margins to the current section.
+
+                IWSection section = document.AddSection();
+                section.PageSetup.Margins = pagemargins;
+                section.AddParagraph();
+                IWTable table = section.AddTable();
+
+                int rowNum = 7, columnNum = 2;
+                RowFormat format = new RowFormat();
+                table.ResetCells(rowNum, columnNum);
+                table.TableFormat.HorizontalAlignment = RowAlignment.Center;
+                float tableWidth = table.Width;
+
+                //table.TableFormat.BackColor = Color.FromArgb(192, 192, 192);
+                table.Rows[0].Cells[0].CellFormat.BackColor = Color.FromArgb(156, 194, 229);
+                table.Rows[0].Cells[1].CellFormat.BackColor = Color.FromArgb(156, 194, 229);
+                table.Rows[2].Cells[0].CellFormat.BackColor = Color.FromArgb(156, 194, 229);
+                table.Rows[2].Cells[1].CellFormat.BackColor = Color.FromArgb(156, 194, 229);
+                table.Rows[4].Cells[0].CellFormat.BackColor = Color.FromArgb(156, 194, 229);
+                table.Rows[4].Cells[1].CellFormat.BackColor = Color.FromArgb(156, 194, 229);
+
+                for (int i = 0; i < columnNum; i++)
+                {
+                    for (int j = 0; j < rowNum; j++)
+                    {
+                        WTableCell cell = table.Rows[j].Cells[i];
+                        cell.Width = (float)(i == 0 ? tableWidth * 0.5 : tableWidth * 0.5);
+                        cell.CellFormat.Paddings.Top = 5;
+                        cell.CellFormat.Paddings.Bottom = 5;
+                        cell.CellFormat.Paddings.Left = 5;
+                        cell.CellFormat.Paddings.Right = 5;
+                        if (i == 0)
+                        {
+                            if (j == 6)
+                            {
+                                cell.CellFormat.Borders.BorderType = BorderStyle.Cleared;
+                                cell.CellFormat.Borders.Top.BorderType = BorderStyle.Single;
+                                cell.CellFormat.Borders.Right.BorderType = BorderStyle.Single;
+                                cell.CellFormat.Borders.Bottom.BorderType = BorderStyle.Single;
+                            }
+                            else if (j == 1 || j == 2 || j == 5 || j == 4)
+                            {
+                                cell.CellFormat.Borders.BorderType = BorderStyle.Cleared;
+                                cell.CellFormat.Borders.Top.BorderType = BorderStyle.Single;
+                                cell.CellFormat.Borders.Right.BorderType = BorderStyle.Single;
+                            }
+                            else
+                            {
+                                cell.CellFormat.Borders.BorderType = BorderStyle.Cleared;
+                                cell.CellFormat.Borders.Right.BorderType = BorderStyle.Single;
+                            }
+                        }
+                        else if (i == 1)
+                        {
+                            if (j == 6)
+                            {
+                                cell.CellFormat.Borders.BorderType = BorderStyle.Cleared;
+                                cell.CellFormat.Borders.Top.BorderType = BorderStyle.Single;
+                                cell.CellFormat.Borders.Bottom.BorderType = BorderStyle.Single;
+                            }
+                            else if (j == 1 || j == 2 || j == 5 || j == 4)
+                            {
+                                cell.CellFormat.Borders.BorderType = BorderStyle.Cleared;
+                                cell.CellFormat.Borders.Top.BorderType = BorderStyle.Single;
+                                cell.CellFormat.Borders.Left.BorderType = BorderStyle.Single;
+                            }
+                            else
+                            {
+                                cell.CellFormat.Borders.BorderType = BorderStyle.Cleared;
+                            }
+                        }
+                    }
+                }
+                table.ApplyHorizontalMerge(0, 0, 1);
+                IWParagraph para = table[0, 0].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Center;
+
+                IWTextRange textRange = para.AppendText("COMMERCIAL INVOICE");
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 16;
+                textRange.CharacterFormat.Bold = true;
+
+
+                //para = table[0, 0].AddParagraph();
+                //para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Center;
+                //textRange = para.AppendText("No: " + convertTime.ToString("ddMMyyyy") + "-" + contract.id);
+                //textRange.CharacterFormat.FontName = "Times New Roman";
+                //textRange.CharacterFormat.FontSize = 13;
+                //textRange.CharacterFormat.Bold = true;
+
+                para = table[0, 0].AddParagraph();
+
+                para = table[1, 0].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+                textRange = para.AppendText("DATE OF EXPORT");
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.Bold = true;
+
+                para = table[1, 0].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+                textRange = para.AppendText(convertTime.ToString("MMMM/yyyy"));
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.Bold = false;
+
+                para = table[1, 0].AddParagraph();
+
+                para = table[1, 1].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+                textRange = para.AppendText("INVOICE NUMBER: " + convertTime.ToString("MM") + contract.id + "/" + convertTime.ToString("yyyy"));
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.Bold = true;
+
+                //para = table[1, 1].AddParagraph();
+                //para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+                //String d1 = (int.Parse(contract.id) < 10 ? "0" + contract.id : contract.id) + "/VTL-" + contract.syntaxConpany + "/VAS/" + convertTime.ToString("yyyy");
+                //textRange = para.AppendText(convertTime.ToString("MM") + contract.id + "/" + convertTime.ToString("yyyy"));
+                //textRange.CharacterFormat.FontName = "Times New Roman";
+                //textRange.CharacterFormat.FontSize = 11;
+                //textRange.CharacterFormat.Bold = false;
+
+                para = table[1, 1].AddParagraph();
+
+                para = table[2, 0].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+                textRange = para.AppendText("PROVIDER");
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.Bold = true;
+
+                para = table[2, 1].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+                textRange = para.AppendText("BUYER");
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.Bold = true;
+
+                para = table[3, 0].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+                textRange = para.AppendText("NAME: " + contract.company);
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.Bold = false;
+
+                para = table[3, 0].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+                textRange = para.AppendText("Address: " + contract.address);
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.Bold = false;
+
+                //para = table[3, 0].AddParagraph();
+                //para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+                //textRange = para.AppendText("Tax code: " + "0108453894");
+                //textRange.CharacterFormat.FontName = "Times New Roman";
+                //textRange.CharacterFormat.FontSize = 11;
+                //textRange.CharacterFormat.Bold = false;
+
+                para = table[3, 0].AddParagraph();
+
+                para = table[3, 1].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+                textRange = para.AppendText("NAME: " + contract.telco);
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.Bold = false;
+
+                para = table[3, 1].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+                textRange = para.AppendText("Address: " + contract.addressTelco);
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.Bold = false;
+
+                //para = table[3, 1].AddParagraph();
+                //para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+                //textRange = para.AppendText("Tax code: " + "1150150");
+                //textRange.CharacterFormat.FontName = "Times New Roman";
+                //textRange.CharacterFormat.FontSize = 11;
+                //textRange.CharacterFormat.Bold = false;
+
+                para = table[3, 1].AddParagraph();
+
+
+                para = table[4, 0].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Center;
+                textRange = para.AppendText("DEFINITION OF PAYMENT");
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.Bold = true;
+
+                IWTable table2 = table[4, 1].AddTable();
+                rowNum = 1; columnNum = 3;
+                table2.ResetCells(rowNum, columnNum);
+                table2.TableFormat.HorizontalAlignment = RowAlignment.Center;
+                tableWidth = table2.Width;
+                for (int i = 0; i < columnNum; i++)
+                {
+                    for (int j = 0; j < rowNum; j++)
+                    {
+                        WTableCell cell = table2.Rows[j].Cells[i];
+                        if (i == 1)
+                        {
+                            cell.CellFormat.Borders.BorderType = BorderStyle.Cleared;
+                            cell.CellFormat.Borders.Left.BorderType = BorderStyle.Single;
+                            cell.CellFormat.Borders.Right.BorderType = BorderStyle.Single;
+                        }
+                        else
+                            cell.CellFormat.Borders.BorderType = BorderStyle.Cleared;
+                    }
+                }
+                IWParagraph para2 = table2[0, 0].AddParagraph();
+                para2.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+
+                textRange = para2.AppendText("QUANTITY");
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 10;
+                textRange.CharacterFormat.Bold = true;
+
+                para2 = table2[0, 1].AddParagraph();
+                para2.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+
+                textRange = para2.AppendText("UNIT PRICE (USD)");
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 10;
+                textRange.CharacterFormat.Bold = true;
+
+                para2 = table2[0, 2].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+
+                textRange = para2.AppendText("TOTAL (USD)");
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 10;
+                textRange.CharacterFormat.Bold = true;
+
+
+                //
+                para = table[5, 0].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+                textRange = para.AppendText(contract.service + " SHARING REVENUE OF  " + convertTime.AddMonths(-1).ToString("MMMM yyyy"));
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.Bold = false;
+                para = table[5, 0].AddParagraph();
+
+                table2 = table[5, 1].AddTable();
+                rowNum = 1; columnNum = 3;
+                table2.ResetCells(rowNum, columnNum);
+                table2.TableFormat.HorizontalAlignment = RowAlignment.Center;
+                tableWidth = table2.Width;
+                for (int i = 0; i < columnNum; i++)
+                {
+                    for (int j = 0; j < rowNum; j++)
+                    {
+                        WTableCell cell = table2.Rows[j].Cells[i];
+                        cell.CellFormat.Paddings.Top = 5;
+                        cell.CellFormat.Paddings.Bottom = 5;
+                        cell.CellFormat.Paddings.Left = 5;
+                        cell.CellFormat.Paddings.Right = 5;
+
+                        if (i == 1)
+                        {
+                            cell.CellFormat.Borders.BorderType = BorderStyle.Cleared;
+                            cell.CellFormat.Borders.Left.BorderType = BorderStyle.Single;
+                            cell.CellFormat.Borders.Right.BorderType = BorderStyle.Single;
+                        }
+                        else
+                            cell.CellFormat.Borders.BorderType = BorderStyle.Cleared;
+                    }
+                }
+                para2 = table2[0, 0].AddParagraph();
+                para2.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+
+                textRange = para2.AppendText("1");
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.Bold = false;
+                para2 = table2[0, 0].AddParagraph();
+                para2 = table2[0, 0].AddParagraph();
+
+
+                para2 = table2[0, 1].AddParagraph();
+                para2.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+
+                textRange = para2.AppendText(int.Parse(contract.money).ToString("0,0", CultureInfo.InvariantCulture));
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.Bold = false;
+                para2 = table2[0, 1].AddParagraph();
+                para2 = table2[0, 1].AddParagraph();
+
+
+                para2 = table2[0, 2].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+
+                textRange = para2.AppendText(int.Parse(contract.money).ToString("0,0", CultureInfo.InvariantCulture));
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.Bold = false;
+
+                para2 = table2[0, 2].AddParagraph();
+                para2 = table2[0, 2].AddParagraph();
+
+
+                para = table[6, 0].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+                textRange = para.AppendText("TOTAL");
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 12;
+                textRange.CharacterFormat.Bold = true;
+
+                para = table[6, 0].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+                textRange = para.AppendText("By word:");
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.Bold = true;
+
+                para = table[6, 1].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Right;
+                textRange = para.AppendText(int.Parse(contract.money).ToString("0,0", CultureInfo.InvariantCulture));
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.Bold = true;
+
+                para = table[6, 1].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+                textRange = para.AppendText(ConvertAmount(double.Parse(contract.money)) + " Dollars.");
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 10;
+                textRange.CharacterFormat.Bold = true;
+
+                para = table[6, 0].AddParagraph();
+                para = table[6, 1].AddParagraph();
+                // content
+                //Appends paragraph.
+
+                IWParagraph paragraph = section.HeadersFooters.Header.AddParagraph();
+                paragraph = section.AddParagraph();
+                paragraph = section.AddParagraph();
+
+
+                paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+                textRange = paragraph.AppendText("Please remit payment to:") as WTextRange;
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.Bold = true;
+
+                paragraph = section.AddParagraph();
+
+
+                table = section.AddTable();
+                rowNum = 5; columnNum = 2;
+                table.ResetCells(rowNum, columnNum);
+                table.TableFormat.HorizontalAlignment = RowAlignment.Center;
+                tableWidth = table.Width;
+                for (int i = 0; i < columnNum; i++)
+                {
+                    for (int j = 0; j < rowNum; j++)
+                    {
+                        WTableCell cell = table.Rows[j].Cells[i];
+
+                        cell.Width = (float)(i == 0 ? tableWidth * 0.3 : tableWidth * 0.7);
+                        cell.CellFormat.Paddings.Top = 5;
+                        cell.CellFormat.Paddings.Bottom = 5;
+                        cell.CellFormat.Paddings.Left = 5;
+                        cell.CellFormat.Paddings.Right = 5;
+
+                        if (i == 0)
+                        {
+                            cell.CellFormat.Borders.BorderType = BorderStyle.Cleared;
+                            cell.CellFormat.Borders.Top.BorderType = BorderStyle.Single;
+                            cell.CellFormat.Borders.Right.BorderType = BorderStyle.Single;
+                            cell.CellFormat.Borders.Bottom.BorderType = BorderStyle.Single;
+                        }
+                        else if (i == 1)
+                        {
+                            cell.CellFormat.Borders.BorderType = BorderStyle.Cleared;
+                            cell.CellFormat.Borders.Top.BorderType = BorderStyle.Single;
+                            cell.CellFormat.Borders.Bottom.BorderType = BorderStyle.Single;
+                        }
+
+                    }
+                }
+
+                para = table[0, 0].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+
+                textRange = para.AppendText("Name of Beneficiary");
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.Bold = false;
+
+                para = table[0, 1].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+
+                textRange = para.AppendText(contract.beneficiary);
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.Bold = false;
+
+                para = table[1, 0].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+
+                textRange = para.AppendText("Address");
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.Bold = false;
+
+                para = table[1, 1].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+
+                textRange = para.AppendText(contract.address);
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.Bold = false;
+
+                para = table[2, 0].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+
+                textRange = para.AppendText("Name of Beneficiary’s bank");
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.Bold = false;
+
+                para = table[2, 1].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+
+                textRange = para.AppendText(contract.bank);
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.Bold = false;
+
+                para = table[3, 0].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+
+                textRange = para.AppendText("Account number");
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.Bold = false;
+
+                para = table[3, 1].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+
+                textRange = para.AppendText(contract.account);
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.Bold = false;
+
+                para = table[4, 0].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+
+                textRange = para.AppendText("SWIFT Code");
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.Bold = false;
+
+                para = table[4, 1].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+
+                textRange = para.AppendText(contract.swiftCode);
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.Bold = false;
+
+                paragraph = section.AddParagraph();
+
+
+                table = section.AddTable();
+                rowNum = 1; columnNum = 2;
+                table.ResetCells(rowNum, columnNum);
+                table.TableFormat.HorizontalAlignment = RowAlignment.Center;
+                tableWidth = table.Width;
+                table.TableFormat.Borders.Color = Color.White;
+                for (int i = 0; i < columnNum; i++)
+                {
+                    for (int j = 0; j < rowNum; j++)
+                    {
+                        WTableCell cell = table.Rows[j].Cells[i];
+                        cell.Width = (float)(i == 0 ? tableWidth * 0.6 : tableWidth * 0.4);
+                        cell.CellFormat.Paddings.Top = 5;
+                        cell.CellFormat.Paddings.Bottom = 5;
+                        cell.CellFormat.Paddings.Left = 5;
+                        cell.CellFormat.Paddings.Right = 5;
+                        cell.CellFormat.Borders.BorderType = Syncfusion.DocIO.DLS.BorderStyle.Cleared;
+                    }
+                }
+
+                para = table[0, 1].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Center;
+                textRange = para.AppendText("SIGNATURE");
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.Bold = true;
+
+                //Saves the Word document to  MemoryStream
+                MemoryStream stream = new MemoryStream();
+                document.Save(stream, FormatType.Docx);
+                stream.Position = 0;
+
+                bool exists = System.IO.Directory.Exists("./Files/Invoices/" + DateTime.Now.ToString("dd_MM_yyyy"));
+                if (!exists)
+                    System.IO.Directory.CreateDirectory("./Files/Invoices/" + DateTime.Now.ToString("dd_MM_yyyy"));
+                FileStream outputStream = new FileStream("./Files/Invoices/" + DateTime.Now.ToString("dd_MM_yyyy") + "/" + contract.id + "_" + contract.syntaxTelco + "_invoice_" + contract.syntaxConpany + ".docx", FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite);
+                document.Save(outputStream, FormatType.Docx);
+                document.Close();
+                outputStream.Flush();
+                outputStream.Dispose();
+                return true;
+            }
+            catch (Exception ex)
+            {
+                log.Error("Exp: " + ex);
+                return false;
+            }
+        }
+
+        public static bool PaymentNatcomAllDumpt(Contract contract)
+        {
+            try
+            {
+                string[] validformats = new[] { "dd/MM/yyyy", "dd-MMM-yyyy" };
+
+                DateTime convertTime = DateTime.ParseExact(contract.time, validformats,
+            CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal);
+
+                // Creating a new document.
+                WordDocument document = new WordDocument();
+
+                // Setting document page margins.
+                MarginsF pagemargins = new MarginsF();
+                pagemargins.Bottom = 20;
+                pagemargins.Top = 20;
+                pagemargins.Left = 75;
+                pagemargins.Right = 75;
+                // Assigning document page margins to the current section.
+
+                IWSection section = document.AddSection();
+                section.PageSetup.Margins = pagemargins;
+                section.AddParagraph();
+                IWTable table = section.AddTable();
+
+                int rowNum = 1, columnNum = 2;
+                RowFormat format = new RowFormat();
+                table.ResetCells(rowNum, columnNum);
+                table.TableFormat.HorizontalAlignment = RowAlignment.Center;
+
+
+
+                for (int i = 0; i < columnNum; i++)
+                {
+                    for (int j = 0; j < rowNum; j++)
+                    {
+                        WTableCell cell = table.Rows[j].Cells[i];
+                        cell.Width = (float)(i == 0 ? table.Width * 0.5 : table.Width * 0.5);
+                        cell.CellFormat.Paddings.Top = 5;
+                        cell.CellFormat.Paddings.Bottom = 5;
+                        cell.CellFormat.Paddings.Left = 5;
+                        cell.CellFormat.Paddings.Right = 5;
+                    }
+                }
+
+                IWParagraph para = table[0, 0].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Center;
+
+                IWTextRange textRange = para.AppendText(contract.company);
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.Bold = true;
+
+                //textRange = table[0, 0].AddParagraph().AppendText("");
+
+                String d1 = "NO: " + "07/2019" + "/" + "MTV " + contract.syntaxConpany + "NV - " + contract.syntaxTelco + " - " + contract.service;
+                para = table[0, 0].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Center;
+                textRange = para.AppendText(d1);
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.Bold = false;
+
+                para = table[0, 1].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Center;
+                textRange = para.AppendText("SOCIALIST REPUBLIC OF VIETNAM");
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.Bold = true;
+
+                para = table[0, 1].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Center;
+                textRange = para.AppendText("Freedom - Equality - Fraternity");
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.Bold = true;
+
+                textRange = table[0, 1].AddParagraph().AppendText("");
+
+                String d2 = "Hanoi, " + convertTime.ToString("dd-MMMM, yyyy");
+                para = table[0, 1].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Center;
+                textRange = para.AppendText(d2);
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.Bold = false;
+
+
+                // content
+                //Appends paragraph.
+                IWParagraph paragraph = section.HeadersFooters.Header.AddParagraph();
+                paragraph = section.AddParagraph();
+                paragraph = section.AddParagraph();
+                paragraph = section.AddParagraph();
+                paragraph = section.AddParagraph();
+
+                paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Center;
+                textRange = paragraph.AppendText("PAYMENT REQUEST") as WTextRange;
+                textRange.CharacterFormat.FontSize = 15;
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.Bold = true;
+
+                paragraph = section.AddParagraph();
+
+                paragraph = section.AddParagraph();
+                paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Center;
+                textRange = paragraph.AppendText("To " + contract.telco) as WTextRange;
+                textRange.CharacterFormat.FontSize = 15;
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.Bold = true;
+
+                paragraph = section.AddParagraph();
+                paragraph = section.AddParagraph();
+
+                paragraph = section.AddParagraph();
+                paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+                textRange = paragraph.AppendText("            " + "According  to  the  contract   No ") as WTextRange;
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.Bold = false;
+
+                paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+                textRange = paragraph.AppendText(contract.contractCode) as WTextRange;
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.Bold = true;
+
+                textRange = paragraph.AppendText(" service provision contract and if there is content of contract") as WTextRange;
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.Bold = true;
+
+                textRange = paragraph.AppendText(" regarding to providing service on " + contract.syntaxTelco + " Mobile network between " + contract.syntaxTelco + " and ") as WTextRange;
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.Bold = false;
+
+                textRange = paragraph.AppendText(contract.company + ".") as WTextRange;
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.Bold = true;
+
+                paragraph = section.AddParagraph();
+
+                paragraph = section.AddParagraph();
+                paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+                textRange = paragraph.AppendText("            " + "According to COMMERCIAL INVOICE No: ") as WTextRange;
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.Bold = false;
+
+                String d3 = convertTime.ToString("ddMMyyyy") + "-" + contract.id + " " + contract.service;
+                paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+                textRange = paragraph.AppendText(d3) as WTextRange;
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.Bold = true;
+
+                paragraph = section.AddParagraph();
+
+                paragraph = section.AddParagraph();
+                paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+                textRange = paragraph.AppendText("            " + "According to Form of Yield Confirmation – Income of ") as WTextRange;
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.Bold = false;
+
+                paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+                textRange = paragraph.AppendText(contract.service) as WTextRange;
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.Bold = true;
+
+                paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+                textRange = paragraph.AppendText(" Service between " + contract.telco + " and ") as WTextRange;
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.Bold = false;
+
+                paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+                textRange = paragraph.AppendText(contract.company) as WTextRange;
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.Bold = true;
+
+                paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+                textRange = paragraph.AppendText(" for month ") as WTextRange;
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.Bold = false;
+
+                paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+                textRange = paragraph.AppendText(convertTime.AddMonths(-1).ToString("MMMM yyyy") + ".") as WTextRange;
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.Bold = true;
+
+                paragraph = section.AddParagraph();
+
+                paragraph = section.AddParagraph();
+                paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+                textRange = paragraph.AppendText("            " + contract.syntaxTelco + " must make payment to " + contract.company + " for " + convertTime.AddMonths(-1).ToString("MMMM yyyy") + " : ") as WTextRange;
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.Bold = false;
+
+                paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+                textRange = paragraph.AppendText(contract.company) as WTextRange;
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.Bold = true;
+
+                paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+                textRange = paragraph.AppendText(" for ") as WTextRange;
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.Bold = false;
+
+                paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+                textRange = paragraph.AppendText(convertTime.ToString("MMMM yyyy") + " : ") as WTextRange;
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.Bold = true;
+
+                paragraph = section.AddParagraph();
+                paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+                textRange = paragraph.AppendText("            " + "$ " + int.Parse(contract.money).ToString("0,0", CultureInfo.InvariantCulture)) as WTextRange;
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.Bold = true;
+
+                paragraph = section.AddParagraph();
+                paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+                textRange = paragraph.AppendText("            " + "Total : $ " + int.Parse(contract.money).ToString("0,0", CultureInfo.InvariantCulture)) as WTextRange;
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.Bold = true;
+
+                //paragraph = section.AddParagraph();
+
+                paragraph = section.AddParagraph();
+                paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+                textRange = paragraph.AppendText("In words : " + ConvertAmount(double.Parse(contract.money)) + " dollars./.") as WTextRange;
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.Bold = true;
+
+
+                //paragraph = section.AddParagraph();
+
+                paragraph = section.AddParagraph();
+                paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+                textRange = paragraph.AppendText("            " + "Thus, you are requested to transfer the payment above and fax us the T/T remittance once available ") as WTextRange;
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.Bold = false;
+
+
+                //paragraph = section.AddParagraph();
+
+                paragraph = section.AddParagraph();
+                paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+                textRange = paragraph.AppendText("            " + "Payment method and currency : Telegraphic in USD") as WTextRange;
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.Bold = false;
+
+                paragraph = section.AddParagraph();
+
+                table = section.AddTable();
+
+                rowNum = 5; columnNum = 2;
+                table.ResetCells(rowNum, columnNum);
+                table.TableFormat.HorizontalAlignment = RowAlignment.Center;
+                float tableWidth = table.Width;
+                for (int i = 0; i < columnNum; i++)
+                {
+                    for (int j = 0; j < rowNum; j++)
+                    {
+                        WTableCell cell = table.Rows[j].Cells[i];
+
+                        cell.Width = (float)(i == 0 ? tableWidth * 0.3 : tableWidth * 0.7);
+
+                        cell.CellFormat.Paddings.Top = 5;
+                        cell.CellFormat.Paddings.Bottom = 5;
+                        cell.CellFormat.Paddings.Left = 5;
+                        cell.CellFormat.Paddings.Right = 5;
+                    }
+                }
+
+                para = table[0, 0].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+
+                textRange = para.AppendText("Beneficiary");
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.Bold = true;
+
+                para = table[1, 0].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+
+                textRange = para.AppendText("Address");
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.Bold = true;
+
+                para = table[3, 0].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+
+                textRange = para.AppendText("Account No.");
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.Bold = true;
+
+                para = table[2, 0].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+
+                textRange = para.AppendText("Bank");
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.Bold = true;
+
+                para = table[4, 0].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+
+                textRange = para.AppendText("Swift Code");
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.Bold = true;
+
+                /////--------------
+                para = table[0, 1].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+
+                textRange = para.AppendText(contract.beneficiary);
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.Bold = true;
+
+                para = table[1, 1].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+
+                textRange = para.AppendText(contract.address);
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.Bold = false;
+
+                para = table[3, 1].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+
+                textRange = para.AppendText(contract.account);
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.Bold = false;
+
+                para = table[2, 1].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+
+                textRange = para.AppendText(contract.bank);
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.Bold = false;
+
+                para = table[4, 1].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+
+                textRange = para.AppendText(contract.swiftCode);
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.Bold = false;
+
+                paragraph = section.AddParagraph();
+
+                paragraph = section.AddParagraph();
+                paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+                textRange = paragraph.AppendText("Best Regards, ") as WTextRange;
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.Bold = false;
+
+
+                table = section.AddTable();
+
+                rowNum = 1; columnNum = 2;
+                table.ResetCells(rowNum, columnNum);
+                table.TableFormat.HorizontalAlignment = RowAlignment.Center;
+                tableWidth = table.Width;
+                table.TableFormat.Borders.Color = Color.White;
+                for (int i = 0; i < columnNum; i++)
+                {
+                    for (int j = 0; j < rowNum; j++)
+                    {
+                        WTableCell cell = table.Rows[j].Cells[i];
+                        cell.Width = (float)(i == 0 ? tableWidth * 0.2 : tableWidth * 0.8);
+                        cell.CellFormat.Paddings.Top = 5;
+                        cell.CellFormat.Paddings.Bottom = 5;
+                        cell.CellFormat.Paddings.Left = 5;
+                        cell.CellFormat.Paddings.Right = 5;
+                        cell.CellFormat.Borders.BorderType = Syncfusion.DocIO.DLS.BorderStyle.Cleared;
+                    }
+                }
+
+                para = table[0, 1].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Center;
+
+                textRange = para.AppendText(contract.company);
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.Bold = true;
+
+                para = table[0, 1].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Center;
+                textRange = para.AppendText("Director");
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.Bold = true;
+
+                //Saves the Word document to  MemoryStream
+                MemoryStream stream = new MemoryStream();
+                document.Save(stream, FormatType.Docx);
+                stream.Position = 0;
+
+                bool exists = Directory.Exists("./Files/Payments/" + DateTime.Now.ToString("dd_MM_yyyy"));
+                if (!exists)
+                    Directory.CreateDirectory("./Files/Payments/" + DateTime.Now.ToString("dd_MM_yyyy"));
+                FileStream outputStream = new FileStream("./Files/Payments/" + DateTime.Now.ToString("dd_MM_yyyy") + "/" + contract.id + "_" + contract.syntaxTelco + "_payment_" + contract.syntaxConpany + ".docx", FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite);
+                document.Save(outputStream, FormatType.Docx);
+                document.Close();
+                outputStream.Flush();
+                outputStream.Dispose();
+                return true;
+            }
+            catch (Exception ex)
+            {
+                log.Error("Exp: " + ex);
+            }
+            return false;
+        }
+
+        public static bool PaymentDumpt(Contract contract)
+        {
+            try
+            {
+                string[] validformats = new[] { "dd/MM/yyyy", "dd-MMM-yyyy" };
+
+                DateTime convertTime = DateTime.ParseExact(contract.time, validformats,
+            CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal);
+
+                int coChu = 12;
+
+                // Creating a new document.
+                WordDocument document = new WordDocument();
+
+                // Setting document page margins.
+                MarginsF pagemargins = new MarginsF();
+                pagemargins.Bottom = 20;
+                pagemargins.Top = 20;
+                pagemargins.Left = 75;
+                pagemargins.Right = 75;
+                // Assigning document page margins to the current section.
+
+                IWSection section = document.AddSection();
+                section.PageSetup.Margins = pagemargins;
+                section.AddParagraph();
+                IWTable table = section.AddTable();
+
+                int rowNum = 1, columnNum = 2;
+                RowFormat format = new RowFormat();
+                table.ResetCells(rowNum, columnNum);
+                table.TableFormat.HorizontalAlignment = RowAlignment.Center;
+
+
+
+                for (int i = 0; i < columnNum; i++)
+                {
+                    for (int j = 0; j < rowNum; j++)
+                    {
+                        WTableCell cell = table.Rows[j].Cells[i];
+                        cell.Width = (float)(i == 0 ? table.Width * 0.5 : table.Width * 0.5);
+                        cell.CellFormat.Paddings.Top = 5;
+                        cell.CellFormat.Paddings.Bottom = 5;
+                        cell.CellFormat.Paddings.Left = 5;
+                        cell.CellFormat.Paddings.Right = 5;
+                    }
+                }
+
+                IWParagraph para = table[0, 0].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Center;
+
+                IWTextRange textRange = para.AppendText(contract.company);
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = coChu;
+                textRange.CharacterFormat.Bold = true;
+
+                //textRange = table[0, 0].AddParagraph().AppendText("");
+
+                String d1 = "NO: " + convertTime.ToString(contract.syntaxConpany == "GTS" ? "ddMM/yyyy" : "MM/yyyy") + "/" + contract.syntaxConpany + " - " + contract.syntaxTelco + " - " + contract.service;
+                para = table[0, 0].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Center;
+                textRange = para.AppendText(d1);
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = coChu;
+                textRange.CharacterFormat.Bold = false;
+
+                para = table[0, 1].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Center;
+                textRange = para.AppendText("SOCIALIST REPUBLIC OF VIETNAM");
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = coChu;
+                textRange.CharacterFormat.Bold = true;
+
+                para = table[0, 1].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Center;
+                textRange = para.AppendText("Freedom - Equality - Fraternity");
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = coChu;
+                textRange.CharacterFormat.Bold = true;
+
+                textRange = table[0, 1].AddParagraph().AppendText("");
+
+                String d2 = "Hanoi, " + convertTime.ToString("dd-MMMM, yyyy");
+                para = table[0, 1].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Center;
+                textRange = para.AppendText(d2);
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = coChu;
+                textRange.CharacterFormat.Bold = false;
+
+
+                // content
+                //Appends paragraph.
+                IWParagraph paragraph = section.HeadersFooters.Header.AddParagraph();
+                paragraph = section.AddParagraph();
+                paragraph = section.AddParagraph();
+                paragraph = section.AddParagraph();
+                paragraph = section.AddParagraph();
+
+                paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Center;
+                textRange = paragraph.AppendText("PAYMENT REQUEST") as WTextRange;
+                textRange.CharacterFormat.FontSize = 15;
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.Bold = true;
+                paragraph = section.AddParagraph();
+                paragraph = section.AddParagraph();
+
+                paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+                textRange = paragraph.AppendText("To: ") as WTextRange;
+                textRange.CharacterFormat.FontSize = coChu;
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.Bold = true;
+                paragraph = section.AddParagraph();
+
+                paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+                textRange = paragraph.AppendText(contract.telco) as WTextRange;
+                textRange.CharacterFormat.FontSize = coChu;
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.Bold = true;
+                paragraph = section.AddParagraph();
+
+                paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+                textRange = paragraph.AppendText("Taxtcode: 1150150") as WTextRange;
+                textRange.CharacterFormat.FontSize = coChu;
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.Bold = true;
+                paragraph = section.AddParagraph();
+
+                paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+                textRange = paragraph.AppendText("According  to  the  contract   " + contract.contractCode) as WTextRange;
+                textRange.CharacterFormat.FontSize = coChu;
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.Bold = false;
+
+                textRange = paragraph.AppendText(" service provision contract and content of contract") as WTextRange;
+                textRange.CharacterFormat.FontSize = coChu;
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.Bold = false;
+
+                textRange = paragraph.AppendText(" regarding to providing " + contract.service + " service on " + contract.syntaxTelco + " Mobile network between " + contract.syntaxTelco + " and " + contract.company + ".") as WTextRange;
+                textRange.CharacterFormat.FontSize = coChu;
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.Bold = false;
+
+                paragraph = section.AddParagraph();
+
+                paragraph = section.AddParagraph();
+                String d3 = convertTime.ToString(contract.syntaxConpany == "ITL" || contract.syntaxConpany == "INTERLAND" ? "yyyyMMdd" : "ddMMyyyy") + "-" + contract.id;
+                paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+                textRange = paragraph.AppendText("            " + "According to COMMERCIAL INVOICE No: " + d3) as WTextRange;
+                textRange.CharacterFormat.FontSize = coChu;
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.Bold = false;
+
+                paragraph = section.AddParagraph();
+
+                paragraph = section.AddParagraph();
+                paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+                textRange = paragraph.AppendText("            " + "According to Form of Yield Confirmation – Income of " + contract.service + " Service between " + contract.syntaxTelco + " and " + contract.company + " for month " + convertTime.AddMonths(-1).ToString("MMMM yyyy") + ".") as WTextRange;
+                textRange.CharacterFormat.FontSize = coChu;
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.Bold = false;
+
+
+                paragraph = section.AddParagraph();
+
+                paragraph = section.AddParagraph();
+                paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+                textRange = paragraph.AppendText("            " + contract.syntaxTelco + " must make payment to " + contract.company + " for " + convertTime.AddMonths(-1).ToString("MMMM yyyy") + " : ") as WTextRange;
+                textRange.CharacterFormat.FontSize = coChu;
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.Bold = false;
+
+                paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+                textRange = paragraph.AppendText("$ " + int.Parse(contract.money).ToString("0,0", CultureInfo.InvariantCulture)) as WTextRange;
+                textRange.CharacterFormat.FontSize = coChu;
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.Bold = true;
+
+                paragraph = section.AddParagraph();
+
+                paragraph = section.AddParagraph();
+                paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+                textRange = paragraph.AppendText("            " + "Total : $ " + int.Parse(contract.money).ToString("0,0", CultureInfo.InvariantCulture)) as WTextRange;
+                textRange.CharacterFormat.FontSize = coChu;
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.Bold = true;
+
+                paragraph = section.AddParagraph();
+
+                paragraph = section.AddParagraph();
+                paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+                textRange = paragraph.AppendText("In words : ") as WTextRange;
+                textRange.CharacterFormat.FontSize = coChu;
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.Bold = false;
+
+                paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+                if (contract.contractCode == "VIETTECH")
+                {
+                    textRange = paragraph.AppendText(ConvertAmount(double.Parse(contract.money)) + " United States Dollars.") as WTextRange;
+
+                }
+                else if (contract.contractCode == "ITL" || contract.contractCode == "INTERLAND")
+                {
+                    textRange = paragraph.AppendText(ConvertAmount(double.Parse(contract.money)) + " USD.") as WTextRange;
+                }
+                else
+                {
+                    textRange = paragraph.AppendText(ConvertAmount(double.Parse(contract.money)) + " dollars./.") as WTextRange;
+                }
+                textRange.CharacterFormat.FontSize = coChu;
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.Bold = true;
+                textRange.CharacterFormat.Italic = true;
+                paragraph = section.AddParagraph();
+
+                paragraph = section.AddParagraph();
+                paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+                textRange = paragraph.AppendText("            " + "Thus, you are requested to transfer the payment above and fax us the T/T remittance once available ") as WTextRange;
+                textRange.CharacterFormat.FontSize = coChu;
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.Bold = false;
+
+
+                paragraph = section.AddParagraph();
+
+                paragraph = section.AddParagraph();
+                paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+                textRange = paragraph.AppendText("            " + "Payment method and currency : Telegraphic in USD") as WTextRange;
+                textRange.CharacterFormat.FontSize = coChu;
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.Bold = false;
+
+                paragraph = section.AddParagraph();
+
+                table = section.AddTable();
+
+                rowNum = 5; columnNum = 2;
+                table.ResetCells(rowNum, columnNum);
+                table.TableFormat.HorizontalAlignment = RowAlignment.Center;
+                float tableWidth = table.Width;
+                for (int i = 0; i < columnNum; i++)
+                {
+                    for (int j = 0; j < rowNum; j++)
+                    {
+                        WTableCell cell = table.Rows[j].Cells[i];
+
+                        cell.Width = (float)(i == 0 ? tableWidth * 0.3 : tableWidth * 0.7);
+
+                        cell.CellFormat.Paddings.Top = 5;
+                        cell.CellFormat.Paddings.Bottom = 5;
+                        cell.CellFormat.Paddings.Left = 5;
+                        cell.CellFormat.Paddings.Right = 5;
+                    }
+                }
+
+                para = table[0, 0].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+
+                textRange = para.AppendText(contract.syntaxConpany == "GTS" ? "Name of Beneficiary" : "Beneficiary");
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = coChu;
+                textRange.CharacterFormat.Bold = contract.syntaxConpany == "GTS" ? false : true;
+
+                para = table[1, 0].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+
+                textRange = para.AppendText("Address");
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = coChu;
+                textRange.CharacterFormat.Bold = contract.syntaxConpany == "GTS" ? false : true;
+
+                para = table[2, 0].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+
+                textRange = para.AppendText(contract.syntaxConpany == "GTS" ? "Bank account:" : "Account No.");
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = coChu;
+                textRange.CharacterFormat.Bold = contract.syntaxConpany == "GTS" ? false : true;
+
+                para = table[3, 0].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+
+                textRange = para.AppendText(contract.syntaxConpany == "GTS" ? "Bank Name" : "Bank");
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = coChu;
+                textRange.CharacterFormat.Bold = contract.syntaxConpany == "GTS" ? false : true;
+
+                para = table[4, 0].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+
+                textRange = para.AppendText("Swift Code:");
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.Bold = contract.syntaxConpany == "GTS" ? false : true;
+
+                /////--------------
+                para = table[0, 1].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+
+                textRange = para.AppendText(contract.beneficiary);
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = coChu;
+                textRange.CharacterFormat.Bold = contract.syntaxConpany == "GTS" ? false : true;
+
+                para = table[1, 1].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+
+                textRange = para.AppendText(contract.address);
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = coChu;
+                textRange.CharacterFormat.Bold = false;
+
+                para = table[2, 1].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+
+                textRange = para.AppendText(contract.account);
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = coChu;
+                textRange.CharacterFormat.Bold = false;
+
+                para = table[3, 1].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+
+                textRange = para.AppendText(contract.bank);
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = coChu;
+                textRange.CharacterFormat.Bold = false;
+
+                para = table[4, 1].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+
+                textRange = para.AppendText(contract.swiftCode);
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = coChu;
+                textRange.CharacterFormat.Bold = false;
+
+                paragraph = section.AddParagraph();
+
+                paragraph = section.AddParagraph();
+                paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+                textRange = paragraph.AppendText("Best Regards, ") as WTextRange;
+                textRange.CharacterFormat.FontSize = coChu;
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.Bold = false;
+
+
+                table = section.AddTable();
+
+                rowNum = 1; columnNum = 2;
+                table.ResetCells(rowNum, columnNum);
+                table.TableFormat.HorizontalAlignment = RowAlignment.Center;
+                tableWidth = table.Width;
+                table.TableFormat.Borders.Color = Color.White;
+                for (int i = 0; i < columnNum; i++)
+                {
+                    for (int j = 0; j < rowNum; j++)
+                    {
+                        WTableCell cell = table.Rows[j].Cells[i];
+                        cell.Width = (float)(i == 0 ? tableWidth * 0.2 : tableWidth * 0.8);
+                        cell.CellFormat.Paddings.Top = 5;
+                        cell.CellFormat.Paddings.Bottom = 5;
+                        cell.CellFormat.Paddings.Left = 5;
+                        cell.CellFormat.Paddings.Right = 5;
+                        cell.CellFormat.Borders.BorderType = Syncfusion.DocIO.DLS.BorderStyle.Cleared;
+                    }
+                }
+
+                para = table[0, 1].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Center;
+
+                textRange = para.AppendText(contract.company);
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = coChu;
+                textRange.CharacterFormat.Bold = true;
+
+                para = table[0, 1].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Center;
+                textRange = para.AppendText("Director");
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = coChu;
+                textRange.CharacterFormat.Bold = true;
+
+                //Saves the Word document to  MemoryStream
+                MemoryStream stream = new MemoryStream();
+                document.Save(stream, FormatType.Docx);
+                stream.Position = 0;
+
+                bool exists = Directory.Exists("./Files/Payments/" + DateTime.Now.ToString("dd_MM_yyyy"));
+                if (!exists)
+                    Directory.CreateDirectory("./Files/Payments/" + DateTime.Now.ToString("dd_MM_yyyy"));
+                FileStream outputStream = new FileStream("./Files/Payments/" + DateTime.Now.ToString("dd_MM_yyyy") + "/" + contract.id + "_" + contract.syntaxTelco + "_payment_" + contract.syntaxConpany + ".docx", FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite);
+                document.Save(outputStream, FormatType.Docx);
+                document.Close();
+                outputStream.Flush();
+                outputStream.Dispose();
+                return true;
+            }
+            catch (Exception ex)
+            {
+                log.Error("Exp: " + ex);
+            }
+            return false;
+        }
+
+        public static bool InvoiceGTSDumpt(Contract contract)
+        {
+            try
+            {
+                string[] validformats = new[] { "MM/dd/yyyy", "yyyy/MM/dd", "MM/dd/yyyy HH:mm:ss", "dd-MMM-yyyy",
+                                        "MM/dd/yyyy hh:mm tt", "yyyy-MM-dd HH:mm:ss, fff", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mm", "yyyy-MM-ddTHH:mm:ss.fff", "yyyy-MM-dd"};
+
+                DateTime convertTime = DateTime.ParseExact(contract.time, validformats,
+            CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal);
+
+                // Creating a new document.
+                WordDocument document = new WordDocument();
+
+                // Setting document page margins.
+                MarginsF pagemargins = new MarginsF();
+                pagemargins.Bottom = 20;
+                pagemargins.Top = 20;
+                pagemargins.Left = 75;
+                pagemargins.Right = 75;
+                // Assigning document page margins to the current section.
+
+                IWSection section = document.AddSection();
+                section.PageSetup.Margins = pagemargins;
+                section.AddParagraph();
+                IWTable table = section.AddTable();
+
+                int rowNum = 1, columnNum = 2;
+                RowFormat format = new RowFormat();
+                table.ResetCells(rowNum, columnNum);
+                table.TableFormat.HorizontalAlignment = RowAlignment.Center;
+
+                for (int i = 0; i < columnNum; i++)
+                {
+                    for (int j = 0; j < rowNum; j++)
+                    {
+                        WTableCell cell = table.Rows[j].Cells[i];
+                        cell.Width = (float)(i == 0 ? table.Width * 0.65 : table.Width * 0.35);
+                        cell.CellFormat.Paddings.Top = 5;
+                        cell.CellFormat.Paddings.Bottom = 5;
+                        cell.CellFormat.Paddings.Left = 5;
+                        cell.CellFormat.Paddings.Right = 5;
+                        cell.CellFormat.Borders.BorderType = Syncfusion.DocIO.DLS.BorderStyle.Cleared;
+
+                    }
+                }
+
+                IWParagraph para = table[0, 0].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+
+                IWTextRange textRange = para.AppendText(contract.company);
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 12;
+                textRange.CharacterFormat.Bold = true;
+
+                para = table[0, 0].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+                textRange = para.AppendText("Add: " + contract.address);
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 12;
+                textRange.CharacterFormat.Bold = false;
+
+                para = table[0, 0].AddParagraph();
+                para = table[0, 0].AddParagraph();
+
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+                textRange = para.AppendText("Registration Number: ");
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 12;
+                textRange.CharacterFormat.Bold = true;
+
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+                textRange = para.AppendText("0108079693");
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 12;
+                textRange.CharacterFormat.Bold = false;
+
+                // Gets the image stream.
+                para = table[0, 1].AddParagraph();
+                FileStream imageStream = new FileStream("./resources/gts.jpg", FileMode.Open, FileAccess.Read);
+                IWPicture picture = para.AppendPicture(imageStream);
+                picture.TextWrappingStyle = TextWrappingStyle.InFrontOfText;
+                picture.VerticalOrigin = VerticalOrigin.Margin;
+                //picture.VerticalPosition = -45;
+                //picture.HorizontalOrigin = HorizontalOrigin.Column;
+                //picture.HorizontalPosition = 263.5f;
+                //picture.WidthScale = 20;
+                //picture.HeightScale = 15;
+
+
+                // content
+                //Appends paragraph.
+                IWParagraph paragraph = section.HeadersFooters.Header.AddParagraph();
+                paragraph = section.AddParagraph();
+                paragraph = section.AddParagraph();
+
+                paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Center;
+                textRange = paragraph.AppendText("INVOICE") as WTextRange;
+                textRange.CharacterFormat.FontSize = 25;
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.Bold = true;
+                textRange.CharacterFormat.TextColor = Color.Orange;
+
+
+                paragraph = section.AddParagraph();
+
+                table = section.AddTable();
+                rowNum = 1; columnNum = 2;
+                table.ResetCells(rowNum, columnNum);
+                table.TableFormat.HorizontalAlignment = RowAlignment.Center;
+                float tableWidth = table.Width;
+                for (int i = 0; i < columnNum; i++)
+                {
+                    for (int j = 0; j < rowNum; j++)
+                    {
+                        WTableCell cell = table.Rows[j].Cells[i];
+
+                        cell.Width = (float)(i == 0 ? tableWidth * 0.5 : tableWidth * 0.5);
+                        cell.CellFormat.Paddings.Top = 5;
+                        cell.CellFormat.Paddings.Bottom = 5;
+                        cell.CellFormat.Paddings.Left = 5;
+                        cell.CellFormat.Paddings.Right = 5;
+                        cell.CellFormat.Borders.BorderType = Syncfusion.DocIO.DLS.BorderStyle.Dot;
+
+                    }
+                }
+
+                para = table[0, 0].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+
+                textRange = para.AppendText("No: ");
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 15;
+                textRange.CharacterFormat.Bold = true;
+
+                textRange = para.AppendText(convertTime.ToString("ddMMyyyy") + "-" + contract.id);
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 13;
+                textRange.CharacterFormat.Bold = false;
+
+                para = table[0, 1].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+
+                textRange = para.AppendText("Date: ");
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 15;
+                textRange.CharacterFormat.Bold = true;
+
+                textRange = para.AppendText(convertTime.ToString("dd/MM/yyyy"));
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 13;
+                textRange.CharacterFormat.Bold = false;
+
+
+                paragraph = section.AddParagraph();
+
+                paragraph = section.AddParagraph();
+                paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+                textRange = paragraph.AppendText(contract.telco) as WTextRange;
+                textRange.CharacterFormat.FontSize = 12;
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.Bold = true;
+
+                paragraph = section.AddParagraph();
+
+                paragraph = section.AddParagraph();
+                paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+                textRange = paragraph.AppendText("Address: ") as WTextRange;
+                textRange.CharacterFormat.FontSize = 12;
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.Bold = true;
+
+                textRange = paragraph.AppendText("CBD 4 Timor Plaza, Comoro, Dili, Timor Leste") as WTextRange;
+                textRange.CharacterFormat.FontSize = 12;
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.Bold = false;
+
+                paragraph = section.AddParagraph();
+
+                paragraph = section.AddParagraph();
+                paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+                textRange = paragraph.AppendText("Tax Registration No : ") as WTextRange;
+                textRange.CharacterFormat.FontSize = 12;
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.Bold = true;
+
+                textRange = paragraph.AppendText("1150150") as WTextRange;
+                textRange.CharacterFormat.FontSize = 12;
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.Bold = false;
+
+                paragraph = section.AddParagraph();
+
+                paragraph = section.AddParagraph();
+                paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+                textRange = paragraph.AppendText("Attention: ") as WTextRange;
+                textRange.CharacterFormat.FontSize = 12;
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.Bold = true;
+
+                textRange = paragraph.AppendText("Mr. Tran Van Bang") as WTextRange;
+                textRange.CharacterFormat.FontSize = 12;
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.Bold = false;
+
+                paragraph = section.AddParagraph();
+
+                paragraph = section.AddParagraph();
+                paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+                textRange = paragraph.AppendText("Contract: ") as WTextRange;
+                textRange.CharacterFormat.FontSize = 12;
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.Bold = true;
+
+                textRange = paragraph.AppendText(contract.contractCode) as WTextRange;
+                textRange.CharacterFormat.FontSize = 12;
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.Bold = false;
+
+                paragraph = section.AddParagraph();
+
+                table = section.AddTable();
+                rowNum = 2; columnNum = 3;
+                table.ResetCells(rowNum, columnNum);
+                table.TableFormat.HorizontalAlignment = RowAlignment.Center;
+                tableWidth = table.Width;
+                for (int i = 0; i < columnNum; i++)
+                {
+                    for (int j = 0; j < rowNum; j++)
+                    {
+                        WTableCell cell = table.Rows[j].Cells[i];
+                        cell.Width = (float)(i == 0 ? tableWidth * 0.1 : i == 1 ? tableWidth * 0.6 : tableWidth * 0.3);
+                        cell.CellFormat.Paddings.Top = 5;
+                        cell.CellFormat.Paddings.Bottom = 5;
+                        cell.CellFormat.Paddings.Left = 5;
+                        cell.CellFormat.Paddings.Right = 5;
+                        cell.CellFormat.Borders.BorderType = Syncfusion.DocIO.DLS.BorderStyle.Dot;
+                    }
+                }
+
+                para = table[0, 0].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Center;
+                textRange = para.AppendText("No");
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 14;
+                textRange.CharacterFormat.Bold = true;
+
+                para = table[0, 1].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Center;
+                textRange = para.AppendText("Description");
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 14;
+                textRange.CharacterFormat.Bold = true;
+
+                para = table[0, 2].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Center;
+                textRange = para.AppendText("Amount");
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 14;
+                textRange.CharacterFormat.Bold = true;
+
+                para = table[1, 0].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Center;
+                textRange = para.AppendText("1");
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 12;
+                textRange.CharacterFormat.Bold = false;
+
+                para = table[1, 1].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+                textRange = para.AppendText(contract.service + " service sharing revenue of " + convertTime.AddMonths(-1).ToString("MMMM yyyy"));
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 14;
+                textRange.CharacterFormat.Bold = false;
+
+                para = table[1, 2].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Center;
+                textRange = para.AppendText("USD " + int.Parse(contract.money).ToString("0,0", CultureInfo.InvariantCulture));
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 14;
+                textRange.CharacterFormat.Bold = false;
+
+
+                paragraph = section.AddParagraph();
+
+                paragraph = section.AddParagraph();
+                paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+                textRange = paragraph.AppendText("In writing: " + ConvertAmount(double.Parse(contract.money)) + " dollars./.") as WTextRange;
+                textRange.CharacterFormat.FontSize = 12;
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.Bold = true;
+
+                paragraph = section.AddParagraph();
+
+
+                paragraph = section.AddParagraph();
+                paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+                textRange = paragraph.AppendText("Following is the Payment reference:") as WTextRange;
+                textRange.CharacterFormat.FontSize = 12;
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.Bold = true;
+
+                paragraph = section.AddParagraph();
+
+                paragraph = section.AddParagraph();
+                paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+                textRange = paragraph.AppendText("-   Name of Bank: ") as WTextRange;
+                textRange.CharacterFormat.FontSize = 12;
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.Bold = false;
+                textRange = paragraph.AppendText(contract.bank) as WTextRange;
+                textRange.CharacterFormat.FontSize = 12;
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.Bold = false;
+
+                paragraph = section.AddParagraph();
+                paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+                textRange = paragraph.AppendText("-   Address: ") as WTextRange;
+                textRange.CharacterFormat.FontSize = 12;
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.Bold = false;
+                textRange = paragraph.AppendText(contract.address) as WTextRange;
+                textRange.CharacterFormat.FontSize = 12;
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.Bold = false;
+
+                paragraph = section.AddParagraph();
+                paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+                textRange = paragraph.AppendText("-   Swift Code: ") as WTextRange;
+                textRange.CharacterFormat.FontSize = 12;
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.Bold = false;
+                textRange = paragraph.AppendText(contract.swiftCode) as WTextRange;
+                textRange.CharacterFormat.FontSize = 12;
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.Bold = false;
+
+                paragraph = section.AddParagraph();
+                paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+                textRange = paragraph.AppendText("-   Account No: ") as WTextRange;
+                textRange.CharacterFormat.FontSize = 12;
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.Bold = false;
+                textRange = paragraph.AppendText(contract.account) as WTextRange;
+                textRange.CharacterFormat.FontSize = 12;
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.Bold = false;
+
+                paragraph = section.AddParagraph();
+                paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+                textRange = paragraph.AppendText("-   Account holdere: ") as WTextRange;
+                textRange.CharacterFormat.FontSize = 12;
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.Bold = false;
+                textRange = paragraph.AppendText(contract.beneficiary) as WTextRange;
+                textRange.CharacterFormat.FontSize = 12;
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.Bold = false;
+
+                table = section.AddTable();
+
+                rowNum = 1; columnNum = 2;
+                table.ResetCells(rowNum, columnNum);
+                table.TableFormat.HorizontalAlignment = RowAlignment.Center;
+                tableWidth = table.Width;
+                table.TableFormat.Borders.Color = Color.White;
+                for (int i = 0; i < columnNum; i++)
+                {
+                    for (int j = 0; j < rowNum; j++)
+                    {
+                        WTableCell cell = table.Rows[j].Cells[i];
+                        cell.Width = (float)(i == 0 ? tableWidth * 0.3 : tableWidth * 0.7);
+                        cell.CellFormat.Paddings.Top = 5;
+                        cell.CellFormat.Paddings.Bottom = 5;
+                        cell.CellFormat.Paddings.Left = 5;
+                        cell.CellFormat.Paddings.Right = 5;
+                        cell.CellFormat.Borders.BorderType = Syncfusion.DocIO.DLS.BorderStyle.Cleared;
+                    }
+                }
+
+                para = table[0, 1].AddParagraph();
+                para = table[0, 1].AddParagraph();
+                para = table[0, 1].AddParagraph();
+
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Center;
+                textRange = para.AppendText("DIRECTOR");
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 17;
+                textRange.CharacterFormat.Bold = true;
+
+                //Saves the Word document to  MemoryStream
+                MemoryStream stream = new MemoryStream();
+                document.Save(stream, FormatType.Docx);
+                stream.Position = 0;
+
+                bool exists = System.IO.Directory.Exists("./Files/Invoices/" + DateTime.Now.ToString("dd_MM_yyyy"));
+                if (!exists)
+                    System.IO.Directory.CreateDirectory("./Files/Invoices/" + DateTime.Now.ToString("dd_MM_yyyy"));
+                FileStream outputStream = new FileStream("./Files/Invoices/" + DateTime.Now.ToString("dd_MM_yyyy") + "/" + contract.id + "_" + contract.syntaxTelco + "_invoice_" + contract.syntaxConpany + ".docx", FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite);
+                document.Save(outputStream, FormatType.Docx);
+                document.Close();
+                outputStream.Flush();
+                outputStream.Dispose();
+                return true;
+            }
+            catch (Exception ex)
+            {
+                log.Error("Exp: " + ex);
+                return false;
+            }
+        }
+
+        public static bool InvoiceVTECHDumpt(Contract contract)
+        {
+            try
+            {
+                string[] validformats = new[] { "MM/dd/yyyy", "yyyy/MM/dd", "MM/dd/yyyy HH:mm:ss", "dd-MMM-yyyy",
+                                        "MM/dd/yyyy hh:mm tt", "yyyy-MM-dd HH:mm:ss, fff", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mm", "yyyy-MM-ddTHH:mm:ss.fff", "yyyy-MM-dd"};
+
+                DateTime convertTime = DateTime.ParseExact(contract.time, validformats,
+            CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal);
+
+                // Creating a new document.
+                WordDocument document = new WordDocument();
+
+                // Setting document page margins.
+                MarginsF pagemargins = new MarginsF();
+                pagemargins.Bottom = 20;
+                pagemargins.Top = 20;
+                pagemargins.Left = 75;
+                pagemargins.Right = 75;
+                // Assigning document page margins to the current section.
+
+                IWSection section = document.AddSection();
+                section.PageSetup.Margins = pagemargins;
+                section.AddParagraph();
+                IWTable table = section.AddTable();
+
+                int rowNum = 7, columnNum = 2;
+                RowFormat format = new RowFormat();
+                table.ResetCells(rowNum, columnNum);
+                table.TableFormat.HorizontalAlignment = RowAlignment.Center;
+                float tableWidth = table.Width;
+
+                //table.TableFormat.BackColor = Color.FromArgb(192, 192, 192);
+                table.Rows[0].Cells[0].CellFormat.BackColor = Color.FromArgb(156, 194, 229);
+                table.Rows[0].Cells[1].CellFormat.BackColor = Color.FromArgb(156, 194, 229);
+                table.Rows[2].Cells[0].CellFormat.BackColor = Color.FromArgb(156, 194, 229);
+                table.Rows[2].Cells[1].CellFormat.BackColor = Color.FromArgb(156, 194, 229);
+                table.Rows[4].Cells[0].CellFormat.BackColor = Color.FromArgb(156, 194, 229);
+                table.Rows[4].Cells[1].CellFormat.BackColor = Color.FromArgb(156, 194, 229);
+
+                for (int i = 0; i < columnNum; i++)
+                {
+                    for (int j = 0; j < rowNum; j++)
+                    {
+                        WTableCell cell = table.Rows[j].Cells[i];
+                        cell.Width = (float)(i == 0 ? tableWidth * 0.5 : tableWidth * 0.5);
+                        cell.CellFormat.Paddings.Top = 5;
+                        cell.CellFormat.Paddings.Bottom = 5;
+                        cell.CellFormat.Paddings.Left = 5;
+                        cell.CellFormat.Paddings.Right = 5;
+                        if (i == 0)
+                        {
+                            if (j == 6)
+                            {
+                                cell.CellFormat.Borders.BorderType = BorderStyle.Cleared;
+                                cell.CellFormat.Borders.Top.BorderType = BorderStyle.Single;
+                                cell.CellFormat.Borders.Right.BorderType = BorderStyle.Single;
+                                cell.CellFormat.Borders.Bottom.BorderType = BorderStyle.Single;
+                            }
+                            else if (j == 1 || j == 2 || j == 5 || j == 4)
+                            {
+                                cell.CellFormat.Borders.BorderType = BorderStyle.Cleared;
+                                cell.CellFormat.Borders.Top.BorderType = BorderStyle.Single;
+                                cell.CellFormat.Borders.Right.BorderType = BorderStyle.Single;
+                            }
+                            else
+                            {
+                                cell.CellFormat.Borders.BorderType = BorderStyle.Cleared;
+                                cell.CellFormat.Borders.Right.BorderType = BorderStyle.Single;
+                            }
+                        }
+                        else if (i == 1)
+                        {
+                            if (j == 6)
+                            {
+                                cell.CellFormat.Borders.BorderType = BorderStyle.Cleared;
+                                cell.CellFormat.Borders.Top.BorderType = BorderStyle.Single;
+                                cell.CellFormat.Borders.Bottom.BorderType = BorderStyle.Single;
+                            }
+                            else if (j == 1 || j == 2 || j == 5 || j == 4)
+                            {
+                                cell.CellFormat.Borders.BorderType = BorderStyle.Cleared;
+                                cell.CellFormat.Borders.Top.BorderType = BorderStyle.Single;
+                                cell.CellFormat.Borders.Left.BorderType = BorderStyle.Single;
+                            }
+                            else
+                            {
+                                cell.CellFormat.Borders.BorderType = BorderStyle.Cleared;
+                            }
+                        }
+                    }
+                }
+                table.ApplyHorizontalMerge(0, 0, 1);
+                IWParagraph para = table[0, 0].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Center;
+
+                IWTextRange textRange = para.AppendText("COMMERCIAL INVOICE");
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 16;
+                textRange.CharacterFormat.Bold = true;
+
+
+                para = table[0, 0].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Center;
+                textRange = para.AppendText("No: " + convertTime.ToString("ddMMyyyy") + "-" + contract.id);
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 13;
+                textRange.CharacterFormat.Bold = true;
+
+                para = table[0, 0].AddParagraph();
+
+                para = table[1, 0].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+                textRange = para.AppendText("DATE OF EXPORT");
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.Bold = true;
+
+                para = table[1, 0].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+                textRange = para.AppendText(convertTime.ToString("dd/MM/yyyy"));
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.Bold = false;
+
+                para = table[1, 0].AddParagraph();
+
+                para = table[1, 1].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+                textRange = para.AppendText("CONTRACT");
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.Bold = true;
+
+                para = table[1, 1].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+                //String d1 = (int.Parse(contract.id) < 10 ? "0" + contract.id : contract.id) + "/VTL-" + contract.syntaxConpany + "/VAS/" + convertTime.ToString("yyyy");
+                String d1 = contract.contractCode;
+                textRange = para.AppendText(d1);
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.Bold = false;
+
+                para = table[1, 1].AddParagraph();
+
+                para = table[2, 0].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+                textRange = para.AppendText("PROVIDER");
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.Bold = true;
+
+                para = table[2, 1].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+                textRange = para.AppendText("BUYER");
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.Bold = true;
+
+                para = table[3, 0].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+                textRange = para.AppendText("NAME: " + contract.company);
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.Bold = false;
+
+                para = table[3, 0].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+                textRange = para.AppendText("Address: " + contract.address);
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.Bold = false;
+
+                para = table[3, 0].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+                textRange = para.AppendText("Tax code: " + "0108453894");
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.Bold = false;
+
+                para = table[3, 0].AddParagraph();
+
+                para = table[3, 1].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+                textRange = para.AppendText("NAME: " + contract.telco);
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.Bold = false;
+
+                para = table[3, 1].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+                textRange = para.AppendText("Address: " + contract.addressTelco + ".");
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.Bold = false;
+
+                para = table[3, 1].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+                textRange = para.AppendText("Tax code: " + "1150150");
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.Bold = false;
+
+                para = table[3, 1].AddParagraph();
+
+
+                para = table[4, 0].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Center;
+                textRange = para.AppendText("DEFINITION OF PAYMENT");
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.Bold = true;
+
+                IWTable table2 = table[4, 1].AddTable();
+                rowNum = 1; columnNum = 3;
+                table2.ResetCells(rowNum, columnNum);
+                table2.TableFormat.HorizontalAlignment = RowAlignment.Center;
+                tableWidth = table2.Width;
+                for (int i = 0; i < columnNum; i++)
+                {
+                    for (int j = 0; j < rowNum; j++)
+                    {
+                        WTableCell cell = table2.Rows[j].Cells[i];
+                        if (i == 1)
+                        {
+                            cell.CellFormat.Borders.BorderType = BorderStyle.Cleared;
+                            cell.CellFormat.Borders.Left.BorderType = BorderStyle.Single;
+                            cell.CellFormat.Borders.Right.BorderType = BorderStyle.Single;
+                        }
+                        else
+                            cell.CellFormat.Borders.BorderType = BorderStyle.Cleared;
+                    }
+                }
+                IWParagraph para2 = table2[0, 0].AddParagraph();
+                para2.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+
+                textRange = para2.AppendText("QUANTITY");
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 10;
+                textRange.CharacterFormat.Bold = true;
+
+                para2 = table2[0, 1].AddParagraph();
+                para2.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+
+                textRange = para2.AppendText("UNIT PRICE (USD)");
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 10;
+                textRange.CharacterFormat.Bold = true;
+
+                para2 = table2[0, 2].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+
+                textRange = para2.AppendText("TOTAL (USD)");
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 10;
+                textRange.CharacterFormat.Bold = true;
+
+
+                //
+                para = table[5, 0].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+                textRange = para.AppendText(contract.service + " service sharing revenue of " + convertTime.AddMonths(-1).ToString("MMMM yyyy"));
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.Bold = false;
+                para = table[5, 0].AddParagraph();
+
+                table2 = table[5, 1].AddTable();
+                rowNum = 1; columnNum = 3;
+                table2.ResetCells(rowNum, columnNum);
+                table2.TableFormat.HorizontalAlignment = RowAlignment.Center;
+                tableWidth = table2.Width;
+                for (int i = 0; i < columnNum; i++)
+                {
+                    for (int j = 0; j < rowNum; j++)
+                    {
+                        WTableCell cell = table2.Rows[j].Cells[i];
+                        cell.CellFormat.Paddings.Top = 5;
+                        cell.CellFormat.Paddings.Bottom = 5;
+                        cell.CellFormat.Paddings.Left = 5;
+                        cell.CellFormat.Paddings.Right = 5;
+
+                        if (i == 1)
+                        {
+                            cell.CellFormat.Borders.BorderType = BorderStyle.Cleared;
+                            cell.CellFormat.Borders.Left.BorderType = BorderStyle.Single;
+                            cell.CellFormat.Borders.Right.BorderType = BorderStyle.Single;
+                        }
+                        else
+                            cell.CellFormat.Borders.BorderType = BorderStyle.Cleared;
+                    }
+                }
+                para2 = table2[0, 0].AddParagraph();
+                para2.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+
+                textRange = para2.AppendText("1");
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.Bold = false;
+                para2 = table2[0, 0].AddParagraph();
+                para2 = table2[0, 0].AddParagraph();
+
+
+                para2 = table2[0, 1].AddParagraph();
+                para2.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+
+                textRange = para2.AppendText(int.Parse(contract.money).ToString("0,0", CultureInfo.InvariantCulture));
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.Bold = false;
+                para2 = table2[0, 1].AddParagraph();
+                para2 = table2[0, 1].AddParagraph();
+
+
+                para2 = table2[0, 2].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+
+                textRange = para2.AppendText(int.Parse(contract.money).ToString("0,0", CultureInfo.InvariantCulture));
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.Bold = false;
+
+                para2 = table2[0, 2].AddParagraph();
+                para2 = table2[0, 2].AddParagraph();
+
+
+                para = table[6, 0].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+                textRange = para.AppendText("TOTAL");
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 12;
+                textRange.CharacterFormat.Bold = true;
+
+                para = table[6, 0].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+                textRange = para.AppendText("By word:");
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.Bold = true;
+
+                para = table[6, 1].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Right;
+                textRange = para.AppendText(int.Parse(contract.money).ToString("0,0", CultureInfo.InvariantCulture));
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.Bold = true;
+
+                para = table[6, 1].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+                textRange = para.AppendText(ConvertAmount(double.Parse(contract.money)) + " Dollars.");
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.Bold = true;
+
+                // content
+                //Appends paragraph.
+
+                IWParagraph paragraph = section.HeadersFooters.Header.AddParagraph();
+                paragraph = section.AddParagraph();
+                paragraph = section.AddParagraph();
+
+
+                paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+                textRange = paragraph.AppendText("Please remit payment to:") as WTextRange;
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.Bold = true;
+
+                paragraph = section.AddParagraph();
+
+
+                table = section.AddTable();
+                rowNum = 5; columnNum = 2;
+                table.ResetCells(rowNum, columnNum);
+                table.TableFormat.HorizontalAlignment = RowAlignment.Center;
+                tableWidth = table.Width;
+                for (int i = 0; i < columnNum; i++)
+                {
+                    for (int j = 0; j < rowNum; j++)
+                    {
+                        WTableCell cell = table.Rows[j].Cells[i];
+
+                        cell.Width = (float)(i == 0 ? tableWidth * 0.3 : tableWidth * 0.7);
+                        cell.CellFormat.Paddings.Top = 5;
+                        cell.CellFormat.Paddings.Bottom = 5;
+                        cell.CellFormat.Paddings.Left = 5;
+                        cell.CellFormat.Paddings.Right = 5;
+
+                        if (i == 0)
+                        {
+                            cell.CellFormat.Borders.BorderType = BorderStyle.Cleared;
+                            cell.CellFormat.Borders.Top.BorderType = BorderStyle.Single;
+                            cell.CellFormat.Borders.Right.BorderType = BorderStyle.Single;
+                            cell.CellFormat.Borders.Bottom.BorderType = BorderStyle.Single;
+                        }
+                        else if (i == 1)
+                        {
+                            cell.CellFormat.Borders.BorderType = BorderStyle.Cleared;
+                            cell.CellFormat.Borders.Top.BorderType = BorderStyle.Single;
+                            cell.CellFormat.Borders.Bottom.BorderType = BorderStyle.Single;
+                        }
+
+                    }
+                }
+
+                para = table[0, 0].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+
+                textRange = para.AppendText("Name of Beneficiary");
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.Bold = false;
+
+                para = table[0, 1].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+
+                textRange = para.AppendText(contract.beneficiary);
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.Bold = false;
+
+                para = table[1, 0].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+
+                textRange = para.AppendText("Address");
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.Bold = false;
+
+                para = table[1, 1].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+
+                textRange = para.AppendText(contract.address);
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.Bold = false;
+
+                para = table[2, 0].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+
+                textRange = para.AppendText("Name of Beneficiary’s bank");
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.Bold = false;
+
+                para = table[2, 1].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+
+                textRange = para.AppendText(contract.bank);
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.Bold = false;
+
+                para = table[3, 0].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+
+                textRange = para.AppendText("Account number");
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.Bold = false;
+
+                para = table[3, 1].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+
+                textRange = para.AppendText(contract.account);
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.Bold = false;
+
+                para = table[4, 0].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+
+                textRange = para.AppendText("SWIFT Code");
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.Bold = false;
+
+                para = table[4, 1].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Left;
+
+                textRange = para.AppendText(contract.swiftCode);
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.Bold = false;
+
+                paragraph = section.AddParagraph();
+
+
+                table = section.AddTable();
+                rowNum = 1; columnNum = 2;
+                table.ResetCells(rowNum, columnNum);
+                table.TableFormat.HorizontalAlignment = RowAlignment.Center;
+                tableWidth = table.Width;
+                table.TableFormat.Borders.Color = Color.White;
+                for (int i = 0; i < columnNum; i++)
+                {
+                    for (int j = 0; j < rowNum; j++)
+                    {
+                        WTableCell cell = table.Rows[j].Cells[i];
+                        cell.Width = (float)(i == 0 ? tableWidth * 0.6 : tableWidth * 0.4);
+                        cell.CellFormat.Paddings.Top = 5;
+                        cell.CellFormat.Paddings.Bottom = 5;
+                        cell.CellFormat.Paddings.Left = 5;
+                        cell.CellFormat.Paddings.Right = 5;
+                        cell.CellFormat.Borders.BorderType = Syncfusion.DocIO.DLS.BorderStyle.Cleared;
+                    }
+                }
+
+                para = table[0, 1].AddParagraph();
+                para.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Center;
+                textRange = para.AppendText("SIGNATURE");
+                textRange.CharacterFormat.FontName = "Times New Roman";
+                textRange.CharacterFormat.FontSize = 11;
+                textRange.CharacterFormat.Bold = true;
+
+                //Saves the Word document to  MemoryStream
+                MemoryStream stream = new MemoryStream();
+                document.Save(stream, FormatType.Docx);
+                stream.Position = 0;
+
+                bool exists = System.IO.Directory.Exists("./Files/Invoices/" + DateTime.Now.ToString("dd_MM_yyyy"));
+                if (!exists)
+                    System.IO.Directory.CreateDirectory("./Files/Invoices/" + DateTime.Now.ToString("dd_MM_yyyy"));
+                FileStream outputStream = new FileStream("./Files/Invoices/" + DateTime.Now.ToString("dd_MM_yyyy") + "/" + contract.id + "_" + contract.syntaxTelco + "_invoice_" + contract.syntaxConpany + ".docx", FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite);
+                document.Save(outputStream, FormatType.Docx);
+                document.Close();
+                outputStream.Flush();
+                outputStream.Dispose();
+                return true;
+            }
+            catch (Exception ex)
+            {
+                log.Error("Exp: " + ex);
+                return false;
+            }
+        }
+
+        public static bool InvoiceITLDumpt(Contract contract)
+        {
+            try
+            {
+                string[] validformats = new[] { "MM/dd/yyyy", "yyyy/MM/dd", "MM/dd/yyyy HH:mm:ss", "dd-MMM-yyyy",
+                                        "MM/dd/yyyy hh:mm tt", "yyyy-MM-dd HH:mm:ss, fff", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mm", "yyyy-MM-ddTHH:mm:ss.fff", "yyyy-MM-dd"};
+
+                DateTime convertTime = DateTime.ParseExact(contract.time, validformats,
+            CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal);
+
+                ExcelEngine excelEngine = new ExcelEngine();
+                int rowCount = 1;
+                IApplication application = excelEngine.Excel;
+
+
+                application.DefaultVersion = ExcelVersion.Excel2013;
+                IWorkbook workbook = application.Workbooks.Create(1);
+                IWorksheet worksheet = workbook.Worksheets[0];
+
+                List<RowAttributed> rowAttributedList = new List<RowAttributed>();
+
+                worksheet.Range["A1"].ColumnWidth = 3;
+                worksheet.Range["B1"].ColumnWidth = 50;
+                worksheet.Range["C1"].ColumnWidth = 8;
+                worksheet.Range["D1"].ColumnWidth = 14;
+                worksheet.Range["E1"].ColumnWidth = 18;
+                worksheet.Range["F1"].ColumnWidth = 30;
+
+                //Defining body style
+                Syncfusion.XlsIO.IStyle bodyStyle = workbook.Styles.Add("BodyStyle");
+                bodyStyle.BeginUpdate();
+                bodyStyle.Color = Color.FromArgb(255, 255, 255);
+                bodyStyle.Borders[ExcelBordersIndex.EdgeLeft].LineStyle = ExcelLineStyle.None;
+                bodyStyle.Borders[ExcelBordersIndex.EdgeRight].LineStyle = ExcelLineStyle.None;
+                bodyStyle.Borders[ExcelBordersIndex.EdgeBottom].LineStyle = ExcelLineStyle.None;
+                bodyStyle.Borders[ExcelBordersIndex.EdgeTop].LineStyle = ExcelLineStyle.None;
+                bodyStyle.EndUpdate();
+
+                worksheet.Range["A1:F39"].CellStyle = bodyStyle;
+
+                // style
+
+                Syncfusion.XlsIO.IStyle cellStyleTableCenterBold = workbook.Styles.Add("table-center-bold");
+                cellStyleTableCenterBold.Font.Size = 12;
+                cellStyleTableCenterBold.Font.Bold = true;
+                cellStyleTableCenterBold.Font.FontName = "Roboto";
+                cellStyleTableCenterBold.HorizontalAlignment = ExcelHAlign.HAlignCenter;
+                cellStyleTableCenterBold.VerticalAlignment = ExcelVAlign.VAlignCenter;
+                cellStyleTableCenterBold.Borders[ExcelBordersIndex.EdgeTop].LineStyle = ExcelLineStyle.Thin;
+                cellStyleTableCenterBold.Borders[ExcelBordersIndex.EdgeBottom].LineStyle = ExcelLineStyle.Thin;
+                cellStyleTableCenterBold.Borders[ExcelBordersIndex.EdgeLeft].LineStyle = ExcelLineStyle.Thin;
+                cellStyleTableCenterBold.Borders[ExcelBordersIndex.EdgeRight].LineStyle = ExcelLineStyle.Thin;
+
+                Syncfusion.XlsIO.IStyle cellStyleTableCenterNormal = workbook.Styles.Add("table-center-normal");
+                cellStyleTableCenterNormal.Font.Size = 12;
+                cellStyleTableCenterNormal.Font.Bold = false;
+                cellStyleTableCenterNormal.Font.FontName = "Roboto";
+                cellStyleTableCenterNormal.HorizontalAlignment = ExcelHAlign.HAlignCenter;
+                cellStyleTableCenterNormal.VerticalAlignment = ExcelVAlign.VAlignCenter;
+                cellStyleTableCenterNormal.Borders[ExcelBordersIndex.EdgeTop].LineStyle = ExcelLineStyle.Thin;
+                cellStyleTableCenterNormal.Borders[ExcelBordersIndex.EdgeBottom].LineStyle = ExcelLineStyle.Thin;
+                cellStyleTableCenterNormal.Borders[ExcelBordersIndex.EdgeLeft].LineStyle = ExcelLineStyle.Thin;
+                cellStyleTableCenterNormal.Borders[ExcelBordersIndex.EdgeRight].LineStyle = ExcelLineStyle.Thin;
+
+                Syncfusion.XlsIO.IStyle cellStyleTextBold = workbook.Styles.Add("text-bold");
+                cellStyleTextBold.Font.Size = 12;
+                cellStyleTextBold.Font.Bold = true;
+                cellStyleTextBold.Font.FontName = "Roboto";
+
+
+                Syncfusion.XlsIO.IStyle cellStyleTextBoldCenter = workbook.Styles.Add("text-bold-center");
+                cellStyleTextBoldCenter.Font.Size = 12;
+                cellStyleTextBoldCenter.Font.Bold = true;
+                cellStyleTextBoldCenter.HorizontalAlignment = ExcelHAlign.HAlignCenter;
+                cellStyleTextBoldCenter.Font.FontName = "Roboto";
+
+                Syncfusion.XlsIO.IStyle cellStyleTextNormal = workbook.Styles.Add("text-normal");
+                cellStyleTextNormal.Font.Size = 12;
+                cellStyleTextNormal.Font.Bold = false;
+                cellStyleTextNormal.Font.FontName = "Roboto";
+
+                Syncfusion.XlsIO.IStyle cellStyleTextNormalCenter = workbook.Styles.Add("text-normal-center");
+                cellStyleTextNormalCenter.Font.Size = 12;
+                cellStyleTextNormalCenter.Font.Bold = false;
+                cellStyleTextNormalCenter.HorizontalAlignment = ExcelHAlign.HAlignCenter;
+                cellStyleTextNormalCenter.Font.FontName = "Roboto";
+
+                worksheet.Range[GetExcelColumnName(1) + rowCount.ToString() + ":" + GetExcelColumnName(6) + rowCount.ToString()].Merge();
+
+                Syncfusion.XlsIO.IStyle rowStyle = workbook.Styles.Add("style1");
+                rowStyle.Borders[ExcelBordersIndex.EdgeLeft].LineStyle = ExcelLineStyle.None;
+                rowStyle.Color = Color.FromArgb(255, 174, 33);
+                worksheet.Range[GetExcelColumnName(1) + rowCount.ToString() + ":" + GetExcelColumnName(6) + rowCount.ToString()].CellStyle = rowStyle;
+                rowCount++;
+
+                worksheet.Range[GetExcelColumnName(1) + rowCount.ToString() + ":" + GetExcelColumnName(6) + rowCount.ToString()].Merge();
+                rowStyle = workbook.Styles.Add("style2");
+                rowStyle.Color = Color.FromArgb(255, 0, 0);
+                worksheet.Range[GetExcelColumnName(1) + rowCount.ToString() + ":" + GetExcelColumnName(6) + rowCount.ToString()].CellStyle = rowStyle;
+                worksheet.Range[GetExcelColumnName(1) + 39.ToString() + ":" + GetExcelColumnName(6) + 39.ToString()].CellStyle = rowStyle;
+                rowCount++;
+
+                rowCount++;
+                worksheet.Range[GetExcelColumnName(2) + rowCount.ToString()].Text = "INVOICE";
+                Syncfusion.XlsIO.IStyle cellStyle = workbook.Styles.Add("style3");
+                worksheet.Range[GetExcelColumnName(2) + rowCount.ToString()].RowHeight = 120;
+                cellStyle.Font.Size = 24;
+                cellStyle.Font.Bold = true;
+                cellStyle.VerticalAlignment = ExcelVAlign.VAlignCenter;
+                worksheet.Range[GetExcelColumnName(2) + rowCount.ToString()].CellStyle = cellStyle;
+
+                //Adding a picture
+                FileStream imageStream = new FileStream("./resources/ITL.jpg", FileMode.Open, FileAccess.Read);
+                IPictureShape shape = worksheet.Pictures.AddPicture(6, 3, imageStream);
+
+                //Positioning a Picture
+                shape.Top = 60;
+                shape.Left = 700;
+
+                //Re-sizing a Picture
+                shape.Height = 160;
+                shape.Width = 180;
+                rowCount++;
+
+                worksheet.Range[GetExcelColumnName(2) + rowCount.ToString() + ":" + GetExcelColumnName(5) + rowCount.ToString()].Merge();
+                worksheet.Range[GetExcelColumnName(2) + rowCount.ToString()].Text = contract.company;
+                worksheet.Range[GetExcelColumnName(2) + rowCount.ToString()].CellStyle = cellStyleTextBold;
+
+
+                worksheet.Range[GetExcelColumnName(6) + rowCount.ToString()].Text = convertTime.ToString("dd/MM/yyyy");
+                worksheet.Range[GetExcelColumnName(6) + rowCount.ToString()].CellStyle = cellStyleTextBoldCenter;
+                rowCount++;
+
+                worksheet.Range[GetExcelColumnName(2) + rowCount.ToString() + ":" + GetExcelColumnName(5) + rowCount.ToString()].Merge();
+                worksheet.Range[GetExcelColumnName(2) + rowCount.ToString()].Text = contract.address;
+                worksheet.Range[GetExcelColumnName(2) + rowCount.ToString()].CellStyle = cellStyleTextNormal;
+                worksheet.Range[GetExcelColumnName(2) + rowCount.ToString()].RowHeight = 40;
+                worksheet.Range[GetExcelColumnName(2) + rowCount.ToString()].WrapText = true;
+
+                worksheet.Range[GetExcelColumnName(6) + rowCount.ToString()].Text = "INVOICE No." + convertTime.ToString("yyyyMMdd") + "-" + contract.id;
+                worksheet.Range[GetExcelColumnName(6) + rowCount.ToString()].CellStyle = cellStyleTextBoldCenter;
+                worksheet.Range[GetExcelColumnName(6) + rowCount.ToString()].Borders[ExcelBordersIndex.EdgeTop].LineStyle = ExcelLineStyle.Thin;
+                worksheet.Range[GetExcelColumnName(6) + rowCount.ToString()].Borders[ExcelBordersIndex.EdgeBottom].LineStyle = ExcelLineStyle.Thin;
+
+                rowCount++;
+
+                worksheet.Range[GetExcelColumnName(2) + rowCount.ToString() + ":" + GetExcelColumnName(5) + rowCount.ToString()].Merge();
+                worksheet.Range[GetExcelColumnName(2) + rowCount.ToString()].Text = "Tax Code: 0107836502";
+                worksheet.Range[GetExcelColumnName(2) + rowCount.ToString()].CellStyle = cellStyleTextNormal;
+
+                rowCount++;
+
+                worksheet.Range[GetExcelColumnName(2) + rowCount.ToString()].Text = "Email: vninterland@gmail.com";
+                worksheet.Range[GetExcelColumnName(2) + rowCount.ToString()].CellStyle = cellStyleTextNormal;
+                rowCount += 3;
+
+                worksheet.Range[GetExcelColumnName(2) + rowCount.ToString()].Text = "BILL TO";
+                worksheet.Range[GetExcelColumnName(2) + rowCount.ToString()].CellStyle = cellStyleTextBold;
+                worksheet.Range[GetExcelColumnName(2) + rowCount.ToString()].Borders[ExcelBordersIndex.EdgeBottom].LineStyle = ExcelLineStyle.Thin;
+                worksheet.Range[GetExcelColumnName(2) + rowCount.ToString()].Borders[ExcelBordersIndex.EdgeBottom].ColorRGB = Color.FromArgb(215, 215, 215);
+
+                worksheet.Range[GetExcelColumnName(4) + rowCount.ToString() + ":" + GetExcelColumnName(6) + rowCount.ToString()].Borders[ExcelBordersIndex.EdgeBottom].LineStyle = ExcelLineStyle.Thin;
+
+                rowCount += 3;
+
+                worksheet.Range[GetExcelColumnName(2) + rowCount.ToString()].Text = contract.telco;
+                worksheet.Range[GetExcelColumnName(2) + rowCount.ToString()].CellStyle = cellStyleTextBold;
+
+                rowCount++;
+
+                worksheet.Range[GetExcelColumnName(2) + rowCount.ToString()].Text = contract.addressTelco;
+                worksheet.Range[GetExcelColumnName(2) + rowCount.ToString()].CellStyle = cellStyleTextNormal;
+                rowCount++;
+
+                worksheet.Range[GetExcelColumnName(2) + rowCount.ToString()].Text = "Tel: +670 76900005";
+                worksheet.Range[GetExcelColumnName(2) + rowCount.ToString()].CellStyle = cellStyleTextNormal;
+                rowCount++;
+
+                worksheet.Range[GetExcelColumnName(2) + rowCount.ToString()].Text = "Tax code: 1150150";
+                worksheet.Range[GetExcelColumnName(2) + rowCount.ToString()].CellStyle = cellStyleTextNormal;
+                rowCount ++;
+
+                worksheet.Range[GetExcelColumnName(2) + rowCount.ToString()].Text = contract.contractCode;
+                worksheet.Range[GetExcelColumnName(2) + rowCount.ToString()].CellStyle = cellStyleTextNormal;
+                rowCount += 2;
+
+                worksheet.Range[GetExcelColumnName(2) + rowCount.ToString() + ":" + GetExcelColumnName(3) + rowCount.ToString()].Merge();
+                worksheet.Range[GetExcelColumnName(2) + rowCount.ToString()].Text = "DESCRIPTION";
+                worksheet.Range[GetExcelColumnName(2) + rowCount.ToString() + ":" + GetExcelColumnName(3) + rowCount.ToString()].CellStyle = cellStyleTableCenterBold;
+                worksheet.Range[GetExcelColumnName(2) + rowCount.ToString()].CellStyle.Font.Size = 11;
+
+                worksheet.Range[GetExcelColumnName(4) + rowCount.ToString()].Text = "QTY";
+                worksheet.Range[GetExcelColumnName(4) + rowCount.ToString()].CellStyle = cellStyleTableCenterBold;
+                worksheet.Range[GetExcelColumnName(4) + rowCount.ToString()].CellStyle.Font.Size = 11;
+
+
+                worksheet.Range[GetExcelColumnName(5) + rowCount.ToString()].Text = "UNIT PRICE (USD)";
+                worksheet.Range[GetExcelColumnName(5) + rowCount.ToString()].CellStyle = cellStyleTableCenterBold;
+                worksheet.Range[GetExcelColumnName(5) + rowCount.ToString()].CellStyle.Font.Size = 11;
+
+                worksheet.Range[GetExcelColumnName(6) + rowCount.ToString()].Text = "TOTAL (USD)";
+                worksheet.Range[GetExcelColumnName(6) + rowCount.ToString()].CellStyle = cellStyleTableCenterBold;
+                worksheet.Range[GetExcelColumnName(6) + rowCount.ToString()].CellStyle.Font.Size = 11;
+
+                rowCount++;
+
+                worksheet.Range[GetExcelColumnName(2) + rowCount.ToString() + ":" + GetExcelColumnName(3) + rowCount.ToString()].Merge();
+                worksheet.Range[GetExcelColumnName(2) + rowCount.ToString() + ":" + GetExcelColumnName(2) + (rowCount + 1).ToString()].Merge();
+                worksheet.Range[GetExcelColumnName(2) + rowCount.ToString()].Text = contract.service + " service sharing revenue of " + convertTime.AddMonths(-1).ToString("MMMM yyyy");
+                worksheet.Range[GetExcelColumnName(2) + rowCount.ToString() + ":" + GetExcelColumnName(3) + rowCount.ToString()].CellStyle = cellStyleTableCenterNormal;
+                worksheet.Range[GetExcelColumnName(2) + rowCount.ToString() + ":" + GetExcelColumnName(2) + (rowCount + 1).ToString()].CellStyle = cellStyleTableCenterNormal;
+                worksheet.Range[GetExcelColumnName(3) + rowCount.ToString() + ":" + GetExcelColumnName(3) + (rowCount + 1).ToString()].CellStyle = cellStyleTableCenterNormal;
+
+
+                worksheet.Range[GetExcelColumnName(4) + rowCount.ToString()].Text = "1";
+                worksheet.Range[GetExcelColumnName(4) + rowCount.ToString() + ":" + GetExcelColumnName(4) + (rowCount + 1).ToString()].Merge();
+                worksheet.Range[GetExcelColumnName(4) + rowCount.ToString()].CellStyle = cellStyleTableCenterNormal;
+
+
+                worksheet.Range[GetExcelColumnName(5) + rowCount.ToString() + ":" + GetExcelColumnName(5) + (rowCount + 1).ToString()].Merge();
+                worksheet.Range[GetExcelColumnName(5) + rowCount.ToString()].Text = int.Parse(contract.money).ToString("0,0", CultureInfo.InvariantCulture);
+                worksheet.Range[GetExcelColumnName(5) + rowCount.ToString() + ":" + GetExcelColumnName(5) + (rowCount + 1).ToString()].CellStyle = cellStyleTableCenterNormal;
+
+
+                worksheet.Range[GetExcelColumnName(6) + rowCount.ToString() + ":" + GetExcelColumnName(6) + (rowCount + 1).ToString()].Merge();
+                worksheet.Range[GetExcelColumnName(6) + rowCount.ToString()].Text = int.Parse(contract.money).ToString("0,0", CultureInfo.InvariantCulture);
+                worksheet.Range[GetExcelColumnName(6) + rowCount.ToString() + ":" + GetExcelColumnName(6) + (rowCount + 1).ToString()].CellStyle = cellStyleTableCenterBold;
+
+                rowCount += 2;
+
+                worksheet.Range[GetExcelColumnName(2) + rowCount.ToString() + ":" + GetExcelColumnName(6) + rowCount.ToString()].Merge();
+                worksheet.Range[GetExcelColumnName(2) + rowCount.ToString()].Text = "By word: " + ConvertAmount(double.Parse(contract.money)) + " USD.";
+                worksheet.Range[GetExcelColumnName(2) + rowCount.ToString() + ":" + GetExcelColumnName(6) + rowCount.ToString()].CellStyle = cellStyleTableCenterNormal;
+
+                rowCount += 2;
+
+                worksheet.Range[GetExcelColumnName(4) + rowCount.ToString() + ":" + GetExcelColumnName(6) + rowCount.ToString()].Merge();
+                worksheet.Range[GetExcelColumnName(4) + rowCount.ToString()].Text = contract.company;
+                worksheet.Range[GetExcelColumnName(4) + rowCount.ToString() + ":" + GetExcelColumnName(6) + rowCount.ToString()].CellStyle = cellStyleTextBoldCenter;
+                worksheet.Range[GetExcelColumnName(4) + rowCount.ToString()].CellStyle.Font.Size = 11;
+
+                rowCount++;
+
+                worksheet.Range[GetExcelColumnName(4) + rowCount.ToString() + ":" + GetExcelColumnName(6) + rowCount.ToString()].Merge();
+                worksheet.Range[GetExcelColumnName(4) + rowCount.ToString()].Text = "DIRECTOR";
+                worksheet.Range[GetExcelColumnName(4) + rowCount.ToString() + ":" + GetExcelColumnName(6) + rowCount.ToString()].CellStyle = cellStyleTextBoldCenter;
+                worksheet.Range[GetExcelColumnName(4) + rowCount.ToString()].CellStyle.Font.Size = 11;
+
+                rowCount++;
+
+                //Saving the workbook as stream
+                bool exists = System.IO.Directory.Exists("./Files/Invoices/" + DateTime.Now.ToString("dd_MM_yyyy"));
+                if (!exists)
+                    System.IO.Directory.CreateDirectory("./Files/Invoices/" + DateTime.Now.ToString("dd_MM_yyyy"));
+                FileStream stream = new FileStream("./Files/Invoices/" + DateTime.Now.ToString("dd_MM_yyyy") + "/" + contract.id + "_" + contract.syntaxTelco + "_invoice_" + contract.syntaxConpany + ".xlsx", FileMode.Create, FileAccess.ReadWrite);
+                workbook.SaveAs(stream);
+                stream.Dispose();
+                return true;
+            }
+            catch (Exception ex)
+            {
+                log.Error("Exp: " + ex);
+                return false;
+            }
+        }
+
+        private static String[] units = { "Zero", "One", "Two", "Three",
+    "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Eleven",
+    "Twelve", "Thirteen", "Fourteen", "Fifteen", "Sixteen",
+    "Seventeen", "Eighteen", "Nineteen" };
+
+        private static String[] unitsNormal = { "zero", "one", "two", "three",
+    "four", "five", "six", "seven", "eight", "nine", "ten", "eleven",
+    "twelve", "thirteen", "fourteen", "fifteen", "sixteen",
+    "seventeen", "eighteen", "nineteen" };
+
+        private static String[] tens = { "", "", "Twenty", "Thirty", "Forty",
+    "Fifty", "Sixty", "Seventy", "Eighty", "Ninety" };
+
+        private static String[] tensNormal = { "", "", "twenty", "thirty", "forty",
+    "fifty", "sixty", "seventy", "eighty", "ninety" };
+
+        public static String ConvertAmount(double amount)
+        {
+            try
+            {
+                Int64 amount_int = (Int64)amount;
+                Int64 amount_dec = (Int64)Math.Round((amount - (double)(amount_int)) * 100);
+                if (amount_dec == 0)
+                {
+                    return FirstLetterToUpperCase(ConvertEnglish(amount_int));
+                }
+                else
+                {
+                    return FirstLetterToUpperCase(ConvertEnglish(amount_int)) + " Point " + ConvertEnglish(amount_dec);
+                }
+            }
+            catch (Exception e)
+            {
+                // TODO: handle exception  
+            }
+            return "";
+        }
+
+        public static String ConvertEnglish(Int64 i)
+        {
+            if (i < 20)
+            {
+                return unitsNormal[i];
+            }
+            if (i < 100)
+            {
+                return tensNormal[i / 10] + ((i % 10 > 0) ? " " + ConvertEnglish(i % 10) : "");
+            }
+            if (i < 1000)
+            {
+                return unitsNormal[i / 100] + " hundred"
+                        + ((i % 100 > 0) ? " and " + ConvertEnglish(i % 100) : "");
+            }
+            if (i < 100000)
+            {
+                return ConvertEnglish(i / 1000) + " thousand "
+                + ((i % 1000 > 0) ? " " + ConvertEnglish(i % 1000) : "");
+            }
+            if (i < 10000000)
+            {
+                return ConvertEnglish(i / 100000) + " lakh "
+                        + ((i % 100000 > 0) ? " " + ConvertEnglish(i % 100000) : "");
+            }
+            if (i < 1000000000)
+            {
+                return ConvertEnglish(i / 10000000) + " crore "
+                        + ((i % 10000000 > 0) ? " " + ConvertEnglish(i % 10000000) : "");
+            }
+            return ConvertEnglish(i / 1000000000) + " arab "
+                    + ((i % 1000000000 > 0) ? " " + ConvertEnglish(i % 1000000000) : "");
+        }
+
+        public static List<String> StringSeprate(String input, int numCharacter)
+        {
+            string[] words = input.Split(' ');
+            int counter = 0;
+            int countWord = 0;
+            String result = "";
+            String result2 = "";
+
+            for (int i = 0; i < words.Length; i++)
+            {
+                int nextCounter = counter + words[i].Length;
+                if (nextCounter < numCharacter)
+                {
+                    countWord++;
+                    if (counter == 0)
+                        result += words[i];
+                    else
+                        result += (" " + words[i]);
+                }
+                counter = nextCounter;
+            }
+            for (int i = countWord; i < words.Length; i++)
+            {
+                if (i == countWord)
+                    result2 += words[i];
+                else
+                    result2 += (" " + words[i]);
+            }
+            List<String> res = new List<string>();
+            res.Add(result);
+            res.Add(result2);
+            return res;
+        }
+
+        public static string FirstLetterToUpperCase(string s)
+        {
+            if (string.IsNullOrEmpty(s))
+                throw new ArgumentException("There is no first letter");
+
+            char[] a = s.ToCharArray();
+            a[0] = char.ToUpper(a[0]);
+            return new string(a);
+        }
+
+        public static void SaveDocFile(String inputFileName)
+        {
+            //Open an existing WordDocument
+            FileStream inputStream = new FileStream(inputFileName, FileMode.Open);
+            WordDocument document = new WordDocument(inputStream, FormatType.Docx);
+            //To-Do some manipulation
+            //To-Do some manipulation
+            //Saving the Word document
+            FileStream outputStream = new FileStream("Sample.docx", FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite);
+            document.Save(outputStream, FormatType.Docx);
+            document.Close();
+            outputStream.Flush();
+            outputStream.Dispose();
+        }
+
+        private static void IterateTextBody(WTextBody textBody)
+        {
+            //Iterates through each of the child items of WTextBody
+            for (int i = 0; i < textBody.ChildEntities.Count; i++)
+            {
+                //IEntity is the basic unit in DocIO DOM. 
+                //Accesses the body items (should be either paragraph, table or block content control) as IEntity
+                IEntity bodyItemEntity = textBody.ChildEntities[i];
+                //A Text body has 3 types of elements - Paragraph, Table and Block Content Control
+                //Decides the element type by using EntityType
+                switch (bodyItemEntity.EntityType)
+                {
+                    case EntityType.Paragraph:
+                        WParagraph paragraph = bodyItemEntity as WParagraph;
+                        //Checks for particular style name and removes the paragraph from DOM
+                        if (paragraph.StyleName == "MyStyle")
+                        {
+                            int index = textBody.ChildEntities.IndexOf(paragraph);
+                            textBody.ChildEntities.RemoveAt(index);
+                        }
+                        break;
+                    case EntityType.Table:
+                        //Table is a collection of rows and cells
+                        //Iterates through table's DOM
+                        IterateTable(bodyItemEntity as WTable);
+                        break;
+                    case EntityType.BlockContentControl:
+                        BlockContentControl blockContentControl = bodyItemEntity as BlockContentControl;
+                        //Iterates to the body items of Block Content Control.
+                        IterateTextBody(blockContentControl.TextBody);
+                        break;
+                }
+            }
+
+        }
+
+        public static string GetExcelColumnName(int columnNumber)
+        {
+            int dividend = columnNumber;
+            string columnName = String.Empty;
+            int modulo;
+
+            while (dividend > 0)
+            {
+                modulo = (dividend - 1) % 26;
+                columnName = Convert.ToChar(65 + modulo).ToString() + columnName;
+                dividend = (int)((dividend - modulo) / 26);
+            }
+            return columnName;
+        }
+
+        private static void IterateTable(WTable table)
+        {
+            //Iterates the row collection in a table
+            foreach (WTableRow row in table.Rows)
+            {
+                //Iterates the cell collection in a table row
+                foreach (WTableCell cell in row.Cells)
+                {
+                    //Table cell is derived from (also a) TextBody
+                    //Reusing the code meant for iterating TextBody
+                    IterateTextBody(cell);
+                }
+            }
+        }
+
+        public static bool CheckFile(String path)
+        {
+            return File.Exists(path);
+        }
+
+        public static void DeleteFile(String path)
+        {
+            File.Delete(path);
+        }
+
+        public static Byte[] GetFileByte(String path)
+        {
+            var dataBytes = File.ReadAllBytes(path);
+            return dataBytes;
+        }
+
+        public static Dictionary<String, String> GetAttribute(String data)
+        {
+
+            Dictionary<String, String> attributes = new Dictionary<String, String>();
+            string[] seprateSpace = data.Split(" ");
+            for (int i = 0; i < seprateSpace.Length; i++)
+            {
+                string[] seprateEqual = seprateSpace[i].Split("=\"");
+                if (seprateEqual.Length >= 2)
+                {
+                    if (seprateEqual[0] == "\"__VIEWSTATEGENERATOR\"")
+                    {
+                        attributes.Add(seprateEqual[0], seprateEqual[1].Remove(seprateEqual[1].Length - 1, 1));
+                    }
+                    else
+                    {
+                        Regex regex = new Regex("value=(['\"])(?:\\/.+?)\\1", RegexOptions.IgnoreCase);
+                        Match match;
+                        string value = seprateEqual[1];
+                        for (match = regex.Match(seprateSpace[i]); match.Success; match = match.NextMatch())
+                        {
+                            string d = match.Groups[0].Value.Substring(7);
+                            value = d.Remove(d.Length - 1, 1);
+
+                        }
+                        attributes.Add(seprateEqual[0], value);
+                    }
+                }
+            }
+            return attributes;
+        }
+
+        public static List<KeyValuePair<string, string>> ParseDataRequest(String responseText)
+        {
+
+            List<KeyValuePair<string, string>> data;
+            data = new List<KeyValuePair<string, string>>();
+
+            Regex regex = new Regex("<input.*?(?:name=\"*\".*?value=\"([^\"]+)| value =\"([^\"]+).*? name =\"*\")\"[^>]*>", RegexOptions.IgnoreCase);
+            Match match;
+            for (match = regex.Match(responseText); match.Success; match = match.NextMatch())
+            {
+                Dictionary<String, String> attrs = UtilsController.GetAttribute(match.Groups[0].Value);
+                String key = "";
+                String value = "";
+                foreach (KeyValuePair<string, string> item in attrs)
+                {
+                    if (item.Key == "name")
+                    {
+                        key = item.Value;
+                    }
+                    if (item.Key == "value")
+                    {
+                        value = item.Value;
+                    }
+                }
+                if (!key.Contains("cmdTraCuu") && !key.Contains("__EVENTTARGET") && !key.Contains("__EVENTARGUMENT"))
+                {
+                    string resultKey = Regex.Replace(key, @"[^\w\d]", "");
+                    data.Add(new KeyValuePair<string, string>(resultKey, value));
+                }
+            }
+            return data;
+        }
+
+    }
+}

+ 23 - 0
SuperCms/Database/ConnCkData.cs

@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+
+// Code scaffolded by EF Core assumes nullable reference types (NRTs) are not used or disabled.
+// If you have enabled NRTs for your project, then un-comment the following line:
+// #nullable disable
+
+namespace SuperCms.Database
+{
+    public partial class ConnCkData
+    {
+        public decimal Id { get; set; }
+        public int? NganhId { get; set; }
+        public DateTime? Vsysdate { get; set; }
+        public string Ngay { get; set; }
+        public string ThayDoi { get; set; }
+        public string TangGiam { get; set; }
+        public decimal? KhoiLuong { get; set; }
+        public decimal? GiaTri { get; set; }
+        public decimal? TnnMua { get; set; }
+        public decimal? TnnBan { get; set; }
+    }
+}

+ 20 - 0
SuperCms/Database/ConnCkNganh.cs

@@ -0,0 +1,20 @@
+using System;
+using System.Collections.Generic;
+
+// Code scaffolded by EF Core assumes nullable reference types (NRTs) are not used or disabled.
+// If you have enabled NRTs for your project, then un-comment the following line:
+// #nullable disable
+
+namespace SuperCms.Database
+{
+    public partial class ConnCkNganh
+    {
+        public decimal Id { get; set; }
+        public string Code { get; set; }
+        public string Name { get; set; }
+        public string Stt { get; set; }
+        public string Note { get; set; }
+        public string SubFrom { get; set; }
+        public string SubTo { get; set; }
+    }
+}

+ 137 - 0
SuperCms/Database/ModelContext.cs

@@ -0,0 +1,137 @@
+using System;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Metadata;
+
+// Code scaffolded by EF Core assumes nullable reference types (NRTs) are not used or disabled.
+// If you have enabled NRTs for your project, then un-comment the following line:
+// #nullable disable
+
+namespace SuperCms.Database
+{
+    public partial class ModelContext : DbContext
+    {
+        public ModelContext()
+        {
+        }
+
+        public ModelContext(DbContextOptions<ModelContext> options)
+            : base(options)
+        {
+        }
+
+        public virtual DbSet<ConnCkData> ConnCkData { get; set; }
+        public virtual DbSet<ConnCkNganh> ConnCkNganh { get; set; }
+
+        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
+        {
+            if (!optionsBuilder.IsConfigured)
+            {
+#warning To protect potentially sensitive information in your connection string, you should move it out of source code. See http://go.microsoft.com/fwlink/?LinkId=723263 for guidance on storing connection strings.
+                optionsBuilder.UseOracle("User Id=mytel;Password=mytel;Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=171.244.50.177)(PORT=1530))(CONNECT_DATA=(SID=orcl)));User Id=mytel;Password=mytel;Connection Timeout=120;");
+            }
+        }
+
+        protected override void OnModelCreating(ModelBuilder modelBuilder)
+        {
+            modelBuilder.HasAnnotation("Relational:DefaultSchema", "MYTEL");
+
+            modelBuilder.Entity<ConnCkData>(entity =>
+            {
+                entity.ToTable("CONN_CK_DATA");
+
+                entity.Property(e => e.Id)
+                    .HasColumnName("ID")
+                    .HasColumnType("NUMBER(20)");
+
+                entity.Property(e => e.GiaTri)
+                    .HasColumnName("GIA_TRI")
+                    .HasColumnType("NUMBER(20)")
+                    .HasDefaultValueSql(@"0 
+");
+
+                entity.Property(e => e.KhoiLuong)
+                    .HasColumnName("KHOI_LUONG")
+                    .HasColumnType("NUMBER(20)")
+                    .HasDefaultValueSql(@"0 
+");
+
+                entity.Property(e => e.NganhId).HasColumnName("NGANH_ID");
+
+                entity.Property(e => e.Ngay)
+                    .HasColumnName("NGAY")
+                    .HasMaxLength(100)
+                    .IsUnicode(false);
+
+                entity.Property(e => e.TangGiam)
+                    .HasColumnName("TANG_GIAM")
+                    .HasMaxLength(100)
+                    .IsUnicode(false);
+
+                entity.Property(e => e.ThayDoi)
+                    .HasColumnName("THAY_DOI")
+                    .HasMaxLength(100)
+                    .IsUnicode(false);
+
+                entity.Property(e => e.TnnBan)
+                    .HasColumnName("TNN_BAN")
+                    .HasColumnType("NUMBER(20)")
+                    .HasDefaultValueSql(@"0 
+");
+
+                entity.Property(e => e.TnnMua)
+                    .HasColumnName("TNN_MUA")
+                    .HasColumnType("NUMBER(20)")
+                    .HasDefaultValueSql(@"0 
+");
+
+                entity.Property(e => e.Vsysdate)
+                    .HasColumnName("VSYSDATE")
+                    .HasColumnType("DATE")
+                    .HasDefaultValueSql(@"sysdate 
+");
+            });
+
+            modelBuilder.Entity<ConnCkNganh>(entity =>
+            {
+                entity.ToTable("CONN_CK_NGANH");
+
+                entity.Property(e => e.Id)
+                    .HasColumnName("ID")
+                    .HasColumnType("NUMBER(20)");
+
+                entity.Property(e => e.Code)
+                    .HasColumnName("CODE")
+                    .HasMaxLength(1000);
+
+                entity.Property(e => e.Name)
+                    .HasColumnName("NAME")
+                    .HasMaxLength(1000);
+
+                entity.Property(e => e.Note)
+                    .HasColumnName("NOTE")
+                    .HasMaxLength(1000);
+
+                entity.Property(e => e.Stt)
+                    .HasColumnName("STT")
+                    .HasMaxLength(20)
+                    .IsUnicode(false);
+
+                entity.Property(e => e.SubFrom)
+                    .HasColumnName("SUB_FROM")
+                    .HasMaxLength(1000);
+
+                entity.Property(e => e.SubTo)
+                    .HasColumnName("SUB_TO")
+                    .HasMaxLength(1000);
+            });
+
+            modelBuilder.HasSequence("CONN_DATA_CONFIG_SEQ");
+
+            modelBuilder.HasSequence("MT_SEQ");
+
+            OnModelCreatingPartial(modelBuilder);
+        }
+
+        partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
+    }
+}

+ 33 - 0
SuperCms/Extensions/SessionExtensions.cs

@@ -0,0 +1,33 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace SuperCms.Extensions
+{
+    using System;
+    using Microsoft.AspNetCore.Http;
+    using Newtonsoft.Json;
+
+    public static class SessionExtensions
+    {
+        public static T GetComplexData<T>(this ISession session, string key)
+        {
+            var data = session.GetString(key);
+            if (data == null)
+            {
+                return default(T);
+            }
+            return JsonConvert.DeserializeObject<T>(data);
+        }
+
+        public static void SetComplexData(this ISession session, string key, object value)
+        {
+            session.SetString(key, JsonConvert.SerializeObject(value));
+        }
+        public static void RemoveComplexData(this ISession session, string key)
+        {
+            session.Remove(key);
+        }
+    }
+}

binární
SuperCms/Files/Invoices/13_06_2022/1_TELEMOR_invoice_GTS.docx


binární
SuperCms/Files/Invoices/23_07_2021/10_invoice_INTERLAND.xlsx


binární
SuperCms/Files/Invoices/23_07_2021/1_invoice_GTS.docx


binární
SuperCms/Files/Invoices/23_07_2021/2_invoice_GTS.docx


binární
SuperCms/Files/Invoices/23_07_2021/3_invoice_GTS.docx


binární
SuperCms/Files/Invoices/23_07_2021/4_invoice_GTS.docx


binární
SuperCms/Files/Invoices/23_07_2021/5_invoice_VIETTECH.docx


binární
SuperCms/Files/Invoices/23_07_2021/6_invoice_VIETTECH.docx


binární
SuperCms/Files/Invoices/23_07_2021/7_invoice_VIETTECH.docx


binární
SuperCms/Files/Invoices/23_07_2021/8_invoice_INTERLAND.xlsx


binární
SuperCms/Files/Invoices/23_07_2021/9_invoice_INTERLAND.xlsx


binární
SuperCms/Files/Payments/13_06_2022/1_3_payment_GTS.docx


binární
SuperCms/Files/Payments/13_06_2022/1_TELEMOR_payment_GTS.docx


binární
SuperCms/Files/Payments/22_07_2021/10_payment_INTERLAND.docx


binární
SuperCms/Files/Payments/22_07_2021/1_payment_GTS.docx


binární
SuperCms/Files/Payments/22_07_2021/2_payment_GTS.docx


binární
SuperCms/Files/Payments/22_07_2021/3_payment_GTS.docx


binární
SuperCms/Files/Payments/22_07_2021/4_payment_GTS.docx


binární
SuperCms/Files/Payments/22_07_2021/5_payment_VIETTECH.docx


binární
SuperCms/Files/Payments/22_07_2021/6_payment_VIETTECH.docx


binární
SuperCms/Files/Payments/22_07_2021/7_payment_VIETTECH.docx


binární
SuperCms/Files/Payments/22_07_2021/8_payment_INTERLAND.docx


binární
SuperCms/Files/Payments/22_07_2021/9_payment_INTERLAND.docx


binární
SuperCms/Files/Payments/23_07_2021/10_payment_INTERLAND.docx


binární
SuperCms/Files/Payments/23_07_2021/1_payment_GTS.docx


binární
SuperCms/Files/Payments/23_07_2021/2_payment_GTS.docx


binární
SuperCms/Files/Payments/23_07_2021/3_payment_GTS.docx


binární
SuperCms/Files/Payments/23_07_2021/4_payment_GTS.docx


binární
SuperCms/Files/Payments/23_07_2021/5_payment_VIETTECH.docx


binární
SuperCms/Files/Payments/23_07_2021/6_payment_VIETTECH.docx


binární
SuperCms/Files/Payments/23_07_2021/7_payment_VIETTECH.docx


binární
SuperCms/Files/Payments/23_07_2021/8_payment_INTERLAND.docx


binární
SuperCms/Files/Payments/23_07_2021/9_payment_INTERLAND.docx


binární
SuperCms/Files/Template/template.xlsx


binární
SuperCms/Files/Template/template2.xlsx


+ 84 - 0
SuperCms/Models/BotStructure.cs

@@ -0,0 +1,84 @@
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace SuperCms.Models
+{
+//    id NUMBER,
+//group_id      NUMBER,
+//    name NCLOB,
+//    description   NCLOB,
+//    status NUMBER,
+//    create_date   DATE DEFAULT sysdate,
+//    update_date DATE DEFAULT sysdate,
+//  start_date    DATE DEFAULT sysdate,
+//    end_date DATE DEFAULT sysdate,
+    public class BotStructure
+    {
+        public String id { get; set; }
+        public String name { get; set; }
+        public String description { get; set; }
+        public String status { get; set; }
+        public String createDate { get; set; }
+        public String updateDate { get; set; }
+        public String startDate { get; set; }
+        public String endDate { get; set; }
+
+        public override string ToString()
+        {
+            return JsonConvert.SerializeObject(this);
+        }
+
+        public BotStructure() { }
+
+        public BotStructure(string json) : this(JObject.Parse(json))
+        { }
+
+        public BotStructure(JObject jObject)
+        {
+            if (jObject != null)
+            {
+                id = (string)jObject["ID"];
+                name = (string)jObject["NAME"];
+                description = (string)jObject["DESCRIPTION"];
+                status = (string)jObject["STATUS"];
+                createDate = (string)jObject["CREATE_DATE"];
+                updateDate = (string)jObject["UPDATE_DATE"];
+                startDate = (string)jObject["START_DATE"];
+                endDate = (string)jObject["END_DATE"];
+            }
+        }
+    }
+
+    public class BotStructures
+    {
+        [JsonProperty("data")]
+        public List<BotStructure> data { get; set; }
+
+        public override string ToString()
+        {
+            return JsonConvert.SerializeObject(this);
+        }
+
+        public BotStructures() { }
+        public BotStructures(string json) : this(JObject.Parse(json)) { }
+        public BotStructures(JObject jObject)
+        {
+            if (jObject != null)
+            {
+                var list = jObject["data"];
+                if (list != null && list.HasValues)
+                {
+                    data = new List<BotStructure>();
+                    JArray a = (JArray)list;
+                    foreach (JObject o in a.Children<JObject>())
+                    {
+                        data.Add(new BotStructure(o));
+                    }
+                }
+            }
+        }
+    }
+}

+ 70 - 0
SuperCms/Models/Config.cs

@@ -0,0 +1,70 @@
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace SuperCms.Models
+{
+    public class Config
+    {
+        public String id { get; set; }
+        public String key { get; set; }
+        public String value { get; set; }
+        public String createDate { get; set; }
+        public String updateDate { get; set; }
+
+        public override string ToString()
+        {
+            return JsonConvert.SerializeObject(this);
+        }
+
+        public Config() { }
+
+        public Config(string json) : this(JObject.Parse(json))
+        { }
+
+        public Config(JObject jObject)
+        {
+            if (jObject != null)
+            {
+                id = (string)jObject["ID"];
+                key = (string)jObject["KEY"];
+                value = (string)jObject["VALUE"];
+                createDate = (string)jObject["CREATE_DATE"];
+                updateDate = (string)jObject["UPDATE_DATE"];
+            }
+        }
+    }
+
+    public class Configs
+    {
+        [JsonProperty("data")]
+        public List<Config> data { get; set; }
+
+        public override string ToString()
+        {
+            return JsonConvert.SerializeObject(this);
+        }
+
+        public Configs() { }
+        public Configs(string json) : this(JObject.Parse(json)) { }
+        public Configs(JObject jObject)
+        {
+            if (jObject != null)
+            {
+                var list = jObject["data"];
+                if (list != null && list.HasValues)
+                {
+                    data = new List<Config>();
+                    JArray a = (JArray)list;
+                    foreach (JObject o in a.Children<JObject>())
+                    {
+                        data.Add(new Config(o));
+                    }
+                }
+            }
+        }
+    }
+}

+ 38 - 0
SuperCms/Models/ConfigViewModel.cs

@@ -0,0 +1,38 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace SuperCms.Models
+{
+    public class ConfigViewModel
+    {
+        public String page { get; set; }
+        public String totalPage { get; set; }
+        public String tableType { get; set; }
+        public BotStructures bots { get; set; }
+        public ScheduleStructures schedules { get; set; }
+        public GroupStructures groups { get; set; }
+        public Configs configs { get; set; }
+        public SendMails sendMails { get; set; }
+        //public ConnConfigs connConfigs { get; set; }
+
+        // editing
+        public BotStructure bot { get; set; }
+        public ScheduleStructure schedule { get; set; }
+        public GroupStructure group { get; set; }
+        public Config config { get; set; }
+        public SendMail sendMail { get; set; }
+        //public ConnConfig connConfig { get; set; }
+
+        // for send mail
+        public ConnTelcos telcos { get; set; }
+        public ConnCompanies companies { get; set; }
+        public ConnTelco telco { get; set; }
+        public ConnCompany company { get; set; }
+        public ConnConfigs services { get; set; }
+        public ConnConfig service { get; set; }
+
+
+    }
+}

+ 75 - 0
SuperCms/Models/ConnCompany.cs

@@ -0,0 +1,75 @@
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace SuperCms.Models
+{
+    public class ConnCompany
+    {
+        public String id { get; set; }
+        public String name { get; set; }
+        public String code { get; set; }
+        public String phone { get; set; }
+        public String mst { get; set; }
+        public String address { get; set; }
+        public String sequence { get; set; }
+
+
+        public override string ToString()
+        {
+            return JsonConvert.SerializeObject(this);
+        }
+
+        public ConnCompany() { }
+
+        public ConnCompany(string json) : this(JObject.Parse(json))
+        { }
+
+        public ConnCompany(JObject jObject)
+        {
+            if (jObject != null)
+            {
+                id = (string)jObject["ID"];
+                name = (string)jObject["NAME"];
+                code = (string)jObject["CODE"];
+                phone = (string)jObject["PHONE"];
+                mst = (string)jObject["MST"];
+                address = (string)jObject["ADDRESS"];
+                sequence = (string)jObject["SEQUENCE"];
+            }
+        }
+    }
+
+    public class ConnCompanies
+    {
+        [JsonProperty("data")]
+        public List<ConnCompany> data { get; set; }
+
+        public override string ToString()
+        {
+            return JsonConvert.SerializeObject(this);
+        }
+
+        public ConnCompanies() { }
+        public ConnCompanies(string json) : this(JObject.Parse(json)) { }
+        public ConnCompanies(JObject jObject)
+        {
+            if (jObject != null)
+            {
+                var list = jObject["data"];
+                if (list != null && list.HasValues)
+                {
+                    data = new List<ConnCompany>();
+                    JArray a = (JArray)list;
+                    foreach (JObject o in a.Children<JObject>())
+                    {
+                        data.Add(new ConnCompany(o));
+                    }
+                }
+            }
+        }
+    }
+}

+ 96 - 0
SuperCms/Models/ConnConfig.cs

@@ -0,0 +1,96 @@
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace SuperCms.Models
+{
+    public class ConnConfig
+    {
+        public String id { get; set; }
+        public String serviceID { get; set; }
+        public String serviceName { get; set; }
+        public String url { get; set; }
+        public String connection { get; set; }
+        public String dateRun { get; set; }
+        public String dateGet { get; set; }
+        public String hourRun { get; set; }
+        public String telco { get; set; }
+        public String vSql { get; set; }
+        public String totalRun { get; set; }
+        public String stt { get; set; }
+        public String telcoID { get; set; }
+        public String companyID { get; set; }
+        public String status { get; set; }
+        public String sequence { get; set; }
+        public String state { get; set; }
+        public String money { get; set; }
+
+        public override string ToString()
+        {
+            return JsonConvert.SerializeObject(this);
+        }
+
+        public ConnConfig() { }
+
+        public ConnConfig(string json) : this(JObject.Parse(json))
+        { }
+
+        public ConnConfig(JObject jObject)
+        {
+            if (jObject != null)
+            {
+                id = (string)jObject["ID"];
+                serviceID = (string)jObject["SV_ID"];
+                serviceName = (string)jObject["SV_NAME"];
+                url = (string)jObject["URL"];
+                connection = (string)jObject["CONN"];
+                dateRun = (string)jObject["SYSTEM_DATE_RUN"];
+                dateGet = (string)jObject["LOCA_DATE_GET"];
+                hourRun = (string)jObject["HOUR_RUN"];
+                telco = (string)jObject["TELCO"];
+                vSql = (string)jObject["V_SQL"];
+                totalRun = (string)jObject["TOTAL_RUN"];
+                stt = (string)jObject["STT"];
+                telcoID = (string)jObject["TELCO_ID"];
+                companyID = (string)jObject["COMPANY_ID"];
+                status = (string)jObject["STATUS"];
+                sequence = (string)jObject["SEQUENCE"];
+                state = (string)jObject["STATE"];
+                money = (string)jObject["MONEY"];
+            }
+        }
+    }
+
+    public class ConnConfigs
+    {
+        [JsonProperty("data")]
+        public List<ConnConfig> data { get; set; }
+
+        public override string ToString()
+        {
+            return JsonConvert.SerializeObject(this);
+        }
+
+        public ConnConfigs() { }
+        public ConnConfigs(string json) : this(JObject.Parse(json)) { }
+        public ConnConfigs(JObject jObject)
+        {
+            if (jObject != null)
+            {
+                var list = jObject["data"];
+                if (list != null && list.HasValues)
+                {
+                    data = new List<ConnConfig>();
+                    JArray a = (JArray)list;
+                    foreach (JObject o in a.Children<JObject>())
+                    {
+                        data.Add(new ConnConfig(o));
+                    }
+                }
+            }
+        }
+    }
+}

+ 80 - 0
SuperCms/Models/ConnData.cs

@@ -0,0 +1,80 @@
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace SuperCms.Models
+{
+    public class ConnData
+    {
+        public String id { get; set; }
+        public String configID { get; set; }
+        public String dateGet { get; set; }
+        public String totalSub { get; set; }
+        public String registerNew { get; set; }
+        public String deactive { get; set; }
+        public String revenue { get; set; }
+        public String expense { get; set; }
+        public String success { get; set; }
+        public String dateRun { get; set; }
+
+        public override string ToString()
+        {
+            return JsonConvert.SerializeObject(this);
+        }
+
+        public ConnData() { }
+
+        public ConnData(string json) : this(JObject.Parse(json))
+        { }
+
+        public ConnData(JObject jObject)
+        {
+            if (jObject != null)
+            {
+                id = (string)jObject["ID"];
+                configID = (string)jObject["CONFIG_ID"];
+                dateGet = (string)jObject["NGAY"];
+                totalSub = (string)jObject["TONGSUB"];
+                registerNew = (string)jObject["DANGKY"];
+                deactive = (string)jObject["HUY"];
+                revenue = (string)jObject["DOANHTHU"];
+                expense = (string)jObject["CONGTIEN"];
+                success = (string)jObject["ISSUCCESS"];
+                dateRun = (string)jObject["VSYSDATE"];
+            }
+        }
+    }
+
+    public class ConnDatas
+    {
+        [JsonProperty("data")]
+        public List<ConnData> data { get; set; }
+
+        public override string ToString()
+        {
+            return JsonConvert.SerializeObject(this);
+        }
+
+        public ConnDatas() { }
+        public ConnDatas(string json) : this(JObject.Parse(json)) { }
+        public ConnDatas(JObject jObject)
+        {
+            if (jObject != null)
+            {
+                var list = jObject["data"];
+                if (list != null && list.HasValues)
+                {
+                    data = new List<ConnData>();
+                    JArray a = (JArray)list;
+                    foreach (JObject o in a.Children<JObject>())
+                    {
+                        data.Add(new ConnData(o));
+                    }
+                }
+            }
+        }
+    }
+}

+ 71 - 0
SuperCms/Models/ConnTelco.cs

@@ -0,0 +1,71 @@
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace SuperCms.Models
+{
+    public class ConnTelco
+    {
+        public String id { get; set; }
+        public String telcoCode { get; set; }
+        public String telcoName { get; set; }
+        public String sequence { get; set; }
+        public String timeDiff { get; set; }
+
+
+        public override string ToString()
+        {
+            return JsonConvert.SerializeObject(this);
+        }
+
+        public ConnTelco() { }
+
+        public ConnTelco(string json) : this(JObject.Parse(json))
+        { }
+
+        public ConnTelco(JObject jObject)
+        {
+            if (jObject != null)
+            {
+                id = (string)jObject["ID"];
+                telcoCode = (string)jObject["TELCO_CODE"];
+                telcoName = (string)jObject["TELCO_NAME"];
+                sequence = (string)jObject["SEQUENCE"];
+                timeDiff = (string)jObject["TIME_DIFF"];
+            }
+        }
+    }
+
+    public class ConnTelcos
+    {
+        [JsonProperty("data")]
+        public List<ConnTelco> data { get; set; }
+
+        public override string ToString()
+        {
+            return JsonConvert.SerializeObject(this);
+        }
+
+        public ConnTelcos() { }
+        public ConnTelcos(string json) : this(JObject.Parse(json)) { }
+        public ConnTelcos(JObject jObject)
+        {
+            if (jObject != null)
+            {
+                var list = jObject["data"];
+                if (list != null && list.HasValues)
+                {
+                    data = new List<ConnTelco>();
+                    JArray a = (JArray)list;
+                    foreach (JObject o in a.Children<JObject>())
+                    {
+                        data.Add(new ConnTelco(o));
+                    }
+                }
+            }
+        }
+    }
+}

+ 28 - 0
SuperCms/Models/Contract.cs

@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace SuperCms.Models
+{
+    public class Contract
+    {
+        public String id { get; set; }
+        public String telco { get; set; }
+        public String company { get; set; }
+        public String service { get; set; }
+        public String address { get; set; }
+        public String addressTelco { get; set; }
+        public String account { get; set; }
+        public String swiftCode { get; set; }
+        public String contractCode { get; set; }
+        public String time { get; set; }
+        public String money { get; set; }
+        public String beneficiary { get; set; }
+        public String syntaxConpany { get; set; }
+        public String syntaxTelco { get; set; }
+        public String bank { get; set; }
+        public String taxCode { get; set; }
+
+    }
+}

+ 11 - 0
SuperCms/Models/ErrorViewModel.cs

@@ -0,0 +1,11 @@
+using System;
+
+namespace SuperCms.Models
+{
+    public class ErrorViewModel
+    {
+        public string RequestId { get; set; }
+
+        public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
+    }
+}

+ 84 - 0
SuperCms/Models/GroupStructure.cs

@@ -0,0 +1,84 @@
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace SuperCms.Models
+{
+//    id NUMBER,
+//bot_id        NUMBER,
+//    name NCLOB,
+//    description   NCLOB,
+//    status NUMBER,
+//    create_date   DATE DEFAULT sysdate,
+//    update_date DATE DEFAULT sysdate,
+//  start_date    DATE DEFAULT sysdate,
+//    end_date DATE DEFAULT sysdate,
+    public class GroupStructure
+    {
+        public String id { get; set; }
+        public String name { get; set; }
+        public String description { get; set; }
+        public String status { get; set; }
+        public String createDate { get; set; }
+        public String updateDate { get; set; }
+        public String startDate { get; set; }
+        public String endDate { get; set; }
+
+        public override string ToString()
+        {
+            return JsonConvert.SerializeObject(this);
+        }
+
+        public GroupStructure() { }
+
+        public GroupStructure(string json) : this(JObject.Parse(json))
+        { }
+
+        public GroupStructure(JObject jObject)
+        {
+            if (jObject != null)
+            {
+                id = (string)jObject["ID"];
+                name = (string)jObject["NAME"];
+                description = (string)jObject["DESCRIPTION"];
+                status = (string)jObject["STATUS"];
+                createDate = (string)jObject["CREATE_DATE"];
+                updateDate = (string)jObject["UPDATE_DATE"];
+                startDate = (string)jObject["START_DATE"];
+                endDate = (string)jObject["END_DATE"];
+            }
+        }
+    }
+
+    public class GroupStructures
+    {
+        [JsonProperty("data")]
+        public List<GroupStructure> data { get; set; }
+
+        public override string ToString()
+        {
+            return JsonConvert.SerializeObject(this);
+        }
+
+        public GroupStructures() { }
+        public GroupStructures(string json) : this(JObject.Parse(json)) { }
+        public GroupStructures(JObject jObject)
+        {
+            if (jObject != null)
+            {
+                var list = jObject["data"];
+                if (list != null && list.HasValues)
+                {
+                    data = new List<GroupStructure>();
+                    JArray a = (JArray)list;
+                    foreach (JObject o in a.Children<JObject>())
+                    {
+                        data.Add(new GroupStructure(o));
+                    }
+                }
+            }
+        }
+    }
+}

+ 46 - 0
SuperCms/Models/HomeViewModel.cs

@@ -0,0 +1,46 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace SuperCms.Models
+{
+    public class HomeViewModel
+    {
+        public ConnDatas connDatas { get; set; }
+        public ConnDatas connDatasNow { get; set; }
+        public ConnDatas connDatasBefore { get; set; }
+        public List<DistributedData> distributedDatas { get; set; }
+        public List<DateTime> listDate { get; set; }
+        public List<DistributedByTime> distributedByTimes { get; set; }
+        public String page { get; set; }
+        public String totalPage { get; set; }
+        public ConnTelcos telcos { get; set; }
+        public ConnCompanies companies { get; set; }
+
+        public ConnConfigs services { get; set; }
+        public ConnConfigs totalServices { get; set; }
+
+
+    }
+
+    public class DistributedData
+    {
+        public ConnConfig service { get; set; }
+        public ConnDatas connDatas { get; set; }
+    }
+
+    public class DistributedByTime
+    {
+        public DateTime time { get; set; }
+        public ConnConfig service { get; set; }
+        public ConnDatas connDatas { get; set; }
+    }
+
+    public class DistributedByTelcoAndCompany
+    {
+        public ConnTelco telco { get; set; }
+        public ConnCompanies companies { get; set; }
+        public ConnConfigs services { get; set; }
+    }
+}

+ 16 - 0
SuperCms/Models/PartialViewModel.cs

@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace LiveInfo.Models
+{
+    public class PartialViewModel
+    {
+        public String message { get; set; }
+        public String id { get; set; }
+        public String url { get; set; }
+        public String tableType { get; set; }
+
+    }
+}

+ 9 - 0
SuperCms/Models/RegistryViewModel.cs

@@ -0,0 +1,9 @@
+using System;
+
+namespace SuperCms.Models
+{
+    public class RegistryViewModel
+    {
+        public String table { get; set; }
+    }
+}

+ 88 - 0
SuperCms/Models/ReportViewModel.cs

@@ -0,0 +1,88 @@
+using Syncfusion.Drawing;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace SuperCms.Models
+{
+    public class ReportViewModel
+    {
+        public String typeGet { get; set; }
+        public String timeNow { get; set; }
+        public String date { get; set; }
+        public String companyID { get; set; }
+        public String telcoID { get; set; }
+        public String page { get; set; }
+        public String totalPage { get; set; }
+
+        public ConnTelcos telcos { get; set; }
+        public ConnCompanies companies { get; set; }
+        public List<DateTime> listDate { get; set; }
+        // data
+        public ConnTelco telco { get; set; }
+        public ConnCompany company { get; set; }
+        public ConnConfigs services { get; set; }
+        public ConnDatas data { get; set; }
+
+        public List<DistributedDataByService> distributedDataByServices { get; set; }
+
+        // for export partial
+        public String startDate { get; set; }
+        public String endDate { get; set; }
+
+    }
+    public class DistributedDataByService
+    {
+        public ConnConfig service { get; set; }
+        public ConnDatas dataNow { get; set; }
+        public ConnDatas dataLastMonth { get; set; }
+        public List<DistributedByTime> distributedByTimes { get; set; }
+
+    }
+
+    public class DistributedDataForExcelByOneMonth
+    {
+        public DateTime month { get; set; }
+        public List<DateTime> time { get; set; }
+        public ConnTelcos telcos { get; set; }
+        public ConnCompanies companies { get; set; }
+        public ConnConfigs services { get; set; }
+        public List<DistributedByTime> distributedByTimes { get; set; }
+    }
+
+    public class ServiceRowPosition
+    {
+        public ConnConfig service { get; set; }
+        public List<String> positions { get; set; }
+    }
+
+    public class RowAttributed
+    {
+        public String character { get; set; }
+        public String number { get; set; }
+        public object center { get; set; }
+
+        public Boolean bold { get; set; }
+        public object color { get; set; }
+        public object background { get; set; }
+        public object thinLeft { get;set; }
+        public object thinRight { get; set; }
+        public object thinTop { get; set; }
+        public object thinBottom { get; set; }
+
+        public RowAttributed(String character, String number,  Boolean bold, object color, object background, object thinLeft, object thinRight, object thinTop, object thinBottom, object center)
+        {
+            this.character = character;
+            this.number = number;
+            this.center = center;
+            this.bold = bold;
+            this.color = color;
+            this.background = background;
+            this.thinLeft = thinLeft;
+            this.thinRight = thinRight;
+            this.thinTop = thinTop;
+            this.thinBottom = thinBottom;
+        }
+    }
+}

+ 63 - 0
SuperCms/Models/ResponseStructure.cs

@@ -0,0 +1,63 @@
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace SuperCms.Models
+{
+    public class ResponseStructure
+    {
+        public String code { get; set; }
+        public String message { get; set; }
+
+        public override string ToString()
+        {
+            return JsonConvert.SerializeObject(this);
+        }
+
+        public ResponseStructure() { }
+
+        public ResponseStructure(string json) : this(JObject.Parse(json))
+        { }
+
+        public ResponseStructure(JObject jObject)
+        {
+            if (jObject != null)
+            {
+                code = (string)jObject["CODE"];
+                message = (string)jObject["MESSAGE"];
+            }
+        }
+    }
+
+    public class ResponseStructures
+    {
+        [JsonProperty("data")]
+        public List<ResponseStructure> data { get; set; }
+
+        public override string ToString()
+        {
+            return JsonConvert.SerializeObject(this);
+        }
+
+        public ResponseStructures() { }
+        public ResponseStructures(string json) : this(JObject.Parse(json)) { }
+        public ResponseStructures(JObject jObject)
+        {
+            if (jObject != null)
+            {
+                var list = jObject["data"];
+                if (list != null && list.HasValues)
+                {
+                    data = new List<ResponseStructure>();
+                    JArray a = (JArray)list;
+                    foreach (JObject o in a.Children<JObject>())
+                    {
+                        data.Add(new ResponseStructure(o));
+                    }
+                }
+            }
+        }
+    }
+}

+ 90 - 0
SuperCms/Models/ScheduleStructure.cs

@@ -0,0 +1,90 @@
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace SuperCms.Models
+{
+    //    id NUMBER,
+    //name          NCLOB,
+    //    description NCLOB,
+    //    status        NUMBER,
+    //    create_date DATE DEFAULT sysdate,
+    //  update_date   DATE DEFAULT sysdate,
+    //    time_run DATE DEFAULT sysdate,
+    //    content NCLOB,
+    //    note          NCLOB,
+    public class ScheduleStructure
+    {
+        public String id { get; set; }
+        public String botID { get; set; }
+        public String groupID { get; set; }
+        public String name { get; set; }
+        public String description { get; set; }
+        public String status { get; set; }
+        public String createDate { get; set; }
+        public String updateDate { get; set; }
+        public String timeRun { get; set; }
+        public String content { get; set; }
+        public String note { get; set; }
+
+        public override string ToString()
+        {
+            return JsonConvert.SerializeObject(this);
+        }
+
+        public ScheduleStructure() { }
+
+        public ScheduleStructure(string json) : this(JObject.Parse(json))
+        { }
+
+        public ScheduleStructure(JObject jObject)
+        {
+            if (jObject != null)
+            {
+                id = (string)jObject["ID"];
+                botID = (string)jObject["BOT_ID"];
+                groupID = (string)jObject["GROUP_ID"];
+                name = (string)jObject["NAME"];
+                description = (string)jObject["DESCRIPTION"];
+                status = (string)jObject["STATUS"];
+                createDate = (string)jObject["CREATE_DATE"];
+                updateDate = (string)jObject["UPDATE_DATE"];
+                timeRun = (string)jObject["TIME_RUN"];
+                content = (string)jObject["CONTENT"];
+                note = (string)jObject["NOTE"];
+            }
+        }
+    }
+
+    public class ScheduleStructures
+    {
+        [JsonProperty("data")]
+        public List<ScheduleStructure> data { get; set; }
+
+        public override string ToString()
+        {
+            return JsonConvert.SerializeObject(this);
+        }
+
+        public ScheduleStructures() { }
+        public ScheduleStructures(string json) : this(JObject.Parse(json)) { }
+        public ScheduleStructures(JObject jObject)
+        {
+            if (jObject != null)
+            {
+                var list = jObject["data"];
+                if (list != null && list.HasValues)
+                {
+                    data = new List<ScheduleStructure>();
+                    JArray a = (JArray)list;
+                    foreach (JObject o in a.Children<JObject>())
+                    {
+                        data.Add(new ScheduleStructure(o));
+                    }
+                }
+            }
+        }
+    }
+}

+ 80 - 0
SuperCms/Models/SendMail.cs

@@ -0,0 +1,80 @@
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace SuperCms.Models
+{
+    public class SendMail
+    {
+        public String id { get; set; }
+        public String telcoId { get; set; }
+        public String companyId { get; set; }
+        public String serviceId { get; set; }
+        public String listMail { get; set; }
+        public String message { get; set; }
+        public String status { get; set; }
+        public String createDate { get; set; }
+        public String updateDate { get; set; }
+        public String timeSend { get; set; }
+
+        public override string ToString()
+        {
+            return JsonConvert.SerializeObject(this);
+        }
+
+        public SendMail() { }
+
+        public SendMail(string json) : this(JObject.Parse(json))
+        { }
+
+        public SendMail(JObject jObject)
+        {
+            if (jObject != null)
+            {
+                id = (string)jObject["ID"];
+                telcoId = (string)jObject["TELCO_ID"];
+                companyId = (string)jObject["COMPANY_ID"];
+                serviceId = (string)jObject["SERVICE_ID"];
+                listMail = (string)jObject["LIST_MAIL"];
+                message = (string)jObject["MESSAGE"];
+                status = (string)jObject["STATUS"];
+                timeSend = (string)jObject["TIME_SEND"];
+                createDate = (string)jObject["CREATE_DATE"];
+                updateDate = (string)jObject["UPDATE_DATE"];
+            }
+        }
+    }
+
+    public class SendMails
+    {
+        [JsonProperty("data")]
+        public List<SendMail> data { get; set; }
+
+        public override string ToString()
+        {
+            return JsonConvert.SerializeObject(this);
+        }
+
+        public SendMails() { }
+        public SendMails(string json) : this(JObject.Parse(json)) { }
+        public SendMails(JObject jObject)
+        {
+            if (jObject != null)
+            {
+                var list = jObject["data"];
+                if (list != null && list.HasValues)
+                {
+                    data = new List<SendMail>();
+                    JArray a = (JArray)list;
+                    foreach (JObject o in a.Children<JObject>())
+                    {
+                        data.Add(new SendMail(o));
+                    }
+                }
+            }
+        }
+    }
+}

+ 16 - 0
SuperCms/Models/StockViewModel.cs

@@ -0,0 +1,16 @@
+using SuperCms.Database;
+using System;
+using System.Collections.Generic;
+
+namespace SuperCms.Models
+{
+    public class StockViewModel
+    {
+        public List<ConnCkData> stockData { get; set; }
+        public List<ConnCkNganh> stockNganh { get; set; }
+        public string fromDate { get; set; }
+        public string toDate { get; set; }
+        public Dictionary<ConnCkNganh, Dictionary<DateTime, ConnCkData>> distributeData { get; set; }
+        public List<DateTime> listDate { get; set; }
+    }
+}

+ 15 - 0
SuperCms/Models/SupportViewModel.cs

@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace SuperCms.Models
+{
+    public class SupportViewModel
+    {
+        public String typeTable { get; set; }
+        public String actionFile { get; set; }
+        public String pageNow { get; set; }
+        public String totalPage { get; set; }
+    }
+}

+ 78 - 0
SuperCms/Oracle/OracleDynamicParameters.cs

@@ -0,0 +1,78 @@
+using Dapper;
+using Oracle.ManagedDataAccess.Client;
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace SuperCms.Oracle
+{
+    public class OracleDynamicParameters : SqlMapper.IDynamicParameters
+    {
+        private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof(OracleDynamicParameters));
+        private readonly DynamicParameters dynamicParameters = new DynamicParameters();
+        private readonly List<OracleParameter> oracleParameters = new List<OracleParameter>();
+
+        public void Add(string name, OracleDbType oracleDbType, ParameterDirection direction, object value = null, int? size = null)
+        {
+            try
+            {
+                OracleParameter oracleParameter;
+                if (size.HasValue)
+                {
+                    oracleParameter = new OracleParameter(name, oracleDbType, size.Value, value, direction);
+                }
+                else
+                {
+                    oracleParameter = new OracleParameter(name, oracleDbType, value, direction);
+                }
+
+                oracleParameters.Add(oracleParameter);
+            }
+            catch (Exception ex)
+            {
+                log.Error(ex);
+                throw ex;
+            }
+
+        }
+
+        public void Add(string name, OracleDbType oracleDbType, ParameterDirection direction)
+        {
+            try
+            {
+                var oracleParameter = new OracleParameter(name, oracleDbType, direction);
+                oracleParameters.Add(oracleParameter);
+            }
+            catch (Exception ex)
+            {
+                log.Error(ex);
+                throw ex;
+            }
+
+        }
+
+        public void AddParameters(IDbCommand command, SqlMapper.Identity identity)
+        {
+            try
+            {
+                ((SqlMapper.IDynamicParameters)dynamicParameters).AddParameters(command, identity);
+
+                var oracleCommand = command as OracleCommand;
+
+                if (oracleCommand != null)
+                {
+                    oracleCommand.Parameters.AddRange(oracleParameters.ToArray());
+                }
+            }
+            catch (Exception ex)
+            {
+                log.Error(ex);
+                throw ex;
+            }
+
+        }
+
+    }
+}

+ 41 - 0
SuperCms/Program.cs

@@ -0,0 +1,41 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Reflection;
+using System.Threading.Tasks;
+using System.Xml;
+using Microsoft.AspNetCore.Hosting;
+using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.Hosting;
+using Microsoft.Extensions.Logging;
+
+namespace SuperCms
+{
+    public class Program
+    {
+        private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof(Program));
+
+        public static void Main(string[] args)
+        {
+            XmlDocument log4netConfig = new XmlDocument();
+            log4netConfig.Load(File.OpenRead("log4net.config"));
+
+            var repo = log4net.LogManager.CreateRepository(
+                Assembly.GetEntryAssembly(), typeof(log4net.Repository.Hierarchy.Hierarchy));
+
+            log4net.Config.XmlConfigurator.Configure(repo, log4netConfig["log4net"]);
+
+            log.Info("Application - Main is invoked");
+
+            CreateHostBuilder(args).Build().Run();
+        }
+
+        public static IHostBuilder CreateHostBuilder(string[] args) =>
+            Host.CreateDefaultBuilder(args)
+                .ConfigureWebHostDefaults(webBuilder =>
+                {
+                    webBuilder.UseStartup<Startup>();
+                });
+    }
+}

+ 27 - 0
SuperCms/Properties/launchSettings.json

@@ -0,0 +1,27 @@
+{
+  "iisSettings": {
+    "windowsAuthentication": false,
+    "anonymousAuthentication": true,
+    "iisExpress": {
+      "applicationUrl": "http://localhost:62173",
+      "sslPort": 44365
+    }
+  },
+  "profiles": {
+    "IIS Express": {
+      "commandName": "IISExpress",
+      "launchBrowser": true,
+      "environmentVariables": {
+        "ASPNETCORE_ENVIRONMENT": "Development"
+      }
+    },
+    "SuperCms": {
+      "commandName": "Project",
+      "launchBrowser": true,
+      "applicationUrl": "https://localhost:5001;http://localhost:5000",
+      "environmentVariables": {
+        "ASPNETCORE_ENVIRONMENT": "Development"
+      }
+    }
+  }
+}

+ 45 - 0
SuperCms/Repositories/ISuperCmsRepo.cs

@@ -0,0 +1,45 @@
+using Dapper;
+using Microsoft.Extensions.Configuration;
+using Oracle.ManagedDataAccess.Client;
+using SuperCms.Models;
+using SuperCms.Oracle;
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace SuperCms.Repositories
+{
+    public interface ISuperCmsRepo
+    {
+        object GetConnConfig(log4net.ILog log);
+        object GetConnTelco(log4net.ILog log);
+        object GetConnData(log4net.ILog log, String fromDate, String toDate);
+        object GetConnCompany(log4net.ILog log);
+        object GetConnDataByService(log4net.ILog log, String serviceID, String fromDate, String toDate);
+        object GetAllBots(log4net.ILog log);
+        object GetAllGroups(log4net.ILog log);
+        object GetAllConfigs(log4net.ILog log);
+        object GetScheduleByRow(log4net.ILog log, String seqPage, String rowsOnPage);
+        object GetTotalRow(log4net.ILog log, String type);
+        object AddingBotStructure(log4net.ILog log, BotStructure bot);
+        object AddingGroupStructure(log4net.ILog log, GroupStructure group);
+        object AddingScheduleStructure(log4net.ILog log, ScheduleStructure schedule);
+        object AddingConfig(log4net.ILog log, Config config);
+        object EditingBotStructure(log4net.ILog log, BotStructure bot);
+        object EditingGroupStructure(log4net.ILog log, GroupStructure group);
+        object EditingScheduleStructure(log4net.ILog log, ScheduleStructure schedule);
+        object EditingConfig(log4net.ILog log, Config config);
+
+        object GetAllSendMails(log4net.ILog log);
+        object AddingSendMail(log4net.ILog log, SendMail mail);
+        object EditingSendMail(log4net.ILog log, SendMail mail);
+        object DeleteStructure(log4net.ILog log, String tableType, String id);
+
+        object AddConnConfig(log4net.ILog log, ConnConfig connConfig);
+        object EditConnConfig(log4net.ILog log, ConnConfig connConfig);
+        object Login(log4net.ILog log, String account, String password);
+
+    }
+}

+ 959 - 0
SuperCms/Repositories/SuperCmsRepo.cs

@@ -0,0 +1,959 @@
+using Dapper;
+using Microsoft.Extensions.Configuration;
+using Oracle.ManagedDataAccess.Client;
+using SuperCms.Oracle;
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Linq;
+using System.Threading.Tasks;
+using SuperCms.Controllers;
+using SuperCms.Models;
+
+namespace SuperCms.Repositories
+{
+    public class SuperCmsRepo : ISuperCmsRepo
+    {
+        IConfiguration configuration;
+        public SuperCmsRepo(IConfiguration _configuration)
+        {
+            configuration = _configuration;
+        }
+        public IDbConnection GetConnection()
+        {
+            var connectionString = configuration.GetSection("Connection").Value;
+            var conn = new OracleConnection(connectionString);
+            return conn;
+        }
+
+        public object GetConnData(log4net.ILog log, String fromDate, String toDate)
+        {
+            object result = null;
+            var conn = this.GetConnection();
+            try
+            {
+                var dyParam = new OracleDynamicParameters();
+                dyParam.Add("sc_fromdate", OracleDbType.NVarchar2, ParameterDirection.Input, fromDate);
+                dyParam.Add("sc_todate", OracleDbType.NVarchar2, ParameterDirection.Input, toDate);
+                dyParam.Add("sc_cursor", OracleDbType.RefCursor, ParameterDirection.Output);
+
+                if (conn.State == ConnectionState.Closed)
+                {
+                    conn.Open();
+                }
+
+                if (conn.State == ConnectionState.Open)
+                {
+                    var query = "GETCONNDATA";
+                    result = SqlMapper.Query(conn, query, param: dyParam, commandType: CommandType.StoredProcedure);
+                }
+            }
+            catch (Exception ex)
+            {
+                log.Error("Exception: ", ex);
+                throw ex;
+            }
+            finally
+            {
+                conn.Close();
+                conn.Dispose();
+            }
+            return result;
+        }
+
+        public object GetConnDataByService(log4net.ILog log, string serviceID, string fromDate, string toDate)
+        {
+            object result = null;
+            var conn = this.GetConnection();
+            try
+            {
+                var dyParam = new OracleDynamicParameters();
+                dyParam.Add("sc_fromdate", OracleDbType.NVarchar2, ParameterDirection.Input, fromDate);
+                dyParam.Add("sc_todate", OracleDbType.NVarchar2, ParameterDirection.Input, toDate);
+                dyParam.Add("sc_serviceid", OracleDbType.Int32, ParameterDirection.Input, serviceID);
+                dyParam.Add("sc_cursor", OracleDbType.RefCursor, ParameterDirection.Output);
+
+                if (conn.State == ConnectionState.Closed)
+                {
+                    conn.Open();
+                }
+
+                if (conn.State == ConnectionState.Open)
+                {
+                    var query = "GETCONNDATABYSERVICE";
+                    result = SqlMapper.Query(conn, query, param: dyParam, commandType: CommandType.StoredProcedure);
+                }
+            }
+            catch (Exception ex)
+            {
+                log.Error("Exception: ", ex);
+
+                throw ex;
+            }
+            finally
+            {
+                conn.Close();
+                conn.Dispose();
+            }
+            return result;
+        }
+
+        public object GetConnConfig(log4net.ILog log)
+        {
+            object result = null;
+            var conn = this.GetConnection();
+            try
+            {
+                var dyParam = new OracleDynamicParameters();
+                dyParam.Add("sc_cursor", OracleDbType.RefCursor, ParameterDirection.Output);
+
+                if (conn.State == ConnectionState.Closed)
+                {
+                    conn.Open();
+                }
+
+                if (conn.State == ConnectionState.Open)
+                {
+                    var query = "GETCONNCONFIG";
+                    result = SqlMapper.Query(conn, query, param: dyParam, commandType: CommandType.StoredProcedure);
+                }
+            }
+            catch (Exception ex)
+            {
+                log.Error("Exception: ", ex);
+                throw ex;
+            }
+            finally
+            {
+                conn.Close();
+                conn.Dispose();
+            }
+            return result;
+        }
+
+        public object GetConnTelco(log4net.ILog log)
+        {
+            object result = null;
+            var conn = this.GetConnection();
+            try
+            {
+                var dyParam = new OracleDynamicParameters();
+                dyParam.Add("sc_cursor", OracleDbType.RefCursor, ParameterDirection.Output);
+
+                if (conn.State == ConnectionState.Closed)
+                {
+                    conn.Open();
+                }
+
+                if (conn.State == ConnectionState.Open)
+                {
+                    var query = "GETCONNTELCO";
+                    result = SqlMapper.Query(conn, query, param: dyParam, commandType: CommandType.StoredProcedure);
+                }
+            }
+            catch (Exception ex)
+            {
+                log.Error("Exception: ", ex);
+                throw ex;
+            }
+            finally
+            {
+                conn.Close();
+                conn.Dispose();
+            }
+            return result;
+        }
+
+        public object GetConnCompany(log4net.ILog log)
+        {
+            object result = null;
+            var conn = this.GetConnection();
+            try
+            {
+                var dyParam = new OracleDynamicParameters();
+                dyParam.Add("sc_cursor", OracleDbType.RefCursor, ParameterDirection.Output);
+
+                if (conn.State == ConnectionState.Closed)
+                {
+                    conn.Open();
+                }
+
+                if (conn.State == ConnectionState.Open)
+                {
+                    var query = "GETCONNCOMPANY";
+                    result = SqlMapper.Query(conn, query, param: dyParam, commandType: CommandType.StoredProcedure);
+                }
+            }
+            catch (Exception ex)
+            {
+                log.Error("Exception: ", ex);
+                throw ex;
+            }
+            finally
+            {
+                conn.Close();
+                conn.Dispose();
+            }
+            return result;
+        }
+
+        public object GetAllBots(log4net.ILog log)
+        {
+            object result = null;
+            var conn = this.GetConnection();
+            try
+            {
+                var dyParam = new OracleDynamicParameters();
+                dyParam.Add("sc_cursor", OracleDbType.RefCursor, ParameterDirection.Output);
+
+                if (conn.State == ConnectionState.Closed)
+                {
+                    conn.Open();
+                }
+
+                if (conn.State == ConnectionState.Open)
+                {
+                    var query = "GETALLBOTS";
+                    result = SqlMapper.Query(conn, query, param: dyParam, commandType: CommandType.StoredProcedure);
+                }
+            }
+            catch (Exception ex)
+            {
+                log.Error("Exception: ", ex);
+                throw ex;
+            }
+            finally
+            {
+                conn.Close();
+                conn.Dispose();
+            }
+            return result;
+        }
+
+        public object GetAllGroups(log4net.ILog log)
+        {
+            object result = null;
+            var conn = this.GetConnection();
+            try
+            {
+                var dyParam = new OracleDynamicParameters();
+                dyParam.Add("sc_cursor", OracleDbType.RefCursor, ParameterDirection.Output);
+
+                if (conn.State == ConnectionState.Closed)
+                {
+                    conn.Open();
+                }
+
+                if (conn.State == ConnectionState.Open)
+                {
+                    var query = "GETALLGROUPS";
+                    result = SqlMapper.Query(conn, query, param: dyParam, commandType: CommandType.StoredProcedure);
+                }
+            }
+            catch (Exception ex)
+            {
+                log.Error("Exception: ", ex);
+                throw ex;
+            }
+            finally
+            {
+                conn.Close();
+                conn.Dispose();
+            }
+            return result;
+        }
+
+        public object GetScheduleByRow(log4net.ILog log, string seqPage, string rowsOnPage)
+        {
+            object result = null;
+            var conn = this.GetConnection();
+            try
+            {
+                var dyParam = new OracleDynamicParameters();
+                dyParam.Add("sc_seqpage", OracleDbType.Int32, ParameterDirection.Input, seqPage);
+                dyParam.Add("sc_rowsonpage", OracleDbType.Int32, ParameterDirection.Input, rowsOnPage);
+                dyParam.Add("sc_cursor", OracleDbType.RefCursor, ParameterDirection.Output);
+
+                if (conn.State == ConnectionState.Closed)
+                {
+                    conn.Open();
+                }
+
+                if (conn.State == ConnectionState.Open)
+                {
+                    var query = "GETSCHEDULEBYROW";
+                    result = SqlMapper.Query(conn, query, param: dyParam, commandType: CommandType.StoredProcedure);
+                }
+            }
+            catch (Exception ex)
+            {
+                log.Error("Exception: ", ex);
+                throw ex;
+            }
+            finally
+            {
+                conn.Close();
+                conn.Dispose();
+            }
+            return result;
+        }
+
+        public object GetTotalRow(log4net.ILog log, string type)
+        {
+            object result = null;
+            var conn = this.GetConnection();
+            try
+            {
+                var dyParam = new OracleDynamicParameters();
+                dyParam.Add("sc_cursor", OracleDbType.RefCursor, ParameterDirection.Output);
+
+                if (conn.State == ConnectionState.Closed)
+                {
+                    conn.Open();
+                }
+
+                if (conn.State == ConnectionState.Open)
+                {
+                    var query = type == UtilsController.Constant.BOTS ? "GETBOTTOTALROW" :
+                       type == UtilsController.Constant.GROUPS ? "GETGROUPTOTALROW" :
+                       "GETSCHEDULETOTALROW";
+                    result = SqlMapper.Query(conn, query, param: dyParam, commandType: CommandType.StoredProcedure);
+                }
+            }
+            catch (Exception ex)
+            {
+                log.Error("Exception: ", ex);
+                throw ex;
+            }
+            finally
+            {
+                conn.Close();
+                conn.Dispose();
+            }
+            return result;
+        }
+
+        public object AddingBotStructure(log4net.ILog log, BotStructure bot)
+        {
+            object result = null;
+            var conn = this.GetConnection();
+            try
+            {
+                var dyParam = new OracleDynamicParameters();
+                dyParam.Add("sc_name", OracleDbType.NVarchar2, ParameterDirection.Input, bot.name);
+                dyParam.Add("sc_description", OracleDbType.NClob, ParameterDirection.Input, bot.description);
+                dyParam.Add("sc_status", OracleDbType.Int32, ParameterDirection.Input, bot.status);
+                dyParam.Add("sc_startdate", OracleDbType.NVarchar2, ParameterDirection.Input, bot.startDate);
+                dyParam.Add("sc_enddate", OracleDbType.NVarchar2, ParameterDirection.Input, bot.endDate);
+                dyParam.Add("sc_cursor", OracleDbType.RefCursor, ParameterDirection.Output);
+
+                if (conn.State == ConnectionState.Closed)
+                {
+                    conn.Open();
+                }
+
+                if (conn.State == ConnectionState.Open)
+                {
+                    var query = "ADDINGBOTSTRUCTURE";
+                    result = SqlMapper.Query(conn, query, param: dyParam, commandType: CommandType.StoredProcedure);
+                }
+            }
+            catch (Exception ex)
+            {
+                log.Error("Exception: ", ex);
+                throw ex;
+            }
+            finally
+            {
+                conn.Close();
+                conn.Dispose();
+            }
+            return result;
+        }
+
+        public object AddingGroupStructure(log4net.ILog log, GroupStructure group)
+        {
+            object result = null;
+            var conn = this.GetConnection();
+            try
+            {
+                var dyParam = new OracleDynamicParameters();
+                dyParam.Add("sc_name", OracleDbType.NVarchar2, ParameterDirection.Input, group.name);
+                dyParam.Add("sc_description", OracleDbType.NClob, ParameterDirection.Input, group.description);
+                dyParam.Add("sc_status", OracleDbType.Int32, ParameterDirection.Input, group.status);
+                dyParam.Add("sc_startDate", OracleDbType.NVarchar2, ParameterDirection.Input, group.startDate);
+                dyParam.Add("sc_enddate", OracleDbType.NVarchar2, ParameterDirection.Input, group.endDate);
+                dyParam.Add("sc_cursor", OracleDbType.RefCursor, ParameterDirection.Output);
+
+                if (conn.State == ConnectionState.Closed)
+                {
+                    conn.Open();
+                }
+
+                if (conn.State == ConnectionState.Open)
+                {
+                    var query = "ADDINGGROUPSTRUCTURE";
+                    result = SqlMapper.Query(conn, query, param: dyParam, commandType: CommandType.StoredProcedure);
+                }
+            }
+            catch (Exception ex)
+            {
+                log.Error("Exception: ", ex);
+                throw ex;
+            }
+            finally
+            {
+                conn.Close();
+                conn.Dispose();
+            }
+            return result;
+        }
+
+        public object AddingScheduleStructure(log4net.ILog log, ScheduleStructure schedule)
+        {
+            object result = null;
+            var conn = this.GetConnection();
+            try
+            {
+                var dyParam = new OracleDynamicParameters();
+                dyParam.Add("sc_botid", OracleDbType.Int32, ParameterDirection.Input, schedule.botID);
+                dyParam.Add("sc_groupid", OracleDbType.Int32, ParameterDirection.Input, schedule.groupID);
+                dyParam.Add("sc_name", OracleDbType.NVarchar2, ParameterDirection.Input, schedule.name);
+                dyParam.Add("sc_description", OracleDbType.NClob, ParameterDirection.Input, schedule.description);
+                dyParam.Add("sc_status", OracleDbType.Int32, ParameterDirection.Input, schedule.status);
+                dyParam.Add("sc_timerun", OracleDbType.NVarchar2, ParameterDirection.Input, schedule.timeRun);
+                dyParam.Add("sc_content", OracleDbType.NClob, ParameterDirection.Input, schedule.content);
+                dyParam.Add("sc_note", OracleDbType.NClob, ParameterDirection.Input, schedule.note);
+                dyParam.Add("sc_cursor", OracleDbType.RefCursor, ParameterDirection.Output);
+
+                if (conn.State == ConnectionState.Closed)
+                {
+                    conn.Open();
+                }
+
+                if (conn.State == ConnectionState.Open)
+                {
+                    var query = "ADDINGSCHEDULESTRUCTURE";
+                    result = SqlMapper.Query(conn, query, param: dyParam, commandType: CommandType.StoredProcedure);
+                }
+            }
+            catch (Exception ex)
+            {
+                log.Error("Exception: ", ex);
+                throw ex;
+            }
+            finally
+            {
+                conn.Close();
+                conn.Dispose();
+            }
+            return result;
+        }
+
+        public object EditingBotStructure(log4net.ILog log, BotStructure bot)
+        {
+            object result = null;
+            var conn = this.GetConnection();
+            try
+            {
+                var dyParam = new OracleDynamicParameters();
+                dyParam.Add("sc_id", OracleDbType.Int32, ParameterDirection.Input, bot.id);
+                dyParam.Add("sc_name", OracleDbType.NVarchar2, ParameterDirection.Input, bot.name);
+                dyParam.Add("sc_description", OracleDbType.NClob, ParameterDirection.Input, bot.description);
+                dyParam.Add("sc_status", OracleDbType.Int32, ParameterDirection.Input, bot.status);
+                dyParam.Add("sc_startdate", OracleDbType.NVarchar2, ParameterDirection.Input, bot.startDate);
+                dyParam.Add("sc_enddate", OracleDbType.NVarchar2, ParameterDirection.Input, bot.endDate);
+                dyParam.Add("sc_cursor", OracleDbType.RefCursor, ParameterDirection.Output);
+
+                if (conn.State == ConnectionState.Closed)
+                {
+                    conn.Open();
+                }
+
+                if (conn.State == ConnectionState.Open)
+                {
+                    var query = "EDITINGBOTSTRUCTURE";
+                    result = SqlMapper.Query(conn, query, param: dyParam, commandType: CommandType.StoredProcedure);
+                }
+            }
+            catch (Exception ex)
+            {
+                log.Error("Exception: ", ex);
+                throw ex;
+            }
+            finally
+            {
+                conn.Close();
+                conn.Dispose();
+            }
+            return result;
+        }
+
+        public object EditingGroupStructure(log4net.ILog log, GroupStructure group)
+        {
+            object result = null;
+            var conn = this.GetConnection();
+            try
+            {
+                var dyParam = new OracleDynamicParameters();
+                dyParam.Add("sc_id", OracleDbType.Int32, ParameterDirection.Input, group.id);
+                dyParam.Add("sc_name", OracleDbType.NVarchar2, ParameterDirection.Input, group.name);
+                dyParam.Add("sc_description", OracleDbType.NClob, ParameterDirection.Input, group.description);
+                dyParam.Add("sc_status", OracleDbType.Int32, ParameterDirection.Input, group.status);
+                dyParam.Add("sc_startdate", OracleDbType.NVarchar2, ParameterDirection.Input, group.startDate);
+                dyParam.Add("sc_enddate", OracleDbType.NVarchar2, ParameterDirection.Input, group.endDate);
+                dyParam.Add("sc_cursor", OracleDbType.RefCursor, ParameterDirection.Output);
+
+                if (conn.State == ConnectionState.Closed)
+                {
+                    conn.Open();
+                }
+
+                if (conn.State == ConnectionState.Open)
+                {
+                    var query = "EDITINGGROUPSTRUCTURE";
+                    result = SqlMapper.Query(conn, query, param: dyParam, commandType: CommandType.StoredProcedure);
+                }
+            }
+            catch (Exception ex)
+            {
+                log.Error("Exception: ", ex);
+                throw ex;
+            }
+            finally
+            {
+                conn.Close();
+                conn.Dispose();
+            }
+            return result;
+        }
+
+        public object EditingScheduleStructure(log4net.ILog log, ScheduleStructure schedule)
+        {
+            object result = null;
+            var conn = this.GetConnection();
+            try
+            {
+                var dyParam = new OracleDynamicParameters();
+                dyParam.Add("sc_id", OracleDbType.Int32, ParameterDirection.Input, schedule.id);
+                dyParam.Add("sc_botid", OracleDbType.Int32, ParameterDirection.Input, schedule.botID);
+                dyParam.Add("sc_groupid", OracleDbType.Int32, ParameterDirection.Input, schedule.groupID);
+                dyParam.Add("sc_name", OracleDbType.NVarchar2, ParameterDirection.Input, schedule.name);
+                dyParam.Add("sc_description", OracleDbType.NClob, ParameterDirection.Input, schedule.description);
+                dyParam.Add("sc_status", OracleDbType.Int32, ParameterDirection.Input, schedule.status);
+                dyParam.Add("sc_timerun", OracleDbType.NVarchar2, ParameterDirection.Input, schedule.timeRun);
+                dyParam.Add("sc_content", OracleDbType.NClob, ParameterDirection.Input, schedule.content);
+                dyParam.Add("sc_note", OracleDbType.NClob, ParameterDirection.Input, schedule.note);
+                dyParam.Add("sc_cursor", OracleDbType.RefCursor, ParameterDirection.Output);
+
+                if (conn.State == ConnectionState.Closed)
+                {
+                    conn.Open();
+                }
+
+                if (conn.State == ConnectionState.Open)
+                {
+                    var query = "EDITINGSCHEDULESTRUCTURE";
+                    result = SqlMapper.Query(conn, query, param: dyParam, commandType: CommandType.StoredProcedure);
+                }
+            }
+            catch (Exception ex)
+            {
+                log.Error("Exception: ", ex);
+                throw ex;
+            }
+            finally
+            {
+                conn.Close();
+                conn.Dispose();
+            }
+            return result;
+        }
+
+        public object DeleteStructure(log4net.ILog log, string tableType, string id)
+        {
+            object result = null;
+            var conn = this.GetConnection();
+            try
+            {
+                var dyParam = new OracleDynamicParameters();
+                dyParam.Add("sc_id", OracleDbType.Int32, ParameterDirection.Input, id);
+                dyParam.Add("sc_cursor", OracleDbType.RefCursor, ParameterDirection.Output);
+
+                if (conn.State == ConnectionState.Closed)
+                {
+                    conn.Open();
+                }
+
+                if (conn.State == ConnectionState.Open)
+                {
+                    var query = tableType == UtilsController.Constant.BOTS ? "DELETEBOTSTRUCTURE" :
+                       tableType == UtilsController.Constant.GROUPS ? "DELETEGROUPSTRUCTURE" :
+                       tableType == UtilsController.Constant.SCHEDULES ? "DELETESCHEDULESTRUCTURE" :
+                       tableType == UtilsController.Constant.CONFIGS ? "DELETECONFIG" :
+                       tableType == UtilsController.Constant.SERVICE_CONFIG ? "DELETECONNCONFIG" :
+                       "DELETESENDMAIL";
+                    result = SqlMapper.Query(conn, query, param: dyParam, commandType: CommandType.StoredProcedure);
+                }
+            }
+            catch (Exception ex)
+            {
+                log.Error("Exception: ", ex);
+                throw ex;
+            }
+            finally
+            {
+                conn.Close();
+                conn.Dispose();
+            }
+            return result;
+        }
+
+        public object Login(log4net.ILog log, string account, string password)
+        {
+            object result = null;
+            var conn = this.GetConnection();
+            try
+            {
+                var dyParam = new OracleDynamicParameters();
+                dyParam.Add("sc_account", OracleDbType.NVarchar2, ParameterDirection.Input, account);
+                dyParam.Add("sc_password", OracleDbType.NVarchar2, ParameterDirection.Input, password);
+                dyParam.Add("sc_cursor", OracleDbType.RefCursor, ParameterDirection.Output);
+
+                if (conn.State == ConnectionState.Closed)
+                {
+                    conn.Open();
+                }
+
+                if (conn.State == ConnectionState.Open)
+                {
+                    var query = "ADMINLOGIN";
+                    result = SqlMapper.Query(conn, query, param: dyParam, commandType: CommandType.StoredProcedure);
+                }
+            }
+            catch (Exception ex)
+            {
+                log.Error("Exception: ", ex);
+                throw ex;
+            }
+            finally
+            {
+                conn.Close();
+                conn.Dispose();
+            }
+            return result;
+        }
+
+        public object GetAllConfigs(log4net.ILog log)
+        {
+            object result = null;
+            var conn = this.GetConnection();
+            try
+            {
+                var dyParam = new OracleDynamicParameters();
+                dyParam.Add("sc_cursor", OracleDbType.RefCursor, ParameterDirection.Output);
+
+                if (conn.State == ConnectionState.Closed)
+                {
+                    conn.Open();
+                }
+
+                if (conn.State == ConnectionState.Open)
+                {
+                    var query = "GETALLCONFIGS";
+                    result = SqlMapper.Query(conn, query, param: dyParam, commandType: CommandType.StoredProcedure);
+                }
+            }
+            catch (Exception ex)
+            {
+                log.Error("Exception: ", ex);
+                throw ex;
+            }
+            finally
+            {
+                conn.Close();
+                conn.Dispose();
+            }
+            return result;
+        }
+
+        public object AddingConfig(log4net.ILog log, Config config)
+        {
+            object result = null;
+            var conn = this.GetConnection();
+            try
+            {
+                var dyParam = new OracleDynamicParameters();
+                dyParam.Add("sc_key", OracleDbType.NVarchar2, ParameterDirection.Input, config.key);
+                dyParam.Add("sc_value", OracleDbType.NVarchar2, ParameterDirection.Input, config.value);
+                dyParam.Add("sc_cursor", OracleDbType.RefCursor, ParameterDirection.Output);
+
+                if (conn.State == ConnectionState.Closed)
+                {
+                    conn.Open();
+                }
+
+                if (conn.State == ConnectionState.Open)
+                {
+                    var query = "ADDINGCONFIG";
+                    result = SqlMapper.Query(conn, query, param: dyParam, commandType: CommandType.StoredProcedure);
+                }
+            }
+            catch (Exception ex)
+            {
+                log.Error("Exception: ", ex);
+                throw ex;
+            }
+            finally
+            {
+                conn.Close();
+                conn.Dispose();
+            }
+            return result;
+        }
+
+        public object EditingConfig(log4net.ILog log, Config config)
+        {
+            object result = null;
+            var conn = this.GetConnection();
+            try
+            {
+                var dyParam = new OracleDynamicParameters();
+                dyParam.Add("sc_id", OracleDbType.Int32, ParameterDirection.Input, config.id);
+                dyParam.Add("sc_key", OracleDbType.NVarchar2, ParameterDirection.Input, config.key);
+                dyParam.Add("sc_value", OracleDbType.NVarchar2, ParameterDirection.Input, config.value);
+                dyParam.Add("sc_cursor", OracleDbType.RefCursor, ParameterDirection.Output);
+
+                if (conn.State == ConnectionState.Closed)
+                {
+                    conn.Open();
+                }
+
+                if (conn.State == ConnectionState.Open)
+                {
+                    var query = "EDITINGCONFIG";
+                    result = SqlMapper.Query(conn, query, param: dyParam, commandType: CommandType.StoredProcedure);
+                }
+            }
+            catch (Exception ex)
+            {
+                log.Error("Exception: ", ex);
+                throw ex;
+            }
+            finally
+            {
+                conn.Close();
+                conn.Dispose();
+            }
+            return result;
+        }
+
+        public object GetAllSendMails(log4net.ILog log)
+        {
+            object result = null;
+            var conn = this.GetConnection();
+            try
+            {
+                var dyParam = new OracleDynamicParameters();
+                dyParam.Add("sc_cursor", OracleDbType.RefCursor, ParameterDirection.Output);
+
+                if (conn.State == ConnectionState.Closed)
+                {
+                    conn.Open();
+                }
+
+                if (conn.State == ConnectionState.Open)
+                {
+                    var query = "GETSENDMAIL";
+                    result = SqlMapper.Query(conn, query, param: dyParam, commandType: CommandType.StoredProcedure);
+                }
+            }
+            catch (Exception ex)
+            {
+                log.Error("Exception: ", ex);
+                throw ex;
+            }
+            finally
+            {
+                conn.Close();
+                conn.Dispose();
+            }
+            return result;
+        }
+
+        public object AddingSendMail(log4net.ILog log, SendMail mail)
+        {
+            object result = null;
+            var conn = this.GetConnection();
+            try
+            {
+                var dyParam = new OracleDynamicParameters();
+                dyParam.Add("sc_telcoid", OracleDbType.Int32, ParameterDirection.Input, mail.telcoId);
+                dyParam.Add("sc_companyid", OracleDbType.Int32, ParameterDirection.Input, mail.companyId);
+                dyParam.Add("sc_serviceid", OracleDbType.Int32, ParameterDirection.Input, mail.serviceId);
+                dyParam.Add("sc_listmail", OracleDbType.NClob, ParameterDirection.Input, mail.listMail);
+                dyParam.Add("sc_message", OracleDbType.NClob, ParameterDirection.Input, mail.message);
+                dyParam.Add("sc_timesend", OracleDbType.NVarchar2, ParameterDirection.Input, mail.timeSend);
+                dyParam.Add("sc_status", OracleDbType.Int32, ParameterDirection.Input, mail.status);
+                dyParam.Add("sc_cursor", OracleDbType.RefCursor, ParameterDirection.Output);
+
+                if (conn.State == ConnectionState.Closed)
+                {
+                    conn.Open();
+                }
+
+                if (conn.State == ConnectionState.Open)
+                {
+                    var query = "ADDINGSENDMAIL";
+                    result = SqlMapper.Query(conn, query, param: dyParam, commandType: CommandType.StoredProcedure);
+                }
+            }
+            catch (Exception ex)
+            {
+                log.Error("Exception: ", ex);
+                throw ex;
+            }
+            finally
+            {
+                conn.Close();
+                conn.Dispose();
+            }
+            return result;
+        }
+
+        public object EditingSendMail(log4net.ILog log, SendMail mail)
+        {
+            object result = null;
+            var conn = this.GetConnection();
+            try
+            {
+                var dyParam = new OracleDynamicParameters();
+                dyParam.Add("sc_id", OracleDbType.Int32, ParameterDirection.Input, mail.id);
+                dyParam.Add("sc_telcoid", OracleDbType.Int32, ParameterDirection.Input, mail.telcoId);
+                dyParam.Add("sc_companyid", OracleDbType.Int32, ParameterDirection.Input, mail.companyId);
+                dyParam.Add("sc_serviceid", OracleDbType.Int32, ParameterDirection.Input, mail.serviceId);
+                dyParam.Add("sc_listmail", OracleDbType.NClob, ParameterDirection.Input, mail.listMail);
+                dyParam.Add("sc_message", OracleDbType.NClob, ParameterDirection.Input, mail.message);
+                dyParam.Add("sc_timesend", OracleDbType.NVarchar2, ParameterDirection.Input, mail.timeSend);
+                dyParam.Add("sc_status", OracleDbType.Int32, ParameterDirection.Input, mail.status);
+                dyParam.Add("sc_cursor", OracleDbType.RefCursor, ParameterDirection.Output);
+
+                if (conn.State == ConnectionState.Closed)
+                {
+                    conn.Open();
+                }
+
+                if (conn.State == ConnectionState.Open)
+                {
+                    var query = "EDITINGSENDMAIL";
+                    result = SqlMapper.Query(conn, query, param: dyParam, commandType: CommandType.StoredProcedure);
+                }
+            }
+            catch (Exception ex)
+            {
+                log.Error("Exception: ", ex);
+                throw ex;
+            }
+            finally
+            {
+                conn.Close();
+                conn.Dispose();
+            }
+            return result;
+        }
+
+        public object AddConnConfig(log4net.ILog log, ConnConfig connConfig)
+        {
+            object result = null;
+            var conn = this.GetConnection();
+            try
+            {
+                var dyParam = new OracleDynamicParameters();
+                dyParam.Add("sc_telcoid", OracleDbType.NVarchar2, ParameterDirection.Input, connConfig.telcoID);
+                dyParam.Add("sc_companyid", OracleDbType.NVarchar2, ParameterDirection.Input, connConfig.companyID);
+
+                dyParam.Add("sc_servicename", OracleDbType.NVarchar2, ParameterDirection.Input, connConfig.serviceName);
+                dyParam.Add("sc_url", OracleDbType.NVarchar2, ParameterDirection.Input, connConfig.url);
+                dyParam.Add("sc_vsql", OracleDbType.NVarchar2, ParameterDirection.Input, connConfig.vSql);
+                dyParam.Add("sc_connection", OracleDbType.NVarchar2, ParameterDirection.Input, connConfig.connection);
+                dyParam.Add("sc_daterun", OracleDbType.NVarchar2, ParameterDirection.Input, connConfig.dateRun);
+                dyParam.Add("sc_dateget", OracleDbType.NVarchar2, ParameterDirection.Input, connConfig.dateGet);
+                dyParam.Add("sc_hourrun", OracleDbType.NVarchar2, ParameterDirection.Input, connConfig.hourRun);
+                dyParam.Add("sc_telco", OracleDbType.NVarchar2, ParameterDirection.Input, connConfig.telco);
+                dyParam.Add("sc_status", OracleDbType.NVarchar2, ParameterDirection.Input, connConfig.status);
+                dyParam.Add("sc_state", OracleDbType.NVarchar2, ParameterDirection.Input, connConfig.state);
+                dyParam.Add("sc_money", OracleDbType.NVarchar2, ParameterDirection.Input, connConfig.money);
+
+                dyParam.Add("sc_cursor", OracleDbType.RefCursor, ParameterDirection.Output);
+
+                if (conn.State == ConnectionState.Closed)
+                {
+                    conn.Open();
+                }
+
+                if (conn.State == ConnectionState.Open)
+                {
+                    var query = "ADDINGCONNCONFIG";
+                    result = SqlMapper.Query(conn, query, param: dyParam, commandType: CommandType.StoredProcedure);
+                }
+            }
+            catch (Exception ex)
+            {
+                log.Error("Exception: ", ex);
+                throw ex;
+            }
+            finally
+            {
+                conn.Close();
+                conn.Dispose();
+            }
+            return result;
+        }
+
+        public object EditConnConfig(log4net.ILog log, ConnConfig connConfig)
+        {
+            object result = null;
+            var conn = this.GetConnection();
+            try
+            {
+                var dyParam = new OracleDynamicParameters();
+                dyParam.Add("sc_id", OracleDbType.NVarchar2, ParameterDirection.Input, connConfig.id);
+                dyParam.Add("sc_servicename", OracleDbType.NVarchar2, ParameterDirection.Input, connConfig.serviceName);
+                dyParam.Add("sc_url", OracleDbType.NVarchar2, ParameterDirection.Input, connConfig.url);
+                dyParam.Add("sc_vsql", OracleDbType.NVarchar2, ParameterDirection.Input, connConfig.vSql);
+                dyParam.Add("sc_connection", OracleDbType.NVarchar2, ParameterDirection.Input, connConfig.connection);
+                dyParam.Add("sc_telcoid", OracleDbType.NVarchar2, ParameterDirection.Input, connConfig.telcoID);
+                dyParam.Add("sc_companyid", OracleDbType.NVarchar2, ParameterDirection.Input, connConfig.companyID);
+                dyParam.Add("sc_hourrun", OracleDbType.NVarchar2, ParameterDirection.Input, connConfig.hourRun);
+                dyParam.Add("sc_telco", OracleDbType.NVarchar2, ParameterDirection.Input, connConfig.telco);
+                dyParam.Add("sc_status", OracleDbType.NVarchar2, ParameterDirection.Input, connConfig.status);
+                dyParam.Add("sc_state", OracleDbType.NVarchar2, ParameterDirection.Input, connConfig.state);
+                dyParam.Add("sc_money", OracleDbType.NVarchar2, ParameterDirection.Input, connConfig.money);
+
+                dyParam.Add("sc_cursor", OracleDbType.RefCursor, ParameterDirection.Output);
+
+                if (conn.State == ConnectionState.Closed)
+                {
+                    conn.Open();
+                }
+
+                if (conn.State == ConnectionState.Open)
+                {
+                    var query = "EDITINGCONNCONFIG";
+                    result = SqlMapper.Query(conn, query, param: dyParam, commandType: CommandType.StoredProcedure);
+                }
+            }
+            catch (Exception ex)
+            {
+                log.Error("Exception: ", ex);
+                throw ex;
+            }
+            finally
+            {
+                conn.Close();
+                conn.Dispose();
+            }
+            return result;
+        }
+    }
+}

binární
SuperCms/Resources/ITL.jpg


binární
SuperCms/Resources/Mountain-200.jpg


binární
SuperCms/Resources/Mountain-300.jpg


binární
SuperCms/Resources/PAYMENT REQUEST ALL.docx


binární
SuperCms/Resources/Sample.docx


binární
SuperCms/Resources/gts.jpg


binární
SuperCms/Resources/payment - Copy.docx


binární
SuperCms/Resources/payment.docx


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 12 - 0
SuperCms/Resources/payment.html


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 12 - 0
SuperCms/Resources/payment_EQUIZZ_07_07_2021.html


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 12 - 0
SuperCms/Resources/payment_FORTUNE_07_07_2021.html


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 12 - 0
SuperCms/Resources/payment_GAME PORTAL_07_07_2021.html


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 12 - 0
SuperCms/Resources/payment_HAPPY CALL_07_07_2021.html


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 12 - 0
SuperCms/Resources/payment_HOROSCOPE_07_07_2021.html


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 12 - 0
SuperCms/Resources/payment_KARA_07_07_2021.html


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 12 - 0
SuperCms/Resources/payment_LUCKY CARD_07_07_2021.html


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 12 - 0
SuperCms/Resources/payment_LUCKY DRAW_07_07_2021.html


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 12 - 0
SuperCms/Resources/payment_MYCUPID_07_07_2021.html


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 12 - 0
SuperCms/Resources/payment_T-EVENT _07_07_2021.html


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 12 - 0
SuperCms/Resources/payment_code.html


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 7803 - 0
SuperCms/Resources/payment_code_all.html


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 12 - 0
SuperCms/Resources/payment_code_generate.html


+ 86 - 0
SuperCms/Startup.cs

@@ -0,0 +1,86 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using Microsoft.AspNetCore.Authentication.Cookies;
+using Microsoft.AspNetCore.Builder;
+using Microsoft.AspNetCore.Hosting;
+using Microsoft.AspNetCore.HttpsPolicy;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Hosting;
+using SuperCms.Database;
+using SuperCms.Repositories;
+
+namespace SuperCms
+{
+    public class Startup
+    {
+        public Startup(IConfiguration configuration)
+        {
+            Configuration = configuration;
+        }
+
+        public IConfiguration Configuration { get; }
+
+        // This method gets called by the runtime. Use this method to add services to the container.
+        public void ConfigureServices(IServiceCollection services)
+        {
+            //services.AddControllersWithViews();
+            services.AddTransient<ISuperCmsRepo, SuperCmsRepo>();
+            services.AddSingleton<IConfiguration>(Configuration);
+
+
+            services.AddDbContext<ModelContext>(options => options
+                .UseOracle(Configuration.GetSection("ConnectionMytel").Value,
+                providerOptions => providerOptions.CommandTimeout(60).UseRelationalNulls(true).MinBatchSize(2)));
+
+            services.AddMvc();
+            //.SetCompatibilityVersion(CompatibilityVersion.Version_2_1)
+            //.AddJsonOptions(options => options.SerializerSettings.ContractResolver = new DefaultContractResolver());
+            services.AddAntiforgery(o => o.HeaderName = "XSRF-TOKEN");
+            services.AddDistributedMemoryCache(); // Adds a default in-memory implementation of IDistributedCache
+            services.AddSession(options =>
+            {
+                options.IdleTimeout = TimeSpan.FromSeconds(600);
+                options.Cookie.HttpOnly = true;
+                options.Cookie.IsEssential = true;
+            });
+            //services.AddSession();
+            services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme).AddCookie();
+            services.AddHttpContextAccessor();
+
+        }
+
+        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
+        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
+        {
+            if (env.IsDevelopment())
+            {
+                app.UseDeveloperExceptionPage();
+            }
+            else
+            {
+                app.UseExceptionHandler("/Home/Error");
+                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
+                app.UseHsts();
+            }
+            app.UseSession();
+            app.UseCookiePolicy();
+            app.UseHttpsRedirection();
+            app.UseStaticFiles();
+
+            app.UseRouting();
+
+            app.UseAuthorization();
+
+            app.UseEndpoints(endpoints =>
+            {
+                endpoints.MapControllerRoute(
+                    name: "default",
+                    pattern: "{controller=Home}/{action=Index}/{id?}");
+            });
+        }
+    }
+}

Některé soubory nejsou zobrazeny, neboť je v těchto rozdílových datech změněno mnoho souborů