This commit is contained in:
2021-08-13 18:24:14 +00:00
parent 5a155c11fd
commit 5ea07cd003
4 changed files with 151 additions and 146 deletions

View File

@@ -127,9 +127,9 @@
this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label1.Location = new System.Drawing.Point(28, 201); this.label1.Location = new System.Drawing.Point(28, 201);
this.label1.Name = "label1"; this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(149, 16); this.label1.Size = new System.Drawing.Size(172, 16);
this.label1.TabIndex = 33; this.label1.TabIndex = 33;
this.label1.Text = "AyaNova 8 server URL:"; this.label1.Text = "AyaNova 8 server address:";
// //
// btnTest // btnTest
// //
@@ -153,7 +153,6 @@
this.label2.TabIndex = 36; this.label2.TabIndex = 36;
this.label2.Text = "Export will erase *all* data on AyaNova 8 Server"; this.label2.Text = "Export will erase *all* data on AyaNova 8 Server";
this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.label2.Click += new System.EventHandler(this.label2_Click);
// //
// lblPreRelease // lblPreRelease
// //

View File

@@ -18,6 +18,7 @@ namespace AyaNova.PlugIn.V8
private async void btnTest_Click(object sender, EventArgs e) private async void btnTest_Click(object sender, EventArgs e)
{ {
if (!ValidateAndCleanServerAddress()) return;
btnOk.Enabled=btnTest.Enabled = false; btnOk.Enabled=btnTest.Enabled = false;
var result = await util.TestUrlAsync(edServerUrl.Text); var result = await util.TestUrlAsync(edServerUrl.Text);
btnOk.Enabled = btnTest.Enabled = true; btnOk.Enabled = btnTest.Enabled = true;
@@ -32,6 +33,7 @@ namespace AyaNova.PlugIn.V8
} }
private async void btnOk_Click(object sender, EventArgs e) private async void btnOk_Click(object sender, EventArgs e)
{ {
if (!ValidateAndCleanServerAddress()) return;
btnOk.Enabled = btnTest.Enabled = false; btnOk.Enabled = btnTest.Enabled = false;
if (!util.Initialized) if (!util.Initialized)
{ {
@@ -39,6 +41,7 @@ namespace AyaNova.PlugIn.V8
if (result != "OK") if (result != "OK")
{ {
MessageBox.Show("Server could not be reached at that URL\n" + result); MessageBox.Show("Server could not be reached at that URL\n" + result);
btnOk.Enabled = btnTest.Enabled = true;
return; return;
} }
} }
@@ -46,6 +49,7 @@ namespace AyaNova.PlugIn.V8
if (!res) if (!res)
{ {
MessageBox.Show("AyaNova 8 SuperUser account login failed"); MessageBox.Show("AyaNova 8 SuperUser account login failed");
btnOk.Enabled = btnTest.Enabled = true;
return; return;
} }
btnOk.Enabled = btnTest.Enabled = true; btnOk.Enabled = btnTest.Enabled = true;
@@ -68,15 +72,35 @@ namespace AyaNova.PlugIn.V8
lblPreRelease.Text = util.PRE_RELEASE_VERSION_STRING; lblPreRelease.Text = util.PRE_RELEASE_VERSION_STRING;
#if (DEBUG) #if (DEBUG)
edServerUrl.Text = "192.168.1.56:7575"; edServerUrl.Text = "http://192.168.1.56:7575";
edUserName.Text = "superuser"; edUserName.Text = "superuser";
edPassword.Text = "l3tm3in"; edPassword.Text = "l3tm3in";
#endif #endif
} }
private void label2_Click(object sender, EventArgs e)
{
private bool ValidateAndCleanServerAddress()
{
var serverUrl=edServerUrl.Text;
Uri u;
try
{
u = new Uri(serverUrl);
var scheme = u.Scheme;
var host = u.Host;
var port = u.Port;
edServerUrl.Text= scheme + "://" + host + ":" + port + "/" + util.API_BASE_ROUTE;
}
catch (Exception ex)
{
MessageBox.Show("Server address not valid\n" + ex.Message);
return false;
}
//ok, it's some kind of url, now format it for api access
return true;
} }

View File

