This commit is contained in:
@@ -69,10 +69,154 @@ namespace AyaNovaQBI
|
||||
#endregion import
|
||||
|
||||
#region AUTOMATIC LINK
|
||||
private void autoLinkToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
private async void autoLinkToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
//Loop through the current AyaNova list
|
||||
//foreach unlinked item
|
||||
// loop through the qb current list and if any names match then
|
||||
// Link the two
|
||||
|
||||
bool SaveIntegration = false;
|
||||
|
||||
Waiting w = new Waiting();
|
||||
w.Show();
|
||||
w.Ops = "Autolinking matching items...";
|
||||
try
|
||||
{
|
||||
|
||||
switch (_Type)
|
||||
{
|
||||
|
||||
case AyaType.Customer:
|
||||
foreach (var i in util.AyaClientList)
|
||||
{
|
||||
if (i.Active)
|
||||
{
|
||||
IntegrationItem m = util.QBIntegration.Items.FirstOrDefault(z => z.ObjectId == i.Id && z.AType == _Type);
|
||||
if (m == null)
|
||||
{
|
||||
foreach (DataRow dr in util.QBClients.Rows)
|
||||
{
|
||||
if (i.Name == dr["FullName"].ToString())
|
||||
{
|
||||
w.Step = i.Name;
|
||||
m = new IntegrationItem { AType = _Type, IntegrationItemName = i.Name, IntegrationItemId = dr["ID"].ToString(), LastSync = System.DateTime.Now, ObjectId = i.Id };
|
||||
util.QBIntegration.Items.Add(m);
|
||||
SaveIntegration = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case AyaType.Vendor:
|
||||
foreach (var i in util.AyaVendorList)
|
||||
{
|
||||
if (i.Active)
|
||||
{
|
||||
IntegrationItem m = util.QBIntegration.Items.FirstOrDefault(z => z.ObjectId == i.Id && z.AType == _Type);
|
||||
if (m == null)
|
||||
{
|
||||
foreach (DataRow dr in util.QBVendors.Rows)
|
||||
{
|
||||
if (i.Name == dr["FullName"].ToString())
|
||||
{
|
||||
w.Step = i.Name;
|
||||
m = new IntegrationItem { AType = _Type, IntegrationItemName = i.Name, IntegrationItemId = dr["ID"].ToString(), LastSync = System.DateTime.Now, ObjectId = i.Id };
|
||||
util.QBIntegration.Items.Add(m);
|
||||
SaveIntegration = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case AyaType.ServiceRate:
|
||||
foreach (var i in util.AyaServiceRateList)
|
||||
{
|
||||
if (i.Active)
|
||||
{
|
||||
IntegrationItem m = util.QBIntegration.Items.FirstOrDefault(z => z.ObjectId == i.Id && z.AType == _Type);
|
||||
if (m == null)
|
||||
{
|
||||
foreach (DataRow dr in util.QBItems.Rows)
|
||||
{
|
||||
if (i.Name == dr["FullName"].ToString())
|
||||
{
|
||||
w.Step = i.Name;
|
||||
m = new IntegrationItem { AType = _Type, IntegrationItemName = i.Name, IntegrationItemId = dr["ID"].ToString(), LastSync = System.DateTime.Now, ObjectId = i.Id };
|
||||
util.QBIntegration.Items.Add(m);
|
||||
SaveIntegration = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case AyaType.TravelRate:
|
||||
foreach (var i in util.AyaServiceRateList)
|
||||
{
|
||||
if (i.Active)
|
||||
{
|
||||
IntegrationItem m = util.QBIntegration.Items.FirstOrDefault(z => z.ObjectId == i.Id && z.AType == _Type);
|
||||
if (m == null)
|
||||
{
|
||||
foreach (DataRow dr in util.QBItems.Rows)
|
||||
{
|
||||
if (i.Name == dr["FullName"].ToString())
|
||||
{
|
||||
w.Step = i.Name;
|
||||
m = new IntegrationItem { AType = _Type, IntegrationItemName = i.Name, IntegrationItemId = dr["ID"].ToString(), LastSync = System.DateTime.Now, ObjectId = i.Id };
|
||||
util.QBIntegration.Items.Add(m);
|
||||
SaveIntegration = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case AyaType.Part:
|
||||
foreach (var i in util.AyaPartList)
|
||||
{
|
||||
if (i.Active)
|
||||
{
|
||||
IntegrationItem m = util.QBIntegration.Items.FirstOrDefault(z => z.ObjectId == i.Id && z.AType == _Type);
|
||||
if (m == null)
|
||||
{
|
||||
foreach (DataRow dr in util.QBItems.Rows)
|
||||
{
|
||||
if (i.Name == dr["FullName"].ToString())
|
||||
{
|
||||
w.Step = i.Name;
|
||||
m = new IntegrationItem { AType = _Type, IntegrationItemName = i.Name, IntegrationItemId = dr["ID"].ToString(), LastSync = System.DateTime.Now, ObjectId = i.Id };
|
||||
util.QBIntegration.Items.Add(m);
|
||||
SaveIntegration = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
w.Visible = false;
|
||||
if (SaveIntegration)
|
||||
{
|
||||
await util.SaveIntegrationObject();
|
||||
Initialize();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
w.Visible = false;
|
||||
await util.CrackDisplayAndIntegrationLogException(ex, "QBI:Map:AutoLink");//case 3717
|
||||
}
|
||||
finally
|
||||
{
|
||||
w.Close();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion auto link
|
||||
|
||||
#region LINK MANUALLY
|
||||
@@ -582,6 +726,6 @@ namespace AyaNovaQBI
|
||||
|
||||
#endregion utility stuff
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user