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.Location = new System.Drawing.Point(28, 201);
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.Text = "AyaNova 8 server URL:";
this.label1.Text = "AyaNova 8 server address:";
//
// btnTest
//
@@ -153,7 +153,6 @@
this.label2.TabIndex = 36;
this.label2.Text = "Export will erase *all* data on AyaNova 8 Server";
this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.label2.Click += new System.EventHandler(this.label2_Click);
//
// lblPreRelease
//

View File

@@ -18,6 +18,7 @@ namespace AyaNova.PlugIn.V8
private async void btnTest_Click(object sender, EventArgs e)
{
if (!ValidateAndCleanServerAddress()) return;
btnOk.Enabled=btnTest.Enabled = false;
var result = await util.TestUrlAsync(edServerUrl.Text);
btnOk.Enabled = btnTest.Enabled = true;
@@ -32,6 +33,7 @@ namespace AyaNova.PlugIn.V8
}
private async void btnOk_Click(object sender, EventArgs e)
{
if (!ValidateAndCleanServerAddress()) return;
btnOk.Enabled = btnTest.Enabled = false;
if (!util.Initialized)
{
@@ -39,6 +41,7 @@ namespace AyaNova.PlugIn.V8
if (result != "OK")
{
MessageBox.Show("Server could not be reached at that URL\n" + result);
btnOk.Enabled = btnTest.Enabled = true;
return;
}
}
@@ -46,6 +49,7 @@ namespace AyaNova.PlugIn.V8
if (!res)
{
MessageBox.Show("AyaNova 8 SuperUser account login failed");
btnOk.Enabled = btnTest.Enabled = true;
return;
}
btnOk.Enabled = btnTest.Enabled = true;
@@ -68,15 +72,35 @@ namespace AyaNova.PlugIn.V8
lblPreRelease.Text = util.PRE_RELEASE_VERSION_STRING;
#if (DEBUG)
edServerUrl.Text = "192.168.1.56:7575";
edServerUrl.Text = "http://192.168.1.56:7575";
edUserName.Text = "superuser";
edPassword.Text = "l3tm3in";
#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
int _highestWorkOrderNumberExported = 0;
private async System.Threading.Tasks.Task ExportServiceWorkorders(ProgressForm progress)
{
if (!progress.KeepGoing) return;
@@ -2585,6 +2586,8 @@ namespace AyaNova.PlugIn.V8
progress.Op(ObjectTypeName + " " + 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.notes = c.Summary;
d.projectId = Getv7v8IdMapNullOk(c.ProjectID);
@@ -2975,6 +2978,12 @@ namespace AyaNova.PlugIn.V8
}//items loop
}//wo loop
//set new seed number for work orders
_highestWorkOrderNumberExported += 1;
{
await util.PutAsync("global-biz-settings/seeds/34/" + _highestWorkOrderNumberExported.ToString());
}
}
#endregion Workorders
@@ -4861,129 +4870,129 @@ and this one
#region Seeds
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
//#region Seeds
//private class GZSeeds
//{
// private readonly List<string> _excludeProperties;
// public ExcludeNamedPropertiesContractResolver(List<string> excludeProperties)
// {
// _excludeProperties = excludeProperties;
// }
// 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;
// }
// public int InventoryAdjustmentStartSeed = 1;
// public int PurchaseOrderStartSeed = 1;
// public int QuoteNumberStartSeed = 1;
// public int WorkorderNumberStartSeed = 1;
// public int PreventiveMaintenanceNumberStartSeed = 1;
//}
#endregion contract resolver
//private static string EnsureValidFileName(string fileName)
//private void ExportSeedNumbers(ProgressForm progress)
//{
// //make lower and replace spaces with dashes
// fileName = fileName.ToLowerInvariant().Replace(" ", "-");
// // 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> ");
// //ensure each character is a valid path character
// foreach (char c in System.IO.Path.GetInvalidFileNameChars())
// int PMStartSeed = 0;
// 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)
//{
// if (Directory.Exists(fldr))
// {
// if (shouldNotExist)
// throw new System.Exception("Error: path already exists and shouldn't:\r\n" + fldr);
// return;
// }
// Directory.CreateDirectory(fldr);
//}
//#region contract resolver
////public class ExcludeNamedPropertiesContractResolver : DefaultContractResolver
////{
//// private readonly List<string> _excludeProperties;
//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"
// };
//// public ExcludeNamedPropertiesContractResolver(List<string> excludeProperties)
//// {
//// _excludeProperties = excludeProperties;
//// }
// }
//}
//// 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
//eoc

View File

@@ -19,8 +19,8 @@ namespace AyaNova.PlugIn.V8
public static string PRE_RELEASE_VERSION_STRING { get; set; }
public static GZTW.AyaNova.BLL.LocalizedTextTable LocaleText = null;
const string TEST_ROUTE = "notify/hello";
const string API_BASE_ROUTE = "api/v8/";
public const string TEST_ROUTE = "notify/hello";
public const string API_BASE_ROUTE = "api/v8/";
public static HttpClient client = new HttpClient();
//url once known to be good
internal static string ApiBaseUrl { get; set; }
@@ -59,27 +59,8 @@ namespace AyaNova.PlugIn.V8
/// <returns></returns>
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;
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
{
// TimeSpan tsDefault = client.Timeout;
@@ -87,14 +68,9 @@ namespace AyaNova.PlugIn.V8
HttpResponseMessage response = await client.GetAsync(serverUrl + TEST_ROUTE);
// client.Timeout = tsDefault;
if (response.IsSuccessStatusCode)
{
return "OK";
}
else
{
return "Failed: " + response.StatusCode.ToString();
}
}
catch (Exception ex)
{
@@ -102,9 +78,6 @@ namespace AyaNova.PlugIn.V8
ex = ex.InnerException;
return "Failed exception: \n" + ex.Message;
}
// return "failed";
}