This commit is contained in:
@@ -101,6 +101,7 @@ namespace AyaNovaQBI
|
||||
break;
|
||||
}
|
||||
}
|
||||
Initialize();
|
||||
}
|
||||
|
||||
#region Import to AyaNova
|
||||
|
||||
@@ -692,6 +692,7 @@ namespace AyaNovaQBI
|
||||
dtTemp.Columns.Add("Name", typeof(string));
|
||||
|
||||
bool present = true;
|
||||
List<NameIdItem> BadIntegrationItemIds = new List<NameIdItem>();
|
||||
foreach (IntegrationItem m in QBIntegration.Items)
|
||||
{
|
||||
present = true;
|
||||
@@ -712,13 +713,14 @@ namespace AyaNovaQBI
|
||||
}
|
||||
|
||||
if (!present)
|
||||
dtTemp.Rows.Add(new object[] { m.Id, m.AType.ToString() + ": " + m.IntegrationItemName });
|
||||
BadIntegrationItemIds.Add(new NameIdItem { Name = m.IntegrationItemName, Id = m.Id });
|
||||
//dtTemp.Rows.Add(new object[] { m.Id, m.AType.ToString() + ": " + m.IntegrationItemName });
|
||||
|
||||
}
|
||||
|
||||
if (dtTemp.Rows.Count > 0)
|
||||
if (BadIntegrationItemIds.Count > 0)
|
||||
{
|
||||
if (dtTemp.Rows.Count == QBIntegration.Items.Count)
|
||||
if (BadIntegrationItemIds.Count == QBIntegration.Items.Count)
|
||||
{
|
||||
//None of the items mapped match offer to remove them all
|
||||
#region Nothing matches
|
||||
@@ -738,9 +740,10 @@ namespace AyaNovaQBI
|
||||
{
|
||||
await IntegrationLog("PFC: User opted to remove all mappings after double warning.");
|
||||
QBIntegration.Items.Clear();
|
||||
//Exists, fetch it check if active then we're done here
|
||||
ApiResponse r = await PostAsync($"integration/{QBI_INTEGRATION_ID}", Newtonsoft.Json.JsonConvert.SerializeObject(QBIntegration));
|
||||
QBIntegration = r.ObjectResponse["data"].ToObject<Integration>();
|
||||
await SaveIntegrationObject();
|
||||
////Exists, fetch it check if active then we're done here
|
||||
//ApiResponse r = await PostAsync($"integration/{QBI_INTEGRATION_ID}", Newtonsoft.Json.JsonConvert.SerializeObject(QBIntegration));
|
||||
//QBIntegration = r.ObjectResponse["data"].ToObject<Integration>();
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -754,19 +757,29 @@ namespace AyaNovaQBI
|
||||
//some items match so iterate them and offer to delete one by one
|
||||
|
||||
await IntegrationLog("PFC: Some integration maps do not match qb database objects");
|
||||
foreach (DataRow row in dtTemp.Rows)
|
||||
//foreach (DataRow row in dtTemp.Rows)
|
||||
foreach(var bi in BadIntegrationItemIds)
|
||||
{
|
||||
|
||||
DialogResult dr = MessageBox.Show("Linked object: " + row["Name"].ToString() + "\r\n" +
|
||||
DialogResult dr = MessageBox.Show("Linked object: " + bi.Name + "\r\n" +
|
||||
"Is missing or set Inactive in QuickBooks.\r\n\r\nRemove it's link from AyaNova?", "", MessageBoxButtons.YesNoCancel,
|
||||
MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button3);
|
||||
if (dr == DialogResult.Cancel) return false;
|
||||
if (dr == DialogResult.Yes)
|
||||
QBIntegration.Items.Remove(QBIntegration.Items.Where(z => z.IntegrationItemId == row["MAPID"].ToString()).First());
|
||||
}
|
||||
{
|
||||
//var mapId = (long)row["MAPID"];
|
||||
var removeItem = QBIntegration.Items.Where(z => z.Id == bi.Id).First();
|
||||
//TODO: this needs to be a reverse for next loop
|
||||
bool bResult = QBIntegration.Items.Remove(bi);
|
||||
if (!bResult)
|
||||
MessageBox.Show("Error attempting to remove unmapped item; it could not be found in the map list");
|
||||
|
||||
ApiResponse r = await PostAsync($"integration/{QBI_INTEGRATION_ID}", Newtonsoft.Json.JsonConvert.SerializeObject(QBIntegration));
|
||||
QBIntegration = r.ObjectResponse["data"].ToObject<Integration>();
|
||||
}
|
||||
}
|
||||
await SaveIntegrationObject();
|
||||
|
||||
//ApiResponse r = await PostAsync($"integration/{QBI_INTEGRATION_ID}", Newtonsoft.Json.JsonConvert.SerializeObject(QBIntegration));
|
||||
//QBIntegration = r.ObjectResponse["data"].ToObject<Integration>();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user