Add a WPF project for utility application
- Import Director contact is implemented
This commit is contained in:
parent
8cc6584e7c
commit
9acb9974a0
9
Marco.Pms.UtilityApplication/App.xaml
Normal file
9
Marco.Pms.UtilityApplication/App.xaml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<Application x:Class="Marco.Pms.UtilityApplication.App"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:local="clr-namespace:Marco.Pms.UtilityApplication"
|
||||||
|
StartupUri="MainWindow.xaml">
|
||||||
|
<Application.Resources>
|
||||||
|
|
||||||
|
</Application.Resources>
|
||||||
|
</Application>
|
14
Marco.Pms.UtilityApplication/App.xaml.cs
Normal file
14
Marco.Pms.UtilityApplication/App.xaml.cs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
using System.Configuration;
|
||||||
|
using System.Data;
|
||||||
|
using System.Windows;
|
||||||
|
|
||||||
|
namespace Marco.Pms.UtilityApplication
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Interaction logic for App.xaml
|
||||||
|
/// </summary>
|
||||||
|
public partial class App : Application
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
10
Marco.Pms.UtilityApplication/AssemblyInfo.cs
Normal file
10
Marco.Pms.UtilityApplication/AssemblyInfo.cs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
using System.Windows;
|
||||||
|
|
||||||
|
[assembly: ThemeInfo(
|
||||||
|
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
|
||||||
|
//(used if a resource is not found in the page,
|
||||||
|
// or application resource dictionaries)
|
||||||
|
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
|
||||||
|
//(used if a resource is not found in the page,
|
||||||
|
// app, or any theme specific resource dictionaries)
|
||||||
|
)]
|
9
Marco.Pms.UtilityApplication/CategoryMaster.cs
Normal file
9
Marco.Pms.UtilityApplication/CategoryMaster.cs
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
namespace Marco.Pms.UtilityApplication
|
||||||
|
{
|
||||||
|
public class CategoryMaster
|
||||||
|
{
|
||||||
|
public string CategoryID { get; set; }
|
||||||
|
public string Categories { get; set; }
|
||||||
|
public string Description { get; set; }
|
||||||
|
}
|
||||||
|
}
|
32
Marco.Pms.UtilityApplication/Contacts.cs
Normal file
32
Marco.Pms.UtilityApplication/Contacts.cs
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
using Marco.Pms.Model.Projects;
|
||||||
|
using System.Net;
|
||||||
|
using System.Xml.Linq;
|
||||||
|
|
||||||
|
namespace Marco.Pms.UtilityApplication
|
||||||
|
{
|
||||||
|
public class Contacts
|
||||||
|
{
|
||||||
|
public string BucketId { get; set; }
|
||||||
|
public string Owner { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
public string Designation { get; set; }
|
||||||
|
|
||||||
|
public string Organization { get; set; }
|
||||||
|
public string Mobile1 { get; set; }
|
||||||
|
public string Mobile2 { get; set; }
|
||||||
|
public string Mobile3 { get; set; }
|
||||||
|
public string Email1 { get; set; }
|
||||||
|
|
||||||
|
public string Email2 { get; set; }
|
||||||
|
public string Location { get; set; }
|
||||||
|
public string Address { get; set; }
|
||||||
|
public string MoreInformation { get; set; }
|
||||||
|
|
||||||
|
public string Category { get; set; }
|
||||||
|
public Guid? CategoryId { get; set; }
|
||||||
|
|
||||||
|
public string Tags { get; set; }
|
||||||
|
public string Project { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
347
Marco.Pms.UtilityApplication/DirectoryHelper.cs
Normal file
347
Marco.Pms.UtilityApplication/DirectoryHelper.cs
Normal file
@ -0,0 +1,347 @@
|
|||||||
|
using Marco.Pms.Model.Dtos.Directory;
|
||||||
|
using OfficeOpenXml;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net.Mail;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Marco.Pms.UtilityApplication
|
||||||
|
{
|
||||||
|
public class DirectoryHelper
|
||||||
|
{
|
||||||
|
|
||||||
|
public async Task<List<CreateContactDto>> GenerateCreateContactDto(List<Contacts> contactsData, List<CategoryMaster> categoryMasters, List<TagsMaster> tagsMaster, List<ProjectMaster> projectMaster)
|
||||||
|
{
|
||||||
|
List<CreateContactDto> lstCreateContactDto = new List<CreateContactDto>();
|
||||||
|
|
||||||
|
CreateContactDto dto = null;
|
||||||
|
foreach (Contacts contact in contactsData)
|
||||||
|
{
|
||||||
|
dto = new CreateContactDto();
|
||||||
|
dto.Name = contact.Name;
|
||||||
|
dto.Organization = contact.Organization;
|
||||||
|
dto.Address = contact.Address;
|
||||||
|
dto.ContactCategoryId = GetContactCategoryID(contact, categoryMasters);
|
||||||
|
dto.Description = contact.MoreInformation;
|
||||||
|
dto.ContactPhones = GetContactPhones(contact);
|
||||||
|
dto.ContactEmails = GetContactEmails(contact);
|
||||||
|
dto.ProjectIds = GetContactProjectIDs(contact, projectMaster);
|
||||||
|
dto.BucketIds = GetContactBucketIDs(contact);
|
||||||
|
dto.Tags = GetContactTags(contact, tagsMaster);
|
||||||
|
|
||||||
|
lstCreateContactDto.Add(dto);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return lstCreateContactDto;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<ContactTagDto>? GetContactTags(Contacts contact, List<TagsMaster> tagsMaster)
|
||||||
|
{
|
||||||
|
List<ContactTagDto> result = new List<ContactTagDto>();
|
||||||
|
ContactTagDto dto = null;
|
||||||
|
foreach (string tag in contact.Tags.Split(","))
|
||||||
|
{
|
||||||
|
dto = new ContactTagDto();
|
||||||
|
dto.Name = tag;
|
||||||
|
var tagObject = tagsMaster.SingleOrDefault(c => c.Tag == tag.Trim());
|
||||||
|
dto.Id = (tagObject != null && tagObject.TagID != "" ? Guid.Parse(tagObject.TagID) : null);
|
||||||
|
|
||||||
|
result.Add(dto);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Guid? GetContactCategoryID(Contacts contact, List<CategoryMaster> categoryMaster)
|
||||||
|
{
|
||||||
|
if (contact.Category != "")
|
||||||
|
{
|
||||||
|
var category = categoryMaster.SingleOrDefault(c => c.Categories == contact.Category.Trim());
|
||||||
|
if (category != null && category.CategoryID != "")
|
||||||
|
{
|
||||||
|
return new Guid(category.CategoryID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<Guid>? GetContactBucketIDs(Contacts contact)
|
||||||
|
{
|
||||||
|
List<Guid>? result = null;
|
||||||
|
if (contact.BucketId != "")
|
||||||
|
{
|
||||||
|
result = new List<Guid>();
|
||||||
|
result.Add(new Guid(contact.BucketId));
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<CreateContactEmailDto>? GetContactEmails(Contacts contact)
|
||||||
|
{
|
||||||
|
List<CreateContactEmailDto> result = new List<CreateContactEmailDto>();
|
||||||
|
|
||||||
|
if (contact.Email1 != "" && IsValidEmailMailAddress(contact.Email1))
|
||||||
|
{
|
||||||
|
CreateContactEmailDto dto = new CreateContactEmailDto();
|
||||||
|
dto.Label = "Work";
|
||||||
|
dto.EmailAddress = contact.Email1;
|
||||||
|
result.Add(dto);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (contact.Email2 != "" && IsValidEmailMailAddress(contact.Email2))
|
||||||
|
{
|
||||||
|
CreateContactEmailDto dto = new CreateContactEmailDto();
|
||||||
|
dto.Label = "Work";
|
||||||
|
dto.EmailAddress = contact.Email2;
|
||||||
|
result.Add(dto);
|
||||||
|
}
|
||||||
|
return result.Count > 0 ? result : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<Guid>? GetContactProjectIDs(Contacts contact, List<Marco.Pms.UtilityApplication.ProjectMaster> projectMasters)
|
||||||
|
{
|
||||||
|
List<Guid>? result = null;
|
||||||
|
if (contact.Project != "")
|
||||||
|
{
|
||||||
|
var category = projectMasters.SingleOrDefault(c => c.ProjectName == contact.Project.Trim());
|
||||||
|
if (category != null && category.ProjectID != "")
|
||||||
|
{
|
||||||
|
if (result == null) result = new List<Guid>();
|
||||||
|
result.Add(new Guid(category.ProjectID));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<CreateContactPhoneDto>? GetContactPhones(Contacts contact)
|
||||||
|
{
|
||||||
|
List<CreateContactPhoneDto> result = new List<CreateContactPhoneDto>();
|
||||||
|
|
||||||
|
if (contact.Mobile1 != "" && IsValidPhoneNumberBasic(contact.Mobile1))
|
||||||
|
{
|
||||||
|
CreateContactPhoneDto dto = new CreateContactPhoneDto();
|
||||||
|
dto.Label = "Office";
|
||||||
|
dto.PhoneNumber = contact.Mobile1;
|
||||||
|
result.Add(dto);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (contact.Mobile2 != "" && IsValidPhoneNumberBasic(contact.Mobile2))
|
||||||
|
{
|
||||||
|
CreateContactPhoneDto dto = new CreateContactPhoneDto();
|
||||||
|
dto.Label = "Office";
|
||||||
|
dto.PhoneNumber = contact.Mobile2;
|
||||||
|
result.Add(dto);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (contact.Mobile3 != "" && IsValidPhoneNumberBasic(contact.Mobile3))
|
||||||
|
{
|
||||||
|
CreateContactPhoneDto dto = new CreateContactPhoneDto();
|
||||||
|
dto.Label = "Office";
|
||||||
|
dto.PhoneNumber = contact.Mobile3;
|
||||||
|
result.Add(dto);
|
||||||
|
}
|
||||||
|
return result.Count > 0 ? result : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool IsValidPhoneNumberBasic(string phoneNumber)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(phoneNumber))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove common non-digit characters for a cleaner check
|
||||||
|
string cleanedNumber = new string(phoneNumber.Where(char.IsDigit).ToArray());
|
||||||
|
|
||||||
|
// Basic check: Assume a typical phone number length (e.g., 7 to 15 digits)
|
||||||
|
// This is highly region-specific. For India, mobile numbers are usually 10 digits.
|
||||||
|
// For US, 10 digits for local, 11 with country code.
|
||||||
|
return cleanedNumber.Length >= 7 && cleanedNumber.Length <= 15;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool IsValidEmailMailAddress(string email)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(email))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Attempt to create a MailAddress object.
|
||||||
|
// If the format is invalid, it will throw a FormatException.
|
||||||
|
MailAddress m = new MailAddress(email);
|
||||||
|
|
||||||
|
// Optional: You can add more specific checks here if needed,
|
||||||
|
// e.g., checking for specific domain names, but MailAddress itself is very good.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (FormatException)
|
||||||
|
{
|
||||||
|
// The email format is invalid.
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
// Catch any other unexpected exceptions.
|
||||||
|
Console.WriteLine($"An unexpected error occurred during email validation: {ex.Message}");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<(List<Contacts> contactsData, List<CategoryMaster> categoryMasters, List<TagsMaster> tagsMaster, List<ProjectMaster> projectMaster)> ReadExcelData(string filePath)
|
||||||
|
{
|
||||||
|
if (!File.Exists(filePath))
|
||||||
|
{
|
||||||
|
throw new FileNotFoundException($"Excel file not found at: {filePath}");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set the license context for EPPlus
|
||||||
|
// If you are using EPPlus in a commercial application, you need to acquire a commercial license.
|
||||||
|
// For non-commercial use or development, use the NonCommercial license context.
|
||||||
|
|
||||||
|
ExcelPackage.License.SetNonCommercialPersonal("Vikas");
|
||||||
|
|
||||||
|
|
||||||
|
List<Contacts> contactsData = new List<Contacts>();
|
||||||
|
List<CategoryMaster> categoryMasters = new List<CategoryMaster>();
|
||||||
|
List<TagsMaster> tagsMaster = new List<TagsMaster>();
|
||||||
|
List<ProjectMaster> projectMaster = new List<ProjectMaster>();
|
||||||
|
|
||||||
|
using (var package = new ExcelPackage(new FileInfo(filePath)))
|
||||||
|
{
|
||||||
|
// --- Read Transactions Sheet ---
|
||||||
|
ExcelWorksheet transactionsSheet = package.Workbook.Worksheets["CategoryMaster"]; // Assuming sheet name "Transactions"
|
||||||
|
if (transactionsSheet != null)
|
||||||
|
{
|
||||||
|
int rowCount = transactionsSheet.Dimension.Rows;
|
||||||
|
for (int row = 2; row <= rowCount; row++) // Assuming header in row 1
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
categoryMasters.Add(new CategoryMaster
|
||||||
|
{
|
||||||
|
CategoryID = transactionsSheet.Cells[row, 1].Text,
|
||||||
|
Categories = transactionsSheet.Cells[row, 2].Text,
|
||||||
|
Description = transactionsSheet.Cells[row, 3].Text,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (FormatException ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Error parsing transaction data on row {row}: {ex.Message}");
|
||||||
|
// Optionally, skip row or log error more verbosely
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine("Transactions sheet not found in the Excel file.");
|
||||||
|
}
|
||||||
|
|
||||||
|
ExcelWorksheet tagsMasterSheet = package.Workbook.Worksheets["TagMaster"]; // Assuming sheet name "Transactions"
|
||||||
|
if (tagsMasterSheet != null)
|
||||||
|
{
|
||||||
|
int rowCount = tagsMasterSheet.Dimension.Rows;
|
||||||
|
for (int row = 2; row <= rowCount; row++) // Assuming header in row 1
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
tagsMaster.Add(new TagsMaster
|
||||||
|
{
|
||||||
|
TagID = tagsMasterSheet.Cells[row, 1].Text,
|
||||||
|
Tag = tagsMasterSheet.Cells[row, 2].Text,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (FormatException ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Error parsing tags data on row {row}: {ex.Message}");
|
||||||
|
// Optionally, skip row or log error more verbosely
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine("tags sheet not found in the Excel file.");
|
||||||
|
}
|
||||||
|
|
||||||
|
ExcelWorksheet projectsMasterSheet = package.Workbook.Worksheets["ProjectMaster"]; // Assuming sheet name "Transactions"
|
||||||
|
if (projectsMasterSheet != null)
|
||||||
|
{
|
||||||
|
int rowCount = projectsMasterSheet.Dimension.Rows;
|
||||||
|
for (int row = 2; row <= rowCount; row++) // Assuming header in row 1
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
projectMaster.Add(new ProjectMaster
|
||||||
|
{
|
||||||
|
ProjectID = projectsMasterSheet.Cells[row, 1].Text,
|
||||||
|
ProjectName = projectsMasterSheet.Cells[row, 2].Text,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (FormatException ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Error parsing projects data on row {row}: {ex.Message}");
|
||||||
|
// Optionally, skip row or log error more verbosely
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine("projects sheet not found in the Excel file.");
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- Read Master Data Sheet ---
|
||||||
|
ExcelWorksheet masterSheet = package.Workbook.Worksheets["Contacts"]; // Assuming sheet name "MasterData"
|
||||||
|
if (masterSheet != null)
|
||||||
|
{
|
||||||
|
int rowCount = masterSheet.Dimension.Rows;
|
||||||
|
for (int row = 3; row <= rowCount; row++) // Assuming header in row 1
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
contactsData.Add(new Contacts
|
||||||
|
{
|
||||||
|
BucketId = masterSheet.Cells[row, 1].Text,
|
||||||
|
Owner = masterSheet.Cells[row, 2].Text,
|
||||||
|
Name = masterSheet.Cells[row, 3].Text,
|
||||||
|
Designation = masterSheet.Cells[row, 4].Text,
|
||||||
|
Organization = masterSheet.Cells[row, 5].Text,
|
||||||
|
|
||||||
|
Mobile1 = masterSheet.Cells[row, 6].Text,
|
||||||
|
Mobile2 = masterSheet.Cells[row, 7].Text,
|
||||||
|
Mobile3 = masterSheet.Cells[row, 8].Text,
|
||||||
|
Email1 = masterSheet.Cells[row, 9].Text,
|
||||||
|
Email2 = masterSheet.Cells[row, 10].Text,
|
||||||
|
Location = masterSheet.Cells[row, 11].Text,
|
||||||
|
Address = masterSheet.Cells[row, 12].Text,
|
||||||
|
MoreInformation = masterSheet.Cells[row, 13].Text,
|
||||||
|
Category = masterSheet.Cells[row, 14].Text,
|
||||||
|
Tags = masterSheet.Cells[row, 15].Text,
|
||||||
|
Project = masterSheet.Cells[row, 16].Text
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (FormatException ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Error parsing master data on row {row}: {ex.Message}");
|
||||||
|
// Optionally, skip row or log error more verbosely
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine("MasterData sheet not found in the Excel file.");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return (contactsData, categoryMasters, tagsMaster, projectMaster);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
16
Marco.Pms.UtilityApplication/MainWindow.xaml
Normal file
16
Marco.Pms.UtilityApplication/MainWindow.xaml
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<Window x:Class="Marco.Pms.UtilityApplication.MainWindow"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:local="clr-namespace:Marco.Pms.UtilityApplication"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
Title="MainWindow" Height="450" Width="800">
|
||||||
|
<Grid>
|
||||||
|
<TextBox HorizontalAlignment="Left" Margin="207,72,0,0" TextWrapping="Wrap" Text="E:\Downloads\Directory Contacts - Marketing Team Yatin.xlsx" VerticalAlignment="Top" Width="348" Name="txtFilePath" FontSize="16"/>
|
||||||
|
<Label Content="Select File" HorizontalAlignment="Left" Margin="86,66,0,0" VerticalAlignment="Top" Name="lblFileName" Height="29" Width="99" FontSize="16"/>
|
||||||
|
<Button Content="Upload File" HorizontalAlignment="Left" Margin="560,72,0,0" VerticalAlignment="Top" Name="btnFileUpload" FontSize="16" Click="btnFileUpload_Click"/>
|
||||||
|
<Button Content="Submit" HorizontalAlignment="Left" Margin="446,124,0,0" VerticalAlignment="Top" x:Name="btnSubmit" FontSize="16" RenderTransformOrigin="0.147,2.815" Click="btnSubmit_Click"/>
|
||||||
|
|
||||||
|
</Grid>
|
||||||
|
</Window>
|
47
Marco.Pms.UtilityApplication/MainWindow.xaml.cs
Normal file
47
Marco.Pms.UtilityApplication/MainWindow.xaml.cs
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
using Marco.Pms.Model.Dtos.Directory;
|
||||||
|
using Microsoft.Win32;
|
||||||
|
using System.Windows;
|
||||||
|
|
||||||
|
namespace Marco.Pms.UtilityApplication
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Interaction logic for MainWindow.xaml
|
||||||
|
/// </summary>
|
||||||
|
public partial class MainWindow : Window
|
||||||
|
{
|
||||||
|
DirectoryHelper helper = new DirectoryHelper();
|
||||||
|
public MainWindow()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btnFileUpload_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
OpenFileDialog openFileDialog = new OpenFileDialog();
|
||||||
|
openFileDialog.Filter = "Excel files (*.xlsx)|*.xlsx|CSV files (*.csv)|*.csv"; // Optional: filter file types
|
||||||
|
|
||||||
|
if (openFileDialog.ShowDialog() == true)
|
||||||
|
{
|
||||||
|
string filePath = openFileDialog.FileName;
|
||||||
|
// Now you can use filePath to read or process the selected file
|
||||||
|
txtFilePath.Text = filePath;
|
||||||
|
//MessageBox.Show($"Selected file: {filePath}");
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private async void btnSubmit_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
List<Contacts> contactsData = null;
|
||||||
|
List<TagsMaster> tagsMaster = null;
|
||||||
|
List<ProjectMaster> projectMaster = null;
|
||||||
|
List<CategoryMaster> categoryMasters = null;
|
||||||
|
|
||||||
|
|
||||||
|
(contactsData, categoryMasters, tagsMaster, projectMaster) = await helper.ReadExcelData(txtFilePath.Text);
|
||||||
|
|
||||||
|
List<CreateContactDto> createContactDto = await helper.GenerateCreateContactDto(contactsData, categoryMasters, tagsMaster, projectMaster);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>WinExe</OutputType>
|
||||||
|
<TargetFramework>net8.0-windows</TargetFramework>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<UseWPF>true</UseWPF>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="EPPlus" Version="8.0.8" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Marco.Pms.Model\Marco.Pms.Model.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
8
Marco.Pms.UtilityApplication/ProjectMaster.cs
Normal file
8
Marco.Pms.UtilityApplication/ProjectMaster.cs
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
namespace Marco.Pms.UtilityApplication
|
||||||
|
{
|
||||||
|
public class ProjectMaster
|
||||||
|
{
|
||||||
|
public string ProjectID { get; set; }
|
||||||
|
public string ProjectName { get; set; }
|
||||||
|
}
|
||||||
|
}
|
8
Marco.Pms.UtilityApplication/TagsMaster.cs
Normal file
8
Marco.Pms.UtilityApplication/TagsMaster.cs
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
namespace Marco.Pms.UtilityApplication
|
||||||
|
{
|
||||||
|
public class TagsMaster
|
||||||
|
{
|
||||||
|
public string TagID { get; set; }
|
||||||
|
public string Tag { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -13,6 +13,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Marco.Pms.Services", "Marco
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Marco.Pms.CacheHelper", "Marco.Pms.CacheHelper\Marco.Pms.CacheHelper.csproj", "{1A105C22-4ED7-4F54-8834-6923DDD96852}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Marco.Pms.CacheHelper", "Marco.Pms.CacheHelper\Marco.Pms.CacheHelper.csproj", "{1A105C22-4ED7-4F54-8834-6923DDD96852}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Marco.Pms.UtilityApplication", "Marco.Pms.UtilityApplication\Marco.Pms.UtilityApplication.csproj", "{1F67DA6E-C4B4-4D48-8484-713F801772A5}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@ -39,6 +41,10 @@ Global
|
|||||||
{1A105C22-4ED7-4F54-8834-6923DDD96852}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{1A105C22-4ED7-4F54-8834-6923DDD96852}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{1A105C22-4ED7-4F54-8834-6923DDD96852}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{1A105C22-4ED7-4F54-8834-6923DDD96852}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{1A105C22-4ED7-4F54-8834-6923DDD96852}.Release|Any CPU.Build.0 = Release|Any CPU
|
{1A105C22-4ED7-4F54-8834-6923DDD96852}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{1F67DA6E-C4B4-4D48-8484-713F801772A5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{1F67DA6E-C4B4-4D48-8484-713F801772A5}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{1F67DA6E-C4B4-4D48-8484-713F801772A5}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{1F67DA6E-C4B4-4D48-8484-713F801772A5}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
Loading…
x
Reference in New Issue
Block a user