@@ -2546,6 +2546,7 @@ namespace AyaNova.PlugIn.V8
╚══╝╚══╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝╚═════╝ ╚══════╝╚═╝ ╚═╝ ╚══╝╚══╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝╚═════╝ ╚══════╝╚═╝ ╚═╝
*/ */
#region Service Workorders #region Service Workorders
int _highestWorkOrderNumberExported = 0;
private async System.Threading.Tasks.Task ExportServiceWorkorders(ProgressForm progress) private async System.Threading.Tasks.Task ExportServiceWorkorders(ProgressForm progress)
{ {
if (!progress.KeepGoing) return; if (!progress.KeepGoing) return;
@@ -2585,6 +2586,8 @@ namespace AyaNova.PlugIn.V8
progress.Op(ObjectTypeName + " " + c.WorkorderService.ServiceNumber); progress.Op(ObjectTypeName + " " + c.WorkorderService.ServiceNumber);
d.serial = c.WorkorderService.ServiceNumber; d.serial = c.WorkorderService.ServiceNumber;
if (c.WorkorderService.ServiceNumber > _highestWorkOrderNumberExported)
_highestWorkOrderNumberExported = c.WorkorderService.ServiceNumber;
d.customerId = Getv7v8IdMap(c.ClientID, "Client for wo " + d.serial); d.customerId = Getv7v8IdMap(c.ClientID, "Client for wo " + d.serial);
d.notes = c.Summary; d.notes = c.Summary;
d.projectId = Getv7v8IdMapNullOk(c.ProjectID); d.projectId = Getv7v8IdMapNullOk(c.ProjectID);
@@ -2975,6 +2978,12 @@ namespace AyaNova.PlugIn.V8
}//items loop }//items loop
}//wo loop }//wo loop
//set new seed number for work orders
_highestWorkOrderNumberExported += 1;
{
await util.PutAsync("global-biz-settings/seeds/34/" + _highestWorkOrderNumberExported.ToString());
}
} }
#endregion Workorders #endregion Workorders
@@ -4861,129 +4870,129 @@ and this one
#region Seeds //#region Seeds
private class GZSeeds //private class GZSeeds
{
public int InventoryAdjustmentStartSeed = 1;
public int PurchaseOrderStartSeed = 1;
public int QuoteNumberStartSeed = 1;
public int WorkorderNumberStartSeed = 1;
public int PreventiveMaintenanceNumberStartSeed = 1;
}
private void ExportSeedNumbers(ProgressForm progress)
{
// List<string> objectExcludeProperties = new List<string>(standardExcludePropertiesList);
progress.Append("Dumping seeds");
//create a new object with the id numbers in it and then dump it
WorkorderPMList pml = WorkorderPMList.GetList("<?xml version=\"1.0\" encoding=\"utf-16\" standalone=\"yes\"?> \r\n" +
"<GRIDCRITERIA> \r\n" +
" <COLUMNITEM CM=\"aWorkorderPreventiveMaintenance.aPreventiveMaintenanceNumber\" UI=\"LT_O_WorkorderPreventiveMaintenance\" PIN=\"0\" WIDTH=\"150\" SORT=\"DESC\" /> \r\n" +
"</GRIDCRITERIA> ");
int PMStartSeed = 0;
if (pml.Count > 0)
{
PMStartSeed = int.Parse(pml[0].LT_O_WorkorderPreventiveMaintenance.Display);
}
var seeds = new GZSeeds();
seeds.InventoryAdjustmentStartSeed = AyaBizUtils.GlobalSettings.InventoryAdjustmentStartSeed + 1;
seeds.PurchaseOrderStartSeed = AyaBizUtils.GlobalSettings.PurchaseOrderStartSeed + 1;
seeds.QuoteNumberStartSeed = AyaBizUtils.GlobalSettings.QuoteNumberStartSeed + 1;
seeds.WorkorderNumberStartSeed = AyaBizUtils.GlobalSettings.WorkorderNumberStartSeed + 1;
seeds.PreventiveMaintenanceNumberStartSeed = PMStartSeed + 1;
//DumpObjectToFolder(tempArchiveFolder, seeds, "seeds", objectExcludeProperties, TypeAndID.Empty, "GZTW.AyaNova.BLL.Seed");
}
#endregion globalsettings
#region contract resolver
//public class ExcludeNamedPropertiesContractResolver : DefaultContractResolver
//{ //{
// private readonly List<string> _excludeProperties; // public int InventoryAdjustmentStartSeed = 1;
// public int PurchaseOrderStartSeed = 1;
// public ExcludeNamedPropertiesContractResolver(List<string> excludeProperties) // public int QuoteNumberStartSeed = 1;
// { // public int WorkorderNumberStartSeed = 1;
// _excludeProperties = excludeProperties; // public int PreventiveMaintenanceNumberStartSeed = 1;
// }
// protected override IList<JsonProperty> CreateProperties(Type type, MemberSerialization memberSerialization)
// {
// IList<JsonProperty> properties = base.CreateProperties(type, memberSerialization);
// // only serializer properties that start with the specified character
// //properties = properties.Where(p => p.PropertyName.StartsWith(_startingWithChar.ToString())).ToList();
// properties = properties.Where(p => !_excludeProperties.Contains(p.PropertyName)).ToList();
// return properties;
// }
//} //}
#endregion contract resolver //private void ExportSeedNumbers(ProgressForm progress)
//private static string EnsureValidFileName(string fileName)
//{ //{
// //make lower and replace spaces with dashes // // List<string> objectExcludeProperties = new List<string>(standardExcludePropertiesList);
// fileName = fileName.ToLowerInvariant().Replace(" ", "-"); // progress.Append("Dumping seeds");
// //create a new object with the id numbers in it and then dump it
// WorkorderPMList pml = WorkorderPMList.GetList("<?xml version=\"1.0\" encoding=\"utf-16\" standalone=\"yes\"?> \r\n" +
// "<GRIDCRITERIA> \r\n" +
// " <COLUMNITEM CM=\"aWorkorderPreventiveMaintenance.aPreventiveMaintenanceNumber\" UI=\"LT_O_WorkorderPreventiveMaintenance\" PIN=\"0\" WIDTH=\"150\" SORT=\"DESC\" /> \r\n" +
// "</GRIDCRITERIA> ");
// //ensure each character is a valid path character // int PMStartSeed = 0;
// foreach (char c in System.IO.Path.GetInvalidFileNameChars()) // if (pml.Count > 0)
// { // {
// fileName = fileName.Replace(c, '_'); // PMStartSeed = int.Parse(pml[0].LT_O_WorkorderPreventiveMaintenance.Display);
// } // }
// return fileName;
// var seeds = new GZSeeds();
// seeds.InventoryAdjustmentStartSeed = AyaBizUtils.GlobalSettings.InventoryAdjustmentStartSeed + 1;
// seeds.PurchaseOrderStartSeed = AyaBizUtils.GlobalSettings.PurchaseOrderStartSeed + 1;
// seeds.QuoteNumberStartSeed = AyaBizUtils.GlobalSettings.QuoteNumberStartSeed + 1;
// seeds.WorkorderNumberStartSeed = AyaBizUtils.GlobalSettings.WorkorderNumberStartSeed + 1;
// seeds.PreventiveMaintenanceNumberStartSeed = PMStartSeed + 1;
// //DumpObjectToFolder(tempArchiveFolder, seeds, "seeds", objectExcludeProperties, TypeAndID.Empty, "GZTW.AyaNova.BLL.Seed");
//} //}
//#endregion globalsettings
//private static void makeFolderIfNotExist(string fldr, bool shouldNotExist = false) //#region contract resolver
//{ ////public class ExcludeNamedPropertiesContractResolver : DefaultContractResolver
// if (Directory.Exists(fldr)) ////{
// { //// private readonly List<string> _excludeProperties;
// if (shouldNotExist)
// throw new System.Exception("Error: path already exists and shouldn't:\r\n" + fldr);
// return;
// }
// Directory.CreateDirectory(fldr);
//}
//private List<string> standardExcludePropertiesList //// public ExcludeNamedPropertiesContractResolver(List<string> excludeProperties)
//{ //// {
// get //// _excludeProperties = excludeProperties;
// { //// }
// return new List<string>()
// {
// "CanWiki",
// "CanDuplicate",
// "IsValid",
// "IsDirty",
// "CurrentUserID",
// "IsEditing",
// "IsNew",
// "IsDeleted",
// "IsSavable",
// "Notify",
// "BrokenRulesText",
// "Docs",
// "MapQuestURL",
// "FullAddress"
// //"XXX",
// //"XXX",
// //"XXX",
// //"XXX",
// //"XXX",
// //"XXX",
// //"XXX",
// //"XXX",
// //"XXX",
// //"XXX",
// //"XXX"
// };
// } //// protected override IList<JsonProperty> CreateProperties(Type type, MemberSerialization memberSerialization)
//} //// {
//// IList<JsonProperty> properties = base.CreateProperties(type, memberSerialization);
//// // only serializer properties that start with the specified character
//// //properties = properties.Where(p => p.PropertyName.StartsWith(_startingWithChar.ToString())).ToList();
//// properties = properties.Where(p => !_excludeProperties.Contains(p.PropertyName)).ToList();
//// return properties;
//// }
////}
//#endregion contract resolver
////private static string EnsureValidFileName(string fileName)
////{
//// //make lower and replace spaces with dashes
//// fileName = fileName.ToLowerInvariant().Replace(" ", "-");
//// //ensure each character is a valid path character
//// foreach (char c in System.IO.Path.GetInvalidFileNameChars())
//// {
//// fileName = fileName.Replace(c, '_');
//// }
//// return fileName;
////}
////private static void makeFolderIfNotExist(string fldr, bool shouldNotExist = false)
////{
//// if (Directory.Exists(fldr))
//// {
//// if (shouldNotExist)
//// throw new System.Exception("Error: path already exists and shouldn't:\r\n" + fldr);
//// return;
//// }
//// Directory.CreateDirectory(fldr);
////}
////private List<string> standardExcludePropertiesList
////{
//// get
//// {
//// return new List<string>()
//// {
//// "CanWiki",
//// "CanDuplicate",
//// "IsValid",
//// "IsDirty",
//// "CurrentUserID",
//// "IsEditing",
//// "IsNew",
//// "IsDeleted",
//// "IsSavable",
//// "Notify",
//// "BrokenRulesText",
//// "Docs",
//// "MapQuestURL",
//// "FullAddress"
//// //"XXX",
//// //"XXX",
//// //"XXX",
//// //"XXX",
//// //"XXX",
//// //"XXX",
//// //"XXX",
//// //"XXX",
//// //"XXX",
//// //"XXX",
//// //"XXX"
//// };
//// }
////}
#endregion old #endregion old
//eoc //eoc

