This commit is contained in:
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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user