This commit is contained in:
@@ -30,6 +30,15 @@ namespace AyaNova.PlugIn.V8
|
|||||||
}
|
}
|
||||||
private async void btnOk_Click(object sender, EventArgs e)
|
private async void btnOk_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
if (!util.Initialized)
|
||||||
|
{
|
||||||
|
var result = await util.TestUrlAsync(edServerUrl.Text);
|
||||||
|
if (result != "OK")
|
||||||
|
{
|
||||||
|
MessageBox.Show("Server could not be reached at that URL\n" + result);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
var res = await util.AuthenticateAsync(edUserName.Text,edPassword.Text);
|
var res = await util.AuthenticateAsync(edUserName.Text,edPassword.Text);
|
||||||
if (!res)
|
if (!res)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -125,11 +125,13 @@ namespace AyaNova.PlugIn.V8
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if(!DEBUG)
|
||||||
if (!AyaBizUtils.AyaNovaConnectionSetting.SingleUserConnection)
|
if (!AyaBizUtils.AyaNovaConnectionSetting.SingleUserConnection)
|
||||||
{
|
{
|
||||||
MessageBox.Show("** WARNING: before proceeding ensure no other users are logged into AyaNova to ensure the integrity of your exported data. Failing to do so *will* result in damaged data. ***");
|
MessageBox.Show("** WARNING: before proceeding ensure no other users are logged into AyaNova to ensure the integrity of your exported data. Failing to do so *will* result in damaged data. ***");
|
||||||
MessageBox.Show("** WARNING: before proceeding make sure your AyaNova Generator service is STOPPED to ensure the integrity of your exported data. Failing to do so *will* result in damaged data. ***");
|
MessageBox.Show("** WARNING: before proceeding make sure your AyaNova Generator service is STOPPED to ensure the integrity of your exported data. Failing to do so *will* result in damaged data. ***");
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
Auth d = new Auth();
|
Auth d = new Auth();
|
||||||
var res = d.ShowDialog(); ;
|
var res = d.ShowDialog(); ;
|
||||||
@@ -139,7 +141,7 @@ namespace AyaNova.PlugIn.V8
|
|||||||
}
|
}
|
||||||
//here because we logged in fine and can proceed
|
//here because we logged in fine and can proceed
|
||||||
|
|
||||||
MessageBox.Show("Login successful! JWT is " + util.JWT);
|
//MessageBox.Show("Login successful! JWT is " + util.JWT);
|
||||||
//Only one command
|
//Only one command
|
||||||
DoExport();
|
DoExport();
|
||||||
}
|
}
|
||||||
@@ -189,18 +191,9 @@ namespace AyaNova.PlugIn.V8
|
|||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//NOTE: when get to PRIORITY, or WORKORDER STATUS be sure to add color code as per already done in USER export
|
//NOTE: when get to PRIORITY, or WORKORDER STATUS be sure to add color code as per already done in USER export
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//progress.Append("Zipping up archive");
|
|
||||||
//FastZip fastZip = new FastZip();
|
|
||||||
//fastZip.CreateZip(zipName, tempArchiveFolder, true, null);
|
|
||||||
|
|
||||||
//progress.Append("Cleaning up temporary folder");
|
|
||||||
//Directory.Delete(tempArchiveFolder, true);
|
|
||||||
|
|
||||||
progress.Append("Export completed");
|
progress.Append("Export completed");
|
||||||
progress.FinishedImport();
|
progress.FinishedImport();
|
||||||
|
|
||||||
@@ -217,8 +210,8 @@ namespace AyaNova.PlugIn.V8
|
|||||||
private void ExportGlobalSettings(ProgressForm progress)
|
private void ExportGlobalSettings(ProgressForm progress)
|
||||||
{
|
{
|
||||||
List<string> objectExcludeProperties = new List<string>(standardExcludePropertiesList);
|
List<string> objectExcludeProperties = new List<string>(standardExcludePropertiesList);
|
||||||
progress.Append("Dumping Global Settings");
|
progress.Append("STUB: Dumping Global Settings");
|
||||||
DumpObjectToFolder(tempArchiveFolder, AyaBizUtils.GlobalSettings, "globalsettings", objectExcludeProperties, new TypeAndID(RootObjectTypes.Global, Address.GlobalAddressID));
|
////DumpObjectToFolder(tempArchiveFolder, AyaBizUtils.GlobalSettings, "globalsettings", objectExcludeProperties, new TypeAndID(RootObjectTypes.Global, Address.GlobalAddressID));
|
||||||
}
|
}
|
||||||
#endregion globalsettings
|
#endregion globalsettings
|
||||||
|
|
||||||
@@ -241,7 +234,7 @@ namespace AyaNova.PlugIn.V8
|
|||||||
if (!SkipLocales.Contains(i.Locale))
|
if (!SkipLocales.Contains(i.Locale))
|
||||||
{
|
{
|
||||||
LocalizedTextTable lt = LocalizedTextTable.Load(i.Locale);
|
LocalizedTextTable lt = LocalizedTextTable.Load(i.Locale);
|
||||||
DumpObjectToFolder(tempArchiveFolder, lt.LT, "translation." + EnsureValidFileName(i.Locale), objectExcludeProperties, TypeAndID.Empty, "GZTW.AyaNova.BLL.Translation");
|
//DumpObjectToFolder(tempArchiveFolder, lt.LT, "translation." + EnsureValidFileName(i.Locale), objectExcludeProperties, TypeAndID.Empty, "GZTW.AyaNova.BLL.Translation");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -259,7 +252,7 @@ namespace AyaNova.PlugIn.V8
|
|||||||
{
|
{
|
||||||
|
|
||||||
Region o = Region.GetItem(i.LT_Region_Label_Name.Value);
|
Region o = Region.GetItem(i.LT_Region_Label_Name.Value);
|
||||||
DumpObjectToFolder(tempArchiveFolder, o, "region." + o.ID.ToString(), objectExcludeProperties, new TypeAndID(RootObjectTypes.Region, o.ID));
|
//DumpObjectToFolder(tempArchiveFolder, o, "region." + o.ID.ToString(), objectExcludeProperties, new TypeAndID(RootObjectTypes.Region, o.ID));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -297,7 +290,7 @@ namespace AyaNova.PlugIn.V8
|
|||||||
seeds.WorkorderNumberStartSeed = AyaBizUtils.GlobalSettings.WorkorderNumberStartSeed + 1;
|
seeds.WorkorderNumberStartSeed = AyaBizUtils.GlobalSettings.WorkorderNumberStartSeed + 1;
|
||||||
seeds.PreventiveMaintenanceNumberStartSeed = PMStartSeed + 1;
|
seeds.PreventiveMaintenanceNumberStartSeed = PMStartSeed + 1;
|
||||||
|
|
||||||
DumpObjectToFolder(tempArchiveFolder, seeds, "seeds", objectExcludeProperties, TypeAndID.Empty, "GZTW.AyaNova.BLL.Seed");
|
//DumpObjectToFolder(tempArchiveFolder, seeds, "seeds", objectExcludeProperties, TypeAndID.Empty, "GZTW.AyaNova.BLL.Seed");
|
||||||
}
|
}
|
||||||
#endregion globalsettings
|
#endregion globalsettings
|
||||||
|
|
||||||
@@ -312,7 +305,7 @@ namespace AyaNova.PlugIn.V8
|
|||||||
foreach (ClientPickList.ClientPickListInfo i in pl)
|
foreach (ClientPickList.ClientPickListInfo i in pl)
|
||||||
{
|
{
|
||||||
Client c = Client.GetItem(i.ID);
|
Client c = Client.GetItem(i.ID);
|
||||||
DumpObjectToFolder(tempArchiveFolder, c, "client." + c.ID.ToString(), objectExcludeProperties, new TypeAndID(RootObjectTypes.Client, c.ID));
|
//DumpObjectToFolder(tempArchiveFolder, c, "client." + c.ID.ToString(), objectExcludeProperties, new TypeAndID(RootObjectTypes.Client, c.ID));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -330,7 +323,7 @@ namespace AyaNova.PlugIn.V8
|
|||||||
foreach (PickListAutoComplete.PickListAutoCompleteInfo i in pl)
|
foreach (PickListAutoComplete.PickListAutoCompleteInfo i in pl)
|
||||||
{
|
{
|
||||||
HeadOffice c = HeadOffice.GetItem(i.ID);
|
HeadOffice c = HeadOffice.GetItem(i.ID);
|
||||||
DumpObjectToFolder(tempArchiveFolder, c, "headoffice." + c.ID.ToString(), excludes, new TypeAndID(RootObjectTypes.HeadOffice, c.ID));
|
//DumpObjectToFolder(tempArchiveFolder, c, "headoffice." + c.ID.ToString(), excludes, new TypeAndID(RootObjectTypes.HeadOffice, c.ID));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion clients
|
#endregion clients
|
||||||
@@ -364,7 +357,7 @@ namespace AyaNova.PlugIn.V8
|
|||||||
JObject xtra = new JObject();
|
JObject xtra = new JObject();
|
||||||
xtra.Add("hexaScheduleBackColor", System.Drawing.ColorTranslator.ToHtml(System.Drawing.Color.FromArgb(c.ScheduleBackColor)));
|
xtra.Add("hexaScheduleBackColor", System.Drawing.ColorTranslator.ToHtml(System.Drawing.Color.FromArgb(c.ScheduleBackColor)));
|
||||||
|
|
||||||
DumpObjectToFolder(tempArchiveFolder, c, "user." + c.ID.ToString(), objectExcludeProperties, new TypeAndID(RootObjectTypes.User, c.ID), null, xtra);
|
//DumpObjectToFolder(tempArchiveFolder, c, "user." + c.ID.ToString(), objectExcludeProperties, new TypeAndID(RootObjectTypes.User, c.ID), null, xtra);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -456,59 +449,59 @@ namespace AyaNova.PlugIn.V8
|
|||||||
|
|
||||||
#region Dump
|
#region Dump
|
||||||
|
|
||||||
/// <summary>
|
// /// <summary>
|
||||||
/// Write out the object properties as JSON
|
// /// Write out the object properties as JSON
|
||||||
/// </summary>
|
// /// </summary>
|
||||||
/// <param name="tempArchiveFolder"></param>
|
// /// <param name="tempArchiveFolder"></param>
|
||||||
/// <param name="o"></param>
|
// /// <param name="o"></param>
|
||||||
private void ExportObjectToFolder(object o, string objectFileName, List<string> excludeProperties,
|
// private void ExportObjectToFolder(object o, string objectFileName, List<string> excludeProperties,
|
||||||
TypeAndID tid, string forceTypeString = "", JObject jExtra = null)
|
// TypeAndID tid, string forceTypeString = "", JObject jExtra = null)
|
||||||
{
|
// {
|
||||||
|
|
||||||
var typestring = o.GetType().ToString();
|
// var typestring = o.GetType().ToString();
|
||||||
if (!string.IsNullOrWhiteSpace(forceTypeString))
|
// if (!string.IsNullOrWhiteSpace(forceTypeString))
|
||||||
{
|
// {
|
||||||
typestring = forceTypeString;
|
// typestring = forceTypeString;
|
||||||
}
|
// }
|
||||||
|
|
||||||
var dumpFolder = tempArchiveFolder + Path.DirectorySeparatorChar + typestring;
|
// var dumpFolder = tempArchiveFolder + Path.DirectorySeparatorChar + typestring;
|
||||||
makeFolderIfNotExist(dumpFolder);
|
// makeFolderIfNotExist(dumpFolder);
|
||||||
|
|
||||||
var outputFileName = dumpFolder + Path.DirectorySeparatorChar + objectFileName + ".json";
|
// var outputFileName = dumpFolder + Path.DirectorySeparatorChar + objectFileName + ".json";
|
||||||
var wikiOutputPath = dumpFolder + Path.DirectorySeparatorChar + objectFileName + Path.DirectorySeparatorChar + "files";
|
// var wikiOutputPath = dumpFolder + Path.DirectorySeparatorChar + objectFileName + Path.DirectorySeparatorChar + "files";
|
||||||
|
|
||||||
JsonSerializer serializer = new JsonSerializer();
|
// JsonSerializer serializer = new JsonSerializer();
|
||||||
serializer.NullValueHandling = NullValueHandling.Include;
|
// serializer.NullValueHandling = NullValueHandling.Include;
|
||||||
serializer.ContractResolver = new ExcludeNamedPropertiesContractResolver(excludeProperties);
|
// serializer.ContractResolver = new ExcludeNamedPropertiesContractResolver(excludeProperties);
|
||||||
serializer.ReferenceLoopHandling = ReferenceLoopHandling.Serialize;
|
// serializer.ReferenceLoopHandling = ReferenceLoopHandling.Serialize;
|
||||||
|
|
||||||
|
|
||||||
#if(DEBUG)
|
//#if(DEBUG)
|
||||||
serializer.Formatting = Formatting.Indented;
|
// serializer.Formatting = Formatting.Indented;
|
||||||
#endif
|
//#endif
|
||||||
// serializer.Converters.Add(new JavaScriptDateTimeConverter());
|
// // serializer.Converters.Add(new JavaScriptDateTimeConverter());
|
||||||
// serializer.NullValueHandling = NullValueHandling.Ignore;
|
// // serializer.NullValueHandling = NullValueHandling.Ignore;
|
||||||
|
|
||||||
//generate file name, should be ID of object plus .json
|
// //generate file name, should be ID of object plus .json
|
||||||
|
|
||||||
JObject jo = JObject.FromObject(o, serializer);
|
// JObject jo = JObject.FromObject(o, serializer);
|
||||||
if (jExtra != null)
|
// if (jExtra != null)
|
||||||
{
|
// {
|
||||||
jo.Add("jextra", jExtra);
|
// jo.Add("jextra", jExtra);
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
using (StreamWriter sw = new StreamWriter(outputFileName))
|
// using (StreamWriter sw = new StreamWriter(outputFileName))
|
||||||
using (JsonWriter writer = new JsonTextWriter(sw))
|
// using (JsonWriter writer = new JsonTextWriter(sw))
|
||||||
{
|
// {
|
||||||
|
|
||||||
// serializer.Serialize(writer, o);
|
// // serializer.Serialize(writer, o);
|
||||||
serializer.Serialize(writer, jo);
|
// serializer.Serialize(writer, jo);
|
||||||
}
|
// }
|
||||||
|
|
||||||
//WIKI / ATTACHMENTS
|
// //WIKI / ATTACHMENTS
|
||||||
DumpWikiPageAndAttachments(tid, wikiOutputPath);
|
// DumpWikiPageAndAttachments(tid, wikiOutputPath);
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
//WIKI
|
//WIKI
|
||||||
@@ -540,76 +533,76 @@ namespace AyaNova.PlugIn.V8
|
|||||||
private void ExportWikiPageAndAttachments(TypeAndID tid, string wikiOutputPath)
|
private void ExportWikiPageAndAttachments(TypeAndID tid, string wikiOutputPath)
|
||||||
{
|
{
|
||||||
|
|
||||||
//may not exist
|
// //may not exist
|
||||||
if (!WikiPage.HasWiki(tid.ID)) return;
|
// if (!WikiPage.HasWiki(tid.ID)) return;
|
||||||
|
|
||||||
WikiPage w = WikiPage.GetItem(tid);
|
// WikiPage w = WikiPage.GetItem(tid);
|
||||||
var content = w.GetContentAsString;
|
// var content = w.GetContentAsString;
|
||||||
AyaFileList fl = AyaFileList.GetList(w.ID);
|
// AyaFileList fl = AyaFileList.GetList(w.ID);
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(content) && fl.Count < 1) return;
|
// if (string.IsNullOrWhiteSpace(content) && fl.Count < 1) return;
|
||||||
|
|
||||||
makeFolderIfNotExist(wikiOutputPath);
|
// makeFolderIfNotExist(wikiOutputPath);
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(content))
|
// if (!string.IsNullOrWhiteSpace(content))
|
||||||
{
|
// {
|
||||||
//write out the html wiki page
|
// //write out the html wiki page
|
||||||
File.WriteAllText(wikiOutputPath + Path.DirectorySeparatorChar + "w.html", content);
|
// File.WriteAllText(wikiOutputPath + Path.DirectorySeparatorChar + "w.html", content);
|
||||||
}
|
// }
|
||||||
|
|
||||||
//files
|
// //files
|
||||||
foreach (AyaFileList.AyaFileListInfo i in fl)
|
// foreach (AyaFileList.AyaFileListInfo i in fl)
|
||||||
{
|
// {
|
||||||
//WikiFileInfo fi = new WikiFileInfo();
|
// //WikiFileInfo fi = new WikiFileInfo();
|
||||||
// fi.Id = i.LT_O_AyaFile.Value.ToString();
|
// // fi.Id = i.LT_O_AyaFile.Value.ToString();
|
||||||
// fi.Name = i.LT_O_AyaFile.Display;
|
// // fi.Name = i.LT_O_AyaFile.Display;
|
||||||
// fi.Size = i.LT_AyaFile_Label_FileSize;
|
// // fi.Size = i.LT_AyaFile_Label_FileSize;
|
||||||
// fi.Creator = i.LT_Common_Label_Creator.Display;
|
// // fi.Creator = i.LT_Common_Label_Creator.Display;
|
||||||
// fi.Created = i.LT_Common_Label_Created.ToString();
|
// // fi.Created = i.LT_Common_Label_Created.ToString();
|
||||||
// ret.Add(fi);
|
// // ret.Add(fi);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//save each file plus file info into their own folder by ayafile id this is because ayafiles can be dupe names and we need the wiki info to fixup the last created date etc
|
// //save each file plus file info into their own folder by ayafile id this is because ayafiles can be dupe names and we need the wiki info to fixup the last created date etc
|
||||||
var filePath = wikiOutputPath + Path.DirectorySeparatorChar + i.LT_O_AyaFile.Value.ToString();
|
// var filePath = wikiOutputPath + Path.DirectorySeparatorChar + i.LT_O_AyaFile.Value.ToString();
|
||||||
makeFolderIfNotExist(filePath);//output/objectype/client.f861ec01-8bde-46e1-9849-fcee9b42f05e/files/d5461ec01-8bde-46e1-9849-fcee9b42f0ff34/
|
// makeFolderIfNotExist(filePath);//output/objectype/client.f861ec01-8bde-46e1-9849-fcee9b42f05e/files/d5461ec01-8bde-46e1-9849-fcee9b42f0ff34/
|
||||||
|
|
||||||
var af = AyaFile.GetItem(i.LT_O_AyaFile.Value);
|
// var af = AyaFile.GetItem(i.LT_O_AyaFile.Value);
|
||||||
if (af == null) continue;
|
// if (af == null) continue;
|
||||||
af.WriteToDisk(filePath, af.Name);
|
// af.WriteToDisk(filePath, af.Name);
|
||||||
|
|
||||||
var fileInfo = new
|
// var fileInfo = new
|
||||||
{
|
// {
|
||||||
name = i.LT_O_AyaFile.Display,
|
// name = i.LT_O_AyaFile.Display,
|
||||||
created = i.LT_Common_Label_Created,
|
// created = i.LT_Common_Label_Created,
|
||||||
creator = i.LT_Common_Label_Creator.Value,
|
// creator = i.LT_Common_Label_Creator.Value,
|
||||||
mimetype = af.mimeType,
|
// mimetype = af.mimeType,
|
||||||
id = af.ID,
|
// id = af.ID,
|
||||||
size = af.FileSize,
|
// size = af.FileSize,
|
||||||
ayafiletype = af.FileType,
|
// ayafiletype = af.FileType,
|
||||||
rootobjectid = af.RootObjectID,
|
// rootobjectid = af.RootObjectID,
|
||||||
rootobjecttype = af.RootObjectType
|
// rootobjecttype = af.RootObjectType
|
||||||
};
|
// };
|
||||||
|
|
||||||
JsonSerializer serializer = new JsonSerializer();
|
// JsonSerializer serializer = new JsonSerializer();
|
||||||
serializer.NullValueHandling = NullValueHandling.Include;
|
// serializer.NullValueHandling = NullValueHandling.Include;
|
||||||
|
|
||||||
#if(DEBUG)
|
//#if(DEBUG)
|
||||||
serializer.Formatting = Formatting.Indented;
|
// serializer.Formatting = Formatting.Indented;
|
||||||
#endif
|
//#endif
|
||||||
JObject jo = JObject.FromObject(fileInfo, serializer);
|
// JObject jo = JObject.FromObject(fileInfo, serializer);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
using (StreamWriter sw = new StreamWriter(filePath + Path.DirectorySeparatorChar + "meta.json"))
|
// using (StreamWriter sw = new StreamWriter(filePath + Path.DirectorySeparatorChar + "meta.json"))
|
||||||
using (JsonWriter writer = new JsonTextWriter(sw))
|
// using (JsonWriter writer = new JsonTextWriter(sw))
|
||||||
{
|
// {
|
||||||
|
|
||||||
// serializer.Serialize(writer, o);
|
// // serializer.Serialize(writer, o);
|
||||||
serializer.Serialize(writer, jo);
|
// serializer.Serialize(writer, jo);
|
||||||
}
|
// }
|
||||||
|
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion dump
|
#endregion dump
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ namespace AyaNova.PlugIn.V8
|
|||||||
//url once known to be good
|
//url once known to be good
|
||||||
internal static string ApiBaseUrl { get; set; }
|
internal static string ApiBaseUrl { get; set; }
|
||||||
internal static string JWT { get; set; }
|
internal static string JWT { get; set; }
|
||||||
static bool Initialized { get; set; }
|
public static bool Initialized { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user