This commit is contained in:
@@ -0,0 +1,250 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>9.0.30729</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{0CD14576-A3D4-4CBD-A8E6-F8BD3EEAA4B7}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>AyaNova.PlugIn.ImportExportCSV</RootNamespace>
|
||||
<AssemblyName>AyaNova.PlugIn.ImportExportCSV</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<FileUpgradeFlags>
|
||||
</FileUpgradeFlags>
|
||||
<OldToolsVersion>3.5</OldToolsVersion>
|
||||
<UpgradeBackupLocation />
|
||||
<TargetFrameworkProfile>
|
||||
</TargetFrameworkProfile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\..\WinFormApp\bin\debug\plugins\ImportExportCSV\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="FileHelpers, Version=1.4.5.0, Culture=neutral">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\..\3rdprtylibs\FileHelpers\FileHelpers.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.VisualBasic" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml.Linq">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Data.DataSetExtensions">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="CopyableMessageBox.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="ImportRate.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="FHRate.cs" />
|
||||
<Compile Include="ImportPartCategory.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="FHPartCategory.cs" />
|
||||
<Compile Include="ImportPriority.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="FHPriority.cs" />
|
||||
<Compile Include="ImportUnitServiceType.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="FHUnitServiceType.cs" />
|
||||
<Compile Include="ImportWorkorderItemType.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="FHWorkorderItemType.cs" />
|
||||
<Compile Include="ImportWorkorderCategory.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="FHWorkorderCategory.cs" />
|
||||
<Compile Include="ImportWorkorderStatus.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="FHWorkorderStatus.cs" />
|
||||
<Compile Include="ExportCSV.cs" />
|
||||
<Compile Include="FHAssembly.cs" />
|
||||
<Compile Include="FHClient.cs" />
|
||||
<Compile Include="FHPart.cs" />
|
||||
<Compile Include="FHUnit.cs" />
|
||||
<Compile Include="GZDataGridViewComboColumnHeaderCell.cs" />
|
||||
<Compile Include="IECSVData.cs" />
|
||||
<Compile Include="ImportUnit.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="ImportPart.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="ImportAssembly.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="ImportClient.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="ImportExportCSV.cs" />
|
||||
<Compile Include="ImportUpdateOptions.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="ImportUpdateOptions.Designer.cs">
|
||||
<DependentUpon>ImportUpdateOptions.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Resource.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Resource.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Timestamp.cs" />
|
||||
<Compile Include="Util.cs" />
|
||||
<Compile Include="Waiting.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\AyaNova.PlugIn\AyaNova.PlugIn.csproj">
|
||||
<Project>{674BC3C9-4F74-4304-91ED-2EAFFFEB09A7}</Project>
|
||||
<Name>AyaNova.PlugIn</Name>
|
||||
<Private>False</Private>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\bizobjects\AyaLib\GZTW.AyaNova.BLL.csproj">
|
||||
<Project>{50B807B6-FC35-4CC3-B54D-91C78426A943}</Project>
|
||||
<Name>GZTW.AyaNova.BLL</Name>
|
||||
<Private>False</Private>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\csla10\CSLA.Core.Bindablebase\CSLA.Core.Bindablebase.csproj">
|
||||
<Project>{C2392355-12A9-4197-A1D3-603C390B1E62}</Project>
|
||||
<Name>CSLA.Core.Bindablebase</Name>
|
||||
<Private>False</Private>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\csla10\CSLA.Server.DataPortal\CSLA.Server.DataPortal.vbproj">
|
||||
<Project>{80828E2C-E9FB-4E73-A27C-7F9CDB96FCDE}</Project>
|
||||
<Name>CSLA.Server.DataPortal</Name>
|
||||
<Private>False</Private>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\csla10\CSLA\CSLA.vbproj">
|
||||
<Project>{1B9A38BB-461A-47A4-AD72-099C694138A0}</Project>
|
||||
<Name>CSLA</Name>
|
||||
<Private>False</Private>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\Data\Data\GZTW.Data.csproj">
|
||||
<Project>{701893AA-C042-4FB2-8643-E139372C1117}</Project>
|
||||
<Name>GZTW.Data</Name>
|
||||
<Private>False</Private>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\Profile\GZTW.Profile\GZTW.Profile.csproj">
|
||||
<Project>{EDE897E2-E2E6-441D-9F83-0B973AE09670}</Project>
|
||||
<Name>GZTW.Profile</Name>
|
||||
<Private>False</Private>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="CopyableMessageBox.resx">
|
||||
<DependentUpon>CopyableMessageBox.cs</DependentUpon>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="ImportRate.resx">
|
||||
<DependentUpon>ImportRate.cs</DependentUpon>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="ImportPartCategory.resx">
|
||||
<DependentUpon>ImportPartCategory.cs</DependentUpon>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="ImportPriority.resx">
|
||||
<DependentUpon>ImportPriority.cs</DependentUpon>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="ImportUnitServiceType.resx">
|
||||
<DependentUpon>ImportUnitServiceType.cs</DependentUpon>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="ImportWorkorderItemType.resx">
|
||||
<DependentUpon>ImportWorkorderItemType.cs</DependentUpon>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="ImportWorkorderCategory.resx">
|
||||
<DependentUpon>ImportWorkorderCategory.cs</DependentUpon>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="ImportWorkorderStatus.resx">
|
||||
<DependentUpon>ImportWorkorderStatus.cs</DependentUpon>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="ImportUnit.resx">
|
||||
<DependentUpon>ImportUnit.cs</DependentUpon>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="ImportPart.resx">
|
||||
<DependentUpon>ImportPart.cs</DependentUpon>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="ImportAssembly.resx">
|
||||
<DependentUpon>ImportAssembly.cs</DependentUpon>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="ImportClient.resx">
|
||||
<DependentUpon>ImportClient.cs</DependentUpon>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="ImportUpdateOptions.resx">
|
||||
<DependentUpon>ImportUpdateOptions.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Resource.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resource.Designer.cs</LastGenOutput>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Waiting.resx">
|
||||
<DependentUpon>Waiting.cs</DependentUpon>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resource\ImportExportCSV16.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resource\ImportExportCSV16icon.ico" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resource\ImportExportCSV32.png" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PreBuildEvent>"C:\data\AyaNova\utils\TimeStamp\bin\Release\TimeStamp.exe" "$(ProjectDir)Timestamp.cs" "/N:AyaNova.PlugIn.ImportExportCSV"</PreBuildEvent>
|
||||
</PropertyGroup>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
@@ -0,0 +1,92 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Collections;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace AyaNova.PlugIn.ImportExportCSV
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for CopyableMessageBox.
|
||||
/// </summary>
|
||||
public class CopyableMessageBox : System.Windows.Forms.Form
|
||||
{
|
||||
private System.Windows.Forms.TextBox edOut;
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.Container components = null;
|
||||
private string mDisplay="";
|
||||
public CopyableMessageBox(string Display)
|
||||
{
|
||||
//
|
||||
// Required for Windows Form Designer support
|
||||
//
|
||||
InitializeComponent();
|
||||
|
||||
mDisplay=Display;
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
protected override void Dispose( bool disposing )
|
||||
{
|
||||
if( disposing )
|
||||
{
|
||||
if(components != null)
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
}
|
||||
base.Dispose( disposing );
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CopyableMessageBox));
|
||||
this.edOut = new System.Windows.Forms.TextBox();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// edOut
|
||||
//
|
||||
this.edOut.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.edOut.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.edOut.Location = new System.Drawing.Point(0, 0);
|
||||
this.edOut.Multiline = true;
|
||||
this.edOut.Name = "edOut";
|
||||
this.edOut.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
|
||||
this.edOut.Size = new System.Drawing.Size(750, 769);
|
||||
this.edOut.TabIndex = 0;
|
||||
//
|
||||
// CopyableMessageBox
|
||||
//
|
||||
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
|
||||
this.ClientSize = new System.Drawing.Size(750, 769);
|
||||
this.Controls.Add(this.edOut);
|
||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||
this.Name = "CopyableMessageBox";
|
||||
this.ShowInTaskbar = false;
|
||||
this.Load += new System.EventHandler(this.CopyableMessageBox_Load);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
private void CopyableMessageBox_Load(object sender, System.EventArgs e)
|
||||
{
|
||||
edOut.Text=mDisplay;
|
||||
edOut.Select(0,0);
|
||||
}
|
||||
}
|
||||
}
|
||||
462
source/Plugins/AyaNova.PlugIn.ImportExportCSV/ExportCSV.cs
Normal file
462
source/Plugins/AyaNova.PlugIn.ImportExportCSV/ExportCSV.cs
Normal file
@@ -0,0 +1,462 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using GZTW.AyaNova.BLL;
|
||||
using System.Windows.Forms;
|
||||
using FileHelpers;
|
||||
using System.Collections;
|
||||
|
||||
namespace AyaNova.PlugIn.ImportExportCSV
|
||||
{
|
||||
public class ExportCSV
|
||||
{
|
||||
/// <summary>
|
||||
/// Export the indicated objects to csv file
|
||||
/// </summary>
|
||||
public static void ExportList(RootObjectTypes objectType, List<Guid> objectIDList)
|
||||
{
|
||||
string objectName = EnumDescConverter.GetEnumDescription(objectType);
|
||||
SaveFileDialog sf = new SaveFileDialog();
|
||||
sf.DefaultExt = ".csv";
|
||||
sf.FileName = objectType.ToString() + ".csv";
|
||||
if (sf.ShowDialog() != DialogResult.OK) return;
|
||||
|
||||
if (objectIDList == null) objectIDList = new List<Guid>();
|
||||
FileHelperEngine engine = null;
|
||||
System.Collections.ArrayList al = new ArrayList();
|
||||
//Got the file name now to export
|
||||
switch (objectType)
|
||||
{
|
||||
case RootObjectTypes.Client:
|
||||
{
|
||||
#region export clients
|
||||
|
||||
//zero selected? Then export all.
|
||||
if (objectIDList.Count == 0)
|
||||
{
|
||||
ClientPickList cpl = ClientPickList.GetList();
|
||||
foreach (ClientPickList.ClientPickListInfo i in cpl)
|
||||
objectIDList.Add(i.ID);
|
||||
|
||||
}
|
||||
FHClient fhc;
|
||||
Client c;
|
||||
engine = new FileHelperEngine(typeof(FHClient));
|
||||
Waiting w = new Waiting();
|
||||
w.Show();
|
||||
w.Ops = "Exporting " + objectName;
|
||||
foreach (Guid id in objectIDList)
|
||||
{
|
||||
c = Client.GetItem(id);
|
||||
ClientList cl = ClientList.GetListForSingleItem(id);
|
||||
|
||||
fhc = new FHClient();
|
||||
w.Step = c.Name;
|
||||
fhc.Name = c.Name;
|
||||
fhc.AccountNumber = c.AccountNumber;
|
||||
|
||||
//contact fields
|
||||
fhc.Contact = c.Contact;
|
||||
fhc.ContactNotes = c.ContactNotes;
|
||||
fhc.Phone1 = c.Phone1;
|
||||
fhc.Phone2 = c.Phone2;
|
||||
fhc.Phone3 = c.Phone3;
|
||||
fhc.Phone4 = c.Phone4;
|
||||
fhc.Phone5 = c.Phone5;
|
||||
fhc.EmailAddress = c.Email;
|
||||
|
||||
|
||||
fhc.DeliveryAddress = c.GoToAddress.DeliveryAddress;
|
||||
fhc.DeliveryCity = c.GoToAddress.City;
|
||||
fhc.DeliveryCountry = c.GoToAddress.Country;
|
||||
fhc.DeliveryPostal = c.GoToAddress.Postal;
|
||||
fhc.DeliveryStateProvince = c.GoToAddress.StateProv;
|
||||
|
||||
|
||||
fhc.GeneralNotes = c.Notes;
|
||||
|
||||
fhc.MailAddress = c.MailToAddress.DeliveryAddress;
|
||||
fhc.MailCity = c.MailToAddress.City;
|
||||
fhc.MailCountry = c.MailToAddress.Country;
|
||||
fhc.MailPostal = c.MailToAddress.Postal;
|
||||
fhc.MailStateProvince = c.MailToAddress.StateProv;
|
||||
fhc.PopupNotes = c.PopUpNotes;
|
||||
|
||||
fhc.TechNotes = c.TechNotes;
|
||||
fhc.WebSite = c.WebAddress;
|
||||
|
||||
//case 1737
|
||||
fhc.ClientGroup = cl[0].LT_O_ClientGroup.Display;
|
||||
fhc.DispatchZone = cl[0].LT_O_DispatchZone.Display;
|
||||
fhc.Region = cl[0].LT_O_Region.Display;
|
||||
|
||||
al.Add(fhc);
|
||||
|
||||
|
||||
}
|
||||
w.Close();
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
engine.WriteFile(sf.FileName, (object[])al.ToArray(typeof(FHClient)));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show("Error writing the export file:\r\n\r\n" + ex.Message);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
MessageBox.Show("Selected clients have been exported to file:\r\n" +
|
||||
sf.FileName);
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
break;
|
||||
case RootObjectTypes.Part:
|
||||
{
|
||||
#region Export parts
|
||||
#region cached lists
|
||||
//Load cached lists
|
||||
|
||||
htManufacturers.Clear();
|
||||
htWholesalers.Clear();
|
||||
VendorPickList vp = VendorPickList.GetList();
|
||||
foreach (VendorPickList.VendorPickListInfo i in vp)
|
||||
{
|
||||
switch (i.VendorType)
|
||||
{
|
||||
case VendorTypes.Manufacturer:
|
||||
//case 3606
|
||||
if (!htManufacturers.ContainsKey(i.Name))
|
||||
htManufacturers.Add(i.Name, i.ID);
|
||||
break;
|
||||
|
||||
case VendorTypes.Wholesaler:
|
||||
//case 3606
|
||||
if (!htWholesalers.ContainsKey(i.Name))
|
||||
htWholesalers.Add(i.Name, i.ID);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Measures = UnitOfMeasures.GetItems();
|
||||
Categories = PartCategories.GetItems();
|
||||
#endregion
|
||||
|
||||
engine = new FileHelperEngine(typeof(FHPart));
|
||||
FHPart fhc;
|
||||
Part p;
|
||||
|
||||
//zero selected? Then export all.
|
||||
if (objectIDList.Count == 0)
|
||||
{
|
||||
PartPickList ppl = PartPickList.GetAllParts();
|
||||
foreach (PartPickList.PartPickListInfo i in ppl)
|
||||
objectIDList.Add(i.ID);
|
||||
}
|
||||
Waiting w = new Waiting();
|
||||
w.Show();
|
||||
w.Ops = "Exporting " + objectName;
|
||||
foreach (Guid id in objectIDList)
|
||||
{
|
||||
p = Part.GetItem(id);
|
||||
fhc = new FHPart();
|
||||
w.Step = p.Name + " " + p.PartNumber;
|
||||
fhc.Number = p.PartNumber;
|
||||
fhc.Name = p.Name;
|
||||
fhc.AlternativeWholeSaler = GetWholesalerByID(p.AlternativeWholesalerID);
|
||||
fhc.AlternativeWholeSalerNumber = p.AlternativeWholesalerNumber;
|
||||
fhc.Category = "";
|
||||
for (int x = 0; x < Categories.Count; x++)
|
||||
{
|
||||
if (Categories[x].ID == p.PartCategoryID)
|
||||
{
|
||||
fhc.Category = Categories[x].Name;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
fhc.Cost = p.Cost.ToString();
|
||||
fhc.Manufacturer = GetManufacturerByID(p.ManufacturerID);
|
||||
fhc.ManufacturerNumber = p.ManufacturerNumber;
|
||||
fhc.Notes = p.Notes;
|
||||
fhc.Retail = p.Retail.ToString();
|
||||
fhc.TrackSerialNumber = (p.TrackSerialNumber ? "TRUE" : "FALSE");
|
||||
fhc.UnitOfMeasure = "";
|
||||
for (int x = 0; x < Measures.Count; x++)
|
||||
{
|
||||
if (Measures[x].ID == p.UnitOfMeasureID)
|
||||
{
|
||||
fhc.UnitOfMeasure = Measures[x].Name;
|
||||
break;
|
||||
}
|
||||
}
|
||||
fhc.UPC = p.UPC;
|
||||
fhc.WholeSaler = GetWholesalerByID(p.WholesalerID);
|
||||
fhc.WholeSalerNumber = p.WholesalerNumber;
|
||||
|
||||
|
||||
|
||||
|
||||
al.Add(fhc);
|
||||
|
||||
|
||||
}
|
||||
w.Close();
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
engine.WriteFile(sf.FileName, (object[])al.ToArray(typeof(FHPart)));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show("Error writing the export file:\r\n\r\n" + ex.Message);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
MessageBox.Show("Selected items have been exported to file:\r\n" +
|
||||
sf.FileName);
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
break;
|
||||
|
||||
case RootObjectTypes.Unit:
|
||||
{
|
||||
#region Export Units
|
||||
|
||||
#region cached lists
|
||||
//Load cached lists
|
||||
try
|
||||
{
|
||||
htManufacturers.Clear();
|
||||
htWholesalers.Clear();
|
||||
htClients.Clear();
|
||||
htModels.Clear();
|
||||
htUnits.Clear();
|
||||
|
||||
VendorPickList vp = VendorPickList.GetList();
|
||||
foreach (VendorPickList.VendorPickListInfo i in vp)
|
||||
{
|
||||
switch (i.VendorType)
|
||||
{
|
||||
case VendorTypes.Manufacturer:
|
||||
//case 3606
|
||||
if (!htManufacturers.ContainsKey(i.Name))
|
||||
htManufacturers.Add(i.Name, i.ID);
|
||||
break;
|
||||
|
||||
case VendorTypes.Wholesaler:
|
||||
//case 3606
|
||||
if (!htWholesalers.ContainsKey(i.Name))
|
||||
htWholesalers.Add(i.Name, i.ID);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ClientPickList p = ClientPickList.GetList();
|
||||
foreach (ClientPickList.ClientPickListInfo i in p)
|
||||
{
|
||||
//case 3606
|
||||
if (!htClients.ContainsKey(i.Name))
|
||||
htClients.Add(i.Name, i.ID);
|
||||
}
|
||||
|
||||
UnitModelPickList upl = UnitModelPickList.GetList();
|
||||
foreach (UnitModelPickList.UnitModelPickListInfo i in upl)
|
||||
{
|
||||
//case 3606
|
||||
if (!htModels.ContainsKey(i.Name))
|
||||
htModels.Add(i.Name, i.ID);
|
||||
}
|
||||
|
||||
UnitPickList unpl = UnitPickList.GetListOfAll();
|
||||
foreach (UnitPickList.UnitPickListInfo i in unpl)
|
||||
{
|
||||
//case 3606
|
||||
if (!htUnits.ContainsKey(i.Serial))
|
||||
htUnits.Add(i.Serial, i.ID);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (ex is System.ArgumentException)
|
||||
{
|
||||
MessageBox.Show(
|
||||
"An error has occurred while attempting to retrieve the lists of objects\r\n" +
|
||||
"already stored in AyaNova which are used to match to the data being imported.\r\n" +
|
||||
"(Clients, Unit Models, Vendors Units etc)\r\n\r\n" +
|
||||
"A duplicate record was found with the same name and must be removed or changed\r\n" +
|
||||
"before you can proceed with this utility. Details below:\r\n\r\n" +
|
||||
ex.Message, "Duplicate object name in AyaNova");
|
||||
|
||||
}
|
||||
else
|
||||
MessageBox.Show("An error has occurred while attempting to retrieve the lists of objects\r\n" +
|
||||
"already stored in AyaNova which are used to match to the data being imported.\r\n" +
|
||||
"The import utility can not proceed, details below:\r\n\r\n", ex.Message);
|
||||
|
||||
return;
|
||||
}
|
||||
#endregion
|
||||
|
||||
//zero selected? Then export all.
|
||||
if (objectIDList.Count == 0)
|
||||
{
|
||||
UnitPickList ppl = UnitPickList.GetListOfAll();
|
||||
foreach (UnitPickList.UnitPickListInfo i in ppl)
|
||||
objectIDList.Add(i.ID);
|
||||
|
||||
}
|
||||
FHUnit fhc;
|
||||
Unit u;
|
||||
engine = new FileHelperEngine(typeof(FHUnit));
|
||||
Waiting w = new Waiting();
|
||||
w.Show();
|
||||
w.Ops = "Exporting " + objectName;
|
||||
foreach (Guid id in objectIDList)
|
||||
{
|
||||
u = Unit.GetItem(id);
|
||||
fhc = new FHUnit();
|
||||
w.Step = u.Serial;
|
||||
fhc.Serial = u.Serial;
|
||||
fhc.Client = GetClientByID(u.ClientID);
|
||||
fhc.Description = u.Description;
|
||||
fhc.Metered = (u.Metered ? "TRUE" : "FALSE");
|
||||
fhc.Notes = u.Notes;
|
||||
if (u.PurchasedDate == System.DBNull.Value)
|
||||
fhc.PurchasedDate = "";
|
||||
else
|
||||
{
|
||||
DateTime dtPurchased = System.Convert.ToDateTime(u.PurchasedDate);
|
||||
fhc.PurchasedDate = dtPurchased.ToString();
|
||||
}
|
||||
|
||||
fhc.PurchasedFromVendor = GetPurchasedFromByID(u.PurchasedFromID);
|
||||
fhc.SalesReceiptNumber = u.Receipt;
|
||||
fhc.UnitModel = GetModelByID(u.UnitModelID);
|
||||
fhc.WarrantyLength = u.WarrantyLength.ToString();//case 1739
|
||||
al.Add(fhc);
|
||||
|
||||
|
||||
}
|
||||
w.Close();
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
engine.WriteFile(sf.FileName, (object[])al.ToArray(typeof(FHUnit)));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show("Error writing the export file:\r\n\r\n" + ex.Message);
|
||||
return;
|
||||
}
|
||||
|
||||
MessageBox.Show("Selected items have been exported to file:\r\n" +
|
||||
sf.FileName);
|
||||
#endregion
|
||||
}
|
||||
break;
|
||||
}//end of object type switch
|
||||
|
||||
|
||||
|
||||
}//end of method
|
||||
|
||||
|
||||
//Part and unit helpers
|
||||
static Hashtable htManufacturers = new Hashtable();
|
||||
static Hashtable htWholesalers = new Hashtable();
|
||||
|
||||
#region part helpers
|
||||
//These are name value lists used to
|
||||
//keep track of the id's of existing items
|
||||
//that are either pre-existing or have been created during import
|
||||
//this supports the code that matches text names of objects to their id's
|
||||
//i.e. "IBM" as a manufacturer to the IBM record in AyaNova already
|
||||
//case is not taken into account during comparison to ensure no little
|
||||
//mismatches due to a small typo in the import file
|
||||
|
||||
static UnitOfMeasures Measures;//=UnitOfMeasures.GetItems();
|
||||
static PartCategories Categories;//=PartCategories.GetItems();
|
||||
|
||||
|
||||
private static string GetWholesalerByID(Guid ID)
|
||||
{
|
||||
foreach (DictionaryEntry de in htWholesalers)
|
||||
{
|
||||
if ((Guid)de.Value == ID)
|
||||
return de.Key.ToString();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private static string GetManufacturerByID(Guid ID)
|
||||
{
|
||||
foreach (DictionaryEntry de in htManufacturers)
|
||||
{
|
||||
if ((Guid)de.Value == ID)
|
||||
return de.Key.ToString();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Unit helpers
|
||||
|
||||
|
||||
static Hashtable htClients = new Hashtable();
|
||||
static Hashtable htModels = new Hashtable();
|
||||
static Hashtable htUnits = new Hashtable();
|
||||
|
||||
static private string GetPurchasedFromByID(Guid ID)
|
||||
{
|
||||
foreach (DictionaryEntry de in htWholesalers)
|
||||
{
|
||||
if ((Guid)de.Value == ID)
|
||||
return de.Key.ToString();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
static private string GetClientByID(Guid ID)
|
||||
{
|
||||
foreach (DictionaryEntry de in htClients)
|
||||
{
|
||||
if ((Guid)de.Value == ID)
|
||||
return de.Key.ToString();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
static private string GetModelByID(Guid ID)
|
||||
{
|
||||
foreach (DictionaryEntry de in htModels)
|
||||
{
|
||||
if ((Guid)de.Value == ID)
|
||||
return de.Key.ToString();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
#endregion
|
||||
|
||||
}//end of class
|
||||
}//end of namespace
|
||||
15
source/Plugins/AyaNova.PlugIn.ImportExportCSV/FHAssembly.cs
Normal file
15
source/Plugins/AyaNova.PlugIn.ImportExportCSV/FHAssembly.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using FileHelpers;
|
||||
|
||||
namespace AyaNova.PlugIn.ImportExportCSV
|
||||
{
|
||||
[DelimitedRecord(","), IgnoreEmptyLines()]
|
||||
public sealed class FHAssembly
|
||||
{
|
||||
[FieldTrim(TrimMode.Both), FieldQuoted('"', QuoteMode.OptionalForBoth, MultilineMode.NotAllow)]
|
||||
public String Name;
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
93
source/Plugins/AyaNova.PlugIn.ImportExportCSV/FHClient.cs
Normal file
93
source/Plugins/AyaNova.PlugIn.ImportExportCSV/FHClient.cs
Normal file
@@ -0,0 +1,93 @@
|
||||
using System;
|
||||
using FileHelpers;
|
||||
|
||||
namespace AyaNova.PlugIn.ImportExportCSV
|
||||
{
|
||||
[DelimitedRecord(","), IgnoreEmptyLines()]
|
||||
public sealed class FHClient
|
||||
{
|
||||
[FieldTrim(TrimMode.Both),FieldQuoted('"',QuoteMode.OptionalForBoth, MultilineMode.AllowForBoth)]
|
||||
public String Name;
|
||||
|
||||
[FieldTrim(TrimMode.Both),FieldQuoted('"',QuoteMode.OptionalForBoth,MultilineMode.AllowForBoth)]
|
||||
public String MailAddress;
|
||||
|
||||
[FieldTrim(TrimMode.Both),FieldQuoted('"',QuoteMode.OptionalForBoth,MultilineMode.AllowForBoth)]
|
||||
public String MailCity;
|
||||
|
||||
[FieldTrim(TrimMode.Both),FieldQuoted('"',QuoteMode.OptionalForBoth,MultilineMode.AllowForBoth)]
|
||||
public String MailStateProvince;
|
||||
|
||||
[FieldTrim(TrimMode.Both),FieldQuoted('"',QuoteMode.OptionalForBoth,MultilineMode.AllowForBoth)]
|
||||
public String MailCountry;
|
||||
|
||||
[FieldTrim(TrimMode.Both),FieldQuoted('"',QuoteMode.OptionalForBoth,MultilineMode.AllowForBoth)]
|
||||
public String MailPostal;
|
||||
|
||||
[FieldTrim(TrimMode.Both),FieldQuoted('"',QuoteMode.OptionalForBoth,MultilineMode.AllowForBoth)]
|
||||
public String DeliveryAddress;
|
||||
|
||||
[FieldTrim(TrimMode.Both),FieldQuoted('"',QuoteMode.OptionalForBoth,MultilineMode.AllowForBoth)]
|
||||
public String DeliveryCity;
|
||||
|
||||
[FieldTrim(TrimMode.Both),FieldQuoted('"',QuoteMode.OptionalForBoth,MultilineMode.AllowForBoth)]
|
||||
public String DeliveryStateProvince;
|
||||
|
||||
[FieldTrim(TrimMode.Both),FieldQuoted('"',QuoteMode.OptionalForBoth,MultilineMode.AllowForBoth)]
|
||||
public String DeliveryCountry;
|
||||
|
||||
[FieldTrim(TrimMode.Both),FieldQuoted('"',QuoteMode.OptionalForBoth,MultilineMode.AllowForBoth)]
|
||||
public String DeliveryPostal;
|
||||
|
||||
[FieldTrim(TrimMode.Both),FieldQuoted('"',QuoteMode.OptionalForBoth,MultilineMode.AllowForBoth)]
|
||||
public String Contact;
|
||||
|
||||
[FieldTrim(TrimMode.Both),FieldQuoted('"',QuoteMode.OptionalForBoth,MultilineMode.AllowForBoth)]
|
||||
public String ContactNotes;
|
||||
|
||||
[FieldTrim(TrimMode.Both),FieldQuoted('"',QuoteMode.OptionalForBoth,MultilineMode.AllowForBoth)]
|
||||
public String Phone1;
|
||||
|
||||
[FieldTrim(TrimMode.Both),FieldQuoted('"',QuoteMode.OptionalForBoth,MultilineMode.AllowForBoth)]
|
||||
public String Phone2;
|
||||
|
||||
[FieldTrim(TrimMode.Both),FieldQuoted('"',QuoteMode.OptionalForBoth,MultilineMode.AllowForBoth)]
|
||||
public String Phone3;
|
||||
|
||||
[FieldTrim(TrimMode.Both), FieldQuoted('"', QuoteMode.OptionalForBoth, MultilineMode.AllowForBoth)]
|
||||
public String Phone4;
|
||||
|
||||
[FieldTrim(TrimMode.Both), FieldQuoted('"', QuoteMode.OptionalForBoth, MultilineMode.AllowForBoth)]
|
||||
public String Phone5;
|
||||
|
||||
[FieldTrim(TrimMode.Both),FieldQuoted('"',QuoteMode.OptionalForBoth,MultilineMode.AllowForBoth)]
|
||||
public String EmailAddress;
|
||||
|
||||
[FieldTrim(TrimMode.Both),FieldQuoted('"',QuoteMode.OptionalForBoth,MultilineMode.AllowForBoth)]
|
||||
public String AccountNumber;
|
||||
|
||||
[FieldTrim(TrimMode.Both),FieldQuoted('"',QuoteMode.OptionalForBoth,MultilineMode.AllowForBoth)]
|
||||
public String WebSite;
|
||||
|
||||
[FieldTrim(TrimMode.Both),FieldQuoted('"',QuoteMode.OptionalForBoth,MultilineMode.AllowForBoth)]
|
||||
public String GeneralNotes;
|
||||
|
||||
[FieldTrim(TrimMode.Both),FieldQuoted('"',QuoteMode.OptionalForBoth,MultilineMode.AllowForBoth)]
|
||||
public String TechNotes;
|
||||
|
||||
[FieldTrim(TrimMode.Both),FieldQuoted('"',QuoteMode.OptionalForBoth,MultilineMode.AllowForBoth)]
|
||||
public String PopupNotes;
|
||||
|
||||
//case 1737
|
||||
[FieldTrim(TrimMode.Both), FieldQuoted('"', QuoteMode.OptionalForBoth, MultilineMode.AllowForBoth)]
|
||||
public String ClientGroup;
|
||||
|
||||
[FieldTrim(TrimMode.Both), FieldQuoted('"', QuoteMode.OptionalForBoth, MultilineMode.AllowForBoth)]
|
||||
public String DispatchZone;
|
||||
|
||||
[FieldTrim(TrimMode.Both), FieldQuoted('"', QuoteMode.OptionalForBoth, MultilineMode.AllowForBoth)]
|
||||
public String Region;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
59
source/Plugins/AyaNova.PlugIn.ImportExportCSV/FHPart.cs
Normal file
59
source/Plugins/AyaNova.PlugIn.ImportExportCSV/FHPart.cs
Normal file
@@ -0,0 +1,59 @@
|
||||
using System;
|
||||
using FileHelpers;
|
||||
|
||||
namespace AyaNova.PlugIn.ImportExportCSV
|
||||
{
|
||||
[DelimitedRecord(","), IgnoreEmptyLines()]
|
||||
public sealed class FHPart
|
||||
{
|
||||
//[FieldTrim(TrimMode.Both),FieldQuoted(MultilineMode.AllowForBoth)]
|
||||
[FieldTrim(TrimMode.Both),FieldQuoted('"',QuoteMode.OptionalForBoth,MultilineMode.AllowForBoth)]
|
||||
public String Name;
|
||||
|
||||
[FieldTrim(TrimMode.Both),FieldQuoted('"',QuoteMode.OptionalForBoth,MultilineMode.AllowForBoth)]
|
||||
public String Number;
|
||||
|
||||
[FieldTrim(TrimMode.Both),FieldQuoted('"',QuoteMode.OptionalForBoth,MultilineMode.AllowForBoth)]
|
||||
public String UnitOfMeasure;
|
||||
|
||||
[FieldTrim(TrimMode.Both),FieldQuoted('"',QuoteMode.OptionalForBoth,MultilineMode.AllowForBoth)]
|
||||
public String Cost;
|
||||
|
||||
[FieldTrim(TrimMode.Both),FieldQuoted('"',QuoteMode.OptionalForBoth,MultilineMode.AllowForBoth)]
|
||||
public String Retail;
|
||||
|
||||
[FieldTrim(TrimMode.Both),FieldQuoted('"',QuoteMode.OptionalForBoth,MultilineMode.AllowForBoth)]
|
||||
public String Category;
|
||||
|
||||
[FieldTrim(TrimMode.Both),FieldQuoted('"',QuoteMode.OptionalForBoth,MultilineMode.AllowForBoth)]
|
||||
public String UPC;
|
||||
|
||||
[FieldTrim(TrimMode.Both),FieldQuoted('"',QuoteMode.OptionalForBoth,MultilineMode.AllowForBoth)]
|
||||
public String TrackSerialNumber;
|
||||
|
||||
[FieldTrim(TrimMode.Both),FieldQuoted('"',QuoteMode.OptionalForBoth,MultilineMode.AllowForBoth)]
|
||||
public String WholeSaler;
|
||||
|
||||
[FieldTrim(TrimMode.Both),FieldQuoted('"',QuoteMode.OptionalForBoth,MultilineMode.AllowForBoth)]
|
||||
public String WholeSalerNumber;
|
||||
|
||||
[FieldTrim(TrimMode.Both),FieldQuoted('"',QuoteMode.OptionalForBoth,MultilineMode.AllowForBoth)]
|
||||
public String AlternativeWholeSaler;
|
||||
|
||||
[FieldTrim(TrimMode.Both),FieldQuoted('"',QuoteMode.OptionalForBoth,MultilineMode.AllowForBoth)]
|
||||
public String AlternativeWholeSalerNumber;
|
||||
|
||||
[FieldTrim(TrimMode.Both),FieldQuoted('"',QuoteMode.OptionalForBoth,MultilineMode.AllowForBoth)]
|
||||
public String Manufacturer;
|
||||
|
||||
[FieldTrim(TrimMode.Both),FieldQuoted('"',QuoteMode.OptionalForBoth,MultilineMode.AllowForBoth)]
|
||||
public String ManufacturerNumber;
|
||||
|
||||
[FieldTrim(TrimMode.Both),FieldQuoted('"',QuoteMode.OptionalForBoth,MultilineMode.AllowForBoth)]
|
||||
public String Notes;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using FileHelpers;
|
||||
|
||||
namespace AyaNova.PlugIn.ImportExportCSV
|
||||
{//case 2072
|
||||
[DelimitedRecord(","),IgnoreEmptyLines()]
|
||||
public sealed class FHPartCategory
|
||||
{
|
||||
[FieldTrim(TrimMode.Both), FieldQuoted('"', QuoteMode.OptionalForBoth, MultilineMode.AllowForBoth)]
|
||||
public String Name;
|
||||
}
|
||||
|
||||
}
|
||||
17
source/Plugins/AyaNova.PlugIn.ImportExportCSV/FHPriority.cs
Normal file
17
source/Plugins/AyaNova.PlugIn.ImportExportCSV/FHPriority.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using FileHelpers;
|
||||
|
||||
namespace AyaNova.PlugIn.ImportExportCSV
|
||||
{//case 2072
|
||||
[DelimitedRecord(","),IgnoreEmptyLines()]
|
||||
public sealed class FHPriority
|
||||
{
|
||||
[FieldTrim(TrimMode.Both), FieldQuoted('"', QuoteMode.OptionalForBoth, MultilineMode.AllowForBoth)]
|
||||
public String Name;
|
||||
|
||||
[FieldTrim(TrimMode.Both), FieldQuoted('"', QuoteMode.OptionalForBoth, MultilineMode.AllowForBoth), FieldOptional()]
|
||||
public String ARGB;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
41
source/Plugins/AyaNova.PlugIn.ImportExportCSV/FHRate.cs
Normal file
41
source/Plugins/AyaNova.PlugIn.ImportExportCSV/FHRate.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using System;
|
||||
using FileHelpers;
|
||||
|
||||
namespace AyaNova.PlugIn.ImportExportCSV
|
||||
{
|
||||
[DelimitedRecord(","), IgnoreEmptyLines()]
|
||||
public sealed class FHRate
|
||||
{
|
||||
[FieldTrim(TrimMode.Both),FieldQuoted('"',QuoteMode.OptionalForBoth, MultilineMode.AllowForBoth)]
|
||||
public String Name;
|
||||
|
||||
[FieldTrim(TrimMode.Both), FieldQuoted('"', QuoteMode.OptionalForBoth, MultilineMode.AllowForBoth), FieldOptional()]
|
||||
public String Description;
|
||||
|
||||
[FieldTrim(TrimMode.Both), FieldQuoted('"', QuoteMode.OptionalForBoth, MultilineMode.AllowForBoth), FieldOptional()]
|
||||
public String AccountNumber;
|
||||
|
||||
[FieldTrim(TrimMode.Both), FieldQuoted('"', QuoteMode.OptionalForBoth, MultilineMode.AllowForBoth), FieldOptional()]
|
||||
public String Cost;
|
||||
|
||||
[FieldTrim(TrimMode.Both), FieldQuoted('"', QuoteMode.OptionalForBoth, MultilineMode.AllowForBoth), FieldOptional()]
|
||||
public String RetailCharge;
|
||||
|
||||
[FieldTrim(TrimMode.Both), FieldQuoted('"', QuoteMode.OptionalForBoth, MultilineMode.AllowForBoth), FieldOptional()]
|
||||
public String ContractRate;
|
||||
|
||||
[FieldTrim(TrimMode.Both), FieldQuoted('"', QuoteMode.OptionalForBoth, MultilineMode.AllowForBoth), FieldOptional()]
|
||||
public String RateType;
|
||||
|
||||
[FieldTrim(TrimMode.Both), FieldQuoted('"', QuoteMode.OptionalForBoth, MultilineMode.AllowForBoth), FieldOptional()]
|
||||
public String UnitChargeDescription;
|
||||
|
||||
[FieldTrim(TrimMode.Both), FieldQuoted('"', QuoteMode.OptionalForBoth, MultilineMode.AllowForBoth), FieldOptional()]
|
||||
public String ClientGroup;
|
||||
|
||||
[FieldTrim(TrimMode.Both), FieldQuoted('"', QuoteMode.OptionalForBoth, MultilineMode.AllowForBoth), FieldOptional()]
|
||||
public String Region;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
42
source/Plugins/AyaNova.PlugIn.ImportExportCSV/FHUnit.cs
Normal file
42
source/Plugins/AyaNova.PlugIn.ImportExportCSV/FHUnit.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using System;
|
||||
using FileHelpers;
|
||||
|
||||
namespace AyaNova.PlugIn.ImportExportCSV
|
||||
{
|
||||
[DelimitedRecord(","),IgnoreEmptyLines()]
|
||||
public sealed class FHUnit
|
||||
{
|
||||
[FieldTrim(TrimMode.Both),FieldQuoted('"',QuoteMode.OptionalForBoth,MultilineMode.AllowForBoth)]
|
||||
public String Serial;
|
||||
|
||||
[FieldTrim(TrimMode.Both),FieldQuoted('"',QuoteMode.OptionalForBoth,MultilineMode.AllowForBoth)]
|
||||
public String Client;
|
||||
|
||||
[FieldTrim(TrimMode.Both),FieldQuoted('"',QuoteMode.OptionalForBoth,MultilineMode.AllowForBoth)]
|
||||
public String UnitModel;
|
||||
|
||||
[FieldTrim(TrimMode.Both),FieldQuoted('"',QuoteMode.OptionalForBoth,MultilineMode.AllowForBoth),FieldOptional()]
|
||||
public String Notes;
|
||||
|
||||
[FieldTrim(TrimMode.Both),FieldQuoted('"',QuoteMode.OptionalForBoth,MultilineMode.AllowForBoth),FieldOptional()]
|
||||
public String PurchasedFromVendor;
|
||||
|
||||
[FieldTrim(TrimMode.Both),FieldQuoted('"',QuoteMode.OptionalForBoth,MultilineMode.AllowForBoth),FieldOptional()]
|
||||
public String SalesReceiptNumber;
|
||||
|
||||
[FieldTrim(TrimMode.Both),FieldQuoted('"',QuoteMode.OptionalForBoth,MultilineMode.AllowForBoth),FieldOptional()]
|
||||
public String PurchasedDate;
|
||||
|
||||
[FieldTrim(TrimMode.Both),FieldQuoted('"',QuoteMode.OptionalForBoth,MultilineMode.AllowForBoth),FieldOptional()]
|
||||
public String Description;
|
||||
|
||||
[FieldTrim(TrimMode.Both),FieldQuoted('"',QuoteMode.OptionalForBoth,MultilineMode.AllowForBoth),FieldOptional()]
|
||||
public String Metered;
|
||||
|
||||
//case 1739
|
||||
[FieldTrim(TrimMode.Both), FieldQuoted('"', QuoteMode.OptionalForBoth, MultilineMode.AllowForBoth), FieldOptional()]
|
||||
public String WarrantyLength;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using FileHelpers;
|
||||
|
||||
namespace AyaNova.PlugIn.ImportExportCSV
|
||||
{//case 2072
|
||||
[DelimitedRecord(","),IgnoreEmptyLines()]
|
||||
public sealed class FHUnitServiceType
|
||||
{
|
||||
[FieldTrim(TrimMode.Both), FieldQuoted('"', QuoteMode.OptionalForBoth, MultilineMode.AllowForBoth)]
|
||||
public String Name;
|
||||
|
||||
[FieldTrim(TrimMode.Both), FieldQuoted('"', QuoteMode.OptionalForBoth, MultilineMode.AllowForBoth), FieldOptional()]
|
||||
public String Description;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using FileHelpers;
|
||||
|
||||
namespace AyaNova.PlugIn.ImportExportCSV
|
||||
{//case 2072
|
||||
[DelimitedRecord(","),IgnoreEmptyLines()]
|
||||
public sealed class FHWorkorderCategory
|
||||
{
|
||||
[FieldTrim(TrimMode.Both), FieldQuoted('"', QuoteMode.OptionalForBoth, MultilineMode.AllowForBoth)]
|
||||
public String Name;
|
||||
|
||||
[FieldTrim(TrimMode.Both), FieldQuoted('"', QuoteMode.OptionalForBoth, MultilineMode.AllowForBoth), FieldOptional()]
|
||||
public String Description;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using FileHelpers;
|
||||
|
||||
namespace AyaNova.PlugIn.ImportExportCSV
|
||||
{//case 2072
|
||||
[DelimitedRecord(","),IgnoreEmptyLines()]
|
||||
public sealed class FHWorkorderItemType
|
||||
{
|
||||
[FieldTrim(TrimMode.Both), FieldQuoted('"', QuoteMode.OptionalForBoth, MultilineMode.AllowForBoth)]
|
||||
public String Name;
|
||||
|
||||
[FieldTrim(TrimMode.Both), FieldQuoted('"', QuoteMode.OptionalForBoth, MultilineMode.AllowForBoth), FieldOptional()]
|
||||
public String Description;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using FileHelpers;
|
||||
|
||||
namespace AyaNova.PlugIn.ImportExportCSV
|
||||
{//case 2072
|
||||
[DelimitedRecord(","),IgnoreEmptyLines()]
|
||||
public sealed class FHWorkorderStatus
|
||||
{
|
||||
[FieldTrim(TrimMode.Both), FieldQuoted('"', QuoteMode.OptionalForBoth, MultilineMode.AllowForBoth)]
|
||||
public String Name;
|
||||
|
||||
[FieldTrim(TrimMode.Both), FieldQuoted('"', QuoteMode.OptionalForBoth, MultilineMode.AllowForBoth), FieldOptional()]
|
||||
public String Description;
|
||||
|
||||
[FieldTrim(TrimMode.Both), FieldQuoted('"', QuoteMode.OptionalForBoth, MultilineMode.AllowForBoth), FieldOptional()]
|
||||
public String ARGB;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
781
source/Plugins/AyaNova.PlugIn.ImportExportCSV/IECSVData.cs
Normal file
781
source/Plugins/AyaNova.PlugIn.ImportExportCSV/IECSVData.cs
Normal file
@@ -0,0 +1,781 @@
|
||||
using System;
|
||||
using System.Xml;
|
||||
using System.IO;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace AyaNova.PlugIn.ImportExportCSV
|
||||
{
|
||||
/// <summary>
|
||||
/// Persistence store for user options etc
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class IECSVData
|
||||
{
|
||||
#region fields
|
||||
|
||||
#region Client
|
||||
private bool _ClientPostalAddress = false;
|
||||
private bool _ClientPhysicalAddress = false;
|
||||
private bool _ClientContact = false;
|
||||
private bool _ClientContactNotes = false;
|
||||
private bool _ClientPhoneNumbers = false;
|
||||
private bool _ClientEmail = false;
|
||||
private bool _ClientWebSite = false;
|
||||
private bool _ClientAccountNumber = false;
|
||||
private bool _ClientNotes = false;
|
||||
private bool _ClientTechNotes = false;
|
||||
private bool _ClientPopupNotes = false;
|
||||
//case 1737
|
||||
private bool _ClientGroup = false;
|
||||
private bool _ClientDispatchZone = false;
|
||||
private bool _ClientRegion = false;
|
||||
|
||||
|
||||
#endregion client
|
||||
|
||||
#region Part
|
||||
private bool _PartName = false;
|
||||
private bool _PartAlternativeWholesaler = false;
|
||||
private bool _PartCategoryID = false;
|
||||
private bool _PartCost = false;
|
||||
private bool _PartManufacturer = false;
|
||||
private bool _PartNotes = false;
|
||||
private bool _PartRetail = false;
|
||||
private bool _PartTrackSerialNumber = false;
|
||||
private bool _PartUnitOfMeasureID = false;
|
||||
private bool _PartUPC = false;
|
||||
private bool _PartWholesaler = false;
|
||||
|
||||
#endregion Part
|
||||
|
||||
#region Unit
|
||||
private bool _UnitClientID = false;
|
||||
private bool _UnitModelID = false;
|
||||
private bool _UnitNotes = false;
|
||||
private bool _UnitPurchasedFromVendor = false;
|
||||
private bool _UnitReceipt = false;
|
||||
private bool _UnitPurchasedDate = false;
|
||||
private bool _UnitDescription = false;
|
||||
private bool _UnitMetered = false;
|
||||
//case 1739
|
||||
private bool _UnitWarrantyLength = false;
|
||||
#endregion unit
|
||||
|
||||
#region Rate
|
||||
private bool _RateDescription = false;
|
||||
private bool _RateAccountNumber = false;
|
||||
private bool _RateCost = false;
|
||||
private bool _RateCharge = false;
|
||||
private bool _RateContractRate = false;
|
||||
private bool _RateType = false;
|
||||
private bool _RateUnitChargeDescription = false;
|
||||
private bool _RateClientGroup = false;
|
||||
private bool _RateRegion = false;
|
||||
#endregion Rate
|
||||
|
||||
//case 1588
|
||||
//save last mappings to restore later
|
||||
#region mappings
|
||||
private string _ClientLastMapping = "";
|
||||
private string _PartLastMapping = "";
|
||||
private string _UnitLastMapping = "";
|
||||
private string _AssemblyLastMapping = "";
|
||||
|
||||
//case 2072
|
||||
private string _WorkorderStatusLastMapping = "";
|
||||
private string _WorkorderCategoryLastMapping = "";
|
||||
private string _WorkorderItemTypeLastMapping = "";
|
||||
private string _UnitServiceTypeLastMapping = "";
|
||||
private string _PriorityLastMapping = "";
|
||||
private string _PartCategoryLastMapping = "";
|
||||
private string _RateLastMapping = "";
|
||||
|
||||
#endregion
|
||||
public bool IsDirty = false;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
#region Client
|
||||
[Browsable(false)]
|
||||
public bool ClientUpdate
|
||||
{
|
||||
get { return _ClientPostalAddress || _ClientPhysicalAddress || _ClientContact || _ClientContactNotes || _ClientPhoneNumbers ||
|
||||
_ClientEmail || _ClientWebSite || _ClientAccountNumber || _ClientNotes || _ClientTechNotes || _ClientPopupNotes ||
|
||||
_ClientGroup || _ClientDispatchZone || _ClientRegion;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[DescriptionAttribute("True=overwrite this field if duplicate record, false=do not overwrite on duplicate"), DefaultValueAttribute(false), CategoryAttribute("Client import")]
|
||||
public bool ClientPostalAddress
|
||||
{
|
||||
get { return _ClientPostalAddress; }
|
||||
set { if (_ClientPostalAddress != value) { _ClientPostalAddress = value; IsDirty = true; } }
|
||||
}
|
||||
|
||||
[DescriptionAttribute("True=overwrite this field if duplicate record, false=do not overwrite on duplicate"), DefaultValueAttribute(false), CategoryAttribute("Client import")]
|
||||
public bool ClientPhysicalAddress
|
||||
{
|
||||
get { return _ClientPhysicalAddress; }
|
||||
set { if (_ClientPhysicalAddress != value) { _ClientPhysicalAddress = value; IsDirty = true; } }
|
||||
}
|
||||
|
||||
|
||||
[DescriptionAttribute("True=overwrite this field if duplicate record, false=do not overwrite on duplicate"), DefaultValueAttribute(false), CategoryAttribute("Client import")]
|
||||
public bool ClientContact
|
||||
{
|
||||
get { return _ClientContact; }
|
||||
set { if (_ClientContact != value) { _ClientContact = value; IsDirty = true; } }
|
||||
}
|
||||
|
||||
|
||||
[DescriptionAttribute("True=overwrite this field if duplicate record, false=do not overwrite on duplicate"), DefaultValueAttribute(false), CategoryAttribute("Client import")]
|
||||
public bool ClientContactNotes
|
||||
{
|
||||
get { return _ClientContactNotes; }
|
||||
set { if (_ClientContactNotes != value) { _ClientContactNotes = value; IsDirty = true; } }
|
||||
}
|
||||
|
||||
[DescriptionAttribute("True=overwrite this field if duplicate record, false=do not overwrite on duplicate"), DefaultValueAttribute(false), CategoryAttribute("Client import")]
|
||||
public bool ClientPhoneNumbers
|
||||
{
|
||||
get { return _ClientPhoneNumbers; }
|
||||
set { if (_ClientPhoneNumbers != value) { _ClientPhoneNumbers = value; IsDirty = true; } }
|
||||
}
|
||||
|
||||
|
||||
[DescriptionAttribute("True=overwrite this field if duplicate record, false=do not overwrite on duplicate"), DefaultValueAttribute(false), CategoryAttribute("Client import")]
|
||||
public bool ClientEmail
|
||||
{
|
||||
get { return _ClientEmail; }
|
||||
set { if (_ClientEmail != value) { _ClientEmail = value; IsDirty = true; } }
|
||||
}
|
||||
|
||||
|
||||
[DescriptionAttribute("True=overwrite this field if duplicate record, false=do not overwrite on duplicate"), DefaultValueAttribute(false), CategoryAttribute("Client import")]
|
||||
public bool ClientWebSite
|
||||
{
|
||||
get { return _ClientWebSite; }
|
||||
set { if (_ClientWebSite != value) { _ClientWebSite = value; IsDirty = true; } }
|
||||
}
|
||||
|
||||
|
||||
[DescriptionAttribute("True=overwrite this field if duplicate record, false=do not overwrite on duplicate"), DefaultValueAttribute(false), CategoryAttribute("Client import")]
|
||||
public bool ClientAccountNumber
|
||||
{
|
||||
get { return _ClientAccountNumber; }
|
||||
set { if (_ClientAccountNumber != value) { _ClientAccountNumber = value; IsDirty = true; } }
|
||||
}
|
||||
|
||||
|
||||
[DescriptionAttribute("True=overwrite this field if duplicate record, false=do not overwrite on duplicate"), DefaultValueAttribute(false), CategoryAttribute("Client import")]
|
||||
public bool ClientNotes
|
||||
{
|
||||
get { return _ClientNotes; }
|
||||
set { if (_ClientNotes != value) { _ClientNotes = value; IsDirty = true; } }
|
||||
}
|
||||
|
||||
|
||||
[DescriptionAttribute("True=overwrite this field if duplicate record, false=do not overwrite on duplicate"), DefaultValueAttribute(false), CategoryAttribute("Client import")]
|
||||
public bool ClientTechNotes
|
||||
{
|
||||
get { return _ClientTechNotes; }
|
||||
set { if (_ClientTechNotes != value) { _ClientTechNotes = value; IsDirty = true; } }
|
||||
}
|
||||
|
||||
|
||||
[DescriptionAttribute("True=overwrite this field if duplicate record, false=do not overwrite on duplicate"), DefaultValueAttribute(false), CategoryAttribute("Client import")]
|
||||
public bool ClientPopupNotes
|
||||
{
|
||||
get { return _ClientPopupNotes; }
|
||||
set { if (_ClientPopupNotes != value) { _ClientPopupNotes = value; IsDirty = true; } }
|
||||
}
|
||||
|
||||
//case 1737
|
||||
[DescriptionAttribute("True=overwrite this field if duplicate record, false=do not overwrite on duplicate"), DefaultValueAttribute(false), CategoryAttribute("Client import")]
|
||||
public bool ClientGroup
|
||||
{
|
||||
get { return _ClientGroup; }
|
||||
set { if (_ClientGroup != value) { _ClientGroup = value; IsDirty = true; } }
|
||||
}
|
||||
|
||||
[DescriptionAttribute("True=overwrite this field if duplicate record, false=do not overwrite on duplicate"), DefaultValueAttribute(false), CategoryAttribute("Client import")]
|
||||
public bool ClientDispatchZone
|
||||
{
|
||||
get { return _ClientDispatchZone; }
|
||||
set { if (_ClientDispatchZone != value) { _ClientDispatchZone = value; IsDirty = true; } }
|
||||
}
|
||||
|
||||
[DescriptionAttribute("True=overwrite this field if duplicate record, false=do not overwrite on duplicate"), DefaultValueAttribute(false), CategoryAttribute("Client import")]
|
||||
public bool ClientRegion
|
||||
{
|
||||
get { return _ClientRegion; }
|
||||
set { if (_ClientRegion != value) { _ClientRegion = value; IsDirty = true; } }
|
||||
}
|
||||
#endregion client
|
||||
|
||||
#region Part
|
||||
|
||||
[Browsable(false)]
|
||||
public bool PartUpdate
|
||||
{
|
||||
get { return _PartName || _PartAlternativeWholesaler || _PartCategoryID || _PartCost || _PartManufacturer ||
|
||||
_PartNotes || _PartRetail || _PartTrackSerialNumber || _PartUnitOfMeasureID || _PartUPC || _PartWholesaler;
|
||||
}
|
||||
}
|
||||
|
||||
[DescriptionAttribute("True=overwrite this field if duplicate record, false=do not overwrite on duplicate"), DefaultValueAttribute(false), CategoryAttribute("Part import")]
|
||||
public bool PartName
|
||||
{
|
||||
get { return _PartName; }
|
||||
set { if (_PartName != value) { _PartName = value; IsDirty = true; } }
|
||||
}
|
||||
|
||||
|
||||
[DescriptionAttribute("True=overwrite this field if duplicate record, false=do not overwrite on duplicate"), DefaultValueAttribute(false), CategoryAttribute("Part import")]
|
||||
public bool PartAlternativeWholesaler
|
||||
{
|
||||
get { return _PartAlternativeWholesaler; }
|
||||
set { if (_PartAlternativeWholesaler != value) { _PartAlternativeWholesaler = value; IsDirty = true; } }
|
||||
}
|
||||
|
||||
|
||||
[DescriptionAttribute("True=overwrite this field if duplicate record, false=do not overwrite on duplicate"), DefaultValueAttribute(false), CategoryAttribute("Part import")]
|
||||
public bool PartCategoryID
|
||||
{
|
||||
get { return _PartCategoryID; }
|
||||
set { if (_PartCategoryID != value) { _PartCategoryID = value; IsDirty = true; } }
|
||||
}
|
||||
|
||||
|
||||
[DescriptionAttribute("True=overwrite this field if duplicate record, false=do not overwrite on duplicate"), DefaultValueAttribute(false), CategoryAttribute("Part import")]
|
||||
public bool PartCost
|
||||
{
|
||||
get { return _PartCost; }
|
||||
set { if (_PartCost != value) { _PartCost = value; IsDirty = true; } }
|
||||
}
|
||||
|
||||
|
||||
[DescriptionAttribute("True=overwrite this field if duplicate record, false=do not overwrite on duplicate"), DefaultValueAttribute(false), CategoryAttribute("Part import")]
|
||||
public bool PartManufacturer
|
||||
{
|
||||
get { return _PartManufacturer; }
|
||||
set { if (_PartManufacturer != value) { _PartManufacturer = value; IsDirty = true; } }
|
||||
}
|
||||
|
||||
|
||||
[DescriptionAttribute("True=overwrite this field if duplicate record, false=do not overwrite on duplicate"), DefaultValueAttribute(false), CategoryAttribute("Part import")]
|
||||
public bool PartNotes
|
||||
{
|
||||
get { return _PartNotes; }
|
||||
set { if (_PartNotes != value) { _PartNotes = value; IsDirty = true; } }
|
||||
}
|
||||
|
||||
[DescriptionAttribute("True=overwrite this field if duplicate record, false=do not overwrite on duplicate"), DefaultValueAttribute(false), CategoryAttribute("Part import")]
|
||||
public bool PartRetail
|
||||
{
|
||||
get { return _PartRetail; }
|
||||
set { if (_PartRetail != value) { _PartRetail = value; IsDirty = true; } }
|
||||
}
|
||||
|
||||
[DescriptionAttribute("True=overwrite this field if duplicate record, false=do not overwrite on duplicate"), DefaultValueAttribute(false), CategoryAttribute("Part import")]
|
||||
public bool PartTrackSerialNumber
|
||||
{
|
||||
get { return _PartTrackSerialNumber; }
|
||||
set { if (_PartTrackSerialNumber != value) { _PartTrackSerialNumber = value; IsDirty = true; } }
|
||||
}
|
||||
|
||||
|
||||
[DescriptionAttribute("True=overwrite this field if duplicate record, false=do not overwrite on duplicate"), DefaultValueAttribute(false), CategoryAttribute("Part import")]
|
||||
public bool PartUnitOfMeasureID
|
||||
{
|
||||
get { return _PartUnitOfMeasureID; }
|
||||
set { if (_PartUnitOfMeasureID != value) { _PartUnitOfMeasureID = value; IsDirty = true; } }
|
||||
}
|
||||
|
||||
|
||||
[DescriptionAttribute("True=overwrite this field if duplicate record, false=do not overwrite on duplicate"), DefaultValueAttribute(false), CategoryAttribute("Part import")]
|
||||
public bool PartUPC
|
||||
{
|
||||
get { return _PartUPC; }
|
||||
set { if (_PartUPC != value) { _PartUPC = value; IsDirty = true; } }
|
||||
}
|
||||
|
||||
|
||||
[DescriptionAttribute("True=overwrite this field if duplicate record, false=do not overwrite on duplicate"), DefaultValueAttribute(false), CategoryAttribute("Part import")]
|
||||
public bool PartWholesaler
|
||||
{
|
||||
get { return _PartWholesaler; }
|
||||
set { if (_PartWholesaler != value) { _PartWholesaler = value; IsDirty = true; } }
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endregion Part
|
||||
|
||||
#region Unit
|
||||
[Browsable(false)]
|
||||
public bool UnitUpdate
|
||||
{
|
||||
get { return _UnitClientID || _UnitModelID || _UnitNotes || _UnitPurchasedFromVendor || _UnitReceipt || _UnitPurchasedDate ||
|
||||
_UnitDescription || _UnitMetered || _UnitWarrantyLength;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
[DescriptionAttribute("True=overwrite this field if duplicate record, false=do not overwrite on duplicate"), DefaultValueAttribute(false), CategoryAttribute("Unit import")]
|
||||
public bool UnitClientID
|
||||
{
|
||||
get { return _UnitClientID; }
|
||||
set { if (_UnitClientID != value) { _UnitClientID = value; IsDirty = true; } }
|
||||
}
|
||||
|
||||
[DescriptionAttribute("True=overwrite this field if duplicate record, false=do not overwrite on duplicate"), DefaultValueAttribute(false), CategoryAttribute("Unit import")]
|
||||
public bool UnitModelID
|
||||
{
|
||||
get { return _UnitModelID; }
|
||||
set { if (_UnitModelID != value) { _UnitModelID = value; IsDirty = true; } }
|
||||
}
|
||||
|
||||
[DescriptionAttribute("True=overwrite this field if duplicate record, false=do not overwrite on duplicate"), DefaultValueAttribute(false), CategoryAttribute("Unit import")]
|
||||
public bool UnitNotes
|
||||
{
|
||||
get { return _UnitNotes; }
|
||||
set { if (_UnitNotes != value) { _UnitNotes = value; IsDirty = true; } }
|
||||
}
|
||||
|
||||
[DescriptionAttribute("True=overwrite this field if duplicate record, false=do not overwrite on duplicate"), DefaultValueAttribute(false), CategoryAttribute("Unit import")]
|
||||
public bool UnitPurchasedFromVendor
|
||||
{
|
||||
get { return _UnitPurchasedFromVendor; }
|
||||
set { if (_UnitPurchasedFromVendor != value) { _UnitPurchasedFromVendor = value; IsDirty = true; } }
|
||||
}
|
||||
|
||||
[DescriptionAttribute("True=overwrite this field if duplicate record, false=do not overwrite on duplicate"), DefaultValueAttribute(false), CategoryAttribute("Unit import")]
|
||||
public bool UnitReceipt
|
||||
{
|
||||
get { return _UnitReceipt; }
|
||||
set { if (_UnitReceipt != value) { _UnitReceipt = value; IsDirty = true; } }
|
||||
}
|
||||
|
||||
[DescriptionAttribute("True=overwrite this field if duplicate record, false=do not overwrite on duplicate"), DefaultValueAttribute(false), CategoryAttribute("Unit import")]
|
||||
public bool UnitPurchasedDate
|
||||
{
|
||||
get { return _UnitPurchasedDate; }
|
||||
set { if (_UnitPurchasedDate != value) { _UnitPurchasedDate = value; IsDirty = true; } }
|
||||
}
|
||||
|
||||
[DescriptionAttribute("True=overwrite this field if duplicate record, false=do not overwrite on duplicate"), DefaultValueAttribute(false), CategoryAttribute("Unit import")]
|
||||
public bool UnitDescription
|
||||
{
|
||||
get { return _UnitDescription; }
|
||||
set { if (_UnitDescription != value) { _UnitDescription = value; IsDirty = true; } }
|
||||
}
|
||||
|
||||
[DescriptionAttribute("True=overwrite this field if duplicate record, false=do not overwrite on duplicate"), DefaultValueAttribute(false), CategoryAttribute("Unit import")]
|
||||
public bool UnitMetered
|
||||
{
|
||||
|
||||
get { return _UnitMetered; }
|
||||
set { if (_UnitMetered != value) { _UnitMetered = value; IsDirty = true; } }
|
||||
}
|
||||
|
||||
//case 1739
|
||||
[DescriptionAttribute("True=overwrite this field if duplicate record, false=do not overwrite on duplicate"), DefaultValueAttribute(false), CategoryAttribute("Unit import")]
|
||||
public bool UnitWarrantyLength
|
||||
{
|
||||
|
||||
get { return _UnitWarrantyLength; }
|
||||
set { if (_UnitWarrantyLength != value) { _UnitWarrantyLength = value; IsDirty = true; } }
|
||||
}
|
||||
|
||||
#endregion Unit
|
||||
|
||||
#region Rate
|
||||
[Browsable(false)]
|
||||
public bool RateUpdate
|
||||
{
|
||||
get
|
||||
{
|
||||
return _RateDescription || _RateAccountNumber || _RateCost || _RateCharge || _RateContractRate ||
|
||||
_RateType || _RateUnitChargeDescription || _RateAccountNumber || _RateClientGroup || _RateRegion;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[DescriptionAttribute("True=overwrite this field if duplicate record, false=do not overwrite on duplicate"), DefaultValueAttribute(false), CategoryAttribute("Rate import")]
|
||||
public bool RateDescription
|
||||
{
|
||||
get { return _RateDescription; }
|
||||
set { if (_RateDescription != value) { _RateDescription = value; IsDirty = true; } }
|
||||
}
|
||||
|
||||
[DescriptionAttribute("True=overwrite this field if duplicate record, false=do not overwrite on duplicate"), DefaultValueAttribute(false), CategoryAttribute("Rate import")]
|
||||
public bool RateAccountNumber
|
||||
{
|
||||
get { return _RateAccountNumber; }
|
||||
set { if (_RateAccountNumber != value) { _RateAccountNumber = value; IsDirty = true; } }
|
||||
}
|
||||
|
||||
|
||||
[DescriptionAttribute("True=overwrite this field if duplicate record, false=do not overwrite on duplicate"), DefaultValueAttribute(false), CategoryAttribute("Rate import")]
|
||||
public bool RateCost
|
||||
{
|
||||
get { return _RateCost; }
|
||||
set { if (_RateCost != value) { _RateCost = value; IsDirty = true; } }
|
||||
}
|
||||
|
||||
|
||||
[DescriptionAttribute("True=overwrite this field if duplicate record, false=do not overwrite on duplicate"), DefaultValueAttribute(false), CategoryAttribute("Rate import")]
|
||||
public bool RateCharge
|
||||
{
|
||||
get { return _RateCharge; }
|
||||
set { if (_RateCharge != value) { _RateCharge = value; IsDirty = true; } }
|
||||
}
|
||||
|
||||
[DescriptionAttribute("True=overwrite this field if duplicate record, false=do not overwrite on duplicate"), DefaultValueAttribute(false), CategoryAttribute("Rate import")]
|
||||
public bool RateContractRate
|
||||
{
|
||||
get { return _RateContractRate; }
|
||||
set { if (_RateContractRate != value) { _RateContractRate = value; IsDirty = true; } }
|
||||
}
|
||||
|
||||
|
||||
[DescriptionAttribute("True=overwrite this field if duplicate record, false=do not overwrite on duplicate"), DefaultValueAttribute(false), CategoryAttribute("Rate import")]
|
||||
public bool RateType
|
||||
{
|
||||
get { return _RateType; }
|
||||
set { if (_RateType != value) { _RateType = value; IsDirty = true; } }
|
||||
}
|
||||
|
||||
|
||||
[DescriptionAttribute("True=overwrite this field if duplicate record, false=do not overwrite on duplicate"), DefaultValueAttribute(false), CategoryAttribute("Rate import")]
|
||||
public bool RateUnitChargeDescription
|
||||
{
|
||||
get { return _RateUnitChargeDescription; }
|
||||
set { if (_RateUnitChargeDescription != value) { _RateUnitChargeDescription = value; IsDirty = true; } }
|
||||
}
|
||||
|
||||
|
||||
[DescriptionAttribute("True=overwrite this field if duplicate record, false=do not overwrite on duplicate"), DefaultValueAttribute(false), CategoryAttribute("Rate import")]
|
||||
public bool RateClientGroup
|
||||
{
|
||||
get { return _RateClientGroup; }
|
||||
set { if (_RateClientGroup != value) { _RateClientGroup = value; IsDirty = true; } }
|
||||
}
|
||||
|
||||
|
||||
[DescriptionAttribute("True=overwrite this field if duplicate record, false=do not overwrite on duplicate"), DefaultValueAttribute(false), CategoryAttribute("Rate import")]
|
||||
public bool RateRegion
|
||||
{
|
||||
get { return _RateRegion; }
|
||||
set { if (_RateRegion != value) { _RateRegion = value; IsDirty = true; } }
|
||||
}
|
||||
#endregion Rate
|
||||
|
||||
|
||||
#region Mappings case 1588
|
||||
[Browsable(false)]
|
||||
public string ClientLastMapping { get { return _ClientLastMapping; } set { if (_ClientLastMapping != value) _ClientLastMapping = value; IsDirty = true; } }
|
||||
|
||||
[Browsable(false)]
|
||||
public string PartLastMapping { get { return _PartLastMapping; } set { if (_PartLastMapping != value) _PartLastMapping = value; IsDirty = true; } }
|
||||
|
||||
[Browsable(false)]
|
||||
public string UnitLastMapping { get { return _UnitLastMapping; } set { if (_UnitLastMapping != value) _UnitLastMapping = value; IsDirty = true; } }
|
||||
|
||||
[Browsable(false)]
|
||||
public string AssemblyLastMapping { get { return _AssemblyLastMapping; } set { if (_AssemblyLastMapping != value) _AssemblyLastMapping = value; IsDirty = true; } }
|
||||
|
||||
//case 2072
|
||||
[Browsable(false)]
|
||||
public string WorkorderStatusLastMapping { get { return _WorkorderStatusLastMapping; } set { if (_WorkorderStatusLastMapping != value) _WorkorderStatusLastMapping = value; IsDirty = true; } }
|
||||
|
||||
[Browsable(false)]
|
||||
public string WorkorderCategoryLastMapping { get { return _WorkorderCategoryLastMapping; } set { if (_WorkorderCategoryLastMapping != value) _WorkorderCategoryLastMapping = value; IsDirty = true; } }
|
||||
|
||||
[Browsable(false)]
|
||||
public string WorkorderItemTypeLastMapping { get { return _WorkorderItemTypeLastMapping; } set { if (_WorkorderItemTypeLastMapping != value) _WorkorderItemTypeLastMapping = value; IsDirty = true; } }
|
||||
|
||||
[Browsable(false)]
|
||||
public string UnitServiceTypeLastMapping { get { return _UnitServiceTypeLastMapping; } set { if (_UnitServiceTypeLastMapping != value) _UnitServiceTypeLastMapping = value; IsDirty = true; } }
|
||||
|
||||
[Browsable(false)]
|
||||
public string PriorityLastMapping { get { return _PriorityLastMapping; } set { if (_PriorityLastMapping != value) _PriorityLastMapping = value; IsDirty = true; } }
|
||||
|
||||
[Browsable(false)]
|
||||
public string PartCategoryLastMapping { get { return _PartCategoryLastMapping; } set { if (_PartCategoryLastMapping != value) _PartCategoryLastMapping = value; IsDirty = true; } }
|
||||
|
||||
[Browsable(false)]
|
||||
public string RateLastMapping { get { return _RateLastMapping; } set { if (_RateLastMapping != value) _RateLastMapping = value; IsDirty = true; } }
|
||||
|
||||
|
||||
|
||||
#endregion case 1588
|
||||
|
||||
#endregion props
|
||||
|
||||
public IECSVData()
|
||||
{
|
||||
//
|
||||
// TODO: Add constructor logic here
|
||||
//
|
||||
}
|
||||
|
||||
#region XML in/out
|
||||
|
||||
/// <summary>
|
||||
/// Set - Sets the fields in this object based on the contents of the xml string
|
||||
/// Get - Get's the fields of this object in the format of an xml string
|
||||
/// </summary>
|
||||
[BrowsableAttribute(false)]
|
||||
public string XMLData
|
||||
{
|
||||
get
|
||||
{
|
||||
System.Text.StringBuilder sb = new System.Text.StringBuilder();
|
||||
System.Xml.XmlTextWriter w = new System.Xml.XmlTextWriter(new StringWriter(sb));
|
||||
w.Formatting = System.Xml.Formatting.Indented;
|
||||
w.WriteStartDocument(true);
|
||||
w.WriteStartElement("ImportExportCSVSettings");
|
||||
|
||||
#region Client
|
||||
// w.WriteElementString("ClientUpdate", XmlConvert.ToString(_ClientUpdate));
|
||||
w.WriteElementString("ClientPostalAddress", XmlConvert.ToString(_ClientPostalAddress));
|
||||
w.WriteElementString("ClientPhysicalAddress", XmlConvert.ToString(_ClientPhysicalAddress));
|
||||
w.WriteElementString("ClientContact", XmlConvert.ToString(_ClientContact));
|
||||
w.WriteElementString("ClientContactNotes", XmlConvert.ToString(_ClientContactNotes));
|
||||
w.WriteElementString("ClientPhoneNumbers", XmlConvert.ToString(_ClientPhoneNumbers));
|
||||
w.WriteElementString("ClientEmail", XmlConvert.ToString(_ClientEmail));
|
||||
w.WriteElementString("ClientWebSite", XmlConvert.ToString(_ClientWebSite));
|
||||
w.WriteElementString("ClientAccountNumber", XmlConvert.ToString(_ClientAccountNumber));
|
||||
w.WriteElementString("ClientNotes", XmlConvert.ToString(_ClientNotes));
|
||||
w.WriteElementString("ClientTechNotes", XmlConvert.ToString(_ClientTechNotes));
|
||||
w.WriteElementString("ClientPopupNotes", XmlConvert.ToString(_ClientPopupNotes));
|
||||
|
||||
//case 1737
|
||||
w.WriteElementString("ClientGroup", XmlConvert.ToString(_ClientGroup));
|
||||
w.WriteElementString("ClientDispatchZone", XmlConvert.ToString(_ClientDispatchZone));
|
||||
w.WriteElementString("ClientRegion", XmlConvert.ToString(_ClientRegion));
|
||||
#endregion client
|
||||
|
||||
#region Part
|
||||
w.WriteElementString("PartName", XmlConvert.ToString(_PartName));
|
||||
w.WriteElementString("PartAlternativeWholesaler", XmlConvert.ToString(_PartAlternativeWholesaler));
|
||||
w.WriteElementString("PartCategoryID", XmlConvert.ToString(_PartCategoryID));
|
||||
w.WriteElementString("PartCost", XmlConvert.ToString(_PartCost));
|
||||
w.WriteElementString("PartManufacturer", XmlConvert.ToString(_PartManufacturer));
|
||||
w.WriteElementString("PartNotes", XmlConvert.ToString(_PartNotes));
|
||||
w.WriteElementString("PartRetail", XmlConvert.ToString(_PartRetail));
|
||||
w.WriteElementString("PartTrackSerialNumber", XmlConvert.ToString(_PartTrackSerialNumber));
|
||||
w.WriteElementString("PartUnitOfMeasureID", XmlConvert.ToString(_PartUnitOfMeasureID));
|
||||
w.WriteElementString("PartUPC", XmlConvert.ToString(_PartUPC));
|
||||
w.WriteElementString("PartWholesaler", XmlConvert.ToString(_PartWholesaler));
|
||||
//w.WriteElementString("PartUpdate", XmlConvert.ToString(_PartUpdate));
|
||||
|
||||
#endregion Part
|
||||
|
||||
#region Unit
|
||||
//w.WriteElementString("UnitUpdate", XmlConvert.ToString(_UnitUpdate));
|
||||
w.WriteElementString("UnitClientID", XmlConvert.ToString(_UnitClientID));
|
||||
w.WriteElementString("UnitModelID", XmlConvert.ToString(_UnitModelID));
|
||||
w.WriteElementString("UnitNotes", XmlConvert.ToString(_UnitNotes));
|
||||
w.WriteElementString("UnitPurchasedFromVendor", XmlConvert.ToString(_UnitPurchasedFromVendor));
|
||||
w.WriteElementString("UnitReceipt", XmlConvert.ToString(_UnitReceipt));
|
||||
w.WriteElementString("UnitPurchasedDate", XmlConvert.ToString(_UnitPurchasedDate));
|
||||
w.WriteElementString("UnitDescription", XmlConvert.ToString(_UnitDescription));
|
||||
w.WriteElementString("UnitMetered", XmlConvert.ToString(_UnitMetered));
|
||||
|
||||
//case 1739
|
||||
w.WriteElementString("UnitWarrantyLength", XmlConvert.ToString(_UnitWarrantyLength));
|
||||
|
||||
#endregion unit
|
||||
|
||||
//case 2072
|
||||
#region Rate
|
||||
w.WriteElementString("RateDescription", XmlConvert.ToString(_RateDescription));
|
||||
w.WriteElementString("RateAccountNumber", XmlConvert.ToString(_RateAccountNumber));
|
||||
w.WriteElementString("RateCost", XmlConvert.ToString(_RateCost));
|
||||
w.WriteElementString("RateCharge", XmlConvert.ToString(_RateCharge));
|
||||
w.WriteElementString("RateContractRate", XmlConvert.ToString(_RateContractRate));
|
||||
w.WriteElementString("RateType", XmlConvert.ToString(_RateType));
|
||||
w.WriteElementString("RateUnitChargeDescription", XmlConvert.ToString(_RateUnitChargeDescription));
|
||||
w.WriteElementString("RateAccountNumber", XmlConvert.ToString(_RateAccountNumber));
|
||||
w.WriteElementString("RateClientGroup", XmlConvert.ToString(_RateClientGroup));
|
||||
w.WriteElementString("RateRegion", XmlConvert.ToString(_RateRegion));
|
||||
#endregion Rate
|
||||
|
||||
|
||||
#region Mappings
|
||||
w.WriteElementString("ClientLastMapping", _ClientLastMapping);
|
||||
w.WriteElementString("PartLastMapping", _PartLastMapping);
|
||||
w.WriteElementString("UnitLastMapping", _UnitLastMapping);
|
||||
w.WriteElementString("AssemblyLastMapping", _AssemblyLastMapping);
|
||||
//case 2072
|
||||
w.WriteElementString("WorkorderStatusLastMapping", _WorkorderStatusLastMapping);
|
||||
w.WriteElementString("WorkorderCategoryLastMapping", _WorkorderCategoryLastMapping);
|
||||
w.WriteElementString("WorkorderItemTypeLastMapping", _WorkorderItemTypeLastMapping);
|
||||
w.WriteElementString("UnitServiceTypeLastMapping", _UnitServiceTypeLastMapping);
|
||||
w.WriteElementString("PriorityLastMapping", _PriorityLastMapping);
|
||||
w.WriteElementString("PartCategoryLastMapping", _PartCategoryLastMapping);
|
||||
w.WriteElementString("RateLastMapping", _RateLastMapping);
|
||||
#endregion mappings
|
||||
|
||||
w.WriteEndElement();
|
||||
w.WriteEndDocument();
|
||||
w.Flush();
|
||||
w.Close();
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
set
|
||||
{
|
||||
// Load the XML file.
|
||||
XmlDocument xmldoc = new XmlDocument();
|
||||
try
|
||||
{
|
||||
xmldoc.LoadXml(value);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new ApplicationException("Error: exception in ImportExportCSVSettings::XMLData.set()->LoadXml:\r\n." + ex.Message, ex.InnerException);
|
||||
|
||||
}
|
||||
|
||||
#region Client
|
||||
//_ClientUpdate = XmlConvert.ToBoolean(xmldoc.SelectSingleNode("/ImportExportCSVSettings/ClientUpdate").InnerText);
|
||||
_ClientPostalAddress = XmlConvert.ToBoolean(xmldoc.SelectSingleNode("/ImportExportCSVSettings/ClientPostalAddress").InnerText);
|
||||
_ClientPhysicalAddress = XmlConvert.ToBoolean(xmldoc.SelectSingleNode("/ImportExportCSVSettings/ClientPhysicalAddress").InnerText);
|
||||
_ClientContact = XmlConvert.ToBoolean(xmldoc.SelectSingleNode("/ImportExportCSVSettings/ClientContact").InnerText);
|
||||
_ClientContactNotes = XmlConvert.ToBoolean(xmldoc.SelectSingleNode("/ImportExportCSVSettings/ClientContactNotes").InnerText);
|
||||
_ClientPhoneNumbers = XmlConvert.ToBoolean(xmldoc.SelectSingleNode("/ImportExportCSVSettings/ClientPhoneNumbers").InnerText);
|
||||
_ClientEmail = XmlConvert.ToBoolean(xmldoc.SelectSingleNode("/ImportExportCSVSettings/ClientEmail").InnerText);
|
||||
_ClientWebSite = XmlConvert.ToBoolean(xmldoc.SelectSingleNode("/ImportExportCSVSettings/ClientWebSite").InnerText);
|
||||
_ClientAccountNumber = XmlConvert.ToBoolean(xmldoc.SelectSingleNode("/ImportExportCSVSettings/ClientAccountNumber").InnerText);
|
||||
_ClientNotes = XmlConvert.ToBoolean(xmldoc.SelectSingleNode("/ImportExportCSVSettings/ClientNotes").InnerText);
|
||||
_ClientTechNotes = XmlConvert.ToBoolean(xmldoc.SelectSingleNode("/ImportExportCSVSettings/ClientTechNotes").InnerText);
|
||||
_ClientPopupNotes = XmlConvert.ToBoolean(xmldoc.SelectSingleNode("/ImportExportCSVSettings/ClientPopupNotes").InnerText);
|
||||
|
||||
//case 1737 new fields
|
||||
if (xmldoc.SelectSingleNode("/ImportExportCSVSettings/ClientGroup") != null)
|
||||
{
|
||||
_ClientGroup = XmlConvert.ToBoolean(xmldoc.SelectSingleNode("/ImportExportCSVSettings/ClientGroup").InnerText);
|
||||
_ClientDispatchZone = XmlConvert.ToBoolean(xmldoc.SelectSingleNode("/ImportExportCSVSettings/ClientDispatchZone").InnerText);
|
||||
_ClientRegion = XmlConvert.ToBoolean(xmldoc.SelectSingleNode("/ImportExportCSVSettings/ClientRegion").InnerText);
|
||||
|
||||
}
|
||||
#endregion client
|
||||
|
||||
#region Part
|
||||
_PartName = XmlConvert.ToBoolean(xmldoc.SelectSingleNode("/ImportExportCSVSettings/PartName").InnerText);
|
||||
_PartAlternativeWholesaler = XmlConvert.ToBoolean(xmldoc.SelectSingleNode("/ImportExportCSVSettings/PartAlternativeWholesaler").InnerText);
|
||||
_PartCategoryID = XmlConvert.ToBoolean(xmldoc.SelectSingleNode("/ImportExportCSVSettings/PartCategoryID").InnerText);
|
||||
_PartCost = XmlConvert.ToBoolean(xmldoc.SelectSingleNode("/ImportExportCSVSettings/PartCost").InnerText);
|
||||
_PartManufacturer = XmlConvert.ToBoolean(xmldoc.SelectSingleNode("/ImportExportCSVSettings/PartManufacturer").InnerText);
|
||||
_PartNotes = XmlConvert.ToBoolean(xmldoc.SelectSingleNode("/ImportExportCSVSettings/PartNotes").InnerText);
|
||||
_PartRetail = XmlConvert.ToBoolean(xmldoc.SelectSingleNode("/ImportExportCSVSettings/PartRetail").InnerText);
|
||||
_PartTrackSerialNumber = XmlConvert.ToBoolean(xmldoc.SelectSingleNode("/ImportExportCSVSettings/PartTrackSerialNumber").InnerText);
|
||||
_PartUnitOfMeasureID = XmlConvert.ToBoolean(xmldoc.SelectSingleNode("/ImportExportCSVSettings/PartUnitOfMeasureID").InnerText);
|
||||
_PartUPC = XmlConvert.ToBoolean(xmldoc.SelectSingleNode("/ImportExportCSVSettings/PartUPC").InnerText);
|
||||
_PartWholesaler = XmlConvert.ToBoolean(xmldoc.SelectSingleNode("/ImportExportCSVSettings/PartWholesaler").InnerText);
|
||||
//_PartUpdate = XmlConvert.ToBoolean(xmldoc.SelectSingleNode("/ImportExportCSVSettings/PartUpdate").InnerText);
|
||||
|
||||
#endregion Part
|
||||
|
||||
#region Unit
|
||||
//_UnitUpdate = XmlConvert.ToBoolean(xmldoc.SelectSingleNode("/ImportExportCSVSettings/UnitUpdate").InnerText);
|
||||
_UnitClientID = XmlConvert.ToBoolean(xmldoc.SelectSingleNode("/ImportExportCSVSettings/UnitClientID").InnerText);
|
||||
_UnitModelID = XmlConvert.ToBoolean(xmldoc.SelectSingleNode("/ImportExportCSVSettings/UnitModelID").InnerText);
|
||||
_UnitNotes = XmlConvert.ToBoolean(xmldoc.SelectSingleNode("/ImportExportCSVSettings/UnitNotes").InnerText);
|
||||
_UnitPurchasedFromVendor = XmlConvert.ToBoolean(xmldoc.SelectSingleNode("/ImportExportCSVSettings/UnitPurchasedFromVendor").InnerText);
|
||||
_UnitReceipt = XmlConvert.ToBoolean(xmldoc.SelectSingleNode("/ImportExportCSVSettings/UnitReceipt").InnerText);
|
||||
_UnitPurchasedDate = XmlConvert.ToBoolean(xmldoc.SelectSingleNode("/ImportExportCSVSettings/UnitPurchasedDate").InnerText);
|
||||
_UnitDescription = XmlConvert.ToBoolean(xmldoc.SelectSingleNode("/ImportExportCSVSettings/UnitDescription").InnerText);
|
||||
_UnitMetered = XmlConvert.ToBoolean(xmldoc.SelectSingleNode("/ImportExportCSVSettings/UnitMetered").InnerText);
|
||||
|
||||
//case 1737 new fields
|
||||
if (xmldoc.SelectSingleNode("/ImportExportCSVSettings/UnitWarrantyLength") != null)
|
||||
{
|
||||
_ClientGroup = XmlConvert.ToBoolean(xmldoc.SelectSingleNode("/ImportExportCSVSettings/UnitWarrantyLength").InnerText);
|
||||
}
|
||||
#endregion unit
|
||||
|
||||
//FUTURE: items are going to have to check for presence of nodes before attempting to retrieve them
|
||||
|
||||
#region Mappings case 1588
|
||||
|
||||
//These need to check for existence as they were added later in v7 update case 1588
|
||||
|
||||
if (xmldoc.SelectSingleNode("/ImportExportCSVSettings/ClientLastMapping") != null)
|
||||
_ClientLastMapping = xmldoc.SelectSingleNode("/ImportExportCSVSettings/ClientLastMapping").InnerText;
|
||||
else
|
||||
_ClientLastMapping = "";
|
||||
|
||||
if (xmldoc.SelectSingleNode("/ImportExportCSVSettings/PartLastMapping") != null)
|
||||
_PartLastMapping = xmldoc.SelectSingleNode("/ImportExportCSVSettings/PartLastMapping").InnerText;
|
||||
else
|
||||
_PartLastMapping = "";
|
||||
|
||||
if (xmldoc.SelectSingleNode("/ImportExportCSVSettings/UnitLastMapping") != null)
|
||||
_UnitLastMapping = xmldoc.SelectSingleNode("/ImportExportCSVSettings/UnitLastMapping").InnerText;
|
||||
else
|
||||
_UnitLastMapping = "";
|
||||
|
||||
if (xmldoc.SelectSingleNode("/ImportExportCSVSettings/AssemblyLastMapping") != null)
|
||||
_AssemblyLastMapping = xmldoc.SelectSingleNode("/ImportExportCSVSettings/AssemblyLastMapping").InnerText;
|
||||
else
|
||||
_AssemblyLastMapping = "";
|
||||
|
||||
//case 2072
|
||||
if (xmldoc.SelectSingleNode("/ImportExportCSVSettings/RateLastMapping") != null)
|
||||
_RateLastMapping = xmldoc.SelectSingleNode("/ImportExportCSVSettings/RateLastMapping").InnerText;
|
||||
else
|
||||
_RateLastMapping = "";
|
||||
//----------------------
|
||||
if (xmldoc.SelectSingleNode("/ImportExportCSVSettings/WorkorderStatusLastMapping") != null)
|
||||
_WorkorderStatusLastMapping = xmldoc.SelectSingleNode("/ImportExportCSVSettings/WorkorderStatusLastMapping").InnerText;
|
||||
else
|
||||
_WorkorderStatusLastMapping = "";
|
||||
//----------------------
|
||||
if (xmldoc.SelectSingleNode("/ImportExportCSVSettings/WorkorderCategoryLastMapping") != null)
|
||||
_WorkorderCategoryLastMapping = xmldoc.SelectSingleNode("/ImportExportCSVSettings/WorkorderCategoryLastMapping").InnerText;
|
||||
else
|
||||
_WorkorderCategoryLastMapping = "";
|
||||
//----------------------
|
||||
if (xmldoc.SelectSingleNode("/ImportExportCSVSettings/WorkorderItemTypeLastMapping") != null)
|
||||
_WorkorderItemTypeLastMapping = xmldoc.SelectSingleNode("/ImportExportCSVSettings/WorkorderItemTypeLastMapping").InnerText;
|
||||
else
|
||||
_WorkorderItemTypeLastMapping = "";
|
||||
//----------------------
|
||||
if (xmldoc.SelectSingleNode("/ImportExportCSVSettings/UnitServiceTypeLastMapping") != null)
|
||||
_UnitServiceTypeLastMapping = xmldoc.SelectSingleNode("/ImportExportCSVSettings/UnitServiceTypeLastMapping").InnerText;
|
||||
else
|
||||
_UnitServiceTypeLastMapping = "";
|
||||
//----------------------
|
||||
if (xmldoc.SelectSingleNode("/ImportExportCSVSettings/PriorityLastMapping") != null)
|
||||
_PriorityLastMapping = xmldoc.SelectSingleNode("/ImportExportCSVSettings/PriorityLastMapping").InnerText;
|
||||
else
|
||||
_PriorityLastMapping = "";
|
||||
//----------------------
|
||||
if (xmldoc.SelectSingleNode("/ImportExportCSVSettings/PartCategoryLastMapping") != null)
|
||||
_PartCategoryLastMapping = xmldoc.SelectSingleNode("/ImportExportCSVSettings/PartCategoryLastMapping").InnerText;
|
||||
else
|
||||
_PartCategoryLastMapping = "";
|
||||
//----------------------
|
||||
|
||||
|
||||
#endregion mappings
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
369
source/Plugins/AyaNova.PlugIn.ImportExportCSV/ImportAssembly.cs
Normal file
369
source/Plugins/AyaNova.PlugIn.ImportExportCSV/ImportAssembly.cs
Normal file
@@ -0,0 +1,369 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Collections;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Forms;
|
||||
using System.Data;
|
||||
using GZTW.AyaNova.BLL;
|
||||
using System.Threading;
|
||||
using CSLA.Security;
|
||||
using FileHelpers;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace AyaNova.PlugIn.ImportExportCSV
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for Form1.
|
||||
/// </summary>
|
||||
public class ImportAssembly : System.Windows.Forms.Form
|
||||
{
|
||||
private System.Windows.Forms.DataGridView dataGrid1;
|
||||
private System.Windows.Forms.MainMenu mainMenu1;
|
||||
private System.Windows.Forms.MenuItem mnuOpen;
|
||||
private System.Windows.Forms.MenuItem mnuImport;
|
||||
private System.Windows.Forms.OpenFileDialog dlgOpen;
|
||||
private System.Windows.Forms.MenuItem mnuExport;
|
||||
private MenuItem mnuImportOptions;
|
||||
private IContainer components;
|
||||
|
||||
public ImportAssembly()
|
||||
{
|
||||
//
|
||||
// Required for Windows Form Designer support
|
||||
//
|
||||
InitializeComponent();
|
||||
|
||||
this.Icon = Resource.ImportExportCSV16icon;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
protected override void Dispose( bool disposing )
|
||||
{
|
||||
if( disposing )
|
||||
{
|
||||
if (components != null)
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
}
|
||||
base.Dispose( disposing );
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.dataGrid1 = new System.Windows.Forms.DataGridView();
|
||||
this.mainMenu1 = new System.Windows.Forms.MainMenu(this.components);
|
||||
this.mnuOpen = new System.Windows.Forms.MenuItem();
|
||||
this.mnuImport = new System.Windows.Forms.MenuItem();
|
||||
this.mnuExport = new System.Windows.Forms.MenuItem();
|
||||
this.mnuImportOptions = new System.Windows.Forms.MenuItem();
|
||||
this.dlgOpen = new System.Windows.Forms.OpenFileDialog();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// dataGrid1
|
||||
//
|
||||
this.dataGrid1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.dataGrid1.Location = new System.Drawing.Point(0, 0);
|
||||
this.dataGrid1.Name = "dataGrid1";
|
||||
this.dataGrid1.ReadOnly = true;
|
||||
this.dataGrid1.Size = new System.Drawing.Size(632, 433);
|
||||
this.dataGrid1.TabIndex = 1;
|
||||
//
|
||||
// mainMenu1
|
||||
//
|
||||
this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
|
||||
this.mnuOpen,
|
||||
this.mnuImport,
|
||||
this.mnuExport,
|
||||
this.mnuImportOptions});
|
||||
//
|
||||
// mnuOpen
|
||||
//
|
||||
this.mnuOpen.Index = 0;
|
||||
this.mnuOpen.Text = "&Open CSV file";
|
||||
this.mnuOpen.Click += new System.EventHandler(this.mnuOpen_Click);
|
||||
//
|
||||
// mnuImport
|
||||
//
|
||||
this.mnuImport.Enabled = false;
|
||||
this.mnuImport.Index = 1;
|
||||
this.mnuImport.Text = "&Import data";
|
||||
this.mnuImport.Click += new System.EventHandler(this.mnuImport_Click);
|
||||
//
|
||||
// mnuExport
|
||||
//
|
||||
this.mnuExport.Index = 2;
|
||||
this.mnuExport.Text = "&Export data";
|
||||
this.mnuExport.Click += new System.EventHandler(this.mnuExport_Click);
|
||||
//
|
||||
// mnuImportOptions
|
||||
//
|
||||
this.mnuImportOptions.Index = 3;
|
||||
this.mnuImportOptions.Text = "&Duplicate import options";
|
||||
this.mnuImportOptions.Visible = false;
|
||||
//
|
||||
// dlgOpen
|
||||
//
|
||||
this.dlgOpen.DefaultExt = "csv";
|
||||
this.dlgOpen.Filter = "CSV files|*.csv";
|
||||
this.dlgOpen.Title = "Comma separated values client file";
|
||||
//
|
||||
// ImportAssembly
|
||||
//
|
||||
this.AutoScaleBaseSize = new System.Drawing.Size(6, 15);
|
||||
this.ClientSize = new System.Drawing.Size(632, 433);
|
||||
this.Controls.Add(this.dataGrid1);
|
||||
this.Menu = this.mainMenu1;
|
||||
this.Name = "ImportAssembly";
|
||||
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
|
||||
this.Load += new System.EventHandler(this.Form1_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//
|
||||
// _________ __
|
||||
// \_ ___ \ __ __ _______/ |_ ____ _____
|
||||
// / \ \/ | | \ / ___/\ __\ / _ \ / \
|
||||
// \ \____| | / \___ \ | | ( <_> )| Y Y \
|
||||
// \______ /|____/ /____ > |__| \____/ |__|_| /
|
||||
// \/ \/ \/
|
||||
// _________ .___
|
||||
// \_ ___ \ ____ __| _/ ____
|
||||
// / \ \/ / _ \ / __ | _/ __ \
|
||||
// \ \____( <_> )/ /_/ | \ ___/
|
||||
// \______ / \____/ \____ | \___ >
|
||||
// \/ \/ \/
|
||||
|
||||
|
||||
|
||||
|
||||
#region Form load and login
|
||||
private void Form1_Load(object sender, System.EventArgs e)
|
||||
{
|
||||
|
||||
{
|
||||
System.Reflection.Assembly a = System.Reflection.Assembly.GetExecutingAssembly();
|
||||
string sVersion = "AyaNova® assembly import / export " + AyaBizUtils.DisplayVersion(a.GetName().Version);
|
||||
System.Diagnostics.FileVersionInfo fileVersion = System.Diagnostics.FileVersionInfo.GetVersionInfo(a.Location);
|
||||
if (fileVersion.FileBuildPart > 0)
|
||||
sVersion += " (Patch " + fileVersion.FileBuildPart.ToString() + ")";
|
||||
this.Text = sVersion;
|
||||
}
|
||||
|
||||
|
||||
MessageBox.Show(
|
||||
"Confirm that you have a backup copy of your AyaNova database before proceeding.\r\n\r\n" +
|
||||
"There is no undo function for importing data other than restoring from a pre-import backup copy.\r\n\r\n" +
|
||||
"** If you are not 100% certain that you have a *working* backup copy ready, stop now **",
|
||||
"ACCIDENTS HAPPEN: DO NOT IMPORT WITHOUT A GOOD BACKUP!");
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Read import file
|
||||
private DataTable dtAssemblies;
|
||||
|
||||
private FHAssembly[] records;
|
||||
private void mnuOpen_Click(object sender, System.EventArgs e)
|
||||
{
|
||||
|
||||
if(dlgOpen.ShowDialog()!=DialogResult.OK) return;
|
||||
this.mnuImport.Enabled=false;
|
||||
if(dtAssemblies==null)
|
||||
{
|
||||
dtAssemblies=new DataTable("CSVAssemblies");
|
||||
dtAssemblies.Columns.Add("Name",typeof(string));
|
||||
|
||||
}
|
||||
else
|
||||
dtAssemblies.Rows.Clear();
|
||||
|
||||
FileHelperEngine engine = new FileHelperEngine(typeof(FHAssembly));
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
records= (FHAssembly[]) engine.ReadFile(dlgOpen.FileName);
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
MessageBox.Show("Error reading the .csv file:\r\n\r\n" + ex.Message);
|
||||
return;
|
||||
}
|
||||
|
||||
string sMax="The first 25 records only";
|
||||
if(records.GetLength(0)<25)
|
||||
sMax="All records";
|
||||
MessageBox.Show(records.GetLength(0).ToString() + " records were read in from the .csv file.\r\n\r\n" +
|
||||
sMax+" will be displayed for you to confirm the fields\r\n" +
|
||||
"and check that the data is displaying correctly before importing.\r\n\r\n" +
|
||||
"If any field doesn't appear correctly you must create a new .csv file with the correct\r\n" +
|
||||
"column order before importing or data will be imported into the wrong place in AyaNova");
|
||||
|
||||
//Maximum 25 records displayed
|
||||
int nMax=0;
|
||||
foreach(FHAssembly c in records)
|
||||
{
|
||||
|
||||
dtAssemblies.Rows.Add(
|
||||
new object[]{c.Name});
|
||||
nMax++;
|
||||
if(nMax>24) break;
|
||||
}
|
||||
|
||||
|
||||
dataGrid1.DataSource=dtAssemblies;
|
||||
this.mnuImport.Enabled=true;
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Import data
|
||||
private PartAssemblies PA = null;
|
||||
private bool ContainsAssembly(string name)
|
||||
{
|
||||
foreach (PartAssembly p in PA)
|
||||
{
|
||||
if (p.Name == name)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void mnuImport_Click(object sender, System.EventArgs e)
|
||||
{
|
||||
|
||||
if(records.GetLength(0)<1)
|
||||
{
|
||||
MessageBox.Show("There are no records to import");
|
||||
return;
|
||||
}
|
||||
|
||||
long lBadCount=0;
|
||||
long lGoodCount=0;
|
||||
Waiting w=new Waiting();
|
||||
w.Show();
|
||||
w.Ops="Importing Assemblies";
|
||||
PA = PartAssemblies.GetItems();
|
||||
foreach(FHAssembly f in records)
|
||||
{
|
||||
|
||||
//If client has a name and doesn't already exist in the db then import it
|
||||
if(f.Name!=null && f.Name!="" && (!ContainsAssembly(t(255,f.Name))))
|
||||
{
|
||||
w.Step=t(255,f.Name);
|
||||
PartAssembly p=PA.Add();
|
||||
p.Name = t(255, f.Name);
|
||||
lGoodCount++;
|
||||
|
||||
}
|
||||
else
|
||||
lBadCount++;
|
||||
|
||||
|
||||
}
|
||||
if (lGoodCount > 0)
|
||||
{
|
||||
w.Step = "Saving...";
|
||||
PA.Save();
|
||||
}
|
||||
|
||||
w.Close();
|
||||
|
||||
if(lBadCount>0)
|
||||
MessageBox.Show(lGoodCount.ToString() + " Assemblies were imported sucessfully.\r\n" +
|
||||
lBadCount.ToString() + " Assemblies were not imported because a assembly with the same name already\r\n" +
|
||||
"exists.");
|
||||
else
|
||||
MessageBox.Show(lGoodCount.ToString() + " Assemblies were imported sucessfully");
|
||||
|
||||
}
|
||||
|
||||
private static string t(int nLength, string s)
|
||||
{
|
||||
if(s==null || s=="") return "";
|
||||
if(s.Length<=nLength) return s;
|
||||
else
|
||||
return s.Substring(0,nLength);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Export data
|
||||
/// <summary>
|
||||
/// Exports all existing clients to CSV format identical
|
||||
/// to that required for import
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void mnuExport_Click(object sender, System.EventArgs e)
|
||||
{
|
||||
SaveFileDialog sf = new SaveFileDialog();
|
||||
sf.DefaultExt = ".csv";
|
||||
sf.FileName = "assemblies.csv";
|
||||
if (sf.ShowDialog() != DialogResult.OK) return;
|
||||
|
||||
Cursor=Cursors.WaitCursor;
|
||||
FileHelperEngine engine = new FileHelperEngine(typeof(FHAssembly));
|
||||
System.Collections.ArrayList alAssemblies = new ArrayList();
|
||||
FHAssembly fhc;
|
||||
PA = PartAssemblies.GetItems();
|
||||
Waiting w=new Waiting();
|
||||
w.Show();
|
||||
w.Ops="Exporting assemblies";
|
||||
foreach(PartAssembly p in PA)
|
||||
{
|
||||
fhc=new FHAssembly();
|
||||
w.Step=p.Name;
|
||||
fhc.Name=p.Name;
|
||||
alAssemblies.Add(fhc);
|
||||
|
||||
}
|
||||
w.Close();
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
engine.WriteFile(sf.FileName, (object[])alAssemblies.ToArray(typeof(FHAssembly)));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
MessageBox.Show("Error writing the export file:\r\n\r\n" + ex.Message);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Cursor=Cursors.Default;
|
||||
MessageBox.Show("All Assemblies in current AyaNova database have been exported to file:\r\n" +
|
||||
sf.FileName);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="mainMenu1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="dlgOpen.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>127, 17</value>
|
||||
</metadata>
|
||||
</root>
|
||||
660
source/Plugins/AyaNova.PlugIn.ImportExportCSV/ImportClient.cs
Normal file
660
source/Plugins/AyaNova.PlugIn.ImportExportCSV/ImportClient.cs
Normal file
@@ -0,0 +1,660 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Collections;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Forms;
|
||||
using System.Data;
|
||||
using GZTW.AyaNova.BLL;
|
||||
using System.Threading;
|
||||
using CSLA.Security;
|
||||
using FileHelpers;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace AyaNova.PlugIn.ImportExportCSV
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for Form1.
|
||||
/// </summary>
|
||||
public class ImportClient : System.Windows.Forms.Form
|
||||
{
|
||||
private System.Windows.Forms.DataGridView DataGridView1;
|
||||
private System.Windows.Forms.MainMenu mainMenu1;
|
||||
private System.Windows.Forms.MenuItem mnuOpen;
|
||||
private System.Windows.Forms.MenuItem mnuImport;
|
||||
private System.Windows.Forms.OpenFileDialog dlgOpen;
|
||||
private System.Windows.Forms.MenuItem mnuExport;
|
||||
private MenuItem mnuImportOptions;
|
||||
private IContainer components;
|
||||
|
||||
public ImportClient()
|
||||
{
|
||||
//
|
||||
// Required for Windows Form Designer support
|
||||
//
|
||||
InitializeComponent();
|
||||
|
||||
this.Icon = Resource.ImportExportCSV16icon;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
protected override void Dispose( bool disposing )
|
||||
{
|
||||
if( disposing )
|
||||
{
|
||||
if (components != null)
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
}
|
||||
base.Dispose( disposing );
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.DataGridView1 = new System.Windows.Forms.DataGridView();
|
||||
this.mainMenu1 = new System.Windows.Forms.MainMenu(this.components);
|
||||
this.mnuOpen = new System.Windows.Forms.MenuItem();
|
||||
this.mnuImport = new System.Windows.Forms.MenuItem();
|
||||
this.mnuExport = new System.Windows.Forms.MenuItem();
|
||||
this.mnuImportOptions = new System.Windows.Forms.MenuItem();
|
||||
this.dlgOpen = new System.Windows.Forms.OpenFileDialog();
|
||||
((System.ComponentModel.ISupportInitialize)(this.DataGridView1)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// DataGridView1
|
||||
//
|
||||
this.DataGridView1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.DataGridView1.Location = new System.Drawing.Point(0, 0);
|
||||
this.DataGridView1.Name = "DataGridView1";
|
||||
this.DataGridView1.ReadOnly = true;
|
||||
this.DataGridView1.Size = new System.Drawing.Size(632, 433);
|
||||
this.DataGridView1.TabIndex = 1;
|
||||
this.DataGridView1.DataBindingComplete += new System.Windows.Forms.DataGridViewBindingCompleteEventHandler(this.DataGridView1_DataBindingComplete);
|
||||
this.DataGridView1.BindingContextChanged += new System.EventHandler(this.DataGridView1_BindingContextChanged);
|
||||
//
|
||||
// mainMenu1
|
||||
//
|
||||
this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
|
||||
this.mnuOpen,
|
||||
this.mnuImport,
|
||||
this.mnuExport,
|
||||
this.mnuImportOptions});
|
||||
//
|
||||
// mnuOpen
|
||||
//
|
||||
this.mnuOpen.Index = 0;
|
||||
this.mnuOpen.Text = "&Open CSV file";
|
||||
this.mnuOpen.Click += new System.EventHandler(this.mnuOpen_Click);
|
||||
//
|
||||
// mnuImport
|
||||
//
|
||||
this.mnuImport.Enabled = false;
|
||||
this.mnuImport.Index = 1;
|
||||
this.mnuImport.Text = "&Import data";
|
||||
this.mnuImport.Click += new System.EventHandler(this.mnuImport_Click);
|
||||
//
|
||||
// mnuExport
|
||||
//
|
||||
this.mnuExport.Index = 2;
|
||||
this.mnuExport.Text = "&Export data";
|
||||
this.mnuExport.Click += new System.EventHandler(this.mnuExport_Click);
|
||||
//
|
||||
// mnuImportOptions
|
||||
//
|
||||
this.mnuImportOptions.Index = 3;
|
||||
this.mnuImportOptions.Text = "&Duplicate import options";
|
||||
this.mnuImportOptions.Visible = false;
|
||||
this.mnuImportOptions.Click += new System.EventHandler(this.mnuImportOptions_Click);
|
||||
//
|
||||
// dlgOpen
|
||||
//
|
||||
this.dlgOpen.DefaultExt = "csv";
|
||||
this.dlgOpen.Filter = "CSV files|*.csv";
|
||||
this.dlgOpen.Title = "Comma separated values client file";
|
||||
//
|
||||
// ImportClient
|
||||
//
|
||||
this.AutoScaleBaseSize = new System.Drawing.Size(6, 15);
|
||||
this.ClientSize = new System.Drawing.Size(632, 433);
|
||||
this.Controls.Add(this.DataGridView1);
|
||||
this.Menu = this.mainMenu1;
|
||||
this.Name = "ImportClient";
|
||||
this.Text = "Client importer v2.0.0.0";
|
||||
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
|
||||
this.Load += new System.EventHandler(this.Form1_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.DataGridView1)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//
|
||||
// _________ __
|
||||
// \_ ___ \ __ __ _______/ |_ ____ _____
|
||||
// / \ \/ | | \ / ___/\ __\ / _ \ / \
|
||||
// \ \____| | / \___ \ | | ( <_> )| Y Y \
|
||||
// \______ /|____/ /____ > |__| \____/ |__|_| /
|
||||
// \/ \/ \/
|
||||
// _________ .___
|
||||
// \_ ___ \ ____ __| _/ ____
|
||||
// / \ \/ / _ \ / __ | _/ __ \
|
||||
// \ \____( <_> )/ /_/ | \ ___/
|
||||
// \______ / \____/ \____ | \___ >
|
||||
// \/ \/ \/
|
||||
|
||||
|
||||
|
||||
|
||||
#region Form load and login
|
||||
private void Form1_Load(object sender, System.EventArgs e)
|
||||
{
|
||||
{
|
||||
System.Reflection.Assembly a = System.Reflection.Assembly.GetExecutingAssembly();
|
||||
string sVersion = "AyaNova® client import / export " + AyaBizUtils.DisplayVersion(a.GetName().Version);
|
||||
System.Diagnostics.FileVersionInfo fileVersion = System.Diagnostics.FileVersionInfo.GetVersionInfo(a.Location);
|
||||
if (fileVersion.FileBuildPart > 0)
|
||||
sVersion += " (Patch " + fileVersion.FileBuildPart.ToString() + ")";
|
||||
this.Text = sVersion;
|
||||
}
|
||||
|
||||
|
||||
mnuImportOptions.Visible = Util.LicensedMode;
|
||||
|
||||
|
||||
MessageBox.Show(
|
||||
"Confirm that you have a backup copy of your AyaNova database before proceeding.\r\n\r\n" +
|
||||
"There is no undo function for importing data other than restoring from a pre-import backup copy.\r\n\r\n" +
|
||||
"** If you are not 100% certain that you have a *working* backup copy ready, stop now **",
|
||||
"ACCIDENTS HAPPEN: DO NOT IMPORT WITHOUT A GOOD BACKUP!");
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Read import file
|
||||
private DataTable dtClients;
|
||||
|
||||
//private FHClient[] records;
|
||||
private void mnuOpen_Click(object sender, System.EventArgs e)
|
||||
{
|
||||
if (dlgOpen.ShowDialog() != DialogResult.OK) return;
|
||||
this.mnuImport.Enabled = false;
|
||||
Util.ReadCSV(DataGridView1, ref dtClients, RootObjectTypes.Client, dlgOpen.FileName);
|
||||
this.mnuImport.Enabled = true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Import data
|
||||
Dictionary<string, int> lsMap = null;
|
||||
private void mnuImport_Click(object sender, System.EventArgs e)
|
||||
{
|
||||
//Save grid settings
|
||||
Util.SaveGridMappings(DataGridView1, RootObjectTypes.Client);
|
||||
|
||||
if(dtClients.Rows.Count<1)
|
||||
{
|
||||
MessageBox.Show("There are no records to import");
|
||||
return;
|
||||
}
|
||||
|
||||
//Get the map
|
||||
lsMap = Util.BuildGridImportMap(DataGridView1);
|
||||
|
||||
if (!lsMap.ContainsKey("Name"))
|
||||
{
|
||||
MessageBox.Show("\"Name\" is a required field to uniquely identify Clients. Select a column to be used as the unique Client name to proceed with import.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
long lBadCount=0;
|
||||
long lGoodCount=0;
|
||||
long lUpdatedCount = 0;
|
||||
|
||||
//case 1737 cache
|
||||
ClientGroups cgroups = ClientGroups.GetItems();
|
||||
Dictionary<string, Guid> regions = new Dictionary<string, Guid>();
|
||||
DispatchZones dzones = DispatchZones.GetItems(false);
|
||||
|
||||
|
||||
RegionList rl = RegionList.GetList("");
|
||||
foreach (RegionList.RegionListInfo i in rl)
|
||||
regions.Add(i.LT_Region_Label_Name.Display, i.LT_Region_Label_Name.Value);
|
||||
|
||||
Waiting w = new Waiting();
|
||||
w.Show();
|
||||
w.Ops = "Importing clients";
|
||||
foreach (DataRow dr in dtClients.Rows)
|
||||
{
|
||||
if (fld(dr,"Name",255)=="") continue;
|
||||
Client c = null;
|
||||
|
||||
string sClientName = fld(dr, "Name", 255);
|
||||
Guid gClientID = Client.IDFromName(sClientName);
|
||||
if (gClientID!=Guid.Empty)
|
||||
{
|
||||
//case 1404 Open existing for update?
|
||||
if (Util.LicensedMode && Util.IEData.ClientUpdate)
|
||||
{
|
||||
//update existing client
|
||||
c = Client.GetItemNoMRU(gClientID);
|
||||
|
||||
}
|
||||
else//not licensed or nothing chosen to update
|
||||
{
|
||||
lBadCount++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
c = Client.NewItem();
|
||||
}
|
||||
|
||||
|
||||
w.Step = sClientName;
|
||||
|
||||
if(c.IsNew)
|
||||
c.Name = sClientName;
|
||||
|
||||
if (c.IsNew || Util.IEData.ClientPostalAddress)
|
||||
{
|
||||
c.MailToAddress.DeliveryAddress = fld(dr, "MailAddress", 255);// t(255, f.MailAddress);
|
||||
c.MailToAddress.City = fld(dr, "MailCity", 255); //t(255, f.MailCity);
|
||||
c.MailToAddress.StateProv = fld(dr, "MailStateProvince", 255); //t(255, f.MailStateProvince);
|
||||
c.MailToAddress.Country = fld(dr, "MailCountry", 255); //t(255, f.MailCountry);
|
||||
c.MailToAddress.Postal = fld(dr, "MailPostal", 255); //t(255, f.MailPostal);
|
||||
}
|
||||
|
||||
if (c.IsNew || Util.IEData.ClientPhysicalAddress)
|
||||
{
|
||||
c.GoToAddress.DeliveryAddress = fld(dr, "DeliveryAddress", 255);// t(255, f.DeliveryAddress);
|
||||
c.GoToAddress.City = fld(dr, "DeliveryCity", 255); //t(255, f.DeliveryCity);
|
||||
c.GoToAddress.StateProv = fld(dr, "DeliveryStateProvince", 255); //t(255, f.DeliveryStateProvince);
|
||||
c.GoToAddress.Country = fld(dr, "DeliveryCountry", 255); //t(255, f.DeliveryCountry);
|
||||
c.GoToAddress.Postal = fld(dr, "DeliveryPostal", 255); //t(255, f.DeliveryPostal);
|
||||
|
||||
}
|
||||
|
||||
if (c.IsNew || Util.IEData.ClientContact)
|
||||
{
|
||||
c.Contact = fld(dr, "Contact", 500);// t(500, f.Contact);
|
||||
}
|
||||
|
||||
if (c.IsNew || Util.IEData.ClientContactNotes)
|
||||
{
|
||||
c.ContactNotes = fld(dr, "ContactNotes", 1024); //t(1024, f.ContactNotes);
|
||||
}
|
||||
|
||||
if (c.IsNew || Util.IEData.ClientPhoneNumbers)
|
||||
{
|
||||
c.Phone1 = fld(dr, "Phone1", 255); //t(255, f.Phone1);
|
||||
c.Phone2 = fld(dr, "Phone2", 255); //t(255, f.Phone2);
|
||||
c.Phone3 = fld(dr, "Phone3", 255); //t(255, f.Phone3);
|
||||
c.Phone4 = fld(dr, "Phone4", 255); //t(255, f.Phone4);
|
||||
c.Phone5 = fld(dr, "Phone5", 255); //t(255, f.Phone5);
|
||||
}
|
||||
|
||||
if (c.IsNew || Util.IEData.ClientEmail)
|
||||
{
|
||||
c.Email = fld(dr, "EmailAddress", 255); //t(255, f.EmailAddress);
|
||||
}
|
||||
|
||||
if (c.IsNew || Util.IEData.ClientAccountNumber)
|
||||
{
|
||||
c.AccountNumber = fld(dr, "AccountNumber", 255); //t(255, f.AccountNumber);
|
||||
}
|
||||
|
||||
if (c.IsNew || Util.IEData.ClientWebSite)
|
||||
{
|
||||
c.WebAddress = fld(dr, "WebSite", 255); //t(255, f.WebSite);
|
||||
}
|
||||
|
||||
if (c.IsNew || Util.IEData.ClientTechNotes)
|
||||
{
|
||||
c.TechNotes = fld(dr, "TechNotes", 32767); //t(32767, f.TechNotes);
|
||||
}
|
||||
|
||||
if (c.IsNew || Util.IEData.ClientNotes)
|
||||
{
|
||||
c.Notes = fld(dr, "GeneralNotes", 32767); //t(32767, f.GeneralNotes);
|
||||
}
|
||||
|
||||
if (c.IsNew || Util.IEData.ClientPopupNotes)
|
||||
{
|
||||
c.PopUpNotes = fld(dr, "PopupNotes", 32767); //t(32767, f.PopupNotes);
|
||||
}
|
||||
|
||||
|
||||
//client group, region, dispatch zone
|
||||
if (c.IsNew || Util.IEData.ClientGroup)
|
||||
{
|
||||
Guid ClientGroupID=Guid.Empty;
|
||||
string s = fld(dr, "ClientGroup", 255).Trim();
|
||||
if (!string.IsNullOrWhiteSpace(s))
|
||||
{
|
||||
foreach (ClientGroup cg in cgroups)
|
||||
{
|
||||
if (cg.Name.Equals(s, StringComparison.CurrentCultureIgnoreCase))
|
||||
{
|
||||
ClientGroupID = cg.ID;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (ClientGroupID == Guid.Empty)
|
||||
{
|
||||
//wasn't in the list so add it and save it
|
||||
ClientGroup cg=cgroups.Add();
|
||||
cg.Name = s;
|
||||
ClientGroupID = cg.ID;
|
||||
cgroups = (ClientGroups)cgroups.Save();
|
||||
|
||||
}
|
||||
}
|
||||
c.ClientGroupID = ClientGroupID;
|
||||
}
|
||||
|
||||
//region
|
||||
if (c.IsNew || Util.IEData.ClientRegion)
|
||||
{
|
||||
Guid RegionID = GZTW.AyaNova.BLL.Region.DefaultRegionID;
|
||||
string s = fld(dr, "Region", 255).Trim();
|
||||
if (!string.IsNullOrWhiteSpace(s))
|
||||
{
|
||||
if (regions.ContainsKey(s))
|
||||
RegionID = regions[s];
|
||||
else
|
||||
{
|
||||
GZTW.AyaNova.BLL.Region r = GZTW.AyaNova.BLL.Region.NewItem();
|
||||
r.Active = true;
|
||||
r.Name = s;
|
||||
RegionID = r.ID;
|
||||
r=(GZTW.AyaNova.BLL.Region)r.Save();
|
||||
regions.Add(r.Name, r.ID);
|
||||
}
|
||||
}
|
||||
c.RegionID = RegionID;
|
||||
}
|
||||
|
||||
//Dispatch zone
|
||||
if (c.IsNew || Util.IEData.ClientDispatchZone)
|
||||
{
|
||||
Guid DispatchZoneID = Guid.Empty;
|
||||
string s = fld(dr, "DispatchZone", 255).Trim();
|
||||
if (!string.IsNullOrWhiteSpace(s))
|
||||
{
|
||||
foreach (DispatchZone cg in dzones)
|
||||
{
|
||||
if (cg.Name.Equals(s, StringComparison.CurrentCultureIgnoreCase))
|
||||
{
|
||||
DispatchZoneID = cg.ID;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (DispatchZoneID == Guid.Empty)
|
||||
{
|
||||
//wasn't in the list so add it and save it
|
||||
DispatchZone cg = dzones.Add();
|
||||
cg.Name = s;
|
||||
DispatchZoneID = cg.ID;
|
||||
dzones = (DispatchZones)dzones.Save();
|
||||
|
||||
}
|
||||
}
|
||||
c.DispatchZoneID = DispatchZoneID;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (c.IsSavable)
|
||||
{
|
||||
bool bWasNew = c.IsNew;
|
||||
c.Save();
|
||||
|
||||
if (bWasNew)
|
||||
lGoodCount++;
|
||||
else
|
||||
lUpdatedCount++;
|
||||
}
|
||||
else
|
||||
{
|
||||
lBadCount++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
w.Close();
|
||||
if (Util.LicensedMode && Util.IEData.ClientUpdate)
|
||||
{
|
||||
if (lBadCount > 0)
|
||||
MessageBox.Show(lGoodCount.ToString() + " Clients were imported / "+lUpdatedCount + " duplicate clients were updated sucessfully.\r\n" +
|
||||
lBadCount.ToString() + " Clients were not imported because they had no name at all or did not pass the business / update rules for a client object.");
|
||||
else
|
||||
MessageBox.Show(lGoodCount.ToString() + " Clients were imported / "+ lUpdatedCount + " duplicate clients were updated sucessfully.");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (lBadCount > 0)
|
||||
MessageBox.Show(lGoodCount.ToString() + " Clients were imported sucessfully.\r\n" +
|
||||
lBadCount.ToString() + " Clients were not imported because a client with the same name already\r\n" +
|
||||
"exists or they had no name at all or did not pass the rules for a client object.");
|
||||
else
|
||||
MessageBox.Show(lGoodCount.ToString() + " Clients were imported sucessfully.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Get a field from the current data row
|
||||
/// </summary>
|
||||
/// <param name="sColumnNameKey"></param>
|
||||
/// <param name="nLength"></param>
|
||||
/// <returns></returns>
|
||||
private string fld(DataRow dr, string sColumnNameKey, int nLength)
|
||||
{
|
||||
if (lsMap.ContainsKey(sColumnNameKey))
|
||||
{
|
||||
return t(nLength, dr[lsMap[sColumnNameKey]].ToString());
|
||||
}
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="nLength"></param>
|
||||
/// <param name="s"></param>
|
||||
/// <returns></returns>
|
||||
private static string t(int nLength, string s)
|
||||
{
|
||||
if(string.IsNullOrWhiteSpace(s)) return "";
|
||||
if(s.Length<=nLength) return s;
|
||||
else
|
||||
return s.Substring(0,nLength);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Export data
|
||||
/// <summary>
|
||||
/// Exports all existing clients to CSV format identical
|
||||
/// to that required for import
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void mnuExport_Click(object sender, System.EventArgs e)
|
||||
{
|
||||
SaveFileDialog sf = new SaveFileDialog();
|
||||
sf.DefaultExt = ".csv";
|
||||
sf.FileName = "clients.csv";
|
||||
if (sf.ShowDialog() != DialogResult.OK) return;
|
||||
|
||||
Cursor=Cursors.WaitCursor;
|
||||
FileHelperEngine engine = new FileHelperEngine(typeof(FHClient));
|
||||
System.Collections.ArrayList alClients=new ArrayList();
|
||||
FHClient fhc;
|
||||
Client c;
|
||||
ClientPickList cpl=ClientPickList.GetList();
|
||||
Waiting w=new Waiting();
|
||||
w.Show();
|
||||
w.Ops="Exporting clients";
|
||||
foreach(ClientPickList.ClientPickListInfo i in cpl)
|
||||
{
|
||||
c=Client.GetItem(i.ID);
|
||||
ClientList cl = ClientList.GetListForSingleItem(i.ID);
|
||||
|
||||
fhc = new FHClient();
|
||||
w.Step = cl[0].LT_O_Client.Display;
|
||||
fhc.Name = cl[0].LT_O_Client.Display;
|
||||
fhc.AccountNumber = cl[0].LT_Client_Label_AccountNumber;
|
||||
|
||||
//contact fields
|
||||
fhc.Contact = cl[0].LT_Client_Label_Contact;
|
||||
fhc.ContactNotes = c.ContactNotes;
|
||||
fhc.Phone1 = cl[0].LT_Client_Label_Phone1;
|
||||
fhc.Phone2 = cl[0].LT_Client_Label_Phone2;
|
||||
fhc.Phone3 = cl[0].LT_Client_Label_Phone3;
|
||||
fhc.Phone4 = cl[0].LT_Client_Label_Phone4;
|
||||
fhc.Phone5 = cl[0].LT_Client_Label_Phone5;
|
||||
fhc.EmailAddress = cl[0].LT_Client_Label_Email;
|
||||
|
||||
|
||||
fhc.DeliveryAddress = c.GoToAddress.DeliveryAddress;
|
||||
fhc.DeliveryCity=c.GoToAddress.City;
|
||||
fhc.DeliveryCountry=c.GoToAddress.Country;
|
||||
fhc.DeliveryPostal=c.GoToAddress.Postal;
|
||||
fhc.DeliveryStateProvince=c.GoToAddress.StateProv;
|
||||
|
||||
|
||||
fhc.GeneralNotes=c.Notes;
|
||||
|
||||
fhc.MailAddress=c.MailToAddress.DeliveryAddress;
|
||||
fhc.MailCity=c.MailToAddress.City;
|
||||
fhc.MailCountry=c.MailToAddress.Country;
|
||||
fhc.MailPostal=c.MailToAddress.Postal;
|
||||
fhc.MailStateProvince=c.MailToAddress.StateProv;
|
||||
fhc.PopupNotes=c.PopUpNotes;
|
||||
|
||||
fhc.TechNotes=c.TechNotes;
|
||||
fhc.WebSite=c.WebAddress;
|
||||
//case 1737
|
||||
fhc.ClientGroup = cl[0].LT_O_ClientGroup.Display;
|
||||
fhc.DispatchZone = cl[0].LT_O_DispatchZone.Display;
|
||||
fhc.Region = cl[0].LT_O_Region.Display;
|
||||
|
||||
|
||||
alClients.Add(fhc);
|
||||
|
||||
|
||||
}
|
||||
w.Close();
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
engine.WriteFile(sf.FileName, (object[]) alClients.ToArray(typeof(FHClient)));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
MessageBox.Show("Error writing the export file:\r\n\r\n" + ex.Message);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Cursor=Cursors.Default;
|
||||
MessageBox.Show("All clients in current AyaNova database have been exported to file:\r\n" +
|
||||
sf.FileName);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
private void mnuImportOptions_Click(object sender, EventArgs e)
|
||||
{
|
||||
Util.ShowOptionsDialog();
|
||||
}
|
||||
|
||||
|
||||
#region case 1588 user selectable column placement
|
||||
|
||||
private void DataGridView1_BindingContextChanged(object sender, EventArgs e)
|
||||
{
|
||||
// Continue only if the data source has been set.
|
||||
if (DataGridView1.DataSource == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//these are the columns that can be selected by the user to import into
|
||||
List<string> ls = new List<string>();
|
||||
ls.Add("Name");
|
||||
ls.Add("MailAddress");
|
||||
ls.Add("MailCity");
|
||||
ls.Add("MailStateProvince");
|
||||
ls.Add("MailCountry");
|
||||
ls.Add("MailPostal");
|
||||
ls.Add("DeliveryAddress");
|
||||
ls.Add("DeliveryCity");
|
||||
ls.Add("DeliveryStateProvince");
|
||||
ls.Add("DeliveryCountry");
|
||||
ls.Add("DeliveryPostal");
|
||||
ls.Add("Contact");
|
||||
ls.Add("ContactNotes");
|
||||
ls.Add("Phone1");
|
||||
ls.Add("Phone2");
|
||||
ls.Add("Phone3");
|
||||
ls.Add("Phone4");
|
||||
ls.Add("Phone5");
|
||||
ls.Add("EmailAddress");
|
||||
ls.Add("AccountNumber");
|
||||
ls.Add("WebSite");
|
||||
ls.Add("GeneralNotes");
|
||||
ls.Add("TechNotes");
|
||||
ls.Add("PopupNotes");
|
||||
//case 1737
|
||||
ls.Add("ClientGroup");
|
||||
ls.Add("DispatchZone");
|
||||
ls.Add("Region");
|
||||
|
||||
// Add the AutoFilter header cell to each column.
|
||||
foreach (DataGridViewColumn col in DataGridView1.Columns)
|
||||
{
|
||||
col.HeaderCell = new
|
||||
GZDataGridViewComboColumnHeaderCell(col.HeaderCell,ls);
|
||||
}
|
||||
|
||||
// Resize the columns to fit their contents.
|
||||
DataGridView1.AutoResizeColumns();
|
||||
|
||||
}
|
||||
|
||||
private void DataGridView1_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
#endregion case 1588
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
}
|
||||
}
|
||||
126
source/Plugins/AyaNova.PlugIn.ImportExportCSV/ImportClient.resx
Normal file
126
source/Plugins/AyaNova.PlugIn.ImportExportCSV/ImportClient.resx
Normal file
@@ -0,0 +1,126 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="mainMenu1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="dlgOpen.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>127, 17</value>
|
||||
</metadata>
|
||||
</root>
|
||||
325
source/Plugins/AyaNova.PlugIn.ImportExportCSV/ImportExportCSV.cs
Normal file
325
source/Plugins/AyaNova.PlugIn.ImportExportCSV/ImportExportCSV.cs
Normal file
@@ -0,0 +1,325 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using AyaNova.PlugIn;
|
||||
using GZTW.AyaNova.BLL;
|
||||
|
||||
|
||||
namespace AyaNova.PlugIn.ImportExportCSV
|
||||
{
|
||||
class ImportExportCSV : IAyaNovaPlugin
|
||||
{
|
||||
//Keep all the object types we want to deal with in a collection
|
||||
//so that we can quickly check it when asked
|
||||
private static List<RootObjectTypes> ObjectsWeCanDealWith = null;
|
||||
|
||||
//Holds the image resources from AyaNova
|
||||
//so we can display the correct icons in our plugin
|
||||
System.Resources.ResourceManager resman = null;
|
||||
|
||||
//Holds the current logged in user's localized text
|
||||
//lookup object
|
||||
LocalizedTextTable LocaleText = null;
|
||||
|
||||
#region IAyaNovaPlugin Members
|
||||
|
||||
#region interface properties
|
||||
public string PluginName
|
||||
{
|
||||
get { return "ImportExport.csv"; }
|
||||
}
|
||||
|
||||
public string PluginVersion
|
||||
{
|
||||
get { return "7.5"; }
|
||||
}
|
||||
|
||||
public string About
|
||||
{
|
||||
get
|
||||
{
|
||||
return "AyaNova Import Export CSV plugin\r\n" +
|
||||
"Built " + AyaNova.PlugIn.ImportExportCSV.Timestamp.BuildAt.ToString() + "\r\n" +
|
||||
"Copyright 2009-2018 Ground Zero Tech-Works Inc.";
|
||||
}
|
||||
}
|
||||
|
||||
public Guid PluginID
|
||||
{
|
||||
get { return new Guid("{46BC31D2-3132-4b43-8789-120604573A08}"); }
|
||||
}
|
||||
|
||||
public System.Drawing.Image PluginSmallIcon
|
||||
{
|
||||
get { return Resource.ImportExportCSV16; }
|
||||
}
|
||||
|
||||
public System.Drawing.Image PluginLargeIcon
|
||||
{
|
||||
get { return Resource.ImportExportCSV32; }
|
||||
}
|
||||
|
||||
public System.Resources.ResourceManager AyaNovaResourceManager
|
||||
{
|
||||
set {
|
||||
resman = value;
|
||||
Util.AyaRes = resman;
|
||||
}
|
||||
}
|
||||
#endregion interface properties
|
||||
|
||||
#region Initialization and Close
|
||||
|
||||
public bool LicensedMode = false;
|
||||
|
||||
public bool Initialize(Version AyaNovaVersion, LocalizedTextTable localizedText)
|
||||
{
|
||||
LocaleText = localizedText;
|
||||
|
||||
|
||||
if (AyaNovaVersion.Major != 7)
|
||||
{
|
||||
MessageBox.Show("This Import Export CSV plugin requires AyaNova version 7");
|
||||
return false;
|
||||
}
|
||||
|
||||
//case 1404
|
||||
//LicensedMode = (!string.IsNullOrEmpty(AyaBizUtils.PluginLicensedVersion("ImportExportCSV")));
|
||||
|
||||
//case 2094
|
||||
//NOTE: this plugin is free to use and a license is only required for the duplicate option
|
||||
//so licensedmode doesn't prevent it from running just the options presented
|
||||
LicensedMode = AyaBizUtils.PluginAllowed("ImportExportCSVDuplicate", AyaNova.PlugIn.ImportExportCSV.Timestamp.BuildAt);
|
||||
|
||||
//only licensed mode needs to check subscription expiry due to unique nature of this plugin
|
||||
if (AyaBizUtils.PluginSubscriptionExists("ImportExportCSVDuplicate") && AyaBizUtils.PluginTooNew("ImportExportCSVDuplicate", AyaNova.PlugIn.ImportExportCSV.Timestamp.BuildAt))
|
||||
{
|
||||
//MessageBox.Show("Warning: the ImportExportCSVDuplicate plugin is newer than your subscription allows and will be disabled\r\nDowngrade back to your previous version or purchase a subscription to use this plugin.");
|
||||
|
||||
MessageBox.Show(
|
||||
"EXTRA FEATURES NOT LICENSED!\r\n\r\nThis ImportExportCSVDuplicate plugin was built " +
|
||||
AyaNova.PlugIn.ImportExportCSV.Timestamp.BuildAt.ToString() + "\r\n" +
|
||||
"but your license subscription for it ended " +
|
||||
AyaBizUtils.PluginSubscriptionDate("ImportExportCSVDuplicate").ToString() + "\r\n" +
|
||||
"\r\nDowngrade back to your previous version or purchase a subscription to \r\ncontinue use of the licensed features of this plugin.");
|
||||
|
||||
}
|
||||
|
||||
Util.LicensedMode = LicensedMode;
|
||||
|
||||
|
||||
ObjectsWeCanDealWith = new List<RootObjectTypes>();
|
||||
ObjectsWeCanDealWith.Add(RootObjectTypes.Nothing);
|
||||
ObjectsWeCanDealWith.Add(RootObjectTypes.Part);
|
||||
ObjectsWeCanDealWith.Add(RootObjectTypes.Client);
|
||||
//case 1463
|
||||
if (!AyaBizUtils.Lite)
|
||||
ObjectsWeCanDealWith.Add(RootObjectTypes.Unit);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
;
|
||||
}
|
||||
#endregion Initialization and close
|
||||
|
||||
#region ShowMenu?
|
||||
public bool SingleObjectMenuShow(RootObjectTypes objectType)
|
||||
{
|
||||
return (ObjectsWeCanDealWith.Contains(objectType));
|
||||
}
|
||||
|
||||
public bool MultipleObjectsMenuShow(RootObjectTypes objectType)
|
||||
{
|
||||
return (ObjectsWeCanDealWith.Contains(objectType));
|
||||
}
|
||||
|
||||
#endregion show menu?
|
||||
|
||||
#region Menu options
|
||||
public List<AyaNovaPluginMenuItem> SingleObjectMenuOptions(RootObjectTypes objectType, object ayaNovaObject)
|
||||
{
|
||||
if (!ObjectsWeCanDealWith.Contains(objectType)) return null;
|
||||
|
||||
|
||||
|
||||
|
||||
List<AyaNovaPluginMenuItem> list = new List<AyaNovaPluginMenuItem>();
|
||||
switch (objectType)
|
||||
{
|
||||
//Main import / export off main menu, just like original utilities
|
||||
case RootObjectTypes.Nothing:
|
||||
list.Add(new AyaNovaPluginMenuItem("MAIN_CLIENTS", "Clients", null, null));
|
||||
list.Add(new AyaNovaPluginMenuItem("MAIN_PARTS", "Parts", null, null));
|
||||
list.Add(new AyaNovaPluginMenuItem("MAIN_ASSEMBLIES", "Part assemblies", null, null));
|
||||
list.Add(new AyaNovaPluginMenuItem("MAIN_PART_CATEGORY", "Part categories", null, null));//case 2072
|
||||
list.Add(new AyaNovaPluginMenuItem("MAIN_PRIORITIES", "Priorities", null, null));//case 2072
|
||||
list.Add(new AyaNovaPluginMenuItem("MAIN_RATES", "Rates", null, null));//case 2072
|
||||
//case 1463
|
||||
if (!AyaBizUtils.Lite)
|
||||
{
|
||||
list.Add(new AyaNovaPluginMenuItem("MAIN_UNITS", "Units", null, null));
|
||||
list.Add(new AyaNovaPluginMenuItem("MAIN_UNIT_SERVICE_TYPES", "Unit service types", null, null));//case 2072
|
||||
}
|
||||
list.Add(new AyaNovaPluginMenuItem("MAIN_WORKORDER_STATUS", "Workorder status", null, null));//case 2072
|
||||
list.Add(new AyaNovaPluginMenuItem("MAIN_WORKORDER_CATEGORY", "Workorder categories", null, null));//case 2072
|
||||
list.Add(new AyaNovaPluginMenuItem("MAIN_WORKORDER_ITEM_TYPES", "Workorder item types", null, null));//case 2072
|
||||
|
||||
|
||||
if(LicensedMode)
|
||||
list.Add(new AyaNovaPluginMenuItem("OPTIONS", "Duplicate import options", null, null));
|
||||
break;
|
||||
default:
|
||||
//If it's not nothing and we already know it's something we can deal with
|
||||
//then present the export
|
||||
list.Add(new AyaNovaPluginMenuItem("EXPORT_SELECTED", "Export item", null, null));
|
||||
if (LicensedMode)
|
||||
list.Add(new AyaNovaPluginMenuItem("OPTIONS", "Duplicate import options", null, null));
|
||||
break;
|
||||
//case RootObjectTypes.Client:
|
||||
// list.Add(new AyaNovaPluginMenuItem("CLIENTLINKREFRESH", "Link / Refresh", null, null));
|
||||
// break;
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<AyaNovaPluginMenuItem> MultipleObjectsMenuOptions(RootObjectTypes objectType)
|
||||
{
|
||||
if (!ObjectsWeCanDealWith.Contains(objectType)) return null;
|
||||
if (objectType == RootObjectTypes.Nothing) return null;
|
||||
List<AyaNovaPluginMenuItem> list = new List<AyaNovaPluginMenuItem>();
|
||||
list.Add(new AyaNovaPluginMenuItem("EXPORT_SELECTED", "Export selected items", null, null));
|
||||
if (LicensedMode)
|
||||
list.Add(new AyaNovaPluginMenuItem("OPTIONS", "Duplicate import options", null, null));
|
||||
return list;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Menu Commands
|
||||
public bool CommandSelectedForList(string commandKey, RootObjectTypes objectType, List<Guid> objectIDList, object listObject)
|
||||
{
|
||||
if (commandKey == "EXPORT_SELECTED")
|
||||
ExportCSV.ExportList(objectType, objectIDList);
|
||||
else if (commandKey == "OPTIONS")
|
||||
{
|
||||
Util.ShowOptionsDialog();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void CommandSelectedForSingleObject(string commandKey, RootObjectTypes objectType, object ayaNovaObject)
|
||||
{
|
||||
//case 3606
|
||||
Util.DupeCheck();
|
||||
|
||||
switch (commandKey)
|
||||
{
|
||||
case "MAIN_CLIENTS":
|
||||
{
|
||||
ImportClient d = new ImportClient();
|
||||
d.ShowDialog();
|
||||
d.Dispose();
|
||||
}
|
||||
break;
|
||||
case "MAIN_PARTS":
|
||||
{
|
||||
ImportPart d = new ImportPart();
|
||||
d.ShowDialog();
|
||||
d.Dispose();
|
||||
}
|
||||
break;
|
||||
case "MAIN_ASSEMBLIES":
|
||||
{
|
||||
ImportAssembly d = new ImportAssembly();
|
||||
d.ShowDialog();
|
||||
d.Dispose();
|
||||
}
|
||||
break;
|
||||
case "MAIN_UNITS":
|
||||
{
|
||||
ImportUnit d = new ImportUnit();
|
||||
d.ShowDialog();
|
||||
d.Dispose();
|
||||
}
|
||||
break;
|
||||
case "EXPORT_SELECTED":
|
||||
{
|
||||
List<Guid> idl = new List<Guid>(1);
|
||||
Guid g = AyaBizUtils.GetBizObjectID(ayaNovaObject);
|
||||
if (g == Guid.Empty)
|
||||
{
|
||||
MessageBox.Show("Can't export selected object, ID not found: " + ayaNovaObject.ToString());
|
||||
return;
|
||||
}
|
||||
idl.Add(g);
|
||||
ExportCSV.ExportList(objectType, idl);
|
||||
}
|
||||
break;
|
||||
case "OPTIONS":
|
||||
{
|
||||
Util.ShowOptionsDialog();
|
||||
}
|
||||
break;
|
||||
//case 2072
|
||||
case "MAIN_WORKORDER_STATUS":
|
||||
{
|
||||
ImportWorkorderStatus d = new ImportWorkorderStatus();
|
||||
d.ShowDialog();
|
||||
d.Dispose();
|
||||
}
|
||||
break;
|
||||
case "MAIN_WORKORDER_CATEGORY":
|
||||
{
|
||||
ImportWorkorderCategory d = new ImportWorkorderCategory();
|
||||
d.ShowDialog();
|
||||
d.Dispose();
|
||||
}
|
||||
break;
|
||||
case "MAIN_WORKORDER_ITEM_TYPES":
|
||||
{
|
||||
ImportWorkorderItemType d = new ImportWorkorderItemType();
|
||||
d.ShowDialog();
|
||||
d.Dispose();
|
||||
}
|
||||
break;
|
||||
case "MAIN_UNIT_SERVICE_TYPES":
|
||||
{
|
||||
ImportUnitServiceType d = new ImportUnitServiceType();
|
||||
d.ShowDialog();
|
||||
d.Dispose();
|
||||
}
|
||||
break;
|
||||
case "MAIN_PRIORITIES":
|
||||
{
|
||||
ImportPriority d = new ImportPriority();
|
||||
d.ShowDialog();
|
||||
d.Dispose();
|
||||
}
|
||||
break;
|
||||
case "MAIN_PART_CATEGORY":
|
||||
{
|
||||
ImportPartCategory d = new ImportPartCategory();
|
||||
d.ShowDialog();
|
||||
d.Dispose();
|
||||
}
|
||||
break;
|
||||
case "MAIN_RATES":
|
||||
{
|
||||
ImportRate d = new ImportRate();
|
||||
d.ShowDialog();
|
||||
d.Dispose();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endregion menu commands
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
719
source/Plugins/AyaNova.PlugIn.ImportExportCSV/ImportPart.cs
Normal file
719
source/Plugins/AyaNova.PlugIn.ImportExportCSV/ImportPart.cs
Normal file
@@ -0,0 +1,719 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Collections;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Forms;
|
||||
using System.Data;
|
||||
using GZTW.AyaNova.BLL;
|
||||
using System.Threading;
|
||||
using CSLA.Security;
|
||||
using FileHelpers;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace AyaNova.PlugIn.ImportExportCSV
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for Form1.
|
||||
/// </summary>
|
||||
public class ImportPart : System.Windows.Forms.Form
|
||||
{
|
||||
private System.Windows.Forms.DataGridView dataGrid1;
|
||||
private System.Windows.Forms.MainMenu mainMenu1;
|
||||
private System.Windows.Forms.MenuItem mnuOpen;
|
||||
private System.Windows.Forms.MenuItem mnuImport;
|
||||
private System.Windows.Forms.OpenFileDialog dlgOpen;
|
||||
private System.Windows.Forms.MenuItem mnuExport;
|
||||
private MenuItem mnuImportOptions;
|
||||
private IContainer components;
|
||||
|
||||
public ImportPart()
|
||||
{
|
||||
//
|
||||
// Required for Windows Form Designer support
|
||||
//
|
||||
InitializeComponent();
|
||||
|
||||
this.Icon = Resource.ImportExportCSV16icon;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
protected override void Dispose( bool disposing )
|
||||
{
|
||||
if( disposing )
|
||||
{
|
||||
if (components != null)
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
}
|
||||
base.Dispose( disposing );
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.dataGrid1 = new System.Windows.Forms.DataGridView();
|
||||
this.mainMenu1 = new System.Windows.Forms.MainMenu(this.components);
|
||||
this.mnuOpen = new System.Windows.Forms.MenuItem();
|
||||
this.mnuImport = new System.Windows.Forms.MenuItem();
|
||||
this.mnuExport = new System.Windows.Forms.MenuItem();
|
||||
this.mnuImportOptions = new System.Windows.Forms.MenuItem();
|
||||
this.dlgOpen = new System.Windows.Forms.OpenFileDialog();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// dataGrid1
|
||||
//
|
||||
this.dataGrid1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.dataGrid1.Location = new System.Drawing.Point(0, 0);
|
||||
this.dataGrid1.Name = "dataGrid1";
|
||||
this.dataGrid1.ReadOnly = true;
|
||||
this.dataGrid1.Size = new System.Drawing.Size(632, 433);
|
||||
this.dataGrid1.TabIndex = 1;
|
||||
this.dataGrid1.BindingContextChanged += new System.EventHandler(this.dataGrid1_BindingContextChanged);
|
||||
//
|
||||
// mainMenu1
|
||||
//
|
||||
this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
|
||||
this.mnuOpen,
|
||||
this.mnuImport,
|
||||
this.mnuExport,
|
||||
this.mnuImportOptions});
|
||||
//
|
||||
// mnuOpen
|
||||
//
|
||||
this.mnuOpen.Index = 0;
|
||||
this.mnuOpen.Text = "&Open CSV file";
|
||||
this.mnuOpen.Click += new System.EventHandler(this.mnuOpen_Click);
|
||||
//
|
||||
// mnuImport
|
||||
//
|
||||
this.mnuImport.Enabled = false;
|
||||
this.mnuImport.Index = 1;
|
||||
this.mnuImport.Text = "&Import data";
|
||||
this.mnuImport.Click += new System.EventHandler(this.mnuImport_Click);
|
||||
//
|
||||
// mnuExport
|
||||
//
|
||||
this.mnuExport.Index = 2;
|
||||
this.mnuExport.Text = "&Export data";
|
||||
this.mnuExport.Click += new System.EventHandler(this.mnuExport_Click);
|
||||
//
|
||||
// mnuImportOptions
|
||||
//
|
||||
this.mnuImportOptions.Index = 3;
|
||||
this.mnuImportOptions.Text = "&Duplicate import options";
|
||||
this.mnuImportOptions.Visible = false;
|
||||
this.mnuImportOptions.Click += new System.EventHandler(this.mnuImportOptions_Click);
|
||||
//
|
||||
// dlgOpen
|
||||
//
|
||||
this.dlgOpen.DefaultExt = "csv";
|
||||
this.dlgOpen.Filter = "CSV files|*.csv";
|
||||
this.dlgOpen.Title = "Comma separated values part file";
|
||||
//
|
||||
// ImportPart
|
||||
//
|
||||
this.AutoScaleBaseSize = new System.Drawing.Size(6, 15);
|
||||
this.ClientSize = new System.Drawing.Size(632, 433);
|
||||
this.Controls.Add(this.dataGrid1);
|
||||
this.Menu = this.mainMenu1;
|
||||
this.Name = "ImportPart";
|
||||
this.Text = "Part importer v2.0.0.0";
|
||||
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
|
||||
this.Load += new System.EventHandler(this.Form1_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//
|
||||
// _________ __
|
||||
// \_ ___ \ __ __ _______/ |_ ____ _____
|
||||
// / \ \/ | | \ / ___/\ __\ / _ \ / \
|
||||
// \ \____| | / \___ \ | | ( <_> )| Y Y \
|
||||
// \______ /|____/ /____ > |__| \____/ |__|_| /
|
||||
// \/ \/ \/
|
||||
// _________ .___
|
||||
// \_ ___ \ ____ __| _/ ____
|
||||
// / \ \/ / _ \ / __ | _/ __ \
|
||||
// \ \____( <_> )/ /_/ | \ ___/
|
||||
// \______ / \____/ \____ | \___ >
|
||||
// \/ \/ \/
|
||||
|
||||
|
||||
#region list objects
|
||||
//These are name value lists used to
|
||||
//keep track of the id's of existing items
|
||||
//that are either pre-existing or have been created during import
|
||||
//this supports the code that matches text names of objects to their id's
|
||||
//i.e. "IBM" as a manufacturer to the IBM record in AyaNova already
|
||||
//case is not taken into account during comparison to ensure no little
|
||||
//mismatches due to a small typo in the import file
|
||||
Hashtable htManufacturers=new Hashtable();
|
||||
Hashtable htWholesalers=new Hashtable();
|
||||
UnitOfMeasures Measures;//=UnitOfMeasures.GetItems();
|
||||
PartCategories Categories;//=PartCategories.GetItems();
|
||||
Hashtable htPartNumbers=new Hashtable();
|
||||
|
||||
#endregion
|
||||
|
||||
#region Form load and login
|
||||
private void Form1_Load(object sender, System.EventArgs e)
|
||||
{
|
||||
{
|
||||
System.Reflection.Assembly a = System.Reflection.Assembly.GetExecutingAssembly();
|
||||
string sVersion = "AyaNova® part import / export " + AyaBizUtils.DisplayVersion(a.GetName().Version);
|
||||
System.Diagnostics.FileVersionInfo fileVersion = System.Diagnostics.FileVersionInfo.GetVersionInfo(a.Location);
|
||||
if (fileVersion.FileBuildPart > 0)
|
||||
sVersion += " (Patch " + fileVersion.FileBuildPart.ToString() + ")";
|
||||
this.Text = sVersion;
|
||||
}
|
||||
|
||||
|
||||
mnuImportOptions.Visible = Util.LicensedMode;
|
||||
|
||||
|
||||
//Load cached lists
|
||||
//case 3606
|
||||
// System.Text.StringBuilder sbDupes = new System.Text.StringBuilder();
|
||||
|
||||
VendorPickList vp=VendorPickList.GetList();
|
||||
|
||||
foreach(VendorPickList.VendorPickListInfo i in vp)
|
||||
{
|
||||
switch(i.VendorType)
|
||||
{
|
||||
case VendorTypes.Manufacturer:
|
||||
//case 3606
|
||||
Util.AddItemWithDupeCheck("Vendor.Manufacturer.Name", htManufacturers, i.ID, i.Name);
|
||||
break;
|
||||
|
||||
case VendorTypes.Wholesaler:
|
||||
//case 3606
|
||||
Util.AddItemWithDupeCheck("Vendor.Wholesaler.Name", htWholesalers, i.ID, i.Name);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
PartPickList p=PartPickList.GetAllParts();
|
||||
foreach(PartPickList.PartPickListInfo i in p)
|
||||
{
|
||||
//case 3606
|
||||
Util.AddItemWithDupeCheck("Part.Number", htPartNumbers, i.ID, i.PartNumber);
|
||||
// htPartNumbers.Add(i.PartNumber,i.ID);
|
||||
}
|
||||
|
||||
Measures=UnitOfMeasures.GetItems();
|
||||
Categories=PartCategories.GetItems();
|
||||
|
||||
|
||||
|
||||
MessageBox.Show(
|
||||
"Confirm that you have a backup copy of your AyaNova database before proceeding.\r\n\r\n" +
|
||||
"There is no undo function for importing data other than restoring from a pre-import backup copy.\r\n\r\n" +
|
||||
"** If you are not 100% certain that you have a *working* backup copy ready, stop now **",
|
||||
"ACCIDENTS HAPPEN: DO NOT IMPORT WITHOUT A GOOD BACKUP!");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Read import file
|
||||
private DataTable dtParts;
|
||||
private void mnuOpen_Click(object sender, System.EventArgs e)
|
||||
{
|
||||
if (dlgOpen.ShowDialog() != DialogResult.OK) return;
|
||||
this.mnuImport.Enabled = false;
|
||||
Util.ReadCSV(dataGrid1, ref dtParts, RootObjectTypes.Part, dlgOpen.FileName);
|
||||
this.mnuImport.Enabled = true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Import data
|
||||
Dictionary<string, int> lsMap = null;
|
||||
private void mnuImport_Click(object sender, System.EventArgs e)
|
||||
{
|
||||
//Save grid settings
|
||||
Util.SaveGridMappings(dataGrid1, RootObjectTypes.Part);
|
||||
|
||||
if (dtParts.Rows.Count < 1)
|
||||
{
|
||||
MessageBox.Show("There are no records to import");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//Get the map
|
||||
lsMap = Util.BuildGridImportMap(dataGrid1);
|
||||
|
||||
if (!lsMap.ContainsKey("Number"))
|
||||
{
|
||||
MessageBox.Show("\"Number\" is a required field to uniquely identify parts. Select a column to be used as the unique part number to proceed with import.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
long lBadCount = 0;
|
||||
long lGoodCount = 0;
|
||||
long lUpdatedCount = 0;
|
||||
Waiting w = new Waiting();
|
||||
w.Show();
|
||||
w.Ops = "Importing parts";
|
||||
foreach (DataRow dr in dtParts.Rows)
|
||||
{
|
||||
string sPartNumber = fld(dr, "Number", 255);
|
||||
|
||||
if (string.IsNullOrWhiteSpace(sPartNumber)) continue;
|
||||
Part p = null;
|
||||
|
||||
|
||||
if (htPartNumbers.Contains(sPartNumber))
|
||||
{
|
||||
//case 1404 Open existing for update?
|
||||
if (Util.LicensedMode && Util.IEData.PartUpdate)
|
||||
{
|
||||
//update existing part
|
||||
p = Part.GetItem((Guid)htPartNumbers[sPartNumber]);
|
||||
|
||||
}
|
||||
else//not licensed or nothing chosen to update
|
||||
{
|
||||
lBadCount++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
p = Part.NewItem();
|
||||
}
|
||||
|
||||
w.Step = sPartNumber;
|
||||
if (p.IsNew)
|
||||
p.PartNumber = sPartNumber;
|
||||
|
||||
if (p.IsNew || Util.IEData.PartName)
|
||||
p.Name = fld(dr, "Name", 255);
|
||||
|
||||
//alternative wholesaler?
|
||||
if (p.IsNew || Util.IEData.PartAlternativeWholesaler)
|
||||
{
|
||||
p.AlternativeWholesalerID = GetWholeSalerIDByName(fld(dr, "AlternativeWholeSaler", 255));
|
||||
p.AlternativeWholesalerNumber = fld(dr, "AlternativeWholeSalerNumber", 255);
|
||||
}
|
||||
|
||||
if (p.IsNew || Util.IEData.PartCategoryID)
|
||||
p.PartCategoryID = GetPartCategoryByName(fld(dr, "Category", 255));
|
||||
|
||||
if (p.IsNew || Util.IEData.PartCost)
|
||||
p.Cost = StringToDecimal(fld(dr, "Cost", 255));
|
||||
|
||||
if (p.IsNew || Util.IEData.PartManufacturer)
|
||||
{
|
||||
p.ManufacturerID = GetManufacturerIDByName(fld(dr, "Manufacturer", 255));
|
||||
p.ManufacturerNumber = fld(dr, "ManufacturerNumber", 255);
|
||||
}
|
||||
|
||||
if (p.IsNew || Util.IEData.PartNotes)
|
||||
p.Notes = fld(dr, "Notes", 32767);// t(32767, f.Notes);
|
||||
|
||||
if (p.IsNew || Util.IEData.PartRetail)
|
||||
p.Retail = StringToDecimal(fld(dr, "Retail", 255));
|
||||
|
||||
if (p.IsNew || Util.IEData.PartTrackSerialNumber)
|
||||
p.TrackSerialNumber = StringToBool(fld(dr, "TrackSerialNumber", 255));
|
||||
|
||||
if (p.IsNew || Util.IEData.PartUnitOfMeasureID)
|
||||
p.UnitOfMeasureID = GetPartUnitOfMeasureByName(fld(dr, "UnitOfMeasure", 255));
|
||||
|
||||
if (p.IsNew || Util.IEData.PartUPC)
|
||||
p.UPC = (fld(dr, "UPC", 15));
|
||||
|
||||
if (p.IsNew || Util.IEData.PartWholesaler)
|
||||
{
|
||||
p.WholesalerID = GetWholeSalerIDByName(fld(dr, "WholeSaler", 255));
|
||||
p.WholesalerNumber = (fld(dr, "WholeSalerNumber", 255));
|
||||
}
|
||||
|
||||
|
||||
if (p.IsSavable)
|
||||
{
|
||||
bool bWasNew = p.IsNew;
|
||||
p.Save();
|
||||
if(bWasNew)
|
||||
htPartNumbers.Add(sPartNumber, p.ID);
|
||||
|
||||
if (bWasNew)
|
||||
lGoodCount++;
|
||||
else
|
||||
lUpdatedCount++;
|
||||
}
|
||||
else
|
||||
{
|
||||
lBadCount++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
w.Close();
|
||||
if (Util.LicensedMode && Util.IEData.PartUpdate)//case 1891
|
||||
{
|
||||
if (lBadCount > 0)
|
||||
MessageBox.Show(lGoodCount.ToString() + " Parts were imported / " + lUpdatedCount + " duplicate parts were updated sucessfully.\r\n" +
|
||||
lBadCount.ToString() + " Parts were not imported because they had no number at all or did not pass the business / update rules for a part object.");
|
||||
else
|
||||
MessageBox.Show(lGoodCount.ToString() + " Parts were imported / " + lUpdatedCount + " duplicate parts were updated sucessfully.");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if (lBadCount > 0)
|
||||
MessageBox.Show(lGoodCount.ToString() + " Parts were imported sucessfully.\r\n" +
|
||||
lBadCount.ToString() + " Parts were not imported because a part with the same number already\r\n" +
|
||||
"exists or they had no number at all or did not pass the rules for a part object.");
|
||||
else
|
||||
MessageBox.Show(lGoodCount.ToString() + " Parts were imported sucessfully");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a field from the current data row
|
||||
/// </summary>
|
||||
/// <param name="sColumnNameKey"></param>
|
||||
/// <param name="nLength"></param>
|
||||
/// <returns></returns>
|
||||
private string fld(DataRow dr, string sColumnNameKey, int nLength)
|
||||
{
|
||||
if (lsMap.ContainsKey(sColumnNameKey))
|
||||
{
|
||||
return t(nLength, dr[lsMap[sColumnNameKey]].ToString());
|
||||
}
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="nLength"></param>
|
||||
/// <param name="s"></param>
|
||||
/// <returns></returns>
|
||||
private static string t(int nLength, string s)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(s)) return "";
|
||||
if (s.Length <= nLength) return s;
|
||||
else
|
||||
return s.Substring(0, nLength);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="s"></param>
|
||||
/// <returns></returns>
|
||||
private bool StringToBool(string s)
|
||||
{
|
||||
if(s==null || s=="") return false;
|
||||
if(s.ToUpper().StartsWith("T")) return true;
|
||||
if(s=="1") return true;
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
private decimal StringToDecimal(string s)
|
||||
{
|
||||
if(s==null || s=="") return 0M;
|
||||
try
|
||||
{
|
||||
return System.Convert.ToDecimal(s);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return 0M;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Match and fetch an existing part category or create a new one
|
||||
/// </summary>
|
||||
/// <param name="sName"></param>
|
||||
/// <returns></returns>
|
||||
private Guid GetPartCategoryByName(string sName)
|
||||
{
|
||||
if(sName=="") return Guid.Empty;
|
||||
|
||||
foreach(PartCategory pc in Categories)
|
||||
{
|
||||
if(pc.Name.ToUpper()==sName.ToUpper())
|
||||
return pc.ID;
|
||||
}
|
||||
|
||||
//Not found so add it
|
||||
PartCategory newpc=Categories.Add();
|
||||
newpc.Name=sName;
|
||||
// try
|
||||
// {
|
||||
//case 1412
|
||||
Categories = (PartCategories)Categories.Save();
|
||||
//}
|
||||
//catch (Exception ex)
|
||||
//{
|
||||
// ex.ToString();
|
||||
//}
|
||||
return newpc.ID;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Match and fetch an existing part UnitOfMeasure or create a new one
|
||||
/// </summary>
|
||||
/// <param name="sName"></param>
|
||||
/// <returns></returns>
|
||||
private Guid GetPartUnitOfMeasureByName(string sName)
|
||||
{
|
||||
if(sName=="") return Guid.Empty;
|
||||
|
||||
foreach(UnitOfMeasure uom in Measures)
|
||||
{
|
||||
if(uom.Name.ToUpper()==sName.ToUpper())
|
||||
return uom.ID;
|
||||
}
|
||||
|
||||
//Not found so add it
|
||||
UnitOfMeasure newuom=Measures.Add();
|
||||
newuom.Name=sName;
|
||||
//case 1412
|
||||
Measures = (UnitOfMeasures)Measures.Save();
|
||||
return newuom.ID;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Identify and fetch an existing ID or add a new wholesaler if necessary
|
||||
/// </summary>
|
||||
/// <param name="sName"></param>
|
||||
/// <returns></returns>
|
||||
private Guid GetWholeSalerIDByName(string sName)
|
||||
{
|
||||
if(sName=="") sName="Unspecified wholesaler";
|
||||
foreach(DictionaryEntry de in htWholesalers)
|
||||
{
|
||||
if(de.Key.ToString().ToUpper()==sName.ToUpper())
|
||||
return (Guid)de.Value;
|
||||
}
|
||||
|
||||
//Not there so add a new record for it
|
||||
Vendor v=Vendor.NewItem();
|
||||
v.Active=true;
|
||||
v.VendorType=VendorTypes.Wholesaler;
|
||||
v.Name=sName;
|
||||
v.Save();
|
||||
htWholesalers.Add(sName,v.ID);
|
||||
return v.ID;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Identify and fetch an existing ID or add a new Manufacturer if necessary
|
||||
/// </summary>
|
||||
/// <param name="sName"></param>
|
||||
/// <returns></returns>
|
||||
private Guid GetManufacturerIDByName(string sName)
|
||||
{
|
||||
if(sName=="") sName="Unspecified manufacturer";
|
||||
foreach(DictionaryEntry de in htManufacturers)
|
||||
{
|
||||
if(de.Key.ToString().ToUpper()==sName.ToUpper())
|
||||
return (Guid)de.Value;
|
||||
}
|
||||
|
||||
//Not there so add a new record for it
|
||||
Vendor v=Vendor.NewItem();
|
||||
v.Active=true;
|
||||
v.VendorType=VendorTypes.Manufacturer;
|
||||
v.Name=sName;
|
||||
v.Save();
|
||||
htManufacturers.Add(sName,v.ID);
|
||||
return v.ID;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Export data
|
||||
/// <summary>
|
||||
/// Exports all existing clients to CSV format identical
|
||||
/// to that required for import
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void mnuExport_Click(object sender, System.EventArgs e)
|
||||
{
|
||||
SaveFileDialog sf = new SaveFileDialog();
|
||||
sf.DefaultExt = ".csv";
|
||||
sf.FileName = "parts.csv";
|
||||
if (sf.ShowDialog() != DialogResult.OK) return;
|
||||
|
||||
Cursor=Cursors.WaitCursor;
|
||||
FileHelperEngine engine = new FileHelperEngine(typeof(FHPart));
|
||||
System.Collections.ArrayList alParts=new ArrayList();
|
||||
FHPart fhc;
|
||||
Part p;
|
||||
PartPickList ppl=PartPickList.GetAllParts();
|
||||
Waiting w=new Waiting();
|
||||
w.Show();
|
||||
w.Ops="Exporting parts";
|
||||
foreach(PartPickList.PartPickListInfo i in ppl)
|
||||
{
|
||||
p=Part.GetItem(i.ID);
|
||||
fhc=new FHPart();
|
||||
w.Step=p.Name + " " + p.PartNumber;
|
||||
fhc.Number=p.PartNumber;
|
||||
fhc.Name=p.Name;
|
||||
fhc.AlternativeWholeSaler=GetWholesalerByID(p.AlternativeWholesalerID);
|
||||
fhc.AlternativeWholeSalerNumber=p.AlternativeWholesalerNumber;
|
||||
fhc.Category="";
|
||||
for(int x=0;x<Categories.Count;x++)
|
||||
{
|
||||
if(Categories[x].ID==p.PartCategoryID)
|
||||
{
|
||||
fhc.Category=Categories[x].Name;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
fhc.Cost=p.Cost.ToString();
|
||||
fhc.Manufacturer=GetManufacturerByID(p.ManufacturerID);
|
||||
fhc.ManufacturerNumber=p.ManufacturerNumber;
|
||||
fhc.Notes=p.Notes;
|
||||
fhc.Retail=p.Retail.ToString();
|
||||
fhc.TrackSerialNumber=(p.TrackSerialNumber?"TRUE":"FALSE");
|
||||
fhc.UnitOfMeasure="";
|
||||
for(int x=0;x<Measures.Count;x++)
|
||||
{
|
||||
if(Measures[x].ID==p.UnitOfMeasureID)
|
||||
{
|
||||
fhc.UnitOfMeasure=Measures[x].Name;
|
||||
break;
|
||||
}
|
||||
}
|
||||
fhc.UPC=p.UPC;
|
||||
fhc.WholeSaler=GetWholesalerByID(p.WholesalerID);
|
||||
fhc.WholeSalerNumber=p.WholesalerNumber;
|
||||
|
||||
|
||||
|
||||
|
||||
alParts.Add(fhc);
|
||||
|
||||
|
||||
}
|
||||
w.Close();
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
engine.WriteFile(sf.FileName, (object[]) alParts.ToArray(typeof(FHPart)));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
MessageBox.Show("Error writing the export file:\r\n\r\n" + ex.Message);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Cursor=Cursors.Default;
|
||||
MessageBox.Show("All parts in current AyaNova database have been exported to file:\r\n" +
|
||||
sf.FileName);
|
||||
}
|
||||
|
||||
|
||||
private string GetWholesalerByID(Guid ID)
|
||||
{
|
||||
foreach(DictionaryEntry de in htWholesalers)
|
||||
{
|
||||
if((Guid)de.Value==ID)
|
||||
return de.Key.ToString();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private string GetManufacturerByID(Guid ID)
|
||||
{
|
||||
foreach(DictionaryEntry de in htManufacturers)
|
||||
{
|
||||
if((Guid)de.Value==ID)
|
||||
return de.Key.ToString();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void mnuImportOptions_Click(object sender, EventArgs e)
|
||||
{
|
||||
Util.ShowOptionsDialog();
|
||||
}
|
||||
|
||||
|
||||
#region case 1588
|
||||
private void dataGrid1_BindingContextChanged(object sender, EventArgs e)
|
||||
{
|
||||
// Continue only if the data source has been set.
|
||||
if (dataGrid1.DataSource == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//these are the columns that can be selected by the user to import into
|
||||
List<string> ls = new List<string>();
|
||||
ls.Add("Name");
|
||||
ls.Add("Number");
|
||||
ls.Add("UnitOfMeasure");
|
||||
ls.Add("Cost");
|
||||
ls.Add("Retail");
|
||||
ls.Add("Category");
|
||||
ls.Add("UPC");
|
||||
ls.Add("TrackSerialNumber");
|
||||
ls.Add("WholeSaler");
|
||||
ls.Add("WholeSalerNumber");
|
||||
ls.Add("AlternativeWholeSaler");
|
||||
ls.Add("AlternativeWholeSalerNumber");
|
||||
ls.Add("Manufacturer");
|
||||
ls.Add("ManufacturerNumber");
|
||||
ls.Add("Notes");
|
||||
|
||||
// Add the AutoFilter header cell to each column.
|
||||
foreach (DataGridViewColumn col in dataGrid1.Columns)
|
||||
{
|
||||
col.HeaderCell = new
|
||||
GZDataGridViewComboColumnHeaderCell(col.HeaderCell, ls);
|
||||
}
|
||||
|
||||
// Resize the columns to fit their contents.
|
||||
dataGrid1.AutoResizeColumns();
|
||||
|
||||
}
|
||||
#endregion case 1588
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
}
|
||||
}
|
||||
126
source/Plugins/AyaNova.PlugIn.ImportExportCSV/ImportPart.resx
Normal file
126
source/Plugins/AyaNova.PlugIn.ImportExportCSV/ImportPart.resx
Normal file
@@ -0,0 +1,126 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="mainMenu1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="dlgOpen.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>127, 17</value>
|
||||
</metadata>
|
||||
</root>
|
||||
@@ -0,0 +1,369 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Collections;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Forms;
|
||||
using System.Data;
|
||||
using GZTW.AyaNova.BLL;
|
||||
using System.Threading;
|
||||
using CSLA.Security;
|
||||
using FileHelpers;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace AyaNova.PlugIn.ImportExportCSV
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for Form1.
|
||||
/// </summary>
|
||||
public class ImportPartCategory : System.Windows.Forms.Form
|
||||
{
|
||||
private System.Windows.Forms.DataGridView dataGrid1;
|
||||
private System.Windows.Forms.MainMenu mainMenu1;
|
||||
private System.Windows.Forms.MenuItem mnuOpen;
|
||||
private System.Windows.Forms.MenuItem mnuImport;
|
||||
private System.Windows.Forms.OpenFileDialog dlgOpen;
|
||||
private System.Windows.Forms.MenuItem mnuExport;
|
||||
private MenuItem mnuImportOptions;
|
||||
private IContainer components;
|
||||
|
||||
public ImportPartCategory()
|
||||
{
|
||||
//
|
||||
// Required for Windows Form Designer support
|
||||
//
|
||||
InitializeComponent();
|
||||
|
||||
this.Icon = Resource.ImportExportCSV16icon;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
protected override void Dispose( bool disposing )
|
||||
{
|
||||
if( disposing )
|
||||
{
|
||||
if (components != null)
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
}
|
||||
base.Dispose( disposing );
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.dataGrid1 = new System.Windows.Forms.DataGridView();
|
||||
this.mainMenu1 = new System.Windows.Forms.MainMenu(this.components);
|
||||
this.mnuOpen = new System.Windows.Forms.MenuItem();
|
||||
this.mnuImport = new System.Windows.Forms.MenuItem();
|
||||
this.mnuExport = new System.Windows.Forms.MenuItem();
|
||||
this.mnuImportOptions = new System.Windows.Forms.MenuItem();
|
||||
this.dlgOpen = new System.Windows.Forms.OpenFileDialog();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// dataGrid1
|
||||
//
|
||||
this.dataGrid1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.dataGrid1.Location = new System.Drawing.Point(0, 0);
|
||||
this.dataGrid1.Name = "dataGrid1";
|
||||
this.dataGrid1.ReadOnly = true;
|
||||
this.dataGrid1.Size = new System.Drawing.Size(632, 433);
|
||||
this.dataGrid1.TabIndex = 1;
|
||||
//
|
||||
// mainMenu1
|
||||
//
|
||||
this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
|
||||
this.mnuOpen,
|
||||
this.mnuImport,
|
||||
this.mnuExport,
|
||||
this.mnuImportOptions});
|
||||
//
|
||||
// mnuOpen
|
||||
//
|
||||
this.mnuOpen.Index = 0;
|
||||
this.mnuOpen.Text = "&Open CSV file";
|
||||
this.mnuOpen.Click += new System.EventHandler(this.mnuOpen_Click);
|
||||
//
|
||||
// mnuImport
|
||||
//
|
||||
this.mnuImport.Enabled = false;
|
||||
this.mnuImport.Index = 1;
|
||||
this.mnuImport.Text = "&Import data";
|
||||
this.mnuImport.Click += new System.EventHandler(this.mnuImport_Click);
|
||||
//
|
||||
// mnuExport
|
||||
//
|
||||
this.mnuExport.Index = 2;
|
||||
this.mnuExport.Text = "&Export data";
|
||||
this.mnuExport.Click += new System.EventHandler(this.mnuExport_Click);
|
||||
//
|
||||
// mnuImportOptions
|
||||
//
|
||||
this.mnuImportOptions.Index = 3;
|
||||
this.mnuImportOptions.Text = "&Duplicate import options";
|
||||
this.mnuImportOptions.Visible = false;
|
||||
//
|
||||
// dlgOpen
|
||||
//
|
||||
this.dlgOpen.DefaultExt = "csv";
|
||||
this.dlgOpen.Filter = "CSV files|*.csv";
|
||||
this.dlgOpen.Title = "Comma separated values client file";
|
||||
//
|
||||
// ImportPartCategory
|
||||
//
|
||||
this.AutoScaleBaseSize = new System.Drawing.Size(6, 15);
|
||||
this.ClientSize = new System.Drawing.Size(632, 433);
|
||||
this.Controls.Add(this.dataGrid1);
|
||||
this.Menu = this.mainMenu1;
|
||||
this.Name = "ImportPartCategory";
|
||||
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
|
||||
this.Load += new System.EventHandler(this.Form1_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//
|
||||
// _________ __
|
||||
// \_ ___ \ __ __ _______/ |_ ____ _____
|
||||
// / \ \/ | | \ / ___/\ __\ / _ \ / \
|
||||
// \ \____| | / \___ \ | | ( <_> )| Y Y \
|
||||
// \______ /|____/ /____ > |__| \____/ |__|_| /
|
||||
// \/ \/ \/
|
||||
// _________ .___
|
||||
// \_ ___ \ ____ __| _/ ____
|
||||
// / \ \/ / _ \ / __ | _/ __ \
|
||||
// \ \____( <_> )/ /_/ | \ ___/
|
||||
// \______ / \____/ \____ | \___ >
|
||||
// \/ \/ \/
|
||||
|
||||
|
||||
|
||||
|
||||
#region Form load and login
|
||||
private void Form1_Load(object sender, System.EventArgs e)
|
||||
{
|
||||
|
||||
{
|
||||
System.Reflection.Assembly a = System.Reflection.Assembly.GetExecutingAssembly();
|
||||
string sVersion = "AyaNova® Part category import / export " + AyaBizUtils.DisplayVersion(a.GetName().Version);
|
||||
System.Diagnostics.FileVersionInfo fileVersion = System.Diagnostics.FileVersionInfo.GetVersionInfo(a.Location);
|
||||
if (fileVersion.FileBuildPart > 0)
|
||||
sVersion += " (Patch " + fileVersion.FileBuildPart.ToString() + ")";
|
||||
this.Text = sVersion;
|
||||
}
|
||||
|
||||
|
||||
MessageBox.Show(
|
||||
"Confirm that you have a backup copy of your AyaNova database before proceeding.\r\n\r\n" +
|
||||
"There is no undo function for importing data other than restoring from a pre-import backup copy.\r\n\r\n" +
|
||||
"** If you are not 100% certain that you have a *working* backup copy ready, stop now **",
|
||||
"ACCIDENTS HAPPEN: DO NOT IMPORT WITHOUT A GOOD BACKUP!");
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Read import file
|
||||
private DataTable dtItems;
|
||||
|
||||
private FHPartCategory[] records;
|
||||
private void mnuOpen_Click(object sender, System.EventArgs e)
|
||||
{
|
||||
|
||||
if(dlgOpen.ShowDialog()!=DialogResult.OK) return;
|
||||
this.mnuImport.Enabled=false;
|
||||
if(dtItems==null)
|
||||
{
|
||||
dtItems=new DataTable("CSVItems");
|
||||
dtItems.Columns.Add("Name",typeof(string));
|
||||
}
|
||||
else
|
||||
dtItems.Rows.Clear();
|
||||
|
||||
FileHelperEngine engine = new FileHelperEngine(typeof(FHPartCategory));
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
records= (FHPartCategory[]) engine.ReadFile(dlgOpen.FileName);
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
MessageBox.Show("Error reading the .csv file:\r\n\r\n" + ex.Message);
|
||||
return;
|
||||
}
|
||||
|
||||
string sMax="The first 25 records only";
|
||||
if(records.GetLength(0)<25)
|
||||
sMax="All records";
|
||||
MessageBox.Show(records.GetLength(0).ToString() + " records were read in from the .csv file.\r\n\r\n" +
|
||||
sMax+" will be displayed for you to confirm the fields\r\n" +
|
||||
"and check that the data is displaying correctly before importing.\r\n\r\n" +
|
||||
"If any field doesn't appear correctly you must create a new .csv file with the correct\r\n" +
|
||||
"column order before importing or data will be imported into the wrong place in AyaNova");
|
||||
|
||||
//Maximum 25 records displayed
|
||||
int nMax=0;
|
||||
foreach(FHPartCategory c in records)
|
||||
{
|
||||
|
||||
dtItems.Rows.Add(
|
||||
new object[]{c.Name});
|
||||
nMax++;
|
||||
if(nMax>24) break;
|
||||
}
|
||||
|
||||
|
||||
dataGrid1.DataSource=dtItems;
|
||||
this.mnuImport.Enabled=true;
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Import data
|
||||
private PartCategories PA = null;
|
||||
private bool ContainsItem(string name)
|
||||
{
|
||||
foreach (PartCategory p in PA)
|
||||
{
|
||||
if (p.Name == name)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void mnuImport_Click(object sender, System.EventArgs e)
|
||||
{
|
||||
|
||||
if(records.GetLength(0)<1)
|
||||
{
|
||||
MessageBox.Show("There are no records to import");
|
||||
return;
|
||||
}
|
||||
|
||||
long lBadCount=0;
|
||||
long lGoodCount=0;
|
||||
Waiting w=new Waiting();
|
||||
w.Show();
|
||||
w.Ops="Importing items";
|
||||
PA = PartCategories.GetItems();
|
||||
foreach(FHPartCategory f in records)
|
||||
{
|
||||
|
||||
//If client has a name and doesn't already exist in the db then import it
|
||||
if(f.Name!=null && f.Name!="" && (!ContainsItem(t(255,f.Name))))
|
||||
{
|
||||
w.Step=t(255,f.Name);
|
||||
PartCategory p=PA.Add();
|
||||
p.Active = true;
|
||||
p.Name = t(255, f.Name);
|
||||
|
||||
lGoodCount++;
|
||||
|
||||
}
|
||||
else
|
||||
lBadCount++;
|
||||
|
||||
|
||||
}
|
||||
if (lGoodCount > 0)
|
||||
{
|
||||
w.Step = "Saving...";
|
||||
PA.Save();
|
||||
}
|
||||
|
||||
w.Close();
|
||||
|
||||
if(lBadCount>0)
|
||||
MessageBox.Show(lGoodCount.ToString() + " items were imported sucessfully.\r\n" +
|
||||
lBadCount.ToString() + " items were not imported because an item with the same name already exists.");
|
||||
else
|
||||
MessageBox.Show(lGoodCount.ToString() + " items were imported sucessfully");
|
||||
|
||||
}
|
||||
|
||||
private static string t(int nLength, string s)
|
||||
{
|
||||
if(s==null || s=="") return "";
|
||||
if(s.Length<=nLength) return s;
|
||||
else
|
||||
return s.Substring(0,nLength);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Export data
|
||||
/// <summary>
|
||||
/// Exports all existing items to CSV format identical
|
||||
/// to that required for import
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void mnuExport_Click(object sender, System.EventArgs e)
|
||||
{
|
||||
SaveFileDialog sf = new SaveFileDialog();
|
||||
sf.DefaultExt = ".csv";
|
||||
sf.FileName = "PartCategory.csv";
|
||||
if (sf.ShowDialog() != DialogResult.OK) return;
|
||||
|
||||
Cursor=Cursors.WaitCursor;
|
||||
FileHelperEngine engine = new FileHelperEngine(typeof(FHPartCategory));
|
||||
System.Collections.ArrayList allItems = new ArrayList();
|
||||
FHPartCategory fhc;
|
||||
PA = PartCategories.GetItems();
|
||||
Waiting w=new Waiting();
|
||||
w.Show();
|
||||
w.Ops="Exporting items";
|
||||
foreach (PartCategory p in PA)
|
||||
{
|
||||
fhc=new FHPartCategory();
|
||||
w.Step=p.Name;
|
||||
fhc.Name=p.Name;
|
||||
allItems.Add(fhc);
|
||||
|
||||
}
|
||||
w.Close();
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
engine.WriteFile(sf.FileName, (object[])allItems.ToArray(typeof(FHPartCategory)));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
MessageBox.Show("Error writing the export file:\r\n\r\n" + ex.Message);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Cursor=Cursors.Default;
|
||||
MessageBox.Show("All Part category items in current AyaNova database have been exported to file:\r\n" +
|
||||
sf.FileName);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="mainMenu1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="dlgOpen.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>127, 17</value>
|
||||
</metadata>
|
||||
</root>
|
||||
399
source/Plugins/AyaNova.PlugIn.ImportExportCSV/ImportPriority.cs
Normal file
399
source/Plugins/AyaNova.PlugIn.ImportExportCSV/ImportPriority.cs
Normal file
@@ -0,0 +1,399 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Collections;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Forms;
|
||||
using System.Data;
|
||||
using GZTW.AyaNova.BLL;
|
||||
using System.Threading;
|
||||
using CSLA.Security;
|
||||
using FileHelpers;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace AyaNova.PlugIn.ImportExportCSV
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for Form1.
|
||||
/// </summary>
|
||||
public class ImportPriority : System.Windows.Forms.Form
|
||||
{
|
||||
private System.Windows.Forms.DataGridView dataGrid1;
|
||||
private System.Windows.Forms.MainMenu mainMenu1;
|
||||
private System.Windows.Forms.MenuItem mnuOpen;
|
||||
private System.Windows.Forms.MenuItem mnuImport;
|
||||
private System.Windows.Forms.OpenFileDialog dlgOpen;
|
||||
private System.Windows.Forms.MenuItem mnuExport;
|
||||
private MenuItem mnuImportOptions;
|
||||
private IContainer components;
|
||||
|
||||
public ImportPriority()
|
||||
{
|
||||
//
|
||||
// Required for Windows Form Designer support
|
||||
//
|
||||
InitializeComponent();
|
||||
|
||||
this.Icon = Resource.ImportExportCSV16icon;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
protected override void Dispose( bool disposing )
|
||||
{
|
||||
if( disposing )
|
||||
{
|
||||
if (components != null)
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
}
|
||||
base.Dispose( disposing );
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.dataGrid1 = new System.Windows.Forms.DataGridView();
|
||||
this.mainMenu1 = new System.Windows.Forms.MainMenu(this.components);
|
||||
this.mnuOpen = new System.Windows.Forms.MenuItem();
|
||||
this.mnuImport = new System.Windows.Forms.MenuItem();
|
||||
this.mnuExport = new System.Windows.Forms.MenuItem();
|
||||
this.mnuImportOptions = new System.Windows.Forms.MenuItem();
|
||||
this.dlgOpen = new System.Windows.Forms.OpenFileDialog();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// dataGrid1
|
||||
//
|
||||
this.dataGrid1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.dataGrid1.Location = new System.Drawing.Point(0, 0);
|
||||
this.dataGrid1.Name = "dataGrid1";
|
||||
this.dataGrid1.ReadOnly = true;
|
||||
this.dataGrid1.Size = new System.Drawing.Size(632, 433);
|
||||
this.dataGrid1.TabIndex = 1;
|
||||
//
|
||||
// mainMenu1
|
||||
//
|
||||
this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
|
||||
this.mnuOpen,
|
||||
this.mnuImport,
|
||||
this.mnuExport,
|
||||
this.mnuImportOptions});
|
||||
//
|
||||
// mnuOpen
|
||||
//
|
||||
this.mnuOpen.Index = 0;
|
||||
this.mnuOpen.Text = "&Open CSV file";
|
||||
this.mnuOpen.Click += new System.EventHandler(this.mnuOpen_Click);
|
||||
//
|
||||
// mnuImport
|
||||
//
|
||||
this.mnuImport.Enabled = false;
|
||||
this.mnuImport.Index = 1;
|
||||
this.mnuImport.Text = "&Import data";
|
||||
this.mnuImport.Click += new System.EventHandler(this.mnuImport_Click);
|
||||
//
|
||||
// mnuExport
|
||||
//
|
||||
this.mnuExport.Index = 2;
|
||||
this.mnuExport.Text = "&Export data";
|
||||
this.mnuExport.Click += new System.EventHandler(this.mnuExport_Click);
|
||||
//
|
||||
// mnuImportOptions
|
||||
//
|
||||
this.mnuImportOptions.Index = 3;
|
||||
this.mnuImportOptions.Text = "&Duplicate import options";
|
||||
this.mnuImportOptions.Visible = false;
|
||||
//
|
||||
// dlgOpen
|
||||
//
|
||||
this.dlgOpen.DefaultExt = "csv";
|
||||
this.dlgOpen.Filter = "CSV files|*.csv";
|
||||
this.dlgOpen.Title = "Comma separated values client file";
|
||||
//
|
||||
// ImportPriority
|
||||
//
|
||||
this.AutoScaleBaseSize = new System.Drawing.Size(6, 15);
|
||||
this.ClientSize = new System.Drawing.Size(632, 433);
|
||||
this.Controls.Add(this.dataGrid1);
|
||||
this.Menu = this.mainMenu1;
|
||||
this.Name = "ImportPriority";
|
||||
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
|
||||
this.Load += new System.EventHandler(this.Form1_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//
|
||||
// _________ __
|
||||
// \_ ___ \ __ __ _______/ |_ ____ _____
|
||||
// / \ \/ | | \ / ___/\ __\ / _ \ / \
|
||||
// \ \____| | / \___ \ | | ( <_> )| Y Y \
|
||||
// \______ /|____/ /____ > |__| \____/ |__|_| /
|
||||
// \/ \/ \/
|
||||
// _________ .___
|
||||
// \_ ___ \ ____ __| _/ ____
|
||||
// / \ \/ / _ \ / __ | _/ __ \
|
||||
// \ \____( <_> )/ /_/ | \ ___/
|
||||
// \______ / \____/ \____ | \___ >
|
||||
// \/ \/ \/
|
||||
|
||||
|
||||
|
||||
|
||||
#region Form load and login
|
||||
private void Form1_Load(object sender, System.EventArgs e)
|
||||
{
|
||||
|
||||
{
|
||||
System.Reflection.Assembly a = System.Reflection.Assembly.GetExecutingAssembly();
|
||||
string sVersion = "AyaNova® Priority import / export " + AyaBizUtils.DisplayVersion(a.GetName().Version);
|
||||
System.Diagnostics.FileVersionInfo fileVersion = System.Diagnostics.FileVersionInfo.GetVersionInfo(a.Location);
|
||||
if (fileVersion.FileBuildPart > 0)
|
||||
sVersion += " (Patch " + fileVersion.FileBuildPart.ToString() + ")";
|
||||
this.Text = sVersion;
|
||||
}
|
||||
|
||||
|
||||
MessageBox.Show(
|
||||
"Confirm that you have a backup copy of your AyaNova database before proceeding.\r\n\r\n" +
|
||||
"There is no undo function for importing data other than restoring from a pre-import backup copy.\r\n\r\n" +
|
||||
"** If you are not 100% certain that you have a *working* backup copy ready, stop now **",
|
||||
"ACCIDENTS HAPPEN: DO NOT IMPORT WITHOUT A GOOD BACKUP!");
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Read import file
|
||||
private DataTable dtItems;
|
||||
|
||||
private FHPriority[] records;
|
||||
private void mnuOpen_Click(object sender, System.EventArgs e)
|
||||
{
|
||||
|
||||
if(dlgOpen.ShowDialog()!=DialogResult.OK) return;
|
||||
this.mnuImport.Enabled=false;
|
||||
if(dtItems==null)
|
||||
{
|
||||
dtItems=new DataTable("CSVItems");
|
||||
dtItems.Columns.Add("Name",typeof(string));
|
||||
dtItems.Columns.Add("ARGB", typeof(string));
|
||||
}
|
||||
else
|
||||
dtItems.Rows.Clear();
|
||||
|
||||
FileHelperEngine engine = new FileHelperEngine(typeof(FHPriority));
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
records= (FHPriority[]) engine.ReadFile(dlgOpen.FileName);
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
MessageBox.Show("Error reading the .csv file:\r\n\r\n" + ex.Message);
|
||||
return;
|
||||
}
|
||||
|
||||
string sMax="The first 25 records only";
|
||||
if(records.GetLength(0)<25)
|
||||
sMax="All records";
|
||||
MessageBox.Show(records.GetLength(0).ToString() + " records were read in from the .csv file.\r\n\r\n" +
|
||||
sMax+" will be displayed for you to confirm the fields\r\n" +
|
||||
"and check that the data is displaying correctly before importing.\r\n\r\n" +
|
||||
"If any field doesn't appear correctly you must create a new .csv file with the correct\r\n" +
|
||||
"column order before importing or data will be imported into the wrong place in AyaNova");
|
||||
|
||||
//Maximum 25 records displayed
|
||||
int nMax=0;
|
||||
foreach(FHPriority c in records)
|
||||
{
|
||||
dtItems.Rows.Add(
|
||||
new object[]{c.Name, c.ARGB});
|
||||
nMax++;
|
||||
if(nMax>24) break;
|
||||
}
|
||||
|
||||
|
||||
dataGrid1.DataSource=dtItems;
|
||||
this.mnuImport.Enabled=true;
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Import data
|
||||
private Priorities PA = null;
|
||||
private bool ContainsItem(string name)
|
||||
{
|
||||
foreach (Priority p in PA)
|
||||
{
|
||||
if (p.Name == name)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void mnuImport_Click(object sender, System.EventArgs e)
|
||||
{
|
||||
|
||||
if(records.GetLength(0)<1)
|
||||
{
|
||||
MessageBox.Show("There are no records to import");
|
||||
return;
|
||||
}
|
||||
|
||||
long lBadCount=0;
|
||||
long lGoodCount=0;
|
||||
Waiting w=new Waiting();
|
||||
w.Show();
|
||||
w.Ops="Importing items";
|
||||
PA = Priorities.GetItems();
|
||||
foreach(FHPriority f in records)
|
||||
{
|
||||
|
||||
//If client has a name and doesn't already exist in the db then import it
|
||||
if(f.Name!=null && f.Name!="" && (!ContainsItem(t(255,f.Name))))
|
||||
{
|
||||
w.Step=t(255,f.Name);
|
||||
Priority p=PA.Add();
|
||||
p.Active = true;
|
||||
p.Name = t(255, f.Name);
|
||||
string sArgb=t(255,f.ARGB);
|
||||
//try to set ARGB, if it's unparseable or empty then the
|
||||
//default will take effect based on Priority constructor (-1 white)
|
||||
if (!string.IsNullOrEmpty(sArgb))
|
||||
{
|
||||
p.Color = argbFromHexString(sArgb);
|
||||
}
|
||||
|
||||
lGoodCount++;
|
||||
|
||||
}
|
||||
else
|
||||
lBadCount++;
|
||||
|
||||
|
||||
}
|
||||
if (lGoodCount > 0)
|
||||
{
|
||||
w.Step = "Saving...";
|
||||
PA.Save();
|
||||
}
|
||||
|
||||
w.Close();
|
||||
|
||||
if(lBadCount>0)
|
||||
MessageBox.Show(lGoodCount.ToString() + " items were imported sucessfully.\r\n" +
|
||||
lBadCount.ToString() + " items were not imported because an item with the same name already exists.");
|
||||
else
|
||||
MessageBox.Show(lGoodCount.ToString() + " items were imported sucessfully");
|
||||
|
||||
}
|
||||
|
||||
private static string t(int nLength, string s)
|
||||
{
|
||||
if(s==null || s=="") return "";
|
||||
if(s.Length<=nLength) return s;
|
||||
else
|
||||
return s.Substring(0,nLength);
|
||||
}
|
||||
|
||||
//Note returns white value if anything
|
||||
//doesn't parse
|
||||
private static int argbFromHexString(string sHex)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(sHex))
|
||||
{
|
||||
sHex = sHex.Trim();
|
||||
//leading hash important for translator
|
||||
if (!sHex.StartsWith("#"))
|
||||
sHex = "#" + sHex;
|
||||
return System.Drawing.ColorTranslator.FromHtml(sHex).ToArgb();
|
||||
}
|
||||
//empty return white
|
||||
return System.Drawing.Color.White.ToArgb();
|
||||
}
|
||||
|
||||
private static string ArgbToHex(int intArgb)
|
||||
{
|
||||
return ColorTranslator.ToHtml(Color.FromArgb(intArgb));
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Export data
|
||||
/// <summary>
|
||||
/// Exports all existing items to CSV format identical
|
||||
/// to that required for import
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void mnuExport_Click(object sender, System.EventArgs e)
|
||||
{
|
||||
SaveFileDialog sf = new SaveFileDialog();
|
||||
sf.DefaultExt = ".csv";
|
||||
sf.FileName = "Priority.csv";
|
||||
if (sf.ShowDialog() != DialogResult.OK) return;
|
||||
|
||||
Cursor=Cursors.WaitCursor;
|
||||
FileHelperEngine engine = new FileHelperEngine(typeof(FHPriority));
|
||||
System.Collections.ArrayList allItems = new ArrayList();
|
||||
FHPriority fhc;
|
||||
PA = Priorities.GetItems();
|
||||
Waiting w=new Waiting();
|
||||
w.Show();
|
||||
w.Ops="Exporting items";
|
||||
foreach (Priority p in PA)
|
||||
{
|
||||
fhc=new FHPriority();
|
||||
w.Step=p.Name;
|
||||
fhc.Name=p.Name;
|
||||
|
||||
fhc.ARGB = ArgbToHex(p.Color);
|
||||
allItems.Add(fhc);
|
||||
|
||||
}
|
||||
w.Close();
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
engine.WriteFile(sf.FileName, (object[])allItems.ToArray(typeof(FHPriority)));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
MessageBox.Show("Error writing the export file:\r\n\r\n" + ex.Message);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Cursor=Cursors.Default;
|
||||
MessageBox.Show("All Priority items in current AyaNova database have been exported to file:\r\n" +
|
||||
sf.FileName);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="mainMenu1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="dlgOpen.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>127, 17</value>
|
||||
</metadata>
|
||||
</root>
|
||||
689
source/Plugins/AyaNova.PlugIn.ImportExportCSV/ImportRate.cs
Normal file
689
source/Plugins/AyaNova.PlugIn.ImportExportCSV/ImportRate.cs
Normal file
@@ -0,0 +1,689 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Collections;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Forms;
|
||||
using System.Data;
|
||||
using GZTW.AyaNova.BLL;
|
||||
using System.Threading;
|
||||
using CSLA.Security;
|
||||
using FileHelpers;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace AyaNova.PlugIn.ImportExportCSV
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for Form1.
|
||||
/// </summary>
|
||||
public class ImportRate : System.Windows.Forms.Form
|
||||
{
|
||||
private System.Windows.Forms.DataGridView DataGridView1;
|
||||
private System.Windows.Forms.MainMenu mainMenu1;
|
||||
private System.Windows.Forms.MenuItem mnuOpen;
|
||||
private System.Windows.Forms.MenuItem mnuImport;
|
||||
private System.Windows.Forms.OpenFileDialog dlgOpen;
|
||||
private System.Windows.Forms.MenuItem mnuExport;
|
||||
private MenuItem mnuImportOptions;
|
||||
private IContainer components;
|
||||
|
||||
public ImportRate()
|
||||
{
|
||||
//
|
||||
// Required for Windows Form Designer support
|
||||
//
|
||||
InitializeComponent();
|
||||
|
||||
this.Icon = Resource.ImportExportCSV16icon;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
if (components != null)
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.DataGridView1 = new System.Windows.Forms.DataGridView();
|
||||
this.mainMenu1 = new System.Windows.Forms.MainMenu(this.components);
|
||||
this.mnuOpen = new System.Windows.Forms.MenuItem();
|
||||
this.mnuImport = new System.Windows.Forms.MenuItem();
|
||||
this.mnuExport = new System.Windows.Forms.MenuItem();
|
||||
this.mnuImportOptions = new System.Windows.Forms.MenuItem();
|
||||
this.dlgOpen = new System.Windows.Forms.OpenFileDialog();
|
||||
((System.ComponentModel.ISupportInitialize)(this.DataGridView1)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// DataGridView1
|
||||
//
|
||||
this.DataGridView1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.DataGridView1.Location = new System.Drawing.Point(0, 0);
|
||||
this.DataGridView1.Name = "DataGridView1";
|
||||
this.DataGridView1.ReadOnly = true;
|
||||
this.DataGridView1.Size = new System.Drawing.Size(632, 433);
|
||||
this.DataGridView1.TabIndex = 1;
|
||||
this.DataGridView1.DataBindingComplete += new System.Windows.Forms.DataGridViewBindingCompleteEventHandler(this.DataGridView1_DataBindingComplete);
|
||||
this.DataGridView1.BindingContextChanged += new System.EventHandler(this.DataGridView1_BindingContextChanged);
|
||||
//
|
||||
// mainMenu1
|
||||
//
|
||||
this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
|
||||
this.mnuOpen,
|
||||
this.mnuImport,
|
||||
this.mnuExport,
|
||||
this.mnuImportOptions});
|
||||
//
|
||||
// mnuOpen
|
||||
//
|
||||
this.mnuOpen.Index = 0;
|
||||
this.mnuOpen.Text = "&Open CSV file";
|
||||
this.mnuOpen.Click += new System.EventHandler(this.mnuOpen_Click);
|
||||
//
|
||||
// mnuImport
|
||||
//
|
||||
this.mnuImport.Enabled = false;
|
||||
this.mnuImport.Index = 1;
|
||||
this.mnuImport.Text = "&Import data";
|
||||
this.mnuImport.Click += new System.EventHandler(this.mnuImport_Click);
|
||||
//
|
||||
// mnuExport
|
||||
//
|
||||
this.mnuExport.Index = 2;
|
||||
this.mnuExport.Text = "&Export data";
|
||||
this.mnuExport.Click += new System.EventHandler(this.mnuExport_Click);
|
||||
//
|
||||
// mnuImportOptions
|
||||
//
|
||||
this.mnuImportOptions.Index = 3;
|
||||
this.mnuImportOptions.Text = "&Duplicate import options";
|
||||
this.mnuImportOptions.Visible = false;
|
||||
this.mnuImportOptions.Click += new System.EventHandler(this.mnuImportOptions_Click);
|
||||
//
|
||||
// dlgOpen
|
||||
//
|
||||
this.dlgOpen.DefaultExt = "csv";
|
||||
this.dlgOpen.Filter = "CSV files|*.csv";
|
||||
this.dlgOpen.Title = "Comma separated values Rate file";
|
||||
//
|
||||
// ImportRate
|
||||
//
|
||||
this.AutoScaleBaseSize = new System.Drawing.Size(6, 15);
|
||||
this.ClientSize = new System.Drawing.Size(632, 433);
|
||||
this.Controls.Add(this.DataGridView1);
|
||||
this.Menu = this.mainMenu1;
|
||||
this.Name = "ImportRate";
|
||||
this.Text = "Rate importer v2.0.0.0";
|
||||
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
|
||||
this.Load += new System.EventHandler(this.Form1_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.DataGridView1)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//
|
||||
// _________ __
|
||||
// \_ ___ \ __ __ _______/ |_ ____ _____
|
||||
// / \ \/ | | \ / ___/\ __\ / _ \ / \
|
||||
// \ \____| | / \___ \ | | ( <_> )| Y Y \
|
||||
// \______ /|____/ /____ > |__| \____/ |__|_| /
|
||||
// \/ \/ \/
|
||||
// _________ .___
|
||||
// \_ ___ \ ____ __| _/ ____
|
||||
// / \ \/ / _ \ / __ | _/ __ \
|
||||
// \ \____( <_> )/ /_/ | \ ___/
|
||||
// \______ / \____/ \____ | \___ >
|
||||
// \/ \/ \/
|
||||
|
||||
|
||||
#region list objects
|
||||
//These are name value lists used to
|
||||
//keep track of the id's of existing items
|
||||
//that are either pre-existing or have been created during import
|
||||
//this supports the code that matches text names of objects to their id's
|
||||
//i.e. "IBM" as a manufacturer to the IBM record in AyaNova already
|
||||
//case is not taken into account during comparison to ensure no little
|
||||
//mismatches due to a small typo in the import file
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Form load and login
|
||||
private void Form1_Load(object sender, System.EventArgs e)
|
||||
{
|
||||
{
|
||||
System.Reflection.Assembly a = System.Reflection.Assembly.GetExecutingAssembly();
|
||||
string sVersion = "AyaNova® Rate import / export " + AyaBizUtils.DisplayVersion(a.GetName().Version);
|
||||
System.Diagnostics.FileVersionInfo fileVersion = System.Diagnostics.FileVersionInfo.GetVersionInfo(a.Location);
|
||||
if (fileVersion.FileBuildPart > 0)
|
||||
sVersion += " (Patch " + fileVersion.FileBuildPart.ToString() + ")";
|
||||
this.Text = sVersion;
|
||||
}
|
||||
|
||||
|
||||
mnuImportOptions.Visible = Util.LicensedMode;
|
||||
|
||||
|
||||
|
||||
MessageBox.Show(
|
||||
"Confirm that you have a backup copy of your AyaNova database before proceeding.\r\n\r\n" +
|
||||
"There is no undo function for importing data other than restoring from a pre-import backup copy.\r\n\r\n" +
|
||||
"** If you are not 100% certain that you have a *working* backup copy ready, stop now **",
|
||||
"ACCIDENTS HAPPEN: DO NOT IMPORT WITHOUT A GOOD BACKUP!");
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Read import file
|
||||
private DataTable dtRates;
|
||||
|
||||
//private FHRate[] records;
|
||||
private void mnuOpen_Click(object sender, System.EventArgs e)
|
||||
{
|
||||
if (dlgOpen.ShowDialog() != DialogResult.OK) return;
|
||||
this.mnuImport.Enabled = false;
|
||||
Util.ReadCSV(DataGridView1, ref dtRates, RootObjectTypes.Rate, dlgOpen.FileName);
|
||||
this.mnuImport.Enabled = true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Import data
|
||||
Dictionary<string, int> lsMap = null;
|
||||
private void mnuImport_Click(object sender, System.EventArgs e)
|
||||
{
|
||||
//Save grid settings
|
||||
Util.SaveGridMappings(DataGridView1, RootObjectTypes.Rate);
|
||||
|
||||
if (dtRates.Rows.Count < 1)
|
||||
{
|
||||
MessageBox.Show("There are no records to import");
|
||||
return;
|
||||
}
|
||||
|
||||
//Get the map
|
||||
lsMap = Util.BuildGridImportMap(DataGridView1);
|
||||
|
||||
if (!lsMap.ContainsKey("Name"))
|
||||
{
|
||||
MessageBox.Show("\"Name\" is a required field to uniquely identify Rates. Select a column to be used as the unique Rate name to proceed with import.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!lsMap.ContainsKey("RateType"))
|
||||
{
|
||||
MessageBox.Show("\"RateType\" wasn't specified. Import will default to Service type rates.");
|
||||
}
|
||||
|
||||
|
||||
long lBadCount = 0;
|
||||
long lGoodCount = 0;
|
||||
long lUpdatedCount = 0;
|
||||
|
||||
//case 1737 cache
|
||||
ClientGroups cgroups = ClientGroups.GetItems();
|
||||
Dictionary<string, Guid> regions = new Dictionary<string, Guid>();
|
||||
RateUnitChargeDescriptions rateUnitChageDescriptions = RateUnitChargeDescriptions.GetItems();
|
||||
|
||||
|
||||
RegionList rl = RegionList.GetList("");
|
||||
foreach (RegionList.RegionListInfo i in rl)
|
||||
{
|
||||
//case 3606
|
||||
if (!regions.ContainsKey(i.LT_Region_Label_Name.Display))
|
||||
regions.Add(i.LT_Region_Label_Name.Display, i.LT_Region_Label_Name.Value);
|
||||
}
|
||||
|
||||
//Unique to rates is that they are an editable child collection
|
||||
//so need to fetch it all and use it in this function
|
||||
Rates TheRates = Rates.GetItems(false);
|
||||
|
||||
Waiting w = new Waiting();
|
||||
w.Show();
|
||||
w.Ops = "Importing Rates";
|
||||
foreach (DataRow dr in dtRates.Rows)
|
||||
{
|
||||
if (fld(dr, "Name", 255) == "") continue;
|
||||
Rate c = null;
|
||||
|
||||
string sRateName = fld(dr, "Name", 255);
|
||||
if (TheRates.Contains(sRateName))
|
||||
{
|
||||
//case 1404 Open existing for update?
|
||||
if (Util.LicensedMode && Util.IEData.RateUpdate)
|
||||
{
|
||||
//update existing Rate
|
||||
c = TheRates[sRateName];
|
||||
}
|
||||
else//not licensed or nothing chosen to update
|
||||
{
|
||||
lBadCount++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
c = TheRates.Add();
|
||||
}
|
||||
|
||||
|
||||
w.Step = sRateName;
|
||||
|
||||
if (c.IsNew)
|
||||
c.Name = sRateName;
|
||||
|
||||
if (c.IsNew || Util.IEData.RateDescription)
|
||||
{
|
||||
c.Description = fld(dr, "Description", 255);
|
||||
}
|
||||
|
||||
if (c.IsNew || Util.IEData.RateAccountNumber)
|
||||
{
|
||||
c.AccountNumber = fld(dr, "AccountNumber", 255);
|
||||
}
|
||||
|
||||
if (c.IsNew || Util.IEData.RateCost)
|
||||
{
|
||||
c.Cost = StringToDecimal(fld(dr, "Cost", 255));
|
||||
}
|
||||
|
||||
if (c.IsNew || Util.IEData.RateCharge)
|
||||
{
|
||||
c.Charge = StringToDecimal(fld(dr, "RetailCharge", 255));
|
||||
}
|
||||
|
||||
if (c.IsNew || Util.IEData.RateContractRate)
|
||||
c.ContractRate = StringToBool(fld(dr, "ContractRate", 255));
|
||||
|
||||
if (c.IsNew || Util.IEData.RateType)
|
||||
c.RateType = GetRateTypeByName(fld(dr, "RateType", 255));
|
||||
|
||||
|
||||
|
||||
|
||||
//------------------------------------------------
|
||||
//Rate group, region, dispatch zone
|
||||
|
||||
//rate unit charge description
|
||||
if (c.IsNew || Util.IEData.RateUnitChargeDescription)
|
||||
{
|
||||
Guid RateUnitChargeDescriptionID = Guid.Empty;
|
||||
string s = fld(dr, "UnitChargeDescription", 255).Trim();
|
||||
if (!string.IsNullOrWhiteSpace(s))
|
||||
{
|
||||
foreach (RateUnitChargeDescription ruc in rateUnitChageDescriptions)
|
||||
{
|
||||
if (ruc.Name.Equals(s, StringComparison.CurrentCultureIgnoreCase))
|
||||
{
|
||||
RateUnitChargeDescriptionID = ruc.ID;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (RateUnitChargeDescriptionID == Guid.Empty)
|
||||
{
|
||||
//wasn't in the list so add it and save it
|
||||
RateUnitChargeDescription ruc = rateUnitChageDescriptions.Add();
|
||||
ruc.Name = s;
|
||||
RateUnitChargeDescriptionID = ruc.ID;
|
||||
rateUnitChageDescriptions = (RateUnitChargeDescriptions)rateUnitChageDescriptions.Save();
|
||||
}
|
||||
}
|
||||
c.RateUnitChargeDescriptionID = RateUnitChargeDescriptionID;
|
||||
}
|
||||
|
||||
|
||||
//client group
|
||||
if (c.IsNew || Util.IEData.ClientGroup)
|
||||
{
|
||||
Guid ClientGroupID = Guid.Empty;
|
||||
string s = fld(dr, "ClientGroup", 255).Trim();
|
||||
if (!string.IsNullOrWhiteSpace(s))
|
||||
{
|
||||
foreach (ClientGroup cg in cgroups)
|
||||
{
|
||||
if (cg.Name.Equals(s, StringComparison.CurrentCultureIgnoreCase))
|
||||
{
|
||||
ClientGroupID = cg.ID;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (ClientGroupID == Guid.Empty)
|
||||
{
|
||||
//wasn't in the list so add it and save it
|
||||
ClientGroup cg = cgroups.Add();
|
||||
cg.Name = s;
|
||||
ClientGroupID = cg.ID;
|
||||
cgroups = (ClientGroups)cgroups.Save();
|
||||
|
||||
}
|
||||
}
|
||||
c.ClientGroupID = ClientGroupID;
|
||||
}
|
||||
|
||||
//region
|
||||
if (c.IsNew || Util.IEData.RateRegion)
|
||||
{
|
||||
Guid RegionID = GZTW.AyaNova.BLL.Region.DefaultRegionID;
|
||||
string s = fld(dr, "Region", 255).Trim();
|
||||
if (!string.IsNullOrWhiteSpace(s))
|
||||
{
|
||||
if (regions.ContainsKey(s))
|
||||
RegionID = regions[s];
|
||||
else
|
||||
{
|
||||
GZTW.AyaNova.BLL.Region r = GZTW.AyaNova.BLL.Region.NewItem();
|
||||
r.Active = true;
|
||||
r.Name = s;
|
||||
RegionID = r.ID;
|
||||
r = (GZTW.AyaNova.BLL.Region)r.Save();
|
||||
regions.Add(r.Name, r.ID);
|
||||
}
|
||||
}
|
||||
c.RegionID = RegionID;
|
||||
}
|
||||
|
||||
|
||||
//================================================
|
||||
|
||||
//modified from normal single root object save
|
||||
//saves (and updates) the collection on each item
|
||||
if (TheRates.IsSavable)
|
||||
{
|
||||
bool bWasNew = c.IsNew;
|
||||
TheRates = (Rates)TheRates.Save();
|
||||
|
||||
if (bWasNew)
|
||||
lGoodCount++;
|
||||
else
|
||||
lUpdatedCount++;
|
||||
}
|
||||
else
|
||||
{
|
||||
lBadCount++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
w.Close();
|
||||
if (Util.LicensedMode && Util.IEData.RateUpdate)
|
||||
{
|
||||
if (lBadCount > 0)
|
||||
MessageBox.Show(lGoodCount.ToString() + " Rates were imported / " + lUpdatedCount + " duplicate Rates were updated sucessfully.\r\n" +
|
||||
lBadCount.ToString() + " Rates were not imported because they had no name at all or did not pass the business / update rules for a Rate object.");
|
||||
else
|
||||
MessageBox.Show(lGoodCount.ToString() + " Rates were imported / " + lUpdatedCount + " duplicate Rates were updated sucessfully.");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (lBadCount > 0)
|
||||
MessageBox.Show(lGoodCount.ToString() + " Rates were imported sucessfully.\r\n" +
|
||||
lBadCount.ToString() + " Rates were not imported because a Rate with the same name already\r\n" +
|
||||
"exists or they had no name at all or did not pass the rules for a Rate object.");
|
||||
else
|
||||
MessageBox.Show(lGoodCount.ToString() + " Rates were imported sucessfully.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Get a field from the current data row
|
||||
/// </summary>
|
||||
/// <param name="sColumnNameKey"></param>
|
||||
/// <param name="nLength"></param>
|
||||
/// <returns></returns>
|
||||
private string fld(DataRow dr, string sColumnNameKey, int nLength)
|
||||
{
|
||||
if (lsMap.ContainsKey(sColumnNameKey))
|
||||
{
|
||||
return t(nLength, dr[lsMap[sColumnNameKey]].ToString());
|
||||
}
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="nLength"></param>
|
||||
/// <param name="s"></param>
|
||||
/// <returns></returns>
|
||||
private static string t(int nLength, string s)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(s)) return "";
|
||||
if (s.Length <= nLength) return s;
|
||||
else
|
||||
return s.Substring(0, nLength);
|
||||
}
|
||||
|
||||
private decimal StringToDecimal(string s)
|
||||
{
|
||||
if (s == null || s == "") return 0M;
|
||||
try
|
||||
{
|
||||
return System.Convert.ToDecimal(s);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return 0M;
|
||||
}
|
||||
}
|
||||
|
||||
private bool StringToBool(string s)
|
||||
{
|
||||
if (s == null || s == "") return false;
|
||||
if (s.ToUpper().StartsWith("T")) return true;
|
||||
if (s == "1") return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
//get rate type by name, if it doesn't start with T then it's a service rate
|
||||
private RateTypes GetRateTypeByName(string sName)
|
||||
{
|
||||
if (sName == "") return RateTypes.Service;
|
||||
|
||||
sName = sName.ToUpper();
|
||||
if (sName.StartsWith("T"))
|
||||
return RateTypes.Travel;
|
||||
return RateTypes.Service;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Export data
|
||||
/// <summary>
|
||||
/// Exports all existing Rates to CSV format identical
|
||||
/// to that required for import
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void mnuExport_Click(object sender, System.EventArgs e)
|
||||
{
|
||||
#region Cache lists
|
||||
ClientGroups cgroups = ClientGroups.GetItems();
|
||||
RateUnitChargeDescriptions rateUnitChageDescriptions = RateUnitChargeDescriptions.GetItems();
|
||||
RegionList regions = RegionList.GetList("");
|
||||
#endregion Cached lists
|
||||
|
||||
|
||||
SaveFileDialog sf = new SaveFileDialog();
|
||||
sf.DefaultExt = ".csv";
|
||||
sf.FileName = "Rates.csv";
|
||||
if (sf.ShowDialog() != DialogResult.OK) return;
|
||||
|
||||
Cursor = Cursors.WaitCursor;
|
||||
FileHelperEngine engine = new FileHelperEngine(typeof(FHRate));
|
||||
System.Collections.ArrayList alRates = new ArrayList();
|
||||
FHRate fhc;
|
||||
//Rate c;
|
||||
Rates TheRates = Rates.GetItems(false);
|
||||
Waiting w = new Waiting();
|
||||
w.Show();
|
||||
w.Ops = "Exporting Rates";
|
||||
foreach (Rate i in TheRates)
|
||||
{
|
||||
|
||||
fhc = new FHRate();
|
||||
w.Step = i.Name;
|
||||
fhc.Name = i.Name;
|
||||
fhc.Description = i.Description;
|
||||
fhc.AccountNumber = i.AccountNumber;
|
||||
fhc.Cost = i.Cost.ToString();
|
||||
fhc.RetailCharge = i.Charge.ToString();
|
||||
fhc.ContractRate = (i.ContractRate ? "TRUE" : "FALSE");
|
||||
fhc.RateType = i.RateType.ToString().ToUpperInvariant();
|
||||
|
||||
if (i.RateUnitChargeDescriptionID == Guid.Empty)
|
||||
{
|
||||
fhc.UnitChargeDescription = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (rateUnitChageDescriptions.Contains(i.RateUnitChargeDescriptionID))
|
||||
{
|
||||
fhc.UnitChargeDescription = rateUnitChageDescriptions[i.RateUnitChargeDescriptionID].Name;
|
||||
}
|
||||
else
|
||||
{
|
||||
fhc.UnitChargeDescription = "";
|
||||
}
|
||||
}
|
||||
|
||||
//Client group
|
||||
if (i.ClientGroupID == Guid.Empty)
|
||||
{
|
||||
fhc.ClientGroup = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (cgroups.Contains(i.ClientGroupID))
|
||||
{
|
||||
fhc.ClientGroup = cgroups[i.ClientGroupID].Name;
|
||||
}
|
||||
else
|
||||
{
|
||||
fhc.ClientGroup = "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Region
|
||||
if (i.RegionID == Guid.Empty)
|
||||
{
|
||||
fhc.Region = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (regions.Contains(i.RegionID))
|
||||
{
|
||||
fhc.Region = regions[i.RegionID];
|
||||
}
|
||||
else
|
||||
{
|
||||
fhc.Region = "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
alRates.Add(fhc);
|
||||
|
||||
|
||||
}
|
||||
w.Close();
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
engine.WriteFile(sf.FileName, (object[])alRates.ToArray(typeof(FHRate)));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show("Error writing the export file:\r\n\r\n" + ex.Message);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Cursor = Cursors.Default;
|
||||
MessageBox.Show("All Rates in current AyaNova database have been exported to file:\r\n" +
|
||||
sf.FileName);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
private void mnuImportOptions_Click(object sender, EventArgs e)
|
||||
{
|
||||
Util.ShowOptionsDialog();
|
||||
}
|
||||
|
||||
|
||||
#region case 1588 user selectable column placement
|
||||
|
||||
private void DataGridView1_BindingContextChanged(object sender, EventArgs e)
|
||||
{
|
||||
// Continue only if the data source has been set.
|
||||
if (DataGridView1.DataSource == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//these are the columns that can be selected by the user to import into
|
||||
List<string> ls = new List<string>();
|
||||
ls.Add("Name");
|
||||
ls.Add("Description");
|
||||
ls.Add("AccountNumber");
|
||||
ls.Add("Cost");
|
||||
ls.Add("RetailCharge");
|
||||
ls.Add("ContractRate");
|
||||
ls.Add("RateType");
|
||||
ls.Add("UnitChargeDescription");
|
||||
ls.Add("ClientGroup");
|
||||
ls.Add("Region");
|
||||
|
||||
|
||||
// Add the AutoFilter header cell to each column.
|
||||
foreach (DataGridViewColumn col in DataGridView1.Columns)
|
||||
{
|
||||
col.HeaderCell = new
|
||||
GZDataGridViewComboColumnHeaderCell(col.HeaderCell, ls);
|
||||
}
|
||||
|
||||
// Resize the columns to fit their contents.
|
||||
DataGridView1.AutoResizeColumns();
|
||||
|
||||
}
|
||||
|
||||
private void DataGridView1_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
#endregion case 1588
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
}
|
||||
}
|
||||
126
source/Plugins/AyaNova.PlugIn.ImportExportCSV/ImportRate.resx
Normal file
126
source/Plugins/AyaNova.PlugIn.ImportExportCSV/ImportRate.resx
Normal file
@@ -0,0 +1,126 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="mainMenu1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="dlgOpen.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>127, 17</value>
|
||||
</metadata>
|
||||
</root>
|
||||
723
source/Plugins/AyaNova.PlugIn.ImportExportCSV/ImportUnit.cs
Normal file
723
source/Plugins/AyaNova.PlugIn.ImportExportCSV/ImportUnit.cs
Normal file
@@ -0,0 +1,723 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Collections;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Forms;
|
||||
using System.Data;
|
||||
using GZTW.AyaNova.BLL;
|
||||
using System.Threading;
|
||||
using CSLA.Security;
|
||||
using FileHelpers;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace AyaNova.PlugIn.ImportExportCSV
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for Form1.
|
||||
/// </summary>
|
||||
public class ImportUnit : System.Windows.Forms.Form
|
||||
{
|
||||
private System.Windows.Forms.DataGridView dataGrid1;
|
||||
private System.Windows.Forms.MainMenu mainMenu1;
|
||||
private System.Windows.Forms.MenuItem mnuOpen;
|
||||
private System.Windows.Forms.MenuItem mnuImport;
|
||||
private System.Windows.Forms.OpenFileDialog dlgOpen;
|
||||
private System.Windows.Forms.MenuItem mnuExport;
|
||||
private MenuItem mnuImportOptions;
|
||||
private IContainer components;
|
||||
|
||||
public ImportUnit()
|
||||
{
|
||||
//
|
||||
// Required for Windows Form Designer support
|
||||
//
|
||||
InitializeComponent();
|
||||
|
||||
this.Icon = Resource.ImportExportCSV16icon;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
if (components != null)
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.dataGrid1 = new System.Windows.Forms.DataGridView();
|
||||
this.mainMenu1 = new System.Windows.Forms.MainMenu(this.components);
|
||||
this.mnuOpen = new System.Windows.Forms.MenuItem();
|
||||
this.mnuImport = new System.Windows.Forms.MenuItem();
|
||||
this.mnuExport = new System.Windows.Forms.MenuItem();
|
||||
this.mnuImportOptions = new System.Windows.Forms.MenuItem();
|
||||
this.dlgOpen = new System.Windows.Forms.OpenFileDialog();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// dataGrid1
|
||||
//
|
||||
this.dataGrid1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.dataGrid1.Location = new System.Drawing.Point(0, 0);
|
||||
this.dataGrid1.Name = "dataGrid1";
|
||||
this.dataGrid1.ReadOnly = true;
|
||||
this.dataGrid1.Size = new System.Drawing.Size(632, 433);
|
||||
this.dataGrid1.TabIndex = 1;
|
||||
this.dataGrid1.BindingContextChanged += new System.EventHandler(this.dataGrid1_BindingContextChanged);
|
||||
//
|
||||
// mainMenu1
|
||||
//
|
||||
this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
|
||||
this.mnuOpen,
|
||||
this.mnuImport,
|
||||
this.mnuExport,
|
||||
this.mnuImportOptions});
|
||||
//
|
||||
// mnuOpen
|
||||
//
|
||||
this.mnuOpen.Index = 0;
|
||||
this.mnuOpen.Text = "&Open CSV file";
|
||||
this.mnuOpen.Click += new System.EventHandler(this.mnuOpen_Click);
|
||||
//
|
||||
// mnuImport
|
||||
//
|
||||
this.mnuImport.Enabled = false;
|
||||
this.mnuImport.Index = 1;
|
||||
this.mnuImport.Text = "&Import data";
|
||||
this.mnuImport.Click += new System.EventHandler(this.mnuImport_Click);
|
||||
//
|
||||
// mnuExport
|
||||
//
|
||||
this.mnuExport.Index = 2;
|
||||
this.mnuExport.Text = "&Export data";
|
||||
this.mnuExport.Click += new System.EventHandler(this.mnuExport_Click);
|
||||
//
|
||||
// mnuImportOptions
|
||||
//
|
||||
this.mnuImportOptions.Index = 3;
|
||||
this.mnuImportOptions.Text = "&Duplicate import options";
|
||||
this.mnuImportOptions.Visible = false;
|
||||
this.mnuImportOptions.Click += new System.EventHandler(this.mnuImportOptions_Click);
|
||||
//
|
||||
// dlgOpen
|
||||
//
|
||||
this.dlgOpen.DefaultExt = "csv";
|
||||
this.dlgOpen.Filter = "CSV files|*.csv";
|
||||
this.dlgOpen.Title = "Comma separated values part file";
|
||||
//
|
||||
// ImportUnit
|
||||
//
|
||||
this.AutoScaleBaseSize = new System.Drawing.Size(6, 15);
|
||||
this.ClientSize = new System.Drawing.Size(632, 433);
|
||||
this.Controls.Add(this.dataGrid1);
|
||||
this.Menu = this.mainMenu1;
|
||||
this.Name = "ImportUnit";
|
||||
this.Text = "Unit importer v2.0.0.0";
|
||||
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
|
||||
this.Load += new System.EventHandler(this.Form1_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//
|
||||
// _________ __
|
||||
// \_ ___ \ __ __ _______/ |_ ____ _____
|
||||
// / \ \/ | | \ / ___/\ __\ / _ \ / \
|
||||
// \ \____| | / \___ \ | | ( <_> )| Y Y \
|
||||
// \______ /|____/ /____ > |__| \____/ |__|_| /
|
||||
// \/ \/ \/
|
||||
// _________ .___
|
||||
// \_ ___ \ ____ __| _/ ____
|
||||
// / \ \/ / _ \ / __ | _/ __ \
|
||||
// \ \____( <_> )/ /_/ | \ ___/
|
||||
// \______ / \____/ \____ | \___ >
|
||||
// \/ \/ \/
|
||||
|
||||
|
||||
#region list objects
|
||||
//These are name value lists used to
|
||||
//keep track of the id's of existing items
|
||||
//that are either pre-existing or have been created during import
|
||||
//this supports the code that matches text names of objects to their id's
|
||||
//i.e. "IBM" as a manufacturer to the IBM record in AyaNova already
|
||||
//case is not taken into account during comparison to ensure no little
|
||||
//mismatches due to a small typo in the import file
|
||||
|
||||
Hashtable htWholeSalers = new Hashtable();
|
||||
Hashtable htManufacturers = new Hashtable();
|
||||
Hashtable htClients = new Hashtable();
|
||||
Hashtable htModels = new Hashtable();
|
||||
Hashtable htUnits = new Hashtable();
|
||||
|
||||
#endregion
|
||||
|
||||
#region Form load and login
|
||||
|
||||
private void Form1_Load(object sender, System.EventArgs e)
|
||||
{
|
||||
{
|
||||
System.Reflection.Assembly a = System.Reflection.Assembly.GetExecutingAssembly();
|
||||
string sVersion = "AyaNova® unit import / export " + AyaBizUtils.DisplayVersion(a.GetName().Version);
|
||||
System.Diagnostics.FileVersionInfo fileVersion = System.Diagnostics.FileVersionInfo.GetVersionInfo(a.Location);
|
||||
if (fileVersion.FileBuildPart > 0)
|
||||
sVersion += " (Patch " + fileVersion.FileBuildPart.ToString() + ")";
|
||||
this.Text = sVersion;
|
||||
}
|
||||
|
||||
mnuImportOptions.Visible = Util.LicensedMode;
|
||||
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
//Load cached lists
|
||||
VendorPickList vp = VendorPickList.GetList();
|
||||
foreach (VendorPickList.VendorPickListInfo i in vp)
|
||||
{
|
||||
if (i.VendorType == VendorTypes.Manufacturer)
|
||||
//case 3606
|
||||
if (!htManufacturers.ContainsKey(i.Name))
|
||||
htManufacturers.Add(i.Name, i.ID);
|
||||
else if (i.VendorType == VendorTypes.Wholesaler)
|
||||
//case 3606
|
||||
if (!htWholeSalers.ContainsKey(i.Name))
|
||||
htWholeSalers.Add(i.Name, i.ID);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
ClientPickList p = ClientPickList.GetList();
|
||||
foreach (ClientPickList.ClientPickListInfo i in p)
|
||||
{
|
||||
//case 3606
|
||||
if (!htClients.ContainsKey(i.Name))
|
||||
htClients.Add(i.Name, i.ID);
|
||||
}
|
||||
|
||||
UnitModelPickList upl = UnitModelPickList.GetList();
|
||||
foreach (UnitModelPickList.UnitModelPickListInfo i in upl)
|
||||
{
|
||||
//case 3606
|
||||
if (!htModels.ContainsKey(i.Name))
|
||||
htModels.Add(i.Name, i.ID);
|
||||
}
|
||||
|
||||
UnitPickList unpl = UnitPickList.GetListOfAll();
|
||||
foreach (UnitPickList.UnitPickListInfo i in unpl)
|
||||
{
|
||||
//case 3606
|
||||
if (!htUnits.ContainsKey(i.Serial))
|
||||
htUnits.Add(i.Serial, i.ID);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (ex is System.ArgumentException)
|
||||
{
|
||||
MessageBox.Show(
|
||||
"An error has occurred while attempting to retrieve the lists of objects\r\n" +
|
||||
"already stored in AyaNova which are used to match to the data being imported.\r\n" +
|
||||
"(Clients, Unit Models, Vendors Units etc)\r\n\r\n" +
|
||||
"A duplicate record was found with the same name and must be removed or changed\r\n" +
|
||||
"before you can proceed with this utility. Details below:\r\n\r\n" +
|
||||
ex.Message, "Duplicate object name in AyaNova");
|
||||
|
||||
}
|
||||
else
|
||||
MessageBox.Show("An error has occurred while attempting to retrieve the lists of objects\r\n" +
|
||||
"already stored in AyaNova which are used to match to the data being imported.\r\n" +
|
||||
"The import utility can not proceed, details below:\r\n\r\n", ex.Message);
|
||||
this.Close();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
MessageBox.Show(
|
||||
"Confirm that you have a backup copy of your AyaNova database before proceeding.\r\n\r\n" +
|
||||
"There is no undo function for importing data other than restoring from a pre-import backup copy.\r\n\r\n" +
|
||||
"** If you are not 100% certain that you have a *working* backup copy ready, stop now **",
|
||||
"ACCIDENTS HAPPEN: DO NOT IMPORT WITHOUT A GOOD BACKUP!");
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Read import file
|
||||
private DataTable dtUnits;
|
||||
|
||||
private void mnuOpen_Click(object sender, System.EventArgs e)
|
||||
{
|
||||
if (dlgOpen.ShowDialog() != DialogResult.OK) return;
|
||||
this.mnuImport.Enabled = false;
|
||||
Util.ReadCSV(dataGrid1, ref dtUnits, RootObjectTypes.Unit, dlgOpen.FileName);
|
||||
this.mnuImport.Enabled = true;
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Import data
|
||||
Dictionary<string, int> lsMap = null;
|
||||
private void mnuImport_Click(object sender, System.EventArgs e)
|
||||
{
|
||||
//Save grid settings
|
||||
Util.SaveGridMappings(dataGrid1, RootObjectTypes.Unit);
|
||||
|
||||
if (dtUnits.Rows.Count < 1)
|
||||
{
|
||||
MessageBox.Show("There are no records to import");
|
||||
return;
|
||||
}
|
||||
|
||||
//Get the map
|
||||
lsMap = Util.BuildGridImportMap(dataGrid1);
|
||||
|
||||
if (!lsMap.ContainsKey("Serial"))
|
||||
{
|
||||
MessageBox.Show("\"Serial\" is a required field to uniquely identify units. Select a column to be used as the unique unit serial number to proceed with import.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!lsMap.ContainsKey("Client"))
|
||||
{
|
||||
MessageBox.Show("\"Client\" is a required field. Select a column that identifies the client name of unit owner to proceed with import.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!lsMap.ContainsKey("UnitModel"))
|
||||
{
|
||||
MessageBox.Show("\"UnitModel\" is a required field. Select a column that identifies the unit model to proceed with import.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
long lBadCount = 0;
|
||||
long lGoodCount = 0;
|
||||
long lUpdatedCount = 0;
|
||||
Waiting w = new Waiting();
|
||||
w.Show();
|
||||
w.Ops = "Importing Unit";
|
||||
foreach (DataRow dr in dtUnits.Rows)
|
||||
{
|
||||
|
||||
if (string.IsNullOrEmpty(fld(dr, "UnitModel", 255)) || string.IsNullOrEmpty(fld(dr, "Client", 255)) || string.IsNullOrEmpty(fld(dr, "Serial", 255))) continue;
|
||||
Unit u = null;
|
||||
|
||||
string sSerial = fld(dr, "Serial", 255);
|
||||
|
||||
if (htUnits.Contains(sSerial))
|
||||
{
|
||||
//case 1404 Open existing for update?
|
||||
if (Util.LicensedMode && Util.IEData.UnitUpdate)
|
||||
{
|
||||
//update existing unit
|
||||
u = Unit.GetItem((Guid)htUnits[sSerial]);
|
||||
|
||||
}
|
||||
else//not licensed or nothing chosen to update
|
||||
{
|
||||
lBadCount++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
u = Unit.NewItem();
|
||||
}
|
||||
|
||||
|
||||
w.Step = sSerial;
|
||||
|
||||
if (u.IsNew)
|
||||
u.Serial = sSerial;
|
||||
|
||||
if (u.IsNew || Util.IEData.UnitClientID)
|
||||
u.ClientID = GetClientIDByName(fld(dr, "Client", 255));
|
||||
|
||||
if (u.IsNew || Util.IEData.UnitModelID)
|
||||
u.UnitModelID = GetModelIDByName(fld(dr, "UnitModel", 255));
|
||||
|
||||
if (u.IsNew || Util.IEData.UnitNotes)
|
||||
u.Notes = fld(dr, "Notes", 32767);// t(32767, f.Notes);
|
||||
|
||||
if (u.IsNew || Util.IEData.UnitPurchasedFromVendor)
|
||||
{
|
||||
string sPurchasedFrom = fld(dr, "PurchasedFromVendor", 255);
|
||||
if (string.IsNullOrWhiteSpace(sPurchasedFrom))
|
||||
u.BoughtHere = true;
|
||||
else
|
||||
u.PurchasedFromID = GetWholeSalerIDByName(sPurchasedFrom);
|
||||
}
|
||||
|
||||
if (u.IsNew || Util.IEData.UnitReceipt)
|
||||
u.Receipt = fld(dr, "SalesReceiptNumber", 255);
|
||||
|
||||
if (u.IsNew || Util.IEData.UnitPurchasedDate)
|
||||
{
|
||||
//Case 887
|
||||
if (!string.IsNullOrEmpty(fld(dr, "PurchasedDate", 255)))
|
||||
u.PurchasedDate = new CSLA.SmartDate(System.Convert.ToDateTime(fld(dr, "PurchasedDate", 255))).DBValue;
|
||||
}
|
||||
|
||||
if (u.IsNew || Util.IEData.UnitDescription)
|
||||
u.Description = fld(dr, "Description", 255);
|
||||
|
||||
if (u.IsNew || Util.IEData.UnitMetered)
|
||||
u.Metered = StringToBool(fld(dr, "Metered", 255));
|
||||
|
||||
if (u.IsNew || Util.IEData.UnitWarrantyLength)
|
||||
{
|
||||
int nWarrantyLength = 0;
|
||||
if (int.TryParse(fld(dr, "WarrantyLength", 255), out nWarrantyLength))
|
||||
{
|
||||
u.OverrideModelWarranty = true;
|
||||
u.WarrantyLength = nWarrantyLength;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (u.IsSavable)
|
||||
{
|
||||
bool bWasNew = u.IsNew;
|
||||
u.Save();
|
||||
if (bWasNew)
|
||||
htUnits.Add(sSerial, u.ID);
|
||||
|
||||
if (bWasNew)
|
||||
lGoodCount++;
|
||||
else
|
||||
lUpdatedCount++;
|
||||
}
|
||||
else
|
||||
{
|
||||
lBadCount++;
|
||||
}
|
||||
}
|
||||
|
||||
w.Close();
|
||||
if (Util.LicensedMode && Util.IEData.UnitUpdate)
|
||||
{
|
||||
if (lBadCount > 0)
|
||||
MessageBox.Show(lGoodCount.ToString() + " Units were imported / " + lUpdatedCount + " duplicate Units were updated sucessfully.\r\n" +
|
||||
lBadCount.ToString() + " Units were not imported because they had no serial number at all or did not pass the business / update rules for a Unit object.");
|
||||
else
|
||||
MessageBox.Show(lGoodCount.ToString() + " Units were imported / " + lUpdatedCount + " duplicate Units were updated sucessfully.");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if (lBadCount > 0)
|
||||
MessageBox.Show(lGoodCount.ToString() + " Units were imported sucessfully.\r\n" +
|
||||
lBadCount.ToString() + " Units were not imported because a unit with the same serial number already\r\n" +
|
||||
"exists or they had no serial number at all or did not pass the rules for a unit object.");
|
||||
else
|
||||
MessageBox.Show(lGoodCount.ToString() + " Units were imported sucessfully");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a field from the current data row
|
||||
/// </summary>
|
||||
/// <param name="sColumnNameKey"></param>
|
||||
/// <param name="nLength"></param>
|
||||
/// <returns></returns>
|
||||
private string fld(DataRow dr, string sColumnNameKey, int nLength)
|
||||
{
|
||||
if (lsMap.ContainsKey(sColumnNameKey))
|
||||
{
|
||||
return t(nLength, dr[lsMap[sColumnNameKey]].ToString());
|
||||
}
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="nLength"></param>
|
||||
/// <param name="s"></param>
|
||||
/// <returns></returns>
|
||||
private static string t(int nLength, string s)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(s)) return "";
|
||||
if (s.Length <= nLength) return s;
|
||||
else
|
||||
return s.Substring(0, nLength);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="s"></param>
|
||||
/// <returns></returns>
|
||||
private bool StringToBool(string s)
|
||||
{
|
||||
if (s == null || s == "") return false;
|
||||
if (s.ToUpper().StartsWith("T")) return true;
|
||||
if (s == "1") return true;
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
private decimal StringToDecimal(string s)
|
||||
{
|
||||
if (s == null || s == "") return 0M;
|
||||
try
|
||||
{
|
||||
return System.Convert.ToDecimal(s);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return 0M;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Identify and fetch an existing ID or add a new Client if necessary
|
||||
/// </summary>
|
||||
/// <param name="sName"></param>
|
||||
/// <returns></returns>
|
||||
private Guid GetClientIDByName(string sName)
|
||||
{
|
||||
|
||||
foreach (DictionaryEntry de in htClients)
|
||||
{
|
||||
if (de.Key.ToString().ToUpper() == sName.ToUpper())
|
||||
return (Guid)de.Value;
|
||||
}
|
||||
|
||||
//Not there so add a new record for it
|
||||
Client c = Client.NewItem();
|
||||
c.Name = sName;
|
||||
c.Save();
|
||||
htClients.Add(sName, c.ID);
|
||||
|
||||
return c.ID;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Identify and fetch an existing ID or add a new Model if necessary
|
||||
/// </summary>
|
||||
/// <param name="sName"></param>
|
||||
/// <returns></returns>
|
||||
private Guid GetModelIDByName(string sName)
|
||||
{
|
||||
|
||||
foreach (DictionaryEntry de in htModels)
|
||||
{
|
||||
//Starts with necessary because unit model list includes model number after
|
||||
//name
|
||||
if (de.Key.ToString().ToUpper().StartsWith(sName.ToUpper()))
|
||||
return (Guid)de.Value;
|
||||
}
|
||||
|
||||
//Not there so add a new record for it
|
||||
UnitModel c = UnitModel.NewItem();
|
||||
c.Name = sName;
|
||||
c.Save();
|
||||
htModels.Add(sName, c.ID);
|
||||
|
||||
return c.ID;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Identify and fetch an existing ID or add a new wholesaler if necessary
|
||||
/// </summary>
|
||||
/// <param name="sName"></param>
|
||||
/// <returns></returns>
|
||||
private Guid GetWholeSalerIDByName(string sName)
|
||||
{
|
||||
if (sName == "") sName = "Unspecified wholesaler";
|
||||
foreach (DictionaryEntry de in htWholeSalers)
|
||||
{
|
||||
if (de.Key.ToString().ToUpper() == sName.ToUpper())
|
||||
return (Guid)de.Value;
|
||||
}
|
||||
|
||||
//Not there so add a new record for it
|
||||
Vendor v = Vendor.NewItem();
|
||||
v.Active = true;
|
||||
v.VendorType = VendorTypes.Wholesaler;
|
||||
v.Name = sName;
|
||||
v.Save();
|
||||
htWholeSalers.Add(sName, v.ID);
|
||||
return v.ID;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Export data
|
||||
/// <summary>
|
||||
/// Exports all existing Units to CSV format identical
|
||||
/// to that required for import
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void mnuExport_Click(object sender, System.EventArgs e)
|
||||
{
|
||||
SaveFileDialog sf = new SaveFileDialog();
|
||||
sf.DefaultExt = ".csv";
|
||||
sf.FileName = "units.csv";
|
||||
if (sf.ShowDialog() != DialogResult.OK) return;
|
||||
|
||||
|
||||
Cursor = Cursors.WaitCursor;
|
||||
FileHelperEngine engine = new FileHelperEngine(typeof(FHUnit));
|
||||
System.Collections.ArrayList alUnits = new ArrayList();
|
||||
FHUnit fhc;
|
||||
Unit u;
|
||||
UnitPickList ppl = UnitPickList.GetListOfAll();
|
||||
Waiting w = new Waiting();
|
||||
w.Show();
|
||||
w.Ops = "Exporting units";
|
||||
foreach (UnitPickList.UnitPickListInfo i in ppl)
|
||||
{
|
||||
u = Unit.GetItem(i.ID);
|
||||
fhc = new FHUnit();
|
||||
w.Step = u.Serial;
|
||||
fhc.Serial = u.Serial;
|
||||
fhc.Client = GetClientByID(u.ClientID);
|
||||
fhc.Description = u.Description;
|
||||
fhc.Metered = (u.Metered ? "TRUE" : "FALSE");
|
||||
fhc.Notes = u.Notes;
|
||||
if (u.PurchasedDate == System.DBNull.Value)
|
||||
fhc.PurchasedDate = "";
|
||||
else
|
||||
{
|
||||
DateTime dtPurchased = System.Convert.ToDateTime(u.PurchasedDate);
|
||||
fhc.PurchasedDate = dtPurchased.ToString();
|
||||
}
|
||||
|
||||
fhc.PurchasedFromVendor = GetPurchasedFromByID(u.PurchasedFromID);
|
||||
fhc.SalesReceiptNumber = u.Receipt;
|
||||
fhc.UnitModel = GetModelByID(u.UnitModelID);
|
||||
fhc.WarrantyLength = u.WarrantyLength.ToString();//case 1739
|
||||
alUnits.Add(fhc);
|
||||
|
||||
|
||||
}
|
||||
w.Close();
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
engine.WriteFile(sf.FileName, (object[])alUnits.ToArray(typeof(FHUnit)));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show("Error writing the export file:\r\n\r\n" + ex.Message);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Cursor = Cursors.Default;
|
||||
MessageBox.Show("All units in current AyaNova database have been exported to file:\r\n" +
|
||||
sf.FileName);
|
||||
}
|
||||
|
||||
|
||||
private string GetPurchasedFromByID(Guid ID)
|
||||
{
|
||||
foreach (DictionaryEntry de in htWholeSalers)
|
||||
{
|
||||
if ((Guid)de.Value == ID)
|
||||
return de.Key.ToString();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private string GetClientByID(Guid ID)
|
||||
{
|
||||
foreach (DictionaryEntry de in htClients)
|
||||
{
|
||||
if ((Guid)de.Value == ID)
|
||||
return de.Key.ToString();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private string GetModelByID(Guid ID)
|
||||
{
|
||||
foreach (DictionaryEntry de in this.htModels)
|
||||
{
|
||||
if ((Guid)de.Value == ID)
|
||||
return de.Key.ToString();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
#endregion
|
||||
|
||||
private void mnuImportOptions_Click(object sender, EventArgs e)
|
||||
{
|
||||
Util.ShowOptionsDialog();
|
||||
}
|
||||
|
||||
#region case 1588
|
||||
private void dataGrid1_BindingContextChanged(object sender, EventArgs e)
|
||||
{
|
||||
// Continue only if the data source has been set.
|
||||
if (dataGrid1.DataSource == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//these are the columns that can be selected by the user to import into
|
||||
List<string> ls = new List<string>();
|
||||
ls.Add("Serial");
|
||||
ls.Add("Client");
|
||||
ls.Add("UnitModel");
|
||||
ls.Add("Notes");
|
||||
ls.Add("PurchasedFromVendor");
|
||||
ls.Add("SalesReceiptNumber");
|
||||
ls.Add("PurchasedDate");
|
||||
ls.Add("Description");
|
||||
ls.Add("Metered");
|
||||
ls.Add("WarrantyLength");//case 1739
|
||||
|
||||
|
||||
// Add the AutoFilter header cell to each column.
|
||||
foreach (DataGridViewColumn col in dataGrid1.Columns)
|
||||
{
|
||||
col.HeaderCell = new
|
||||
GZDataGridViewComboColumnHeaderCell(col.HeaderCell, ls);
|
||||
}
|
||||
|
||||
// Resize the columns to fit their contents.
|
||||
dataGrid1.AutoResizeColumns();
|
||||
|
||||
}
|
||||
#endregion case 1588
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
}
|
||||
}
|
||||
126
source/Plugins/AyaNova.PlugIn.ImportExportCSV/ImportUnit.resx
Normal file
126
source/Plugins/AyaNova.PlugIn.ImportExportCSV/ImportUnit.resx
Normal file
@@ -0,0 +1,126 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="mainMenu1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="dlgOpen.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>127, 17</value>
|
||||
</metadata>
|
||||
</root>
|
||||
@@ -0,0 +1,374 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Collections;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Forms;
|
||||
using System.Data;
|
||||
using GZTW.AyaNova.BLL;
|
||||
using System.Threading;
|
||||
using CSLA.Security;
|
||||
using FileHelpers;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace AyaNova.PlugIn.ImportExportCSV
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for Form1.
|
||||
/// </summary>
|
||||
public class ImportUnitServiceType : System.Windows.Forms.Form
|
||||
{
|
||||
private System.Windows.Forms.DataGridView dataGrid1;
|
||||
private System.Windows.Forms.MainMenu mainMenu1;
|
||||
private System.Windows.Forms.MenuItem mnuOpen;
|
||||
private System.Windows.Forms.MenuItem mnuImport;
|
||||
private System.Windows.Forms.OpenFileDialog dlgOpen;
|
||||
private System.Windows.Forms.MenuItem mnuExport;
|
||||
private MenuItem mnuImportOptions;
|
||||
private IContainer components;
|
||||
|
||||
public ImportUnitServiceType()
|
||||
{
|
||||
//
|
||||
// Required for Windows Form Designer support
|
||||
//
|
||||
InitializeComponent();
|
||||
|
||||
this.Icon = Resource.ImportExportCSV16icon;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
protected override void Dispose( bool disposing )
|
||||
{
|
||||
if( disposing )
|
||||
{
|
||||
if (components != null)
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
}
|
||||
base.Dispose( disposing );
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.dataGrid1 = new System.Windows.Forms.DataGridView();
|
||||
this.mainMenu1 = new System.Windows.Forms.MainMenu(this.components);
|
||||
this.mnuOpen = new System.Windows.Forms.MenuItem();
|
||||
this.mnuImport = new System.Windows.Forms.MenuItem();
|
||||
this.mnuExport = new System.Windows.Forms.MenuItem();
|
||||
this.mnuImportOptions = new System.Windows.Forms.MenuItem();
|
||||
this.dlgOpen = new System.Windows.Forms.OpenFileDialog();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// dataGrid1
|
||||
//
|
||||
this.dataGrid1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.dataGrid1.Location = new System.Drawing.Point(0, 0);
|
||||
this.dataGrid1.Name = "dataGrid1";
|
||||
this.dataGrid1.ReadOnly = true;
|
||||
this.dataGrid1.Size = new System.Drawing.Size(632, 433);
|
||||
this.dataGrid1.TabIndex = 1;
|
||||
//
|
||||
// mainMenu1
|
||||
//
|
||||
this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
|
||||
this.mnuOpen,
|
||||
this.mnuImport,
|
||||
this.mnuExport,
|
||||
this.mnuImportOptions});
|
||||
//
|
||||
// mnuOpen
|
||||
//
|
||||
this.mnuOpen.Index = 0;
|
||||
this.mnuOpen.Text = "&Open CSV file";
|
||||
this.mnuOpen.Click += new System.EventHandler(this.mnuOpen_Click);
|
||||
//
|
||||
// mnuImport
|
||||
//
|
||||
this.mnuImport.Enabled = false;
|
||||
this.mnuImport.Index = 1;
|
||||
this.mnuImport.Text = "&Import data";
|
||||
this.mnuImport.Click += new System.EventHandler(this.mnuImport_Click);
|
||||
//
|
||||
// mnuExport
|
||||
//
|
||||
this.mnuExport.Index = 2;
|
||||
this.mnuExport.Text = "&Export data";
|
||||
this.mnuExport.Click += new System.EventHandler(this.mnuExport_Click);
|
||||
//
|
||||
// mnuImportOptions
|
||||
//
|
||||
this.mnuImportOptions.Index = 3;
|
||||
this.mnuImportOptions.Text = "&Duplicate import options";
|
||||
this.mnuImportOptions.Visible = false;
|
||||
//
|
||||
// dlgOpen
|
||||
//
|
||||
this.dlgOpen.DefaultExt = "csv";
|
||||
this.dlgOpen.Filter = "CSV files|*.csv";
|
||||
this.dlgOpen.Title = "Comma separated values client file";
|
||||
//
|
||||
// ImportUnitServiceType
|
||||
//
|
||||
this.AutoScaleBaseSize = new System.Drawing.Size(6, 15);
|
||||
this.ClientSize = new System.Drawing.Size(632, 433);
|
||||
this.Controls.Add(this.dataGrid1);
|
||||
this.Menu = this.mainMenu1;
|
||||
this.Name = "ImportUnitServiceType";
|
||||
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
|
||||
this.Load += new System.EventHandler(this.Form1_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//
|
||||
// _________ __
|
||||
// \_ ___ \ __ __ _______/ |_ ____ _____
|
||||
// / \ \/ | | \ / ___/\ __\ / _ \ / \
|
||||
// \ \____| | / \___ \ | | ( <_> )| Y Y \
|
||||
// \______ /|____/ /____ > |__| \____/ |__|_| /
|
||||
// \/ \/ \/
|
||||
// _________ .___
|
||||
// \_ ___ \ ____ __| _/ ____
|
||||
// / \ \/ / _ \ / __ | _/ __ \
|
||||
// \ \____( <_> )/ /_/ | \ ___/
|
||||
// \______ / \____/ \____ | \___ >
|
||||
// \/ \/ \/
|
||||
|
||||
|
||||
|
||||
|
||||
#region Form load and login
|
||||
private void Form1_Load(object sender, System.EventArgs e)
|
||||
{
|
||||
|
||||
{
|
||||
System.Reflection.Assembly a = System.Reflection.Assembly.GetExecutingAssembly();
|
||||
string sVersion = "AyaNova® Unit service type import / export " + AyaBizUtils.DisplayVersion(a.GetName().Version);
|
||||
System.Diagnostics.FileVersionInfo fileVersion = System.Diagnostics.FileVersionInfo.GetVersionInfo(a.Location);
|
||||
if (fileVersion.FileBuildPart > 0)
|
||||
sVersion += " (Patch " + fileVersion.FileBuildPart.ToString() + ")";
|
||||
this.Text = sVersion;
|
||||
}
|
||||
|
||||
|
||||
MessageBox.Show(
|
||||
"Confirm that you have a backup copy of your AyaNova database before proceeding.\r\n\r\n" +
|
||||
"There is no undo function for importing data other than restoring from a pre-import backup copy.\r\n\r\n" +
|
||||
"** If you are not 100% certain that you have a *working* backup copy ready, stop now **",
|
||||
"ACCIDENTS HAPPEN: DO NOT IMPORT WITHOUT A GOOD BACKUP!");
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Read import file
|
||||
private DataTable dtItems;
|
||||
|
||||
private FHUnitServiceType[] records;
|
||||
private void mnuOpen_Click(object sender, System.EventArgs e)
|
||||
{
|
||||
|
||||
if(dlgOpen.ShowDialog()!=DialogResult.OK) return;
|
||||
this.mnuImport.Enabled=false;
|
||||
if(dtItems==null)
|
||||
{
|
||||
dtItems=new DataTable("CSVItems");
|
||||
dtItems.Columns.Add("Name",typeof(string));
|
||||
dtItems.Columns.Add("Description", typeof(string));
|
||||
|
||||
}
|
||||
else
|
||||
dtItems.Rows.Clear();
|
||||
|
||||
FileHelperEngine engine = new FileHelperEngine(typeof(FHUnitServiceType));
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
records= (FHUnitServiceType[]) engine.ReadFile(dlgOpen.FileName);
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
MessageBox.Show("Error reading the .csv file:\r\n\r\n" + ex.Message);
|
||||
return;
|
||||
}
|
||||
|
||||
string sMax="The first 25 records only";
|
||||
if(records.GetLength(0)<25)
|
||||
sMax="All records";
|
||||
MessageBox.Show(records.GetLength(0).ToString() + " records were read in from the .csv file.\r\n\r\n" +
|
||||
sMax+" will be displayed for you to confirm the fields\r\n" +
|
||||
"and check that the data is displaying correctly before importing.\r\n\r\n" +
|
||||
"If any field doesn't appear correctly you must create a new .csv file with the correct\r\n" +
|
||||
"column order before importing or data will be imported into the wrong place in AyaNova");
|
||||
|
||||
//Maximum 25 records displayed
|
||||
int nMax=0;
|
||||
foreach(FHUnitServiceType c in records)
|
||||
{
|
||||
|
||||
dtItems.Rows.Add(
|
||||
new object[]{c.Name, c.Description});
|
||||
nMax++;
|
||||
if(nMax>24) break;
|
||||
}
|
||||
|
||||
|
||||
dataGrid1.DataSource=dtItems;
|
||||
this.mnuImport.Enabled=true;
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Import data
|
||||
private UnitServiceTypes PA = null;
|
||||
private bool ContainsItem(string name)
|
||||
{
|
||||
foreach (UnitServiceType p in PA)
|
||||
{
|
||||
if (p.Name == name)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void mnuImport_Click(object sender, System.EventArgs e)
|
||||
{
|
||||
|
||||
if(records.GetLength(0)<1)
|
||||
{
|
||||
MessageBox.Show("There are no records to import");
|
||||
return;
|
||||
}
|
||||
|
||||
long lBadCount=0;
|
||||
long lGoodCount=0;
|
||||
Waiting w=new Waiting();
|
||||
w.Show();
|
||||
w.Ops="Importing items";
|
||||
PA = UnitServiceTypes.GetItems();
|
||||
foreach(FHUnitServiceType f in records)
|
||||
{
|
||||
|
||||
//If client has a name and doesn't already exist in the db then import it
|
||||
if(f.Name!=null && f.Name!="" && (!ContainsItem(t(255,f.Name))))
|
||||
{
|
||||
w.Step=t(255,f.Name);
|
||||
UnitServiceType p=PA.Add();
|
||||
p.Active = true;
|
||||
p.Name = t(255, f.Name);
|
||||
p.Description = t(255, f.Description);
|
||||
|
||||
lGoodCount++;
|
||||
|
||||
}
|
||||
else
|
||||
lBadCount++;
|
||||
|
||||
|
||||
}
|
||||
if (lGoodCount > 0)
|
||||
{
|
||||
w.Step = "Saving...";
|
||||
PA.Save();
|
||||
}
|
||||
|
||||
w.Close();
|
||||
|
||||
if(lBadCount>0)
|
||||
MessageBox.Show(lGoodCount.ToString() + " items were imported sucessfully.\r\n" +
|
||||
lBadCount.ToString() + " items were not imported because an item with the same name already exists.");
|
||||
else
|
||||
MessageBox.Show(lGoodCount.ToString() + " items were imported sucessfully");
|
||||
|
||||
}
|
||||
|
||||
private static string t(int nLength, string s)
|
||||
{
|
||||
if(s==null || s=="") return "";
|
||||
if(s.Length<=nLength) return s;
|
||||
else
|
||||
return s.Substring(0,nLength);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Export data
|
||||
/// <summary>
|
||||
/// Exports all existing items to CSV format identical
|
||||
/// to that required for import
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void mnuExport_Click(object sender, System.EventArgs e)
|
||||
{
|
||||
SaveFileDialog sf = new SaveFileDialog();
|
||||
sf.DefaultExt = ".csv";
|
||||
sf.FileName = "UnitServiceType.csv";
|
||||
if (sf.ShowDialog() != DialogResult.OK) return;
|
||||
|
||||
Cursor=Cursors.WaitCursor;
|
||||
FileHelperEngine engine = new FileHelperEngine(typeof(FHUnitServiceType));
|
||||
System.Collections.ArrayList allItems = new ArrayList();
|
||||
FHUnitServiceType fhc;
|
||||
PA = UnitServiceTypes.GetItems();
|
||||
Waiting w=new Waiting();
|
||||
w.Show();
|
||||
w.Ops="Exporting items";
|
||||
foreach (UnitServiceType p in PA)
|
||||
{
|
||||
fhc=new FHUnitServiceType();
|
||||
w.Step=p.Name;
|
||||
fhc.Name=p.Name;
|
||||
fhc.Description = p.Description;
|
||||
|
||||
allItems.Add(fhc);
|
||||
|
||||
}
|
||||
w.Close();
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
engine.WriteFile(sf.FileName, (object[])allItems.ToArray(typeof(FHUnitServiceType)));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
MessageBox.Show("Error writing the export file:\r\n\r\n" + ex.Message);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Cursor=Cursors.Default;
|
||||
MessageBox.Show("All Unit service types in current AyaNova database have been exported to file:\r\n" +
|
||||
sf.FileName);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="mainMenu1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="dlgOpen.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>127, 17</value>
|
||||
</metadata>
|
||||
</root>
|
||||
76
source/Plugins/AyaNova.PlugIn.ImportExportCSV/ImportUpdateOptions.Designer.cs
generated
Normal file
76
source/Plugins/AyaNova.PlugIn.ImportExportCSV/ImportUpdateOptions.Designer.cs
generated
Normal file
@@ -0,0 +1,76 @@
|
||||
namespace AyaNova.PlugIn.ImportExportCSV
|
||||
{
|
||||
partial class ImportUpdateOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.pgImportOpts = new System.Windows.Forms.PropertyGrid();
|
||||
this.btnOK = new System.Windows.Forms.Button();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// pgImportOpts
|
||||
//
|
||||
this.pgImportOpts.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.pgImportOpts.Location = new System.Drawing.Point(2, 3);
|
||||
this.pgImportOpts.Name = "pgImportOpts";
|
||||
this.pgImportOpts.Size = new System.Drawing.Size(405, 401);
|
||||
this.pgImportOpts.TabIndex = 0;
|
||||
this.pgImportOpts.ToolbarVisible = false;
|
||||
//
|
||||
// btnOK
|
||||
//
|
||||
this.btnOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.btnOK.DialogResult = System.Windows.Forms.DialogResult.OK;
|
||||
this.btnOK.Location = new System.Drawing.Point(167, 417);
|
||||
this.btnOK.Name = "btnOK";
|
||||
this.btnOK.Size = new System.Drawing.Size(75, 35);
|
||||
this.btnOK.TabIndex = 7;
|
||||
this.btnOK.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// ImportUpdateOptions
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(408, 464);
|
||||
this.ControlBox = false;
|
||||
this.Controls.Add(this.btnOK);
|
||||
this.Controls.Add(this.pgImportOpts);
|
||||
this.Name = "ImportUpdateOptions";
|
||||
this.Text = "Import duplicate record update options";
|
||||
this.Load += new System.EventHandler(this.ImportUpdateOptions_Load);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.PropertyGrid pgImportOpts;
|
||||
private System.Windows.Forms.Button btnOK;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace AyaNova.PlugIn.ImportExportCSV
|
||||
{
|
||||
public partial class ImportUpdateOptions : Form
|
||||
{
|
||||
public ImportUpdateOptions()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void ImportUpdateOptions_Load(object sender, EventArgs e)
|
||||
{
|
||||
this.Icon = Resource.ImportExportCSV16icon;
|
||||
this.btnOK.Image = (System.Drawing.Image)Util.AyaRes.GetObject("OK24");
|
||||
|
||||
pgImportOpts.SelectedObject = Util.IEData;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
@@ -0,0 +1,374 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Collections;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Forms;
|
||||
using System.Data;
|
||||
using GZTW.AyaNova.BLL;
|
||||
using System.Threading;
|
||||
using CSLA.Security;
|
||||
using FileHelpers;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace AyaNova.PlugIn.ImportExportCSV
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for Form1.
|
||||
/// </summary>
|
||||
public class ImportWorkorderCategory : System.Windows.Forms.Form
|
||||
{
|
||||
private System.Windows.Forms.DataGridView dataGrid1;
|
||||
private System.Windows.Forms.MainMenu mainMenu1;
|
||||
private System.Windows.Forms.MenuItem mnuOpen;
|
||||
private System.Windows.Forms.MenuItem mnuImport;
|
||||
private System.Windows.Forms.OpenFileDialog dlgOpen;
|
||||
private System.Windows.Forms.MenuItem mnuExport;
|
||||
private MenuItem mnuImportOptions;
|
||||
private IContainer components;
|
||||
|
||||
public ImportWorkorderCategory()
|
||||
{
|
||||
//
|
||||
// Required for Windows Form Designer support
|
||||
//
|
||||
InitializeComponent();
|
||||
|
||||
this.Icon = Resource.ImportExportCSV16icon;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
protected override void Dispose( bool disposing )
|
||||
{
|
||||
if( disposing )
|
||||
{
|
||||
if (components != null)
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
}
|
||||
base.Dispose( disposing );
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.dataGrid1 = new System.Windows.Forms.DataGridView();
|
||||
this.mainMenu1 = new System.Windows.Forms.MainMenu(this.components);
|
||||
this.mnuOpen = new System.Windows.Forms.MenuItem();
|
||||
this.mnuImport = new System.Windows.Forms.MenuItem();
|
||||
this.mnuExport = new System.Windows.Forms.MenuItem();
|
||||
this.mnuImportOptions = new System.Windows.Forms.MenuItem();
|
||||
this.dlgOpen = new System.Windows.Forms.OpenFileDialog();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// dataGrid1
|
||||
//
|
||||
this.dataGrid1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.dataGrid1.Location = new System.Drawing.Point(0, 0);
|
||||
this.dataGrid1.Name = "dataGrid1";
|
||||
this.dataGrid1.ReadOnly = true;
|
||||
this.dataGrid1.Size = new System.Drawing.Size(632, 433);
|
||||
this.dataGrid1.TabIndex = 1;
|
||||
//
|
||||
// mainMenu1
|
||||
//
|
||||
this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
|
||||
this.mnuOpen,
|
||||
this.mnuImport,
|
||||
this.mnuExport,
|
||||
this.mnuImportOptions});
|
||||
//
|
||||
// mnuOpen
|
||||
//
|
||||
this.mnuOpen.Index = 0;
|
||||
this.mnuOpen.Text = "&Open CSV file";
|
||||
this.mnuOpen.Click += new System.EventHandler(this.mnuOpen_Click);
|
||||
//
|
||||
// mnuImport
|
||||
//
|
||||
this.mnuImport.Enabled = false;
|
||||
this.mnuImport.Index = 1;
|
||||
this.mnuImport.Text = "&Import data";
|
||||
this.mnuImport.Click += new System.EventHandler(this.mnuImport_Click);
|
||||
//
|
||||
// mnuExport
|
||||
//
|
||||
this.mnuExport.Index = 2;
|
||||
this.mnuExport.Text = "&Export data";
|
||||
this.mnuExport.Click += new System.EventHandler(this.mnuExport_Click);
|
||||
//
|
||||
// mnuImportOptions
|
||||
//
|
||||
this.mnuImportOptions.Index = 3;
|
||||
this.mnuImportOptions.Text = "&Duplicate import options";
|
||||
this.mnuImportOptions.Visible = false;
|
||||
//
|
||||
// dlgOpen
|
||||
//
|
||||
this.dlgOpen.DefaultExt = "csv";
|
||||
this.dlgOpen.Filter = "CSV files|*.csv";
|
||||
this.dlgOpen.Title = "Comma separated values client file";
|
||||
//
|
||||
// ImportWorkorderCategory
|
||||
//
|
||||
this.AutoScaleBaseSize = new System.Drawing.Size(6, 15);
|
||||
this.ClientSize = new System.Drawing.Size(632, 433);
|
||||
this.Controls.Add(this.dataGrid1);
|
||||
this.Menu = this.mainMenu1;
|
||||
this.Name = "ImportWorkorderCategory";
|
||||
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
|
||||
this.Load += new System.EventHandler(this.Form1_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//
|
||||
// _________ __
|
||||
// \_ ___ \ __ __ _______/ |_ ____ _____
|
||||
// / \ \/ | | \ / ___/\ __\ / _ \ / \
|
||||
// \ \____| | / \___ \ | | ( <_> )| Y Y \
|
||||
// \______ /|____/ /____ > |__| \____/ |__|_| /
|
||||
// \/ \/ \/
|
||||
// _________ .___
|
||||
// \_ ___ \ ____ __| _/ ____
|
||||
// / \ \/ / _ \ / __ | _/ __ \
|
||||
// \ \____( <_> )/ /_/ | \ ___/
|
||||
// \______ / \____/ \____ | \___ >
|
||||
// \/ \/ \/
|
||||
|
||||
|
||||
|
||||
|
||||
#region Form load and login
|
||||
private void Form1_Load(object sender, System.EventArgs e)
|
||||
{
|
||||
|
||||
{
|
||||
System.Reflection.Assembly a = System.Reflection.Assembly.GetExecutingAssembly();
|
||||
string sVersion = "AyaNova® Workorder category import / export " + AyaBizUtils.DisplayVersion(a.GetName().Version);
|
||||
System.Diagnostics.FileVersionInfo fileVersion = System.Diagnostics.FileVersionInfo.GetVersionInfo(a.Location);
|
||||
if (fileVersion.FileBuildPart > 0)
|
||||
sVersion += " (Patch " + fileVersion.FileBuildPart.ToString() + ")";
|
||||
this.Text = sVersion;
|
||||
}
|
||||
|
||||
|
||||
MessageBox.Show(
|
||||
"Confirm that you have a backup copy of your AyaNova database before proceeding.\r\n\r\n" +
|
||||
"There is no undo function for importing data other than restoring from a pre-import backup copy.\r\n\r\n" +
|
||||
"** If you are not 100% certain that you have a *working* backup copy ready, stop now **",
|
||||
"ACCIDENTS HAPPEN: DO NOT IMPORT WITHOUT A GOOD BACKUP!");
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Read import file
|
||||
private DataTable dtItems;
|
||||
|
||||
private FHWorkorderCategory[] records;
|
||||
private void mnuOpen_Click(object sender, System.EventArgs e)
|
||||
{
|
||||
|
||||
if(dlgOpen.ShowDialog()!=DialogResult.OK) return;
|
||||
this.mnuImport.Enabled=false;
|
||||
if(dtItems==null)
|
||||
{
|
||||
dtItems=new DataTable("CSVItems");
|
||||
dtItems.Columns.Add("Name",typeof(string));
|
||||
dtItems.Columns.Add("Description", typeof(string));
|
||||
|
||||
}
|
||||
else
|
||||
dtItems.Rows.Clear();
|
||||
|
||||
FileHelperEngine engine = new FileHelperEngine(typeof(FHWorkorderCategory));
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
records= (FHWorkorderCategory[]) engine.ReadFile(dlgOpen.FileName);
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
MessageBox.Show("Error reading the .csv file:\r\n\r\n" + ex.Message);
|
||||
return;
|
||||
}
|
||||
|
||||
string sMax="The first 25 records only";
|
||||
if(records.GetLength(0)<25)
|
||||
sMax="All records";
|
||||
MessageBox.Show(records.GetLength(0).ToString() + " records were read in from the .csv file.\r\n\r\n" +
|
||||
sMax+" will be displayed for you to confirm the fields\r\n" +
|
||||
"and check that the data is displaying correctly before importing.\r\n\r\n" +
|
||||
"If any field doesn't appear correctly you must create a new .csv file with the correct\r\n" +
|
||||
"column order before importing or data will be imported into the wrong place in AyaNova");
|
||||
|
||||
//Maximum 25 records displayed
|
||||
int nMax=0;
|
||||
foreach(FHWorkorderCategory c in records)
|
||||
{
|
||||
|
||||
dtItems.Rows.Add(
|
||||
new object[]{c.Name, c.Description});
|
||||
nMax++;
|
||||
if(nMax>24) break;
|
||||
}
|
||||
|
||||
|
||||
dataGrid1.DataSource=dtItems;
|
||||
this.mnuImport.Enabled=true;
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Import data
|
||||
private WorkorderCategories PA = null;
|
||||
private bool ContainsItem(string name)
|
||||
{
|
||||
foreach (WorkorderCategory p in PA)
|
||||
{
|
||||
if (p.Name == name)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void mnuImport_Click(object sender, System.EventArgs e)
|
||||
{
|
||||
|
||||
if(records.GetLength(0)<1)
|
||||
{
|
||||
MessageBox.Show("There are no records to import");
|
||||
return;
|
||||
}
|
||||
|
||||
long lBadCount=0;
|
||||
long lGoodCount=0;
|
||||
Waiting w=new Waiting();
|
||||
w.Show();
|
||||
w.Ops="Importing items";
|
||||
PA = WorkorderCategories.GetItems();
|
||||
foreach(FHWorkorderCategory f in records)
|
||||
{
|
||||
|
||||
//If client has a name and doesn't already exist in the db then import it
|
||||
if(f.Name!=null && f.Name!="" && (!ContainsItem(t(255,f.Name))))
|
||||
{
|
||||
w.Step=t(255,f.Name);
|
||||
WorkorderCategory p=PA.Add();
|
||||
p.Active = true;
|
||||
p.Name = t(255, f.Name);
|
||||
p.Description = t(255, f.Description);
|
||||
|
||||
lGoodCount++;
|
||||
|
||||
}
|
||||
else
|
||||
lBadCount++;
|
||||
|
||||
|
||||
}
|
||||
if (lGoodCount > 0)
|
||||
{
|
||||
w.Step = "Saving...";
|
||||
PA.Save();
|
||||
}
|
||||
|
||||
w.Close();
|
||||
|
||||
if(lBadCount>0)
|
||||
MessageBox.Show(lGoodCount.ToString() + " items were imported sucessfully.\r\n" +
|
||||
lBadCount.ToString() + " items were not imported because an item with the same name already exists.");
|
||||
else
|
||||
MessageBox.Show(lGoodCount.ToString() + " items were imported sucessfully");
|
||||
|
||||
}
|
||||
|
||||
private static string t(int nLength, string s)
|
||||
{
|
||||
if(s==null || s=="") return "";
|
||||
if(s.Length<=nLength) return s;
|
||||
else
|
||||
return s.Substring(0,nLength);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Export data
|
||||
/// <summary>
|
||||
/// Exports all existing items to CSV format identical
|
||||
/// to that required for import
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void mnuExport_Click(object sender, System.EventArgs e)
|
||||
{
|
||||
SaveFileDialog sf = new SaveFileDialog();
|
||||
sf.DefaultExt = ".csv";
|
||||
sf.FileName = "WorkorderCategory.csv";
|
||||
if (sf.ShowDialog() != DialogResult.OK) return;
|
||||
|
||||
Cursor=Cursors.WaitCursor;
|
||||
FileHelperEngine engine = new FileHelperEngine(typeof(FHWorkorderCategory));
|
||||
System.Collections.ArrayList allItems = new ArrayList();
|
||||
FHWorkorderCategory fhc;
|
||||
PA = WorkorderCategories.GetItems();
|
||||
Waiting w=new Waiting();
|
||||
w.Show();
|
||||
w.Ops="Exporting items";
|
||||
foreach (WorkorderCategory p in PA)
|
||||
{
|
||||
fhc=new FHWorkorderCategory();
|
||||
w.Step=p.Name;
|
||||
fhc.Name=p.Name;
|
||||
fhc.Description = p.Description;
|
||||
|
||||
allItems.Add(fhc);
|
||||
|
||||
}
|
||||
w.Close();
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
engine.WriteFile(sf.FileName, (object[])allItems.ToArray(typeof(FHWorkorderCategory)));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
MessageBox.Show("Error writing the export file:\r\n\r\n" + ex.Message);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Cursor=Cursors.Default;
|
||||
MessageBox.Show("All Workorder category items in current AyaNova database have been exported to file:\r\n" +
|
||||
sf.FileName);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="mainMenu1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="dlgOpen.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>127, 17</value>
|
||||
</metadata>
|
||||
</root>
|
||||
@@ -0,0 +1,374 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Collections;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Forms;
|
||||
using System.Data;
|
||||
using GZTW.AyaNova.BLL;
|
||||
using System.Threading;
|
||||
using CSLA.Security;
|
||||
using FileHelpers;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace AyaNova.PlugIn.ImportExportCSV
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for Form1.
|
||||
/// </summary>
|
||||
public class ImportWorkorderItemType : System.Windows.Forms.Form
|
||||
{
|
||||
private System.Windows.Forms.DataGridView dataGrid1;
|
||||
private System.Windows.Forms.MainMenu mainMenu1;
|
||||
private System.Windows.Forms.MenuItem mnuOpen;
|
||||
private System.Windows.Forms.MenuItem mnuImport;
|
||||
private System.Windows.Forms.OpenFileDialog dlgOpen;
|
||||
private System.Windows.Forms.MenuItem mnuExport;
|
||||
private MenuItem mnuImportOptions;
|
||||
private IContainer components;
|
||||
|
||||
public ImportWorkorderItemType()
|
||||
{
|
||||
//
|
||||
// Required for Windows Form Designer support
|
||||
//
|
||||
InitializeComponent();
|
||||
|
||||
this.Icon = Resource.ImportExportCSV16icon;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
protected override void Dispose( bool disposing )
|
||||
{
|
||||
if( disposing )
|
||||
{
|
||||
if (components != null)
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
}
|
||||
base.Dispose( disposing );
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.dataGrid1 = new System.Windows.Forms.DataGridView();
|
||||
this.mainMenu1 = new System.Windows.Forms.MainMenu(this.components);
|
||||
this.mnuOpen = new System.Windows.Forms.MenuItem();
|
||||
this.mnuImport = new System.Windows.Forms.MenuItem();
|
||||
this.mnuExport = new System.Windows.Forms.MenuItem();
|
||||
this.mnuImportOptions = new System.Windows.Forms.MenuItem();
|
||||
this.dlgOpen = new System.Windows.Forms.OpenFileDialog();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// dataGrid1
|
||||
//
|
||||
this.dataGrid1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.dataGrid1.Location = new System.Drawing.Point(0, 0);
|
||||
this.dataGrid1.Name = "dataGrid1";
|
||||
this.dataGrid1.ReadOnly = true;
|
||||
this.dataGrid1.Size = new System.Drawing.Size(632, 433);
|
||||
this.dataGrid1.TabIndex = 1;
|
||||
//
|
||||
// mainMenu1
|
||||
//
|
||||
this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
|
||||
this.mnuOpen,
|
||||
this.mnuImport,
|
||||
this.mnuExport,
|
||||
this.mnuImportOptions});
|
||||
//
|
||||
// mnuOpen
|
||||
//
|
||||
this.mnuOpen.Index = 0;
|
||||
this.mnuOpen.Text = "&Open CSV file";
|
||||
this.mnuOpen.Click += new System.EventHandler(this.mnuOpen_Click);
|
||||
//
|
||||
// mnuImport
|
||||
//
|
||||
this.mnuImport.Enabled = false;
|
||||
this.mnuImport.Index = 1;
|
||||
this.mnuImport.Text = "&Import data";
|
||||
this.mnuImport.Click += new System.EventHandler(this.mnuImport_Click);
|
||||
//
|
||||
// mnuExport
|
||||
//
|
||||
this.mnuExport.Index = 2;
|
||||
this.mnuExport.Text = "&Export data";
|
||||
this.mnuExport.Click += new System.EventHandler(this.mnuExport_Click);
|
||||
//
|
||||
// mnuImportOptions
|
||||
//
|
||||
this.mnuImportOptions.Index = 3;
|
||||
this.mnuImportOptions.Text = "&Duplicate import options";
|
||||
this.mnuImportOptions.Visible = false;
|
||||
//
|
||||
// dlgOpen
|
||||
//
|
||||
this.dlgOpen.DefaultExt = "csv";
|
||||
this.dlgOpen.Filter = "CSV files|*.csv";
|
||||
this.dlgOpen.Title = "Comma separated values client file";
|
||||
//
|
||||
// ImportWorkorderItemType
|
||||
//
|
||||
this.AutoScaleBaseSize = new System.Drawing.Size(6, 15);
|
||||
this.ClientSize = new System.Drawing.Size(632, 433);
|
||||
this.Controls.Add(this.dataGrid1);
|
||||
this.Menu = this.mainMenu1;
|
||||
this.Name = "ImportWorkorderItemType";
|
||||
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
|
||||
this.Load += new System.EventHandler(this.Form1_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//
|
||||
// _________ __
|
||||
// \_ ___ \ __ __ _______/ |_ ____ _____
|
||||
// / \ \/ | | \ / ___/\ __\ / _ \ / \
|
||||
// \ \____| | / \___ \ | | ( <_> )| Y Y \
|
||||
// \______ /|____/ /____ > |__| \____/ |__|_| /
|
||||
// \/ \/ \/
|
||||
// _________ .___
|
||||
// \_ ___ \ ____ __| _/ ____
|
||||
// / \ \/ / _ \ / __ | _/ __ \
|
||||
// \ \____( <_> )/ /_/ | \ ___/
|
||||
// \______ / \____/ \____ | \___ >
|
||||
// \/ \/ \/
|
||||
|
||||
|
||||
|
||||
|
||||
#region Form load and login
|
||||
private void Form1_Load(object sender, System.EventArgs e)
|
||||
{
|
||||
|
||||
{
|
||||
System.Reflection.Assembly a = System.Reflection.Assembly.GetExecutingAssembly();
|
||||
string sVersion = "AyaNova® Workorder item type import / export " + AyaBizUtils.DisplayVersion(a.GetName().Version);
|
||||
System.Diagnostics.FileVersionInfo fileVersion = System.Diagnostics.FileVersionInfo.GetVersionInfo(a.Location);
|
||||
if (fileVersion.FileBuildPart > 0)
|
||||
sVersion += " (Patch " + fileVersion.FileBuildPart.ToString() + ")";
|
||||
this.Text = sVersion;
|
||||
}
|
||||
|
||||
|
||||
MessageBox.Show(
|
||||
"Confirm that you have a backup copy of your AyaNova database before proceeding.\r\n\r\n" +
|
||||
"There is no undo function for importing data other than restoring from a pre-import backup copy.\r\n\r\n" +
|
||||
"** If you are not 100% certain that you have a *working* backup copy ready, stop now **",
|
||||
"ACCIDENTS HAPPEN: DO NOT IMPORT WITHOUT A GOOD BACKUP!");
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Read import file
|
||||
private DataTable dtItems;
|
||||
|
||||
private FHWorkorderItemType[] records;
|
||||
private void mnuOpen_Click(object sender, System.EventArgs e)
|
||||
{
|
||||
|
||||
if(dlgOpen.ShowDialog()!=DialogResult.OK) return;
|
||||
this.mnuImport.Enabled=false;
|
||||
if(dtItems==null)
|
||||
{
|
||||
dtItems=new DataTable("CSVItems");
|
||||
dtItems.Columns.Add("Name",typeof(string));
|
||||
dtItems.Columns.Add("Description", typeof(string));
|
||||
|
||||
}
|
||||
else
|
||||
dtItems.Rows.Clear();
|
||||
|
||||
FileHelperEngine engine = new FileHelperEngine(typeof(FHWorkorderItemType));
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
records= (FHWorkorderItemType[]) engine.ReadFile(dlgOpen.FileName);
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
MessageBox.Show("Error reading the .csv file:\r\n\r\n" + ex.Message);
|
||||
return;
|
||||
}
|
||||
|
||||
string sMax="The first 25 records only";
|
||||
if(records.GetLength(0)<25)
|
||||
sMax="All records";
|
||||
MessageBox.Show(records.GetLength(0).ToString() + " records were read in from the .csv file.\r\n\r\n" +
|
||||
sMax+" will be displayed for you to confirm the fields\r\n" +
|
||||
"and check that the data is displaying correctly before importing.\r\n\r\n" +
|
||||
"If any field doesn't appear correctly you must create a new .csv file with the correct\r\n" +
|
||||
"column order before importing or data will be imported into the wrong place in AyaNova");
|
||||
|
||||
//Maximum 25 records displayed
|
||||
int nMax=0;
|
||||
foreach(FHWorkorderItemType c in records)
|
||||
{
|
||||
|
||||
dtItems.Rows.Add(
|
||||
new object[]{c.Name, c.Description});
|
||||
nMax++;
|
||||
if(nMax>24) break;
|
||||
}
|
||||
|
||||
|
||||
dataGrid1.DataSource=dtItems;
|
||||
this.mnuImport.Enabled=true;
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Import data
|
||||
private WorkorderItemTypes PA = null;
|
||||
private bool ContainsItem(string name)
|
||||
{
|
||||
foreach (WorkorderItemType p in PA)
|
||||
{
|
||||
if (p.Name == name)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void mnuImport_Click(object sender, System.EventArgs e)
|
||||
{
|
||||
|
||||
if(records.GetLength(0)<1)
|
||||
{
|
||||
MessageBox.Show("There are no records to import");
|
||||
return;
|
||||
}
|
||||
|
||||
long lBadCount=0;
|
||||
long lGoodCount=0;
|
||||
Waiting w=new Waiting();
|
||||
w.Show();
|
||||
w.Ops="Importing items";
|
||||
PA = WorkorderItemTypes.GetItems();
|
||||
foreach(FHWorkorderItemType f in records)
|
||||
{
|
||||
|
||||
//If client has a name and doesn't already exist in the db then import it
|
||||
if(f.Name!=null && f.Name!="" && (!ContainsItem(t(255,f.Name))))
|
||||
{
|
||||
w.Step=t(255,f.Name);
|
||||
WorkorderItemType p=PA.Add();
|
||||
p.Active = true;
|
||||
p.Name = t(255, f.Name);
|
||||
p.Description = t(255, f.Description);
|
||||
|
||||
lGoodCount++;
|
||||
|
||||
}
|
||||
else
|
||||
lBadCount++;
|
||||
|
||||
|
||||
}
|
||||
if (lGoodCount > 0)
|
||||
{
|
||||
w.Step = "Saving...";
|
||||
PA.Save();
|
||||
}
|
||||
|
||||
w.Close();
|
||||
|
||||
if(lBadCount>0)
|
||||
MessageBox.Show(lGoodCount.ToString() + " items were imported sucessfully.\r\n" +
|
||||
lBadCount.ToString() + " items were not imported because an item with the same name already exists.");
|
||||
else
|
||||
MessageBox.Show(lGoodCount.ToString() + " items were imported sucessfully");
|
||||
|
||||
}
|
||||
|
||||
private static string t(int nLength, string s)
|
||||
{
|
||||
if(s==null || s=="") return "";
|
||||
if(s.Length<=nLength) return s;
|
||||
else
|
||||
return s.Substring(0,nLength);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Export data
|
||||
/// <summary>
|
||||
/// Exports all existing items to CSV format identical
|
||||
/// to that required for import
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void mnuExport_Click(object sender, System.EventArgs e)
|
||||
{
|
||||
SaveFileDialog sf = new SaveFileDialog();
|
||||
sf.DefaultExt = ".csv";
|
||||
sf.FileName = "WorkorderItemType.csv";
|
||||
if (sf.ShowDialog() != DialogResult.OK) return;
|
||||
|
||||
Cursor=Cursors.WaitCursor;
|
||||
FileHelperEngine engine = new FileHelperEngine(typeof(FHWorkorderItemType));
|
||||
System.Collections.ArrayList allItems = new ArrayList();
|
||||
FHWorkorderItemType fhc;
|
||||
PA = WorkorderItemTypes.GetItems();
|
||||
Waiting w=new Waiting();
|
||||
w.Show();
|
||||
w.Ops="Exporting items";
|
||||
foreach (WorkorderItemType p in PA)
|
||||
{
|
||||
fhc=new FHWorkorderItemType();
|
||||
w.Step=p.Name;
|
||||
fhc.Name=p.Name;
|
||||
fhc.Description = p.Description;
|
||||
|
||||
allItems.Add(fhc);
|
||||
|
||||
}
|
||||
w.Close();
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
engine.WriteFile(sf.FileName, (object[])allItems.ToArray(typeof(FHWorkorderItemType)));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
MessageBox.Show("Error writing the export file:\r\n\r\n" + ex.Message);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Cursor=Cursors.Default;
|
||||
MessageBox.Show("All Workorder item types in current AyaNova database have been exported to file:\r\n" +
|
||||
sf.FileName);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="mainMenu1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="dlgOpen.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>127, 17</value>
|
||||
</metadata>
|
||||
</root>
|
||||
@@ -0,0 +1,412 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Collections;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Forms;
|
||||
using System.Data;
|
||||
using GZTW.AyaNova.BLL;
|
||||
using System.Threading;
|
||||
using CSLA.Security;
|
||||
using FileHelpers;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace AyaNova.PlugIn.ImportExportCSV
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for Form1.
|
||||
/// </summary>
|
||||
public class ImportWorkorderStatus : System.Windows.Forms.Form
|
||||
{
|
||||
private System.Windows.Forms.DataGridView dataGrid1;
|
||||
private System.Windows.Forms.MainMenu mainMenu1;
|
||||
private System.Windows.Forms.MenuItem mnuOpen;
|
||||
private System.Windows.Forms.MenuItem mnuImport;
|
||||
private System.Windows.Forms.OpenFileDialog dlgOpen;
|
||||
private System.Windows.Forms.MenuItem mnuExport;
|
||||
private MenuItem mnuImportOptions;
|
||||
private IContainer components;
|
||||
|
||||
public ImportWorkorderStatus()
|
||||
{
|
||||
//
|
||||
// Required for Windows Form Designer support
|
||||
//
|
||||
InitializeComponent();
|
||||
|
||||
this.Icon = Resource.ImportExportCSV16icon;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
protected override void Dispose( bool disposing )
|
||||
{
|
||||
if( disposing )
|
||||
{
|
||||
if (components != null)
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
}
|
||||
base.Dispose( disposing );
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.dataGrid1 = new System.Windows.Forms.DataGridView();
|
||||
this.mainMenu1 = new System.Windows.Forms.MainMenu(this.components);
|
||||
this.mnuOpen = new System.Windows.Forms.MenuItem();
|
||||
this.mnuImport = new System.Windows.Forms.MenuItem();
|
||||
this.mnuExport = new System.Windows.Forms.MenuItem();
|
||||
this.mnuImportOptions = new System.Windows.Forms.MenuItem();
|
||||
this.dlgOpen = new System.Windows.Forms.OpenFileDialog();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// dataGrid1
|
||||
//
|
||||
this.dataGrid1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.dataGrid1.Location = new System.Drawing.Point(0, 0);
|
||||
this.dataGrid1.Name = "dataGrid1";
|
||||
this.dataGrid1.ReadOnly = true;
|
||||
this.dataGrid1.Size = new System.Drawing.Size(632, 433);
|
||||
this.dataGrid1.TabIndex = 1;
|
||||
//
|
||||
// mainMenu1
|
||||
//
|
||||
this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
|
||||
this.mnuOpen,
|
||||
this.mnuImport,
|
||||
this.mnuExport,
|
||||
this.mnuImportOptions});
|
||||
//
|
||||
// mnuOpen
|
||||
//
|
||||
this.mnuOpen.Index = 0;
|
||||
this.mnuOpen.Text = "&Open CSV file";
|
||||
this.mnuOpen.Click += new System.EventHandler(this.mnuOpen_Click);
|
||||
//
|
||||
// mnuImport
|
||||
//
|
||||
this.mnuImport.Enabled = false;
|
||||
this.mnuImport.Index = 1;
|
||||
this.mnuImport.Text = "&Import data";
|
||||
this.mnuImport.Click += new System.EventHandler(this.mnuImport_Click);
|
||||
//
|
||||
// mnuExport
|
||||
//
|
||||
this.mnuExport.Index = 2;
|
||||
this.mnuExport.Text = "&Export data";
|
||||
this.mnuExport.Click += new System.EventHandler(this.mnuExport_Click);
|
||||
//
|
||||
// mnuImportOptions
|
||||
//
|
||||
this.mnuImportOptions.Index = 3;
|
||||
this.mnuImportOptions.Text = "&Duplicate import options";
|
||||
this.mnuImportOptions.Visible = false;
|
||||
//
|
||||
// dlgOpen
|
||||
//
|
||||
this.dlgOpen.DefaultExt = "csv";
|
||||
this.dlgOpen.Filter = "CSV files|*.csv";
|
||||
this.dlgOpen.Title = "Comma separated values client file";
|
||||
//
|
||||
// ImportWorkorderStatus
|
||||
//
|
||||
this.AutoScaleBaseSize = new System.Drawing.Size(6, 15);
|
||||
this.ClientSize = new System.Drawing.Size(632, 433);
|
||||
this.Controls.Add(this.dataGrid1);
|
||||
this.Menu = this.mainMenu1;
|
||||
this.Name = "ImportWorkorderStatus";
|
||||
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
|
||||
this.Load += new System.EventHandler(this.Form1_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//
|
||||
// _________ __
|
||||
// \_ ___ \ __ __ _______/ |_ ____ _____
|
||||
// / \ \/ | | \ / ___/\ __\ / _ \ / \
|
||||
// \ \____| | / \___ \ | | ( <_> )| Y Y \
|
||||
// \______ /|____/ /____ > |__| \____/ |__|_| /
|
||||
// \/ \/ \/
|
||||
// _________ .___
|
||||
// \_ ___ \ ____ __| _/ ____
|
||||
// / \ \/ / _ \ / __ | _/ __ \
|
||||
// \ \____( <_> )/ /_/ | \ ___/
|
||||
// \______ / \____/ \____ | \___ >
|
||||
// \/ \/ \/
|
||||
|
||||
|
||||
#region Form load and login
|
||||
private void Form1_Load(object sender, System.EventArgs e)
|
||||
{
|
||||
|
||||
{
|
||||
System.Reflection.Assembly a = System.Reflection.Assembly.GetExecutingAssembly();
|
||||
string sVersion = "AyaNova® WorkorderStatus import / export " + AyaBizUtils.DisplayVersion(a.GetName().Version);
|
||||
System.Diagnostics.FileVersionInfo fileVersion = System.Diagnostics.FileVersionInfo.GetVersionInfo(a.Location);
|
||||
if (fileVersion.FileBuildPart > 0)
|
||||
sVersion += " (Patch " + fileVersion.FileBuildPart.ToString() + ")";
|
||||
this.Text = sVersion;
|
||||
}
|
||||
|
||||
|
||||
MessageBox.Show(
|
||||
"Confirm that you have a backup copy of your AyaNova database before proceeding.\r\n\r\n" +
|
||||
"There is no undo function for importing data other than restoring from a pre-import backup copy.\r\n\r\n" +
|
||||
"** If you are not 100% certain that you have a *working* backup copy ready, stop now **",
|
||||
"ACCIDENTS HAPPEN: DO NOT IMPORT WITHOUT A GOOD BACKUP!");
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Read import file
|
||||
private DataTable dtItems;
|
||||
|
||||
private FHWorkorderStatus[] records;
|
||||
private void mnuOpen_Click(object sender, System.EventArgs e)
|
||||
{
|
||||
|
||||
if(dlgOpen.ShowDialog()!=DialogResult.OK) return;
|
||||
this.mnuImport.Enabled=false;
|
||||
if(dtItems==null)
|
||||
{
|
||||
dtItems=new DataTable("CSVAssemblies");
|
||||
dtItems.Columns.Add("Name",typeof(string));
|
||||
dtItems.Columns.Add("Description", typeof(string));
|
||||
dtItems.Columns.Add("ARGB", typeof(string));
|
||||
|
||||
}
|
||||
else
|
||||
dtItems.Rows.Clear();
|
||||
|
||||
FileHelperEngine engine = new FileHelperEngine(typeof(FHWorkorderStatus));
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
records= (FHWorkorderStatus[]) engine.ReadFile(dlgOpen.FileName);
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
MessageBox.Show("Error reading the .csv file:\r\n\r\n" + ex.Message);
|
||||
return;
|
||||
}
|
||||
|
||||
string sMax="The first 25 records only";
|
||||
if(records.GetLength(0)<25)
|
||||
sMax="All records";
|
||||
MessageBox.Show(records.GetLength(0).ToString() + " records were read in from the .csv file.\r\n\r\n" +
|
||||
sMax+" will be displayed for you to confirm the fields\r\n" +
|
||||
"and check that the data is displaying correctly before importing.\r\n\r\n" +
|
||||
"If any field doesn't appear correctly you must create a new .csv file with the correct\r\n" +
|
||||
"column order before importing or data will be imported into the wrong place in AyaNova");
|
||||
|
||||
//Maximum 25 records displayed
|
||||
int nMax=0;
|
||||
foreach(FHWorkorderStatus c in records)
|
||||
{
|
||||
|
||||
dtItems.Rows.Add(
|
||||
new object[]{c.Name, c.Description, c.ARGB});
|
||||
nMax++;
|
||||
if(nMax>24) break;
|
||||
}
|
||||
|
||||
|
||||
dataGrid1.DataSource=dtItems;
|
||||
this.mnuImport.Enabled=true;
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Import data
|
||||
private WorkorderStatuses PA = null;
|
||||
private bool ContainsItem(string name)
|
||||
{
|
||||
foreach (WorkorderStatus p in PA)
|
||||
{
|
||||
if (p.Name == name)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void mnuImport_Click(object sender, System.EventArgs e)
|
||||
{
|
||||
|
||||
if(records.GetLength(0)<1)
|
||||
{
|
||||
MessageBox.Show("There are no records to import");
|
||||
return;
|
||||
}
|
||||
|
||||
long lBadCount=0;
|
||||
long lGoodCount=0;
|
||||
Waiting w=new Waiting();
|
||||
w.Show();
|
||||
w.Ops="Importing items";
|
||||
PA = WorkorderStatuses.GetItems();
|
||||
foreach(FHWorkorderStatus f in records)
|
||||
{
|
||||
|
||||
//If client has a name and doesn't already exist in the db then import it
|
||||
if(f.Name!=null && f.Name!="" && (!ContainsItem(t(255,f.Name))))
|
||||
{
|
||||
w.Step=t(255,f.Name);
|
||||
WorkorderStatus p=PA.Add();
|
||||
p.Active = true;
|
||||
p.Name = t(255, f.Name);
|
||||
p.Description = t(255, f.Description);
|
||||
string sArgb=t(255,f.ARGB);
|
||||
////try to set ARGB, if it's unparseable or empty then the
|
||||
////default will take effect based on workorderStatus constructor (-1 white)
|
||||
//if (!string.IsNullOrEmpty(sArgb))
|
||||
//{
|
||||
// int n = 0;
|
||||
// if (int.TryParse(sArgb, out n))
|
||||
// {
|
||||
// p.ARGB = n;
|
||||
// }
|
||||
//}
|
||||
|
||||
//try to set ARGB in HEX FORMAT, if it's unparseable or empty then the
|
||||
//default will take effect based on Priority constructor (-1 white)
|
||||
if (!string.IsNullOrEmpty(sArgb))
|
||||
{
|
||||
p.ARGB = argbFromHexString(sArgb);
|
||||
}
|
||||
|
||||
|
||||
lGoodCount++;
|
||||
|
||||
}
|
||||
else
|
||||
lBadCount++;
|
||||
|
||||
|
||||
}
|
||||
if (lGoodCount > 0)
|
||||
{
|
||||
w.Step = "Saving...";
|
||||
PA.Save();
|
||||
}
|
||||
|
||||
w.Close();
|
||||
|
||||
if(lBadCount>0)
|
||||
MessageBox.Show(lGoodCount.ToString() + " items were imported sucessfully.\r\n" +
|
||||
lBadCount.ToString() + " items were not imported because an item with the same name already exists.");
|
||||
else
|
||||
MessageBox.Show(lGoodCount.ToString() + " items were imported sucessfully");
|
||||
|
||||
}
|
||||
|
||||
private static string t(int nLength, string s)
|
||||
{
|
||||
if(s==null || s=="") return "";
|
||||
if(s.Length<=nLength) return s;
|
||||
else
|
||||
return s.Substring(0,nLength);
|
||||
}
|
||||
|
||||
|
||||
//Note returns white value if anything
|
||||
//doesn't parse
|
||||
private static int argbFromHexString(string sHex)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(sHex))
|
||||
{
|
||||
sHex = sHex.Trim();
|
||||
//leading hash important for translator
|
||||
if (!sHex.StartsWith("#"))
|
||||
sHex = "#" + sHex;
|
||||
return System.Drawing.ColorTranslator.FromHtml(sHex).ToArgb();
|
||||
}
|
||||
//empty return white
|
||||
return System.Drawing.Color.White.ToArgb();
|
||||
}
|
||||
|
||||
private static string ArgbToHex(int intArgb)
|
||||
{
|
||||
return ColorTranslator.ToHtml(Color.FromArgb(intArgb));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Export data
|
||||
/// <summary>
|
||||
/// Exports all existing items to CSV format identical
|
||||
/// to that required for import
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void mnuExport_Click(object sender, System.EventArgs e)
|
||||
{
|
||||
SaveFileDialog sf = new SaveFileDialog();
|
||||
sf.DefaultExt = ".csv";
|
||||
sf.FileName = "WorkorderStatus.csv";
|
||||
if (sf.ShowDialog() != DialogResult.OK) return;
|
||||
|
||||
Cursor=Cursors.WaitCursor;
|
||||
FileHelperEngine engine = new FileHelperEngine(typeof(FHWorkorderStatus));
|
||||
System.Collections.ArrayList allItems = new ArrayList();
|
||||
FHWorkorderStatus fhc;
|
||||
PA = WorkorderStatuses.GetItems();
|
||||
Waiting w=new Waiting();
|
||||
w.Show();
|
||||
w.Ops="Exporting items";
|
||||
foreach (WorkorderStatus p in PA)
|
||||
{
|
||||
fhc=new FHWorkorderStatus();
|
||||
w.Step=p.Name;
|
||||
fhc.Name=p.Name;
|
||||
fhc.Description = p.Description;
|
||||
//fhc.ARGB = p.ARGB.ToString();
|
||||
fhc.ARGB = ArgbToHex(p.ARGB);
|
||||
allItems.Add(fhc);
|
||||
|
||||
}
|
||||
w.Close();
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
engine.WriteFile(sf.FileName, (object[])allItems.ToArray(typeof(FHWorkorderStatus)));
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
MessageBox.Show("Error writing the export file:\r\n\r\n" + ex.Message);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Cursor=Cursors.Default;
|
||||
MessageBox.Show("All Workorder status items in current AyaNova database have been exported to file:\r\n" +
|
||||
sf.FileName);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="mainMenu1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="dlgOpen.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>127, 17</value>
|
||||
</metadata>
|
||||
</root>
|
||||
@@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("AyaNova.PlugIn.ImportExportCSV")]
|
||||
[assembly: AssemblyDescription("CSV format import export utility")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Ground Zero Tech-Works Inc.")]
|
||||
[assembly: AssemblyProduct("AyaNova.PlugIn.ImportExportCSV")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2006-2018")]
|
||||
[assembly: AssemblyTrademark("AyaNova is a registered trademark of Ground Zero Tech-Works Inc.")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("f65e05f3-b83e-4dcc-9210-670a95c2ec1b")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("7.5.0.0")]
|
||||
[assembly: AssemblyFileVersion("7.5.1.0")]
|
||||
84
source/Plugins/AyaNova.PlugIn.ImportExportCSV/Resource.Designer.cs
generated
Normal file
84
source/Plugins/AyaNova.PlugIn.ImportExportCSV/Resource.Designer.cs
generated
Normal file
@@ -0,0 +1,84 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.1
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace AyaNova.PlugIn.ImportExportCSV {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resource {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resource() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("AyaNova.PlugIn.ImportExportCSV.Resource", typeof(Resource).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
internal static System.Drawing.Bitmap ImportExportCSV16 {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("ImportExportCSV16", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
internal static System.Drawing.Icon ImportExportCSV16icon {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("ImportExportCSV16icon", resourceCulture);
|
||||
return ((System.Drawing.Icon)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
internal static System.Drawing.Bitmap ImportExportCSV32 {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("ImportExportCSV32", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
130
source/Plugins/AyaNova.PlugIn.ImportExportCSV/Resource.resx
Normal file
130
source/Plugins/AyaNova.PlugIn.ImportExportCSV/Resource.resx
Normal file
@@ -0,0 +1,130 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="ImportExportCSV16" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>Resource\ImportExportCSV16.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="ImportExportCSV16icon" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>Resource\ImportExportCSV16icon.ico;System.Drawing.Icon, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="ImportExportCSV32" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>Resource\ImportExportCSV32.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
</root>
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 848 B |
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.8 KiB |
524
source/Plugins/AyaNova.PlugIn.ImportExportCSV/Util.cs
Normal file
524
source/Plugins/AyaNova.PlugIn.ImportExportCSV/Util.cs
Normal file
@@ -0,0 +1,524 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using GZTW.AyaNova.BLL;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace AyaNova.PlugIn.ImportExportCSV
|
||||
{
|
||||
public static class Util
|
||||
{
|
||||
public static System.Resources.ResourceManager AyaRes = null;
|
||||
public static bool LicensedMode = false;
|
||||
private static Integration _IECSVIntegrationData = null;
|
||||
private static IECSVData _IEData = null;
|
||||
public static Guid PluginID
|
||||
{
|
||||
get { return new Guid("{46BC31D2-3132-4b43-8789-120604573A08}"); }
|
||||
}
|
||||
|
||||
public static IECSVData IEData
|
||||
{
|
||||
get
|
||||
{
|
||||
#region retrieve / create
|
||||
if (_IECSVIntegrationData == null)
|
||||
{
|
||||
if (Integration.IntegrationExists(PluginID))
|
||||
{
|
||||
_IECSVIntegrationData = Integration.GetItem(PluginID);
|
||||
|
||||
_IEData = new IECSVData();
|
||||
|
||||
if (_IECSVIntegrationData.AIObject == null || _IECSVIntegrationData.AIObject.ToString() == "")
|
||||
{
|
||||
_IECSVIntegrationData.AIObject = _IEData.XMLData;
|
||||
_IECSVIntegrationData = (Integration)_IECSVIntegrationData.Save();
|
||||
}
|
||||
else
|
||||
{
|
||||
//All normal, parse xml and move on
|
||||
_IEData.XMLData = (string)_IECSVIntegrationData.AIObject;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_IECSVIntegrationData = Integration.NewItem(PluginID);
|
||||
_IECSVIntegrationData.Active = true;
|
||||
_IECSVIntegrationData.AppVersion = "6.3+";
|
||||
_IECSVIntegrationData.Name = "AyaNova ImportExportCSV - Plugin integration";
|
||||
_IEData = new IECSVData();
|
||||
_IECSVIntegrationData.AIObject = _IEData.XMLData;
|
||||
_IECSVIntegrationData = (Integration)_IECSVIntegrationData.Save();
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
return _IEData;
|
||||
#endregion retrieve create
|
||||
}
|
||||
}
|
||||
|
||||
public static void SaveIntegrationData()
|
||||
{
|
||||
if (!_IEData.IsDirty) return;
|
||||
_IECSVIntegrationData.AIObject = _IEData.XMLData;
|
||||
_IECSVIntegrationData = (Integration)_IECSVIntegrationData.Save();
|
||||
_IEData.IsDirty = false;
|
||||
}
|
||||
|
||||
|
||||
public static void ShowOptionsDialog()
|
||||
{
|
||||
ImportUpdateOptions d = new ImportUpdateOptions();
|
||||
d.ShowDialog();
|
||||
d.Dispose();
|
||||
SaveIntegrationData();
|
||||
}
|
||||
|
||||
#region case 1588 Mapping
|
||||
/// <summary>
|
||||
/// case 1588 map of user choices for what data goes where used for import.
|
||||
/// </summary>
|
||||
/// <param name="grid"></param>
|
||||
/// <returns></returns>
|
||||
public static Dictionary<string, int> BuildGridImportMap(DataGridView grid)
|
||||
{
|
||||
Dictionary<string, int> lsMap = new Dictionary<string, int>(grid.ColumnCount);
|
||||
foreach (DataGridViewColumn cm in grid.Columns)
|
||||
{
|
||||
if (cm.HeaderCell.Value != null && !string.IsNullOrWhiteSpace(cm.HeaderCell.Value.ToString()))
|
||||
lsMap.Add(cm.HeaderCell.Value.ToString(), cm.Index);
|
||||
}
|
||||
|
||||
return lsMap;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the columns to their last used value from database
|
||||
/// </summary>
|
||||
/// <param name="grid"></param>
|
||||
/// <param name="objectType"></param>
|
||||
internal static void LoadGridMappings(DataGridView grid, RootObjectTypes objectType)
|
||||
{
|
||||
int nColumn = 0;
|
||||
//case 1762
|
||||
int GridColumnsCount = grid.Columns.Count;
|
||||
if (GridColumnsCount == 0) return;
|
||||
GridColumnsCount--;//account for zero based index
|
||||
|
||||
string sLastMapping = "";
|
||||
switch (objectType)
|
||||
{
|
||||
case RootObjectTypes.Client:
|
||||
sLastMapping = IEData.ClientLastMapping;
|
||||
break;
|
||||
case RootObjectTypes.Part:
|
||||
sLastMapping = IEData.PartLastMapping;
|
||||
break;
|
||||
case RootObjectTypes.Unit:
|
||||
sLastMapping = IEData.UnitLastMapping;
|
||||
break;
|
||||
case RootObjectTypes.PartAssembly:
|
||||
sLastMapping = IEData.AssemblyLastMapping;
|
||||
break;
|
||||
//case 2072
|
||||
case RootObjectTypes.WorkorderStatus:
|
||||
sLastMapping = IEData.WorkorderStatusLastMapping;
|
||||
break;
|
||||
case RootObjectTypes.WorkorderCategory:
|
||||
sLastMapping = IEData.WorkorderCategoryLastMapping;
|
||||
break;
|
||||
case RootObjectTypes.WorkorderItemType:
|
||||
sLastMapping = IEData.WorkorderItemTypeLastMapping;
|
||||
break;
|
||||
case RootObjectTypes.UnitServiceType:
|
||||
sLastMapping = IEData.UnitServiceTypeLastMapping;
|
||||
break;
|
||||
case RootObjectTypes.Priority:
|
||||
sLastMapping = IEData.PriorityLastMapping;
|
||||
break;
|
||||
case RootObjectTypes.PartCategory:
|
||||
sLastMapping = IEData.PartCategoryLastMapping;
|
||||
break;
|
||||
case RootObjectTypes.Rate:
|
||||
sLastMapping = IEData.RateLastMapping;
|
||||
break;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(sLastMapping))
|
||||
{
|
||||
//grid.SuspendLayout();
|
||||
string[] smap = sLastMapping.Split(',');
|
||||
foreach (string s in smap)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(s))
|
||||
{
|
||||
grid.Columns[nColumn].HeaderCell.Value = s;
|
||||
grid.Columns[nColumn].AutoSizeMode = DataGridViewAutoSizeColumnMode.ColumnHeader;
|
||||
}
|
||||
nColumn++;
|
||||
if (nColumn > GridColumnsCount)
|
||||
{
|
||||
// MessageBox.Show("Less columns in source than last import, skipping extra columns");
|
||||
break;
|
||||
}
|
||||
}
|
||||
//grid.PerformLayout();
|
||||
// grid.Invalidate();
|
||||
grid.AutoResizeColumns();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Save the last mappings to the database
|
||||
/// </summary>
|
||||
/// <param name="grid"></param>
|
||||
/// <param name="objectType"></param>
|
||||
internal static void SaveGridMappings(DataGridView grid, RootObjectTypes objectType)
|
||||
{
|
||||
|
||||
System.Text.StringBuilder sb = new StringBuilder();
|
||||
foreach (DataGridViewColumn cm in grid.Columns)
|
||||
{
|
||||
if (cm.HeaderCell.Value == null)
|
||||
sb.Append(",");
|
||||
else
|
||||
{
|
||||
sb.Append(cm.HeaderCell.Value.ToString());
|
||||
sb.Append(",");
|
||||
}
|
||||
}
|
||||
|
||||
//removing hanging comma
|
||||
if (sb.Length > 0)
|
||||
sb.Length = sb.Length - 1;
|
||||
|
||||
switch (objectType)
|
||||
{
|
||||
case RootObjectTypes.Client:
|
||||
IEData.ClientLastMapping = sb.ToString();
|
||||
break;
|
||||
case RootObjectTypes.Part:
|
||||
IEData.PartLastMapping = sb.ToString();
|
||||
break;
|
||||
case RootObjectTypes.Unit:
|
||||
IEData.UnitLastMapping = sb.ToString();
|
||||
break;
|
||||
case RootObjectTypes.PartAssembly:
|
||||
IEData.AssemblyLastMapping = sb.ToString();
|
||||
break;
|
||||
//case 2072
|
||||
case RootObjectTypes.WorkorderStatus:
|
||||
IEData.WorkorderStatusLastMapping = sb.ToString();
|
||||
break;
|
||||
case RootObjectTypes.WorkorderCategory:
|
||||
IEData.WorkorderCategoryLastMapping = sb.ToString();
|
||||
break;
|
||||
case RootObjectTypes.WorkorderItemType:
|
||||
IEData.WorkorderItemTypeLastMapping = sb.ToString();
|
||||
break;
|
||||
case RootObjectTypes.UnitServiceType:
|
||||
IEData.UnitServiceTypeLastMapping = sb.ToString();
|
||||
break;
|
||||
case RootObjectTypes.Priority:
|
||||
IEData.PriorityLastMapping = sb.ToString();
|
||||
break;
|
||||
case RootObjectTypes.PartCategory:
|
||||
IEData.PartCategoryLastMapping = sb.ToString();
|
||||
break;
|
||||
case RootObjectTypes.Rate:
|
||||
IEData.RateLastMapping = sb.ToString();
|
||||
break;
|
||||
}
|
||||
SaveIntegrationData();
|
||||
|
||||
}
|
||||
|
||||
|
||||
//abstracts out the common code in all import types
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="grid"></param>
|
||||
/// <param name="dt"></param>
|
||||
/// <param name="obtype"></param>
|
||||
public static void ReadCSV(DataGridView grid, ref System.Data.DataTable dt, RootObjectTypes obtype, string csvPath)
|
||||
{
|
||||
if (dt != null)
|
||||
{
|
||||
dt.Clear();
|
||||
dt = null;
|
||||
}
|
||||
|
||||
|
||||
bool bHasErrors = false;
|
||||
System.Text.StringBuilder sbErrors = new System.Text.StringBuilder();
|
||||
long lRecordsRead = 0;
|
||||
long lRecordsBad = 0;
|
||||
|
||||
Microsoft.VisualBasic.FileIO.TextFieldParser rdr = new Microsoft.VisualBasic.FileIO.TextFieldParser(csvPath);
|
||||
rdr.TextFieldType = Microsoft.VisualBasic.FileIO.FieldType.Delimited;
|
||||
rdr.SetDelimiters(",");
|
||||
rdr.TrimWhiteSpace = true;
|
||||
rdr.HasFieldsEnclosedInQuotes = true;
|
||||
|
||||
|
||||
List<string[]> lsRows = new List<string[]>();
|
||||
int nMaxRowFields = 0;
|
||||
|
||||
string[] sCurrentRow;
|
||||
while (!rdr.EndOfData)
|
||||
{
|
||||
try
|
||||
{
|
||||
sCurrentRow = rdr.ReadFields();
|
||||
if (sCurrentRow.Length > nMaxRowFields)
|
||||
nMaxRowFields = sCurrentRow.Length;
|
||||
lsRows.Add(sCurrentRow);
|
||||
|
||||
lRecordsRead++;
|
||||
}
|
||||
catch (Microsoft.VisualBasic.FileIO.MalformedLineException ex)
|
||||
{
|
||||
bHasErrors = true;
|
||||
sbErrors.Append("Line ");
|
||||
sbErrors.Append(ex.Message);
|
||||
sbErrors.Append(" is not valid and will be skipped.\r\n");
|
||||
lRecordsBad++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (bHasErrors)
|
||||
{
|
||||
MessageBox.Show(lRecordsBad.ToString() + " records were malformed and not able to be read:\r\n\r\n" + sbErrors.ToString());
|
||||
}
|
||||
|
||||
|
||||
MessageBox.Show(lRecordsRead.ToString() +
|
||||
" records were successfully read from the .csv file and will now be displayed\r\n" +
|
||||
" for you to set the order of the fields before importing.");
|
||||
|
||||
dt = new System.Data.DataTable("CSVData");
|
||||
for (int x = 0; x < nMaxRowFields; x++)
|
||||
{
|
||||
dt.Columns.Add("Column" + (x + 1).ToString(), typeof(string));
|
||||
}
|
||||
|
||||
foreach (string[] sRow in lsRows)
|
||||
{
|
||||
System.Data.DataRow dr = dt.NewRow();
|
||||
int nField = 0;
|
||||
foreach (string sField in sRow)
|
||||
{
|
||||
dr[nField] = sField;
|
||||
nField++;
|
||||
}
|
||||
dt.Rows.Add(dr);
|
||||
}
|
||||
|
||||
grid.DataSource = dt;
|
||||
|
||||
//Load last used grid mappings
|
||||
Util.LoadGridMappings(grid, obtype);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endregion mapping
|
||||
|
||||
#region case 3606 dupes
|
||||
|
||||
/// <summary>
|
||||
/// checks for all duplicates in AyaNova of relevant objects and
|
||||
/// presents a warning message if found
|
||||
/// </summary>
|
||||
public static void DupeCheck()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
|
||||
{
|
||||
var dupes = ClientPickList.DuplicateNameCheck();
|
||||
if (dupes.Count > 0)
|
||||
{
|
||||
sb.AppendLine("DUPLICATE CLIENT NAMES");
|
||||
sb.AppendLine("======================");
|
||||
sb.AppendLine(String.Join("\r\n", dupes));
|
||||
sb.AppendLine();
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
var dupes = VendorPickList.DuplicateNameCheck();
|
||||
if (dupes.Count > 0)
|
||||
{
|
||||
sb.AppendLine("DUPLICATE VENDOR NAMES");
|
||||
sb.AppendLine("======================");
|
||||
sb.AppendLine(String.Join("\r\n", dupes));
|
||||
sb.AppendLine();
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
var dupes = UnitPickList.DuplicateSerialCheck();
|
||||
if (dupes.Count > 0)
|
||||
{
|
||||
sb.AppendLine("DUPLICATE UNIT SERIAL NUMBERS");
|
||||
sb.AppendLine("=============================");
|
||||
sb.AppendLine(String.Join("\r\n", dupes));
|
||||
sb.AppendLine();
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
var dupes = UnitModelPickList.DuplicateNameCheck();
|
||||
if (dupes.Count > 0)
|
||||
{
|
||||
sb.AppendLine("DUPLICATE UNIT MODEL NAMES");
|
||||
sb.AppendLine("==========================");
|
||||
sb.AppendLine(String.Join("\r\n", dupes));
|
||||
sb.AppendLine();
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
var dupes = PartPickList.DuplicatePartNumberCheck();
|
||||
if (dupes.Count > 0)
|
||||
{
|
||||
sb.AppendLine("DUPLICATE PART NUMBERS");
|
||||
sb.AppendLine("======================");
|
||||
sb.AppendLine(String.Join("\r\n", dupes));
|
||||
sb.AppendLine();
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
var dupes = PartAssemblies.DuplicateNameCheck();
|
||||
if (dupes.Count > 0)
|
||||
{
|
||||
sb.AppendLine("DUPLICATE PART ASSEMBLY NAMES");
|
||||
sb.AppendLine("=============================");
|
||||
sb.AppendLine(String.Join("\r\n", dupes));
|
||||
sb.AppendLine();
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
var dupes = PartCategories.DuplicateNameCheck();
|
||||
if (dupes.Count > 0)
|
||||
{
|
||||
sb.AppendLine("DUPLICATE PART CATEGORY NAMES");
|
||||
sb.AppendLine("=============================");
|
||||
sb.AppendLine(String.Join("\r\n", dupes));
|
||||
sb.AppendLine();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
var dupes = PriorityPickList.DuplicateNameCheck();
|
||||
if (dupes.Count > 0)
|
||||
{
|
||||
sb.AppendLine("DUPLICATE PRIORITY NAMES");
|
||||
sb.AppendLine("========================");
|
||||
sb.AppendLine(String.Join("\r\n", dupes));
|
||||
sb.AppendLine();
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
var dupes = RatePickList.DuplicateNameCheck();
|
||||
if (dupes.Count > 0)
|
||||
{
|
||||
sb.AppendLine("DUPLICATE RATE NAMES");
|
||||
sb.AppendLine("====================");
|
||||
sb.AppendLine(String.Join("\r\n", dupes));
|
||||
sb.AppendLine();
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
var dupes = UnitServiceTypePickList.DuplicateNameCheck();
|
||||
if (dupes.Count > 0)
|
||||
{
|
||||
sb.AppendLine("DUPLICATE UNIT SERVICE TYPE NAMES");
|
||||
sb.AppendLine("=================================");
|
||||
sb.AppendLine(String.Join("\r\n", dupes));
|
||||
sb.AppendLine();
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
var dupes = WorkorderCategories.DuplicateNameCheck();
|
||||
if (dupes.Count > 0)
|
||||
{
|
||||
sb.AppendLine("DUPLICATE WORKORDER CATEGORY NAMES");
|
||||
sb.AppendLine("==================================");
|
||||
sb.AppendLine(String.Join("\r\n", dupes));
|
||||
sb.AppendLine();
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
var dupes = WorkorderItemTypePickList.DuplicateNameCheck();
|
||||
if (dupes.Count > 0)
|
||||
{
|
||||
sb.AppendLine("DUPLICATE WORKORDER ITEM TYPE NAMES");
|
||||
sb.AppendLine("===================================");
|
||||
sb.AppendLine(String.Join("\r\n", dupes));
|
||||
sb.AppendLine();
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
var dupes = WorkorderStatusPickList.DuplicateNameCheck();
|
||||
if (dupes.Count > 0)
|
||||
{
|
||||
sb.AppendLine("DUPLICATE WORKORDER STATUS NAMES");
|
||||
sb.AppendLine("================================");
|
||||
sb.AppendLine(String.Join("\r\n", dupes));
|
||||
sb.AppendLine();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (sb.Length > 0)
|
||||
{
|
||||
string sDupesWarning =
|
||||
"***** DUPLICATE ITEMS FOUND *****\r\n\r\n" +
|
||||
"The following list of objects in your AyaNova database contain duplicate names.\r\n\r\n" +
|
||||
"In order to protect the integrity of your data, you should either remove or rename\r\n" +
|
||||
"all duplicate named records before using this utility to avoid issues with incorrect matches:\r\n\r\n\r\n";
|
||||
CopyableMessageBox c = new CopyableMessageBox(sDupesWarning + sb.ToString());
|
||||
c.ShowDialog();
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//case 3606 Dupe checks
|
||||
public static void AddItemWithDupeCheck(string objectType, System.Collections.Hashtable ht, Guid id, string name)
|
||||
{
|
||||
if (!ht.ContainsKey(name))
|
||||
{
|
||||
ht.Add(name, id);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
|
||||
}//EOC
|
||||
}//EONS
|
||||
117
source/Plugins/AyaNova.PlugIn.ImportExportCSV/Waiting.cs
Normal file
117
source/Plugins/AyaNova.PlugIn.ImportExportCSV/Waiting.cs
Normal file
@@ -0,0 +1,117 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Collections;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace AyaNova.PlugIn.ImportExportCSV
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for Waiting.
|
||||
/// </summary>
|
||||
public class Waiting : System.Windows.Forms.Form
|
||||
{
|
||||
|
||||
private System.Windows.Forms.Label lblStep;
|
||||
private System.Windows.Forms.Label lblOps;
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.Container components = null;
|
||||
|
||||
public Waiting()
|
||||
{
|
||||
//
|
||||
// Required for Windows Form Designer support
|
||||
//
|
||||
InitializeComponent();
|
||||
|
||||
//
|
||||
// TODO: Add any constructor code after InitializeComponent call
|
||||
//
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
protected override void Dispose( bool disposing )
|
||||
{
|
||||
if( disposing )
|
||||
{
|
||||
if(components != null)
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
}
|
||||
base.Dispose( disposing );
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.lblOps = new System.Windows.Forms.Label();
|
||||
this.lblStep = new System.Windows.Forms.Label();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// lblOps
|
||||
//
|
||||
this.lblOps.Cursor = System.Windows.Forms.Cursors.AppStarting;
|
||||
this.lblOps.Dock = System.Windows.Forms.DockStyle.Top;
|
||||
this.lblOps.Font = new System.Drawing.Font("Microsoft Sans Serif", 11F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.lblOps.Location = new System.Drawing.Point(0, 0);
|
||||
this.lblOps.Name = "lblOps";
|
||||
this.lblOps.Size = new System.Drawing.Size(308, 32);
|
||||
this.lblOps.TabIndex = 0;
|
||||
//
|
||||
// lblStep
|
||||
//
|
||||
this.lblStep.Cursor = System.Windows.Forms.Cursors.AppStarting;
|
||||
this.lblStep.Dock = System.Windows.Forms.DockStyle.Top;
|
||||
this.lblStep.Font = new System.Drawing.Font("Microsoft Sans Serif", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.lblStep.Location = new System.Drawing.Point(0, 32);
|
||||
this.lblStep.Name = "lblStep";
|
||||
this.lblStep.Size = new System.Drawing.Size(308, 33);
|
||||
this.lblStep.TabIndex = 1;
|
||||
//
|
||||
// Waiting
|
||||
//
|
||||
this.AutoScaleBaseSize = new System.Drawing.Size(6, 15);
|
||||
this.BackColor = System.Drawing.SystemColors.Window;
|
||||
this.ClientSize = new System.Drawing.Size(308, 56);
|
||||
this.ControlBox = false;
|
||||
this.Controls.Add(this.lblStep);
|
||||
this.Controls.Add(this.lblOps);
|
||||
this.Cursor = System.Windows.Forms.Cursors.AppStarting;
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
|
||||
this.Name = "Waiting";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.Text = "Processing";
|
||||
this.TopMost = true;
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
public string Ops
|
||||
{
|
||||
set
|
||||
{
|
||||
lblOps.Text=value;
|
||||
this.Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
public string Step
|
||||
{
|
||||
set
|
||||
{
|
||||
lblStep.Text=value;
|
||||
this.Refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
120
source/Plugins/AyaNova.PlugIn.ImportExportCSV/Waiting.resx
Normal file
120
source/Plugins/AyaNova.PlugIn.ImportExportCSV/Waiting.resx
Normal file
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
Reference in New Issue
Block a user