View File

@@ -19,8 +19,8 @@ namespace AyaNova.PlugIn.V8
public static string PRE_RELEASE_VERSION_STRING { get; set; } public static string PRE_RELEASE_VERSION_STRING { get; set; }
public static GZTW.AyaNova.BLL.LocalizedTextTable LocaleText = null; public static GZTW.AyaNova.BLL.LocalizedTextTable LocaleText = null;
const string TEST_ROUTE = "notify/hello"; public const string TEST_ROUTE = "notify/hello";
const string API_BASE_ROUTE = "api/v8/"; public const string API_BASE_ROUTE = "api/v8/";
public static HttpClient client = new HttpClient(); public static HttpClient client = new HttpClient();
//url once known to be good //url once known to be good
internal static string ApiBaseUrl { get; set; } internal static string ApiBaseUrl { get; set; }
@@ -59,27 +59,8 @@ namespace AyaNova.PlugIn.V8
/// <returns></returns> /// <returns></returns>
public static async Task<string> TestUrlAsync(string serverUrl) public static async Task<string> TestUrlAsync(string serverUrl)
{ {
if (string.IsNullOrEmpty(serverUrl)) return "Server url required";
if (!serverUrl.Contains("/api/"))
{
if (!serverUrl.EndsWith("/")) serverUrl += "/";
serverUrl += API_BASE_ROUTE;
}
if (!serverUrl.StartsWith("http")) serverUrl = "http://" + serverUrl;
ApiBaseUrl = serverUrl; ApiBaseUrl = serverUrl;
InitClient(); InitClient();
//try to connect, ping the server api
//if (!Initialized)
//{
// client.BaseAddress = new Uri(serverUrl);
// client.DefaultRequestHeaders.Accept.Clear();
// client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
// Initialized = true;
//}
try try
{ {
// TimeSpan tsDefault = client.Timeout; // TimeSpan tsDefault = client.Timeout;
@@ -87,14 +68,9 @@ namespace AyaNova.PlugIn.V8
HttpResponseMessage response = await client.GetAsync(serverUrl + TEST_ROUTE); HttpResponseMessage response = await client.GetAsync(serverUrl + TEST_ROUTE);
// client.Timeout = tsDefault; // client.Timeout = tsDefault;
if (response.IsSuccessStatusCode) if (response.IsSuccessStatusCode)
{
return "OK"; return "OK";
}
else else
{
return "Failed: " + response.StatusCode.ToString(); return "Failed: " + response.StatusCode.ToString();
}
} }
catch (Exception ex) catch (Exception ex)
{ {
@@ -102,9 +78,6 @@ namespace AyaNova.PlugIn.V8
ex = ex.InnerException; ex = ex.InnerException;
return "Failed exception: \n" + ex.Message; return "Failed exception: \n" + ex.Message;
} }
// return "failed";
} }